feat(smartfactory): 增加搬运组工资记录按月搜索功能

- 在 HandlingGroupUserAmountController 中添加 type 参数,用于指定搜索类型
- 在 HandlingGroupUserAmountService 接口中增加 type 参数
- 在 HandlingGroupUserAmountServiceImpl 中实现按类型搜索的逻辑- 更新 HandlingGroupUserAmountMapper.xml 中的 SQL 语句,修正工厂 ID 的查询条件
This commit is contained in:
aikai 2025-04-08 15:50:11 +08:00
parent 6b2b14c96f
commit 92b64bf0d8
4 changed files with 17 additions and 9 deletions

View File

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

View File

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

View File

@ -88,14 +88,21 @@ public class HandlingGroupUserAmountServiceImpl implements HandlingGroupUserAmou
}
@Override
public HandlingGroupUserAmountMonthVO getListByMonth(Long id, Long factoryId, String time, String name) {
public HandlingGroupUserAmountMonthVO getListByMonth(Long id, Long factoryId, Integer type, String time, String name) {
HandlingGroupUserAmountMonthVO vo = new HandlingGroupUserAmountMonthVO();
Map<Integer, String> headers = new HashMap<>();
// -- 根据yyyy-MM获取到该月第一天时间 - 再获取到最后一天 - 完了后组装表头
String[] times = time.split("-");
List<String> dateList;
if (type == 1) {
LocalDateTime startTime = LocalDateTime.of(Integer.parseInt(times[0]), Integer.parseInt(times[1]), 1, 0, 0, 0);
LocalDateTime endTime = startTime.plusMonths(1).minusDays(1);
List<String> dateList = DateUtils.betweenDayList(startTime, endTime);
dateList = DateUtils.betweenDayList(startTime, endTime);
} else {
LocalDateTime startTime = LocalDateTime.of(Integer.parseInt(times[0]), Integer.parseInt(times[1]), 26, 0, 0, 0).minusMonths(1);
LocalDateTime endTime = LocalDateTime.of(Integer.parseInt(times[0]), Integer.parseInt(times[1]), 25, 0, 0, 0);
dateList = DateUtils.betweenDayList(startTime, endTime);
}
headers.put(1, NAME);
int num = 1;
for (String date : dateList) {
@ -105,7 +112,6 @@ public class HandlingGroupUserAmountServiceImpl implements HandlingGroupUserAmou
headers.put(num + 1, TOTAL_AMOUNT);
// - 插入表头
vo.setHeaders(headers);
List<Map<String, Object>> map = handlingGroupUserAmountMapper.getListByMonth(id, factoryId, dateList, name);
List<HandlingGroupUserAmountMonthItemVO> list = new ArrayList<>();
for (Map<String, Object> item : map) {

View File

@ -89,7 +89,7 @@
and b.id = #{id}
</if>
<if test="factoryId != null">
and a.factory_id = #{factoryId}
and b.factory_id = #{factoryId}
</if>
<if test="name != null and name != ''">
and b.nick_name like concat('%', #{name}, '%')