提交 90cd26e9 authored 作者: 000516's avatar 000516

删除原sfa-kq逻辑
package com.sfa.operation.controller.sfa.core;
import com.sfa.common.security.utils.SecurityUtils;
import com.sfa.operation.pojo.sfa.request.KqMxVo;
import com.sfa.operation.pojo.sfa.response.SfaKqMxDto;
import com.sfa.operation.service.sfa.IKqMxCoreService;
import com.sfa.system.api.model.LoginUser;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
/**
* @author : liqiulin
* @date : 2024-11-04 17
* @describe :
*/
@RestController
@RequestMapping("/kqmx/core")
public class KqMxCoreController {
@Autowired
IKqMxCoreService kqMxCoreService;
/**
* 打卡
* @param kqMxVo 打卡基础明细
*/
@PostMapping
public void kqClockIn(@RequestBody @Validated KqMxVo kqMxVo){
SfaKqMxDto kqMxDto = new SfaKqMxDto();
BeanUtils.copyProperties(kqMxVo,kqMxDto);
LoginUser loginUser = SecurityUtils.getLoginUser();
Date date = new Date();
kqMxDto.setKqUserid(loginUser.getUserid())
.setKqTime(date)
.setRuleId(loginUser.getRuleId())
.setRuleName(loginUser.getRuleName())
.setCreateDate(date)
.setCreateBy(loginUser.getUsername())
.setCreateUserId(loginUser.getUserid())
.setKqAddress(kqMxDto.getKqProvinc() + "-" + kqMxDto.getKqCity() + "-" + kqMxDto.getKqCounty() + "-" + kqMxDto.getKqAddress());
kqMxCoreService.kqClockIn(kqMxDto);
}
}
package com.sfa.operation.controller.sfa.query;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.sfa.common.core.utils.DateUtils;
import com.sfa.common.security.utils.SecurityUtils;
import com.sfa.operation.service.sfa.IKqMxQueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @author : liqiulin
* @date : 2024-11-05 13
* @describe :
*/
@RestController
@RequestMapping("/kqmx/query")
public class KqMxQueryController {
@Autowired
IKqMxQueryService kqMxQueryService;
@GetMapping("/roll")
public Map rollDateList(){
Long userId = SecurityUtils.getUserId();
Date dateStart = DateUtils.dateStart(DateUtil.offsetDay(new DateTime(), -7));
Map dataMap = kqMxQueryService.rollDateList(dateStart, userId);
HashMap<String,Object> rMap = new HashMap<>();
rMap.put("data",dataMap);
rMap.put("current",new DateTime());
return rMap;
}
}
package com.sfa.operation.domain.sfa.dao;
import com.sfa.operation.pojo.sfa.response.SfaKqMxDto;
import java.util.Date;
import java.util.List;
/**
* @author : liqiulin
* @date : 2024-11-05 10
* @describe :
*/
public interface ISfaKqmxDao {
void add(SfaKqMxDto kqMxDto);
List<SfaKqMxDto> betweentDate(Date dateStart, Long userId);
}
package com.sfa.operation.domain.sfa.dao.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sfa.common.core.enums.ECode;
import com.sfa.common.core.exception.WXLSQLException;
import com.sfa.operation.domain.sfa.dao.ISfaKqmxDao;
import com.sfa.operation.domain.sfa.entity.SfaKqmxEntity;
import com.sfa.operation.domain.sfa.mapper.SfaKqmxMapper;
import com.sfa.operation.pojo.sfa.response.SfaKqMxDto;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* @author : liqiulin
* @date : 2024-11-05 10
* @describe :
*/
@Service
public class SfaKqmxDaoImpl implements ISfaKqmxDao {
@Autowired
SfaKqmxMapper sfaKqmxMapper;
@Override
public void add(SfaKqMxDto kqMxDto) {
try {
SfaKqmxEntity kqDo = new SfaKqmxEntity();
BeanUtils.copyProperties(kqMxDto,kqDo);
kqDo.setKqLon(kqMxDto.getKqLocal()[0]);
kqDo.setKqLat(kqMxDto.getKqLocal()[1]);
sfaKqmxMapper.insertOne(kqDo);
}catch (Exception e) {
String eMsg = e.getCause().getMessage();
if (eMsg.contains("for key 'date_type_unique'")) {
throw new WXLSQLException(ECode.KQMX_CURRENTLY_TYPE_KQ_HAS);
}else {
throw new WXLSQLException(ECode.KQMX_CLOCK_IN_ERRPR);
}
}
}
@Override
public List<SfaKqMxDto> betweentDate(Date dateStart, Long userId) {
LambdaQueryWrapper<SfaKqmxEntity> qw = new LambdaQueryWrapper<>();
qw.ge(SfaKqmxEntity::getCreateDate, dateStart);
qw.eq(SfaKqmxEntity::getCreateUserId,userId);
qw.select(SfaKqmxEntity::getCreateDate, SfaKqmxEntity::getKqmxId, SfaKqmxEntity::getKqTime, SfaKqmxEntity::getKqAddress, SfaKqmxEntity::getKqPicurl, SfaKqmxEntity::getKqType);
List<SfaKqmxEntity> dos = sfaKqmxMapper.selectList(qw);
List<SfaKqMxDto> dtos = com.sfa.common.core.utils.bean.BeanUtils.transitionDtos(dos, SfaKqMxDto.class);
return dtos;
}
}
package com.sfa.operation.domain.sfa.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* sfa考勤明细表
* @TableName sfa_kqmx
*/
@AllArgsConstructor
@NoArgsConstructor
@TableName(value ="sfa_kqmx")
@Data
public class SfaKqmxEntity implements Serializable {
/**
* 考勤明细ID
*/
@TableId(type = IdType.AUTO)
private Long kqmxId;
/**
* 员工ID
*/
private Long kqUserid;
/**
* 考勤规则ID
*/
private Long ruleId;
/**
* 考勤规则名称
*/
private String ruleName;
/**
* 上班打卡时间
*/
private Date kqTime;
/**
* 经度
*/
private BigDecimal kqLon;
/**
* 纬度
*/
private BigDecimal kqLat;
/**
* 打卡-省-市-区-详细地址
*/
private String kqAddress;
/**
* 打卡省编码
*/
private String kqProvinceNum;
/**
* 打卡省编码
*/
private String kqProvinc;
/**
* 打卡城市编码
*/
private String kqCityNum;
/**
* 打卡市编码
*/
private String kqCity;
/**
* 打卡县/区编码
*/
private String kqCountyNum;
/**
* 打卡区编码
*/
private String kqCounty;
/**
* 考勤照片
*/
private String kqPicurl;
/**
* 1:上班;2:午班;3:下班;
*/
private Integer kqType;
private Date createDate;
/**
* 记录版本
*/
private Integer flag;
/**
* 记录删除
*/
private String delFlag;
/**
* 创建者/打卡人员
*/
private String createBy;
/**
* 创建人UserID
*/
private Long createUserId;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新者
*/
private String updateBy;
/**
* 修改人UserID
*/
private Long updateUserId;
/**
* 更新时间
*/
private Date updateTime;
/**
* 备注
*/
private String remark;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package com.sfa.operation.domain.sfa.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sfa.operation.domain.sfa.entity.SfaKqmxEntity;
import org.springframework.stereotype.Repository;
/**
* @author a02200059
* @description 针对表【sfa_kqmx(sfa考勤明细表)】的数据库操作Mapper
* @createDate 2024-11-04 15:50:25
*/
@Repository
public interface SfaKqmxMapper extends BaseMapper<SfaKqmxEntity> {
void insertOne(SfaKqmxEntity kqDo);
}
package com.sfa.operation.pojo.sfa.request;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
/**
* @author : liqiulin
* @date : 2024-11-04 16
* @describe :
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class KqMxVo {
@NotNull(message = "打卡经纬度获取不到")
private BigDecimal[] kqLocal;
@NotBlank(message = "打卡省份获取不到")
private String kqProvinc;
@NotBlank(message = "打卡城市获取不到")
private String kqCity;
@NotBlank(message = "打卡区域获取不到")
private String kqCounty;
@NotBlank(message = "详细位置获取不到")
private String kqAddress;
private String kqPicurl;
/**
* 1:上班;2:午班;3:下班;
*/
@NotNull(message = "无法判断上下班类型,请刷新重试")
@Max(value = 3,message = "无法判断上下班类型,请刷新重试(<=3)")
@Min(value = 1,message = "无法判断上下班类型,请刷新重试(>=1)")
private Integer kqType;
}
package com.sfa.operation.pojo.sfa.response;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author : liqiulin
* @date : 2024-11-04 16
* @describe :
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class SfaKqMxDto {
/**
* 考勤明细ID
*/
private Long kqmxId;
private Date kqTime;
private BigDecimal[] kqLocal;
private String kqProvinc;
private String kqCity;
private String kqCounty;
private String kqAddress;
private String kqPicurl;
/**
* 1:上班;2:午班;3:下班;
*/
private Integer kqType;
/**
* 员工ID
*/
private Long kqUserid;
/**
* 考勤规则ID
*/
private Long ruleId;
/**
* 考勤规则名称
*/
private String ruleName;
/**
* 打卡省编码
*/
private String kqProvinceNum;
/**
* 打卡城市编码
*/
private String kqCityNum;
/**
* 打卡县/区编码
*/
private String kqCountyNum;
private Date createDate;
/**
* 创建者/打卡人员
*/
private String createBy;
/**
* 创建人UserID
*/
private Long createUserId;
public SfaKqMxDto(Integer kqType) {
this.kqType = kqType;
}
}
package com.sfa.operation.service.sfa;
import com.sfa.operation.pojo.sfa.response.SfaKqMxDto;
/**
* @author : liqiulin
* @date : 2024-11-04 18
* @describe :
*/
public interface IKqMxCoreService {
void kqClockIn(SfaKqMxDto kqMxDto);
}
package com.sfa.operation.service.sfa;
import java.util.Date;
import java.util.Map;
/**
* @author : liqiulin
* @date : 2024-11-05 14
* @describe :
*/
public interface IKqMxQueryService {
Map rollDateList(Date dateStart, Long userId);
}
package com.sfa.operation.service.sfa.impl;
import com.sfa.common.core.constant.SecurityConstants;
import com.sfa.common.core.domain.R;
import com.sfa.operation.domain.sfa.dao.ISfaKqmxDao;
import com.sfa.operation.pojo.sfa.response.SfaKqMxDto;
import com.sfa.operation.service.sfa.IKqMxCoreService;
import com.sfa.system.api.RemoteSiteService;
import com.sfa.system.api.pojo.response.SiteDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Objects;
/**
* @author : liqiulin
* @date : 2024-11-04 18
* @describe :
*/
@Service
public class KqMxCoreServiceImpl implements IKqMxCoreService {
@Autowired
RemoteSiteService remoteSiteService;
@Autowired
ISfaKqmxDao kqmxDao;
@Override
public void kqClockIn(SfaKqMxDto kqMxDto) {
SiteDto siteDto = new SiteDto()
.setProvinceName(kqMxDto.getKqProvinc())
.setCityName(kqMxDto.getKqCity())
.setCountyName(kqMxDto.getKqCounty());
R<SiteDto> siteDtoR = remoteSiteService.getCountyName(siteDto, SecurityConstants.INNER);
if (!Objects.isNull(siteDtoR.getData())){
SiteDto data = siteDtoR.getData();
kqMxDto.setKqProvinceNum(data.getProvinceNum())
.setKqCityNum(data.getCityNum())
.setKqCountyNum(data.getCountyNum());
}
kqmxDao.add(kqMxDto);
}
}
package com.sfa.operation.service.sfa.impl;
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.sfa.dao.ISfaKqmxDao;
import com.sfa.operation.enums.KqEnum;
import com.sfa.operation.pojo.sfa.response.SfaKqMxDto;
import com.sfa.operation.service.sfa.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.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author : liqiulin
* @date : 2024-11-05 14
* @describe :
*/
@Service
public class KqMxQueryServiceImpl implements IKqMxQueryService {
@Autowired
ISfaKqmxDao sfaKqmxDao;
@Autowired
RemoteKqRuleService remoteKqRuleService;
@Override
public Map rollDateList( Date dateStart,Long userId) {
Long ruleId = SecurityUtils.getLoginUser().getRuleId();
MdmKqRuleDto kqruleDto = remoteKqRuleService.getInfo(ruleId, SecurityConstants.INNER).getData();
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();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sfa.operation.domain.sfa.mapper.SfaKqmxMapper">
<insert id="insertOne" parameterType="com.sfa.operation.domain.sfa.entity.SfaKqmxEntity">
INSERT INTO sfa_kqmx (kq_userid, rule_id, rule_name, kq_time, kq_local, kq_lon, kq_lat, kq_address,
kq_province_num, kq_provinc, kq_city_num, kq_city, kq_county_num, kq_county, kq_picurl,
kq_type, create_date, create_by, create_user_id)
VALUES (#{kqUserid}, #{ruleId}, #{ruleName}, #{kqTime},ST_GeomFromText('POINT(${kqLon} ${kqLat})'),
#{kqLon},
#{kqLat}, #{kqAddress}, #{kqProvinceNum}, #{kqProvinc}, #{kqCityNum},
#{kqCity},
#{kqCountyNum},
#{kqCounty}, #{kqPicurl}, #{kqType}, #{createDate}, #{createBy},
#{createUserId});
</insert>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论