| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.rmi.CORBA.Util; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private WorkService workService; |
| | | @Autowired |
| | | private BasCrnpService basCrnpService; |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | throw new CoolException("orderNo不能为空"); |
| | | } |
| | | if (param.getExecute() == null) { |
| | | throw new CoolException("reason不能为空"); |
| | | throw new CoolException("execute不能为空"); |
| | | } |
| | | |
| | | List<WrkMast> activeTasks = findActiveOutboundTasks(param.getOrderId()); |
| | |
| | | for (WrkMast wrkMast : activeTasks) { |
| | | HashMap<String,Object> hashMap = new HashMap<>(); |
| | | hashMap.put("taskNo", wrkMast.getWrkNo()); |
| | | if (!Cools.isEmpty(wrkMast) && wrkMast.getWrkSts() ==11L) { |
| | | workService.cancelWrkMast(wrkMast.getWrkNo()+"", 9955L); |
| | | continue; |
| | | } |
| | | taskList.add(hashMap); |
| | | } |
| | | wcsApiService.pauseOutTasks(taskList); |
| | |
| | | stationParams.add(stationParam); |
| | | } |
| | | } |
| | | String requestJson = JSON.toJSONString(stationParams); |
| | | String response = ""; |
| | | boolean pushOk = false; |
| | | String pushUrl = buildMesStationRequestUrl(); |
| | | try { |
| | | //获取Cookie值 |
| | | HashMap<String, Object> headers = new HashMap<>(); |
| | |
| | | .setHeaders(headers) |
| | | .setUri(mesUrl) |
| | | .setPath(stationAddress) |
| | | .setJson(JSON.toJSONString(stationParams)) |
| | | .setJson(requestJson) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonResponse = JSON.parseObject(response); |
| | | if (jsonResponse.getInteger("code") == 200) { |
| | | |
| | | if (jsonResponse != null && Integer.valueOf(200).equals(jsonResponse.getInteger("code"))) { |
| | | pushOk = true; |
| | | } else { |
| | | return R.error(); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | apiLogService.save( |
| | | "推ERP-站点同步", |
| | | pushUrl, |
| | | null, |
| | | "127.0.0.1", |
| | | requestJson, |
| | | response, |
| | | pushOk, |
| | | "站点同步推对方" |
| | | ); |
| | | } catch (Exception logEx) { |
| | | log.error("save station sync api log failed", logEx); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | private String buildMesStationRequestUrl() { |
| | | if (Cools.isEmpty(mesUrl)) { |
| | | return stationAddress; |
| | | } |
| | | if (stationAddress == null) { |
| | | return mesUrl; |
| | | } |
| | | if (mesUrl.endsWith("/") && stationAddress.startsWith("/")) { |
| | | return mesUrl + stationAddress.substring(1); |
| | | } |
| | | if (!mesUrl.endsWith("/") && !stationAddress.startsWith("/")) { |
| | | return mesUrl + "/" + stationAddress; |
| | | } |
| | | return mesUrl + stationAddress; |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | if (param.getFull() == 1) { |
| | | //满托盘 |
| | | mat = matService.selectByMatnr("emptyPallet"); |
| | | if(param.getBoxType1().equals("aws")){ |
| | | mat = matService.selectByMatnr("amazon"); |
| | | }else { |
| | | mat = matService.selectByMatnr("cloudWarehouse"); |
| | | } |
| | | |
| | | } else if (param.getFull() == 0) { |
| | | //空托盘 |
| | | mat = matService.selectByMatnr("emptyPallet"); |
| | |
| | | waitPakin.setManu(String.valueOf(param.getLocId()));//mes具体库位编号 |
| | | waitPakin.setThreeCode(param.getBizNo()); |
| | | waitPakin.setBeBatch(param.getPackage1());//是否散货,0 非散货;1 散货;为了管控出货速率,散货可以出慢点。 |
| | | // ERP 入口默认打 erp,MQTT 组托会在参数里显式传 aws。 |
| | | waitPakin.setBoxType1(Cools.isEmpty(param.getBoxType1()) ? "erp" : param.getBoxType1()); |
| | | if (!waitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("保存入库通知档失败"); |
| | | } |
| | | return null; |
| | | return R.ok().add(Cools.add("palletId", param.getPalletId()).add("orderId", param.getOrderId())); |
| | | } |
| | | |
| | | @Override |
| | | public R outOrder(OutTaskParam param) { |
| | | public R outOrder(OutTaskParam param,int count) { |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_sts", "F").eq("barcode", param.getPalletId())); |
| | | if (locMast == null) { |
| | | return R.error("没有找到托盘码=" + param.getPalletId() + "对应的库位"); |
| | | throw new CoolException("没有找到托盘码=" + param.getPalletId() + "对应的库位"); |
| | | } |
| | | Integer ioType = 101; |
| | | // 获取路径 |
| | |
| | | wrkDetl.setAppeUser(9995L); |
| | | wrkDetl.setModiTime(now); |
| | | wrkDetl.setModiUser(9995L); |
| | | wrkDetl.setSupp(param.getSeq()+"/"+count); |
| | | |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | |
| | | log.error(locMast.getLocNo() + "库位不是在库状态"); |
| | | throw new CoolException(locMast.getLocNo() + "库位不是在库状态"); |
| | | } |
| | | return R.ok().add(Cools.add("wrkNo", workNo).add("orderId", param.getOrderId())); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R outOrderBatch(List<OutTaskParam> params) { |
| | | int n = params.size(); |
| | | for (OutTaskParam outTaskParam : params) { |
| | | R r = outOrder(outTaskParam, n); |
| | | if (!Objects.equals(r.get("code"), 200)) { |
| | | throw new CoolException("出库建单失败"); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | } |
| | | |
| | | |