xiaochen 2 år sedan
förälder
incheckning
eea9d74ebe

+ 9 - 0
src/main/java/com/tld/controller/GsPlugOutController.java

@@ -87,6 +87,15 @@ public class GsPlugOutController {
         askGoodsService.CreateOtherDeliveryMaterials(removalCode);
     }
 
+    /**
+     * 其他发货(参照要货申请制单(其他发货通知_青岛工厂))接口文档/其他出货接口文档/其它出库
+     * @param removalCode 入库单编号
+     */
+    @GetMapping("CreateOtherDeliveryMaterial")
+    public void CreateOtherDeliveryMaterial(String removalCode){
+        askGoodsService.CreateOtherDeliveryMaterial(removalCode);
+    }
+
     /**
      * 失败重传
      * @param error 参数

+ 8 - 0
src/main/java/com/tld/model/AskGoods.java

@@ -252,4 +252,12 @@ public class AskGoods implements Serializable {
      * 库存数量
      */
     private String amount;
+    /**
+     * 分组   groupBy
+     */
+    private String groupBy;
+    /**
+     * 子表id分录单id
+     */
+    private String documentPointsId;
 }

+ 2 - 0
src/main/java/com/tld/service/AskGoodsService.java

@@ -55,4 +55,6 @@ public interface AskGoodsService {
     void CreateOtherInStock(String removalCode);
 
     void CreateOtherDeliveryMaterials(String removalCode);
+
+    void CreateOtherDeliveryMaterial(String removalCode);
 }

+ 111 - 7
src/main/java/com/tld/service/impl/AskGoodsServiceImpl.java

@@ -140,7 +140,8 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                 Inventory inventory = new Inventory()
                         .setMaterialId(askGoods1.getMaterialId())
                         .setWbs(askGoods1.getWbs())
-                        .setCompanyCode(askGoods1.getCompanyNumber());
+                        .setCompanyCode(askGoods1.getCompanyNumber())
+                        .setGroupBy(askGoods.getGroupBy());
                 List<Map<String, Object>> inventorVal = queryListMapper.storageLocation(inventory);
                 if(inventorVal.size() != 0){
                     mapVal.add(inventorVal.get(0).get("sum").toString());
@@ -616,13 +617,13 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                 map.put("errMsg", "未查询到该库位的库存");
                 return map;
             }
