zhs 2 anni fa
parent
commit
2020733b09

+ 3 - 3
src/main/java/com/tld/controller/GsPlugOutController.java

@@ -70,9 +70,9 @@ public class GsPlugOutController {
     }
 
     /**
-     *
-     * @param error
-     * @return
+     * 失败重传
+     * @param error 参数
+     * @return 返回结果
      */
     @PostMapping("anew")
     public Map<String, Object> anew(@RequestBody Error error){

+ 35 - 0
src/main/java/com/tld/controller/StorageLocationController.java

@@ -1,12 +1,18 @@
 package com.tld.controller;
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.tld.excel.ExcelUtils;
 import com.tld.model.StorageLocation;
+import com.tld.model.UserMaterial;
 import com.tld.service.StorageLocationService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -77,4 +83,33 @@ public class StorageLocationController {
         storageLocationService.export(storageLocation, response);
     }
 
+    /**
+     * 导入
+     * @param file 文件
+     * @param request 参数
+     * @throws Exception
+     */
+    @PostMapping("/import")
+    public Map<String, Object> importExcel(@RequestPart("file") MultipartFile file, HttpServletRequest request) throws Exception{
+        Map<String, Object> map = new HashMap<>();
+        JSONArray array = ExcelUtils.readMultipartFile(file);
+        for(int i = 0; i < array.size(); i++){
+            JSONObject jsonObject = array.getJSONObject(i);
+            String value = jsonObject.get("所在仓库").toString();
+            String id = storageLocationService.getWarehouseWhere(value);
+            StorageLocation storageLocation = new StorageLocation()
+                    .setStorageLocationCode(jsonObject.get("库位编号").toString())
+                    .setStorageLocationName(jsonObject.get("库位名称").toString())
+                    .setWarehouseWhere(id)
+                    .setStorageLocationType(jsonObject.get("库位类型").toString())
+                    .setIsNotDisable(jsonObject.get("是否混合库位").toString())
+                    .setIsProduct(jsonObject.get("是否产成品库位0是1否").toString())
+                    .setModifyUser(request.getHeader("userId"));
+            storageLocationService.importExcel(storageLocation);
+        }
+        map.put("msg", "200");
+        map.put("data", array.size());
+        return map;
+    }
+
 }

+ 30 - 1
src/main/java/com/tld/controller/UserMaterialController.java

@@ -1,13 +1,19 @@
 package com.tld.controller;
 
-import com.tld.model.User;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.tld.excel.ExcelUtils;
 import com.tld.model.UserMaterial;
 import com.tld.service.UserMaterialService;
 import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -79,4 +85,27 @@ public class UserMaterialController {
         userMaterialService.Export(userMaterial, response);
     }
 
+    /**
+     * 物料用户绑定导入
+     * @param file 数据
+     * @param request 用户id
+     * @throws Exception
+     */
+    @PostMapping("/import")
+    public Map<String, Object> importExcel(@RequestPart("file") MultipartFile file, HttpServletRequest request) throws Exception{
+        Map<String, Object> map = new HashMap<>();
+        JSONArray array = ExcelUtils.readMultipartFile(file);
+        for(int i = 0; i < array.size(); i++){
+            JSONObject jsonObject = array.getJSONObject(i);
+            UserMaterial userMaterial = new UserMaterial()
+                    .setMaterialId(jsonObject.get("物料编号").toString())
+                    .setUserName(jsonObject.get("工号").toString())
+                    .setModifyUser(request.getHeader("userId"));
+            userMaterialService.replaceUser(userMaterial);
+        }
+        map.put("msg", "200");
+        map.put("data", array.size());
+        return map;
+    }
+
 }

+ 2 - 0
src/main/java/com/tld/mapper/StorageLocationMapper.java

@@ -18,4 +18,6 @@ public interface StorageLocationMapper {
     List<Map<String, Object>> export(StorageLocation storageLocation);
 
     int getStorageCount(StorageLocation storageLocation);
+
+    String getWarehouseWhere(String value);
 }

+ 2 - 0
src/main/java/com/tld/mapper/UserMaterialMapper.java

@@ -23,4 +23,6 @@ public interface UserMaterialMapper {
     int getMaterial(@Param("wllbCode") String wllbCode);
 
     List<Map<String, Object>> Export(UserMaterial userMaterial);
+
+    Map<String, Object> getMaterialVal(UserMaterial userMaterial);
 }

+ 4 - 0
src/main/java/com/tld/service/StorageLocationService.java

@@ -18,4 +18,8 @@ public interface StorageLocationService {
     void export(StorageLocation storageLocation, HttpServletResponse response);
 
     Map<String, Object> getStorageAll(StorageLocation storageLocation);
+
+    String getWarehouseWhere(String value);
+
+    void importExcel(StorageLocation storageLocation);
 }

+ 3 - 0
src/main/java/com/tld/service/UserMaterialService.java

