| | |
| | | @TableField("box_type3") |
| | | private String boxType3 = "1"; |
| | | |
| | | /** |
| | | * 宽度 |
| | | */ |
| | | @ApiModelProperty(value= "宽度") |
| | | @TableField("width") |
| | | private Double width; |
| | | |
| | | /** |
| | | * 高度 |
| | | */ |
| | | @ApiModelProperty(value= "高度") |
| | | @TableField("height") |
| | | private Double height; |
| | | |
| | | public OrderDetlPakin() {} |
| | | |
| | | public OrderDetlPakin(Long orderId, String orderNo, Double anfme, Double qty, String matnr, String maktx, String batch, String specs, String model, String color, String brand, String unit, Double price, String sku, Double units, String barcode, String origin, String manu, String manuDate, String itemNum, Double safeQty, Double weight, Double manLength, Double volume, String threeCode, String supp, String suppCode, Integer beBatch, String deadTime, Integer deadWarn, Integer source, Integer inspect, Integer danger, Integer status, Long createBy, Date createTime, Long updateBy, Date updateTime, String memo) { |
| | |
| | | @TableField("box_type3") |
| | | private String boxType3 = "1"; |
| | | |
| | | /** |
| | | * 宽度 |
| | | */ |
| | | @ApiModelProperty(value= "宽度") |
| | | @TableField("width") |
| | | private Double width; |
| | | |
| | | /** |
| | | * 高度 |
| | | */ |
| | | @ApiModelProperty(value= "高度") |
| | | @TableField("height") |
| | | private Double height; |
| | | |
| | | public OrderDetlPakout() {} |
| | | |
| | | public OrderDetlPakout(Long orderId, String orderNo, Double anfme, Double qty, String matnr, String maktx, String batch, String specs, String model, String color, String brand, String unit, Double price, String sku, Double units, String barcode, String origin, String manu, String manuDate, String itemNum, Double safeQty, Double weight, Double manLength, Double volume, String threeCode, String supp, String suppCode, Integer beBatch, String deadTime, Integer deadWarn, Integer source, Integer inspect, Integer danger, Integer status, Long createBy, Date createTime, Long updateBy, Date updateTime, String memo) { |
| | |
| | | |
| | | OrderPakin selectOrderMoveStatus(); |
| | | OrderPakin selectOrderMoveStatusInitial(); |
| | | |
| | | List<String> AllStatusSatisfyOrder(@Param("moveStatus") Integer moveStatus); |
| | | boolean updateOrderStatus(@Param("orderNo")String orderNo); |
| | | } |
| | |
| | | |
| | | OrderPakout selectOrderMoveStatus(); |
| | | OrderPakout selectOrderMoveStatusInitial(); |
| | | |
| | | List<String> AllStatusSatisfyOrder(@Param("moveStatus") Integer moveStatus); |
| | | boolean updateOrderStatus(@Param("orderNo")String orderNo); |
| | | } |
| | |
| | | OrderPakin selectOrderMoveStatus(); |
| | | OrderPakin selectOrderMoveStatusInitial(); |
| | | |
| | | List<String> AllStatusSatisfyOrder(Integer moveStatus); |
| | | |
| | | boolean updateOrderStatus(String orderNo); |
| | | |
| | | } |
| | |
| | | OrderPakout selectOrderMoveStatus(); |
| | | OrderPakout selectOrderMoveStatusInitial(); |
| | | |
| | | List<String> AllStatusSatisfyOrder(Integer moveStatus); |
| | | |
| | | boolean updateOrderStatus(String orderNo); |
| | | |
| | | } |
| | |
| | | return this.baseMapper.selectOrderMoveStatusInitial(); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> AllStatusSatisfyOrder(Integer moveSatus){ |
| | | return this.baseMapper.AllStatusSatisfyOrder(moveSatus); |
| | | } |
| | | |
| | | @Override |
| | | public boolean updateOrderStatus(String orderNo){ |
| | | return this.baseMapper.updateOrderStatus(orderNo); |
| | | } |
| | | } |
| | |
| | | return this.baseMapper.selectOrderMoveStatusInitial(); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> AllStatusSatisfyOrder(Integer moveSatus){ |
| | | return this.baseMapper.AllStatusSatisfyOrder(moveSatus); |
| | | } |
| | | |
| | | @Override |
| | | public boolean updateOrderStatus(String orderNo){ |
| | | return this.baseMapper.updateOrderStatus(orderNo); |
| | | } |
| | | } |
| | |
| | | package com.zy.asrs.task; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.zy.asrs.entity.BasArmMastSign; |
| | | import com.zy.asrs.entity.BasArmRules; |
| | | import com.zy.asrs.entity.OrderDetl; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.OrderToLine; |
| | | import com.zy.asrs.service.BasArmMastSignService; |
| | | import com.zy.asrs.service.BasArmRulesService; |
| | | import com.zy.asrs.service.OrderDetlService; |
| | | import com.zy.asrs.service.OrderService; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.service.impl.OrderDetlServiceImpl; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.asrs.task.handler.OrderToLineHandler; |
| | | import com.zy.asrs.utils.GroupedLockerOptimizerUtils; |
| | | import com.zy.asrs.utils.OptimizedLockerPackingUtils; |
| | | import com.zy.asrs.utils.OrderInAndOutUtil; |
| | | import com.zy.asrs.utils.ToSortLineUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | //订单下发至分拣线 |
| | | public class OrderToSortLineScheduler { |
| | | @Autowired |
| | | private OrderService orderService; |
| | | private OrderPakinService orderPakinService; |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | private OrderDetlPakinService orderDetlPakinService; |
| | | @Autowired |
| | | private BasArmRulesService basArmRulesService; |
| | | @Autowired |
| | |
| | | @Scheduled(cron = "0/3 * * * * ? ") |
| | | private void orderToSortLine() { |
| | | //获取未下发单据 |
| | | List<String> orderNos = orderService.AllStatusSatisfyOrder(0); |
| | | List<String> orderNos = orderPakinService.AllStatusSatisfyOrder(0); |
| | | if(orderNos == null || orderNos.isEmpty()) { |
| | | // log.info("未有新订单"); |
| | | return; |
| | |
| | | //遍历单据 |
| | | for (String orderNo : orderNos) { |
| | | try{ |
| | | List<OrderDetl> orderDetls = orderDetlService.selectByOrderNo(orderNo); |
| | | List<OrderDetlPakin> orderDetlPakinList = orderDetlPakinService.selectList(new EntityWrapper<OrderDetlPakin>().eq("order_no",orderNo)); |
| | | // List<GroupedLockerOptimizerUtils.Item> items = new ArrayList<>(); |
| | | if (orderDetls.size()<1){ |
| | | if (orderDetlPakinList.size()<1){ |
| | | continue; |
| | | } |
| | | |
| | | |
| | | List<OptimizedLockerPackingUtils.Item> items = new ArrayList<>(); |
| | | for (OrderDetl orderDetl:orderDetls){ |
| | | for (OrderDetlPakin orderDetl:orderDetlPakinList){ |
| | | Integer number = basArmRulesService.getNumber(orderDetl.getWeight(),orderDetl.getVolume(),orderDetl.getManLength(),orderDetl.getWidth(),orderDetl.getHeight()); |
| | | if (number == null) { |
| | | BasArmRules basArmRules = new BasArmRules(); |
| | |
| | | log.error("下发单据异常,跳转下一个订单===>"+e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | private void groupRemainders(List<OrderDetl> sameMaterialList, double totalRemainder, |
| | | int number, List<OrderToLine.MatList> matLists) { |
| | | // 策略1: 如果余料总量较大,尝试分成多个合理大小的组 |
| | | if (totalRemainder > number * 0.6) { |
| | | // 可以分成2组或更多组 |
| | | int suggestedGroups = (int) Math.ceil(totalRemainder / (number * 0.8)); |
| | | distributeRemainders(sameMaterialList, totalRemainder, suggestedGroups, matLists); |
| | | } else { |
| | | // 小余料单组处理 |
| | | Long bindingTag = System.currentTimeMillis(); |
| | | matLists.add(createMatListItem(sameMaterialList.get(0), totalRemainder, bindingTag, true)); |
| | | } |
| | | } |
| | | |
| | | |
| | | private void distributeRemainders(List<OrderDetl> sameMaterialList, double totalRemainder, |
| | | int groupCount, List<OrderToLine.MatList> matLists) { |
| | | double average = totalRemainder / groupCount; |
| | | |
| | | for (int i = 0; i < groupCount; i++) { |
| | | double groupQuantity; |
| | | if (i == groupCount - 1) { |
| | | // 最后一组取剩余所有 |
| | | groupQuantity = totalRemainder - (average * (groupCount - 1)); |
| | | } else { |
| | | groupQuantity = average; |
| | | } |
| | | |
| | | // 为每组生成唯一标记 |
| | | Long groupTag = System.currentTimeMillis() + i; |
| | | matLists.add(createMatListItem(sameMaterialList.get(0), groupQuantity, groupTag, true)); |
| | | } |
| | | } |
| | | |
| | | private OrderToLine.MatList createMatListItem(OrderDetl orderDetl, Double quantity, Long bindingTag, boolean isRemainder) { |
| | | return new OrderToLine.MatList( |
| | | orderDetl.getMatnr(), |
| | | orderDetl.getSupp(), |
| | | quantity, |
| | | orderDetl.getBarcode(), |
| | | 1, |
| | | isRemainder ? null : orderDetl.getOrigin(), |
| | | isRemainder ? bindingTag : System.currentTimeMillis() |
| | | ); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.zy.asrs.entity.param.OrderToLine; |
| | | import com.zy.asrs.service.ApiLogService; |
| | | import com.zy.asrs.service.BasArmRulesService; |
| | | import com.zy.asrs.service.OrderPakinService; |
| | | import com.zy.asrs.service.OrderService; |
| | | import com.zy.asrs.task.AbstractHandler; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | @Autowired |
| | | private OrderService orderService; |
| | | private OrderPakinService orderPakinService; |
| | | |
| | | @Value("${line.address.URL}") |
| | | //端口 |
| | |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | success = true; |
| | | orderService.updateOrderStatus(orderToline.getOrderNo()); //更新订单状态 0 -> 1 |
| | | orderPakinService.updateOrderStatus(orderToline.getOrderNo()); //更新订单状态 0 -> 1 |
| | | } else { |
| | | log.error("下发单据!!!url:{};request:{};response:{}", URL+Path, JSON.toJSONString(orderToline), response); |
| | | throw new CoolException("下发单据失败"); |
| | |
| | | order by update_time |
| | | </select> |
| | | |
| | | <select id="AllStatusSatisfyOrder" resultType="String"> |
| | | select order_no |
| | | from man_order_pakin |
| | | where move_status = #{moveStatus} |
| | | </select> |
| | | |
| | | <update id="updateOrderStatus"> |
| | | update man_order_pakin |
| | | set move_status = 1 |
| | | where 1=1 |
| | | and order_no = #{orderNo} |
| | | </update> |
| | | |
| | | </mapper> |
| | |
| | | order by update_time |
| | | </select> |
| | | |
| | | <select id="AllStatusSatisfyOrder" resultType="String"> |
| | | select order_no |
| | | from man_order_pakout |
| | | where move_status = #{moveStatus} |
| | | </select> |
| | | |
| | | <update id="updateOrderStatus"> |
| | | update man_order_pakout |
| | | set move_status = 1 |
| | | where 1=1 |
| | | and order_no = #{orderNo} |
| | | </update> |
| | | |
| | | </mapper> |