-            if(Integer.parseInt(inventory.get(0).getAmount()) < Integer.parseInt(askGoods.getNum())){
+            if(Double.parseDouble(inventory.get(0).getAmount()) < Double.parseDouble(askGoods.getNum())){
                 map.put("msg", "500");
                 map.put("errMsg", "库存数量不足");
                 return map;
             }
             //如果出库库存等于虚拟表库存则删除此库存
-            if(Integer.parseInt(askGoods.getNum()) == Integer.parseInt(inventory.get(0).getAmount())){
+            if(Double.parseDouble(askGoods.getNum()) == Double.parseDouble(inventory.get(0).getAmount())){
                 askGoodsMapper.deleteInventory(inventory.get(0));
             } else {
                 inventory.get(0).setAmount(askGoods.getNum());
@@ -1220,7 +1221,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                     List<JSONObject> list = new LinkedList<>();
                     for (Map<String, Object> map : askGoodsMapper.getRemovalz(mapList.get(0).get("askGoodsId").toString(),maps.get("warehouseWhere").toString())) {
                         JSONObject BillItems = new JSONObject();
-                        BillItems.put("WMSItemID", map.get("id"));//分录ID
+                        BillItems.put("WMSItemID", map.get("askId"));//分录ID
                         BillItems.put("GIReqBillID", map.get("askGoodsId"));//要货申请单ID
                         BillItems.put("GIReqBillItemID", map.get("entryNumber"));//要货申请明细ID
                         BillItems.put("Material", map.get("materialId"));//物料id
@@ -1247,7 +1248,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                 //如果失败存入报错信息跟数据
                 error.setErrorInfo(result.get("data").toString());
                 error.setUrl("http://42.159.85.29:52480/cwbase/sg/V1/ERP/TELD/DEVTEST/API_WMS_PurInStock/CreateMakeUpOtherOutStock");
-                error.setDataVal(returnData.toJSONString()).setType("其它库");
+                error.setDataVal(returnData.toJSONString()).setType("其它库");
                 errorMapper.addError(error);
             } else {
                 JSONObject jsonObject = (JSONObject) JSONObject.parse(result.get("data").toString());
@@ -1256,7 +1257,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                     //如果失败存入报错信息跟数据
                     error.setErrorInfo(jsonObject1.get("Msg").toString());
                     error.setUrl("http://42.159.85.29:52480/cwbase/sg/V1/ERP/TELD/DEVTEST/API_WMS_PurInStock/CreateMakeUpOtherOutStock");
-                    error.setDataVal(returnData.toJSONString()).setType("其它库");
+                    error.setDataVal(returnData.toJSONString()).setType("其它库");
                     errorMapper.addError(error);
                 } else {
                     List<JSONObject> data1 = (List<JSONObject>) JSONObject.parse(jsonObject1.get("data").toString());
@@ -1267,7 +1268,110 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                                     //如果失败存入报错信息跟数据
                                     error.setErrorInfo(map.get("FailReason").toString());
                                     error.setUrl("http://42.159.85.29:52480/cwbase/sg/V1/ERP/TELD/DEVTEST/API_WMS_PurInStock/CreateMakeUpOtherOutStock");
-                                    error.setDataVal(jsonObject2.toString()).setType("其它入库");
+                                    error.setDataVal(jsonObject2.toString()).setType("其它出库");
+                                    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();
+        }
+    }
+
+    /**
+    * @Description: 其他发货(参照要货申请制单(其他发货通知_青岛工厂))接口文档
+    * @Param: removalCode
+    * @return: void
+    * @Author: XiaoChen
+    * @Date: 2023/4/14
+    */
+    @Override
+    public void CreateOtherDeliveryMaterial(String removalCode) {
+        try {
+            JSONObject returnData = new JSONObject();
+            List<JSONObject> retunList = new LinkedList<>();
+            LinkedList<String> noticeIds = new LinkedList<>();
+            //通过出库单编号查询单据ID
+            List<Map<String,Object>> lists = askGoodsMapper.getCreateOtherDeliveryMaterialsWarehouseWhere(removalCode);
+            //根据id查询子表的供货仓库
+            //根据仓库循环
+            for (Map<String, Object> maps : lists) {
+                List<Map<String, Object>> mapList = askGoodsMapper.getGsRemoval(removalCode);
+                if(mapList.size() >0 ) {
+                    JSONObject strJson = new JSONObject();
+                    //父表
+                    strJson.put("GIReqBillID", 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", maps.get("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(),maps.get("warehouseWhere").toString())) {
+                        JSONObject BillItems = new JSONObject();
+                        BillItems.put("WMSItemID", map.get("askId"));//分录ID
+                        BillItems.put("GIReqBillID", map.get("askGoodsId"));//要货申请单ID
+                        BillItems.put("GIReqBillItemID", 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("ReqOutStocks", 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/CreateOtherOutStock", 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/CreateOtherOutStock");
+                error.setDataVal(returnData.toJSONString()).setType("其它出库");
+                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/CreateOtherOutStock");
+                    error.setDataVal(returnData.toJSONString()).setType("其它出库");
+                    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/CreateOtherOutStock");
+                                    error.setDataVal(jsonObject2.toString()).setType("其它出库");
                                     errorMapper.addError(error);
                                 }
                             }

+ 1 - 1
src/main/java/com/tld/service/impl/ReceiveGoodsSerivceImpl.java

@@ -110,7 +110,7 @@ public class ReceiveGoodsSerivceImpl implements ReceiveGoodsSerivce {
                for (ReceiveGoods receiveGoods : receiveGoodsList) {
                    receiveGoods.setType("0");
                    //存在一个采购单发送多次的情况  如果是一个采购单多次传输 则改变原数据的数量
-                   ReceiveGoods receiveGoods1 = new ReceiveGoods().setOrderCode(receiveGoods.getOrderCode()).setMaterialId(receiveGoods.getMaterialId());
+                   ReceiveGoods receiveGoods1 = new ReceiveGoods().setOrderCode(receiveGoods.getOrderCode()).setMaterialId(receiveGoods.getMaterialId()).setWbs(receiveGoods.getWbs()).setCompanyNumber(receiveGoods.getCompanyNumber());
                    List<ReceiveGoods> listRepeat = receiveGoodsMapper.getReceiveGoods(receiveGoods1);
                    if (listRepeat.size() != 0) {
                        receiveGoods.setArrivalNum(String.valueOf(Integer.parseInt(listRepeat.get(0).getArrivalNum()) + Integer.parseInt(receiveGoods.getArrivalNum())));

+ 3 - 2
src/main/resources/mapper/AskGoodsMapper.xml

@@ -119,6 +119,7 @@
           and a.account_sleeve = #{companyNumber}
           and a.hold = '0'
           and (c.warehouse_type = '0' or c.warehouse_type = '1' or c.warehouse_type = '2')
+          and a.wbs = #{wbs}
         order by a.produc_batch
     </select>
     <!-- 新增出库虚拟表 -->
@@ -1345,7 +1346,7 @@
         update tld_removal_half set transmission_type = "1" where storage_code = #{removalCode}
     </update>
     <!-- 往单据上增加数量 -->
-    <update id="updateNoticesWarehousingNum">
-        update tld_enquiry set out_num = (out_num + 0) + #{amount} where ask_goods_id = #{askGoodsId} and entry_number = #{entryNumber}
+    <update id="updateEnquiryOutNum">
+        update tld_enquiry set out_num = (out_num + 0) + #{num} where ask_goods_id = #{askGoodsId} and entry_number = #{entryNumber}
     </update>
 </mapper>

+ 6 - 2
src/main/resources/mapper/QueryListMappeer.xml

@@ -96,7 +96,8 @@
             a.account_sleeve as accountSleeve,
             a.supplier_id as supplierId,
             e.name as supplierName,
-            a.storage_location_code as storageLocationCode
+            a.storage_location_code as storageLocationCode,
+            m.name as measurementName
         FROM
         tld_inventory a
         LEFT JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
@@ -104,6 +105,7 @@
         LEFT JOIN tld_customer e ON a.supplier_id = e.code
         LEFT JOIN tld_warehouse f on b.warehouse_where = f.tld_id
         LEFT JOIN tld_company p on a.account_sleeve = p.code
+        LEFT JOIN tld_measurement m on c.unit_of_measurement = m.tld_id
         <trim prefix="WHERE" prefixOverrides="and |or">
             <if test="storageLocationCode != null and storageLocationCode != ''">
                 and a.storage_location_code = #{storageLocationCode}
@@ -146,7 +148,7 @@
             </if>
         </trim>
         GROUP BY
-/*        a.storage_location_code,
+/*      a.storage_location_code,
         a.material_id,
         a.wbs,
         a.account_sleeve*/
@@ -1066,6 +1068,7 @@
             a.measurement_id,
             a.num,
             a.out_num,
+            a.entry_number,
             b.ask_goods_code,
             b.company_number,
             b.sqrq,
@@ -1075,6 +1078,7 @@
             b.request_type_number,
             b.request_type_name,
             b.if_commodity,
+            b.id as documentPointsId,
             c.name as materialName,
             c.code as materialCode,
             c.part_type,