| | |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.service.AgvCommonService; |
| | | import lombok.Synchronized; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @Synchronized |
| | | public String allocationOut(AgvMobileStartPakin param, Long userId) { |
| | | Date now = new Date(); |
| | | AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", param.getDevNo())); |
| | | Integer oldWrkNo = agvWrkMast.getWrkNo(); |
| | | if (Cools.isEmpty(agvWrkMast)) { |
| | | throw new CoolException("工作档中没有此站点任务"); |
| | | } |
| | | |
| | | //生成AGV工作历史档 + 生成AGV工作明细历史档 |
| | | agvWrkMastLogService.save(agvWrkMast); |
| | | agvWrkDetlLogService.save(agvWrkMast.getWrkNo()); |
| | | |
| | | //删除AGV工作档 |
| | | agvWrkMastService.deleteById(agvWrkMast); |
| | | //生成工作档 |
| | | AgvWrkMast mast = new AgvWrkMast(); |
| | | //工作状态 |
| | | mast.setWrkSts(210L); |
| | | //入出库类型 |
| | | mast.setIoType(111); |
| | | mast.setIoTime(now); |
| | | //优先级 |
| | | mast.setIoPri(300.0); |
| | | //源站点 |
| | | mast.setSourceLocNo(""); |
| | | //目标站点 |
| | | mast.setLocNo(""); |
| | | //容器编码 |
| | | mast.setBarcode(agvWrkMast.getBarcode()); |
| | | //容器类型 |
| | | mast.setWhsType(30); |
| | | // 目标楼层 |
| | | mast.setPauseMk(agvWrkMast.getPauseMk()); |
| | | mast.setAppeUser(userId); |
| | | mast.setAppeTime(now); |
| | | mast.setModiUser(userId); |
| | | mast.setModiTime(now); |
| | | if (!agvWrkMastService.insertByIncrease(mast)) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | AgvWrkMast wrkMast = createWrkMast(111, 210L, "", "", agvWrkMast.getBarcode(), now, userId, 30, agvWrkMast.getCrnNo()); |
| | | // 更新工作明细 |
| | | List<AgvWrkDetl> agvWrkDetls = agvWrkDetlService.selectList(new EntityWrapper<AgvWrkDetl>().eq("wrk_no", agvWrkMast.getWrkNo())); |
| | | List<AgvWrkDetl> agvWrkDetls = agvWrkDetlService.selectList(new EntityWrapper<AgvWrkDetl>().eq("supp_code", agvWrkMast.getBarcode())); |
| | | for (AgvWrkDetl agvWrkDetl : agvWrkDetls) { |
| | | agvWrkDetl.setWrkNo(mast.getWrkNo()); |
| | | if (!agvWrkDetlService.update(agvWrkDetl,new EntityWrapper<AgvWrkDetl>().eq("wrk_no", agvWrkMast.getWrkNo()))) { |
| | | throw new CoolException("更新工作明细失败"); |
| | | agvWrkDetl.setWrkNo(wrkMast.getWrkNo()); |
| | | // 保持工作档明细 |
| | | agvWrkDetl.setWrkNo(wrkMast.getWrkNo()); |
| | | agvWrkDetl.setModiUser(userId); |
| | | agvWrkDetl.setModiTime(now); |
| | | if (!agvWrkDetlService.insert(agvWrkDetl)) { |
| | | throw new CoolException("保存工作明细失败"); |
| | | } |
| | | } |
| | | // 更新站点状态 |
| | | agvLocMastService.updateLocStsByLocNo(agvWrkMast.getSourceLocNo(),"O","",null); |
| | | // 更新源库位状态 |
| | | agvBasDevpService.updateLocStsAndBarcodeByDevNo(agvWrkMast.getLocNo(),"O","",agvWrkMast.getWhsType().shortValue()); |
| | | |
| | | //删除AGV工作明细档 |
| | | agvWrkDetlService.delete(new EntityWrapper<AgvWrkDetl>().eq("wrk_no",oldWrkNo)); |
| | | return "ok"; |
| | | } |
| | | /* |
| | | 调拨进场 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public String allocationIn(AgvMobileStartPakin param, Long userId) { |
| | | Date now = new Date(); |
| | | AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("barcode", param.getBarcode())); |
| | | AgvBasDevp agvBasDevp = agvBasDevpService.selectByDevNo(param.getDevNo()); |
| | | if (Cools.isEmpty(agvWrkMast)) { |
| | | throw new CoolException("工作档中没有此货架任务"); |
| | | } |
| | | if (agvWrkMast.getCrnNo() != agvBasDevp.getFloor()) { |
| | | throw new CoolException("请移动到->" + agvWrkMast.getCrnNo() + "楼入库点入库"); |
| | | } |
| | | //工作状态 |
| | | agvWrkMast.setWrkSts(211L); |
| | | //入出库类型 |
| | | agvWrkMast.setIoType(112); |
| | | agvWrkMast.setSourceLocNo(param.getDevNo()); |
| | | agvWrkMast.setModiUser(userId); |
| | | agvWrkMast.setModiTime(now); |
| | | if (!agvWrkMastService.update(agvWrkMast,new EntityWrapper<AgvWrkMast>().eq("wrk_no",agvWrkMast.getWrkNo()))) { |
| | | throw new CoolException("更新工作档失败"); |
| | | } |
| | | // 更新源库位状态 |
| | | agvBasDevpService.updateLocStsAndBarcodeByDevNo(param.getDevNo(),"F",agvWrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue()); |
| | | //删除AGV工作档 |
| | | return "ok"; |
| | | } |
| | | /* |
| | | * 站点回退 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public String doBack(AgvMobileStartPakin param, Long userId) { |
| | | Date now = new Date(); |
| | | AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", param.getDevNo())); |
| | | Integer oldWrkNo = agvWrkMast.getWrkNo(); |
| | | // 新建回退工作档 |
| | | AgvWrkMast wrkMast = createWrkMast(58, 201L, agvWrkMast.getLocNo(), agvWrkMast.getSourceLocNo(), agvWrkMast.getBarcode(), now, userId, agvWrkMast.getWhsType(), 0); |
| | | // 更新接驳位,更新库位状态 |
| | | agvLocMastService.updateLocStsByLocNo(wrkMast.getLocNo(),"S",wrkMast.getBarcode(),wrkMast.getWhsType().shortValue()); |
| | | agvBasDevpService.updateLocStsAndBarcodeByDevNo(wrkMast.getSourceLocNo(),"R",wrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue()); |
| | | // 更新工作明细 |
| | | List<AgvWrkDetl> agvWrkDetls = agvWrkDetlService.selectList(new EntityWrapper<AgvWrkDetl>().eq("supp_code", agvWrkMast.getBarcode())); |
| | | for (AgvWrkDetl agvWrkDetl : agvWrkDetls) { |
| | | agvWrkDetl.setWrkNo(wrkMast.getWrkNo()); |
| | | // 保持工作档明细 |
| | | agvWrkDetl.setWrkNo(wrkMast.getWrkNo()); |
| | | agvWrkDetl.setModiUser(userId); |
| | | agvWrkDetl.setModiTime(now); |
| | | if (!agvWrkDetlService.insert(agvWrkDetl)) { |
| | | throw new CoolException("保存工作明细失败"); |
| | | } |
| | | // 同步订单数量 |
| | | OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("matnr", agvWrkDetl.getMatnr()).eq("three_code",agvWrkDetl.getThreeCode()).in("source",18,31,34)); |
| | | orderDetl.setQty(orderDetl.getQty() - agvWrkDetl.getAnfme()); |
| | | if (!orderDetlService.update(orderDetl,new EntityWrapper<OrderDetl>().eq("order_no",orderDetl.getOrderNo()).eq("matnr", orderDetl.getMatnr()).eq("three_code",orderDetl.getThreeCode()))){ |
| | | throw new CoolException("修改订单明细失败,请联系管理员"+orderDetl.getOrderNo()+orderDetl.getMatnr()); |
| | | } |
| | | } |
| | | |
| | | //生成AGV工作历史档 + 生成AGV工作明细历史档 |
| | | agvWrkMastLogService.save(agvWrkMast); |
| | | agvWrkDetlLogService.save(agvWrkMast.getWrkNo()); |
| | | //删除AGV工作档 |
| | | agvWrkMastService.deleteById(agvWrkMast); |
| | | //删除AGV工作明细档 |
| | | agvWrkDetlService.delete(new EntityWrapper<AgvWrkDetl>().eq("wrk_no",oldWrkNo)); |
| | | return "ok"; |
| | | } |
| | | /* |
| | |
| | | agvLocMastService.updateById(locMast); |
| | | } |
| | | |
| | | /* |
| | | 生成工作档 |
| | | */ |
| | | private AgvWrkMast createWrkMast(int ioType, long wrkSts, String sourceLocNo, String locNo, String barcode, Date now, Long userId, int containerType,int floor){ |
| | | AgvWrkMast wrkMast = new AgvWrkMast(); |
| | | //工作状态 |
| | | wrkMast.setWrkSts(wrkSts); |
| | | //入出库类型 |
| | | wrkMast.setIoType(ioType); |
| | | wrkMast.setIoTime(now); |
| | | //优先级 |
| | | wrkMast.setIoPri(300.0); |
| | | //源站点 |
| | | wrkMast.setSourceLocNo(sourceLocNo); |
| | | //目标站点 |
| | | wrkMast.setLocNo(locNo); |
| | | //容器编码 |
| | | wrkMast.setBarcode(barcode); |
| | | //容器类型 |
| | | wrkMast.setWhsType(containerType); |
| | | // 目标楼层 |
| | | wrkMast.setCrnNo(floor); |
| | | |
| | | wrkMast.setAppeUser(userId); |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(now); |
| | | |
| | | if (!agvWrkMastService.insertByIncrease(wrkMast)) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | |
| | | wrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", locNo).eq("source_loc_no",sourceLocNo).eq("barcode",barcode).orderBy("modi_time",false)); |
| | | |
| | | return wrkMast; |
| | | } |
| | | |
| | | } |