|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.plugins.Page; | 
|---|
|  |  |  | import com.core.annotations.ManagerAuth; | 
|---|
|  |  |  | import com.core.common.BaseRes; | 
|---|
|  |  |  | import com.core.common.Cools; | 
|---|
|  |  |  | import com.core.common.DateUtils; | 
|---|
|  |  |  | import com.core.common.R; | 
|---|
|  |  |  | import com.core.exception.CoolException; | 
|---|
|  |  |  | import com.zy.asrs.entity.Mat; | 
|---|
|  |  |  | import com.zy.asrs.entity.MatBarcode; | 
|---|
|  |  |  | import com.zy.asrs.entity.WaitPakin; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.CombParam; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.MobileAdjustParam; | 
|---|
|  |  |  | import com.zy.asrs.service.MatBarcodeService; | 
|---|
|  |  |  | import com.zy.asrs.service.MatService; | 
|---|
|  |  |  | import com.zy.asrs.service.MobileService; | 
|---|
|  |  |  | import com.zy.asrs.service.WaitPakinService; | 
|---|
|  |  |  | import com.zy.common.web.BaseController; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestBody; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestParam; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RestController; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | public class BarcodeMatnrController extends BaseController { | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MatBarcodeService matBarcodeService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MobileService mobileService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MatService matService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WaitPakinService waitPakinService; | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | * 物料托盘绑定分页查询 | 
|---|
|  |  |  | * */ | 
|---|
|  |  |  | 
|---|
|  |  |  | matBarcodeService.deleteMatBarcode(list); | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | * 批量组托 | 
|---|
|  |  |  | * */ | 
|---|
|  |  |  | @RequestMapping("/barcodeMatnr/matnrAndBarcode") | 
|---|
|  |  |  | @ManagerAuth(memo = "物料托盘批量组托") | 
|---|
|  |  |  | public R matnrAndBarcode(@RequestBody List<MatBarcode> list) { | 
|---|
|  |  |  | if (Cools.isEmpty(list)){ | 
|---|
|  |  |  | return R.error(BaseRes.PARAM); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (MatBarcode matBarcode : list) { | 
|---|
|  |  |  | if (!matBarcode.getZpallet().equals(list.get(0).getZpallet())){ | 
|---|
|  |  |  | throw new CoolException("请选择相同托盘码的数据"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | waitPakinService.comb(list); | 
|---|
|  |  |  | return R.ok("组托成功"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /*物料托盘绑定 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * */ | 
|---|
|  |  |  | @RequestMapping(value = "/barcodeMatnr/add/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R add(WaitPakin waitPakin) { | 
|---|
|  |  |  | if (Cools.isEmpty(waitPakin.getBarcode())||Cools.isEmpty(waitPakin.getModiUser())){ | 
|---|
|  |  |  | return R.error(BaseRes.PARAM); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | matBarcodeService.addBarcodeMatnr(waitPakin); | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /*组托 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * */ | 
|---|
|  |  |  | @RequestMapping(value = "/barcodeMatnr/add1/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R comb(WaitPakin waitPakin) { | 
|---|
|  |  |  | Mat mat = matService.selectById(waitPakin.getModiUser()); | 
|---|
|  |  |  | MatBarcode matBarcode = matBarcodeService.selectbyMatnr(mat.getMatnr()); | 
|---|
|  |  |  | if (matBarcode == null){ | 
|---|
|  |  |  | throw new CoolException("该物料未与托盘绑定"); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | if (!matBarcode.getZpallet().equals(waitPakin.getBarcode())){ | 
|---|
|  |  |  | throw new CoolException("该物料与其他托盘绑定,不能与当前托盘"+waitPakin.getBarcode()+"绑定,与该物料绑定的托盘是"+matBarcode.getZpallet()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (mat.getColor().equals("报废")){ | 
|---|
|  |  |  | throw new CoolException("该物料已报废,请勿绑定"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.isEmpty(waitPakin.getBarcode())||Cools.isEmpty(waitPakin.getModiUser())||Cools.isEmpty(waitPakin.getAnfme())){ | 
|---|
|  |  |  | return R.error(BaseRes.PARAM); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | mobileService.combToWms(waitPakin); | 
|---|
|  |  |  | return R.ok("组托成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /*并板 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * */ | 
|---|
|  |  |  | @RequestMapping(value = "/barcodeMatnr/add2/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R clamp(WaitPakin waitPakin) { | 
|---|
|  |  |  | if (Cools.isEmpty(waitPakin.getBarcode())||Cools.isEmpty(waitPakin.getModiUser())||Cools.isEmpty(waitPakin.getAnfme())){ | 
|---|
|  |  |  | return R.error(BaseRes.PARAM); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Mat mat = matService.selectById(waitPakin.getModiUser()); | 
|---|
|  |  |  | MatBarcode matBarcode = matBarcodeService.selectbyMatnr(mat.getMatnr()); | 
|---|
|  |  |  | if (matBarcode == null){ | 
|---|
|  |  |  | throw new CoolException("该物料未与托盘绑定"); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | if (!matBarcode.getZpallet().equals(waitPakin.getBarcode())){ | 
|---|
|  |  |  | throw new CoolException("该物料与其他托盘绑定,不能与当前托盘"+waitPakin.getBarcode()+"绑定,与该物料绑定的托盘是"+matBarcode.getZpallet()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | MobileAdjustParam combParam=new MobileAdjustParam(); | 
|---|
|  |  |  | ArrayList<CombParam.CombMat> combMats=new ArrayList<>(); | 
|---|
|  |  |  | CombParam.CombMat combMat=new CombParam.CombMat(); | 
|---|
|  |  |  | combMat.setMatnr(mat.getMatnr()); | 
|---|
|  |  |  | combMat.setMaktx(mat.getMaktx()); | 
|---|
|  |  |  | //        combMat.setAnfme(waitPakin.getAnfme()); | 
|---|
|  |  |  | combMat.setAnfme(1.0); | 
|---|
|  |  |  | combMats.add(combMat); | 
|---|
|  |  |  | combParam.setBarcode(waitPakin.getBarcode()); | 
|---|
|  |  |  | combParam.setCombMats(combMats); | 
|---|
|  |  |  | mobileService.adjustNew(combParam, Boolean.TRUE, getUserId()); | 
|---|
|  |  |  | return R.ok("并板成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|