| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.api.entity.OrderItemsParam; |
| | | import com.zy.api.entity.OutOrderParams; |
| | | import com.zy.api.entity.PubOrderParams; |
| | | import com.zy.api.entity.ReportOrderParam; |
| | | import com.zy.api.entity.ReportOrderParams; |
| | | import com.zy.api.entity.StockAdjustParams; |
| | | import com.zy.api.entity.StockUpOrderParams; |
| | | import com.zy.api.entity.dto.XSR; |
| | | import com.zy.api.enums.MatLocType; |
| | | import com.zy.api.service.KopenApiService; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.enums.OrderTypeEnum; |
| | |
| | | private KopenApiService kopenApiService; |
| | | @Autowired |
| | | private MatService matService; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | @Autowired |
| | | CheckOrderDetlService checkOrderDetlService; |
| | | |
| | | |
| | | @Transactional |
| | | public ReturnT<String> startOrderIssuedOnceMore(Order order) { |
| | |
| | | ReportOrderParam orderParam = new ReportOrderParam(); |
| | | orderParam.setCompany_id(order.getCstmrName()) |
| | | .setWms_id(order.getId() + "") |
| | | .setOrder_no(order.getOrderNo()) |
| | | // .setOrder_no(order.getOrderNo()) |
| | | .setDispatch_no(order.getOrderNo()) |
| | | .setType(order.getDocType() + "") |
| | | .setInv_no(order.getNumber()) |
| | | .setPm_tktid(order.getItemName()) |
| | | .setUpdate_time(Utils.dateToStr(new Date(), "yyyy-MM-dd HH:mm:ss")) |
| | | .setTarget_location(""); |
| | | .setTarget_location("1"); |
| | | |
| | | List<ReportOrderParams> reportOrderParams = new ArrayList<>(); |
| | | orderDetls.forEach(detl -> { |
| | |
| | | throw new CoolException("物料不存在"); |
| | | } |
| | | ReportOrderParams itemParam = new ReportOrderParams(); |
| | | |
| | | LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>() |
| | | .eq("matnr", detl.getMatnr()) |
| | | .eq("supp_code", detl.getSuppCode()) |
| | | .eq("order_no", detl.getOrderNo())); |
| | | if (Objects.isNull(locDetl)) { |
| | | throw new CoolException("库存明细不存在 ,请检查单据是否完成!!"); |
| | | } |
| | | |
| | | // BS Code |
| | | itemParam.setTotal_serial(detl.getThreeCode()) |
| | | // 上报时,默认产品类型是null |
| | |
| | | .setPro_komcode(detl.getMatnr()) |
| | | // 上报时,默认产品id是供应商编码 |
| | | .setPro_id(detl.getSuppCode()) |
| | | // 上报时,默认来源位置是null |
| | | .setLocation_no(null) |
| | | // 上报时,默认目标位置是null |
| | | .setLocation_type(null) |
| | | .setLocation_no(locDetl.getZpallet()) |
| | | .setSj_emp(locDetl.getModiUser$()) |
| | | .setLocation_type(MatLocType.getMatTag(material.getTagId() + "")) |
| | | // 上报时,默认上报时间是更新时间 |
| | | .setSj_date(order.getUpdateBy().toString()) |
| | | // 上报时,默认上报人是更新人 |
| | | .setSj_emp(order.getUpdateBy$()) |
| | | .setSj_date(Utils.dateToStr(order.getUpdateTime(), "yyyy-MM-dd HH:mm:ss") ) |
| | | // 上报时,默认上报数量是订单数量 |
| | | .setPick_qty(detl.getQty().intValue()) |
| | | // 上报时,默认损坏数量是0 |
| | |
| | | XSR response = null; |
| | | boolean success = false; |
| | | try { |
| | | response = kopenApiService.getInDispatchResult(orderParam); |
| | | |
| | | List<ReportOrderParam> orderParams = new ArrayList<>(); |
| | | orderParams.add(orderParam); |
| | | if (order.getReportOnce() < 4) { |
| | | response = kopenApiService.getInDispatchResult(orderParams, order); |
| | | } else { |
| | | return FAIL; |
| | | } |
| | | // if (true) { |
| | | // success = true; |
| | | // // 修改订单状态 4.完成 ===>> 6.已上报 |
| | |
| | | // 保存接口日志 |
| | | apiLogService.save( |
| | | "上架派工单完成上报", |
| | | MesConstant.URL + MesConstant.PAKIN_URL, |
| | | MesConstant.URL + MesConstant.IN_DISPATCH_RESULT, |
| | | null, |
| | | "127.0.0.1", |
| | | JSON.toJSONString(orderParam), |
| | |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | } else { |
| | | log.error("请求接口失败!!!url:{};request:{};response:{}", MesConstant.URL + MesConstant.PAKOUT_URL, |
| | | log.error("请求接口失败!!!url:{};request:{};response:{}", |
| | | MesConstant.URL + MesConstant.OUT_DISPATCH_RESULT, |
| | | JSON.toJSONString(orderParam), JSON.toJSONString(response)); |
| | | throw new CoolException("上报mes系统失败"); |
| | | throw new CoolException("上报KOPEN系统失败"); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("fail", e); |
| | |
| | | // 保存接口日志 |
| | | apiLogService.save( |
| | | "备货派工单完成上报", |
| | | MesConstant.URL + MesConstant.PAKOUT_URL, |
| | | MesConstant.URL + MesConstant.OUT_DISPATCH_RESULT, |
| | | null, |
| | | "127.0.0.1", |
| | | JSON.toJSONString(orderParam), |
| | |
| | | log.error("", e); |
| | | } |
| | | } |
| | | } else if (Integer.valueOf(docType.getDocId() + "").equals(OrderTypeEnum.STOCK.type)) { |
| | | // 备货单反馈 |
| | | StockUpOrderParams stockUpOrderParams = new StockUpOrderParams(); |
| | | stockUpOrderParams.setCompany_id(order.getCstmrName()) |
| | | .setWms_id(order.getId() + "") |
| | | .setDispatch_no(order.getNumber()); |
| | | |
| | | OutOrderParams pubOrderParams = new OutOrderParams(); |
| | | pubOrderParams.setPick_no(order.getOrderNo()) |
| | | .setOrder_no(order.getShipCode()) |
| | | .setCus_id(order.getCstmrName()) |
| | | .setCus_address(order.getTel()); |
| | | |
| | | List<OrderItemsParam> reportOrderParams = new ArrayList<>(); |
| | | orderDetls.forEach(detl -> { |
| | | Mat material = matService.selectByMatnr(detl.getMatnr()); |
| | | if (Objects.isNull(material)) { |
| | | throw new CoolException("物料不存在"); |
| | | } |
| | | OrderItemsParam itemParam = new OrderItemsParam(); |
| | | // 上报时,默认产品类型是null |
| | | itemParam.setPro_type(material.getProType()); |
| | | // 上报时,默认产品编码 |
| | | itemParam.setPro_komcode(material.getMatnr()); |
| | | // 上报时,默认产品id是供应商编码 |
| | | itemParam.setPro_id(detl.getSuppCode()); |
| | | |
| | | // 上报时,默认上报时间是更新时间 |
| | | itemParam.setPick_qty(detl.getQty().intValue()); |
| | | reportOrderParams.add(itemParam); |
| | | }); |
| | | pubOrderParams.setPartList(reportOrderParams); |
| | | |
| | | List<OutOrderParams> pubOrderParamsList = new ArrayList<>(); |
| | | pubOrderParamsList.add(pubOrderParams); |
| | | // 设置派工单明细 |
| | | stockUpOrderParams.setDetails(pubOrderParamsList); |
| | | stockUpOrderParams.setUpdate_time(order.getUpdateBy$()); |
| | | |
| | | XSR response = null; |
| | | boolean success = false; |
| | | try { |
| | | // response = new HttpHandler.Builder() |
| | | // .setUri(MesConstant.URL) |
| | | // .setPath(MesConstant.PAKOUT_URL) |
| | | // .setJson(JSON.toJSONString(pakoutParam)) |
| | | // .build() |
| | | // .doPost(); |
| | | // JSONObject jsonObject = JSON.parseObject(response); |
| | | // if (jsonObject.getInteger("code").equals(200)) { |
| | | if (true) { |
| | | success = true; |
| | | // 修改订单状态 4.完成 ===>> 6.已上报 |
| | | if (!orderService.updateSettle(order.getId(), settle, null)) { |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | } |
| | | } else { |
| | | log.error("请求接口失败!!!url:{};request:{};response:{}", |
| | | MesConstant.URL + MesConstant.OUT_DETAILS_RESULT, |
| | | JSON.toJSONString(stockUpOrderParams), JSON.toJSONString(response)); |
| | | throw new CoolException("上报KOPEN系统失败"); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("fail", e); |
| | | return FAIL.setMsg(e.getMessage()); |
| | | } finally { |
| | | try { |
| | | // 保存接口日志 |
| | | apiLogService.save( |
| | | "备货单完成上报", |
| | | MesConstant.URL + MesConstant.OUT_DETAILS_RESULT, |
| | | null, |
| | | "127.0.0.1", |
| | | JSON.toJSONString(stockUpOrderParams), |
| | | JSON.toJSONString(response), |
| | | success); |
| | | } catch (Exception e) { |
| | | log.error("", e); |
| | | } |
| | | } |
| | | |
| | | } |
| | | return SUCCESS; |
| | | } |
| | | |
| | | /** |
| | | * 损溢单完结上报 |
| | | * |
| | | * @param order |
| | | * @return |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ReturnT<String> startCheckOrderReport(CheckOrder order) { |
| | | List<StockAdjustParams> adjustParams = new ArrayList<>(); |
| | | |
| | | StockAdjustParams adjustParam = new StockAdjustParams(); |
| | | |
| | | adjustParam.setCompany_id(order.getCstmrName()) |
| | | .setWms_id(order.getId() + "") |
| | | .setType(0 + "") |
| | | .setCompany_id(order.getCstmrName()); |
| | | |
| | | adjustParam.setBsby_no(order.getNumber()) |
| | | .setResason("") |
| | | .setReason_name(""); |
| | | List<CheckOrderDetl> detls = checkOrderDetlService |
| | | .selectList(new EntityWrapper<CheckOrderDetl>().eq("order_id", order.getId())); |
| | | if (Objects.isNull(detls) || detls.isEmpty()) { |
| | | throw new CoolException("损溢单详情不存在"); |
| | | } |
| | | List<OrderItemsParam> items = new ArrayList<>(); |
| | | detls.forEach(detl -> { |
| | | Mat material = matService.selectByMatnr(detl.getMatnr()); |
| | | if (Objects.isNull(material)) { |
| | | throw new CoolException("物料不存在"); |
| | | } |
| | | OrderItemsParam itemParam = new OrderItemsParam(); |
| | | itemParam.setLocation_no(detl.getZpallet()) |
| | | .setPro_komcode(material.getMatnr()) |
| | | .setPro_id(detl.getSuppCode()) |
| | | .setBsby_qty(detl.getDiffQty().intValue()); |
| | | items.add(itemParam); |
| | | }); |
| | | adjustParam.setDetails(items); |
| | | |
| | | adjustParams.add(adjustParam); |
| | | |
| | | return SUCCESS; |
| | | // TODO Auto-generated method stub |
| | | |
| | | } |
| | | |
| | | } |