提交 ddeac52c authored 作者: 000516's avatar 000516 提交者: Coding

集成Mybatis-plus;分页规范修改;完成考勤功能

Merge Request: 集成Mybatis-plus;分页规范修改;完成考勤功能 Created By: @李秋林 Accepted By: @李秋林 URL: https://g-pkkp8204.coding.net/p/wangxiaolu-sfa/d/wangxiaolu-sfa-module-operation/git/merge/33?initial=true
...@@ -2,6 +2,7 @@ package com.sfa.operation.controller.query; ...@@ -2,6 +2,7 @@ package com.sfa.operation.controller.query;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.sfa.common.core.utils.DateUtils;
import com.sfa.common.security.utils.SecurityUtils; import com.sfa.common.security.utils.SecurityUtils;
import com.sfa.operation.service.IKqMxQueryService; import com.sfa.operation.service.IKqMxQueryService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -9,6 +10,7 @@ import org.springframework.web.bind.annotation.GetMapping; ...@@ -9,6 +10,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -26,8 +28,8 @@ public class KqMxQueryController { ...@@ -26,8 +28,8 @@ public class KqMxQueryController {
@GetMapping("/roll") @GetMapping("/roll")
public Map rollDateList(){ public Map rollDateList(){
Long userId = SecurityUtils.getUserId(); Long userId = SecurityUtils.getUserId();
DateTime dateTime = DateUtil.offsetDay(new DateTime(), -7); Date dateStart = DateUtils.dateStart(DateUtil.offsetDay(new DateTime(), -7));
Map dataMap = kqMxQueryService.rollDateList(dateTime, userId); Map dataMap = kqMxQueryService.rollDateList(dateStart, userId);
HashMap<String,Object> rMap = new HashMap<>(); HashMap<String,Object> rMap = new HashMap<>();
rMap.put("data",dataMap); rMap.put("data",dataMap);
rMap.put("current",new DateTime()); rMap.put("current",new DateTime());
......
package com.sfa.operation.domain.dao; package com.sfa.operation.domain.dao;
import cn.hutool.core.date.DateTime;
import com.sfa.operation.pojo.response.SfaKqMxDto; import com.sfa.operation.pojo.response.SfaKqMxDto;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -13,5 +13,5 @@ import java.util.List; ...@@ -13,5 +13,5 @@ import java.util.List;
public interface ISfaKqmxDao { public interface ISfaKqmxDao {
void add(SfaKqMxDto kqMxDto); void add(SfaKqMxDto kqMxDto);
List<SfaKqMxDto> betweentDate(DateTime dateTime,Long userId); List<SfaKqMxDto> betweentDate(Date dateStart, Long userId);
} }
package com.sfa.operation.domain.dao.impl; package com.sfa.operation.domain.dao.impl;
import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sfa.common.core.enums.ECode; import com.sfa.common.core.enums.ECode;
import com.sfa.common.core.exception.WXLSQLException; import com.sfa.common.core.exception.WXLSQLException;
...@@ -12,6 +11,7 @@ import org.springframework.beans.BeanUtils; ...@@ -12,6 +11,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -44,10 +44,12 @@ public class SfaKqmxDaoImpl implements ISfaKqmxDao { ...@@ -44,10 +44,12 @@ public class SfaKqmxDaoImpl implements ISfaKqmxDao {
} }
@Override @Override
public List<SfaKqMxDto> betweentDate(DateTime dateTime,Long userId) { public List<SfaKqMxDto> betweentDate(Date dateStart, Long userId) {
LambdaQueryWrapper<SfaKqmx> qw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SfaKqmx> qw = new LambdaQueryWrapper<>();
qw.ge(SfaKqmx::getCreateDate, dateTime); qw.ge(SfaKqmx::getCreateDate, dateStart);
qw.eq(SfaKqmx::getCreateUserId,userId); qw.eq(SfaKqmx::getCreateUserId,userId);
qw.select(SfaKqmx::getCreateDate,SfaKqmx::getKqmxId,SfaKqmx::getKqTime,SfaKqmx::getKqAddress,SfaKqmx::getKqPicurl,SfaKqmx::getKqType);
List<SfaKqmx> dos = sfaKqmxMapper.selectList(qw); List<SfaKqmx> dos = sfaKqmxMapper.selectList(qw);
List<SfaKqMxDto> dtos = com.sfa.common.core.utils.bean.BeanUtils.transitionDtos(dos, SfaKqMxDto.class); List<SfaKqMxDto> dtos = com.sfa.common.core.utils.bean.BeanUtils.transitionDtos(dos, SfaKqMxDto.class);
return dtos; return dtos;
......
package com.sfa.operation.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author : liqiulin
* @date : 2024-11-08 11
* @describe :
*/
@AllArgsConstructor
@Getter
public enum KqEnum {
FIR_CLOCK(1,"上班卡"),
SEC_CLOCK(2,"午班卡"),
THI_CLOCK(3,"下班卡")
;
private Integer kqType;
private String kqTypeMsg;
}
...@@ -79,4 +79,7 @@ public class SfaKqMxDto { ...@@ -79,4 +79,7 @@ public class SfaKqMxDto {
*/ */
private Long createUserId; private Long createUserId;
public SfaKqMxDto(Integer kqType) {
this.kqType = kqType;
}
} }
package com.sfa.operation.service; package com.sfa.operation.service;
import cn.hutool.core.date.DateTime; import java.util.Date;
import java.util.Map; import java.util.Map;
/** /**
...@@ -10,5 +9,5 @@ import java.util.Map; ...@@ -10,5 +9,5 @@ import java.util.Map;
* @describe : * @describe :
*/ */
public interface IKqMxQueryService { public interface IKqMxQueryService {
Map rollDateList(DateTime dateTime,Long userId); Map rollDateList(Date dateStart, Long userId);
} }
package com.sfa.operation.service.impl; package com.sfa.operation.service.impl;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil;
import com.sfa.common.core.constant.SecurityConstants;
import com.sfa.common.core.utils.DateUtils;
import com.sfa.common.security.utils.SecurityUtils;
import com.sfa.operation.domain.dao.ISfaKqmxDao; import com.sfa.operation.domain.dao.ISfaKqmxDao;
import com.sfa.operation.enums.KqEnum;
import com.sfa.operation.pojo.response.SfaKqMxDto; import com.sfa.operation.pojo.response.SfaKqMxDto;
import com.sfa.operation.service.IKqMxQueryService; import com.sfa.operation.service.IKqMxQueryService;
import com.sfa.system.api.RemoteKqRuleService;
import com.sfa.system.api.pojo.response.MdmKqRuleDto;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date; import java.text.SimpleDateFormat;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -22,11 +27,43 @@ import java.util.stream.Collectors; ...@@ -22,11 +27,43 @@ import java.util.stream.Collectors;
public class KqMxQueryServiceImpl implements IKqMxQueryService { public class KqMxQueryServiceImpl implements IKqMxQueryService {
@Autowired @Autowired
ISfaKqmxDao sfaKqmxDao; ISfaKqmxDao sfaKqmxDao;
@Autowired
RemoteKqRuleService remoteKqRuleService;
@Override @Override
public Map rollDateList(DateTime dateTime,Long userId) { public Map rollDateList( Date dateStart,Long userId) {
List<SfaKqMxDto> dtos = sfaKqmxDao.betweentDate(dateTime,userId); Long ruleId = SecurityUtils.getLoginUser().getRuleId();
TreeMap<Date, List<SfaKqMxDto>> collect = dtos.stream().collect(Collectors.groupingBy(SfaKqMxDto::getCreateDate, TreeMap::new, Collectors.toList())); MdmKqRuleDto kqruleDto = remoteKqRuleService.getInfo(ruleId, SecurityConstants.INNER).getData();
return collect.descendingMap(); List<SfaKqMxDto> dtos = sfaKqmxDao.betweentDate(dateStart,userId);
TreeMap<String, List<SfaKqMxDto>> gm = dtos.stream().collect(Collectors.groupingBy(item -> new SimpleDateFormat(DateUtils.YYYY_MM_DD).format(item.getCreateDate()), TreeMap::new, Collectors.toList()));
// 判断无考勤,或下标0非今天时,创建今日数据
String today = DateUtil.today();
boolean hasSec = Objects.nonNull(kqruleDto.getSecBegintime());
int clockNum = Objects.nonNull(kqruleDto.getSecBegintime()) ? 3 : 2;
// 无需处理
if (gm.containsKey(today) && (gm.get(today).size() == clockNum)) {
return gm.descendingMap();
}
// 无今日明细
if (MapUtils.isEmpty(gm) || !gm.containsKey(today)){
List<SfaKqMxDto> mxDtos = new ArrayList<>();
mxDtos.add(new SfaKqMxDto(KqEnum.FIR_CLOCK.getKqType()));
if (hasSec){
mxDtos.add(new SfaKqMxDto(KqEnum.SEC_CLOCK.getKqType()));
}
mxDtos.add(new SfaKqMxDto(KqEnum.THI_CLOCK.getKqType()));
gm.put(today,mxDtos);
return gm.descendingMap();
}
List<SfaKqMxDto> mxDtos = gm.get(today);
if (mxDtos.size() < clockNum - 1) {
mxDtos.add(new SfaKqMxDto(KqEnum.SEC_CLOCK.getKqType()));
}
mxDtos.add(new SfaKqMxDto(KqEnum.THI_CLOCK.getKqType()));
return gm.descendingMap();
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论