| | |
| | | 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.constant.MesConstant; |
| | | import com.zy.common.entity.Parameter; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.model.MesCombParam; |
| | |
| | | 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 javax.annotation.Resource; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | |
| | | |
| | | @Resource |
| | | private BasDevpMapper basDevpMapper; |
| | | |
| | | @Value("mes.url") |
| | | private String url; |
| | | |
| | | @Value("mes.pakin") |
| | | private String code; |
| | | |
| | | @Override |
| | | public R inLocCallAgv(String sta, String inSta) { |
| | |
| | | // 生成入库通知档 |
| | | List<DetlDto> detlDtos = new ArrayList<>(); |
| | | |
| | | 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); |
| | | if (!codeDataParam.getQuality().equals(order.getShipCode())) { |
| | | throw new CoolException("单据质量状态和组托物料不匹配"); |
| | | } |
| | | 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 -> { |
| | | |
| | | // 订单明细数量校验 |
| | |
| | | } |
| | | |
| | | // DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme(),orderDetl.getManu()); |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme(),orderDetl.getSuppCode() |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme(), elem.getThreeCode() |
| | | , orderDetl.getManu(),orderDetl.getSku(),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()); |
| | | assert one != null; |
| | |
| | | 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.getOrderNo()); //u8发过来的订单号 |
| | | waitPakin.setSuppCode(detlDto.getFromOrderNo()); //来源单号 |
| | | waitPakin.setThreeCode(detlDto.getFromOrderNo()); //条码 |
| | | waitPakin.setTemp1(detlDto.getTemp1()); |
| | | waitPakin.setTemp2(detlDto.getTemp2()); |
| | | waitPakin.setTemp3(detlDto.getTemp3()); |
| | |
| | | orderService.updateSettle(order.getId(), 2L, userId); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | 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); |
| | | } |
| | | MesResponse jsonObject = JSON.parseObject(response, MesResponse.class); |
| | | if (jsonObject.getCode().equals(200)) { |
| | | return JSON.parseArray(jsonObject.getData(), CodeDataParam.class); |
| | | } |
| | | throw new CoolException(jsonObject.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | wrkDetl.setTemp4(orderDetl.getTemp4()); |
| | | wrkDetlService.insert(wrkDetl); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | // 添加明细 |
| | | 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()); |
| | |
| | | } |
| | | String response = ""; |
| | | boolean success = false; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(MesConstant.URL) |
| | | .setPath(MesConstant.PACK_DOWN_URL) |
| | | .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); } |
| | | } |
| | | // 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); } |
| | | // } |
| | | |
| | | } |
| | | |
| | |
| | | openParam.setOrderNo(orderNo); |
| | | openParam.setInboundDate(DateUtils.convert(now)); |
| | | openParam.setOrderType("打包入库单"); |
| | | openParam.setOrderDetails(detlDtos); |
| | | openParam.setDetails(detlDtos); |
| | | openService.pakinOrderCreate(openParam); |
| | | Order order = orderService.selectByNo(orderNo); |
| | | if (null == order) { |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | if (!checkOrderService.updateById(inventoryCheckOrder)){ |
| | | 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( |
| | | "盘点单上报", |
| | | MesConstant.URL + MesConstant.PACK_DOWN_URL, |
| | | null, |
| | | "127.0.0.1", |
| | | JSON.toJSONString(param), |
| | | response, |
| | | success |
| | | ); |
| | | } catch (Exception e) { log.error("", e); } |
| | | } |
| | | // 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) { |