feat(smartfactory): 增加用户ID筛选功能并优化数据结构

- 在 HandlingGroupUserAmountMonthItemVO 中将 contentList 的类型从 List 改为 Map- 在 getListByMonth 方法中添加 id 参数,用于筛选特定用户的数据
- 更新相关 mapper 和 service
This commit is contained in:
aikai 2025-04-07 11:33:21 +08:00
parent 346716c3ff
commit 6b2b14c96f
6 changed files with 16 additions and 11 deletions

View File

@ -68,10 +68,11 @@ public class HandlingGroupUserAmountController {
@GetMapping("/getListByMonth")
@Operation(summary = "获得搬运组工资记录 按月搜索")
@Parameter(name = "time", description = "日期 格式(yyyy-MM) 默认当前月", required = true, example = "1024")
public CommonResult<HandlingGroupUserAmountMonthVO> getListByMonth(@RequestParam(value = "name", required = false) String name,
public CommonResult<HandlingGroupUserAmountMonthVO> getListByMonth(@RequestParam(value = "id", required = false) Long id,
@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "time", required = true) String time,
@RequestParam(value = "factoryId", required = false) Long factoryId) {
HandlingGroupUserAmountMonthVO vo = handlingGroupUserAmountService.getListByMonth(factoryId, time, name);
HandlingGroupUserAmountMonthVO vo = handlingGroupUserAmountService.getListByMonth(id, factoryId, time, name);
return success(vo);
}

View File

@ -13,5 +13,5 @@ public class HandlingGroupUserAmountMonthItemVO {
private Long userId;
@Schema(description = "列表", example = "22544")
private List<Map<Integer,String>> contentList;
private Map<Integer,String> contentList;
}

View File

@ -57,5 +57,5 @@ public interface HandlingGroupUserAmountMapper extends BaseMapperX<HandlingGroup
* @param name
* @return
*/
List<Map<String, Object>> getListByMonth(@Param("factoryId") Long factoryId, @Param("dateList") List<String> dateList, @Param("name") String name);
List<Map<String, Object>> getListByMonth(@Param("id") Long id, @Param("factoryId") Long factoryId, @Param("dateList") List<String> dateList, @Param("name") String name);
}

View File

@ -78,5 +78,5 @@ public interface HandlingGroupUserAmountService {
* @param name
* @return
*/
HandlingGroupUserAmountMonthVO getListByMonth(Long factoryId, String time, String name);
HandlingGroupUserAmountMonthVO getListByMonth(Long id, Long factoryId, String time, String name);
}

View File

@ -17,7 +17,10 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 搬运组每日个人工资记录 Service 实现类
@ -85,7 +88,7 @@ public class HandlingGroupUserAmountServiceImpl implements HandlingGroupUserAmou
}
@Override
public HandlingGroupUserAmountMonthVO getListByMonth(Long factoryId, String time, String name) {
public HandlingGroupUserAmountMonthVO getListByMonth(Long id, Long factoryId, String time, String name) {
HandlingGroupUserAmountMonthVO vo = new HandlingGroupUserAmountMonthVO();
Map<Integer, String> headers = new HashMap<>();
// -- 根据yyyy-MM获取到该月第一天时间 - 再获取到最后一天 - 完了后组装表头
@ -103,9 +106,8 @@ public class HandlingGroupUserAmountServiceImpl implements HandlingGroupUserAmou
// - 插入表头
vo.setHeaders(headers);
List<Map<String, Object>> map = handlingGroupUserAmountMapper.getListByMonth(factoryId, dateList, name);
List<Map<String, Object>> map = handlingGroupUserAmountMapper.getListByMonth(id, factoryId, dateList, name);
List<HandlingGroupUserAmountMonthItemVO> list = new ArrayList<>();
List<Map<Integer, String>> contentList = new ArrayList<>();
for (Map<String, Object> item : map) {
HandlingGroupUserAmountMonthItemVO itemVO = new HandlingGroupUserAmountMonthItemVO();
itemVO.setUserId((Long) item.get("userId"));
@ -117,8 +119,7 @@ public class HandlingGroupUserAmountServiceImpl implements HandlingGroupUserAmou
itemMap.put(num, item.get(date).toString());
}
itemMap.put(num + 1, item.get("totalAmount").toString());
contentList.add(itemMap);
itemVO.setContentList(contentList);
itemVO.setContentList(itemMap);
list.add(itemVO);
}
vo.setList(list);

View File

@ -85,6 +85,9 @@
left join sf_staff as b on a.user_id = b.id
<where>
a.deleted = 0
<if test="id != null">
and b.id = #{id}
</if>
<if test="factoryId != null">
and a.factory_id = #{factoryId}
</if>