| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.fasterxml.jackson.databind.JsonNode; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.zy.asrs.entity.DocType; |
| | | import com.zy.asrs.entity.Order; |
| | | import com.zy.asrs.entity.OrderDetl; |
| | | import com.zy.asrs.service.ApiLogService; |
| | | import com.zy.asrs.service.DocTypeService; |
| | | import com.zy.asrs.service.OrderDetlService; |
| | | import com.zy.asrs.service.OrderService; |
| | | import com.zy.asrs.task.AbstractHandler; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Set; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * Created by Monkey D. Luffy on 2023.10.21 |
| | |
| | | @Autowired |
| | | private DocTypeService docTypeService; |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | @Autowired |
| | | private LoginAuthenticationHandler loginAuthenticationHandler; |
| | | |
| | | @Transactional |
| | | public ReturnT<String> start(Order order) { |
| | | List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId()); |
| | | if (Cools.isEmpty(orderDetls) || orderDetls.size()==0){ |
| | | return SUCCESS; |
| | | } |
| | | //登录金蝶r |
| | | ReturnT<String> start = loginAuthenticationHandler.start(); |
| | | DocType docType = docTypeService.selectById(order.getDocType()); |
| | |
| | | return SUCCESS; |
| | | } |
| | | KingDeeUtilType kingDeeUtilType = KingDeeUtilType.get(docType.getDocName()); |
| | | |
| | | if (kingDeeUtilType.entryId!=2){ |
| | | return SUCCESS; |
| | | } |
| | | Date now = new Date(); |
| | | //条件拼接 |
| | | JSONObject jsonObjectFBillTypeID = new JSONObject(); |
| | | JSONObject jsonObjectFPickerId = new JSONObject(); |
| | | if (kingDeeUtilType.pakIn==1){ |
| | | jsonObjectFBillTypeID.put("FNUMBER","QTRKD01_SYS"); |
| | | }else { |
| | | jsonObjectFBillTypeID.put("FNUMBER","QTCKD01_SYS"); |
| | | jsonObjectFPickerId.put("FStaffNumber","X0103_GLGW074_1"); |
| | | } |
| | | |
| | | JSONObject jsonObjectFStockOrgId = new JSONObject(); |
| | | jsonObjectFStockOrgId.put("FNUMBER","100"); |
| | | |
| | | JSONObject jsonObjectFOwnerIdHead = new JSONObject(); |
| | | jsonObjectFOwnerIdHead.put("FNUMBER","100"); |
| | | |
| | | JSONObject jsonObjectFDEPTID = new JSONObject(); |
| | | jsonObjectFDEPTID.put("FNUMBER","CX"); |
| | | |
| | | List<JSONObject> jsonObjects = new ArrayList<>(); |
| | | |
| | | for (OrderDetl orderDetl:orderDetls){ |
| | | JSONObject jsonObjectFMATERIALID = new JSONObject(); |
| | | jsonObjectFMATERIALID.put("FNUMBER",orderDetl.getMatnr()); |
| | | |
| | | JSONObject jsonObjectFSTOCKID = new JSONObject(); |
| | | jsonObjectFSTOCKID.put("FNUMBER","CK001"); |
| | | |
| | | JSONObject jsonObjectFLOT = new JSONObject(); |
| | | jsonObjectFLOT.put("FNUMBER",orderDetl.getBatch()); |
| | | |
| | | // 使用LinkedHashMap来保持插入顺序 |
| | | Map<String, Object> orderedMap = new LinkedHashMap<>(); |
| | | |
| | | // 按照期望的顺序添加键值对 |
| | | orderedMap.put("FMATERIALID", jsonObjectFMATERIALID); |
| | | orderedMap.put("FSTOCKID", jsonObjectFSTOCKID); |
| | | orderedMap.put("FLOT", jsonObjectFLOT); |
| | | orderedMap.put("FQty", orderDetl.getQty()); // 将"FQty"放到最后 |
| | | |
| | | JSONObject jsonObjectEnd = new JSONObject(orderedMap); |
| | | |
| | | jsonObjects.add(jsonObjectEnd); |
| | | } |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("Numbers",order.getOrderNo()); |
| | | jsonObject.put("FBillTypeID",jsonObjectFBillTypeID); |
| | | if (kingDeeUtilType.pakIn==0){ |
| | | jsonObject.put("FPickerId",jsonObjectFPickerId); |
| | | } |
| | | jsonObject.put("FDate",DateUtils.convert(now, DateUtils.yyyyMMdd_F)); |
| | | jsonObject.put("FStockOrgId",jsonObjectFStockOrgId); |
| | | jsonObject.put("FOwnerTypeIdHead","BD_OwnerOrg"); |
| | | jsonObject.put("FOwnerIdHead",jsonObjectFOwnerIdHead); |
| | | jsonObject.put("FDEPTID",jsonObjectFDEPTID); |
| | | jsonObject.put("FEntity",jsonObjects); |
| | | |
| | | JSONObject jsonObjectModel = new JSONObject(); |
| | | jsonObjectModel.put("Model",jsonObject); |
| | | |
| | | JSONObject jsonObject1 = new JSONObject(); |
| | | jsonObject1.put("data", jsonObject); |
| | | jsonObject1.put("data", jsonObjectModel); |
| | | jsonObject1.put("FormId",kingDeeUtilType.correspondingFormId); |
| | | String add = jsonObject1.toJSONString(); |
| | | //上报 |
| | |
| | | .setUri(URL) |
| | | .setPath(outaddressSave) |
| | | .setJson(add) |
| | | .setHttps(true) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject data = JSON.parseObject(response); |
| | | Object IsSuccess = findValueByKey(JSON.parseObject(response), "IsSuccess"); |
| | | String bool=IsSuccess.toString(); |
| | | String bool1=IsSuccess.toString(); |
| | | //保存完成原订单8转6 |
| | | if(bool.equals("true")){ |
| | | success = true; |
| | | order.setSettle(6L); |
| | | if(bool1.equals("true")){ |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | JsonNode rootNode = objectMapper.readTree(response); |
| | | boolean bool = rootNode.get("Result").get("ResponseStatus").get("IsSuccess").asBoolean(); |
| | | log.info("审核bool:"+bool); |
| | | //提交完成原订单4转6 6.上报完成 |
| | | if(bool){ |
| | | success = true; |
| | | order.setSettle(6L); |
| | | order.setUpdateTime(new Date()); |
| | | orderService.update(order,new EntityWrapper<Order>().eq("order_no",order.getOrderNo())); |
| | | } |
| | | }else { |
| | | success = false; |
| | | order.setSettle(7L); |
| | | order.setUpdateTime(new Date()); |
| | | orderService.update(order,new EntityWrapper<Order>().eq("order_no",order.getOrderNo())); |
| | | } |
| | | } catch (Exception e) { |