| | |
| | | import com.core.common.Cools; |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.asrs.service.OrderService; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.utils.Synchro; |
| | | import com.zy.system.entity.User; |
| | | import com.zy.system.service.UserService; |
| | |
| | | import java.io.Serializable; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | @TableName("man_order_detl") |
| | |
| | | ); |
| | | } |
| | | |
| | | public static OrderDetl find(List<OrderDetl> detlDtos, String matnr, String batch, String brand, String standby1, String standby2, String standby3) { |
| | | if (Cools.isEmpty(matnr)) { |
| | | return null; |
| | | } |
| | | for (OrderDetl detlDto : detlDtos) { |
| | | if (matnr.equals(detlDto.getMatnr()) && Cools.eq(batch, detlDto.getBatch()) |
| | | && brand.equals(detlDto.getBrand()) && standby1.equals(detlDto.getStandby1()) |
| | | && standby2.equals(detlDto.getStandby2()) && standby3.equals(detlDto.getStandby3())) { |
| | | return detlDto; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getPakinPakoutStatus$(){ |
| | | if (Cools.isEmpty(this.pakinPakoutStatus)) return null; |
| | | switch (this.pakinPakoutStatus){ |
| | |
| | | int updateSettle(@Param("orderId")Long orderId, @Param("settle")Long settle, @Param("userId")Long userId); |
| | | |
| | | List<Order> selectComplete(); |
| | | List<Order> selectComplete1(); |
| | | List<Order> selectComplete8(); |
| | | |
| | | int addToLogTable(Order order); |
| | |
| | | void remove(Long orderId); |
| | | |
| | | List<Order> selectComplete(); |
| | | List<Order> selectComplete1(); |
| | | List<Order> selectComplete8(); |
| | | |
| | | boolean addToLogTable(Order order); |
| | |
| | | now, // 修改时间 |
| | | null // 备注 |
| | | ); |
| | | order.setPakinPakoutStatus(1); |
| | | if (!orderService.insert(order)) { |
| | | throw new CoolException("生成单据主档失败,请联系管理员"); |
| | | } |
| | |
| | | List<DetlDto> orderDetails = param.getOrderDetails(); |
| | | for (DetlDto detail : orderDetails) { |
| | | DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(),detail.getBrand(),detail.getStandby1(),detail.getStandby2(),detail.getStandby3(),detail.getLineNumber(), detail.getAnfme()); |
| | | if (DetlDto.has(list, dto)) { |
| | | if (DetlDto.hasLineNumber(list, dto)) { |
| | | DetlDto detlDto = DetlDto.findLineNumber(list, dto.getMatnr(), dto.getBatch(),dto.getBrand(),dto.getStandby1(),dto.getStandby2(),dto.getStandby3(),dto.getLineNumber()); |
| | | assert detlDto != null; |
| | | detlDto.setAnfme(detlDto.getAnfme() + detail.getAnfme()); |
| | |
| | | now, // 修改时间 |
| | | null // 备注 |
| | | ); |
| | | order.setPakinPakoutStatus(2); |
| | | if (!orderService.insert(order)) { |
| | | throw new CoolException("生成单据主档失败,请联系管理员"); |
| | | } |
| | |
| | | List<DetlDto> orderDetails = param.getOrderDetails(); |
| | | for (DetlDto detail : orderDetails) { |
| | | DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(),detail.getBrand(),detail.getStandby1(),detail.getStandby2(),detail.getStandby3(),detail.getLineNumber(), detail.getAnfme()); |
| | | if (DetlDto.has(list, dto)) { |
| | | if (DetlDto.hasLineNumber(list, dto)) { |
| | | DetlDto detlDto = DetlDto.findLineNumber(list, dto.getMatnr(), dto.getBatch(),dto.getBrand(),dto.getStandby1(),dto.getStandby2(),dto.getStandby3(),dto.getLineNumber()); |
| | | assert detlDto != null; |
| | | detlDto.setAnfme(detlDto.getAnfme() + detail.getAnfme()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Order> selectComplete1() { |
| | | return this.baseMapper.selectComplete1(); |
| | | } |
| | | |
| | | @Override |
| | | public List<Order> selectComplete8() { |
| | | return this.baseMapper.selectComplete8(); |
| | | } |
| | |
| | | |
| | | @Scheduled(cron = "0/5 * * * * ? ") |
| | | @Async("orderThreadPool") |
| | | public void completeAndReportOrderIssued() { |
| | | String erpReport = Parameter.get().getErpReport(); |
| | | if (!Cools.isEmpty(erpReport) && erpReport.equals("true")) { |
| | | List<Order> orderList = orderService.selectComplete1(); |
| | | // List<Order> orderList = orderService.selectList(new EntityWrapper<Order>().eq("settle", 1L).eq("status", 1).orderBy("create_time", true)); |
| | | for (Order order : orderList) { |
| | | try { |
| | | ReturnT<String> result = orderSyncHandler.startOrderIssued(order); |
| | | if (!result.isSuccess()) { |
| | | log.error("单据[orderNo={}]上报erp失败", order.getOrderNo()); |
| | | } |
| | | } catch (Exception e){ |
| | | log.error(e.getMessage()); |
| | | log.error("单据[orderNo={}]上报erp失败", order.getOrderNo()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Scheduled(cron = "0/5 * * * * ? ") |
| | | @Async("orderThreadPool") |
| | | public void completeAndReportOrderInAndOutUtil() { |
| | | String erpReport = Parameter.get().getErpReport(); |
| | | if (!Cools.isEmpty(erpReport) && erpReport.equals("true")) { |
| | | List<Order> orders = OrderInAndOutUtil.selectComplete(null); |
| | | for (Order order : orders) { |
| | | ReturnT<String> result = orderSyncHandler.startOrderInAndOutUtil(order); |
| | | if (!result.isSuccess()) { |
| | | try { |
| | | ReturnT<String> result = orderSyncHandler.startOrderInAndOutUtil(order); |
| | | if (!result.isSuccess()) { |
| | | log.error("单据[orderNo={}]转上报表失败", order.getOrderNo()); |
| | | } |
| | | } catch (Exception e){ |
| | | log.error(e.getMessage()); |
| | | log.error("单据[orderNo={}]转上报表失败", order.getOrderNo()); |
| | | } |
| | | } |
| | |
| | | |
| | | @Scheduled(cron = "0/5 * * * * ? ") |
| | | @Async("orderThreadPool") |
| | | public void completeAndReportOrder() { |
| | | public void completeAndReportOrderReport() { |
| | | String erpReport = Parameter.get().getErpReport(); |
| | | if (!Cools.isEmpty(erpReport) && erpReport.equals("true")) { |
| | | List<Order> orders = orderService.selectComplete(); |
| | | for (Order order : orders) { |
| | | ReturnT<String> result = orderSyncHandler.startOrder(order); |
| | | if (!result.isSuccess()) { |
| | | try { |
| | | ReturnT<String> result = orderSyncHandler.startOrderReport(order); |
| | | if (!result.isSuccess()) { |
| | | log.error("单据[orderNo={}]上报erp失败", order.getOrderNo()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | log.error("单据[orderNo={}]上报erp失败", order.getOrderNo()); |
| | | } |
| | | } |
| | |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.asrs.utils.OrderInAndOutUtil; |
| | | import com.zy.common.constant.MesConstant; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.model.MesPakinParam; |
| | | import com.zy.common.model.MesPakoutParam; |
| | | import com.zy.common.utils.HttpHandler; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private DocTypeService docTypeService; |
| | | @Transactional |
| | | public ReturnT<String> startOrderIssued(Order order) { |
| | | DocType docType = docTypeService.selectById(order.getDocType()); |
| | | if (null == docType) { |
| | | return SUCCESS; |
| | | } |
| | | List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId()); |
| | | |
| | | OrderInAndOutUtil.insertOrder(order.getPakinPakoutStatus$(),order); |
| | | // 单据明细档 |
| | | List<DetlDto> list = new ArrayList<>(); |
| | | List<OrderDetl> orderDetlList = new ArrayList<>(); |
| | | |
| | | for (OrderDetl detail : orderDetls) { |
| | | DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(),detail.getBrand(),detail.getStandby1(),detail.getStandby2(),detail.getStandby3(), detail.getAnfme()); |
| | | if (DetlDto.has(list, dto)) { |
| | | DetlDto detlDto = DetlDto.find(list, dto.getMatnr(), dto.getBatch(),dto.getBrand(),dto.getStandby1(),dto.getStandby2(),dto.getStandby3()); |
| | | assert detlDto != null; |
| | | detlDto.setAnfme(detlDto.getAnfme() + detail.getAnfme()); |
| | | |
| | | OrderDetl orderDetl = OrderDetl.find(orderDetlList, dto.getMatnr(), dto.getBatch(),dto.getBrand(),dto.getStandby1(),dto.getStandby2(),dto.getStandby3()); |
| | | assert orderDetl != null; |
| | | orderDetl.setAnfme(orderDetl.getAnfme() + detail.getAnfme()); |
| | | } else { |
| | | list.add(dto); |
| | | orderDetlList.add(detail); |
| | | } |
| | | } |
| | | for (OrderDetl orderDetl : orderDetlList){ |
| | | OrderInAndOutUtil.insertOrderDetl(order.getPakinPakoutStatus$(),order,orderDetl); |
| | | } |
| | | // 修改订单状态 1.未作业 ===>> 2.作业中 |
| | | if (!orderService.updateSettle(order.getId(), 2L, null)) { |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | return SUCCESS; |
| | | } |
| | | @Transactional |
| | | public ReturnT<String> startOrderInAndOutUtil(Order order) { |
| | | DocType docType = docTypeService.selectById(order.getDocType()); |
| | | if (null == docType) { |
| | | return SUCCESS; |
| | | } |
| | | List<OrderDetl> orderDetls = OrderInAndOutUtil.selectByOrderId(order.getPakinPakoutStatus$(), order.getId()); |
| | | Order orderNew = new Order(order); |
| | | orderService.insert(orderNew); |
| | | for (OrderDetl orderDetl : orderDetls){ |
| | | OrderDetl orderDetlNew = new OrderDetl(orderDetl); |
| | | orderDetlNew.setOrderId(orderNew.getId()); |
| | | orderDetlService.insert(orderDetlNew); |
| | | Order orderSou = orderService.selectByNo(order.getOrderNo()); |
| | | if (!orderSou.getSettle().equals(2L)){ |
| | | return FAIL.setMsg("订单状态不正确,请联系管理员"); |
| | | } |
| | | // 修改订单状态 4.完成 ===>> 6.已上报 |
| | | List<OrderDetl> orderDetlList = orderDetlService.selectByOrderId(orderSou.getId()); |
| | | |
| | | List<OrderDetl> orderDetls = OrderInAndOutUtil.selectByOrderId(order.getPakinPakoutStatus$(), order.getId()); |
| | | |
| | | for (OrderDetl orderDetlSou : orderDetlList){ |
| | | for (OrderDetl orderDetl : orderDetls){ |
| | | if (orderDetl.getQty().equals(0D)){ |
| | | continue; |
| | | } |
| | | if (orderDetlSou.beSimilar(orderDetl)){ |
| | | double v = orderDetlSou.getAnfme() - orderDetlSou.getQty(); |
| | | if (v<orderDetl.getQty() || orderDetl.getQty().equals(v)){ |
| | | orderDetlSou.setQty(orderDetlSou.getAnfme()); |
| | | orderDetl.setQty(orderDetl.getQty() - v); |
| | | break; |
| | | } else { |
| | | orderDetlSou.setQty(orderDetlSou.getQty()+orderDetl.getQty()); |
| | | orderDetl.setQty(0D); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | for (OrderDetl orderDetlSou : orderDetlList){ |
| | | orderDetlService.updateById(orderDetlSou); |
| | | } |
| | | // 修改订单状态 2.作业中 ===>> 4.待上报 |
| | | if (!orderService.updateSettle(orderSou.getId(), 4L, null)) { |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | // 修改订单状态 4.完成 ===>> 6.结束 |
| | | OrderInAndOutUtil.updateOrder(order.getPakinPakoutStatus$(),order.getId(),6L,null); |
| | | return SUCCESS; |
| | | } |
| | | @Transactional |
| | | public ReturnT<String> startOrder(Order order) { |
| | | public ReturnT<String> startOrderReport(Order order) { |
| | | DocType docType = docTypeService.selectById(order.getDocType()); |
| | | if (null == docType) { |
| | | return SUCCESS; |
| | |
| | | return false; |
| | | } |
| | | |
| | | public static boolean hasLineNumber(List<DetlDto> detlDtos, DetlDto detlDto) { |
| | | for (DetlDto dto : detlDtos) { |
| | | if (dto.getMatnr().equals(detlDto.getMatnr()) && Cools.eq(dto.getBatch(), detlDto.getBatch()) |
| | | && Cools.eq(dto.getBrand(), detlDto.getBrand()) && Cools.eq(dto.getStandby1(), detlDto.getStandby1()) |
| | | && Cools.eq(dto.getStandby2(), detlDto.getStandby2()) && Cools.eq(dto.getStandby3(), detlDto.getStandby3()) |
| | | && dto.getLineNumber().equals(detlDto.getLineNumber())) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public static DetlDto find(List<DetlDto> detlDtos, String matnr, String batch, String brand, String standby1, String standby2, String standby3) { |
| | | if (Cools.isEmpty(matnr)) { |
| | | return null; |
| | |
| | | order by create_time asc |
| | | </select> |
| | | |
| | | <select id="selectComplete1" resultMap="BaseResultMap"> |
| | | select top 5 * |
| | | from man_order |
| | | where 1=1 |
| | | and settle = 1 |
| | | and status = 1 |
| | | order by create_time asc |
| | | </select> |
| | | |
| | | <select id="selectComplete8" resultMap="BaseResultMap"> |
| | | select top 5 * |
| | | from man_order |