@@ -4,6 +4,7 @@ import com.tld.model.UserMaterial;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.util.List;
 import java.util.Map;
 
 public interface UserMaterialService {
@@ -18,4 +19,6 @@ public interface UserMaterialService {
     Map<String, Object> getUser();
 
     void Export(UserMaterial userMaterial, HttpServletResponse response);
+
+    void replaceUser(UserMaterial userMaterial);
 }

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

@@ -322,10 +322,8 @@ public class AskGoodsServiceImpl implements AskGoodsService {
             JSONObject ReqOutStocks = new JSONObject();
             ReqOutStocks.put("ReqOutStocks",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/CreateProductiveOutStock", returnData);
-            System.out.println("result:"+result);
             Error error = new Error();
             int type = 0;
             if(Integer.parseInt(result.get("msg").toString()) != 200){

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

@@ -96,7 +96,7 @@ public class QueryListServiceImpl implements QueryListService {
             //导出数据汇总
             List<List<Object>> sheetDataList = new ArrayList<>();
             //表头数据
-            List<Object> head = Arrays.asList("物料编号", "物料名称", "数量","库位名称","所属公司","供应商","WBS编号","仓库名称");
+            List<Object> head = Arrays.asList("会计年度", "会计期间", "仓库编号", "仓库名称", "库位名称", "物料编号", "物料名称", "主计量单位", "库存数量", "WBS编号", "安全库存", "库龄(天)", "核算分类名称", "物料分类名称", "所属公司编号", "所属公司名车才能够");
             //查询数据
             List<Map<String, Object>> list = queryListMapper.getStorageLocation(inventory);
             sheetDataList.add(head);

+ 10 - 0
src/main/java/com/tld/service/impl/StorageLocationServiceImpl.java

@@ -130,4 +130,14 @@ public class StorageLocationServiceImpl implements StorageLocationService {
         }
         return map;
     }
+
+    @Override
+    public String getWarehouseWhere(String value) {
+        return storageLocationMapper.getWarehouseWhere(value);
+    }
+
+    @Override
+    public void importExcel(StorageLocation storageLocation) {
+        storageLocationMapper.addStorage(storageLocation);
+    }
 }

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

@@ -124,7 +124,7 @@ public class UserMaterialServiceImpl implements UserMaterialService {
             //导出数据汇总
             List<List<Object>> sheetDataList = new ArrayList<>();
             //表头数据
-            List<Object> head = Arrays.asList("物料编号", "物料名称", "用户名称","真实姓名");
+            List<Object> head = Arrays.asList("物料编号", "物料名称", "工号","真实姓名");
             //查询数据
             List<Map<String, Object>> list = userMaterialMapper.Export(userMaterial);
             sheetDataList.add(head);
@@ -143,4 +143,16 @@ public class UserMaterialServiceImpl implements UserMaterialService {
             e.printStackTrace();
         }
     }
+
+    @Override
+    public void replaceUser(UserMaterial userMaterial) {
+        try{
+            Map<String, Object> map = userMaterialMapper.getMaterialVal(userMaterial);
+            userMaterial.setMaterialId(map.get("materialId").toString())
+                    .setUserId(map.get("id").toString());
+            userMaterialMapper.addUserMaterial(userMaterial);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
 }

+ 7 - 5
src/main/resources/mapper/AskGoodsMapper.xml

@@ -62,10 +62,10 @@
                a.production_code,
                a.wbs
         FROM tld_ask_goods a
-                 JOIN tld_ask_goods_f b ON a.ask_goods_id = b.ask_goods_id
-                 LEFT JOIN tld_department c ON b.department = c.code
-                 JOIN tld_material e ON a.material_id = e.tld_id
-                 left join tld_company g on b.company_number = g.code
+         JOIN tld_ask_goods_f b ON a.ask_goods_id = b.ask_goods_id
+         LEFT JOIN tld_department c ON b.department = c.code
+         JOIN tld_material e ON a.material_id = e.tld_id
+         left join tld_company g on b.company_number = g.code
         WHERE (a.num + 0) <![CDATA[>]]> (
             IFNULL(a.out_num, 0) + 0)
           and e.part_type != '半成品' and e.part_type != '产成品'
@@ -82,7 +82,9 @@
                b.company_number,
                c.name,
                c.code,
-               c.id                 AS departmentId
+               c.id                 AS departmentId,
+               a.production_code,
+               a.wbs
         FROM tld_ask_goods a
                  JOIN tld_ask_goods_f b ON a.ask_goods_id = b.ask_goods_id
                  LEFT JOIN tld_department c ON b.department = c.code

+ 37 - 36
src/main/resources/mapper/QueryListMappeer.xml

@@ -137,28 +137,28 @@
         GROUP BY
         a.storage_location_code,
         a.material_id,
-        a.wbs ,
+        a.wbs,
         a.account_sleeve
     </select>
     <!-- 查询库位信息 -->
     <select id="getQueryInventory" resultType="java.util.Map">
         SELECT
-        a.storage_location_code as storageLocationCode,
-        a.material_id as materialId,
-        a.amount AS sum,
-        a.serial,
-        a.produc_batch as producBatch,
-        a.supplier_id as supplierId,
-        b.storage_location_name as storageLocationName ,
-        b.warehouse_where as warehouseWhere,
-        b.storage_location_type as storageLocationType,
-        b.storage_location_capacity as storageLocationCapacity,
-        b.is_not_disable as isNotDisable,
-        b.create_time as createTime,
-        b.is_product as isProduct,
-        c.name as name,
-        c.code as code,
-        e.name as supplierName
+            a.storage_location_code as storageLocationCode,
+            a.material_id as materialId,
+            a.amount AS sum,
+            a.serial,
+            a.produc_batch as producBatch,
+            a.supplier_id as supplierId,
+            b.storage_location_name as storageLocationName ,
+            b.warehouse_where as warehouseWhere,
+            b.storage_location_type as storageLocationType,
+            b.storage_location_capacity as storageLocationCapacity,
+            b.is_not_disable as isNotDisable,
+            b.create_time as createTime,
+            b.is_product as isProduct,
+            c.name as name,
+            c.code as code,
+            e.name as supplierName
         FROM
         tld_inventory a
         LEFT JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
@@ -176,16 +176,23 @@
     <!--导出-->
     <select id="getStorageLocation" resultType="java.util.LinkedHashMap">
         SELECT
-        c.code as code,
-        c.name as name,
-        sum( a.amount ) AS sum,
-        b.storage_location_name as storageLocationName ,
-        p.name as companyName,
-        e.name as supplierName,
-        a.wbs as wbs,
-        f.name as warehouseName,
-        FROM
-        tld_inventory a
+            YEAR(CURDATE()) AS year,
+            MONTH(CURDATE()) AS month,
+            f.code as warehouseCode,
+            f.name as warehouseName,
+            b.storage_location_name as storageLocationName,
+            c.code as code,
+            c.name as name,
+            c.unit_of_measurement,
+            sum( a.amount ) AS sum,
+            a.wbs as wbs,
+            c.max_num,
+            DATEDIFF(now(),scrq),
+            c.part_type,
+            c.wllb_class,
+            p.code as companyCode,
+            p.name as companyName
+        FROM tld_inventory a
         LEFT JOIN tld_storage_location b ON a.storage_location_code = b.storage_location_code
         LEFT JOIN tld_material c ON a.material_id = c.tld_id
         LEFT JOIN tld_customer e ON a.supplier_id = e.code
@@ -222,7 +229,9 @@
         </trim>
         GROUP BY
         a.storage_location_code,
-        a.material_id
+        a.material_id,
+        a.wbs,
+        a.account_sleeve
     </select>
     <!-- 查询接入信息 -->
     <select id="getAccess" resultType="com.tld.model.Access">
@@ -926,13 +935,5 @@
         </trim>
         ORDER BY a.scrq DESC
     </select>
-    <!--查询库存数量-->
-    <select id="getAmount" resultType="java.lang.String">
-        select ifnull(sum(amount),'0') as amount from tld_inventory where wbs = #{wbs} and account_sleeve = #{companyNumber} and wllb_code = #{materialCode}
-    </select>
-    <!--查询库存数量-->
-    <select id="getAmounts" resultType="java.lang.String">
-        select ifnull(sum(amount),'0') as amount from tld_inventory where wbs = #{wbs} and account_sleeve = #{companyNumber} and wllb_code = #{materialCode}
-    </select>
 
 </mapper>

+ 5 - 0
src/main/resources/mapper/StorageLocationMapper.xml

@@ -54,6 +54,7 @@
     </select>
     <!-- 新增库位信息 -->
     <insert id="addStorage">
+        delete from tld_storage_location where storage_location_code = #{storageLocationCode};
         insert into tld_storage_location(storage_location_code,storage_location_name,warehouse_where,storage_location_type,is_not_disable,storage_location_capacity,create_time,is_product,modify_user,modify_time)
         values(#{storageLocationCode},#{storageLocationName},#{warehouseWhere},#{storageLocationType},#{isNotDisable},#{storageLocationCapacity},NOW(),#{isProduct},#{modifyUser},NOW())
     </insert>
@@ -130,4 +131,8 @@
     <select id="getStorageCount" resultType="int">
         select count(*) from tld_storage_location where storage_location_code = #{storageLocationCode}
     </select>
+    <!-- 仓库id -->
+    <select id="getWarehouseWhere" resultType="String">
+        select tld_id from tld_warehouse where name = #{value}
+    </select>
 </mapper>

+ 7 - 1
src/main/resources/mapper/UserMaterialMapper.xml

@@ -47,6 +47,7 @@
     </select>
     <!-- 新增用户绑定物料信息 -->
     <insert id="addUserMaterial">
+        delete from tld_user_material where material_id = #{materialId} and user_id = #{userId};
         insert into tld_user_material(material_id,user_id,scrq,modify_user,modify_time) value(#{materialId},#{userId},now(),#{modifyUser},now())
     </insert>
     <!-- 修改用户绑定物料信息 -->
@@ -126,5 +127,10 @@
         </trim>
         order by a.id desc
     </select>
-
+    <!-- 查询物料跟用户id -->
+    <select id="getMaterialVal" parameterType="java.util.Map" resultType="java.util.Map">
+        select (select tld_id from tld_material where code = #{materialId}) as materialId,
+               (select id from tld_user where user_name = #{userName}) as id
+               from dual
+    </select>
 </mapper>