|  |  |  | 
|---|
|  |  |  | package com.zy.asrs.wms.task.handler; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSON; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONArray; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
|---|
|  |  |  | import com.zy.asrs.common.sys.entity.OperateLog; | 
|---|
|  |  |  | import com.zy.asrs.common.sys.service.OperateLogService; | 
|---|
|  |  |  | import com.zy.asrs.common.utils.HttpHandler; | 
|---|
|  |  |  | import com.zy.asrs.common.utils.Utils; | 
|---|
|  |  |  | import com.zy.asrs.common.wms.entity.Order; | 
|---|
|  |  |  | import com.zy.asrs.common.wms.entity.WaitPakin; | 
|---|
|  |  |  | import com.zy.asrs.common.wms.entity.WrkDetl; | 
|---|
|  |  |  | import com.zy.asrs.common.wms.entity.WrkMast; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.zy.asrs.wms.task.core.ReturnT; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Value; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  | import org.springframework.transaction.interceptor.TransactionAspectSupport; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Iterator; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.text.SimpleDateFormat; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * Created by vincent on 2020/7/6 | 
|---|
|  |  |  | 
|---|
|  |  |  | private WaitPakinLogService waitPakinLogService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OrderService orderService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private OperateLogService operateLogService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Value("${erp.url}") | 
|---|
|  |  |  | private String ERP_URL; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Value("${erp.report}") | 
|---|
|  |  |  | private String ERP_REPORT; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Value("${erp.login}") | 
|---|
|  |  |  | private String ERP_LOGIN; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // update asr_wrk_mast set inv_wh = 'Y', ove_mk = 'Y' where wrk_no = | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | 
|---|
|  |  |  | while (iterator.hasNext()) { | 
|---|
|  |  |  | WrkDetl wrkDetl = iterator.next(); | 
|---|
|  |  |  | if (!Cools.isEmpty(wrkDetl.getOrderNo())) { | 
|---|
|  |  |  | wrkDetlsKeyOrder.add(wrkDetl); | 
|---|
|  |  |  | orderService.checkComplete(wrkDetl.getOrderNo(),hostId); | 
|---|
|  |  |  | iterator.remove(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 保存工作明细档历史档 | 
|---|
|  |  |  | if (!wrkDetlLogService.saveToHistory(wrkMast.getWrkNo(), hostId)) { | 
|---|
|  |  |  | //                exceptionHandle("保存工作明细历史档[workNo={0}]失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | exceptionHandle("保存工作明细历史档[workNo={0}]失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 删除工作明细档 | 
|---|
|  |  |  | if (!wrkDetlService.remove(new LambdaQueryWrapper<WrkDetl>().eq(WrkDetl::getWrkNo, wrkMast.getWrkNo()).eq(WrkDetl::getHostId, hostId))) { | 
|---|
|  |  |  | //                exceptionHandle("删除工作明细档[workNo={0}]失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | exceptionHandle("删除工作明细档[workNo={0}]失败", wrkMast.getWrkNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 修改订单状态 作业中 ===>> 已完成 | 
|---|
|  |  |  | for (WrkDetl wrkDetl : wrkDetlsKeyOrder) { | 
|---|
|  |  |  | orderService.checkComplete(wrkDetl.getOrderNo(), hostId); | 
|---|
|  |  |  | List<WrkDetl> wrkDetls2 = wrkDetlService.list(new LambdaQueryWrapper<WrkDetl>().eq(WrkDetl::getWrkNo, wrkMast.getWrkNo()).eq(WrkDetl::getHostId, hostId)); | 
|---|
|  |  |  | // 区分订单任务 | 
|---|
|  |  |  | if (!Cools.isEmpty(wrkDetls2)) { | 
|---|
|  |  |  | Iterator<WrkDetl> iterator = wrkDetls2.iterator(); | 
|---|
|  |  |  | while (iterator.hasNext()) { | 
|---|
|  |  |  | WrkDetl wrkDetl = iterator.next(); | 
|---|
|  |  |  | if (!Cools.isEmpty(wrkDetl.getOrderNo())) { | 
|---|
|  |  |  | orderService.checkComplete(wrkDetl.getOrderNo(),hostId); | 
|---|
|  |  |  | iterator.remove(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //            // 修改订单状态 作业中 ===>> 已完成 | 
|---|
|  |  |  | //            for (WrkDetl wrkDetl : wrkDetlsKeyOrder) { | 
|---|
|  |  |  | //                orderService.checkComplete(wrkDetl.getOrderNo(), hostId); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("fail", e); | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|