|
@@ -646,6 +646,100 @@ public class AskGoodsServiceImpl implements AskGoodsService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 销售发货单接口
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void CreateBOLOutStock(String removalCode) {
|
|
|
+ try{
|
|
|
+ JSONObject returnData = new JSONObject();
|
|
|
+ List<JSONObject> retunList = new LinkedList<>();
|
|
|
+ for(String warehouseWhere : askGoodsMapper.getWarehouseWhere(removalCode)){
|
|
|
+ List<Map<String, Object>> mapList = askGoodsMapper.getGsRemoval(removalCode);
|
|
|
+ if(mapList.size() >0 ) {
|
|
|
+ JSONObject strJson = new JSONObject();
|
|
|
+ //父表
|
|
|
+ strJson.put("BOLID", mapList.get(0).get("askGoodsId").toString());//要货单id
|
|
|
+ strJson.put("WMSID", mapList.get(0).get("id").toString());//出库单id
|
|
|
+ strJson.put("WMSCode", mapList.get(0).get("removalCode").toString());//出库单编号
|
|
|
+ strJson.put("WareHouse", warehouseWhere);//仓库ID
|
|
|
+ strJson.put("SourceBillDate",DateUtil.dateConversion(mapList.get(0).get("scrq").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.getRemovalz(mapList.get(0).get("askGoodsId").toString(), warehouseWhere)) {
|
|
|
+ JSONObject BillItems = new JSONObject();
|
|
|
+ BillItems.put("WMSItemID", map.get("id"));//分录ID
|
|
|
+ BillItems.put("BOLID", map.get("askGoodsId"));//要货申请单ID
|
|
|
+ BillItems.put("BOLItemID", map.get("entryNumber"));//要货申请明细ID
|
|
|
+ BillItems.put("Material", map.get("materialId"));//物料id
|
|
|
+ BillItems.put("Quantity", map.get("num"));//数量
|
|
|
+ BillItems.put("FlexField1", map.get("wbs"));//wbs
|
|
|
+ BillItems.put("FlexField1Code", " ");//WBS编号
|
|
|
+ BillItems.put("FlexField1Name", " ");//WBS名称
|
|
|
+ list.add(BillItems);
|
|
|
+ }
|
|
|
+ strJson.put("BillItems", list);
|
|
|
+ retunList.add(strJson);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ JSONObject ReqOutStocks = new JSONObject();
|
|
|
+ ReqOutStocks.put("BILLs",retunList);
|
|
|
+ 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/CreateBOLOutStock", 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/CreateBOLOutStock");
|
|
|
+ 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/CreateBOLOutStock");
|
|
|
+ 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/CreateProductiveOutStock");
|
|
|
+ error.setDataVal(jsonObject2.toString());
|
|
|
+ errorMapper.addError(error);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //删除父子表信息
|
|
|
+ askGoodsMapper.delPlugOutRemoval(removalCode);
|
|
|
+ askGoodsMapper.delRemovalz(removalCode);
|
|
|
+ //添加记录到tld_access
|
|
|
+ String names = "出库回传" ;
|
|
|
+ String accessType = "1" ;
|
|
|
+ String returnGsRemoval = returnData.toString() ;
|
|
|
+ askGoodsMapper.addAccess(names,returnGsRemoval,accessType);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 出库单生成
|
|
|
* @return
|