| | |
| | | import com.core.exception.CoolException; |
| | | import com.sun.org.apache.xpath.internal.operations.Or; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.CombParam; |
| | | import com.zy.asrs.entity.param.MobileAdjustParam; |
| | | import com.zy.asrs.entity.param.OffSaleParam; |
| | | import com.zy.asrs.entity.param.OpenOrderPakinParam; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.mapper.ManLocDetlMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.MatUtils; |
| | |
| | | private ManLocDetlMapper manLocDetlMapper; |
| | | @Autowired |
| | | private WaitPakinLogService waitPakinLogService; |
| | | |
| | | @Autowired |
| | | private LocCheckService locCheckService; |
| | | |
| | | @Autowired |
| | | private OrderCheckService orderCheckService; |
| | | |
| | | @Autowired |
| | | private OriginRuleService originRuleService; |
| | | |
| | | @Autowired |
| | | private LocInPrintMatService locInPrintMatService; |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | return R.ok("上架成功"); |
| | | } |
| | | |
| | | @Override |
| | | public R adjustNew(MobileAdjustNewParam combParam, Long userId) { |
| | | |
| | | |
| | | for (WrkDetl detl: combParam.getWrkDetls()){ |
| | | EntityWrapper<LocCheck> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("order_no", combParam.getOrderNo()) |
| | | .eq("matnr", detl.getMatnr()) |
| | | .eq("loc_no", detl.getLocNo()) |
| | | .eq("batch",detl.getBatch()); |
| | | LocCheck CheckDetl = locCheckService.selectOne(wrapper); |
| | | if (CheckDetl == null){ |
| | | Date now = new Date(); |
| | | LocCheck locCheck = new LocCheck(); |
| | | locCheck.setLocNo(detl.getLocNo()); |
| | | locCheck.setMaktx(detl.getMaktx()); |
| | | locCheck.setType(1); |
| | | locCheck.setMatnr(detl.getMatnr()); |
| | | locCheck.setAnfme(detl.getAnfme()); |
| | | locCheck.setRealAnfme(detl.getAnfme()); |
| | | locCheck.setDiffAnfme(detl.getAnfme()); |
| | | locCheck.setExamine(0); |
| | | locCheck.setOwner(detl.getOwner()); |
| | | locCheck.setPayment(detl.getPayment()); |
| | | locCheck.setCreateTime(now); |
| | | locCheck.setUpdateTime(now); |
| | | locCheck.setOrderNo(combParam.getOrderNo()); |
| | | locCheck.setBatch(detl.getBatch()); |
| | | |
| | | if (!locCheckService.insert(locCheck)){ |
| | | return R.error("盘点明细插入失败"); |
| | | } |
| | | }else { |
| | | CheckDetl.setRealAnfme(detl.getAnfme()); |
| | | CheckDetl.setDiffAnfme(detl.getAnfme()- CheckDetl.getAnfme()); |
| | | if (!locCheckService.update(CheckDetl,wrapper)){ |
| | | return R.error("明细更新失败"); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | OrderCheck orderCheck = orderCheckService.selectOne(new EntityWrapper<OrderCheck>().eq("order_no", combParam.getOrderNo())); |
| | | orderCheck.setSettle(2L); |
| | | if (!orderCheckService.update(orderCheck,new EntityWrapper<OrderCheck>().eq("order_no", combParam.getOrderNo()))){ |
| | | return R.error("更新盘点单状态失败!"); |
| | | } |
| | | |
| | | |
| | | return R.ok("盘点成功"); |
| | | } |
| | | |
| | | @Override |
| | | public R manDetlOrigin(JSONObject json, User user) { |
| | | Date now = new Date(); |
| | | String jsonLocNo = (String) json.get("locNo"); //获取库位码 |
| | | String jsonCode = (String) json.get("code"); //获取条码 |
| | | String jsonOrigin = (String) json.get("origin"); //获取来源地 |
| | | OriginRule originRule = originRuleService.selectOne(new EntityWrapper<OriginRule>() |
| | | .eq("origin_address", jsonOrigin)); |
| | | |
| | | String code = "0"; |
| | | String weight = "0"; |
| | | String date = "0"; |
| | | try{ |
| | | if (originRule.getStartCode() != 0 && originRule.getEndCode() !=0){ |
| | | code = jsonCode.substring(originRule.getStartCode() - 1, originRule.getEndCode()); |
| | | } |
| | | if (originRule.getStartWeight() != 0 && originRule.getEndWeight() !=0){ |
| | | weight = jsonCode.substring(originRule.getStartWeight() - 1, originRule.getEndWeight()); |
| | | } |
| | | if (originRule.getStartDate() != 0 && originRule.getEndDate() !=0){ |
| | | date = jsonCode.substring(originRule.getStartDate() - 1, originRule.getEndDate()); |
| | | } |
| | | }catch (Exception e){ |
| | | return R.error("条码位置有误"); |
| | | } |
| | | Node node = nodeService.selectOne(new EntityWrapper<Node>().eq("name", jsonLocNo)); //获取对应库位信息 |
| | | if (Cools.isEmpty(node)){ |
| | | return R.error("未查询到库位信息"); |
| | | } |
| | | |
| | | JSONArray combMats = json.getJSONArray("combMats"); |
| | | for (int i = 0; i < combMats.size(); i++) { |
| | | OrderDetl jsonOriginDetl = combMats.getObject(i, OrderDetl.class); |
| | | |
| | | Mat mat = matService.selectByMatnr(jsonOriginDetl.getMatnr()); |
| | | if (Cools.isEmpty(mat)){ |
| | | return R.error("未查询到商品信息"); |
| | | } |
| | | //增加打印档案 |
| | | LocInPrintMat locInPrintMat = new LocInPrintMat(now,user.getId(), mat.getMatnr(),jsonOriginDetl.getBatch(),jsonOriginDetl.getAnfme(),jsonLocNo,mat.getMaktx()); |
| | | locInPrintMatService.insert(locInPrintMat); |
| | | |
| | | Wrapper<ManLocDetl> manLocDetlWrapper = new EntityWrapper<ManLocDetl>().eq("loc_no", jsonLocNo).eq("matnr", jsonOriginDetl.getMatnr()).eq("batch",date); |
| | | ManLocDetl manLocDetl1 = manLocDetlService.selectOne(manLocDetlWrapper); |
| | | if(!Cools.isEmpty(manLocDetl1)){ |
| | | BigDecimal inAnfme = BigDecimal.valueOf(jsonOriginDetl.getAnfme()); |
| | | BigDecimal anfme = BigDecimal.valueOf(manLocDetl1.getAnfme()); |
| | | |
| | | BigDecimal sum = anfme.add(inAnfme); |
| | | manLocDetl1.setAnfme(sum.doubleValue()); |
| | | if (!manLocDetlService.update(manLocDetl1,manLocDetlWrapper)) { |
| | | return R.error("物料信息上架失败"); |
| | | } |
| | | |
| | | }else { |
| | | ManLocDetl manLocDetl = new ManLocDetl(); //初始化库存实体类 |
| | | manLocDetl.sync(mat); |
| | | manLocDetl.setLocNo(node.getUuid()); |
| | | manLocDetl.setNodeId(node.getId()); |
| | | // manLocDetl.setZpallet(waitPakin.getZpallet()); |
| | | manLocDetl.setAnfme(jsonOriginDetl.getAnfme()); |
| | | manLocDetl.setName(jsonCode); |
| | | manLocDetl.setModel(code); |
| | | manLocDetl.setWeight(Double.valueOf(weight)); |
| | | manLocDetl.setBatch(date); |
| | | manLocDetl.setCustName(jsonOriginDetl.getOrigin()); |
| | | manLocDetl.setStatus(1); |
| | | manLocDetl.setCreateBy(user.getId()); |
| | | manLocDetl.setCreateTime(now); |
| | | manLocDetl.setUpdateBy(user.getId()); |
| | | manLocDetl.setModiTime(now); |
| | | // manLocDetl.setOrderNo(waitPakin.getOrderNo()); |
| | | manLocDetl.setStockFreeze(1); |
| | | |
| | | if (!manLocDetlService.insert(manLocDetl)){ //数据库插入实体类信息 |
| | | return R.error("物料信息入库失败"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public R manDetlOrigInNo(JSONObject json, User user) { |
| | | Date now = new Date(); |
| | | String jsonLocNo = (String) json.get("locNo"); //获取库位码 |
| | | |
| | | Node node = nodeService.selectOne(new EntityWrapper<Node>().eq("name", jsonLocNo)); //获取对应库位信息 |
| | | if (Cools.isEmpty(node)){ |
| | | return R.error("未查询到库位信息"); |
| | | } |
| | | |
| | | JSONArray combMats = json.getJSONArray("combMats"); |
| | | for (int i = 0; i < combMats.size(); i++) { |
| | | OrderDetl jsonOriginDetl = combMats.getObject(i, OrderDetl.class); |
| | | |
| | | Mat mat = matService.selectByMatnr(jsonOriginDetl.getMatnr()); |
| | | if (Cools.isEmpty(mat)){ |
| | | return R.error("未查询到商品信息"); |
| | | } |
| | | //增加打印档案 |
| | | LocInPrintMat locInPrintMat = new LocInPrintMat(now,user.getId(), mat.getMatnr(),jsonOriginDetl.getBatch(),jsonOriginDetl.getAnfme(),jsonLocNo,mat.getMaktx()); |
| | | locInPrintMatService.insert(locInPrintMat); |
| | | |
| | | Wrapper<ManLocDetl> manLocDetlWrapper = new EntityWrapper<ManLocDetl>().eq("loc_no", jsonLocNo).eq("matnr", jsonOriginDetl.getMatnr()).eq("batch",jsonOriginDetl.getBatch()); |
| | | ManLocDetl manLocDetl1 = manLocDetlService.selectOne(manLocDetlWrapper); |
| | | if(!Cools.isEmpty(manLocDetl1)){ |
| | | BigDecimal inAnfme = BigDecimal.valueOf(jsonOriginDetl.getAnfme()); |
| | | BigDecimal anfme = BigDecimal.valueOf(manLocDetl1.getAnfme()); |
| | | |
| | | BigDecimal sum = anfme.add(inAnfme); |
| | | manLocDetl1.setAnfme(sum.doubleValue()); |
| | | if (!manLocDetlService.update(manLocDetl1,manLocDetlWrapper)) { |
| | | return R.error("物料信息上架失败"); |
| | | } |
| | | |
| | | }else { |
| | | ManLocDetl manLocDetl = new ManLocDetl(); //初始化库存实体类 |
| | | manLocDetl.sync(mat); |
| | | manLocDetl.setLocNo(node.getUuid()); |
| | | manLocDetl.setNodeId(node.getId()); |
| | | // manLocDetl.setZpallet(waitPakin.getZpallet()); |
| | | manLocDetl.setAnfme(jsonOriginDetl.getAnfme()); |
| | | manLocDetl.setName(""); |
| | | manLocDetl.setModel(""); |
| | | manLocDetl.setWeight(jsonOriginDetl.getAnfme()); |
| | | manLocDetl.setBatch(jsonOriginDetl.getBatch()); |
| | | manLocDetl.setCustName(jsonOriginDetl.getOrigin()); |
| | | manLocDetl.setStatus(1); |
| | | manLocDetl.setCreateBy(user.getId()); |
| | | manLocDetl.setCreateTime(now); |
| | | manLocDetl.setUpdateBy(user.getId()); |
| | | manLocDetl.setModiTime(now); |
| | | // manLocDetl.setOrderNo(waitPakin.getOrderNo()); |
| | | manLocDetl.setStockFreeze(1); |
| | | |
| | | if (!manLocDetlService.insert(manLocDetl)){ //数据库插入实体类信息 |
| | | return R.error("物料信息入库失败"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public R manDetlOriginOut(JSONObject json, User user) { |
| | | JSONArray combMats = json.getJSONArray("combMats"); |
| | | for (int i = 0; i < combMats.size(); i++) { |
| | | MatPrint jsonOriginDetl = combMats.getObject(i, MatPrint.class); |
| | | Double parseLong = jsonOriginDetl.getAnfme(); |
| | | Wrapper<ManLocDetl> manLocDetlWrapper = new EntityWrapper<ManLocDetl>().eq("loc_no", jsonOriginDetl.getLocNo()).eq("matnr", jsonOriginDetl.getMatnr()).eq("batch", jsonOriginDetl.getBatch()); |
| | | ManLocDetl manLocDetl = manLocDetlService.selectOne(manLocDetlWrapper); |
| | | if (Cools.isEmpty(manLocDetl)){ |
| | | return R.error("未商品明细信息!库位号:"+jsonOriginDetl.getLocNo()+";商品编号:"+jsonOriginDetl.getMatnr()+"批次:"+jsonOriginDetl.getBatch()); |
| | | } |
| | | BigDecimal outAnfme = BigDecimal.valueOf(parseLong); |
| | | BigDecimal anfme = BigDecimal.valueOf(manLocDetl.getAnfme()); |
| | | |
| | | if (manLocDetl.getAnfme() > parseLong){ |
| | | BigDecimal num = anfme.subtract(outAnfme); |
| | | manLocDetl.setAnfme(num.doubleValue()); |
| | | if (!manLocDetlService.update(manLocDetl,manLocDetlWrapper)) { |
| | | return R.error("物料信息下架失败"); |
| | | } |
| | | |
| | | }else if (manLocDetl.getAnfme().equals(jsonOriginDetl.getAnfme())) { |
| | | if (!manLocDetlService.delete(manLocDetlWrapper)) { |
| | | return R.error("物料信息删除失败"); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | } |