|
@@ -919,6 +919,110 @@ public class AskGoodsServiceImpl implements AskGoodsService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @Description: 生产收货接口文档
|
|
|
+ * @Param: removalCode 入库单编号
|
|
|
+ * @return: void
|
|
|
+ * @Author: XiaoChen
|
|
|
+ * @Date: 2023/4/7
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void CreateGRReqInStock(String removalCode) {
|
|
|
+ try {
|
|
|
+ JSONObject returnData = new JSONObject();
|
|
|
+ List<JSONObject> retunList = new LinkedList<>();
|
|
|
+ //通过入库单编号查询入库单信息
|
|
|
+ ReturnWarehousing returnWarehousing = askGoodsMapper.getReturnGsWarehousing(removalCode);
|
|
|
+ //根据id查询子表的供货仓库
|
|
|
+ for (String warehouseWhere : askGoodsMapper.getStorageLocationWarehouseWhere(returnWarehousing)) {
|
|
|
+ //查询父表信息
|
|
|
+ List<Map<String, Object>> mapList = askGoodsMapper.getNoticeParent(returnWarehousing.getOrderNumber());
|
|
|
+ if (mapList.size() > 0) {
|
|
|
+ JSONObject strJson = new JSONObject();
|
|
|
+ //父表
|
|
|
+ strJson.put("GRReqBillID", mapList.get(0).get("noticeId").toString());//入库通知单ID
|
|
|
+ strJson.put("WMSID", mapList.get(0).get("id").toString());//利道WMS出库单id
|
|
|
+ strJson.put("WMSCode", mapList.get(0).get("noticeCode").toString());//利道WMS出库单编号
|
|
|
+ strJson.put("WareHouse", warehouseWhere);//仓库ID
|
|
|
+ strJson.put("SourceBillDate", DateUtil.dateConversion(mapList.get(0).get("noticeTime").toString()));//业务日期
|
|
|
+ strJson.put("SourceType", mapList.get(0).get("sourceType").toString());//来源类型
|
|
|
+ strJson.put("MoveType", mapList.get(0).get("moveType").toString());//移动类型
|
|
|
+ strJson.put("IsRed", 0);//是否红单1
|
|
|
+ strJson.put("Creator", "测试");//制单人姓名1
|
|
|
+ //子表
|
|
|
+ List<JSONObject> list = new LinkedList<>();
|
|
|
+ for (Map<String, Object> map : askGoodsMapper.getNoticeSubtabulation(mapList.get(0).get("noticeId").toString())) {
|
|
|
+ JSONObject BillItems = new JSONObject();
|
|
|
+ BillItems.put("WMSItemID", map.get("id"));//分录ID
|
|
|
+ BillItems.put("GRReqBillID", map.get("noticeId"));//入库通知单ID
|
|
|
+ BillItems.put("GRReqBillItemID", map.get("entryNumber"));//入库通知单明细ID
|
|
|
+ BillItems.put("Material", map.get("materialId"));//物料id
|
|
|
+ BillItems.put("Quantity", map.get("num"));//数量
|
|
|
+ BillItems.put("FlexField1", map.get("wbsId"));//wbs
|
|
|
+ BillItems.put("FlexField1Code", map.get("wbsCode"));//WBS编号
|
|
|
+ BillItems.put("FlexField1Name", map.get("wbsName"));//WBS名称
|
|
|
+ list.add(BillItems);
|
|
|
+ }
|
|
|
+ strJson.put("BillItems", list);
|
|
|
+ retunList.add(strJson);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ JSONObject ReqOutStocks = new JSONObject();
|
|
|
+ ReqOutStocks.put("BILLs", retunList);
|
|
|
+ List<JSONObject> retunList1 = new LinkedList<>();
|
|
|
+ returnData.put("strJson", JSON.toJSONString(ReqOutStocks));
|
|
|
+ System.out.println(returnData);
|
|
|
+ HttpClientUtil httpClientUtil1 = new HttpClientUtil();
|
|
|
+ Map<String, Object> result = httpClientUtil1.doPost("http://42.159.85.29:52480/cwbase/sg/V1/ERP/TELD/DEVTEST/API_WMS_PurInStock/CreateGRReqInStock", returnData);
|
|
|
+ System.out.println("result:" + result);
|
|
|
+ Error error = new Error();
|
|
|
+ if (Integer.parseInt(result.get("msg").toString()) != 200) {
|
|
|
+ //如果失败存入报错信息跟数据
|
|
|
+ error.setErrorInfo(result.get("data").toString());
|
|
|
+ error.setUrl("http://42.159.85.29:52480/cwbase/sg/V1/ERP/TELD/DEVTEST/API_WMS_PurInStock/CreateGRReqInStock");
|
|
|
+ error.setDataVal(returnData.toJSONString());
|
|
|
+ errorMapper.addError(error);
|
|
|
+ } else {
|
|
|
+ JSONObject jsonObject = (JSONObject) JSONObject.parse(result.get("data").toString());
|
|
|
+ JSONObject jsonObject1 = (JSONObject) JSONObject.parse(jsonObject.get("result").toString());
|
|
|
+ if (jsonObject1.get("State").toString().equals("0")) {
|
|
|
+ //如果失败存入报错信息跟数据
|
|
|
+ error.setErrorInfo(jsonObject1.get("Msg").toString());
|
|
|
+ error.setUrl("http://42.159.85.29:52480/cwbase/sg/V1/ERP/TELD/DEVTEST/API_WMS_PurInStock/CreateGRReqInStock");
|
|
|
+ error.setDataVal(returnData.toJSONString());
|
|
|
+ errorMapper.addError(error);
|
|
|
+ } else {
|
|
|
+ List<JSONObject> data1 = (List<JSONObject>) JSONObject.parse(jsonObject1.get("data").toString());
|
|
|
+ for (JSONObject map : data1) {
|
|
|
+ if (map.get("State").toString().equals("0")) {
|
|
|
+ for (JSONObject jsonObject2 : retunList) {
|
|
|
+ if (jsonObject2.get("WMSCode").toString().equals(map.get("WMSCode")) && jsonObject2.get("WareHouse").toString().equals(map.get("WareHouse"))) {
|
|
|
+ //如果失败存入报错信息跟数据
|
|
|
+ error.setErrorInfo(map.get("FailReason").toString());
|
|
|
+ error.setUrl("http://42.159.85.29:52480/cwbase/sg/V1/ERP/TELD/DEVTEST/API_WMS_PurInStock/CreateGRReqInStock");
|
|
|
+ error.setDataVal(jsonObject2.toString());
|
|
|
+ errorMapper.addError(error);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //删除父子表信息
|
|
|
+ //根据code
|
|
|
+// askGoodsMapper.delNoticeParent(returnWarehousing.getOrderNumber());
|
|
|
+// //根据id
|
|
|
+// askGoodsMapper.delNoticeSubtabulation(returnWarehousing.getOrderNumber());
|
|
|
+ //添加记录到tld_access
|
|
|
+ String names = "报工单";
|
|
|
+ String accessType = "1";
|
|
|
+ String returnGsRemoval = returnData.toString();
|
|
|
+ askGoodsMapper.addAccess(names, returnGsRemoval, accessType);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 出库单生成
|
|
|
* @return
|