| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.DocType; |
| | | import com.zy.asrs.entity.Order; |
| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | @Transactional |
| | | public ReturnT<String> start(Order order) { |
| | | |
| | | List<String> docNames = new ArrayList<>(Arrays.asList("银座采购入库单", "银座委外材料出库单", "银座委外入库单", "银座生产材料出库单")); |
| | | //List<String> docNames = new ArrayList<>(Arrays.asList("银座采购入库单", "银座委外材料出库单", "银座委外入库单", "银座生产材料出库单")); |
| | | List<String> docNames = new ArrayList<>(Arrays.asList("银座委外入库单", "银座生产材料出库单")); |
| | | |
| | | DocType docType = docTypeService.selectById(order.getDocType()); |
| | | if (!docNames.contains(docType.getDocName())) { |
| | |
| | | ReportErpParam param = new ReportErpParam(); |
| | | mappingParam(order, param); |
| | | mappingParamChildren(orderDetlList, param); |
| | | if (Cools.isEmpty(order.getPltType())) { |
| | | return SUCCESS; |
| | | } |
| | | |
| | | int code = doHttpRequest(param, "单据审核", url, orderReportPath, null, "127.0.0.1"); |
| | | if (code == 0) { |
| | | log.info("单据审核,{}", order); |
| | | order.setSettle(6L); |
| | | orderService.updateById(order); |
| | | } |
| | |
| | | return SUCCESS; |
| | | } |
| | | |
| | | |
| | | @Transactional |
| | | public void timelyStart(Order order) { |
| | | |
| | | List<String> docNames = new ArrayList<>(Arrays.asList("银座采购入库单", "银座委外材料出库单")); |
| | | |
| | | DocType docType = docTypeService.selectById(order.getDocType()); |
| | | if (docNames.contains(docType.getDocName())) { |
| | | List<OrderDetl> orderDetlList = orderDetlService.selectByOrderId(order.getId()); |
| | | List<OrderDetl> report = new ArrayList<>(); |
| | | for (OrderDetl orderDetl : orderDetlList) { |
| | | if (orderDetl.getQty() > 0 && orderDetl.getQty() > (orderDetl.getReportQty() == null ? 0D : orderDetl.getReportQty())) { |
| | | report.add(orderDetl); |
| | | } |
| | | } |
| | | if (Cools.isEmpty(order.getPltType())) { |
| | | return; |
| | | } |
| | | if (!Cools.isEmpty(report)) { |
| | | ReportErpParam param = new ReportErpParam(); |
| | | mappingParam(order, param); |
| | | mappingParamChildren(report, param); |
| | | |
| | | int code = doHttpRequest(param, "单据审核", url, orderReportPath, null, "127.0.0.1"); |
| | | if (code == 0) { |
| | | for (OrderDetl orderDetl : report) { |
| | | log.info("{}单据审核上报了:{}", order.getOrderNo(), orderDetl.getQty() - (orderDetl.getReportQty() == null ? 0D : orderDetl.getReportQty())); |
| | | orderDetl.setReportQty(orderDetl.getQty()); |
| | | orderDetlService.updateById(orderDetl); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | public void mappingParam(Order order, ReportErpParam param) { |
| | | param.set操作系统号(order.getDefNumber()); |
| | | //param.set操作系统号(order.getDefNumber()); |
| | | param.set操作系统号("998"); |
| | | param.set操作单据(order.getDocType$()); |
| | | param.set操作类型("add"); |
| | | param.setDdate(order.getOrderTime()); |
| | |
| | | param.setCOrderCode(order.getOrderNo()); |
| | | param.setCMaker(""); |
| | | param.setCHandler(""); |
| | | param.setCDefine14(order.getOrderNo()); |
| | | param.setCDefine14(order.getOrderNo() + "_" + DateUtils.convert(new Date(), DateUtils.yyyyMMddHHmmss + "_" + order.getPltType())); |
| | | } |
| | | |
| | | public void mappingParamChildren(List<OrderDetl> orderDetlList, ReportErpParam param) { |
| | |
| | | ReportErpParam.ChildInfo childInfo = new ReportErpParam.ChildInfo(); |
| | | childInfo.setIrowno(orderDetl.getItemNum()); |
| | | childInfo.setCInvCode(orderDetl.getMatnr()); |
| | | childInfo.setIQuantity(orderDetl.getQty() + ""); |
| | | childInfo.setIQuantity(orderDetl.getQty() - (orderDetl.getReportQty() == null ? 0D : orderDetl.getReportQty()) + ""); |
| | | childInfo.setCBatch(orderDetl.getBatch()); |
| | | childInfo.setINum(orderDetl.getLength() + ""); |
| | | childInfo.setIinvexchrate(""); |
| | |
| | | boolean success = false; |
| | | |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(url) |
| | | .setPath(path) |
| | | .setJson(JSONObject.toJSONString(requestParam)) |
| | | .build() |
| | | .doPost(); |
| | | response = new HttpHandler.Builder().setUri(url).setPath(path).setJson(JSONObject.toJSONString(requestParam)).build().doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | |
| | | if (Cools.isEmpty(jsonObject.get("succeed"))) { |
| | |
| | | log.error(e.getMessage()); |
| | | throw new CoolException("调用接口响应错误"); |
| | | } finally { |
| | | apiLogService.save( |
| | | namespace, |
| | | url + path, |
| | | appkey, |
| | | ip, |
| | | JSON.toJSONString(JSONObject.toJSONString(requestParam)), |
| | | response, |
| | | success |
| | | ); |
| | | apiLogService.save(namespace, url + path, appkey, ip, JSON.toJSONString(JSONObject.toJSONString(requestParam)), response, success); |
| | | } |
| | | |
| | | } |