Browse Source

问题修改

zhs 2 years ago
parent
commit
4f6acae9a2

+ 32 - 3
src/main/java/com/tld/controller/DictionaryController.java

@@ -3,9 +3,9 @@ package com.tld.controller;
 import com.tld.model.Dictionary;
 import com.tld.service.DictionaryService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
 import java.util.Map;
 
 /**
@@ -37,4 +37,33 @@ public class DictionaryController {
     public Map<String, Object> getDictionaryPage(Dictionary dictionary){
         return dictionaryService.getDictionaryPage(dictionary);
     }
+
+    /**
+     * 新增字典内容
+     * @param dictionary 参数
+     * @param request 参数
+     * @return 返回结果
+     */
+    @PostMapping("addDictionary")
+    public Map<String, Object> addDictionary(Dictionary dictionary, HttpServletRequest request){
+        return dictionaryService.addDiction(dictionary, request);
+    }
+    /**
+     * 修改字典内容
+     * @param dictionary 参数
+     * @return 返回结果
+     */
+    @PostMapping("updateDictionary")
+    public Map<String, Object> updateDictionary(Dictionary dictionary, HttpServletRequest request){
+        return dictionaryService.updateDictionary(dictionary, request);
+    }
+    /**
+     * 删除字典内容
+     * @param dictionary 参数
+     * @return 返回结果
+     */
+    @DeleteMapping("deleteDictionary")
+    public Map<String, Object> deleteDictionary(Dictionary dictionary){
+        return dictionaryService.deleteDictionary(dictionary);
+    }
 }

+ 8 - 0
src/main/java/com/tld/mapper/DictionaryMapper.java

@@ -29,4 +29,12 @@ public interface DictionaryMapper {
     int getInventorySumAmount(Dictionary dictionary1);
 
     List<Dictionary> getDictionaryMaterialPage(Dictionary dictionary);
+
+    void updateMaterial(Dictionary dictionary);
+
+    void updateTreasuryAccount(Dictionary dictionary);
+
+    void updateDictionary(Dictionary dictionary);
+
+    void deleteDictionary(Dictionary dictionary);
 }

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

@@ -103,4 +103,12 @@ public class Dictionary  implements Serializable {
      * 修改时间
      */
     private String modifyTime;
+    /**
+     * 类型
+     */
+    private String typeVal;
+    /**
+     * 公司编号
+     */
+    private String companyNumber;
 }

+ 7 - 0
src/main/java/com/tld/service/DictionaryService.java

@@ -2,6 +2,7 @@ package com.tld.service;
 
 import com.tld.model.Dictionary;
 
+import javax.servlet.http.HttpServletRequest;
 import java.util.List;
 import java.util.Map;
 
@@ -11,4 +12,10 @@ public interface DictionaryService {
     Map<String, Object> getDictionary(Dictionary dictionary);
 
     Map<String, Object> getDictionaryPage(Dictionary dictionary);
+
+    Map<String, Object> updateDictionary(Dictionary dictionary, HttpServletRequest request);
+
+    Map<String, Object> deleteDictionary(Dictionary dictionary);
+
+    Map<String, Object> addDiction(Dictionary dictionary, HttpServletRequest request);
 }

+ 79 - 0
src/main/java/com/tld/service/impl/DictionaryServiceImpl.java

@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
 import com.tld.model.Dictionary;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.servlet.http.HttpServletRequest;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -34,6 +35,7 @@ public class DictionaryServiceImpl implements DictionaryService {
                     return map;
                 }
                 dictionary.setTableName(tableName);
+                dictionary.setTypeVal("0");
                 if (dictionary.getType().equals("物料字典")) {
                     dictionaryMapper.addMaterial(dictionary);
                 } else if (dictionary.getType().equals("库账对存")) {
@@ -96,4 +98,81 @@ public class DictionaryServiceImpl implements DictionaryService {
         }
         return map;
     }
