|  |  |  | 
|---|
|  |  |  | package com.zy.asrs.service.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSON; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
|---|
|  |  |  | import com.core.common.BaseRes; | 
|---|
|  |  |  | import com.core.common.Cools; | 
|---|
|  |  |  | import com.core.common.DateUtils; | 
|---|
|  |  |  | import com.core.common.SnowflakeIdWorker; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.mapper.Wrapper; | 
|---|
|  |  |  | import com.core.common.*; | 
|---|
|  |  |  | import com.core.exception.CoolException; | 
|---|
|  |  |  | import com.zy.asrs.entity.*; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.CombParam; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.MobileAdjustParam; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.OpenOrderPakinParam; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.*; | 
|---|
|  |  |  | import com.zy.asrs.mapper.BasDevpMapper; | 
|---|
|  |  |  | import com.zy.asrs.mapper.ManLocDetlMapper; | 
|---|
|  |  |  | import com.zy.asrs.service.*; | 
|---|
|  |  |  | import com.zy.asrs.third.CodeDataParam; | 
|---|
|  |  |  | import com.zy.asrs.third.CodeParam; | 
|---|
|  |  |  | import com.zy.asrs.third.MesResponse; | 
|---|
|  |  |  | import com.zy.asrs.third.TokenUtils; | 
|---|
|  |  |  | import com.zy.asrs.utils.MatUtils; | 
|---|
|  |  |  | import com.zy.common.constant.AgvSiteConstant; | 
|---|
|  |  |  | import com.zy.common.constant.ApiInterfaceConstant; | 
|---|
|  |  |  | import com.zy.common.entity.Parameter; | 
|---|
|  |  |  | import com.zy.common.model.DetlDto; | 
|---|
|  |  |  | import com.zy.common.model.MesCombParam; | 
|---|
|  |  |  | import com.zy.common.service.CommonService; | 
|---|
|  |  |  | import com.zy.common.utils.HttpHandler; | 
|---|
|  |  |  | 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 java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.Iterator; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import javax.annotation.Resource; | 
|---|
|  |  |  | import java.io.IOException; | 
|---|
|  |  |  | import java.math.BigDecimal; | 
|---|
|  |  |  | import java.text.SimpleDateFormat; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 移动端服务核心类 | 
|---|
|  |  |  | 
|---|
|  |  |  | private OpenService openService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SnowflakeIdWorker snowflakeIdWorker; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ApiLogService apiLogService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private BasCrnpService basCrnpService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LocMastService locMastService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LocDetlService locDetlService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private StaDescService staDescService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CommonService commonService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NodeService nodeService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ManLocDetlService manLocDetlService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ManLocDetlMapper manLocDetlMapper; | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private InventoryCheckOrderService checkOrderService; | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private InventoryCheckOrderDetlService checkOrderDetlService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private BasDevpMapper basDevpMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Value("${mes.url}") | 
|---|
|  |  |  | private String url; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Value("${mes.code}") | 
|---|
|  |  |  | private String code; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public R inLocCallAgv(String sta, String inSta) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BasDevp basDevp = basDevpMapper.selectById(inSta); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 判断是否有出库任务 | 
|---|
|  |  |  | Wrapper<WrkMast> wrapper = new EntityWrapper<WrkMast>().lt("wrk_sts", 14).in("io_type", 101, 103, 107, 110); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | switch (inSta) { | 
|---|
|  |  |  | case "1040": | 
|---|
|  |  |  | wrapper.in("source_sta_no", "1043", "1044"); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case "2010": | 
|---|
|  |  |  | wrapper.in("source_sta_no", "2013", "2014"); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case "2000": | 
|---|
|  |  |  | wrapper.in("source_sta_no", "2003", "2004"); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case "3010": | 
|---|
|  |  |  | wrapper.in("source_sta_no", "3013", "3014"); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | default: | 
|---|
|  |  |  | } | 
|---|
|  |  |  | int count = wrkMastService.selectCount(wrapper); | 
|---|
|  |  |  | log.info("入库呼叫agv呼叫站点:{},目标站点:{},出库任务数:{}", sta, inSta, count); | 
|---|
|  |  |  | if (count != 0) { | 
|---|
|  |  |  | return R.parse(inSta + "站点存在出库任务"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 先绑定 | 
|---|
|  |  |  | //        boolean flag = bindPodAndBerth(sta); | 
|---|
|  |  |  | //        if (!flag) { | 
|---|
|  |  |  | //            return R.parse(inSta + "绑定失败"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ForwardAGVTaskParam forwardAGVTaskParam = new ForwardAGVTaskParam(); | 
|---|
|  |  |  | forwardAGVTaskParam.setReqCode(UUID.randomUUID().toString().replace("-", "")); | 
|---|
|  |  |  | forwardAGVTaskParam.setClientCode("IWMS"); | 
|---|
|  |  |  | forwardAGVTaskParam.setTaskTyp("GT3"); | 
|---|
|  |  |  | forwardAGVTaskParam.setCtnrTyp("2"); | 
|---|
|  |  |  | forwardAGVTaskParam.setPriority("1"); | 
|---|
|  |  |  | List<ForwardAGVTaskParam.PositionCodePaths> positionCodePathsList = new ArrayList<>(); | 
|---|
|  |  |  | positionCodePathsList.add(new ForwardAGVTaskParam.PositionCodePaths(sta, "05")); | 
|---|
|  |  |  | positionCodePathsList.add(new ForwardAGVTaskParam.PositionCodePaths(inSta, "05")); | 
|---|
|  |  |  | forwardAGVTaskParam.setPositionCodePath(positionCodePathsList); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String body = JSON.toJSONString(forwardAGVTaskParam); | 
|---|
|  |  |  | String response = ""; | 
|---|
|  |  |  | String message = ""; | 
|---|
|  |  |  | boolean success = false; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | response = new HttpHandler.Builder() | 
|---|
|  |  |  | .setUri(ApiInterfaceConstant.AGV_IP) | 
|---|
|  |  |  | .setPath(ApiInterfaceConstant.AGV_CALL_IN_PATH) | 
|---|
|  |  |  | .setJson(body) | 
|---|
|  |  |  | .build() | 
|---|
|  |  |  | .doPost(); | 
|---|
|  |  |  | JSONObject jsonObject = JSON.parseObject(response); | 
|---|
|  |  |  | if (jsonObject.getInteger("code").equals(0)) { | 
|---|
|  |  |  | success = true; | 
|---|
|  |  |  | // 入库暂存+1 | 
|---|
|  |  |  | basDevp.setInQty(basDevp.getInQty() + 1); | 
|---|
|  |  |  | basDevpMapper.updateById(basDevp); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | message = jsonObject.getString("message"); | 
|---|
|  |  |  | log.error("入库呼叫agv失败!!!url:{};request:{};response:{}", ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_CALL_IN_PATH, body, response); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("入库呼叫agv异常", e); | 
|---|
|  |  |  | } finally { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | // 保存接口日志 | 
|---|
|  |  |  | apiLogService.save( | 
|---|
|  |  |  | "入库呼叫agv", | 
|---|
|  |  |  | ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_CALL_IN_PATH, | 
|---|
|  |  |  | null, | 
|---|
|  |  |  | "127.0.0.1", | 
|---|
|  |  |  | body, | 
|---|
|  |  |  | response, | 
|---|
|  |  |  | success | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("", e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return success ? R.ok("呼叫agv成功") : R.parse(message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public R unbind(String site) { | 
|---|
|  |  |  | String staMap = AgvSiteConstant.SiteMap.get(site); | 
|---|
|  |  |  | if (staMap == null) { | 
|---|
|  |  |  | return R.parse("没有找到该站点的入库映射:" + site); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | JSONObject jsonObject = new JSONObject(); | 
|---|
|  |  |  | jsonObject.put("reqCode", UUID.randomUUID().toString().replace("-", "")); // 请求唯一值 | 
|---|
|  |  |  | jsonObject.put("ctnrTyp", "2"); // 容器类型2 | 
|---|
|  |  |  | jsonObject.put("stgBinCode", staMap); // 仓位编号,根据客仓编号转换 | 
|---|
|  |  |  | jsonObject.put("indBind", "0"); // 1绑定,0解绑 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String body = jsonObject.toJSONString(); | 
|---|
|  |  |  | String response = ""; | 
|---|
|  |  |  | String message = ""; | 
|---|
|  |  |  | boolean success = false; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | response = new HttpHandler.Builder() | 
|---|
|  |  |  | .setUri(ApiInterfaceConstant.AGV_IP) | 
|---|
|  |  |  | .setPath(ApiInterfaceConstant.AGV_BIND_PATH) | 
|---|
|  |  |  | .setJson(body) | 
|---|
|  |  |  | .build() | 
|---|
|  |  |  | .doPost(); | 
|---|
|  |  |  | JSONObject res = JSON.parseObject(response); | 
|---|
|  |  |  | message = jsonObject.getString("message"); | 
|---|
|  |  |  | if (res.getInteger("code").equals(0)) { | 
|---|
|  |  |  | success = true; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | log.error("调用agv解绑暂存位失败!!!url:{};request:{};response:{}", ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_BIND_PATH, body, response); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("调用agv解绑暂存位异常", e); | 
|---|
|  |  |  | } finally { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | // 保存接口日志 | 
|---|
|  |  |  | apiLogService.save( | 
|---|
|  |  |  | "调用agv解绑暂存位", | 
|---|
|  |  |  | ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_BIND_PATH, | 
|---|
|  |  |  | null, | 
|---|
|  |  |  | "127.0.0.1", | 
|---|
|  |  |  | body, | 
|---|
|  |  |  | response, | 
|---|
|  |  |  | success | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("", e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return success ? R.ok("解绑成功") : R.parse(message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private boolean bindPodAndBerth(String sta) { | 
|---|
|  |  |  | String staMap = AgvSiteConstant.SiteMap.get(sta); | 
|---|
|  |  |  | if (staMap == null) { | 
|---|
|  |  |  | log.error("没有找到该站点的入库映射:{}", sta); | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | JSONObject jsonObject = new JSONObject(); | 
|---|
|  |  |  | jsonObject.put("reqCode", UUID.randomUUID().toString().replace("-", "")); // 请求唯一值 | 
|---|
|  |  |  | jsonObject.put("ctnrTyp", "2"); // 容器类型2 | 
|---|
|  |  |  | jsonObject.put("stgBinCode", staMap); // 仓位编号,根据客仓编号转换 | 
|---|
|  |  |  | jsonObject.put("indBind", "1"); // 1绑定,0解绑 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String body = jsonObject.toJSONString(); | 
|---|
|  |  |  | String response = ""; | 
|---|
|  |  |  | boolean success = false; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | response = new HttpHandler.Builder() | 
|---|
|  |  |  | .setUri(ApiInterfaceConstant.AGV_IP) | 
|---|
|  |  |  | .setPath(ApiInterfaceConstant.AGV_BIND_PATH) | 
|---|
|  |  |  | .setJson(body) | 
|---|
|  |  |  | .build() | 
|---|
|  |  |  | .doPost(); | 
|---|
|  |  |  | JSONObject res = JSON.parseObject(response); | 
|---|
|  |  |  | if (res.getInteger("code").equals(0)) { | 
|---|
|  |  |  | success = true; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | log.error("调用agv绑定仓位失败!!!url:{};request:{};response:{}", ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_BIND_PATH, body, response); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("调用agv绑定仓位异常", e); | 
|---|
|  |  |  | } finally { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | // 保存接口日志 | 
|---|
|  |  |  | apiLogService.save( | 
|---|
|  |  |  | "调用agv绑定仓位", | 
|---|
|  |  |  | ApiInterfaceConstant.AGV_IP + ApiInterfaceConstant.AGV_BIND_PATH, | 
|---|
|  |  |  | null, | 
|---|
|  |  |  | "127.0.0.1", | 
|---|
|  |  |  | body, | 
|---|
|  |  |  | response, | 
|---|
|  |  |  | success | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("", e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return success; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | 
|---|
|  |  |  | if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) { | 
|---|
|  |  |  | throw new CoolException(BaseRes.PARAM); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 判断是否有相同条码的数据 | 
|---|
|  |  |  | if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). | 
|---|
|  |  |  | eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) { | 
|---|
|  |  |  | throw new CoolException(param.getBarcode() + "数据正在进行入库"); | 
|---|
|  |  |  | HashMap<String, Object> comData = new HashMap<>(); | 
|---|
|  |  |  | param.getCombMats().forEach(elem -> { | 
|---|
|  |  |  | // 判断是否有相同条码的数据 | 
|---|
|  |  |  | if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). | 
|---|
|  |  |  | eq("zpallet", param.getBarcode()) | 
|---|
|  |  |  | .eq("io_status", "N") | 
|---|
|  |  |  | .eq("matnr", elem.getMatnr()).eq("batch", elem.getBatch())) > 0) { | 
|---|
|  |  |  | throw new CoolException(param.getBarcode() + "已有相同数据"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (comData.get(elem.getThreeCode()) == null) { | 
|---|
|  |  |  | comData.put(elem.getThreeCode(), elem); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | throw new CoolException(elem.getThreeCode() + "该条码扫码了多次"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (param.getBarcode().length() != 8) { | 
|---|
|  |  |  | throw new CoolException("条码长度不是8位===>>" + param.getBarcode()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", param.getBarcode())); | 
|---|
|  |  |  | int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet", param.getBarcode())); | 
|---|
|  |  |  | //        int countwait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet",param.getBarcode())); | 
|---|
|  |  |  | if (countLoc > 0 || countWrk > 0) { | 
|---|
|  |  |  | throw new CoolException("工作档/库存条码数据已存在===>>" + param.getBarcode()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Date now = new Date(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 无单组托 | 
|---|
|  |  |  | 
|---|
|  |  |  | // 生成入库通知档 | 
|---|
|  |  |  | List<DetlDto> detlDtos = new ArrayList<>(); | 
|---|
|  |  |  | param.getCombMats().forEach(elem -> { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 判断是否有相同条码的数据 | 
|---|
|  |  |  | if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). | 
|---|
|  |  |  | eq("zpallet", param.getBarcode()) | 
|---|
|  |  |  | .eq("io_status", "N") | 
|---|
|  |  |  | .eq("matnr", elem.getMatnr()).eq("three_code",elem.getThreeCode()).eq("batch", elem.getBatch())) > 0) { | 
|---|
|  |  |  | throw new CoolException(param.getBarcode() + "已有相同数据"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme()); | 
|---|
|  |  |  | if (DetlDto.has(detlDtos, detlDto)) { | 
|---|
|  |  |  | DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch()); | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new CoolException("保存入库通知档失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 关联组托 | 
|---|
|  |  |  | // 关联组托 | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | Order order = orderService.selectByNo(param.getOrderNo()); | 
|---|
|  |  |  | if (order.getSettle() > 2) { | 
|---|
|  |  |  | if (Cools.isEmpty(order) || order.getSettle() > 2) { | 
|---|
|  |  |  | throw new CoolException("单据编号已过期"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 生成入库通知档 | 
|---|
|  |  |  | List<DetlDto> detlDtos = new ArrayList<>(); | 
|---|
|  |  |  | param.getCombMats().forEach(elem -> { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<String> codes = new ArrayList<>(); | 
|---|
|  |  |  | for (CombParam.CombMat elem : param.getCombMats()) { | 
|---|
|  |  |  | codes.add(elem.getThreeCode()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<CodeDataParam> data = getData(TokenUtils.getToken(url), new CodeParam(codes)); | 
|---|
|  |  |  | List<CombParam.CombMat> combMats = param.getCombMats(); | 
|---|
|  |  |  | for (int i = 0; i < data.size(); i++) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //} | 
|---|
|  |  |  | //for (CombParam.CombMat elem : param.getCombMats()) { | 
|---|
|  |  |  | CombParam.CombMat elem = combMats.get(i); | 
|---|
|  |  |  | CodeDataParam codeDataParam = data.get(i); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | elem.setTemp1(codeDataParam.getQuality()); | 
|---|
|  |  |  | elem.setAnfme(codeDataParam.getQty()); | 
|---|
|  |  |  | //elem.setBatch(codeDataParam.getBatchNum()); | 
|---|
|  |  |  | elem.setThreeCode(codeDataParam.getBarcode()); | 
|---|
|  |  |  | elem.setMatnr(codeDataParam.getProductionCode()); | 
|---|
|  |  |  | elem.setMaktx(codeDataParam.getProductionName()); | 
|---|
|  |  |  | //            param.getCombMats().forEach(elem -> { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 订单明细数量校验 | 
|---|
|  |  |  | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch()); | 
|---|
|  |  |  | if (Cools.isEmpty(orderDetl)) { | 
|---|
|  |  |  | throw new CoolException("该单据中未找到对应物料明细"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.isEmpty(codeDataParam.getQuality())){ | 
|---|
|  |  |  | throw new CoolException("条码未返回质量状态"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!codeDataParam.getQuality().equals(orderDetl.getInspect())) { | 
|---|
|  |  |  | throw new CoolException("单据质量状态和组托物料不匹配"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (elem.getAnfme() > orderDetl.getEnableQty()) { | 
|---|
|  |  |  | throw new CoolException(orderDetl.getMatnr() + "入库数量不合法"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 修改订单明细数量 | 
|---|
|  |  |  | if (!orderDetlService.increase(order.getId(), elem.getMatnr(), elem.getBatch(), elem.getAnfme())) { | 
|---|
|  |  |  | throw new CoolException("修改单据明细数量失败"); | 
|---|
|  |  |  | // 修改订单作业数量 | 
|---|
|  |  |  | if (!orderDetlService.increaseWorkQty(order.getId(), elem.getMatnr(), elem.getBatch(), elem.getAnfme())) { | 
|---|
|  |  |  | throw new CoolException("修改单据作业数量失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme()); | 
|---|
|  |  |  | //                DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme(),orderDetl.getManu()); | 
|---|
|  |  |  | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme(), elem.getThreeCode() | 
|---|
|  |  |  | , orderDetl.getManu(), codeDataParam.getBatchNum(), orderDetl.getSupp(), orderDetl.getTemp1(), orderDetl.getTemp2(), orderDetl.getTemp3(), orderDetl.getTemp4()); | 
|---|
|  |  |  | detlDto.setTemp1(codeDataParam.getQuality()); | 
|---|
|  |  |  | detlDto.setFromOrderNo(codeDataParam.getBarcode()); | 
|---|
|  |  |  | if (DetlDto.has(detlDtos, detlDto)) { | 
|---|
|  |  |  | DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch()); | 
|---|
|  |  |  | DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch(),detlDto.getFromOrderNo()); | 
|---|
|  |  |  | assert one != null; | 
|---|
|  |  |  | one.setAnfme(one.getAnfme() + detlDto.getAnfme()); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | detlDtos.add(detlDto); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | //            }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (DetlDto detlDto : detlDtos) { | 
|---|
|  |  |  | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); | 
|---|
|  |  |  | if (Cools.isEmpty(mat)) { | 
|---|
|  |  |  | 
|---|
|  |  |  | WaitPakin waitPakin = new WaitPakin(); | 
|---|
|  |  |  | waitPakin.sync(mat); | 
|---|
|  |  |  | waitPakin.setOrderNo(order.getOrderNo());   // 单据编号 | 
|---|
|  |  |  | waitPakin.setBatch(detlDto.getBatch());     // 批号 | 
|---|
|  |  |  | waitPakin.setBatch(detlDto.getBatch());     // 序列码 | 
|---|
|  |  |  | waitPakin.setZpallet(param.getBarcode());   // 托盘码 | 
|---|
|  |  |  | waitPakin.setIoStatus("N");     // 入出状态 | 
|---|
|  |  |  | waitPakin.setAnfme(detlDto.getAnfme());  // 数量 | 
|---|
|  |  |  | 
|---|
|  |  |  | waitPakin.setAppeTime(now); | 
|---|
|  |  |  | waitPakin.setModiUser(userId); | 
|---|
|  |  |  | waitPakin.setModiTime(now); | 
|---|
|  |  |  | waitPakin.setDanger(detlDto.getDanger()); | 
|---|
|  |  |  | waitPakin.setManu(detlDto.getMark()); //标记 | 
|---|
|  |  |  | waitPakin.setOrigin(order.getItemName());//仓库 | 
|---|
|  |  |  | waitPakin.setSupp(detlDto.getSuppName()); //供应商 | 
|---|
|  |  |  | waitPakin.setSku(detlDto.getCustomer()); //客户名称 | 
|---|
|  |  |  | waitPakin.setThreeCode(detlDto.getFromOrderNo()); //条码 | 
|---|
|  |  |  | waitPakin.setTemp1(detlDto.getTemp1()); | 
|---|
|  |  |  | waitPakin.setTemp2(detlDto.getTemp2()); | 
|---|
|  |  |  | waitPakin.setTemp3(detlDto.getTemp3()); | 
|---|
|  |  |  | waitPakin.setTemp4(detlDto.getTemp4()); | 
|---|
|  |  |  | int countWrk2 = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet", param.getBarcode())); | 
|---|
|  |  |  | if (countWrk2 > 0) { | 
|---|
|  |  |  | throw new CoolException("工作档条码数据已存在===>>" + param.getBarcode()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!waitPakinService.insert(waitPakin)) { | 
|---|
|  |  |  | throw new CoolException("保存入库通知档失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public List<CodeDataParam> getData(Map<String, Object> token, CodeParam codeParam) { | 
|---|
|  |  |  | String response = null; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | response = new HttpHandler.Builder() | 
|---|
|  |  |  | .setHeaders(token) | 
|---|
|  |  |  | .setUri(url) | 
|---|
|  |  |  | .setPath(code) | 
|---|
|  |  |  | .setJson(JSON.toJSONString(codeParam)) | 
|---|
|  |  |  | .build() | 
|---|
|  |  |  | .doPost(); | 
|---|
|  |  |  | } catch (IOException e) { | 
|---|
|  |  |  | throw new RuntimeException(e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | log.info("getData:{}", response); | 
|---|
|  |  |  | MesResponse jsonObject = JSON.parseObject(response, MesResponse.class); | 
|---|
|  |  |  | if (jsonObject.getCode().equals(200)) { | 
|---|
|  |  |  | JSONObject jsonObject1 = JSON.parseObject(jsonObject.getData()); | 
|---|
|  |  |  | if (jsonObject1.getString("barcodeList") != null) { | 
|---|
|  |  |  | return JSON.parseArray(jsonObject1.getString("barcodeList"), CodeDataParam.class); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | throw new CoolException(jsonObject.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void mergeComb(CombParam param, Long userId) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) { | 
|---|
|  |  |  | throw new CoolException(BaseRes.PARAM); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (param.getCombMats().stream().anyMatch(obj -> obj.getAnfme() == null)) { | 
|---|
|  |  |  | throw new CoolException("入库物料数量不能为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Order order = orderService.selectByNo(param.getOrderNo()); | 
|---|
|  |  |  | if (Cools.isEmpty(order) || order.getSettle() > 2) { | 
|---|
|  |  |  | throw new CoolException("单据编号已过期"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 判断是否有相同条码的数据 | 
|---|
|  |  |  | if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>(). | 
|---|
|  |  |  | eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) { | 
|---|
|  |  |  | throw new CoolException(param.getBarcode() + "数据正在进行入库"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", param.getBarcode())); | 
|---|
|  |  |  | WrkMast wrkMast = wrkMastService.selectByBarcode(param.getBarcode()); | 
|---|
|  |  |  | if (wrkMast.getWrkSts() != 14 && wrkMast.getIoType() != 104) { | 
|---|
|  |  |  | throw new CoolException(param.getBarcode() + "该条码数据不为并板出库"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //设置非null批号, | 
|---|
|  |  |  | for (CombParam.CombMat combMat : param.getCombMats()) { | 
|---|
|  |  |  | if (combMat.getBatch() == null) { | 
|---|
|  |  |  | combMat.setBatch(""); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Date now = new Date(); | 
|---|
|  |  |  | for (CombParam.CombMat combMat : param.getCombMats()) { | 
|---|
|  |  |  | // 订单明细数量校验 | 
|---|
|  |  |  | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), combMat.getMatnr(), combMat.getBatch()); | 
|---|
|  |  |  | if (Cools.isEmpty(orderDetl)) { | 
|---|
|  |  |  | throw new CoolException("该单据中未找到对应物料明细"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (combMat.getAnfme() > orderDetl.getEnableQty()) { | 
|---|
|  |  |  | throw new CoolException(orderDetl.getMatnr() + "入库数量不合法"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 修改订单作业数量 | 
|---|
|  |  |  | if (!orderDetlService.increaseWorkQty(order.getId(), combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme())) { | 
|---|
|  |  |  | throw new CoolException("修改单据作业数量失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Mat mat = matService.selectByMatnr(combMat.getMatnr()); | 
|---|
|  |  |  | WrkDetl wrkDetl = new WrkDetl(); | 
|---|
|  |  |  | wrkDetl.sync(mat); | 
|---|
|  |  |  | wrkDetl.setBatch(combMat.getBatch()); | 
|---|
|  |  |  | wrkDetl.setWrkNo(wrkMast.getWrkNo()); | 
|---|
|  |  |  | wrkDetl.setOrderNo(param.getOrderNo()); | 
|---|
|  |  |  | wrkDetl.setZpallet(param.getBarcode()); | 
|---|
|  |  |  | wrkDetl.setAnfme(combMat.getAnfme()); | 
|---|
|  |  |  | wrkDetl.setAppeTime(now); | 
|---|
|  |  |  | wrkDetl.setAppeUser(userId); | 
|---|
|  |  |  | wrkDetl.setModiTime(now); | 
|---|
|  |  |  | wrkDetl.setModiUser(userId); | 
|---|
|  |  |  | wrkDetl.setManu(orderDetl.getManu()); | 
|---|
|  |  |  | wrkDetl.setSupp(orderDetl.getSupp()); | 
|---|
|  |  |  | wrkDetl.setTemp1(orderDetl.getTemp1()); | 
|---|
|  |  |  | wrkDetl.setTemp2(orderDetl.getTemp2()); | 
|---|
|  |  |  | wrkDetl.setTemp3(orderDetl.getTemp3()); | 
|---|
|  |  |  | wrkDetl.setTemp4(orderDetl.getTemp4()); | 
|---|
|  |  |  | wrkDetlService.insert(wrkDetl); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 商品上架 | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void onSale(CombParam param) { | 
|---|
|  |  |  | Date now = new Date(); | 
|---|
|  |  |  | // 获取库位号 | 
|---|
|  |  |  | String locno = param.getLocno(); | 
|---|
|  |  |  | Node node = nodeService.selectByUuid(locno); | 
|---|
|  |  |  | if (Cools.isEmpty(node)) { | 
|---|
|  |  |  | throw new CoolException(param.getLocno() + ":库位不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取商品列表 | 
|---|
|  |  |  | for (CombParam.CombMat combMat : param.getCombMats()) { | 
|---|
|  |  |  | Mat mat = matService.selectByMatnr(combMat.getMatnr()); | 
|---|
|  |  |  | if (Cools.isEmpty(mat)) { | 
|---|
|  |  |  | throw new CoolException(combMat.getMatnr() + ":商品档案不存在!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.isEmpty(combMat.getAnfme()) || combMat.getAnfme() == 0) { | 
|---|
|  |  |  | throw new CoolException(combMat.getMatnr() + ":商品数量有误!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.isEmpty(combMat.getBatch())) { | 
|---|
|  |  |  | //                throw new CoolException(combMat.getMatnr() + ":商品批号有误!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ManLocDetl manLocDetl = new ManLocDetl(); | 
|---|
|  |  |  | manLocDetl.setLocNo(locno); | 
|---|
|  |  |  | manLocDetl.setNodeId(node.getId()); | 
|---|
|  |  |  | manLocDetl.setMaktx(mat.getMaktx()); | 
|---|
|  |  |  | manLocDetl.setMatnr(mat.getMatnr()); | 
|---|
|  |  |  | manLocDetl.setBatch(Cools.isEmpty(combMat.getBatch()) ? "" : combMat.getBatch()); | 
|---|
|  |  |  | manLocDetl.setAnfme(combMat.getAnfme()); | 
|---|
|  |  |  | manLocDetl.setModiTime(now); | 
|---|
|  |  |  | if (!manLocDetlService.insert(manLocDetl)) { | 
|---|
|  |  |  | throw new CoolException("商品上架失败!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 商品下架 | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void offSale(OffSaleParam offSaleParam) { | 
|---|
|  |  |  | ManLocDetl manLocDetl = manLocDetlMapper.selectLocNo0(offSaleParam.getLocNo(), offSaleParam.getMatnr()); | 
|---|
|  |  |  | if (Cools.isEmpty(manLocDetl)) { | 
|---|
|  |  |  | throw new CoolException("无此商品!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | double anfme = manLocDetl.getAnfme() - offSaleParam.getAnfme(); | 
|---|
|  |  |  | if (anfme < 0) { | 
|---|
|  |  |  | throw new CoolException("商品库存不足!"); | 
|---|
|  |  |  | } else if (anfme == 0) { | 
|---|
|  |  |  | manLocDetlMapper.deleteLocNo0(offSaleParam.getLocNo(), offSaleParam.getMatnr()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | manLocDetlMapper.updateAnfme0(anfme, manLocDetl.getNodeId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 查找商品 | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 添加明细 | 
|---|
|  |  |  | for (WrkDetl wrkDetl : list) { | 
|---|
|  |  |  | if (wrkDetl.getAnfme() == 0.0D) { continue; } | 
|---|
|  |  |  | if (wrkDetl.getAnfme() == 0.0D) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // todo 盘点记录、保存调整记录 | 
|---|
|  |  |  | String orderNo = wrkDetl.getOrderNo(); | 
|---|
|  |  |  | Mat mat = matService.selectByMatnr(wrkDetl.getMatnr()); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 修改盘点任务主档状态 | 
|---|
|  |  |  | wrkMast.setFullPlt(wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()).size() != 0?"Y":"N"); | 
|---|
|  |  |  | wrkMast.setFullPlt(wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()).size() != 0 ? "Y" : "N"); | 
|---|
|  |  |  | wrkMast.setModiTime(now); | 
|---|
|  |  |  | wrkMast.setModiUser(userId); | 
|---|
|  |  |  | if (!wrkMastService.updateById(wrkMast)) { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void packComb(CombParam param, Long userId) { | 
|---|
|  |  |  | if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) { | 
|---|
|  |  |  | throw new CoolException(BaseRes.PARAM); | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new CoolException(elem.getMatnr() + "条码已下线,请检查!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme()); | 
|---|
|  |  |  | Mat analyse = MatUtils.analyseMat(elem.getMatnr()); | 
|---|
|  |  |  | // 条码、物料代码、序列号、数量 | 
|---|
|  |  |  | DetlDto detlDto = new DetlDto(elem.getMatnr(), analyse.getMatnr(), analyse.getBarcode(), elem.getAnfme()); | 
|---|
|  |  |  | //                DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme()); | 
|---|
|  |  |  | if (DetlDto.has(detlDtos, detlDto)) { | 
|---|
|  |  |  | DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch()); | 
|---|
|  |  |  | assert one != null; | 
|---|
|  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (packDown) { | 
|---|
|  |  |  | // 数据上报 todo | 
|---|
|  |  |  | MesCombParam mesCombParam = new MesCombParam(); | 
|---|
|  |  |  | mesCombParam.setZpallet(param.getBarcode()); | 
|---|
|  |  |  | mesCombParam.setPakinTime(DateUtils.convert(now)); | 
|---|
|  |  |  | mesCombParam.setLgort("5008"); | 
|---|
|  |  |  | mesCombParam.setPlantCode("5000"); | 
|---|
|  |  |  | mesCombParam.setFromCode("5012-20"); | 
|---|
|  |  |  | mesCombParam.setStationCode("JJQ-PFZPDB-XX"); | 
|---|
|  |  |  | for (DetlDto detlDto : detlDtos) { | 
|---|
|  |  |  | mesCombParam.getList().add(new MesCombParam.Detl(detlDto.getOrderNo(), detlDto.getAnfme())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String response = ""; | 
|---|
|  |  |  | boolean success = false; | 
|---|
|  |  |  | //                try { | 
|---|
|  |  |  | //                    response = new HttpHandler.Builder() | 
|---|
|  |  |  | //                            .setUri(url) | 
|---|
|  |  |  | //                            .setPath(code) | 
|---|
|  |  |  | //                            .setJson(JSON.toJSONString(mesCombParam)) | 
|---|
|  |  |  | //                            .build() | 
|---|
|  |  |  | //                            .doPost(); | 
|---|
|  |  |  | //                    JSONObject jsonObject = JSON.parseObject(response); | 
|---|
|  |  |  | //                    if (jsonObject.getInteger("code").equals(200)) { | 
|---|
|  |  |  | //                        success = true; | 
|---|
|  |  |  | //                    } else if (jsonObject.getInteger("code").equals(500)) { | 
|---|
|  |  |  | //                        log.error("请求接口失败!!!url:{};request:{};response:{}", MesConstant.URL+MesConstant.PACK_DOWN_URL, JSON.toJSONString(mesCombParam), response); | 
|---|
|  |  |  | //                        throw new CoolException(jsonObject.getString("msg")); | 
|---|
|  |  |  | //                    } else { | 
|---|
|  |  |  | //                        log.error("请求接口失败!!!url:{};request:{};response:{}", MesConstant.URL+MesConstant.PACK_DOWN_URL, JSON.toJSONString(mesCombParam), response); | 
|---|
|  |  |  | //                        throw new CoolException("上报mes系统失败"); | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | //                } catch (Exception e) { | 
|---|
|  |  |  | //                    log.error("fail", e); | 
|---|
|  |  |  | //                    throw new CoolException(e.getMessage()); | 
|---|
|  |  |  | //                } finally { | 
|---|
|  |  |  | //                    try { | 
|---|
|  |  |  | //                        // 保存接口日志 | 
|---|
|  |  |  | //                        apiLogService.save( | 
|---|
|  |  |  | //                                "打包下线帮托上报", | 
|---|
|  |  |  | //                                MesConstant.URL + MesConstant.PACK_DOWN_URL, | 
|---|
|  |  |  | //                                null, | 
|---|
|  |  |  | //                                "127.0.0.1", | 
|---|
|  |  |  | //                                JSON.toJSONString(mesCombParam), | 
|---|
|  |  |  | //                                response, | 
|---|
|  |  |  | //                                success | 
|---|
|  |  |  | //                        ); | 
|---|
|  |  |  | //                    } catch (Exception e) { log.error("", e); } | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 生成入库单据 | 
|---|
|  |  |  | String orderNo = "PACK" + snowflakeIdWorker.nextId(); | 
|---|
|  |  |  | OpenOrderPakinParam openParam = new OpenOrderPakinParam(); | 
|---|
|  |  |  | openParam.setOrderNo(orderNo); | 
|---|
|  |  |  | openParam.setOrderTime(DateUtils.convert(now)); | 
|---|
|  |  |  | openParam.setInboundDate(DateUtils.convert(now)); | 
|---|
|  |  |  | openParam.setOrderType("打包入库单"); | 
|---|
|  |  |  | openParam.setOrderDetails(detlDtos); | 
|---|
|  |  |  | openParam.setDetails(detlDtos); | 
|---|
|  |  |  | openService.pakinOrderCreate(openParam); | 
|---|
|  |  |  | Order order = orderService.selectByNo(orderNo); | 
|---|
|  |  |  | if (null == order) { | 
|---|
|  |  |  | throw new CoolException("生成单据失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (orderService.updateSettle(order.getId(), 2L, userId)) { | 
|---|
|  |  |  | if (!orderService.updateSettle(order.getId(), 2L, userId)) { | 
|---|
|  |  |  | throw new CoolException("修改单据状态失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 生成入库通知档 | 
|---|
|  |  |  | for (DetlDto detlDto : detlDtos) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 修改作业数量 ---------------------------------------- | 
|---|
|  |  |  | // 订单明细数量校验 | 
|---|
|  |  |  | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), detlDto.getMatnr(), detlDto.getBatch()); | 
|---|
|  |  |  | if (detlDto.getAnfme() > orderDetl.getEnableQty()) { | 
|---|
|  |  |  | throw new CoolException(orderDetl.getMatnr() + "入库数量不合法"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 修改订单作业数量 | 
|---|
|  |  |  | if (!orderDetlService.increaseWorkQty(order.getId(), detlDto.getMatnr(), detlDto.getBatch(), detlDto.getAnfme())) { | 
|---|
|  |  |  | throw new CoolException("修改单据作业数量失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 保存入库通知档 | 
|---|
|  |  |  | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); | 
|---|
|  |  |  | if (Cools.isEmpty(mat)) { | 
|---|
|  |  |  | throw new CoolException(detlDto.getMatnr() + "商品档案不存在"); | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new CoolException("保存入库通知档失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 修改打包数据状态 | 
|---|
|  |  |  | Pack pack = packService.selectByBarcode(detlDto.getMatnr()); | 
|---|
|  |  |  | Pack pack = packService.selectByBarcode(detlDto.getOrderNo()); | 
|---|
|  |  |  | pack.setSettle(2L); | 
|---|
|  |  |  | pack.setUpdateTime(now); | 
|---|
|  |  |  | pack.setUpdateBy(userId); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void pakoutByOrder(JSONObject param, Long userId) { | 
|---|
|  |  |  | Integer staNo = param.containsKey("staNo") ? Integer.parseInt(param.get("staNo").toString()) : 0; | 
|---|
|  |  |  | String orderNo = param.containsKey("orderNo") ? param.get("orderNo").toString() : ""; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BasDevp sta = basDevpService.checkSiteStatus(staNo); | 
|---|
|  |  |  | //根据订单号生成出库任务工作档 | 
|---|
|  |  |  | Order order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no", orderNo)); | 
|---|
|  |  |  | if (order.getSettle() != 1 && order.getSettle() != 2) { | 
|---|
|  |  |  | throw new CoolException("该订单已处理"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<OrderDetl> orderDetls = orderDetlService.selectList(new EntityWrapper<OrderDetl>().eq("order_no", orderNo)); | 
|---|
|  |  |  | Date now = new Date(); | 
|---|
|  |  |  | for (OrderDetl orderDetl : orderDetls) { | 
|---|
|  |  |  | //查询所有库位状态为F的库位信息 | 
|---|
|  |  |  | List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), null, null, orderDetl.getSupp(), orderDetl.getTemp1(), orderDetl.getTemp2()); | 
|---|
|  |  |  | if (locDetls.size() == 0) { | 
|---|
|  |  |  | throw new CoolException("库存中没有该物料"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (LocDetl locDetl : locDetls) { | 
|---|
|  |  |  | //如果该库位出库路线所用的堆垛机out_enable不为Y,跳过该循环 | 
|---|
|  |  |  | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("loc_no", locDetl.getLocNo())); | 
|---|
|  |  |  | if (Cools.isEmpty(locMast)) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | BasCrnp crn_no = basCrnpService.selectOne(new EntityWrapper<BasCrnp>() | 
|---|
|  |  |  | .eq("crn_no", locMast.getCrnNo())); | 
|---|
|  |  |  | if (Cools.isEmpty(crn_no) || !crn_no.getOutEnable().equals("Y")) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //可出库数量 = 订单数量 - 作业中数量 | 
|---|
|  |  |  | Double outQty = orderDetl.getAnfme() - orderDetl.getWorkQty(); | 
|---|
|  |  |  | if (outQty <= 0) { | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 判断入出库类型:101.全板出库 or 103.拣料出库 | 
|---|
|  |  |  | Double sumCount = locDetlService.getLocDetlSumQty(locDetl.getLocNo()); | 
|---|
|  |  |  | Double curOutQty = outQty >= locDetl.getAnfme() ? locDetl.getAnfme() : outQty;   //本次出库量 | 
|---|
|  |  |  | int ioType = sumCount <= curOutQty ? 101 : 103; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | stockOut(orderDetl, sta, locDetl, curOutQty, ioType, userId, now); | 
|---|
|  |  |  | order.setSettle(2L); | 
|---|
|  |  |  | order.setUpdateBy(userId); | 
|---|
|  |  |  | order.setUpdateTime(now); | 
|---|
|  |  |  | if (!orderService.update(order, new EntityWrapper<Order>().eq("order_no", orderNo))) { | 
|---|
|  |  |  | throw new CoolException("更新订单状态失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orderDetl.setWorkQty(orderDetl.getWorkQty() + curOutQty); | 
|---|
|  |  |  | orderDetl.setUpdateBy(userId); | 
|---|
|  |  |  | orderDetl.setUpdateTime(now); | 
|---|
|  |  |  | Wrapper wrapper = new EntityWrapper<OrderDetl>().eq("order_no", orderNo) | 
|---|
|  |  |  | .eq("matnr", orderDetl.getMatnr()); | 
|---|
|  |  |  | if (!Cools.isEmpty(orderDetl.getBatch())) { | 
|---|
|  |  |  | wrapper.eq("batch", orderDetl.getBatch()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!orderDetlService.update(orderDetl, wrapper)) { | 
|---|
|  |  |  | throw new CoolException("更新订单明细失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | //    @Transactional | 
|---|
|  |  |  | public void leftoversOut(Map<String, Object> map, Long userId) { | 
|---|
|  |  |  | String barcode = map.get("barcode").toString(); | 
|---|
|  |  |  | String barcode2 = map.get("barcode2").toString(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", barcode2)); | 
|---|
|  |  |  | int countWrk = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("barcode", barcode2).ne("io_type", 200)); | 
|---|
|  |  |  | int countwait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", barcode2)); | 
|---|
|  |  |  | if (countLoc > 0 || countWrk > 0 || countwait > 0) { | 
|---|
|  |  |  | throw new CoolException("该条码已被使用===>>" + barcode2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", barcode).eq("io_type", 103)); | 
|---|
|  |  |  | if (Cools.isEmpty(wrkMast)) { | 
|---|
|  |  |  | throw new CoolException("未查询到拣料任务"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | int workNo = commonService.getWorkNo(1); | 
|---|
|  |  |  | WrkMast wrkMast2 = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", barcode2).eq("io_type", 200)); | 
|---|
|  |  |  | if (Cools.isEmpty(wrkMast2)) { | 
|---|
|  |  |  | Date now = new Date(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | WrkMast wrkMast1 = new WrkMast(); | 
|---|
|  |  |  | wrkMast1.sync(wrkMast); | 
|---|
|  |  |  | wrkMast1.setWrkNo(workNo); | 
|---|
|  |  |  | wrkMast1.setWrkSts(2L); | 
|---|
|  |  |  | wrkMast1.setIoType(200); | 
|---|
|  |  |  | wrkMast1.setSourceStaNo(wrkMast.getStaNo() == 113 ? 111 : 117); | 
|---|
|  |  |  | wrkMast1.setStaNo(wrkMast.getStaNo() == 113 ? 204 : 304); | 
|---|
|  |  |  | wrkMast1.setIoTime(now); | 
|---|
|  |  |  | wrkMast1.setIoPri(13D); // 优先级:13 | 
|---|
|  |  |  | wrkMast1.setCrnNo(wrkMast.getCrnNo()); | 
|---|
|  |  |  | wrkMast1.setSourceLocNo(wrkMast.getLocNo()); // 源库位 | 
|---|
|  |  |  | wrkMast1.setFullPlt("Y"); // 满板:Y | 
|---|
|  |  |  | wrkMast1.setPicking("N"); // 拣料 | 
|---|
|  |  |  | wrkMast1.setExitMk("N"); // 退出 | 
|---|
|  |  |  | wrkMast1.setEmptyMk("N"); // 空板 | 
|---|
|  |  |  | wrkMast1.setLinkMis("N"); | 
|---|
|  |  |  | wrkMast1.setAppeUser(userId); // 操作人员数据 | 
|---|
|  |  |  | wrkMast1.setAppeTime(now); | 
|---|
|  |  |  | wrkMast1.setModiUser(userId); | 
|---|
|  |  |  | wrkMast1.setModiTime(now); | 
|---|
|  |  |  | wrkMast1.setBarcode(barcode2); | 
|---|
|  |  |  | if (!wrkMastService.insert(wrkMast1)) { | 
|---|
|  |  |  | throw new CoolException("保存工作档失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("zpallet", map.get("barcode"))); | 
|---|
|  |  |  | if (Cools.isEmpty(wrkDetls)) { | 
|---|
|  |  |  | throw new CoolException("未查询到拣料任务明细"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (WrkDetl wrkDetl : wrkDetls) { | 
|---|
|  |  |  | WrkDetl wrkDetl1 = new WrkDetl(); | 
|---|
|  |  |  | wrkDetl1.sync(wrkDetl); | 
|---|
|  |  |  | wrkDetl1.setWrkNo(workNo); | 
|---|
|  |  |  | wrkDetlService.insert(wrkDetl1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void pdaAdjust(pdaAdjustParam param, Long userId) { | 
|---|
|  |  |  | if (Cools.isEmpty(param)) { | 
|---|
|  |  |  | throw new CoolException("盘点列表参数为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (InventoryCheckOrderDetl orderDetl : param.getParam()) { | 
|---|
|  |  |  | InventoryCheckOrderDetl inventoryCheckOrderDetl = checkOrderDetlService.selectOne(new EntityWrapper<InventoryCheckOrderDetl>() | 
|---|
|  |  |  | .eq("order_no", orderDetl.getOrderNo()) | 
|---|
|  |  |  | .eq("matnr", orderDetl.getMatnr()) | 
|---|
|  |  |  | .eq("batch", orderDetl.getBatch())); | 
|---|
|  |  |  | if (Cools.isEmpty(inventoryCheckOrderDetl)) { | 
|---|
|  |  |  | throw new CoolException("未查询到盘点信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!inventoryCheckOrderDetl.getStatus().equals("1")) { | 
|---|
|  |  |  | throw new CoolException("该任务已盘点"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | inventoryCheckOrderDetl.setCheckAnfme(orderDetl.getCheckAnfme()); | 
|---|
|  |  |  | inventoryCheckOrderDetl.setStatus("2"); | 
|---|
|  |  |  | if (!checkOrderDetlService.updateById(inventoryCheckOrderDetl)) { | 
|---|
|  |  |  | throw new CoolException("保存盘点信息失败!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void inventoryUpload(String orderId) { | 
|---|
|  |  |  | if (Cools.isEmpty(orderId)) { | 
|---|
|  |  |  | throw new CoolException("盘点单id为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | InventoryCheckOrder inventoryCheckOrder = checkOrderService.selectById(orderId); | 
|---|
|  |  |  | if (Cools.isEmpty(inventoryCheckOrder)) { | 
|---|
|  |  |  | throw new CoolException("未找到盘点单"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (inventoryCheckOrder.getStatus().equals("2")) { | 
|---|
|  |  |  | throw new CoolException("盘点单已提交"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | int count = checkOrderDetlService.selectCount(new EntityWrapper<InventoryCheckOrderDetl>() | 
|---|
|  |  |  | .eq("order_no", inventoryCheckOrder.getOrderNo()).isNull("check_anfme")); | 
|---|
|  |  |  | if (count > 0) { | 
|---|
|  |  |  | throw new CoolException("有未完成的盘点任务"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<InventoryCheckOrderDetl> checkOrderProfitDetls = checkOrderDetlService.selectList(new EntityWrapper<InventoryCheckOrderDetl>() | 
|---|
|  |  |  | .eq("order_no", inventoryCheckOrder.getOrderNo()) | 
|---|
|  |  |  | .addFilter("anfme < check_anfme")); | 
|---|
|  |  |  | if (!checkOrderProfitDetls.isEmpty()) { | 
|---|
|  |  |  | //获取盘盈单param | 
|---|
|  |  |  | InventoryErpParam erpProfitParam = getErpProfitParam(inventoryCheckOrder, checkOrderProfitDetls); | 
|---|
|  |  |  | uploadErp(erpProfitParam); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<InventoryCheckOrderDetl> checkOrderDeficitDetls = checkOrderDetlService.selectList(new EntityWrapper<InventoryCheckOrderDetl>() | 
|---|
|  |  |  | .eq("order_no", inventoryCheckOrder.getOrderNo()) | 
|---|
|  |  |  | .addFilter("anfme > check_anfme")); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!checkOrderDeficitDetls.isEmpty()) { | 
|---|
|  |  |  | //获取盘亏单param | 
|---|
|  |  |  | InventoryErpParam erpDeficitParam = getErpDeficitParam(inventoryCheckOrder, checkOrderDeficitDetls); | 
|---|
|  |  |  | uploadErp(erpDeficitParam); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | inventoryCheckOrder.setStatus("2"); | 
|---|
|  |  |  | if (!checkOrderService.updateById(inventoryCheckOrder)) { | 
|---|
|  |  |  | throw new CoolException("状态更新失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void pingKuShelves(CombParam combParam, Long userId) { | 
|---|
|  |  |  | Node node = nodeService.selectOne(new EntityWrapper<Node>().eq("name", combParam.getLocno()).eq("type", 3)); | 
|---|
|  |  |  | if (Cools.isEmpty(node)) { | 
|---|
|  |  |  | throw new CoolException("未找到库位信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Order order = orderService.selectByNo(combParam.getOrderNo()); | 
|---|
|  |  |  | if (Cools.isEmpty(order) || order.getSettle() > 2) { | 
|---|
|  |  |  | throw new CoolException("单据编号已过期"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 生成入库通知档 | 
|---|
|  |  |  | List<DetlDto> detlDtos = new ArrayList<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (CombParam.CombMat elem : combParam.getCombMats()) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //            param.getCombMats().forEach(elem -> { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 订单明细数量校验 | 
|---|
|  |  |  | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch()); | 
|---|
|  |  |  | if (Cools.isEmpty(orderDetl)) { | 
|---|
|  |  |  | throw new CoolException("该单据中未找到对应物料明细"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (elem.getAnfme() > orderDetl.getEnableQty()) { | 
|---|
|  |  |  | throw new CoolException(orderDetl.getMatnr() + "入库数量不合法"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 修改订单作业数量 | 
|---|
|  |  |  | if (!orderDetlService.increaseWorkQty(order.getId(), elem.getMatnr(), elem.getBatch(), elem.getAnfme())) { | 
|---|
|  |  |  | throw new CoolException("修改单据作业数量失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //                DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme(),orderDetl.getManu()); | 
|---|
|  |  |  | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme(), orderDetl.getSuppCode() | 
|---|
|  |  |  | , orderDetl.getManu(), orderDetl.getSku(), orderDetl.getSupp(), orderDetl.getTemp1(), orderDetl.getTemp2(), orderDetl.getTemp3(), orderDetl.getTemp4()); | 
|---|
|  |  |  | if (DetlDto.has(detlDtos, detlDto)) { | 
|---|
|  |  |  | DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch()); | 
|---|
|  |  |  | assert one != null; | 
|---|
|  |  |  | one.setAnfme(one.getAnfme() + detlDto.getAnfme()); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | detlDtos.add(detlDto); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //            }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | int workNo = commonService.getWorkNo(4); | 
|---|
|  |  |  | Date now = new Date(); | 
|---|
|  |  |  | // 生成工作档 | 
|---|
|  |  |  | WrkMast wrkMast = new WrkMast(); | 
|---|
|  |  |  | wrkMast.setWrkNo(workNo); | 
|---|
|  |  |  | wrkMast.setIoTime(new Date()); | 
|---|
|  |  |  | wrkMast.setWrkSts(4L); // 工作状态:生成入库ID | 
|---|
|  |  |  | wrkMast.setIoType(300); // 入出库状态:1.入库 | 
|---|
|  |  |  | wrkMast.setIoPri(12D); // 优先级 | 
|---|
|  |  |  | wrkMast.setLocNo(node.getName()); | 
|---|
|  |  |  | wrkMast.setBarcode(""); // 托盘码 | 
|---|
|  |  |  | wrkMast.setFullPlt("Y"); // 满板:Y | 
|---|
|  |  |  | wrkMast.setPicking("N"); // 拣料 | 
|---|
|  |  |  | wrkMast.setExitMk("N"); // 退出 | 
|---|
|  |  |  | wrkMast.setEmptyMk("N"); // 空板 | 
|---|
|  |  |  | wrkMast.setLinkMis("Y"); | 
|---|
|  |  |  | wrkMast.setSheetNo(order.getOrderNo()); | 
|---|
|  |  |  | // 操作人员数据 | 
|---|
|  |  |  | wrkMast.setAppeTime(now); | 
|---|
|  |  |  | wrkMast.setModiTime(now); | 
|---|
|  |  |  | boolean res = wrkMastService.insert(wrkMast); | 
|---|
|  |  |  | if (!res) { | 
|---|
|  |  |  | throw new CoolException("保存工作档失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (DetlDto detlDto : detlDtos) { | 
|---|
|  |  |  | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); | 
|---|
|  |  |  | if (Cools.isEmpty(mat)) { | 
|---|
|  |  |  | throw new CoolException(detlDto.getMatnr() + "商品档案不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | WrkDetl wrkDetl = new WrkDetl(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | wrkDetl.sync(detlDto); | 
|---|
|  |  |  | wrkDetl.sync(mat); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | wrkDetl.setOrderNo(order.getOrderNo()); | 
|---|
|  |  |  | wrkDetl.setWrkNo(wrkMast.getWrkNo()); | 
|---|
|  |  |  | wrkDetl.setIoTime(wrkMast.getIoTime()); | 
|---|
|  |  |  | wrkDetl.setAppeTime(now); | 
|---|
|  |  |  | wrkDetl.setModiTime(now); | 
|---|
|  |  |  | wrkDetl.setManu(detlDto.getMark()); //标记 | 
|---|
|  |  |  | wrkDetl.setOrigin(order.getItemName());//仓库 | 
|---|
|  |  |  | wrkDetl.setSupp(detlDto.getSuppName()); //供应商 | 
|---|
|  |  |  | wrkDetl.setSku(detlDto.getCustomer()); //客户名称 | 
|---|
|  |  |  | wrkDetl.setThreeCode(detlDto.getOrderNo()); //u8发过来的订单号 | 
|---|
|  |  |  | wrkDetl.setSuppCode(detlDto.getFromOrderNo()); //来源单号 | 
|---|
|  |  |  | wrkDetl.setTemp1(detlDto.getTemp1()); | 
|---|
|  |  |  | wrkDetl.setTemp2(detlDto.getTemp2()); | 
|---|
|  |  |  | wrkDetl.setTemp3(detlDto.getSuppName()); | 
|---|
|  |  |  | wrkDetl.setTemp4(detlDto.getTemp4()); | 
|---|
|  |  |  | if (!wrkDetlService.insert(wrkDetl)) { | 
|---|
|  |  |  | throw new CoolException("保存工作明细失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orderService.updateSettle(order.getId(), 2L, userId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void pingKuUnShelves(CombParam combParam, Long userId) { | 
|---|
|  |  |  | String orderNo = combParam.getOrderNo(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Node node = nodeService.selectOne(new EntityWrapper<Node>().eq("name", combParam.getLocno()).eq("type", 3)); | 
|---|
|  |  |  | if (Cools.isEmpty(node)) { | 
|---|
|  |  |  | throw new CoolException("未找到库位信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //根据订单号生成出库任务工作档 | 
|---|
|  |  |  | Order order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no", orderNo)); | 
|---|
|  |  |  | if (order.getSettle() != 1 && order.getSettle() != 2) { | 
|---|
|  |  |  | throw new CoolException("该订单已处理"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<DetlDto> detlDtos = new ArrayList<>(); | 
|---|
|  |  |  | for (CombParam.CombMat elem : combParam.getCombMats()) { | 
|---|
|  |  |  | Wrapper<ManLocDetl> manLocDetlWrapper = new EntityWrapper<ManLocDetl>().eq("loc_no", combParam.getLocno()) | 
|---|
|  |  |  | .eq("matnr", elem.getMatnr()).eq("batch", elem.getBatch()) | 
|---|
|  |  |  | .eq("temp3", elem.getSupp()).eq("temp1", elem.getTemp1()).eq("temp2", elem.getTemp2()); | 
|---|
|  |  |  | ManLocDetl manLocDetl = manLocDetlService.selectOne(manLocDetlWrapper); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (Cools.isEmpty(manLocDetl)) { | 
|---|
|  |  |  | throw new CoolException("该库位未查询到货物信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (elem.getAnfme() > manLocDetl.getAnfme()) { | 
|---|
|  |  |  | throw new CoolException("出库数量大于库位剩余数量"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch()); | 
|---|
|  |  |  | if (Cools.isEmpty(orderDetl)) { | 
|---|
|  |  |  | throw new CoolException("该单据中未找到对应物料明细"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (elem.getAnfme() > orderDetl.getEnableQty()) { | 
|---|
|  |  |  | throw new CoolException(orderDetl.getMatnr() + "入库数量不合法"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 修改订单作业数量 | 
|---|
|  |  |  | if (!orderDetlService.increaseWorkQty(order.getId(), elem.getMatnr(), elem.getBatch(), elem.getAnfme())) { | 
|---|
|  |  |  | throw new CoolException("修改单据作业数量失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme(), orderDetl.getSuppCode() | 
|---|
|  |  |  | , orderDetl.getManu(), orderDetl.getSku(), orderDetl.getSupp(), orderDetl.getTemp1(), orderDetl.getTemp2(), orderDetl.getTemp3(), orderDetl.getTemp4()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int workNo = commonService.getWorkNo(4); | 
|---|
|  |  |  | Date now = new Date(); | 
|---|
|  |  |  | // 生成工作档 | 
|---|
|  |  |  | WrkMast wrkMast = new WrkMast(); | 
|---|
|  |  |  | wrkMast.setWrkNo(workNo); | 
|---|
|  |  |  | wrkMast.setIoTime(new Date()); | 
|---|
|  |  |  | wrkMast.setWrkSts(14L); // 工作状态:生成入库ID | 
|---|
|  |  |  | wrkMast.setIoType(301); // 入出库状态:301.平库出库 | 
|---|
|  |  |  | wrkMast.setIoPri(12D); // 优先级 | 
|---|
|  |  |  | wrkMast.setSourceLocNo(node.getName()); | 
|---|
|  |  |  | wrkMast.setBarcode(""); // 托盘码 | 
|---|
|  |  |  | wrkMast.setFullPlt("Y"); // 满板:Y | 
|---|
|  |  |  | wrkMast.setPicking("N"); // 拣料 | 
|---|
|  |  |  | wrkMast.setExitMk("N"); // 退出 | 
|---|
|  |  |  | wrkMast.setEmptyMk("N"); // 空板 | 
|---|
|  |  |  | wrkMast.setLinkMis("Y"); | 
|---|
|  |  |  | wrkMast.setSheetNo(order.getOrderNo()); | 
|---|
|  |  |  | // 操作人员数据 | 
|---|
|  |  |  | wrkMast.setAppeTime(now); | 
|---|
|  |  |  | wrkMast.setModiTime(now); | 
|---|
|  |  |  | boolean res = wrkMastService.insert(wrkMast); | 
|---|
|  |  |  | if (!res) { | 
|---|
|  |  |  | throw new CoolException("保存工作档失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); | 
|---|
|  |  |  | if (Cools.isEmpty(mat)) { | 
|---|
|  |  |  | throw new CoolException(detlDto.getMatnr() + "商品档案不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | WrkDetl wrkDetl = new WrkDetl(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | wrkDetl.sync(detlDto); | 
|---|
|  |  |  | wrkDetl.sync(mat); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | wrkDetl.setOrderNo(order.getOrderNo()); | 
|---|
|  |  |  | wrkDetl.setWrkNo(wrkMast.getWrkNo()); | 
|---|
|  |  |  | wrkDetl.setIoTime(wrkMast.getIoTime()); | 
|---|
|  |  |  | wrkDetl.setAppeTime(now); | 
|---|
|  |  |  | wrkDetl.setModiTime(now); | 
|---|
|  |  |  | wrkDetl.setManu(detlDto.getMark()); //标记 | 
|---|
|  |  |  | wrkDetl.setOrigin(order.getItemName());//仓库 | 
|---|
|  |  |  | wrkDetl.setSupp(detlDto.getSuppName()); //供应商 | 
|---|
|  |  |  | wrkDetl.setSku(detlDto.getCustomer()); //客户名称 | 
|---|
|  |  |  | wrkDetl.setThreeCode(detlDto.getOrderNo()); //u8发过来的订单号 | 
|---|
|  |  |  | wrkDetl.setSuppCode(detlDto.getFromOrderNo()); //来源单号 | 
|---|
|  |  |  | wrkDetl.setTemp1(detlDto.getTemp1()); | 
|---|
|  |  |  | wrkDetl.setTemp2(detlDto.getTemp2()); | 
|---|
|  |  |  | wrkDetl.setTemp3(detlDto.getTemp3()); | 
|---|
|  |  |  | wrkDetl.setTemp4(detlDto.getTemp4()); | 
|---|
|  |  |  | if (!wrkDetlService.insert(wrkDetl)) { | 
|---|
|  |  |  | throw new CoolException("保存工作明细失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (new BigDecimal(manLocDetl.getAnfme()).subtract(new BigDecimal(elem.getAnfme())).doubleValue() == 0) { | 
|---|
|  |  |  | manLocDetlService.delete(manLocDetlWrapper); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | manLocDetl.setAnfme(new BigDecimal(manLocDetl.getAnfme()).subtract(new BigDecimal(elem.getAnfme())).doubleValue()); | 
|---|
|  |  |  | if (!manLocDetlService.update(manLocDetl, manLocDetlWrapper)) { | 
|---|
|  |  |  | throw new CoolException("更新明细失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orderService.updateSettle(order.getId(), 2L, userId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void uploadErp(InventoryErpParam param) { | 
|---|
|  |  |  | //        String response = ""; | 
|---|
|  |  |  | //        boolean success = false; | 
|---|
|  |  |  | //        try { | 
|---|
|  |  |  | //            HashMap<String, Object> headers = new HashMap<>(); | 
|---|
|  |  |  | //            headers.put("Content-Type", "application/json"); | 
|---|
|  |  |  | //            response = new HttpHandler.Builder() | 
|---|
|  |  |  | //                    .setHeaders(headers) | 
|---|
|  |  |  | //                    .setUri("10.0.100.160:30108") | 
|---|
|  |  |  | //                    .setPath("web/apps/gongqi.df.dataTrans/DTInterFace/doJobWithupdateBody") | 
|---|
|  |  |  | //                    .setJson(JSON.toJSONString(param)) | 
|---|
|  |  |  | //                    .build() | 
|---|
|  |  |  | //                    .doPost(); | 
|---|
|  |  |  | //            JSONObject jsonObject = JSON.parseObject(response); | 
|---|
|  |  |  | //            if (jsonObject.getInteger("errcode").equals(0)) { | 
|---|
|  |  |  | //                success = true; | 
|---|
|  |  |  | //            } else if (jsonObject.getInteger("errcode").equals(1)) { | 
|---|
|  |  |  | //                log.error("请求接口失败!!!url:{};request:{};response:{}", MesConstant.URL+MesConstant.PACK_DOWN_URL, JSON.toJSONString(param), response); | 
|---|
|  |  |  | //                throw new CoolException(jsonObject.getString("msg")); | 
|---|
|  |  |  | //            } else { | 
|---|
|  |  |  | //                log.error("请求接口失败!!!url:{};request:{};response:{}", MesConstant.URL+MesConstant.PACK_DOWN_URL, JSON.toJSONString(param), response); | 
|---|
|  |  |  | //                throw new CoolException("上报mes系统失败"); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //        } catch (Exception e) { | 
|---|
|  |  |  | //            log.error("fail", e); | 
|---|
|  |  |  | //            throw new CoolException(e.getMessage()); | 
|---|
|  |  |  | //        } finally { | 
|---|
|  |  |  | //            try { | 
|---|
|  |  |  | //                // 保存接口日志 | 
|---|
|  |  |  | //                apiLogService.save( | 
|---|
|  |  |  | //                        "盘点单上报", | 
|---|
|  |  |  | //                        url , | 
|---|
|  |  |  | //                        null, | 
|---|
|  |  |  | //                        "127.0.0.1", | 
|---|
|  |  |  | //                        JSON.toJSONString(param), | 
|---|
|  |  |  | //                        response, | 
|---|
|  |  |  | //                        success | 
|---|
|  |  |  | //                ); | 
|---|
|  |  |  | //            } catch (Exception e) { log.error("", e); } | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public InventoryErpParam getErpProfitParam(InventoryCheckOrder inventoryCheckOrder, List<InventoryCheckOrderDetl> checkOrderProfitDetls) { | 
|---|
|  |  |  | Date date = new Date(); | 
|---|
|  |  |  | InventoryErpParam erpProfitParam = new InventoryErpParam(); | 
|---|
|  |  |  | InventoryErpParam.DataJson dataJson = new InventoryErpParam.DataJson(); | 
|---|
|  |  |  | dataJson.setFlowCode("LIKUwms12GOTmes"); | 
|---|
|  |  |  | dataJson.setTableCode("DTInventInTable_pdd"); | 
|---|
|  |  |  | dataJson.setLogName("盘盈单-入库单"); | 
|---|
|  |  |  | erpProfitParam.setDataJson(dataJson); | 
|---|
|  |  |  | List<InventoryErpParam.UpdateJson> updateJsonList = new ArrayList<>(); | 
|---|
|  |  |  | InventoryErpParam.UpdateJson updateJson = new InventoryErpParam.UpdateJson(); | 
|---|
|  |  |  | updateJson.setOrderNo(inventoryCheckOrder.getOrderNo()); | 
|---|
|  |  |  | updateJson.setDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date)); | 
|---|
|  |  |  | List<InventoryErpParam.MatDetails> matDetails = new ArrayList<>(); | 
|---|
|  |  |  | for (InventoryCheckOrderDetl checkOrderProfitDetl : checkOrderProfitDetls) { | 
|---|
|  |  |  | InventoryErpParam.MatDetails matDetail = new InventoryErpParam.MatDetails(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Mat mat = matService.selectByMatnr(checkOrderProfitDetl.getMatnr()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | matDetail.setMatnr(checkOrderProfitDetl.getMatnr()); | 
|---|
|  |  |  | matDetail.setBatch(checkOrderProfitDetl.getBatch()); | 
|---|
|  |  |  | matDetail.setSpecs(mat.getSpecs()); | 
|---|
|  |  |  | Double anfme = new BigDecimal(checkOrderProfitDetl.getCheckAnfme()).subtract(new BigDecimal(checkOrderProfitDetl.getAnfme())).doubleValue(); | 
|---|
|  |  |  | matDetail.setAnfme(anfme); | 
|---|
|  |  |  | matDetail.setLocNo(checkOrderProfitDetl.getLocNo()); | 
|---|
|  |  |  | matDetail.setWarehouse(checkOrderProfitDetl.getArea()); | 
|---|
|  |  |  | matDetail.setSeq(updateJson.getMatDetails() == null ? 1 : updateJson.getMatDetails().size() + 1); | 
|---|
|  |  |  | matDetails.add(matDetail); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | updateJson.setMatDetails(matDetails); | 
|---|
|  |  |  | updateJsonList.add(updateJson); | 
|---|
|  |  |  | erpProfitParam.setUpdateJson(updateJsonList); | 
|---|
|  |  |  | return erpProfitParam; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public InventoryErpParam getErpDeficitParam(InventoryCheckOrder inventoryCheckOrder, List<InventoryCheckOrderDetl> checkOrderDeficitDetls) { | 
|---|
|  |  |  | Date date = new Date(); | 
|---|
|  |  |  | InventoryErpParam erpDeficitParam = new InventoryErpParam(); | 
|---|
|  |  |  | InventoryErpParam.DataJson dataJson = new InventoryErpParam.DataJson(); | 
|---|
|  |  |  | dataJson.setFlowCode("LIKUwms12GOTmes"); | 
|---|
|  |  |  | dataJson.setTableCode("DTInventOutTable_pdd"); | 
|---|
|  |  |  | dataJson.setLogName("盘亏单-出库单"); | 
|---|
|  |  |  | erpDeficitParam.setDataJson(dataJson); | 
|---|
|  |  |  | List<InventoryErpParam.UpdateJson> updateJsonList2 = new ArrayList<>(); | 
|---|
|  |  |  | InventoryErpParam.UpdateJson updateJson2 = new InventoryErpParam.UpdateJson(); | 
|---|
|  |  |  | updateJson2.setOrderNo(inventoryCheckOrder.getOrderNo()); | 
|---|
|  |  |  | updateJson2.setDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date)); | 
|---|
|  |  |  | List<InventoryErpParam.MatDetails> matDetails = new ArrayList<>(); | 
|---|
|  |  |  | for (InventoryCheckOrderDetl checkOrderDeficitDetl : checkOrderDeficitDetls) { | 
|---|
|  |  |  | InventoryErpParam.MatDetails matDetail = new InventoryErpParam.MatDetails(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Mat mat = matService.selectByMatnr(checkOrderDeficitDetl.getMatnr()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | matDetail.setMatnr(checkOrderDeficitDetl.getMatnr()); | 
|---|
|  |  |  | matDetail.setBatch(checkOrderDeficitDetl.getBatch()); | 
|---|
|  |  |  | matDetail.setSpecs(mat.getSpecs()); | 
|---|
|  |  |  | Double anfme = new BigDecimal(checkOrderDeficitDetl.getAnfme()).subtract(new BigDecimal(checkOrderDeficitDetl.getCheckAnfme())).doubleValue(); | 
|---|
|  |  |  | matDetail.setAnfme(anfme); | 
|---|
|  |  |  | matDetail.setLocNo(checkOrderDeficitDetl.getLocNo()); | 
|---|
|  |  |  | matDetail.setWarehouse(checkOrderDeficitDetl.getArea()); | 
|---|
|  |  |  | matDetail.setSeq(updateJson2.getMatDetails() == null ? 1 : updateJson2.getMatDetails().size() + 1); | 
|---|
|  |  |  | matDetails.add(matDetail); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | updateJson2.setMatDetails(matDetails); | 
|---|
|  |  |  | updateJsonList2.add(updateJson2); | 
|---|
|  |  |  | erpDeficitParam.setUpdateJson(updateJsonList2); | 
|---|
|  |  |  | return erpDeficitParam; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public void stockOut(OrderDetl orderDetl, BasDevp staNo, LocDetl locDetl, | 
|---|
|  |  |  | Double curOutQty, Integer ioType, Long userId, Date now) { | 
|---|
|  |  |  | // 获取库位 | 
|---|
|  |  |  | LocMast locMast = locMastService.selectById(locDetl.getLocNo()); | 
|---|
|  |  |  | // 获取路径 | 
|---|
|  |  |  | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() | 
|---|
|  |  |  | .eq("type_no", ioType) | 
|---|
|  |  |  | .eq("stn_no", staNo.getDevNo()) | 
|---|
|  |  |  | .eq("crn_no", locMast.getCrnNo()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | StaDesc staDesc = staDescService.selectOne(wrapper); | 
|---|
|  |  |  | if (Cools.isEmpty(staDesc)) { | 
|---|
|  |  |  | throw new CoolException("出库路径不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 生成工作号 | 
|---|
|  |  |  | int workNo = commonService.getWorkNo(2); | 
|---|
|  |  |  | // 生成工作档 | 
|---|
|  |  |  | WrkMast wrkMast = new WrkMast(); | 
|---|
|  |  |  | wrkMast.setWrkNo(workNo); | 
|---|
|  |  |  | wrkMast.setIoTime(now); | 
|---|
|  |  |  | wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID | 
|---|
|  |  |  | wrkMast.setIoType(ioType); // 入出库状态 | 
|---|
|  |  |  | wrkMast.setIoPri(13D); // 优先级:13 | 
|---|
|  |  |  | wrkMast.setCrnNo(locMast.getCrnNo()); | 
|---|
|  |  |  | wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 源站 | 
|---|
|  |  |  | wrkMast.setStaNo(staDesc.getStnNo()); // 目标站 | 
|---|
|  |  |  | wrkMast.setSourceLocNo(locDetl.getLocNo()); // 源库位 | 
|---|
|  |  |  | wrkMast.setFullPlt("Y"); // 满板:Y | 
|---|
|  |  |  | wrkMast.setPicking("N"); // 拣料 | 
|---|
|  |  |  | wrkMast.setExitMk("N"); // 退出 | 
|---|
|  |  |  | wrkMast.setEmptyMk("N"); // 空板 | 
|---|
|  |  |  | wrkMast.setLinkMis("N"); | 
|---|
|  |  |  | wrkMast.setAppeUser(userId); // 操作人员数据 | 
|---|
|  |  |  | wrkMast.setAppeTime(now); | 
|---|
|  |  |  | wrkMast.setModiUser(userId); | 
|---|
|  |  |  | wrkMast.setModiTime(now); | 
|---|
|  |  |  | wrkMast.setBarcode(locMast.getBarcode()); | 
|---|
|  |  |  | if (!wrkMastService.insert(wrkMast)) { | 
|---|
|  |  |  | throw new CoolException("保存工作档失败,出库库位号:" + locDetl.getLocNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | WrkDetl wrkDetl = new WrkDetl(); | 
|---|
|  |  |  | wrkDetl.sync(locDetl); | 
|---|
|  |  |  | wrkDetl.setWrkNo(workNo); | 
|---|
|  |  |  | wrkDetl.setIoTime(now); | 
|---|
|  |  |  | wrkDetl.setAnfme(curOutQty); // 数量 | 
|---|
|  |  |  | wrkDetl.setOrderNo(orderDetl.getOrderNo()); | 
|---|
|  |  |  | wrkDetl.setAppeTime(now); | 
|---|
|  |  |  | wrkDetl.setAppeUser(userId); | 
|---|
|  |  |  | wrkDetl.setModiTime(now); | 
|---|
|  |  |  | wrkDetl.setModiUser(userId); | 
|---|
|  |  |  | if (!wrkDetlService.insert(wrkDetl)) { | 
|---|
|  |  |  | throw new CoolException("保存工作档明细失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 修改库位状态:   F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 | 
|---|
|  |  |  | locMast = locMastService.selectById(locDetl.getLocNo()); | 
|---|
|  |  |  | if (locMast.getLocSts().equals("F")) { | 
|---|
|  |  |  | locMast.setLocSts(ioType == 101 ? "R" : "P"); | 
|---|
|  |  |  | locMast.setModiUser(userId); | 
|---|
|  |  |  | locMast.setModiTime(new Date()); | 
|---|
|  |  |  | if (!locMastService.updateById(locMast)) { | 
|---|
|  |  |  | throw new CoolException("预约库位状态失败,库位号:" + locDetl.getLocNo()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | throw new CoolException(locDetl.getLocNo() + "库位不是在库状态"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|