| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.common.*; |
| | | 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.*; |
| | | import com.zy.asrs.entity.param.CombParam; |
| | | import com.zy.asrs.entity.param.MobileAdjustNewParam; |
| | | 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.mapper.ManLocDetlMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.MatUtils; |
| | | import com.zy.asrs.utils.SaasUtils; |
| | | import com.zy.common.CodeRes; |
| | | import com.zy.common.constant.MesConstant; |
| | | import com.zy.common.entity.Parameter; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.model.MesCombParam; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.common.utils.Synchro; |
| | | import com.zy.system.entity.User; |
| | | import com.zy.system.service.SaasLogService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.Iterator; |
| | |
| | | private ManLocDetlService manLocDetlService; |
| | | @Autowired |
| | | private ManLocDetlMapper manLocDetlMapper; |
| | | @Autowired |
| | | private WaitPakinLogService waitPakinLogService; |
| | | |
| | | @Autowired |
| | | private LocCheckService locCheckService; |
| | | |
| | | @Autowired |
| | | private OrderCheckService orderCheckService; |
| | | |
| | | @Autowired |
| | | private OriginRuleService originRuleService; |
| | | |
| | | @Autowired |
| | | private LocInPrintMatService locInPrintMatService; |
| | | |
| | | @Autowired |
| | | private LocOutPrintMatService locOutPrintMatService; |
| | | |
| | | @Autowired |
| | | private LocOwnerService locOwnerService; |
| | | @Autowired |
| | | private PlaService plaService; |
| | | @Autowired |
| | | private PlaQtyService plaQtyService; |
| | | @Autowired |
| | | private SaasLogService saasLogService; |
| | | |
| | | |
| | | |
| | | @Override |
| | |
| | | combMat.setBatch(""); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | Date now = new Date(); |
| | | |
| | | // 无单组托 |
| | | if (Cools.isEmpty(param.getOrderNo())) { |
| | | |
| | |
| | | // 关联组托 |
| | | } else { |
| | | for (CombParam.CombMat combMat : param.getCombMats()) { |
| | | Integer sum = orderDetlService.sameOrderComb(param.getOrderNo(), combMat.getMatnr(),combMat.getBatch()); |
| | | OrderDetl orderDetl = orderDetlService.selectItem(param.getOrderNo(), combMat.getMatnr(), combMat.getBatch()); |
| | | OrderDetl orderDetl = orderDetlService.selectItem(combMat.getOrderNo(), combMat.getMatnr(), combMat.getBatch()); |
| | | if (orderDetl == null) { |
| | | throw new CoolException("找不到组托的单据明细"); |
| | | |
| | | } |
| | | Double anfme = orderDetl.getAnfme(); |
| | | if ( anfme > (anfme - sum)) { |
| | | Double workQty = orderDetl.getWorkQty(); |
| | | 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("组托数量已超出订单需求量,请检查是否有其他的组托已完成"); |
| | | } |
| | | } |
| | | Order order = orderService.selectByNo(param.getOrderNo()); |
| | | if (order.getSettle() > 2) { |
| | | throw new CoolException("单据编号已过期"); |
| | | } |
| | | |
| | | // 生成入库通知档 |
| | | List<DetlDto> detlDtos = new ArrayList<>(); |
| | | for (CombParam.CombMat elem : param.getCombMats()) { |
| | | Order order = orderService.selectByNo(elem.getOrderNo()); |
| | | if (order.getSettle() > 2) { |
| | | throw new CoolException("单据编号已过期"); |
| | | } |
| | | // 订单明细数量校验 |
| | | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch()); |
| | | if(orderDetl == null){ |
| | |
| | | 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; |
| | |
| | | detlDtos.add(detlDto); |
| | | } |
| | | } |
| | | int i=0; |
| | | for (DetlDto detlDto : detlDtos) { |
| | | Order order = orderService.selectByNo(param.getCombMats().get(i).getOrderNo()); |
| | | i++; |
| | | String uuid = String.valueOf(System.currentTimeMillis()); |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | |
| | | } |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | waitPakin.sync(mat); |
| | | waitPakin.setOrderNo(order.getOrderNo()); // 单据编号 |
| | | waitPakin.setOrderNo(order.getOrderNo()); // 单据编号 |
| | | waitPakin.setBatch(detlDto.getBatch()); // 序列码 |
| | | waitPakin.setZpallet(param.getBarcode()); // 托盘码 |
| | | waitPakin.setIoStatus("N"); // 入出状态 |
| | |
| | | if (!waitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("保存入库通知档失败"); |
| | | } |
| | | orderService.updateSettle(order.getId(), 2L, userId); |
| | | } |
| | | orderService.updateSettle(order.getId(), 2L, userId); |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | @Transactional |
| | | @Override |
| | | public R manDetlIn(JSONObject json) { |
| | | 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); |
| | | } |
| | | if (jsonOrderDetl.getWeight() == null){ |
| | | jsonOrderDetl.setWeight(0.0); |
| | | } |
| | | if(manLocDetlService.increase(checkManLocDetl.getAnfme() + jsonOrderDetl.getAnfme(), |
| | | node.getName(), |
| | |
| | | } |
| | | orderService.checkComplete(order.getOrderNo()); |
| | | |
| | | SaasUtils.insertLog(0,jsonLocNo,jsonOrderDetl.getMatnr(), jsonOrderDetl.getAnfme()); |
| | | SaasUtils.insertLog(0,jsonLocNo,jsonOrderDetl.getMatnr(), jsonOrderDetl.getAnfme(),user.getUsername()); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | @Transactional |
| | | @Override |
| | | public R manDetlOut(JSONObject json) { |
| | | 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"); |
| | |
| | | EntityWrapper<ManPakOut> manPakOutEntityWrapper = new EntityWrapper<>(); |
| | | manPakOutEntityWrapper.eq("loc_no",jsonLocNo); |
| | | manPakOutEntityWrapper.eq("matnr",jsonOrderDetl.getMatnr()); |
| | | manPakOutEntityWrapper.eq("doc_num",order.getOrderNo()); |
| | | ManPakOut manPakOut = manPakOutService.selectOne(manPakOutEntityWrapper); //获取拣货单中的对应的订单 |
| | | if(Cools.isEmpty(manPakOut)){ |
| | | return R.error("没有找到对应的出库单"+jsonLocNo+"-------"+jsonOrderDetl.getMatnr()); |
| | | } |
| | | if(manPakOut.getCount() == null){ |
| | | manPakOut.setCount(0); |
| | | manPakOut.setCount(0.0); |
| | | } |
| | | // 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.getAnfme() > checkManLocDetl.getAnfme()) { |
| | | return R.error("出库数量大于可出数量"); |
| | | } |
| | | Double finalQty = checkManLocDetl.getAnfme() - jsonOrderDetl.getAnfme(); |
| | | Double weight = checkManLocDetl.getWeight() - jsonOrderDetl.getWeight(); |
| | | if(checkManLocDetl.getWeight() == null){ |
| | | checkManLocDetl.setWeight(0.0); |
| | | } |
| | | if(jsonOrderDetl.getWeight() == null){ |
| | | jsonOrderDetl.setWeight(0.0); |
| | | } |
| | | 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); |
| | | //更新订单状态 |
| | |
| | | boolean log=true; |
| | | for (OrderDetl orderDetl1: orderDetls) { |
| | | //工作中的数量小于总订单数时,订单状态改为2,作业中 |
| | | if(orderDetl1.getQty() < orderDetl.getAnfme()){ |
| | | if(orderDetl1.getQty() < orderDetl1.getAnfme()){ |
| | | log=false; |
| | | } |
| | | } |
| | |
| | | return R.error("更新订单状态失败"); |
| | | } |
| | | if(manPakOut.getCount() == null){ |
| | | manPakOut.setCount(0); |
| | | 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("更新拣货单状态失败"); |
| | |
| | | EntityWrapper<ManLocDetl> manLocDetlEntityWrapper = new EntityWrapper<>(); |
| | | manLocDetlEntityWrapper.eq("loc_no",manPakOut.getLocNo()); |
| | | manLocDetlEntityWrapper.eq("matnr",manPakOut.getMatnr()); |
| | | if (checkManLocDetl.getAnfme().intValue() == manPakOut.getCount()){ |
| | | |
| | | |
| | | if (checkManLocDetl.getAnfme() == 0 ){ |
| | | if(!manLocDetlService.delete(manLocDetlEntityWrapper)){ |
| | | return R.error("删除平库库存失败"); |
| | | } |
| | |
| | | return R.error("更新平库库存状态失败"); |
| | | } |
| | | } |
| | | SaasUtils.insertLog(1,jsonLocNo,jsonOrderDetl.getMatnr(), jsonOrderDetl.getAnfme()); |
| | | SaasUtils.insertLog(1,jsonLocNo,jsonOrderDetl.getMatnr(), jsonOrderDetl.getAnfme(),user.getUsername()); |
| | | |
| | | } |
| | | return R.ok("下架完成"); |
| | | } |
| | | |
| | | @Override |
| | | public R manDetlInBarcode(JSONObject json, User user) { |
| | | 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().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; |
| | | |
| | | for (WaitPakin waitPakin: waitPakins) { |
| | | Order order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no", waitPakin.getOrderNo())); //获取对应订单信息 |
| | | if (order.equals(null)){ |
| | | return R.error("未查询到订单信息"); |
| | | } |
| | | OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("order_no", waitPakin. |
| | | getOrderNo()).eq("matnr", waitPakin.getMatnr())); //获取对应订单明细信息 |
| | | if (orderDetl.equals(null)){ |
| | | return R.error("未查询到订单明细信息"); |
| | | } |
| | | Node node = nodeService.selectOne(new EntityWrapper<Node>().eq("name", jsonLocNo)); //获取对应库位信息 |
| | | if (node.equals(null)){ |
| | | return R.error("未查询到库位信息"); |
| | | } |
| | | Date date = new Date(); |
| | | ManLocDetl manLocDetl = new ManLocDetl(); //初始化库存实体类 |
| | | manLocDetl.setLocNo(node.getName()); |
| | | manLocDetl.setNodeId(node.getId()); |
| | | manLocDetl.setZpallet(waitPakin.getZpallet()); |
| | | manLocDetl.setAnfme(waitPakin.getAnfme()); |
| | | manLocDetl.setMatnr(waitPakin.getMatnr()); |
| | | manLocDetl.setMaktx(waitPakin.getMaktx()); |
| | | manLocDetl.setStatus(1); |
| | | manLocDetl.setCreateBy(user.getId()); |
| | | manLocDetl.setCreateTime(date); |
| | | manLocDetl.setUpdateBy(user.getId()); |
| | | manLocDetl.setModiTime(date); |
| | | manLocDetl.setOrderNo(waitPakin.getOrderNo()); |
| | | manLocDetl.setStockFreeze(1); |
| | | |
| | | if (!manLocDetlService.insert(manLocDetl)){ //数据库插入实体类信息 |
| | | return R.error("物料信息入库失败"); |
| | | } |
| | | orderDetl.setQty(orderDetl.getQty()+ waitPakin.getAnfme()); //更新订单明细数量 |
| | | if (!orderDetlService.updateById(orderDetl)){ |
| | | return R.error("更新订单明细失败"); |
| | | } |
| | | |
| | | WaitPakinLog waitPakinLog = new WaitPakinLog(); //初始化入库通知单日志实体类 |
| | | waitPakinLog.setZpallet(waitPakin.getZpallet()); |
| | | waitPakinLog.setAnfme(waitPakin.getAnfme()); |
| | | waitPakinLog.setMatnr(waitPakin.getMatnr()); |
| | | waitPakinLog.setLocNo(jsonLocNo); |
| | | waitPakinLog.setMaktx(waitPakin.getMaktx()); |
| | | waitPakinLog.setOrderNo(waitPakin.getOrderNo()); |
| | | waitPakinLog.setWeight(waitPakin.getWeight()); |
| | | waitPakinLog.setStatus("Y"); |
| | | waitPakinLog.setIoStatus("Y"); |
| | | waitPakinLog.setModiUser(user.getId()); |
| | | waitPakinLog.setModiTime(date); |
| | | waitPakinLog.setAppeUser(user.getId()); |
| | | waitPakinLog.setAppeTime(date); |
| | | waitPakinLog.setUuid(waitPakin.getUuid()); |
| | | |
| | | if (!waitPakinLogService.insert(waitPakinLog)){ //插入入库通知历史档数据库 |
| | | return R.error("插入历史入库通知档失败"); |
| | | } |
| | | //订单是否完成 |
| | | List<OrderDetl> or = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("order_no", waitPakin.getOrderNo())); |
| | | for (OrderDetl o: or) { |
| | | if(o.getAnfme()-o.getQty()>0){ |
| | | log=false; |
| | | break; |
| | | } |
| | | } |
| | | if(log){ |
| | | order.setSettle(4L); |
| | | if(!orderService.update(order,new EntityWrapper<Order>().eq("order_no", waitPakin.getOrderNo()))){ |
| | | return R.error("订单转完成状态失败!!!"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!waitPakinService.delete(new EntityWrapper<WaitPakin>().eq("zpallet",jsonBarNo))){ //删除原入库通知档 |
| | | return R.error("删除入库通知档失败"); |
| | | } |
| | | 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 ownerName = (String) json.get("owner"); //获取拥有者 |
| | | LocOwner locOwner = locOwnerService.selectOne(new EntityWrapper<LocOwner>().eq("owner", ownerName)); |
| | | Long ownerId = locOwner.getId(); |
| | | String jsonCode = (String) json.get("code"); //获取条码 |
| | | String jsonOrigin = (String) json.get("origin"); //获取来源地 |
| | | if (Cools.isEmpty(jsonLocNo)){ |
| | | return R.error("库位号参数为空!"); |
| | | }else if (Cools.isEmpty(ownerId)){ |
| | | return R.error("拥有者参数为空!"); |
| | | }else if (Cools.isEmpty(jsonCode)){ |
| | | return R.error("条码参数为空!"); |
| | | }else if (Cools.isEmpty(jsonOrigin)){ |
| | | return R.error("来源地参数为空!"); |
| | | } |
| | | Integer jsonOwner = ownerId.intValue(); //获取拥有者 |
| | | 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()); |
| | | locInPrintMat.setOwnerId(ownerId); |
| | | locInPrintMatService.insert(locInPrintMat); |
| | | |
| | | Wrapper<ManLocDetl> manLocDetlWrapper = new EntityWrapper<ManLocDetl>().eq("loc_no", jsonLocNo) |
| | | .eq("matnr", jsonOriginDetl.getMatnr()).eq("batch",date).eq("owner",jsonOwner); |
| | | 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); |
| | | manLocDetl.setOwner(jsonOwner); |
| | | try { |
| | | Date produceTime = DateUtils.convert(manLocDetl.getBatch(),DateUtils.yyyyMMdd); |
| | | manLocDetl.setProduceTime(produceTime); |
| | | } catch (Exception e) { |
| | | manLocDetl.setProduceTime(now); |
| | | } |
| | | |
| | | 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"); //获取库位码 |
| | | String ownerName = (String) json.get("owner"); //获取拥有者 |
| | | LocOwner locOwner = locOwnerService.selectOne(new EntityWrapper<LocOwner>().eq("owner", ownerName)); |
| | | Long ownerId = locOwner.getId(); |
| | | if (Cools.isEmpty(jsonLocNo)){ |
| | | return R.error("库位号参数为空!"); |
| | | }else if (Cools.isEmpty(ownerId)){ |
| | | return R.error("拥有者参数为空!"); |
| | | } |
| | | Integer jsonOwner = ownerId.intValue(); //获取拥有者 |
| | | 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()); |
| | | locInPrintMat.setOwnerId(ownerId); |
| | | locInPrintMatService.insert(locInPrintMat); |
| | | |
| | | Wrapper<ManLocDetl> manLocDetlWrapper = new EntityWrapper<ManLocDetl>().eq("loc_no", jsonLocNo) |
| | | .eq("matnr", jsonOriginDetl.getMatnr()).eq("batch",jsonOriginDetl.getBatch()).eq("owner",jsonOwner); |
| | | 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.setOwner(jsonOwner); |
| | | // manLocDetl.setOrderNo(waitPakin.getOrderNo()); |
| | | manLocDetl.setStockFreeze(1); |
| | | try { |
| | | Date produceTime = DateUtils.convert(jsonOriginDetl.getBatch(),DateUtils.yyyyMMdd); |
| | | manLocDetl.setProduceTime(produceTime); |
| | | } catch (Exception e) { |
| | | manLocDetl.setProduceTime(now); |
| | | } |
| | | if (!manLocDetlService.insert(manLocDetl)){ //数据库插入实体类信息 |
| | | return R.error("物料信息入库失败"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public R manDetlOriginOut(JSONObject json, User user) { |
| | | Date now = new Date(); |
| | | JSONArray combMats = json.getJSONArray("combMats"); |
| | | List<MatPrint> matPrintList=new ArrayList<>(); |
| | | List<Long> ids=new ArrayList<>(); |
| | | for (int i = 0; i < combMats.size(); i++) { |
| | | MatPrint matPrintNow = combMats.getObject(i, MatPrint.class); |
| | | if (!ids.contains(matPrintNow.getIndex())){ |
| | | ids.add(matPrintNow.getIndex()); |
| | | matPrintList.add(matPrintNow); |
| | | } |
| | | } |
| | | for (MatPrint jsonOriginDetl:matPrintList) { |
| | | Double parseLong = jsonOriginDetl.getAnfme(); |
| | | Long ownerId = Long.parseLong(jsonOriginDetl.getOwner()); |
| | | jsonOriginDetl.setOwnerId(ownerId); |
| | | Wrapper<ManLocDetl> manLocDetlWrapper = new EntityWrapper<ManLocDetl>().eq("loc_no", jsonOriginDetl.getLocNo()) |
| | | .eq("matnr", jsonOriginDetl.getMatnr()).eq("batch", jsonOriginDetl.getBatch()).eq("owner",jsonOriginDetl.getOwnerId()); |
| | | ManLocDetl manLocDetl = manLocDetlService.selectOne(manLocDetlWrapper); |
| | | if (Cools.isEmpty(manLocDetl)){ |
| | | return R.error("未查询到商品明细信息!库位号:"+jsonOriginDetl.getLocNo()+";商品编号:"+jsonOriginDetl.getMatnr()+"批次:"+jsonOriginDetl.getBatch()+"货主"+jsonOriginDetl.getOwnerId()); |
| | | } |
| | | BigDecimal outAnfme = BigDecimal.valueOf(parseLong); |
| | | BigDecimal anfme = BigDecimal.valueOf(manLocDetl.getAnfme()); |
| | | |
| | | if (manLocDetl.getAnfme() > parseLong){ |
| | | BigDecimal num = anfme.subtract(outAnfme); |
| | | manLocDetl.setAnfme(num.doubleValue()); |
| | | manLocDetl.setUpdateBy(user.getId()); |
| | | manLocDetl.setModiTime(now); |
| | | if (!manLocDetlService.update(manLocDetl,manLocDetlWrapper)) { |
| | | return R.error("物料信息下架失败"); |
| | | } |
| | | |
| | | }else if (manLocDetl.getAnfme().equals(jsonOriginDetl.getAnfme())) { |
| | | if (!manLocDetlService.delete(manLocDetlWrapper)) { |
| | | return R.error("物料信息删除失败"); |
| | | } |
| | | } |
| | | } |
| | | for (MatPrint jsonOriginDetl:matPrintList) { |
| | | //增加打印档案 |
| | | LocOutPrintMat locOutPrintMat = new LocOutPrintMat(now, user.getId(), jsonOriginDetl.getMatnr(), jsonOriginDetl.getBatch(), jsonOriginDetl.getAnfme(), jsonOriginDetl.getLocNo(), jsonOriginDetl.getMaktx()); |
| | | locOutPrintMat.setOwnerId(jsonOriginDetl.getOwnerId()); |
| | | locOutPrintMatService.insert(locOutPrintMat); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public void plaPakin(String locNo, String batch, String packageNo) { |
| | | Pla pla = plaService.selectByBatchAndPackageNo(batch, packageNo); |
| | | if(!pla.getLocNo().equals(locNo)){ |
| | | throw new CoolException("该物料入库的库位错误"); |
| | | } |
| | | if("已入库".equals(pla.getStatus())){ |
| | | throw new CoolException("该物料已入库"); |
| | | } |
| | | pla.setStatus("已入库"); |
| | | pla.setModifyTime(new Date()); |
| | | plaService.updateById(pla); |
| | | SaasUtils.insertLog(0,locNo,batch+","+packageNo,pla.getWeightAnfme(),null); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void plaPakout(String locNo, String batch, String packageNo, String orderNo, String orderDetlId, String wrkNo, Double anfme) { |
| | | Pla pla = plaService.selectByBatchAndPackageNo(batch, packageNo); |
| | | |
| | | ManPakOut manPakOut = manPakOutService.selectById(wrkNo); |
| | | |
| | | PlaQty plaQty = plaQtyService.selectById(orderDetlId); |
| | | |
| | | //更新拣货单信息 |
| | | if(manPakOut.getCount() + anfme > manPakOut.getAnfme()){ |
| | | throw new CoolException("拣货重量大于拣货单所需拣货重量,请重新分配拣货重量"); |
| | | } |
| | | if(manPakOut.getStatus() == 1){ |
| | | throw new CoolException("该拣料单已出库"); |
| | | } |
| | | manPakOut.setCount(manPakOut.getCount() + anfme); |
| | | if (manPakOut.getAnfme().equals(manPakOut.getCount())){ |
| | | manPakOut.setStatus(1); |
| | | manPakOutService.updateById(manPakOut); |
| | | } |
| | | |
| | | //更新pla明细 |
| | | pla.setWeightAnfme(pla.getWeightAnfme() - anfme); |
| | | pla.setQtyAnfme(pla.getQtyAnfme() - anfme); |
| | | if(pla.getWeightAnfme() <= 0){ |
| | | pla.setStatus("全部出库"); |
| | | }else { |
| | | pla.setStatus("部分出库"); |
| | | } |
| | | plaService.updateById(pla); |
| | | SaasUtils.insertLog(1,locNo,batch+","+packageNo,anfme,null); |
| | | |
| | | } |
| | | } |