Parcourir la source

景聚庭-商品管理新版细节完善

huangguoce il y a 1 semaine
Parent
commit
dbc325c4df

+ 2 - 1
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/collect/mapper/xml/PsiCollectBasicMapper.xml

@@ -34,7 +34,7 @@
 			a.handled_by,
 			a.handled_by_office,
 			a.collect_date,
-			b.goods_name,
+			c.name as goods_name,
 			b.id as detail_id,
 			so.name as handledByOfficeName,
 			su.name as handledByName,
@@ -49,6 +49,7 @@
 			left join sys_user su on a.handled_by = su.id
 			left join sys_office so on a.handled_by_office = so.id
 			left join psi_management_collect_detailed b on a.id = b.basic_id and b.del_flag = '0'
+			left join psi_management_type c on b.collect_type = c.id
 			left join act_ru_task art ON a.proc_ins_id = art.PROC_INST_ID_
 			left join psi_management_collect_basics_return returna on returna.basic_id = a.id and returna.del_flag = '0'
 			left join act_ru_task art_r ON returna.proc_ins_id = art_r.PROC_INST_ID_

+ 8 - 10
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/collect/mapper/xml/PsiCollectDetailedMapper.xml

@@ -32,8 +32,7 @@
              LEFT JOIN (
                 SELECT
                     sum( collect_number ) AS collect_number,
-                    goods_name,
-                STATUS
+                    collect_type
                 FROM
                     psi_management_collect_detailed e
                     LEFT JOIN psi_management_collect_basics f ON e.basic_id = f.id
@@ -42,26 +41,25 @@
                     f.`status` = 5
                     AND e.del_flag = 0
                 GROUP BY
-                    e.goods_name
-                ) b ON a.goods_name = b.goods_name
+                    e.collect_type
+                ) b ON a.collect_type =  b.collect_type
 
              LEFT JOIN (
                  SELECT
                      sum( current_inventory ) AS current_inventory,
-                     trade_name
+                     ware_house_type
                  FROM
                      psi_management_warehouse_detailed e
                  WHERE  e.del_flag = 0
-                 GROUP BY
-                     e.trade_name
-             ) wd ON a.goods_name = wd.trade_name
+                 GROUP BY e.ware_house_type
+             ) wd ON a.collect_type = wd.ware_house_type
 
-             LEFT JOIN psi_management_warehouse_detailed c on a.goods_name = c.trade_name and a.collect_type = c.ware_house_type
+             LEFT JOIN psi_management_warehouse_detailed c on a.collect_type = c.ware_house_type
              LEFT JOIN psi_management_warehouse_basics bas ON c.basic_id = bas.id
 
              LEFT JOIN psi_management_type d ON a.collect_type = d.id
              WHERE a.basic_id = #{id} AND a.del_flag = '0' and c.del_flag = '0' AND ( bas.`status` = '0' OR bas.`status` = '5')
-             group by a.goods_name;
+             group by a.id;
     </select>
     <select id="getRecordsByBasicId" resultType="com.jeeplus.psimanage.collect.domain.PsiCollectDetailedRecord">
         select

+ 1 - 1
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/collect/service/PsiCollectService.java

@@ -864,7 +864,7 @@ public class PsiCollectService {
             queryWrapper.like("a.collect_no", dto.getCollectNo());
         }
         if (StringUtils.isNotEmpty(dto.getGoodsName())) {
-            queryWrapper.like("b.goods_name", dto.getGoodsName());
+            queryWrapper.like("c.name", dto.getGoodsName());
         }
         if (StringUtils.isNotEmpty(dto.getHandledBy())) {
             queryWrapper.eq("su.id", dto.getHandledBy());

+ 0 - 8
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/materialType/mapper/PsiMaterialTypeMapper.java

@@ -29,14 +29,6 @@ public interface PsiMaterialTypeMapper extends BaseMapper<PsiMaterialTypeInfo>,
      * @return
      */
     PsiMaterialTypeInfo getById(String id);
-    /**
-     * 根据name和parentId查询名称是否重复
-     * @param name
-     * @param parentId
-     * @return
-     */
-    Integer checkNameIsExist(@Param("name") String name, @Param("parentId") String parentId);
-
     Integer getNo(@Param("parentId") String parentId);
 
     Integer getLevel(@Param("parentId") String parentId);

+ 0 - 10
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/materialType/mapper/xml/PsiMaterialTypeMapper.xml

@@ -68,16 +68,6 @@
 		</where>
 	</select>
 
-	<select id="checkNameIsExist" resultType="java.lang.Integer">
-        SELECT
-			COUNT( 0 )
-		FROM
-			psi_management_type
-		WHERE
-			del_flag = 0
-			AND `name` = #{name}
-			AND parent_id = #{parentId}
-    </select>
     <select id="getNo" resultType="java.lang.Integer">
         SELECT
 			(MAX(`sort`) + 1) AS `sort`

+ 2 - 8
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/materialType/service/PsiMaterialTypeService.java

@@ -198,13 +198,7 @@ public class PsiMaterialTypeService extends ServiceImpl<PsiMaterialTypeMapper, P
      */
     public String add(PsiMaterialTypeInfo info) {
         if (!prepareMaterialTypeInfo(info)) {
-            return "false";
-        }
-
-        // 判断名称是否已存在
-        Integer isExist = mapper.checkNameIsExist(info.getName(), info.getParentId());
-        if (isExist > 0) {
-            return "false";
+            return "商品节点下不能新增下级";
         }
         // 获取当前登录人信息
         UserDTO userDto = SpringUtil.getBean ( IUserApi.class ).getByToken(TokenProvider.getCurrentToken ( ));
@@ -233,7 +227,7 @@ public class PsiMaterialTypeService extends ServiceImpl<PsiMaterialTypeMapper, P
         // 获取当前登录人信息
 //        UserDTO userDto = UserUtils.getCurrentUserDTO();
         if (!prepareMaterialTypeInfo(info)) {
-            return "false";
+            return "商品节点下不能新增下级";
         }
         info.setUpdateBy(userDto.getId());
         info.setUpdateDate(new Date());

+ 109 - 100
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/psiWareHouse/mapper/xml/PsiWareHouseBasicMapper.xml

@@ -37,10 +37,10 @@
 				a.create_by_id as createBy,
 				a.create_time as createDate,
 				a.ware_house_type,
-				a.trade_name,
-				a.brand,
-				a.specification,
-				a.company,
+				c.name as trade_name,
+				c.brand,
+				c.specification,
+				c.company,
 				b.NAME AS wareHouseTypeName,
 				sum( trade_number ) AS allNumber,
 				b.collect_number AS borrowNumber,
@@ -50,25 +50,32 @@
 				psi_management_warehouse_detailed a
 				LEFT JOIN (
 				SELECT
-					sum( g.collect_number ) AS collect_number,
-					e.goods_name,
+					sum(
+						CASE
+							WHEN r.status = '5' AND d.id IS NULL THEN IFNULL(e.not_surplus_stock, 0)
+							WHEN r.status = '5' AND d.is_return = '2' THEN IFNULL(e.not_surplus_stock, e.collect_number)
+							WHEN r.status = '5' AND d.is_return = '1' THEN 0
+							ELSE IFNULL(e.not_surplus_stock, e.collect_number)
+						END
+					) AS collect_number,
+					e.collect_type,
 					c.NAME as name,
-					e.basic_id as mmcId,
-				STATUS
+					min(e.basic_id) as mmcId
 				FROM
-					psi_management_collect_detailed e
+					psi_management_collect_detailed_record e
 					LEFT JOIN psi_management_collect_basics f ON e.basic_id = f.id
 					AND f.del_flag = 0
+					LEFT JOIN psi_management_collect_detailed d ON e.detail_id = d.id
+					LEFT JOIN psi_management_collect_basics_return r ON r.basic_id = e.basic_id AND r.del_flag = 0
 					LEFT JOIN psi_management_type c ON e.collect_type = c.id
-					left join psi_management_collect_detailed g on e.goods_name = g.goods_name and g.del_flag = 0
 				WHERE
 					f.`status` = 5 AND e.del_flag = 0
 				GROUP BY
-					e.id
-				) b ON a.trade_name = b.goods_name
+					e.collect_type, c.NAME
+				) b ON a.ware_house_type = b.collect_type
 				LEFT JOIN psi_management_type c ON a.ware_house_type = c.id
 				${ew.customSqlSegment}
-				GROUP BY a.trade_name,a.ware_house_type
+				GROUP BY a.ware_house_type
 				HAVING sum( trade_number ) - IFNULL(collect_number,0) &lt;= 5
 				ORDER BY a.update_time DESC
 	</select>
@@ -79,10 +86,10 @@
 			a.create_by_id as createBy,
 			a.create_time as createDate,
 			a.ware_house_type,
-			a.trade_name,
-			a.brand,
-			a.specification,
-			a.company,
+			c.name as trade_name,
+			c.brand,
+			c.specification,
+			c.company,
 			c.name as wareHouseTypeName,
 			sum( trade_number ) AS allNumber,
 			b.collect_number AS borrowNumber,
@@ -101,45 +108,50 @@
 			left join
 			(
 			select
-			    sum(collect_number) as collect_number,
-			    goods_name,
-			    status
-			 from psi_management_collect_detailed e
+			    sum(
+					CASE
+						WHEN r.status = '5' AND d.id IS NULL THEN IFNULL(e.not_surplus_stock, 0)
+						WHEN r.status = '5' AND d.is_return = '2' THEN IFNULL(e.not_surplus_stock, e.collect_number)
+						WHEN r.status = '5' AND d.is_return = '1' THEN 0
+						ELSE IFNULL(e.not_surplus_stock, e.collect_number)
+					END
+				) as collect_number,
+			    e.collect_type
+			 from psi_management_collect_detailed_record e
 			left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
-			WHERE f.`status` = 5 and e.del_flag = 0 and e.is_return = '0'
-			GROUP BY e.goods_name
+			left join psi_management_collect_detailed d on e.detail_id = d.id
+			left join psi_management_collect_basics_return r on r.basic_id = e.basic_id and r.del_flag = 0
+			WHERE f.`status` = 5 and e.del_flag = 0
+			GROUP BY e.collect_type
 			) b
-			on a.trade_name = b.goods_name
+			on a.ware_house_type = b.collect_type
 			left join
 			(
 				select
 					sum(loss_number) as loss_number,
-					goods_name,
-					status
+					collect_type
 				from psi_management_loss_detailed e
 						 left join psi_management_loss_basics f on e.basic_id = f.id and f.del_flag = 0
 				WHERE f.`status` = 5 and e.del_flag = 0
-				GROUP BY e.goods_name
+				GROUP BY e.collect_type
 			) loss
-			on a.trade_name = loss.goods_name
+			on a.ware_house_type = loss.collect_type
 			left join
 			(
 				select
 					sum(returned_num) AS returned_num,
 					sum(not_surplus_stock) AS not_surplus_stock,
-					inventory_id,
-					goods_name,
-					status
+					collect_type
 				from psi_management_collect_detailed_record e
 						 left join psi_management_collect_basics pmcba on e.basic_id = pmcba.id and pmcba.del_flag = 0
 				WHERE pmcba.`status` = 5 and e.del_flag = 0
-				group BY e.goods_name
+				group BY e.collect_type
 			) pmcdra
-			on a.trade_name = pmcdra.goods_name
+			on a.ware_house_type = pmcdra.collect_type
 			LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
 			left join psi_management_type c on a.ware_house_type = c.id
 			${ew.customSqlSegment}
-			GROUP BY a.trade_name,a.ware_house_type
+			GROUP BY a.ware_house_type
 			ORDER BY a.ware_house_type DESC,a.trade_name
 	</select>
 
@@ -150,8 +162,8 @@
 			a.create_by_id as createBy,
 			a.create_time as createDate,
 			a.ware_house_type,
-			a.trade_name,
-			a.company,
+			c.name as trade_name,
+			c.company,
 			c.name as wareHouseTypeName,
 			IFNULL(his_detail.trade_number,0)  AS allNumber,
 			b.collect_number AS borrowNumber,
@@ -174,28 +186,32 @@
 				left join
 			(
 				select
-					sum(collect_number) as collect_number,
-					goods_name,
-					collect_type,
-					status
-				from psi_management_collect_detailed e
+					sum(
+						CASE
+							WHEN r.status = '5' AND d.id IS NULL THEN IFNULL(e.not_surplus_stock, 0)
+							WHEN r.status = '5' AND d.is_return = '2' THEN IFNULL(e.not_surplus_stock, e.collect_number)
+							WHEN r.status = '5' AND d.is_return = '1' THEN 0
+							ELSE IFNULL(e.not_surplus_stock, e.collect_number)
+						END
+					) as collect_number,
+					e.collect_type
+				from psi_management_collect_detailed_record e
 						 left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
+						 left join psi_management_collect_detailed d on e.detail_id = d.id
+						 left join psi_management_collect_basics_return r on r.basic_id = e.basic_id and r.del_flag = 0
 				WHERE f.`status` = 5
 				  and e.del_flag = 0
-				  and e.is_return = '0'
 				<if test="dto != null and dto.dateRange != null and dto.dateRange.length == 2">
 					and f.collect_date &gt;= #{dto.dateRange[0]} AND f.collect_date &lt;= #{dto.dateRange[1]}
 				</if>
-				GROUP BY e.goods_name, e.collect_type
+				GROUP BY e.collect_type
 			) b
-			on a.trade_name = b.goods_name AND a.ware_house_type = b.collect_type
+			on a.ware_house_type = b.collect_type
 				left join
 			(
 				select
 					sum(loss_number) as loss_number,
-					goods_name,
-					collect_type,
-					status
+					collect_type
 				from psi_management_loss_detailed e
 						 left join psi_management_loss_basics f on e.basic_id = f.id and f.del_flag = 0
 				WHERE f.`status` = 5
@@ -203,15 +219,13 @@
 				<if test="dto != null and dto.dateRange != null and dto.dateRange.length == 2">
 					and f.collect_date &gt;= #{dto.dateRange[0]} AND f.collect_date &lt;= #{dto.dateRange[1]}
 				</if>
-				GROUP BY e.goods_name, e.collect_type
+				GROUP BY e.collect_type
 			) loss
-			on a.trade_name = loss.goods_name AND a.ware_house_type = loss.collect_type
+			on a.ware_house_type = loss.collect_type
 			left join(
 				select
 				sum(loss_number) as loss_number,
-				goods_name,
-				collect_type,
-				status
+				collect_type
 				from psi_management_loss_detailed e
 				left join psi_management_loss_basics f on e.basic_id = f.id and f.del_flag = 0
 				WHERE f.`status` = 5
@@ -219,15 +233,14 @@
 				<if test="dto != null and dto.dateRange != null and dto.dateRange.length == 2">
 				and f.collect_date  &gt;= #{dto.dateRange[1]}
 				</if>
-				GROUP BY e.goods_name, e.collect_type
+				GROUP BY e.collect_type
 			) loss_after
-			on a.trade_name = loss_after.goods_name AND a.ware_house_type = loss_after.collect_type
+			on a.ware_house_type = loss_after.collect_type
 				left join
 			(
 				select
 					sum(returned_num) AS returned_num,
 					sum(not_surplus_stock) AS not_surplus_stock,
-					goods_name,
 					collect_type
 				from psi_management_collect_detailed_record e
 						 left join psi_management_collect_basics pmcba on e.basic_id = pmcba.id and pmcba.del_flag = 0
@@ -236,14 +249,13 @@
 				<if test=" dto != null and dto.dateRange != null and dto.dateRange.length == 2">
 					and pmcba.collect_date &gt;= #{dto.dateRange[0]} AND pmcba.collect_date &lt;= #{dto.dateRange[1]}
 				</if>
-				group BY e.goods_name, e.collect_type
+				group BY e.collect_type
 			) pmcdra
-			on a.trade_name = pmcdra.goods_name AND a.ware_house_type = pmcdra.collect_type
+			on a.ware_house_type = pmcdra.collect_type
 		LEFT JOIN (
 				select
 					sum(returned_num) AS returned_num,
 					sum(not_surplus_stock) AS not_surplus_stock,
-					goods_name,
 					collect_type
 				from psi_management_collect_detailed_record e
 					left join psi_management_collect_basics pmcba on e.basic_id = pmcba.id and pmcba.del_flag = 0
@@ -252,21 +264,19 @@
 				<if test=" dto != null and dto.dateRange != null and dto.dateRange.length == 2">
 					and pmcba.collect_date &gt;= #{dto.dateRange[1]}
 				</if>
-				group BY e.goods_name, e.collect_type
+				group BY e.collect_type
 			) after_pmcdra
-		on a.trade_name = after_pmcdra.goods_name AND a.ware_house_type = after_pmcdra.collect_type
+		on a.ware_house_type = after_pmcdra.collect_type
 			LEFT JOIN (
 				SELECT
-				trade_name,
 				ware_house_type,
 				SUM(current_inventory) AS allCurrentInventory
 				FROM psi_management_warehouse_detailed
 				WHERE del_flag = 0
-				GROUP BY trade_name, ware_house_type
-			) all_stock ON a.trade_name = all_stock.trade_name AND a.ware_house_type = all_stock.ware_house_type
+				GROUP BY ware_house_type
+			) all_stock ON a.ware_house_type = all_stock.ware_house_type
 			LEFT JOIN (
 				SELECT
-					pwd.trade_name,
 					pwd.ware_house_type,
 					SUM(pwd.trade_number) AS trade_number
 				FROM psi_management_warehouse_detailed pwd
@@ -275,11 +285,10 @@
 					<if test=" dto != null and dto.dateRange != null and dto.dateRange.length == 2">
 						and pmcba.ware_house_date &gt;= #{dto.dateRange[0]} AND pmcba.ware_house_date &lt;= #{dto.dateRange[1]}
 					</if>
-					GROUP BY pwd.trade_name, pwd.ware_house_type
-			) his_detail ON a.trade_name = his_detail.trade_name AND a.ware_house_type = his_detail.ware_house_type
+					GROUP BY pwd.ware_house_type
+			) his_detail ON a.ware_house_type = his_detail.ware_house_type
 			LEFT JOIN (
 				SELECT
-					ab.trade_name,
 					ab.ware_house_type,
 					SUM(ab.trade_number) AS trade_number
 				FROM psi_management_warehouse_detailed ab
@@ -288,12 +297,12 @@
 				<if test="dto != null and dto.dateRange != null and dto.dateRange.length == 2">
 					and pmcba.ware_house_date  &gt;= #{dto.dateRange[1]}
 				</if>
-				GROUP BY ab.trade_name, ab.ware_house_type
-			) after_pmwd ON a.trade_name = after_pmwd.trade_name AND a.ware_house_type = after_pmwd.ware_house_type
+				GROUP BY ab.ware_house_type
+			) after_pmwd ON a.ware_house_type = after_pmwd.ware_house_type
 				LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
 				left join psi_management_type c on a.ware_house_type = c.id
 			${ew.customSqlSegment}
-		GROUP BY a.trade_name,a.ware_house_type
+		GROUP BY a.ware_house_type
 		ORDER BY a.ware_house_type DESC,a.trade_name
 	</select>
 
@@ -305,7 +314,7 @@
 			a.create_by_id as createBy,
 			a.create_time as createDate,
 			a.ware_house_type,
-			a.trade_name,
+			c.name as trade_name,
 			a.company,
 			c.name as wareHouseTypeName,
 			sum( trade_number ) AS allNumber,
@@ -323,18 +332,17 @@
 			(
 				select
 					sum(collect_number) as collect_number,
-					goods_name,
-					status
+					collect_type
 				from psi_management_collect_detailed e
 						 left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
 				WHERE f.`status` = 5 and e.del_flag = 0
-				GROUP BY e.goods_name
+				GROUP BY e.collect_type
 			) b
-			on a.trade_name = b.goods_name
+			on a.ware_house_type = b.collect_type
 				LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
 				left join psi_management_type c on a.ware_house_type = c.id
 			${ew.customSqlSegment}
-		GROUP BY a.trade_name,a.ware_house_type
+		GROUP BY a.ware_house_type
 		ORDER BY a.ware_house_type DESC,a.trade_name
 	</select>
 
@@ -344,7 +352,7 @@
 			a.id,
 			a.produce_date as produce_date,
 			a.ware_house_type,
-			a.trade_name,
+			c.name as trade_name,
 			a.spec,
 			a.specification,
 			a.company,
@@ -368,7 +376,7 @@
 		SELECT
 			a.id,
 			a.produce_date as produce_date,
-			a.trade_name,
+			c.name as trade_name,
 			a.spec,
 			a.company,
 			a.current_inventory,
@@ -383,7 +391,7 @@
 				left join psi_management_type c on a.ware_house_type = c.id
 			${ew.customSqlSegment}
 
-		GROUP BY a.trade_name,a.ware_house_type,a.produce_date
+		GROUP BY a.ware_house_type,a.produce_date
 		ORDER BY a.produce_date asc
 	</select>
 
@@ -442,7 +450,6 @@
 			sy.name as collectHandleBy,
 			so.name as collectHandleByOff,
 			a.collect_date,
-			b.goods_name,
 			b.collect_number,
 			b.current_inventory,
 			pmwd.spec,
@@ -472,23 +479,23 @@
 			c.name as wareHouseTypeName,
 			sum(trade_number) as allNumber,
 			b.collect_number as borrowNumber,
-			a.current_inventory as tradeNumber,
+			sum(a.current_inventory) as tradeNumber,
 			a.warn_num,
 			a.warn_flag
 		FROM
 			psi_management_warehouse_detailed a
 			left join
-			(select sum(collect_number) as collect_number,goods_name,status from psi_management_collect_detailed e
+			(select sum(collect_number) as collect_number,collect_type from psi_management_collect_detailed e
 			left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
 			WHERE f.`status` = 5 and e.collect_type = #{collectTypeId}
-			GROUP BY e.goods_name) b
-			on a.trade_name = b.goods_name
+			GROUP BY e.collect_type) b
+			on a.ware_house_type = b.collect_type
 			LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
 			left join psi_management_type c on a.ware_house_type = c.id
 			where a.trade_name = #{goodsName}
 			  and a.ware_house_type = #{collectTypeId}
 			  and a.del_flag = 0
-			GROUP BY a.trade_name
+			GROUP BY a.ware_house_type
 			ORDER BY a.update_time DESC
 	</select>
 	<select id="getByTypeAndGoodsNameByProduceDate"
@@ -507,11 +514,11 @@
 		FROM
 			psi_management_warehouse_detailed a
 				left join
-			(select sum(collect_number) as collect_number,goods_name,status from psi_management_collect_detailed e
+			(select sum(collect_number) as collect_number,collect_type from psi_management_collect_detailed e
 																					 left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
 			 WHERE f.`status` = 5 and e.collect_type = #{collectTypeId}
-			 GROUP BY e.goods_name) b
-			on a.trade_name = b.goods_name
+			 GROUP BY e.collect_type) b
+			on a.ware_house_type = b.collect_type
 
 				LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
 				left join psi_management_type c on a.ware_house_type = c.id
@@ -519,7 +526,7 @@
 		  and a.ware_house_type = #{collectTypeId}
 		  and a.produce_date = #{produceDate}
 		  and a.del_flag = 0
-		GROUP BY a.trade_name
+		GROUP BY a.ware_house_type,a.produce_date
 		ORDER BY a.produce_date asc
 	</select>
 
@@ -538,11 +545,11 @@
 		FROM
 			psi_management_warehouse_detailed a
 				left join
-			(select sum(collect_number) as collect_number,goods_name,status from psi_management_collect_detailed e
+			(select sum(collect_number) as collect_number,collect_type from psi_management_collect_detailed e
 																					 left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
 			 WHERE f.`status` = 5 and e.collect_type = #{collectTypeId}
-			 GROUP BY e.goods_name) b
-			on a.trade_name = b.goods_name
+			 GROUP BY e.collect_type) b
+			on a.ware_house_type = b.collect_type
 				LEFT JOIN psi_management_warehouse_basics bas on a.basic_id = bas.id
 				left join psi_management_type c on a.ware_house_type = c.id
 		where a.trade_name = #{goodsName}
@@ -575,16 +582,17 @@
 		left join psi_management_type c on a.ware_house_type = c.id
 
 		left join
-		(select sum(collect_number) as collect_number,goods_name,status from psi_management_collect_detailed e
+		(select sum(collect_number) as collect_number,collect_type from psi_management_collect_detailed e
 		left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
-		WHERE f.`status` = 5 and e.del_flag = 0 and e.produce_date &lt;= #{produceDate} and e.collect_type = #{wareHouseType} and e.goods_name = #{tradeName}) b
-		on a.trade_name = b.goods_name
+		WHERE f.`status` = 5 and e.del_flag = 0 and e.produce_date &lt;= #{produceDate} and e.collect_type = #{wareHouseType} and e.goods_name = #{tradeName}
+		GROUP BY e.collect_type) b
+		on a.ware_house_type = b.collect_type
 
 		WHERE a.ware_house_type = #{wareHouseType}
 		and a.del_flag = 0
 		and a.trade_name = #{tradeName}
 		and a.produce_date &lt;= #{produceDate}
-		GROUP BY a.trade_name,a.ware_house_type
+		GROUP BY a.ware_house_type
 		ORDER BY a.ware_house_type DESC
 	</select>
 	<select id="getCollectInfoByTime" resultType="java.lang.String">
@@ -595,16 +603,17 @@
 		left join psi_management_type c on a.ware_house_type = c.id
 
 		left join
-		(select sum(collect_number) as collect_number,goods_name,status from psi_management_collect_detailed e
+		(select sum(collect_number) as collect_number,collect_type from psi_management_collect_detailed e
 		left join psi_management_collect_basics f on e.basic_id = f.id and f.del_flag = 0
-		WHERE f.`status` = 5 and e.del_flag = 0 and e.create_time &lt;= #{createDate} and e.collect_type = #{wareHouseType} and e.goods_name = #{tradeName}) b
-		on a.trade_name = b.goods_name
+		WHERE f.`status` = 5 and e.del_flag = 0 and e.create_time &lt;= #{createDate} and e.collect_type = #{wareHouseType} and e.goods_name = #{tradeName}
+		GROUP BY e.collect_type) b
+		on a.ware_house_type = b.collect_type
 
 		WHERE a.ware_house_type = #{wareHouseType}
 		and a.del_flag = 0
 		and a.trade_name = #{tradeName}
 		and a.create_time &lt;= #{createDate}
-		GROUP BY a.trade_name,a.ware_house_type
+		GROUP BY a.ware_house_type
 		ORDER BY a.ware_house_type DESC
 	</select>
 	<select id="getCollectNumByType" resultType="java.lang.String">

+ 6 - 6
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/psiWareHouse/mapper/xml/PsiWareHouseSummaryMapper.xml

@@ -13,8 +13,7 @@
             LEFT JOIN (
             SELECT
                 sum( b.collect_number ) AS num2,
-                b.collect_type,
-                b.goods_name
+                b.collect_type
             FROM
                 psi_management_collect_detailed b
                 LEFT JOIN psi_management_collect_basics c ON b.basic_id = c.id
@@ -25,8 +24,9 @@
 
             AND b.del_flag = 0
             AND c.`status` = 5
+            GROUP BY b.collect_type
             ) AS c ON a.ware_house_type = c.collect_type
-            AND a.trade_name = c.goods_name
+
         WHERE
             a.ware_house_type = #{wareHouseType}
             AND a.trade_name = #{tradeName}
@@ -54,7 +54,7 @@
             -- 只查当前批次、当前生产日期对应的领用数量
                 LEFT JOIN (
                 SELECT
-                    b.goods_name,
+                    b.collect_type,
                     b.produce_date,  -- 必须加上生产日期
                     sum(b.collect_number) AS num2
                 FROM
@@ -67,9 +67,9 @@
                   AND b.del_flag = 0
                   AND c.`status` = 5
                 -- 按商品  生产日期分组
-                GROUP BY b.goods_name, b.produce_date
+                GROUP BY b.collect_type, b.produce_date
             ) c
-                          ON a.trade_name = c.goods_name
+                          ON a.ware_house_type = c.collect_type
                               AND a.produce_date = c.produce_date  -- 关键:按生产日期匹配
         WHERE
             a.ware_house_type = #{wareHouseType}

+ 6 - 6
jeeplus-modules/jeeplus-psi-management/src/main/java/com/jeeplus/psimanage/psiWareHouse/service/PsiWareHouseBasicService.java

@@ -967,7 +967,7 @@ public class PsiWareHouseBasicService {
 //            queryWrapper.like("c.ware_house_number", dto.getWareHouseNumber());
 //        }
         if (StringUtils.isNotEmpty(dto.getTradeName())) {
-            queryWrapper.like("a.trade_name", dto.getTradeName());
+            queryWrapper.like("c.name", dto.getTradeName());
         }
         if (StringUtils.isNotEmpty(dto.getBasicId())) {
             queryWrapper.eq("b.mmcId", dto.getBasicId());
@@ -1010,7 +1010,7 @@ public class PsiWareHouseBasicService {
 //            queryWrapper.like("c.ware_house_number", dto.getWareHouseNumber());
 //        }
         if (StringUtils.isNotEmpty(dto.getTradeName())) {
-            queryWrapper.like("a.trade_name", dto.getTradeName());
+            queryWrapper.like("c.name", dto.getTradeName());
         }
         queryWrapper.and(wq ->{
             wq.eq("bas.`status`","0")
@@ -1089,7 +1089,7 @@ public class PsiWareHouseBasicService {
 
         queryWrapper.eq("a.del_flag", "0");
         if (StringUtils.isNotEmpty(dto.getTradeName())) {
-            queryWrapper.like("a.trade_name", dto.getTradeName());
+            queryWrapper.like("c.name", dto.getTradeName());
         }
         queryWrapper.and(wq ->{
             wq.eq("bas.`status`","0")
@@ -1260,7 +1260,7 @@ public class PsiWareHouseBasicService {
         queryWrapper.eq("a.del_flag", "0");
 
         if (StringUtils.isNotEmpty(dto.getTradeName())) {
-            queryWrapper.like("a.trade_name", dto.getTradeName());
+            queryWrapper.like("c.name", dto.getTradeName());
         }
         queryWrapper.and(wq ->{
             wq.eq("bas.`status`","0")
@@ -1455,7 +1455,7 @@ public class PsiWareHouseBasicService {
         queryWrapper.eq("a.del_flag", "0");
 
         if (StringUtils.isNotEmpty(dto.getTradeName())) {
-            queryWrapper.like("a.trade_name", dto.getTradeName());
+            queryWrapper.like("c.name", dto.getTradeName());
         }
         queryWrapper.and(wq ->{
             wq.eq("bas.`status`","0")
@@ -1520,7 +1520,7 @@ public class PsiWareHouseBasicService {
         queryWrapper.eq("a.del_flag", "0");
 
         if (StringUtils.isNotEmpty(dto.getTradeName())) {
-            queryWrapper.like("a.trade_name", dto.getTradeName());
+            queryWrapper.like("c.name", dto.getTradeName());
         }
         queryWrapper.and(wq ->{
             wq.eq("bas.`status`","0")