| | |
| | | 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; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 移动端服务核心类 |
| | |
| | | private ManLocDetlMapper manLocDetlMapper; |
| | | @Autowired |
| | | private WaitPakinLogService waitPakinLogService; |
| | | |
| | | @Autowired |
| | | private LocCheckService locCheckService; |
| | | |
| | | @Autowired |
| | | private OrderCheckService orderCheckService; |
| | | |
| | | @Autowired |
| | | private OriginRuleService originRuleService; |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | Double anfme = orderDetl.getAnfme(); |
| | | Double workQty = orderDetl.getWorkQty(); |
| | | if ( anfme - (workQty+combMat.getAnfme()) < 0) { |
| | | BigDecimal a1 = new BigDecimal(orderDetl.getAnfme()).setScale(2,BigDecimal.ROUND_HALF_UP); |
| | | BigDecimal b1 = new BigDecimal(orderDetl.getWorkQty()).setScale(2,BigDecimal.ROUND_HALF_UP); |
| | | BigDecimal c1 = new BigDecimal(combMat.getAnfme()).setScale(2,BigDecimal.ROUND_HALF_UP); |
| | | double e1 = b1.add(c1).doubleValue(); |
| | | BigDecimal f1 = new BigDecimal(e1).setScale(2,BigDecimal.ROUND_HALF_UP); |
| | | Double d1 = a1.subtract(f1).doubleValue(); |
| | | if ( d1 < 0.0) { |
| | | throw new CoolException("组托数量已超出订单需求量,请检查是否有其他的组托已完成"); |
| | | } |
| | | } |
| | |
| | | throw new CoolException("修改单据作业数量失败"); |
| | | } |
| | | |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme(),orderDetl.getOwner(),elem.getWeight()); |
| | | detlDto.setPayment(orderDetl.getPayment()); |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme(),elem.getWeight()); |
| | | if (DetlDto.has(detlDtos, detlDto)) { |
| | | DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch()); |
| | | assert one != null; |
| | |
| | | public R manDetlIn(JSONObject json, User user) { |
| | | Date date = new Date(); |
| | | String jsonLocNo = (String) json.get("locNo"); |
| | | |
| | | LocMast locMast = locMastService.selectLocStatus(jsonLocNo); |
| | | if (locMast.getLocSts().equals("X")){ |
| | | return R.error("库位已被冻结"); |
| | | } |
| | | |
| | | List<ManLocDetl> locDetls = manLocDetlService.selectList(new EntityWrapper<ManLocDetl>().eq("loc_no", jsonLocNo)); |
| | | Node node = nodeService.selectOne(new EntityWrapper<Node>() |
| | | .eq("name", jsonLocNo)); |
| | | |
| | | // if (node.getParentName().equals("A") || node.getParentName().equals("B")){ |
| | | // if (node.getRow1() == 1 && locDetls.size() >=11){ |
| | | // return R.error("该库位排已满"); |
| | | // } |
| | | // if (node.getRow1() == 6 && locDetls.size() >=4){ |
| | | // return R.error("该库位排已满"); |
| | | // } |
| | | // if (node.getRow1() == 12 && locDetls.size() >=4){ |
| | | // return R.error("该库位排已满"); |
| | | // } |
| | | // |
| | | // } |
| | | // if (locDetls.size() >=12){ |
| | | // return R.error("该库位排已满"); |
| | | // } |
| | | |
| | | |
| | | |
| | | JSONArray combMats = json.getJSONArray("combMats"); |
| | | for (int i = 0; i < combMats.size(); i++) { |
| | | OrderDetl jsonOrderDetl = combMats.getObject(i, OrderDetl.class); |
| | |
| | | manLocDetl.setOwner(orderDetl.getOwner()); |
| | | manLocDetl.setWeight(jsonOrderDetl.getWeight()); |
| | | manLocDetl.setOrderNo(jsonOrderDetl.getOrderNo()); |
| | | manLocDetl.setStockFreeze(1); |
| | | if(!manLocDetlService.insert(manLocDetl)){ |
| | | return R.error("插入平库物料失败!"); |
| | | } |
| | | } else { |
| | | } |
| | | else { |
| | | if (checkManLocDetl.getWeight() == null){ |
| | | checkManLocDetl.setWeight(0.0); |
| | | } |
| | |
| | | public R manDetlOut(JSONObject json,User user) { |
| | | Date date = new Date(); |
| | | String jsonLocNo = (String) json.get("locNo"); |
| | | |
| | | LocMast locMast = locMastService.selectLocStatus(jsonLocNo); |
| | | if (locMast.getLocSts().equals("X")){ |
| | | return R.error("库位已被冻结"); |
| | | } |
| | | |
| | | Node node = nodeService.selectOne(new EntityWrapper<Node>() |
| | | .eq("name", jsonLocNo)); |
| | | JSONArray combMats = json.getJSONArray("combMats"); |
| | |
| | | // if (jsonOrderDetl.getAnfme() > manPakOut.getAnfme()) { //判断工作数量是否大于拣货单的数量 |
| | | // return R.error("出库数量大于拣货单总数量"); |
| | | // } |
| | | if (jsonOrderDetl.getAnfme() > (manPakOut.getAnfme()-manPakOut.getCount())) { //判断工作数量是否大于拣货单剩余可出的数量 |
| | | BigDecimal a1 = new BigDecimal(manPakOut.getAnfme()).setScale(2,BigDecimal.ROUND_HALF_UP); |
| | | BigDecimal b1 = new BigDecimal(manPakOut.getCount()).setScale(2,BigDecimal.ROUND_HALF_UP); |
| | | Double c1 = a1.subtract(b1).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue(); |
| | | if (jsonOrderDetl.getAnfme() > c1) { //判断工作数量是否大于拣货单剩余可出的数量 |
| | | return R.error("出库数量大于拣货单剩余可出数量"); |
| | | } |
| | | if (orderDetl.getWorkQty() - orderDetl.getQty() <jsonOrderDetl.getAnfme() ){ |
| | | |
| | | BigDecimal e1 = new BigDecimal(orderDetl.getWorkQty()).setScale(2,BigDecimal.ROUND_HALF_UP); |
| | | BigDecimal f1 = new BigDecimal(orderDetl.getQty()).setScale(2,BigDecimal.ROUND_HALF_UP); |
| | | Double g1 = e1.subtract(f1).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue(); |
| | | if ( g1 <jsonOrderDetl.getAnfme() ){ |
| | | return R.error("出库数量大于单据剩余可出数量"); |
| | | } |
| | | //查询平库中是否有一样的物料号 |
| | |
| | | if(jsonOrderDetl.getWeight() == null){ |
| | | jsonOrderDetl.setWeight(0.0); |
| | | } |
| | | Double finalQty = checkManLocDetl.getAnfme() - jsonOrderDetl.getAnfme(); |
| | | Double weight = checkManLocDetl.getWeight() - jsonOrderDetl.getWeight(); |
| | | Double finalQty = new BigDecimal(checkManLocDetl.getAnfme()).setScale(2,BigDecimal.ROUND_HALF_UP).subtract(new BigDecimal(jsonOrderDetl.getAnfme()).setScale(2,BigDecimal.ROUND_HALF_UP)).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue() ; |
| | | Double weight = new BigDecimal(checkManLocDetl.getWeight()).setScale(2,BigDecimal.ROUND_HALF_UP).subtract(new BigDecimal(jsonOrderDetl.getWeight()).setScale(2,BigDecimal.ROUND_HALF_UP)).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue() ; |
| | | checkManLocDetl.setAnfme(finalQty); |
| | | checkManLocDetl.setWeight(weight); |
| | | if (weight < 0){ |
| | |
| | | return R.error("修改平库物料失败!"); |
| | | } |
| | | } |
| | | orderDetl.setQty(orderDetl.getQty() + jsonOrderDetl.getAnfme()); |
| | | orderDetl.setQty( new BigDecimal(orderDetl.getQty()).setScale(2,BigDecimal.ROUND_HALF_UP).add(new BigDecimal(jsonOrderDetl.getAnfme()).setScale(2,BigDecimal.ROUND_HALF_UP)).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue() ); |
| | | orderDetl.setUpdateTime(date); |
| | | orderDetlService.updateById(orderDetl); |
| | | //更新订单状态 |
| | |
| | | if(manPakOut.getCount() == null){ |
| | | manPakOut.setCount(0.0); |
| | | } |
| | | manPakOut.setCount(manPakOut.getCount()+jsonOrderDetl.getAnfme().intValue()); |
| | | |
| | | manPakOut.setCount(new BigDecimal(manPakOut.getCount()).setScale(2,BigDecimal.ROUND_HALF_UP).add(new BigDecimal(jsonOrderDetl.getAnfme()).setScale(2,BigDecimal.ROUND_HALF_UP)).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue()); |
| | | if (!manPakOutService.update(manPakOut,manPakOutEntityWrapper)){ |
| | | return R.error("更新拣货单完成数目失败"); |
| | | } |
| | | if (manPakOut.getAnfme().intValue() == manPakOut.getCount()){ |
| | | if (manPakOut.getAnfme().equals(manPakOut.getCount())){ |
| | | manPakOut.setStatus(1); |
| | | if (!manPakOutService.update(manPakOut,manPakOutEntityWrapper)){ |
| | | return R.error("更新拣货单状态失败"); |
| | |
| | | String jsonLocNo = (String) json.get("locNo"); //获取库位码 |
| | | String jsonBarNo = (String) json.get("barcode"); //获取托盘码 |
| | | |
| | | LocMast locMast = locMastService.selectLocStatus(jsonLocNo); |
| | | if (locMast.getLocSts().equals("X")){ |
| | | return R.error("库位已被冻结"); |
| | | } |
| | | |
| | | List<WaitPakin> waitPakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", jsonBarNo)); //获取对应组托信息 |
| | | if (Cools.isEmpty(waitPakins)){ |
| | | return R.error("未查询到组托"); |
| | | } else if (waitPakins.get(0).getIoStatus() == "Y") { |
| | | } else if (waitPakins.get(0).getIoStatus().equals("Y")) { |
| | | return R.error("组托已经生成工作档"); |
| | | } |
| | | |
| | | for (WaitPakin waitPakin: waitPakins) { |
| | | List<ManLocDetl> manLocDetls = manLocDetlService.selectList(new EntityWrapper<ManLocDetl>().eq("zpallet", waitPakin.getZpallet())); |
| | | if (!Cools.isEmpty(manLocDetls) || manLocDetls.size()>0){ |
| | | return R.error("所在库位已存在明细"); |
| | | } |
| | | } |
| | | //判断订单是否完成 |
| | | boolean log =true; |
| | |
| | | manLocDetl.setUpdateBy(user.getId()); |
| | | manLocDetl.setModiTime(date); |
| | | manLocDetl.setOrderNo(waitPakin.getOrderNo()); |
| | | manLocDetl.setOwner(waitPakin.getOwner()); |
| | | manLocDetl.setPayment(waitPakin.getPayment()); |
| | | manLocDetl.setStockFreeze(1); |
| | | |
| | | if (!manLocDetlService.insert(manLocDetl)){ //数据库插入实体类信息 |
| | | return R.error("物料信息入库失败"); |
| | |
| | | waitPakinLog.setModiTime(date); |
| | | waitPakinLog.setAppeUser(user.getId()); |
| | | waitPakinLog.setAppeTime(date); |
| | | waitPakinLog.setOwner(waitPakin.getOwner()); |
| | | waitPakinLog.setPayment(waitPakin.getPayment()); |
| | | waitPakinLog.setUuid(waitPakin.getUuid()); |
| | | |
| | | if (!waitPakinLogService.insert(waitPakinLog)){ //插入入库通知历史档数据库 |
| | |
| | | } |
| | | 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) { |
| | | String jsonLocNo = (String) json.get("locNo"); //获取库位码 |
| | | |
| | | JSONArray combMats = json.getJSONArray("combMats"); |
| | | for (int i = 0; i < combMats.size(); i++) { |
| | | DetlOriginDTO jsonOriginDetl = combMats.getObject(i, DetlOriginDTO.class); |
| | | OriginRule originRule = originRuleService.selectOne(new EntityWrapper<OriginRule>() |
| | | .eq("origin_address", jsonOriginDetl.getOrigin())); |
| | | String code = "0"; |
| | | String weight = "0"; |
| | | String date = "0"; |
| | | try{ |
| | | if (originRule.getStartCode() != 0 && originRule.getEndCode() !=0){ |
| | | code = jsonOriginDetl.getMatnr().substring(originRule.getStartCode() - 1, originRule.getEndCode()); |
| | | } |
| | | if (originRule.getStartWeight() != 0 && originRule.getEndWeight() !=0){ |
| | | weight = jsonOriginDetl.getMatnr().substring(originRule.getStartWeight() - 1, originRule.getEndWeight()); |
| | | } |
| | | if (originRule.getStartDate() != 0 && originRule.getEndDate() !=0){ |
| | | date = jsonOriginDetl.getMatnr().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("未查询到库位信息"); |
| | | } |
| | | Date now = new Date(); |
| | | ManLocDetl manLocDetl = new ManLocDetl(); //初始化库存实体类 |
| | | manLocDetl.setLocNo(node.getName()); |
| | | manLocDetl.setNodeId(node.getId()); |
| | | // manLocDetl.setZpallet(waitPakin.getZpallet()); |
| | | manLocDetl.setAnfme(jsonOriginDetl.getAnfme()); |
| | | manLocDetl.setMatnr(jsonOriginDetl.getMatnr()); |
| | | manLocDetl.setMaktx(code); |
| | | manLocDetl.setWeight(Double.valueOf( weight)); |
| | | manLocDetl.setUnit(date); |
| | | 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(); |
| | | } |
| | | } |