自动化立体仓库 - WMS系统
skyouc
22 小时以前 bf945f3086a3d0334dbff0ef1d64d6a1d87dffc9
src/main/java/com/zy/asrs/task/handler/OrderSyncHandler.java
@@ -5,13 +5,11 @@
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.exception.CoolException;
import com.zy.asrs.entity.DocType;
import com.zy.asrs.entity.Order;
import com.zy.asrs.entity.OrderDetl;
import com.zy.asrs.service.ApiLogService;
import com.zy.asrs.service.DocTypeService;
import com.zy.asrs.service.OrderDetlService;
import com.zy.asrs.service.OrderService;
import com.zy.api.entity.ReportOrderParam;
import com.zy.api.service.KopenApiService;
import com.zy.asrs.entity.*;
import com.zy.asrs.enums.OrderTypeEnum;
import com.zy.asrs.service.*;
import com.zy.asrs.task.AbstractHandler;
import com.zy.asrs.task.core.ReturnT;
import com.zy.asrs.utils.OrderInAndOutUtil;
@@ -21,6 +19,7 @@
import com.zy.common.model.MesPakoutParam;
import com.zy.common.utils.HttpHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@@ -46,6 +45,12 @@
    private ApiLogService apiLogService;
    @Autowired
    private DocTypeService docTypeService;
    @Autowired
    private OrderPakinService  orderPakinService;
    @Autowired
    private OrderDetlPakinService orderDetlPakinService;
    @Autowired
    private KopenApiService kopenApiService;
    @Transactional
    public ReturnT<String> startOrderIssuedOnceMore(Order order) {
@@ -97,7 +102,7 @@
        for (OrderDetl detail : orderDetls) {
            DetlDto dto = new DetlDto(detail.getMatnr(), detail.getBatch(),detail.getBrand(),detail.getStandby1(),detail.getStandby2(),detail.getStandby3(),
                    detail.getBoxType1(),detail.getBoxType2(),detail.getBoxType3(), detail.getAnfme());
                    detail.getBoxType1(),detail.getBoxType2(),detail.getBoxType3(), detail.getAnfme(), detail.getThreeCode());
            if (DetlDto.has(list, dto)) {
                DetlDto detlDto = DetlDto.find(list, dto.getMatnr(), dto.getBatch(),dto.getBrand(),dto.getStandby1(),dto.getStandby2(),dto.getStandby3(),dto.getBoxType1(),dto.getBoxType2(),dto.getBoxType3());
                assert detlDto != null;
@@ -114,6 +119,15 @@
        for (OrderDetl orderDetl : orderDetlList){
            orderDetl.setWorkQty(0D);
            OrderInAndOutUtil.insertOrderDetl(order.getPakinPakoutStatus$(),order,orderDetl);
            //小松:如果下发备货派工单,则生成备货出库+备货入库
            if (order.getDocType().equals(OrderTypeEnum.TRANSFER.type.longValue())){
                try {
                    ifTransfetInsertStockIn(order,orderDetl);
                }catch (Exception e){
                    throw new CoolException(e.getMessage());
                }
            }
        }
        // 修改订单状态 1.未作业 ===>> 2.作业中
        if (!orderService.updateSettle(order.getId(), 2L, null)) {
@@ -122,8 +136,41 @@
        return SUCCESS;
    }
    @Transactional(rollbackFor = Exception.class)
    public void ifTransfetInsertStockIn(Order order, OrderDetl orderDetl){
        OrderPakin orderPakin = new OrderPakin();
        BeanUtils.copyProperties(order,orderPakin);
        orderPakin.setDocType(OrderTypeEnum.STOCK_IN.type.longValue());
        if (!orderPakinService.insert(orderPakin)){
            throw new CoolException("插入备货入库单失败");
        }
        OrderDetlPakin orderDetlPakin = new OrderDetlPakin();
        BeanUtils.copyProperties(orderDetl,orderDetlPakin);
        orderDetlPakin.setOrderId(orderPakin.getId());
        if (!orderDetlPakinService.insert(orderDetlPakin)){
            throw new CoolException("插入备货入库单失败");
        }
    }
    @Transactional
    public ReturnT<String> startOrderInAndOutUtil(Order order) {
        //小松:轮训到备货派工单是查询备货入库单是否完成
        if (order.getDocType().equals(OrderTypeEnum.STOCK_IN.type.longValue())){
            return SUCCESS;
        }
        if (order.getDocType().equals(OrderTypeEnum.TRANSFER.type.longValue())){
            OrderPakin orderPakin = orderPakinService.selectByNo(order.getOrderNo());
            if (null != orderPakin) {
                if (!orderPakin.getSettle().equals(4L)){
                    return SUCCESS;
                }
            }
        }
        DocType docType = docTypeService.selectById(order.getDocType());
        if (null == docType) {
            return SUCCESS;
@@ -165,6 +212,16 @@
        OrderInAndOutUtil.updateOrder(order.getPakinPakoutStatus$(),order.getId(),6L,null);
        return SUCCESS;
    }
    /**
     * 单据上报
     * @author Ryan
     * @date 2025/12/15 16:14
     * @param order
     * @return com.zy.asrs.task.core.ReturnT<java.lang.String>
     */
    @Transactional
    public ReturnT<String> startOrderReport(Order order) {
        DocType docType = docTypeService.selectById(order.getDocType());
@@ -190,6 +247,9 @@
            String response = "";
            boolean success = false;
            try {
                ReportOrderParam orderParam = new ReportOrderParam();
                kopenApiService.getInDispatchResult(orderParam);
//                response = new HttpHandler.Builder()
//                        .setUri(MesConstant.URL)
//                        .setPath(MesConstant.PAKIN_URL)