Jelajahi Sumber

问题修改

zhs 2 tahun lalu
induk
melakukan
a6e63887e5

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

@@ -27,4 +27,6 @@ public interface DictionaryMapper {
     Dictionary getWarehouseInfo(WarehouseTransfer warehouseTransfer);
 
     int getInventorySumAmount(Dictionary dictionary1);
+
+    List<Dictionary> getDictionaryMaterialPage(Dictionary dictionary);
 }

+ 5 - 2
src/main/java/com/tld/service/impl/DictionaryServiceImpl.java

@@ -76,16 +76,19 @@ public class DictionaryServiceImpl implements DictionaryService {
             String tableName = dictionaryMapper.getTableName(dictionary.getType());
             dictionary.setTableName(tableName);
             PageHelper.startPage(dictionary.getPage(), dictionary.getLimit());
-            PageInfo<Dictionary> list = new PageInfo<>(dictionaryMapper.getDictionaryPage(dictionary));
+            PageInfo<Dictionary> list = null;
             if(dictionary.getType().equals("物料字典")){
+                list = new PageInfo<>(dictionaryMapper.getDictionaryMaterialPage(dictionary));
                 for(Dictionary dictionary1 : list.getList()){
                     int amount = dictionaryMapper.getInventorySumAmount(dictionary1);
                     amountMap.put(dictionary1.getTldId(), amount);
                 }
+                map.put("amount", amountMap);
+            } else {
+                list = new PageInfo<>(dictionaryMapper.getDictionaryPage(dictionary));
             }
             map.put("msg", "200");
             map.put("data", list);
-            map.put("amount", amountMap);
         }  catch (Exception e){
             e.printStackTrace();
             map.put("msg", "500");

+ 24 - 7
src/main/resources/mapper/DictionaryMapper.xml

@@ -34,19 +34,17 @@
     <!-- 查询字典内容分页 -->
     <select id="getDictionaryPage" resultType="com.tld.model.Dictionary">
         select
-               a.*,b.name as materialType,c.user_name as modifyUser
-        from ${tableName} a
-        left join tld_material_type b on a.wllb_class = b.tld_id
-        left join tld_user c on a.modify_user = c.id
+               *
+        from ${tableName}
         <trim prefix="WHERE" prefixOverrides="and |or">
             <if test="name != null and name != ''">
-                and a.name = #{name}
+                and name = #{name}
             </if>
             <if test="code != null and code != ''">
-                and a.code = #{code}
+                and code = #{code}
             </if>
             <if test="tldId != null and tldId != ''">
-                and a.tld_id = #{tldId}
+                and tld_id = #{tldId}
             </if>
         </trim>
     </select>
@@ -67,4 +65,23 @@
     <select id="getInventorySumAmount" resultType="int">
         select ifnull(sum(amount), 0) from tld_inventory where material_id = #{tldId}
     </select>
+    <!-- 查询字典内容分页 -->
+    <select id="getDictionaryMaterialPage" resultType="com.tld.model.Dictionary">
+        select
+            a.*,b.name as materialType,c.user_name as modifyUser
+        from ${tableName} a
+        left join tld_material_type b on a.wllb_class = b.tld_id
+        left join tld_user c on a.modify_user = c.id
+        <trim prefix="WHERE" prefixOverrides="and |or">
+            <if test="name != null and name != ''">
+                and a.name = #{name}
+            </if>
+            <if test="code != null and code != ''">
+                and a.code = #{code}
+            </if>
+            <if test="tldId != null and tldId != ''">
+                and a.tld_id = #{tldId}
+            </if>
+        </trim>
+    </select>
 </mapper>