Compare commits

...

3 Commits

Author SHA1 Message Date
furongxin
ca80611f91 Merge branch 'dev' of http://git.znkjfw.com/ak/zn-cloud into frx
# Conflicts:
#	zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/mysql/handlinggroupuseramount/HandlingGroupUserAmountMapper.java
#	zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/handlinggroupuseramount/HandlingGroupUserAmountService.java
#	zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/handlinggroupuseramount/HandlingGroupUserAmountServiceImpl.java
#	zn-module-smartfactory/zn-module-smartfactory-biz/src/main/resources/mapper/handlinggroupuseramount/HandlingGroupUserAmountMapper.xml
2025-05-20 14:32:48 +08:00
aikai
e31365ad90 refactor(smartfactory): 优化搬运组金额规格查询和删除逻辑
- 修改 HandlingGroupAmountSpecificationsController 中的查询逻辑,按搬运组 ID 分组
- 在 HandlingGroupAmountSpecificationsServiceImpl 中实现批量删除功能,同时删除关联的 HandlingGroupUserAmount 记录
- 在 HandlingGroupUserAmountService 接口和实现类中添加按搬运组 ID 查询的方法
- 更新 HandlingGroupUserAmountMapper 和 XML 映射文件,支持按搬运组 ID 查询- 优化 HandlingGroupAmountSpecificationsMapper XML 映射文件中的查询语句,提高查询效率
2025-05-19 16:00:58 +08:00
aikai
bb49e919cb feat(smartfactory): 作为工厂主管查询搬运工时支持多工厂查询
- 在 HandlingGroupAmountSpecificationsTotalNumDTO 和 HandlingGroupAmountSpecificationsPageReqVO 中添加 factoryIds 字段
- 修改 HandlingGroupAmountSpecificationsServiceImpl 中的方法以支持多工厂查询
- 更新 HandlingGroupAmountSpecificationsMapper.xml 中的 SQL 语句以支持多工厂查询
2025-05-19 09:28:40 +08:00
9 changed files with 88 additions and 21 deletions

View File

@ -101,17 +101,17 @@ public class HandlingGroupAmountSpecificationsController {
PageResult<HandlingGroupAmountSpecificationsRespVO> result = BeanUtils.toBean(pageResult, HandlingGroupAmountSpecificationsRespVO.class);
// 计算合计 - 先根据工厂+搬运组+日期进行分组
Map<String, List<HandlingGroupAmountSpecificationsRespVO>> map = result.getList().stream().collect(Collectors.groupingBy(a -> a.getFactoryId() + "_" + a.getHandlingGroupId() + "_" + a.getDateStr()));
List<Long> ids = result.getList().stream().map(HandlingGroupAmountSpecificationsRespVO::getId).collect(Collectors.toList());
List<Long> ids = result.getList().stream().map(HandlingGroupAmountSpecificationsRespVO::getHandlingGroupId).distinct().collect(Collectors.toList());
Map<Long, List<HandlingGroupUserAmountDO>> handlingGroupUserAmountMap = new HashMap<>();
if (CollUtil.isNotEmpty(ids)) {
List<HandlingGroupUserAmountDO> list = handlingGroupUserAmountService.getByHandlingGroupAmountSpecificationsId(ids);
handlingGroupUserAmountMap = list.stream().collect(Collectors.groupingBy(HandlingGroupUserAmountDO::getHandlingGroupAmountSpecificationsId));
List<HandlingGroupUserAmountDO> list = handlingGroupUserAmountService.getByHandlingGroupIds(ids);
handlingGroupUserAmountMap = list.stream().collect(Collectors.groupingBy(HandlingGroupUserAmountDO::getHandlingGroupId));
}
for (HandlingGroupAmountSpecificationsRespVO handlingGroupAmountSpecificationsDO : result.getList()) {
String key = handlingGroupAmountSpecificationsDO.getFactoryId() + "_" + handlingGroupAmountSpecificationsDO.getHandlingGroupId() + "_" + handlingGroupAmountSpecificationsDO.getDateStr();
handlingGroupAmountSpecificationsDO.setTotalAmount(getSumValue(map.get(key), HandlingGroupAmountSpecificationsRespVO::getAmount, BigDecimal::add));
handlingGroupAmountSpecificationsDO.setTotalNum(getSumValue(map.get(key), HandlingGroupAmountSpecificationsRespVO::getTotalCount, Integer::sum));
List<HandlingGroupUserAmountDO> items = handlingGroupUserAmountMap.get(handlingGroupAmountSpecificationsDO.getId());
List<HandlingGroupUserAmountDO> items = handlingGroupUserAmountMap.get(handlingGroupAmountSpecificationsDO.getHandlingGroupId());
if (CollUtil.isNotEmpty(items)) {
List<HandlingGroupUserAmountItemVO> handlingGroupUserAmountItemVOS = BeanUtils.toBean(items, HandlingGroupUserAmountItemVO.class);
handlingGroupAmountSpecificationsDO.setHandlingGroupUserAmountItemVOS(handlingGroupUserAmountItemVOS);

View File

@ -6,6 +6,7 @@ import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import java.util.List;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ -23,4 +24,6 @@ public class HandlingGroupAmountSpecificationsTotalNumDTO {
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "工厂ids")
private List<Long> factoryIds;
}

View File

@ -10,6 +10,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ -47,4 +48,7 @@ public class HandlingGroupAmountSpecificationsPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "工厂ids", example = "23178")
private List<Long> factoryIds;
}

View File

@ -72,6 +72,8 @@ public interface HandlingGroupUserAmountMapper extends BaseMapperX<HandlingGroup
*/
List<HandlingGroupUserAmountDO> getByHandlingGroupAmountSpecificationsId(@Param("handlingGroupAmountSpecificationsIds") List<Long> handlingGroupAmountSpecificationsIds);
List<HandlingGroupUserAmountDO> getByHandlingGroupIds(@Param("handlingGroupIds") List<Long> handlingGroupIds);
List<HandlingGroupUserAmountDO> selectAmountSum(@Param("factoryId") Long factoryId, @Param("month") String month);
Long selectIsExists(@Param("factoryId") Long factoryId, @Param("month") String month);

View File

@ -1,13 +1,16 @@
package cn.iocoder.yudao.module.smartfactory.service.handlinggroupamountspecifications;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroup.vo.HandlingGroupListVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.dto.HandlingGroupAmountSpecificationsTotalNumDTO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo.*;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsDO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupuseramount.HandlingGroupUserAmountDO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlingspecifications.HandlingSpecificationsDO;
import cn.iocoder.yudao.module.smartfactory.dal.mysql.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsMapper;
import cn.iocoder.yudao.module.smartfactory.service.handlinggroupuseramount.HandlingGroupUserAmountService;
import cn.iocoder.yudao.module.smartfactory.service.handlingspecifications.HandlingSpecificationsService;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
@ -40,6 +43,8 @@ public class HandlingGroupAmountSpecificationsServiceImpl implements HandlingGro
private HandlingGroupAmountSpecificationsMapper handlingGroupAmountSpecificationsMapper;
@Resource
private HandlingSpecificationsService handlingSpecificationsService;
@Resource
private HandlingGroupUserAmountService handlingGroupUserAmountService;
@Resource
private AdminUserApi userApi;
@ -63,12 +68,10 @@ public class HandlingGroupAmountSpecificationsServiceImpl implements HandlingGro
@Override
public PageResult<HandlingGroupAmountSpecificationsDO> getHandlingGroupAmountSpecificationsPage(HandlingGroupAmountSpecificationsPageReqVO pageReqVO) {
// 判断当前登录人是否属于工厂主管
AdminUserRespDTO userRespDTO = userApi.getUser(getLoginUserId()).getCheckedData();
DeptRespDTO deptRespDTO = deptApi.getDept(userRespDTO.getDeptId()).getCheckedData();
if (deptRespDTO.getFactoryId() != null) {
pageReqVO.setFactoryId(deptRespDTO.getFactoryId());
List<DeptRespDTO> deptRespDTOS = deptApi.getDeptByLeaderId(getLoginUserId()).getCheckedData();
if (CollUtil.isNotEmpty(deptRespDTOS)) {
pageReqVO.setFactoryIds(deptRespDTOS.stream().map(DeptRespDTO::getFactoryId).distinct().collect(Collectors.toList()));
}
IPage<HandlingGroupAmountSpecificationsDO> pageResult = handlingGroupAmountSpecificationsMapper.getHandlingGroupAmountSpecificationsPage(MyBatisUtils.buildPage(pageReqVO), pageReqVO);
return new PageResult<>(pageResult.getRecords(), pageResult.getTotal());
}
@ -152,14 +155,24 @@ public class HandlingGroupAmountSpecificationsServiceImpl implements HandlingGro
@Override
public void batchDelete(HandlingGroupAmountSpecificationsBatchDelVO vo) {
handlingGroupAmountSpecificationsMapper.delete(new LambdaQueryWrapper<HandlingGroupAmountSpecificationsDO>()
List<HandlingGroupAmountSpecificationsDO> list = handlingGroupAmountSpecificationsMapper.selectList(new LambdaQueryWrapper<HandlingGroupAmountSpecificationsDO>()
.eq(HandlingGroupAmountSpecificationsDO::getFactoryId, vo.getFactoryId())
.eq(HandlingGroupAmountSpecificationsDO::getHandlingGroupId, vo.getHandlingGroupId())
.eq(HandlingGroupAmountSpecificationsDO::getDateStr, vo.getDateStr()));
}
List<Long> ids = list.stream().map(HandlingGroupAmountSpecificationsDO::getId).collect(Collectors.toList());
handlingGroupAmountSpecificationsMapper.deleteBatchIds(ids);
handlingGroupUserAmountService.remove(new LambdaQueryWrapper<HandlingGroupUserAmountDO>()
.in(HandlingGroupUserAmountDO::getHandlingGroupAmountSpecificationsId, ids)
);
}
@Override
public HandlingGroupAmountSpecificationsTotalNumVO getTotalNum(HandlingGroupAmountSpecificationsTotalNumDTO dto) {
// 判断当前登录人是否属于工厂主管
List<DeptRespDTO> deptRespDTOS = deptApi.getDeptByLeaderId(getLoginUserId()).getCheckedData();
if (CollUtil.isNotEmpty(deptRespDTOS)) {
dto.setFactoryIds(deptRespDTOS.stream().map(DeptRespDTO::getFactoryId).distinct().collect(Collectors.toList()));
}
return handlingGroupAmountSpecificationsMapper.getTotalNum(dto);
}

View File

@ -102,4 +102,6 @@ public interface HandlingGroupUserAmountService extends IService<HandlingGroupUs
* @param month
*/
void confirmHandlingGroupUserAmount(Long factoryId, String month);
List<HandlingGroupUserAmountDO> getByHandlingGroupIds(List<Long> handlingGroupIds);
}

View File

@ -248,4 +248,10 @@ public class HandlingGroupUserAmountServiceImpl extends ServiceImpl<HandlingGrou
// 插入工资记录
staffSalaryMapper.insertBatch(salaryDOS);
}
@Override
public List<HandlingGroupUserAmountDO> getByHandlingGroupIds(List<Long> handlingGroupIds) {
return handlingGroupUserAmountMapper.getByHandlingGroupIds(handlingGroupIds);
}
}

View File

@ -21,10 +21,6 @@
LEFT JOIN sf_handling_specifications AS b ON a.handling_specifications_id = b.id
LEFT JOIN sf_staff AS c ON c.id = a.staff_id
left join sf_handling_group as d on a.handling_group_id = d.id
<if test="vo.porterName != null and vo.porterName != ''">
left join sf_handling_group_user_amount as e on a.id = e.handling_group_amount_specifications_id
left join sf_staff as g on g.id = e.user_id
</if>
<where>
a.deleted = 0
and b.deleted = 0
@ -40,8 +36,20 @@
<if test="vo.factoryId != null">
AND a.factory_id = #{vo.factoryId}
</if>
<if test="vo.factoryIds != null and vo.factoryIds.size() > 0">
and a.factory_id in
<foreach collection="vo.factoryIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="vo.porterName != null and vo.porterName != ''">
AND EXISTS (
select e.id from sf_handling_group_user_amount as e
left join sf_staff as g on g.id = e.user_id
where a.id = e.handling_group_amount_specifications_id
and g.nick_name like concat('%', #{vo.porterName}, '%')
and e.deleted = 0
)
</if>
<if test="vo.createTime != null and vo.createTime.length > 0">
<if test="vo.createTime[0] != null">
@ -52,9 +60,6 @@
</if>
</if>
</where>
<if test="vo.porterName != null and vo.porterName != ''">
group by a.id
</if>
</select>
<select id="getHandlingGroupAmountSpecifications"
resultType="cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsDO">
@ -101,13 +106,17 @@
sum(a.amount) as amount
from sf_handling_group_amount_specifications AS a
left join sf_staff as b on a.staff_id = b.id
left join sf_handling_group_user_amount as c on a.id = c.handling_group_amount_specifications_id
left join sf_staff as d on d.id = c.user_id
<where>
a.deleted = 0
<if test="dto.factoryId != null">
and a.factory_id = #{dto.factoryId}
</if>
<if test="dto.factoryIds != null and dto.factoryIds.size() > 0">
and a.factory_id in
<foreach collection="dto.factoryIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="dto.handlingSpecificationsId != null">
and a.handling_specifications_id = #{dto.handlingSpecificationsId}
</if>
@ -115,7 +124,17 @@
and b.nick_name like concat('%', #{dto.forkliftDriverName}, '%')
</if>
<if test="dto.porterName != null and dto.porterName != ''">
AND EXISTS (
SELECT
c.id
FROM
sf_handling_group_user_amount AS c
LEFT JOIN sf_staff AS d ON d.id = c.user_id
WHERE
c.deleted = 0
and a.id = c.handling_group_amount_specifications_id
and d.nick_name like concat('%', #{dto.porterName}, '%')
)
</if>
<if test="dto.createTime != null and dto.createTime.length > 0">
<if test="dto.createTime[0] != null">

View File

@ -180,4 +180,22 @@
AND a.date_str LIKE CONCAT('%', #{month}, '%')
AND a.deleted = 0
</select>
<select id="getByHandlingGroupIds"
resultType="cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupuseramount.HandlingGroupUserAmountDO">
select a.*,
b.nick_name as userName
FROM sf_handling_group_user_amount as a
LEFT JOIN sf_staff as b on a.user_id = b.id
<where>
a.deleted = 0
and b.deleted = 0
<if test="handlingGroupIds != null and handlingGroupIds.size() > 0">
and a.handling_group_id in
<foreach collection="handlingGroupIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
</where>
</select>
</mapper>