+
+    @Override
+    public Map<String, Object> updateDictionary(Dictionary dictionary, HttpServletRequest request) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            String tableName = dictionaryMapper.getTableName(dictionary.getType());
+            if ("null".equals(tableName)) {
+                map.put("msg", "500");
+                map.put("errMsg", "失败,请联系是否存在此字典");
+                return map;
+            }
+            dictionary.setTableName(tableName);
+            dictionary.setModifyUser(request.getHeader("userId"));
+            if (dictionary.getType().equals("物料字典")) {
+                dictionaryMapper.updateMaterial(dictionary);
+            } else if (dictionary.getType().equals("库账对存")) {
+                dictionaryMapper.updateTreasuryAccount(dictionary);
+            } else {
+                dictionaryMapper.updateDictionary(dictionary);
+            }
+            map.put("msg", "200");
+        }  catch (Exception e){
+            e.printStackTrace();
+            map.put("msg", "500");
+            map.put("errMsg", "失败");
+        }
+        return map;
+    }
+
+    @Override
+    public Map<String, Object> deleteDictionary(Dictionary dictionary) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            String tableName = dictionaryMapper.getTableName(dictionary.getType());
+            if ("null".equals(tableName)) {
+                map.put("msg", "500");
+                map.put("errMsg", "失败,请联系是否存在此字典");
+                return map;
+            }
+            dictionary.setTableName(tableName);
+            dictionaryMapper.deleteDictionary(dictionary);
+            map.put("msg", "200");
+        }  catch (Exception e){
+            e.printStackTrace();
+            map.put("msg", "500");
+            map.put("errMsg", "失败");
+        }
+        return map;
+    }
+
+    @Override
+    public Map<String, Object> addDiction(Dictionary dictionary, HttpServletRequest request) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            String tableName = dictionaryMapper.getTableName(dictionary.getType());
+            if ("null".equals(tableName)) {
+                map.put("msg", "500");
+                map.put("errMsg", "失败,请联系是否存在此字典");
+                return map;
+            }
+            dictionary.setTableName(tableName);
+            dictionary.setTypeVal("1");
+            if (dictionary.getType().equals("物料字典")) {
+                dictionaryMapper.addMaterial(dictionary);
+            } else if (dictionary.getType().equals("库账对存")) {
+                dictionaryMapper.addTreasuryAccount(dictionary);
+            } else {
+                dictionaryMapper.addDictionary(dictionary);
+            }
+            map.put("msg", "200");
+        }  catch (Exception e){
+            e.printStackTrace();
+            map.put("msg", "500");
+            map.put("errMsg", "失败");
+        }
+        return map;
+    }
 }

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

@@ -45,7 +45,7 @@
         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
+            LEFT JOIN tld_department c ON b.department = c.code
             JOIN tld_material e ON a.material_id = e.tld_id
         WHERE
                 ( a.num + 0 ) <![CDATA[>]]> (
@@ -67,7 +67,7 @@
         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
+            LEFT JOIN tld_department c ON b.department = c.code
             JOIN tld_material e ON a.material_id = e.tld_id
         WHERE
                 ( a.num + 0 ) <![CDATA[>]]> (
@@ -293,7 +293,7 @@
         from tld_removal a
         left join tld_material b on a.wllb_code = b.code
         left join tld_user c on a.user_id = c.id
-        left join tld_department e on a.department = e.tld_id
+        left join tld_department e on a.department = e.code
         left join tld_storage_location g on a.storage_location_code = g.storage_location_code
         left join tld_customer h on a.supplier_id = h.code
         <trim prefix="WHERE" prefixOverrides="and |or">
@@ -327,7 +327,7 @@
         from tld_removal a
         left join tld_material b on a.wllb_code = b.code
         left join tld_user c on a.user_id = c.id
-        left join tld_department e on a.department = e.tld_id
+        left join tld_department e on a.department = e.code
         left join tld_storage_location g on a.storage_location_code = g.storage_location_code
         left join tld_customer h on a.supplier_id = h.code
         <trim prefix="WHERE" prefixOverrides="and |or">
@@ -398,7 +398,7 @@
             tld_ask_goods a
             join tld_material b on a.material_id = b.tld_id
             join tld_ask_goods_f c on a.ask_goods_id = c.ask_goods_id
-            left join tld_department e on c.department = e.tld_id
+            left join tld_department e on c.department = e.code
         WHERE
             (a.num + 0) <![CDATA[>]]> (a.out_num + 0) and b.part_type = #{partType}
         <if test="productionCode != null and productionCode != ''">
@@ -431,7 +431,7 @@
             a.wbs
         from tld_removal_half_product a
         left join tld_material b on a.wllb_code = b.code
-        left join tld_department c on a.department = c.tld_id
+        left join tld_department c on a.department = c.code
         left join tld_user e on a.user_id = e.id
         <if test="wllbCode != null and wllbCode != ''">
             and a.wllb_code = #{wllbCode}
@@ -457,7 +457,7 @@
             a.wbs
         from tld_removal_half_product a
         left join tld_material b on a.wllb_code = b.code
-        left join tld_department c on a.department = c.tld_id
+        left join tld_department c on a.department = c.code
         left join tld_user e on a.user_id = e.id
         <if test="wllbCode != null and wllbCode != ''">
             and a.wllb_code = #{wllbCode}

+ 2 - 2
src/main/resources/mapper/ContainerMapper.xml

@@ -20,7 +20,7 @@
             a.modify_time as modifyTime,
             c.user_name as modifyUser
         from tld_container a
-        left join tld_department b on a.department = b.id
+        left join tld_department b on a.department = b.code
         left join tld_user c on a.modify_user = c.id
         <trim prefix="WHERE" prefixOverrides="and |or">
             <if test="department != null and department != ''">
@@ -83,7 +83,7 @@
             a.num,
             a.create_time
         from tld_container a
-        left join tld_department b on a.department = b.id
+        left join tld_department b on a.department = b.code
         <trim prefix="WHERE" prefixOverrides="and |or">
             <if test="department != null and department != ''">
                 and a.department = #{department}

+ 97 - 6
src/main/resources/mapper/DictionaryMapper.xml

@@ -8,13 +8,13 @@
     </select>
     <!-- 物料字典新增 -->
     <insert id="addMaterial">
-        insert into tld_material(code,name,tld_id,specification_and_model,unit_of_measurement,size,is_not_disable,is_recommend,min_num,max_num)
-        values(#{code},#{name},#{tldId},#{specificationAndModel},#{unitOfMeasurement},'0','0','0',"0","0")
+        insert into tld_material(code,name,tld_id,specification_and_model,unit_of_measurement,size,is_not_disable,is_recommend,min_num,max_num,typ,company_number)
+        values(#{code},#{name},#{tldId},#{specificationAndModel},#{unitOfMeasurement},'0','0','0',"0","0",#{typeVal},#{companyNumber})
     </insert>
     <!-- 字典新增 -->
     <insert id="addDictionary">
-        insert into ${tableName}(code,name,tld_id)
-        values(#{code},#{name},#{tldId})
+        insert into ${tableName}(code,name,tld_id,type)
+        values(#{code},#{name},#{tldId},#{typeVal})
     </insert>
     <!-- 查询字典内容 -->
     <select id="getDictionary" resultType="com.tld.model.Dictionary">
@@ -50,8 +50,8 @@
     </select>
     <!-- 库账对存字典新增 -->
     <insert id="addTreasuryAccount">
-        insert into tld_treasury_account(material_id,code,name,num)
-        values(#{materialId},#{code},#{name},#{num})
+        insert into tld_treasury_account(material_id,code,name,num,type)
+        values(#{materialId},#{code},#{name},#{num},#{typeVal})
     </insert>
     <!-- 查询仓库id -->
     <select id="getWarehouse" resultType="String">
@@ -84,4 +84,95 @@
             </if>
         </trim>
     </select>
+    <!-- 修改物料字典内容 -->
+    <update id="updateMaterial">
+        update tld_material
+        <set>
+            <trim suffixOverrides=",">
+                <if test="code != null and code != ''">
+                    code = #{code},
+                </if>
+                <if test="name != null and name != ''">
+                    name = #{name},
+                </if>
+                <if test="tldId != null and tldId != ''">
+                    tld_id = #{tldId},
+                </if>
+                <if test="specificationAndModel != null and specificationAndModel != ''">
+                    specification_and_model = #{specificationAndModel},
+                </if>
+                <if test="unitOfMeasurement != null and unitOfMeasurement != ''">
+                    unit_of_measurement = #{unitOfMeasurement},
+                </if>
+                <if test="size != null and size != ''">
+                    size = #{size},
+                </if>
+                <if test="wllbClass != null and wllbClass != ''">
+                    wllb_class = #{wllbClass},
+                </if>
+                <if test="isNotDisable != null and isNotDisable != ''">
+                    is_not_disable = #{isNotDisable},
+                </if>
+                <if test="isRecommend != null and isRecommend != ''">
+                    is_recommend = #{isRecommend},
+                </if>
+                <if test="partType != null and partType != ''">
+                    part_type = #{partType},
+                </if>
+                <if test="minNum != null and minNum != ''">
+                    min_num = #{minNum},
+                </if>
+                <if test="maxNum != null and maxNum != ''">
+                    max_num = #{maxNum},
+                </if>
+                <if test="companyNumber != null and companyNumber != ''">
+                    company_number = #{companyNumber},
+                </if>
+                modify_user = #{modifyUser},modify_time=now(),
+            </trim>
+        </set>
+            where id = #{id}
+    </update>
+    <!-- 库存对账 -->
+    <update id="updateTreasuryAccount">
+        update tld_material
+        <set>
+            <if test="materialId != null and materialId != ''">
+                material_id = #{materialId},
+            </if>
+            <if test="code != null and code != ''">
+                code = #{code},
+            </if>
+            <if test="name != null and name != ''">
+                name = #{name},
+            </if>
+            <if test="tldId != null and tldId != ''">
+                tld_id = #{tldId},
+            </if>
+        </set>
+            where id = #{id}
+    </update>
+    <!-- 修改字典内容 -->
+    <update id="updateDictionary">
+        update ${tableName}
+        <set>
+            <if test="materialId != null and materialId != ''">
+                material_id = #{materialId},
+            </if>
+            <if test="code != null and code != ''">
+                code = #{code},
+            </if>
+            <if test="name != null and name != ''">
+                name = #{name},
+            </if>
+            <if test="tldId != null and tldId != ''">
+                tld_id = #{tldId},
+            </if>
+        </set>
+        where id = #{id}
+    </update>
+    <!-- 删除字典内容 -->
+    <delete id="deleteDictionary">
+        delete from ${tableName} where id = #{id}
+    </delete>
 </mapper>

+ 2 - 2
src/main/resources/mapper/GoodsMapper.xml

@@ -28,7 +28,7 @@
             b.name as userDepartmentName,
             c.storage_location_name as storageLocationName
         from tld_goods a
-        left join tld_department b on a.user_department = b.id
+        left join tld_department b on a.user_department = b.code
         left join tld_storage_location c on a.storage_location = c.id
         <trim prefix="WHERE" prefixOverrides="and |or">
             <if test="itemNumber != null and itemNumber != ''">
@@ -121,7 +121,7 @@
             a.packing_type,
             a.unit
         from tld_goods a
-        left join tld_department b on a.user_department = b.id
+        left join tld_department b on a.user_department = b.code
         left join tld_storage_location c on a.storage_location = c.id
         <trim prefix="WHERE" prefixOverrides="and |or">
             <if test="itemNumber != null and itemNumber != ''">

+ 4 - 4
src/main/resources/mapper/InviteMapper.xml

@@ -50,7 +50,7 @@
         FROM
             tld_invite a
             JOIN tld_invite_f b ON a.ask_goods_id = b.ask_goods_id
-            LEFT JOIN tld_department c ON b.department = c.CODE
+            LEFT JOIN tld_department c ON b.department = c.code
             JOIN tld_material e ON a.material_id = e.tld_id
         WHERE
                 ( a.num + 0 ) <![CDATA[>]]> (
@@ -71,7 +71,7 @@
         FROM
             tld_invite a
             JOIN tld_invite_f b ON a.ask_goods_id = b.ask_goods_id
-            LEFT JOIN tld_department c ON b.department = c.CODE
+            LEFT JOIN tld_department c ON b.department = c.code
             JOIN tld_material e ON a.material_id = e.tld_id
         WHERE
                 ( a.num + 0 ) <![CDATA[>]]> (
@@ -371,7 +371,7 @@
         from tld_removal a
         left join tld_material b on a.wllb_code = b.code
         left join tld_user c on a.user_id = c.id
-        left join tld_department e on a.department = e.tld_id
+        left join tld_department e on a.department = e.code
         left join tld_storage_location g on a.storage_location_code = g.storage_location_code
         left join tld_customer h on a.supplier_id = h.code
         <trim prefix="WHERE" prefixOverrides="and |or">
@@ -404,7 +404,7 @@
         from tld_removal a
         left join tld_material b on a.wllb_code = b.code
         left join tld_user c on a.user_id = c.id
-        left join tld_department e on a.department = e.tld_id
+        left join tld_department e on a.department = e.code
         left join tld_storage_location g on a.storage_location_code = g.storage_location_code
         left join tld_customer h on a.supplier_id = h.code
         <trim prefix="WHERE" prefixOverrides="and |or">

+ 2 - 2
src/main/resources/mapper/UserMapper.xml

@@ -45,7 +45,7 @@
         from tld_user a
         left join tld_user f on a.modify_user = f.id
         left join tld_role b on a.role = b.id
-        left join tld_department c on a.department = c.tld_id
+        left join tld_department c on a.department = c.code
         <trim prefix="WHERE" prefixOverrides="and |or">
             <if test="code != null and code != ''">
                 and a.code like CONCAT(CONCAT('%', #{code}), '%')
@@ -126,7 +126,7 @@
             a.create_time
         from tld_user a
         left join tld_role b on a.role = b.id
-        left join tld_department c on a.department = c.tld_id
+        left join tld_department c on a.department = c.code
         <trim prefix="WHERE" prefixOverrides="and |or">
             <if test="code != null and code != ''">
                 and a.code like CONCAT(CONCAT('%', #{code}), '%')

+ 2 - 2
src/main/resources/mapper/WarehousingMapper.xml

@@ -197,7 +197,7 @@
         from tld_storage a
         left join tld_material b on a.wllb_code = b.code
         left join tld_user c on a.user_id = c.id
-        left join tld_department e on a.department_id = e.tld_id
+        left join tld_department e on a.department_id = e.code
         left join tld_storage_location g on a.storage_location_code = g.storage_location_code
         left join tld_customer h on a.supplier_id = h.code
         <trim prefix="WHERE" prefixOverrides="and |or">
@@ -251,7 +251,7 @@
         from tld_storage a
         left join tld_material b on a.wllb_code = b.code
         left join tld_user c on a.user_id = c.id
-        left join tld_department e on a.department_id = e.tld_id
+        left join tld_department e on a.department_id = e.code
         left join tld_storage_location g on a.storage_location_code = g.storage_location_code
         left join tld_customer h on a.supplier_id = h.code
         <trim prefix="WHERE" prefixOverrides="and |or">