|  |  |  | 
|---|
|  |  |  | import com.zy.common.utils.Synchro; | 
|---|
|  |  |  | import com.zy.common.web.BaseController; | 
|---|
|  |  |  | import com.zy.nc.entity.NccJcQilibcBarcodeflowWms; | 
|---|
|  |  |  | import com.zy.nc.entity.NccQilibcTmprintWms; | 
|---|
|  |  |  | import com.zy.nc.entity.NccSaleXclGgsybWms; | 
|---|
|  |  |  | import com.zy.nc.service.NccJcQilibcBarcodeflowWmsService; | 
|---|
|  |  |  | import com.zy.nc.service.NccQilibcTmprintWmsService; | 
|---|
|  |  |  | import com.zy.nc.service.NccSaleXclGgsybWmsService; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.annotation.Resource; | 
|---|
|  |  |  | import java.math.BigDecimal; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | private ManLocDetlMapper manLocDetlMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WrkDetlLogService wrkDetlLogService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WrkMastLogService wrkMastLogService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private StoreTypeService storeTypeService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MatService matService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NccJcQilibcBarcodeflowWmsService nccJcQilibcBarcodeflowWmsService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NccQilibcTmprintWmsService nccQilibcTmprintWmsService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NccSaleXclGgsybWmsService nccSaleXclGgsybWmsService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrderPakinService orderPakinService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | matParam.setWeight(nccJcQilibcBarcodeflowWms.getNastnum() == null ? 0.0D : nccJcQilibcBarcodeflowWms.getNastnum().doubleValue()); | 
|---|
|  |  |  | matParam.setAnfme2(nccJcQilibcBarcodeflowWms.getNastnum() == null ? 0.0D : nccJcQilibcBarcodeflowWms.getNastnum().doubleValue()); | 
|---|
|  |  |  | matParam.setTiaoma(nccJcQilibcBarcodeflowWms.getVbarcode()); | 
|---|
|  |  |  | matParam.setCstateid(nccJcQilibcBarcodeflowWms.getCstateid()); | 
|---|
|  |  |  | return R.ok().add(matParam); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/mat/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R pdaSearchV3(@RequestParam String matnr) { | 
|---|
|  |  |  | EntityWrapper<NccJcQilibcBarcodeflowWms> wrapper = new EntityWrapper<>(); | 
|---|
|  |  |  | wrapper.eq("VBARCODE", matnr).orderBy("ts", false); | 
|---|
|  |  |  | NccJcQilibcBarcodeflowWms nccJcQilibcBarcodeflowWms = nccJcQilibcBarcodeflowWmsService.selectOne(wrapper); | 
|---|
|  |  |  | if (null == nccJcQilibcBarcodeflowWms) { | 
|---|
|  |  |  | EntityWrapper<NccQilibcTmprintWms> wrapper = new EntityWrapper<>(); | 
|---|
|  |  |  | wrapper.eq("BARCODE", matnr).orderBy("PRINTTIME", false); | 
|---|
|  |  |  | NccQilibcTmprintWms nccQilibcTmprintWms = nccQilibcTmprintWmsService.selectOne(wrapper); | 
|---|
|  |  |  | if (null == nccQilibcTmprintWms) { | 
|---|
|  |  |  | return R.error("未找到此条码"); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | if (!nccJcQilibcBarcodeflowWms.getInfla().equals("出库")) { | 
|---|
|  |  |  | return R.error("该条码最后一次不是出库"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Mat mat = matService.selectByMatnr(nccJcQilibcBarcodeflowWms.getWlbm()); | 
|---|
|  |  |  | Mat mat = matService.selectByMatnr(nccQilibcTmprintWms.getWlbm()); | 
|---|
|  |  |  | MatParam matParam = new MatParam(); | 
|---|
|  |  |  | Synchro.Copy(mat, matParam); | 
|---|
|  |  |  | matParam.setBatch(nccJcQilibcBarcodeflowWms.getVbatchcode()); | 
|---|
|  |  |  | matParam.setAnfme(nccJcQilibcBarcodeflowWms.getAsnnum() == null ? 0.0D : nccJcQilibcBarcodeflowWms.getAsnnum().doubleValue()); | 
|---|
|  |  |  | matParam.setAnfme2(nccJcQilibcBarcodeflowWms.getNastnum() == null ? 0.0D : nccJcQilibcBarcodeflowWms.getNastnum().doubleValue()); | 
|---|
|  |  |  | matParam.setTiaoma(nccJcQilibcBarcodeflowWms.getVbarcode()); | 
|---|
|  |  |  | matParam.setBatch(nccQilibcTmprintWms.getVbatchcode()); | 
|---|
|  |  |  | //        matParam.setAnfme(nccQilibcTmprintWms.getAsnnum() == null ? 0.0D : nccQilibcTmprintWms.getAsnnum().doubleValue()); | 
|---|
|  |  |  | //        matParam.setAnfme2(nccQilibcTmprintWms.getNastnum() == null ? 0.0D : nccQilibcTmprintWms.getNastnum().doubleValue()); | 
|---|
|  |  |  | matParam.setAnfme(0.0D); | 
|---|
|  |  |  | matParam.setAnfme2(0.0D); | 
|---|
|  |  |  | matParam.setTiaoma(nccQilibcTmprintWms.getBarcode()); | 
|---|
|  |  |  | matParam.setStandby1(nccQilibcTmprintWms.getCkbm()); | 
|---|
|  |  |  | matParam.setCstateid(nccQilibcTmprintWms.getCstateid()); | 
|---|
|  |  |  | return R.ok().add(matParam); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/mat/back") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R pdaSearchBack(@RequestParam String barcode) { | 
|---|
|  |  |  | WrkMastLog wrkMastLog = wrkMastLogService.selectOne(new EntityWrapper<WrkMastLog>() | 
|---|
|  |  |  | .eq("barcode", barcode) | 
|---|
|  |  |  | .in("io_type", 101, 103, 107) | 
|---|
|  |  |  | .orderBy("appe_time", false) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(null == wrkMastLog) { | 
|---|
|  |  |  | return R.error("未找到此托盘码出库记录"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<WrkDetlLog> wrkDetlLogs = wrkDetlLogService.selectList(new EntityWrapper<WrkDetlLog>() | 
|---|
|  |  |  | .eq("wrk_no", wrkMastLog.getWrkNo()) | 
|---|
|  |  |  | .eq("zpallet", barcode) | 
|---|
|  |  |  | .orderBy("io_time", false) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if (wrkDetlLogs.isEmpty()) { | 
|---|
|  |  |  | return R.error("未找到此托盘码出库记录明细"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | WrkDetlLog wrkDetlLog = wrkDetlLogs.get(0); | 
|---|
|  |  |  | String batch = wrkDetlLog.getBatch(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | HashMap<String, Object> map = new HashMap<>(); | 
|---|
|  |  |  | Mat mat = matService.selectByMatnr(wrkDetlLog.getMatnr()); | 
|---|
|  |  |  | if (mat == null) { | 
|---|
|  |  |  | return R.error("未找到物料明细"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | MatParam matParam = new MatParam(); | 
|---|
|  |  |  | Synchro.Copy(mat, matParam); | 
|---|
|  |  |  | matParam.setBatch(batch); | 
|---|
|  |  |  | matParam.setAnfme(0.0D); | 
|---|
|  |  |  | matParam.setAnfme2(0.0D); | 
|---|
|  |  |  | matParam.setTiaoma(batch); | 
|---|
|  |  |  | matParam.setCstateid(wrkDetlLog.getCstateid()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String[] split = wrkDetlLog.getOrderNo().split("-"); | 
|---|
|  |  |  | map.put("orderNo", split[0]); | 
|---|
|  |  |  | map.put("matData", matParam); | 
|---|
|  |  |  | return R.ok().add(map); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/comb/cancel") | 
|---|
|  |  |  | @ManagerAuth(memo = "取消组托") | 
|---|
|  |  |  | public R combCancel(@RequestBody CombCancelParam param) { | 
|---|
|  |  |  | mobileService.combCancel(param, getUserId()); | 
|---|
|  |  |  | return R.ok("取消组托成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/comb/auth") | 
|---|
|  |  |  | @ManagerAuth(memo = "组托") | 
|---|
|  |  |  | public R comb(@RequestBody CombParam combParam) { | 
|---|
|  |  |  | mobileService.comb(combParam, getUserId()); | 
|---|
|  |  |  | return R.ok("组托成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/comb2/auth") | 
|---|
|  |  |  | @ManagerAuth(memo = "采购组托") | 
|---|
|  |  |  | public R comb2(@RequestBody CombParam combParam) { | 
|---|
|  |  |  | CombParam.CombMat combMat = combParam.getCombMats().get(0); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ArrayList<String> ckbmList = new ArrayList<>(); | 
|---|
|  |  |  | List<StoreType> storeTypes = storeTypeService.selectList(new EntityWrapper<StoreType>() | 
|---|
|  |  |  | .like("store_name", "立体库")); | 
|---|
|  |  |  | for (StoreType storeType : storeTypes) { | 
|---|
|  |  |  | ckbmList.add(storeType.getStoreId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //        NccSaleXclGgsybWms nccSaleXclGgsybWms = nccSaleXclGgsybWmsService.selectOne(new EntityWrapper<NccSaleXclGgsybWms>() | 
|---|
|  |  |  | //                .eq("WLBM", combMat.getMatnr()) | 
|---|
|  |  |  | //                .eq("VBATCHCODE", combMat.getBatch()) | 
|---|
|  |  |  | //                .in("CKBM", ckbmList) | 
|---|
|  |  |  | //        ); | 
|---|
|  |  |  | //        if(null == nccSaleXclGgsybWms) { | 
|---|
|  |  |  | //            return R.error("未查到ERP库存"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        //ERP库存数量 | 
|---|
|  |  |  | //        BigDecimal zsl = nccSaleXclGgsybWms.getZsl(); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        //获取立库数量 | 
|---|
|  |  |  | //        List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>() | 
|---|
|  |  |  | //                .eq("matnr", combMat.getMatnr()) | 
|---|
|  |  |  | //                .eq("batch", combMat.getBatch()) | 
|---|
|  |  |  | //        ); | 
|---|
|  |  |  | //        BigDecimal stockNum = new BigDecimal(0); | 
|---|
|  |  |  | //        for (LocDetl locDetl : locDetls) { | 
|---|
|  |  |  | //            stockNum = stockNum.add(BigDecimal.valueOf(locDetl.getAnfme())); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        //加上组托数量 | 
|---|
|  |  |  | //        for (CombParam.CombMat mat : combParam.getCombMats()) { | 
|---|
|  |  |  | //            stockNum = stockNum.add(BigDecimal.valueOf(mat.getAnfme())); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        if(stockNum.doubleValue() > zsl.doubleValue()) { | 
|---|
|  |  |  | //            return R.error("组托数量超过ERP库存"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        List<CombParam.CombMat> combMats = combParam.getCombMats(); | 
|---|
|  |  |  | //        for (CombParam.CombMat mat : combMats) { | 
|---|
|  |  |  | //            mat.setStandby1(nccSaleXclGgsybWms.getCkbm()); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mobileService.comb(combParam, getUserId()); | 
|---|
|  |  |  | return R.ok("组托成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok("出库成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/checkOut/submit/auth") | 
|---|
|  |  |  | @ManagerAuth(memo = "盘点上报ERP") | 
|---|
|  |  |  | public R checkOutSubmit(@RequestParam("orderId") Integer orderId) { | 
|---|
|  |  |  | mobileService.checkOutSubmit(orderId, getUserId()); | 
|---|
|  |  |  | return R.ok("上报ERP成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/pallet/toOutSta") | 
|---|
|  |  |  | @ManagerAuth(memo = "托盘去出库口") | 
|---|
|  |  |  | public R toOutSta(@RequestBody PalletToOutStaParam param) { | 
|---|
|  |  |  | mobileService.toOutSta(param, getUserId()); | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/pallet/toAllOut") | 
|---|
|  |  |  | @ManagerAuth(memo = "拣料转全板") | 
|---|
|  |  |  | public R toAllOut(@RequestBody PalletToAllOutParam param) { | 
|---|
|  |  |  | mobileService.toAllOut(param, getUserId()); | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|