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
This commit is contained in:
furongxin 2025-05-20 14:32:48 +08:00
commit ca80611f91
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); 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())); 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<>(); Map<Long, List<HandlingGroupUserAmountDO>> handlingGroupUserAmountMap = new HashMap<>();
if (CollUtil.isNotEmpty(ids)) { if (CollUtil.isNotEmpty(ids)) {
List<HandlingGroupUserAmountDO> list = handlingGroupUserAmountService.getByHandlingGroupAmountSpecificationsId(ids); List<HandlingGroupUserAmountDO> list = handlingGroupUserAmountService.getByHandlingGroupIds(ids);
handlingGroupUserAmountMap = list.stream().collect(Collectors.groupingBy(HandlingGroupUserAmountDO::getHandlingGroupAmountSpecificationsId)); handlingGroupUserAmountMap = list.stream().collect(Collectors.groupingBy(HandlingGroupUserAmountDO::getHandlingGroupId));
} }
for (HandlingGroupAmountSpecificationsRespVO handlingGroupAmountSpecificationsDO : result.getList()) { for (HandlingGroupAmountSpecificationsRespVO handlingGroupAmountSpecificationsDO : result.getList()) {
String key = handlingGroupAmountSpecificationsDO.getFactoryId() + "_" + handlingGroupAmountSpecificationsDO.getHandlingGroupId() + "_" + handlingGroupAmountSpecificationsDO.getDateStr(); String key = handlingGroupAmountSpecificationsDO.getFactoryId() + "_" + handlingGroupAmountSpecificationsDO.getHandlingGroupId() + "_" + handlingGroupAmountSpecificationsDO.getDateStr();
handlingGroupAmountSpecificationsDO.setTotalAmount(getSumValue(map.get(key), HandlingGroupAmountSpecificationsRespVO::getAmount, BigDecimal::add)); handlingGroupAmountSpecificationsDO.setTotalAmount(getSumValue(map.get(key), HandlingGroupAmountSpecificationsRespVO::getAmount, BigDecimal::add));
handlingGroupAmountSpecificationsDO.setTotalNum(getSumValue(map.get(key), HandlingGroupAmountSpecificationsRespVO::getTotalCount, Integer::sum)); 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)) { if (CollUtil.isNotEmpty(items)) {
List<HandlingGroupUserAmountItemVO> handlingGroupUserAmountItemVOS = BeanUtils.toBean(items, HandlingGroupUserAmountItemVO.class); List<HandlingGroupUserAmountItemVO> handlingGroupUserAmountItemVOS = BeanUtils.toBean(items, HandlingGroupUserAmountItemVO.class);
handlingGroupAmountSpecificationsDO.setHandlingGroupUserAmountItemVOS(handlingGroupUserAmountItemVOS); handlingGroupAmountSpecificationsDO.setHandlingGroupUserAmountItemVOS(handlingGroupUserAmountItemVOS);

View File

@ -6,6 +6,7 @@ import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime; 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; 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 = "创建时间") @Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime; 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.math.BigDecimal;
import java.time.LocalDateTime; 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; 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) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime; 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> 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); List<HandlingGroupUserAmountDO> selectAmountSum(@Param("factoryId") Long factoryId, @Param("month") String month);
Long selectIsExists(@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; 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.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; 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.handlinggroup.vo.HandlingGroupListVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.dto.HandlingGroupAmountSpecificationsTotalNumDTO; 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.controller.admin.handlinggroupamountspecifications.vo.*;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsDO; 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.dataobject.handlingspecifications.HandlingSpecificationsDO;
import cn.iocoder.yudao.module.smartfactory.dal.mysql.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsMapper; 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.smartfactory.service.handlingspecifications.HandlingSpecificationsService;
import cn.iocoder.yudao.module.system.api.dept.DeptApi; import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
@ -40,6 +43,8 @@ public class HandlingGroupAmountSpecificationsServiceImpl implements HandlingGro
private HandlingGroupAmountSpecificationsMapper handlingGroupAmountSpecificationsMapper; private HandlingGroupAmountSpecificationsMapper handlingGroupAmountSpecificationsMapper;
@Resource @Resource
private HandlingSpecificationsService handlingSpecificationsService; private HandlingSpecificationsService handlingSpecificationsService;
@Resource
private HandlingGroupUserAmountService handlingGroupUserAmountService;
@Resource @Resource
private AdminUserApi userApi; private AdminUserApi userApi;
@ -63,12 +68,10 @@ public class HandlingGroupAmountSpecificationsServiceImpl implements HandlingGro
@Override @Override
public PageResult<HandlingGroupAmountSpecificationsDO> getHandlingGroupAmountSpecificationsPage(HandlingGroupAmountSpecificationsPageReqVO pageReqVO) { public PageResult<HandlingGroupAmountSpecificationsDO> getHandlingGroupAmountSpecificationsPage(HandlingGroupAmountSpecificationsPageReqVO pageReqVO) {
// 判断当前登录人是否属于工厂主管 // 判断当前登录人是否属于工厂主管
AdminUserRespDTO userRespDTO = userApi.getUser(getLoginUserId()).getCheckedData(); List<DeptRespDTO> deptRespDTOS = deptApi.getDeptByLeaderId(getLoginUserId()).getCheckedData();
DeptRespDTO deptRespDTO = deptApi.getDept(userRespDTO.getDeptId()).getCheckedData(); if (CollUtil.isNotEmpty(deptRespDTOS)) {
if (deptRespDTO.getFactoryId() != null) { pageReqVO.setFactoryIds(deptRespDTOS.stream().map(DeptRespDTO::getFactoryId).distinct().collect(Collectors.toList()));
pageReqVO.setFactoryId(deptRespDTO.getFactoryId());
} }
IPage<HandlingGroupAmountSpecificationsDO> pageResult = handlingGroupAmountSpecificationsMapper.getHandlingGroupAmountSpecificationsPage(MyBatisUtils.buildPage(pageReqVO), pageReqVO); IPage<HandlingGroupAmountSpecificationsDO> pageResult = handlingGroupAmountSpecificationsMapper.getHandlingGroupAmountSpecificationsPage(MyBatisUtils.buildPage(pageReqVO), pageReqVO);
return new PageResult<>(pageResult.getRecords(), pageResult.getTotal()); return new PageResult<>(pageResult.getRecords(), pageResult.getTotal());
} }
@ -152,14 +155,24 @@ public class HandlingGroupAmountSpecificationsServiceImpl implements HandlingGro
@Override @Override
public void batchDelete(HandlingGroupAmountSpecificationsBatchDelVO vo) { 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::getFactoryId, vo.getFactoryId())
.eq(HandlingGroupAmountSpecificationsDO::getHandlingGroupId, vo.getHandlingGroupId()) .eq(HandlingGroupAmountSpecificationsDO::getHandlingGroupId, vo.getHandlingGroupId())
.eq(HandlingGroupAmountSpecificationsDO::getDateStr, vo.getDateStr())); .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 @Override
public HandlingGroupAmountSpecificationsTotalNumVO getTotalNum(HandlingGroupAmountSpecificationsTotalNumDTO dto) { 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); return handlingGroupAmountSpecificationsMapper.getTotalNum(dto);
} }

View File

@ -102,4 +102,6 @@ public interface HandlingGroupUserAmountService extends IService<HandlingGroupUs
* @param month * @param month
*/ */
void confirmHandlingGroupUserAmount(Long factoryId, String 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); 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_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_staff AS c ON c.id = a.staff_id
left join sf_handling_group as d on a.handling_group_id = d.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> <where>
a.deleted = 0 a.deleted = 0
and b.deleted = 0 and b.deleted = 0
@ -40,8 +36,20 @@
<if test="vo.factoryId != null"> <if test="vo.factoryId != null">
AND a.factory_id = #{vo.factoryId} AND a.factory_id = #{vo.factoryId}
</if> </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 != ''"> <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 g.nick_name like concat('%', #{vo.porterName}, '%')
and e.deleted = 0
)
</if> </if>
<if test="vo.createTime != null and vo.createTime.length > 0"> <if test="vo.createTime != null and vo.createTime.length > 0">
<if test="vo.createTime[0] != null"> <if test="vo.createTime[0] != null">
@ -52,9 +60,6 @@
</if> </if>
</if> </if>
</where> </where>
<if test="vo.porterName != null and vo.porterName != ''">
group by a.id
</if>
</select> </select>
<select id="getHandlingGroupAmountSpecifications" <select id="getHandlingGroupAmountSpecifications"
resultType="cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsDO"> resultType="cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsDO">
@ -101,13 +106,17 @@
sum(a.amount) as amount sum(a.amount) as amount
from sf_handling_group_amount_specifications AS a from sf_handling_group_amount_specifications AS a
left join sf_staff as b on a.staff_id = b.id 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> <where>
a.deleted = 0 a.deleted = 0
<if test="dto.factoryId != null"> <if test="dto.factoryId != null">
and a.factory_id = #{dto.factoryId} and a.factory_id = #{dto.factoryId}
</if> </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"> <if test="dto.handlingSpecificationsId != null">
and a.handling_specifications_id = #{dto.handlingSpecificationsId} and a.handling_specifications_id = #{dto.handlingSpecificationsId}
</if> </if>
@ -115,7 +124,17 @@
and b.nick_name like concat('%', #{dto.forkliftDriverName}, '%') and b.nick_name like concat('%', #{dto.forkliftDriverName}, '%')
</if> </if>
<if test="dto.porterName != null and dto.porterName != ''"> <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}, '%') and d.nick_name like concat('%', #{dto.porterName}, '%')
)
</if> </if>
<if test="dto.createTime != null and dto.createTime.length > 0"> <if test="dto.createTime != null and dto.createTime.length > 0">
<if test="dto.createTime[0] != null"> <if test="dto.createTime[0] != null">

View File

@ -180,4 +180,22 @@
AND a.date_str LIKE CONCAT('%', #{month}, '%') AND a.date_str LIKE CONCAT('%', #{month}, '%')
AND a.deleted = 0 AND a.deleted = 0
</select> </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> </mapper>