祥慧恒昕绩效模块开发
This commit is contained in:
parent
1e9be8cb03
commit
80e709a6ae
|
|
@ -0,0 +1,41 @@
|
|||
package com.weaver.seconddev.xianghui.performance.controller;
|
||||
|
||||
import com.weaver.common.authority.annotation.WeaPermission;
|
||||
import com.weaver.common.base.entity.result.WeaResult;
|
||||
import com.weaver.seconddev.xianghui.performance.entity.po.EbTableMonitorPO;
|
||||
import com.weaver.seconddev.xianghui.performance.entity.po.HrKpiFlowPO;
|
||||
import com.weaver.seconddev.xianghui.performance.service.EbTableMonitorService;
|
||||
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 javax.ws.rs.QueryParam;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/secondev/xh/performance")
|
||||
@WeaPermission(publicPermission = true)
|
||||
public class EbTableMonitorController {
|
||||
|
||||
@Autowired
|
||||
private EbTableMonitorService ebTableMonitorService;
|
||||
|
||||
@GetMapping("/getData")
|
||||
public WeaResult<List<HrKpiFlowPO>> getData() {
|
||||
return WeaResult.success(ebTableMonitorService.getData());
|
||||
}
|
||||
|
||||
@GetMapping("/buildEbData")
|
||||
public WeaResult<List<EbTableMonitorPO>> buildEbData() {
|
||||
return WeaResult.success(ebTableMonitorService.buildEbData());
|
||||
}
|
||||
|
||||
@GetMapping("/deleteEbData")
|
||||
public WeaResult<Integer> deleteEbData(@QueryParam("pfid") String pfid) {
|
||||
return WeaResult.success(ebTableMonitorService.deleteEbData(pfid));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package com.weaver.seconddev.xianghui.performance.cron;
|
||||
|
||||
import com.weaver.common.distribution.genid.IdGenerator;
|
||||
import com.weaver.common.escheduler.handler.annotation.ESchedulerHandler;
|
||||
import com.weaver.seconddev.xianghui.performance.entity.po.EbTableMonitorPO;
|
||||
import com.weaver.seconddev.xianghui.performance.mapper.EbTableMonitorMapper;
|
||||
import com.weaver.seconddev.xianghui.performance.service.EbTableMonitorService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service
|
||||
public class EbTableInsertEscheduler {
|
||||
|
||||
@Autowired
|
||||
private EbTableMonitorService ebTableMonitorService;
|
||||
|
||||
@Autowired
|
||||
private EbTableMonitorMapper ebTableMonitorMapper;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(EbTableInsertEscheduler.class);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* value: 业务方法的执行名称
|
||||
* cron: cron表达式自定义执行时间
|
||||
* @throws Exception
|
||||
*/
|
||||
@ESchedulerHandler(value = "EbTableInsertHander", cron = "0/10 * * * * ?")
|
||||
public void ebTableInsertHander() throws Exception {
|
||||
try {
|
||||
|
||||
List<EbTableMonitorPO> ebTableMonitorPOS = ebTableMonitorService.buildEbData();
|
||||
ebTableMonitorPOS.forEach(item -> {
|
||||
boolean isExsit = ebTableMonitorMapper.existsByPfid(item.getPfid(),item.getTenantKey());
|
||||
if (isExsit) {
|
||||
//更新
|
||||
ebTableMonitorMapper.updateByPfid(item);
|
||||
}else {
|
||||
// 使用新的ID生成器
|
||||
Long idNext = IdGenerator.generate();
|
||||
item.setId(idNext);
|
||||
item.setFormDataId(idNext);
|
||||
ebTableMonitorMapper.insert(item);
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("demoJobHandler runnint error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
package com.weaver.seconddev.xianghui.performance.entity.bo;
|
||||
|
||||
import com.weaver.common.distribution.genid.IdGenerator;
|
||||
import com.weaver.common.hrm.cache.HrmDepartmentComInfo;
|
||||
import com.weaver.common.hrm.util.StringUtils;
|
||||
import com.weaver.common.hrm.util.Util;
|
||||
import com.weaver.common.i18n.tool.util.I18nContextUtil;
|
||||
import com.weaver.seconddev.xianghui.performance.entity.po.EbTableMonitorPO;
|
||||
import com.weaver.seconddev.xianghui.performance.entity.po.EmployeePO;
|
||||
import com.weaver.seconddev.xianghui.performance.entity.po.HrKpiFlowPO;
|
||||
import com.weaver.seconddev.xianghui.performance.mapper.HrKpiFlowMapper;
|
||||
import com.weaver.seconddev.xianghui.performance.service.EbTableMonitorService;
|
||||
import com.weaver.verupgrade.conn.CONN_TYPE;
|
||||
import com.weaver.verupgrade.conn.RecordSet;
|
||||
import com.weaver.workflow.common.cfg.org.service.DepartMentService;
|
||||
import com.weaver.workflow.common.constant.org.WeaDeptPathLevel;
|
||||
import com.weaver.workflow.common.entity.org.WeaDepartMent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/6/11 11:21
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Component
|
||||
public class EbTableMonitorBO {
|
||||
|
||||
@Autowired
|
||||
private HrKpiFlowMapper hrKpiFlowMapper;
|
||||
|
||||
@Autowired
|
||||
private DepartMentService departMentService;
|
||||
|
||||
@Autowired
|
||||
private EbTableMonitorService ebTableMonitorService;
|
||||
|
||||
|
||||
public List<EbTableMonitorPO> convertToEbTableMonitor(List<HrKpiFlowPO> hrKpiFlows) {
|
||||
|
||||
EmployeePO employeePO = selectEmployee();
|
||||
return hrKpiFlows.stream()
|
||||
.map(hrKpiFlow -> {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
|
||||
String formattedDate = hrKpiFlow.getRealPeriod() != null
|
||||
? sdf.format(hrKpiFlow.getRealPeriod())
|
||||
: null;
|
||||
WeaDepartMent weaDepartMent = departMentService.getDepartMentById(hrKpiFlow.getDepartmentId());
|
||||
String deptPath = departMentService.getDeptPath(hrKpiFlow.getDepartmentId(), WeaDeptPathLevel.DEPT_ALL_LEVEL, ">", employeePO.getTenantKey());
|
||||
if (StringUtils.isNotBlank(deptPath)) {
|
||||
deptPath = deptPath + ">" + weaDepartMent.getDepartMentName();
|
||||
} else {
|
||||
deptPath = weaDepartMent.getDepartMentName();
|
||||
}
|
||||
|
||||
return EbTableMonitorPO.builder()
|
||||
// 基础字段
|
||||
.dataIndex(0)
|
||||
.isFlow(0)
|
||||
.dataStatus(1)
|
||||
.createTime(new Date())
|
||||
.updateTime(new Date())
|
||||
.tenantKey(employeePO.getTenantKey())
|
||||
.creator(employeePO.getId())
|
||||
.updater(employeePO.getId())
|
||||
.deleteType(0)
|
||||
.ftStatus(0)
|
||||
|
||||
// 自定义字段
|
||||
.pfid(String.valueOf(hrKpiFlow.getId()))
|
||||
.khmc(hrKpiFlow.getName())
|
||||
.khzq(hrKpiFlow.getDateType())
|
||||
.khdx(hrKpiFlow.getKpiUser())
|
||||
.pfzq(hrKpiFlow.getRealPeriod())
|
||||
.dqjd(hrKpiFlow.getFlowStatus())
|
||||
.dclr(getPengdingPerson(hrKpiFlow,employeePO.getTenantKey()))
|
||||
.fbsj(hrKpiFlow.getCreateTime())
|
||||
.bm(hrKpiFlow.getDepartmentId())
|
||||
.qljbm(deptPath)
|
||||
.zq(formattedDate)
|
||||
.df(hrKpiFlow.getScore())
|
||||
.xs(ebTableMonitorService.buildScoreCoefficient(hrKpiFlow,employeePO.getTenantKey()))
|
||||
.build();
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
public String getPengdingPerson(HrKpiFlowPO hrKpiFlowPO,String tenantKey){
|
||||
if ("frozen".equals(hrKpiFlowPO.getFlowStatus())){
|
||||
return "";
|
||||
}
|
||||
List<Long> operatorsByStepId = hrKpiFlowMapper.findOperatorsByStepId(hrKpiFlowPO.getKpiCurrentStep(), tenantKey);
|
||||
|
||||
return operatorsByStepId.stream()
|
||||
.distinct()
|
||||
.map(String::valueOf)
|
||||
.collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
public EmployeePO selectEmployee(){
|
||||
//todo 如果sysadmin名称会变 后续用配置文件id
|
||||
RecordSet rs = I18nContextUtil.getBean(RecordSet.class);
|
||||
String poolname = CONN_TYPE.hrm.getType();
|
||||
EmployeePO employeePO = new EmployeePO();
|
||||
String sql = "select id,tenant_key from eteams.employee where username = 'sysadmin'";
|
||||
rs.executeSql(sql,poolname);
|
||||
if (rs.next()){
|
||||
employeePO.setId(Util.getLongValue(rs.getString("id")));
|
||||
employeePO.setTenantKey(Util.null2String(rs.getString("tenant_key")));
|
||||
}
|
||||
return employeePO;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
package com.weaver.seconddev.xianghui.performance.entity.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/6/10 16:35
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("uf_jxcx")
|
||||
public class EbTableMonitorPO {
|
||||
|
||||
/**
|
||||
* eb表单基础字段
|
||||
*/
|
||||
private Long id;
|
||||
private Long formDataId;
|
||||
private Integer dataIndex;
|
||||
private Integer isFlow;
|
||||
private Integer dataStatus;
|
||||
private Date createTime;
|
||||
private Date updateTime;
|
||||
private String tenantKey;
|
||||
private Long creator;
|
||||
private Long updater;
|
||||
private Integer deleteType;
|
||||
private Integer ftStatus;
|
||||
|
||||
/**
|
||||
* 自定义字段
|
||||
*/
|
||||
private String pfid;
|
||||
private String khmc;
|
||||
private String khzq;
|
||||
private Date pfzq;
|
||||
private Long khdx;
|
||||
private Long bm;
|
||||
private String dqjd;
|
||||
private String dclr;
|
||||
private Date fbsj;
|
||||
private String qljbm;
|
||||
/**
|
||||
* 评分周期截取字段 2025-06
|
||||
*/
|
||||
private String zq;
|
||||
private BigDecimal df;
|
||||
private BigDecimal xs;
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
package com.weaver.seconddev.xianghui.performance.entity.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/6/10 16:35
|
||||
* @Version 1.0
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("uf_jxdfxs")
|
||||
public class EbTableScoreCoefficientPO {
|
||||
|
||||
/**
|
||||
* eb表单基础字段
|
||||
*/
|
||||
private Long id;
|
||||
private Long formDataId;
|
||||
private Integer dataIndex;
|
||||
private Integer isFlow;
|
||||
private Integer dataStatus;
|
||||
private Date createTime;
|
||||
private Date updateTime;
|
||||
private String tenantKey;
|
||||
private Long creator;
|
||||
private Long updater;
|
||||
private Integer deleteType;
|
||||
private Integer ftStatus;
|
||||
|
||||
/**
|
||||
* 自定义字段
|
||||
*/
|
||||
private Long bm;
|
||||
private Date nf;
|
||||
private BigDecimal zxfs;
|
||||
private BigDecimal zdfs;
|
||||
private String pfxs;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.weaver.seconddev.xianghui.performance.entity.po;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/6/11 14:52
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class EmployeePO {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String tenantKey;
|
||||
|
||||
private String username;
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
package com.weaver.seconddev.xianghui.performance.entity.po;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/6/10 16:46
|
||||
* @Description: 评分
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class HrKpiFlowPO {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 考核对象
|
||||
*/
|
||||
private Long kpiUser;
|
||||
|
||||
/**
|
||||
* 评分名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 当前步骤id
|
||||
*/
|
||||
private Long kpiCurrentStep;
|
||||
|
||||
|
||||
/**
|
||||
* 考核周期
|
||||
*/
|
||||
private String dateType;
|
||||
|
||||
/**
|
||||
* 当前阶段
|
||||
*/
|
||||
private String flowStatus;
|
||||
|
||||
/**
|
||||
* 评分周期
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date realPeriod;
|
||||
|
||||
/**
|
||||
* 待处理人
|
||||
*/
|
||||
private String pendingPerson;
|
||||
|
||||
|
||||
/**
|
||||
* 发布时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
|
||||
/**
|
||||
* 部门
|
||||
*/
|
||||
private Long departmentId;
|
||||
|
||||
/**
|
||||
* 分数
|
||||
*/
|
||||
private BigDecimal score;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.weaver.seconddev.xianghui.performance.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.weaver.seconddev.xianghui.performance.entity.po.EbTableMonitorPO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface EbTableMonitorMapper extends BaseMapper<EbTableMonitorPO> {
|
||||
|
||||
boolean existsByPfid(@Param("pfid") String pfid, @Param("tenantKey") String tenantKey);
|
||||
void deleteByPfid(@Param("pfid") String pfid, @Param("tenantKey") String tenantKey);
|
||||
|
||||
int updateByPfid(@Param("record") EbTableMonitorPO record);
|
||||
|
||||
int insert(@Param("record") EbTableMonitorPO record);
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.weaver.seconddev.xianghui.performance.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.weaver.seconddev.xianghui.performance.entity.po.EbTableScoreCoefficientPO;
|
||||
import com.weaver.seconddev.xianghui.performance.entity.po.HrKpiFlowPO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface EbTableScoreCoefficientMapper extends BaseMapper<EbTableScoreCoefficientPO> {
|
||||
|
||||
List<EbTableScoreCoefficientPO> selectScoreCoefficient(@Param("hrKpiFlowPO") HrKpiFlowPO hrKpiFlowPO,@Param("year") String year,@Param("tenantKey") String tenantKey);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.weaver.seconddev.xianghui.performance.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.weaver.seconddev.xianghui.performance.entity.po.HrKpiFlowPO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface HrKpiFlowMapper extends BaseMapper<HrKpiFlowPO> {
|
||||
|
||||
List<HrKpiFlowPO> selectHrKpiFlowList(@Param("tenantKey")String tenantKey,@Param("startDate") Date startDate,
|
||||
@Param("endDate") Date endDate);
|
||||
|
||||
List<Long> findOperatorsByStepId(@Param("stepId") Long stepId, @Param("tenantKey") String tenantKey);
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package com.weaver.seconddev.xianghui.performance.service;
|
||||
|
||||
import com.weaver.seconddev.xianghui.performance.entity.po.EbTableMonitorPO;
|
||||
import com.weaver.seconddev.xianghui.performance.entity.po.HrKpiFlowPO;
|
||||
|
||||
import com.weaver.framework.rpc.context.impl.TenantRpcContext;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/6/10 11:40
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
public interface EbTableMonitorService {
|
||||
|
||||
List<HrKpiFlowPO> getData();
|
||||
|
||||
List<EbTableMonitorPO> buildEbData();
|
||||
|
||||
int deleteEbData(String pfid);
|
||||
|
||||
BigDecimal buildScoreCoefficient(HrKpiFlowPO hrKpiFlowPO,String tenantKey);
|
||||
|
||||
/**
|
||||
* 获取租户
|
||||
*/
|
||||
default String getTenantKey() {
|
||||
return TenantRpcContext.getCurrentTenantKey();
|
||||
}
|
||||
|
||||
default String getCurrentUserId() {
|
||||
return TenantRpcContext.getCurrentEmployeeId();
|
||||
}
|
||||
|
||||
default Long getCurrentUserIdLong() {
|
||||
return TenantRpcContext.getEmployeeIdLong();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
package com.weaver.seconddev.xianghui.performance.service.impl;
|
||||
|
||||
import com.weaver.seconddev.xianghui.performance.entity.bo.EbTableMonitorBO;
|
||||
import com.weaver.seconddev.xianghui.performance.entity.po.EbTableMonitorPO;
|
||||
import com.weaver.seconddev.xianghui.performance.entity.po.EbTableScoreCoefficientPO;
|
||||
import com.weaver.seconddev.xianghui.performance.entity.po.EmployeePO;
|
||||
import com.weaver.seconddev.xianghui.performance.entity.po.HrKpiFlowPO;
|
||||
import com.weaver.seconddev.xianghui.performance.mapper.EbTableMonitorMapper;
|
||||
import com.weaver.seconddev.xianghui.performance.mapper.EbTableScoreCoefficientMapper;
|
||||
import com.weaver.seconddev.xianghui.performance.mapper.HrKpiFlowMapper;
|
||||
import com.weaver.seconddev.xianghui.performance.service.EbTableMonitorService;
|
||||
import com.weaver.teams.security.context.UserContext;
|
||||
import com.weaver.teams.security.user.User;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.weaver.teams.security.DateUtils.clearTime;
|
||||
import static com.weaver.teams.security.DateUtils.setTimeToEndOfDay;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/6/10 11:40
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Service
|
||||
public class EbTableMonitorServiceImpl implements EbTableMonitorService {
|
||||
|
||||
@Autowired
|
||||
private HrKpiFlowMapper hrKpiFlowMapper;
|
||||
|
||||
@Autowired
|
||||
private EbTableMonitorMapper ebTableMonitorMapper;
|
||||
|
||||
@Autowired
|
||||
private EbTableScoreCoefficientMapper ebTableScoreCoefficientMapper;
|
||||
|
||||
@Autowired
|
||||
private EbTableMonitorBO ebTableMonitorBO;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(EbTableMonitorServiceImpl.class);
|
||||
|
||||
|
||||
@Override
|
||||
public List<HrKpiFlowPO> getData() {
|
||||
|
||||
// User currentUser = UserContext.getCurrentUser();
|
||||
// String tenantKey1 = currentUser.getTenantKey();
|
||||
EmployeePO employeePO = ebTableMonitorBO.selectEmployee();
|
||||
String tenantKey = employeePO.getTenantKey();
|
||||
return hrKpiFlowMapper.selectHrKpiFlowList(tenantKey,getFirstDayOfCurrentYear(),getLastDayOfCurrentYear());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EbTableMonitorPO> buildEbData() {
|
||||
List<HrKpiFlowPO> data = getData();
|
||||
return ebTableMonitorBO.convertToEbTableMonitor(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteEbData(String pfid) {
|
||||
User currentUser = UserContext.getCurrentUser();
|
||||
String tenantKey = currentUser.getTenantKey();
|
||||
ebTableMonitorMapper.deleteByPfid(pfid,tenantKey);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal buildScoreCoefficient(HrKpiFlowPO hrKpiFlowPO,String tenantKey) {
|
||||
String year = "";
|
||||
if (hrKpiFlowPO.getRealPeriod() != null) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
|
||||
year = sdf.format(hrKpiFlowPO.getRealPeriod());
|
||||
}
|
||||
List<EbTableScoreCoefficientPO> coefficientPOList = ebTableScoreCoefficientMapper.selectScoreCoefficient(hrKpiFlowPO, year, tenantKey);
|
||||
EbTableScoreCoefficientPO coefficientPO = coefficientPOList.stream()
|
||||
.max(Comparator.comparingLong(EbTableScoreCoefficientPO::getId))
|
||||
.orElse(null);
|
||||
|
||||
if (coefficientPO == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String pfxs = coefficientPO.getPfxs();
|
||||
if (pfxs == null) {return null;}
|
||||
|
||||
if (pfxs.trim().contains("实际绩效得分/100") ) {
|
||||
return Optional.ofNullable(hrKpiFlowPO.getScore())
|
||||
.map(score -> score.divide(new BigDecimal(100), 2, RoundingMode.HALF_UP))
|
||||
.orElse(null);
|
||||
}else {
|
||||
try {
|
||||
return new BigDecimal(pfxs);
|
||||
} catch (NumberFormatException e) {
|
||||
log.error("无效的pfxs数值格式: {}", pfxs+"--->"+hrKpiFlowPO.getScore());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Date getFirstDayOfCurrentYear() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(Calendar.DAY_OF_YEAR, 1); // 设为当年第一天
|
||||
return clearTime(cal.getTime()); // 时间清零:00:00:00
|
||||
}
|
||||
|
||||
private Date getLastDayOfCurrentYear() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(Calendar.MONTH, 11); // 12月(注意Calendar.MONTH从0开始)
|
||||
cal.set(Calendar.DAY_OF_MONTH, 31); // 31号
|
||||
return setTimeToEndOfDay(cal.getTime()); // 时间设为:23:59:59
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
<?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.weaver.seconddev.xianghui.performance.mapper.EbTableMonitorMapper">
|
||||
|
||||
<select id="existsByPfid" resultType="boolean">
|
||||
SELECT COUNT(1) > 0
|
||||
FROM uf_jxcx
|
||||
WHERE pfid = #{pfid}
|
||||
AND tenant_key = #{tenantKey}
|
||||
AND delete_type = 0
|
||||
</select>
|
||||
|
||||
<update id="updateByPfid">
|
||||
UPDATE uf_jxcx
|
||||
SET
|
||||
<!-- 基础字段 -->
|
||||
update_time = #{record.updateTime},
|
||||
|
||||
<!-- 自定义字段 -->
|
||||
khmc = #{record.khmc},
|
||||
khzq = #{record.khzq},
|
||||
pfzq = #{record.pfzq},
|
||||
khdx = #{record.khdx},
|
||||
bm = #{record.bm},
|
||||
dqjd = #{record.dqjd},
|
||||
dclr = #{record.dclr},
|
||||
fbsj = #{record.fbsj},
|
||||
qljbm = #{record.qljbm},
|
||||
zq = #{record.zq},
|
||||
df=#{record.df},
|
||||
xs=#{record.xs}
|
||||
WHERE
|
||||
pfid = #{record.pfid}
|
||||
AND tenant_key = #{record.tenantKey}
|
||||
AND delete_type = 0
|
||||
</update>
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO uf_jxcx (
|
||||
<!-- 基础字段 -->
|
||||
id,
|
||||
form_data_id,
|
||||
data_index,
|
||||
is_flow,
|
||||
data_status,
|
||||
create_time,
|
||||
update_time,
|
||||
tenant_key,
|
||||
creator,
|
||||
updater,
|
||||
delete_type,
|
||||
ft_status,
|
||||
|
||||
<!-- 自定义字段 -->
|
||||
pfid,
|
||||
khmc,
|
||||
khzq,
|
||||
pfzq,
|
||||
khdx,
|
||||
bm,
|
||||
dqjd,
|
||||
dclr,
|
||||
fbsj,
|
||||
qljbm,
|
||||
zq,
|
||||
df,
|
||||
xs
|
||||
) VALUES (
|
||||
#{record.id},
|
||||
#{record.formDataId},
|
||||
#{record.dataIndex},
|
||||
#{record.isFlow},
|
||||
#{record.dataStatus},
|
||||
#{record.createTime},
|
||||
#{record.updateTime},
|
||||
#{record.tenantKey},
|
||||
#{record.creator},
|
||||
#{record.updater},
|
||||
#{record.deleteType},
|
||||
#{record.ftStatus},
|
||||
|
||||
#{record.pfid},
|
||||
#{record.khmc},
|
||||
#{record.khzq},
|
||||
#{record.pfzq},
|
||||
#{record.khdx},
|
||||
#{record.bm},
|
||||
#{record.dqjd},
|
||||
#{record.dclr},
|
||||
#{record.fbsj},
|
||||
#{record.qljbm},
|
||||
#{record.zq},
|
||||
#{record.df},
|
||||
#{record.xs}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="deleteByPfid">
|
||||
UPDATE uf_jxcx SET delete_type = 3
|
||||
WHERE pfid = #{pfid}
|
||||
AND tenant_key = #{tenantKey}
|
||||
AND delete_type = 0
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?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.weaver.seconddev.xianghui.performance.mapper.EbTableScoreCoefficientMapper">
|
||||
|
||||
<resultMap id="hrKpiFlowResultMap" type="com.weaver.seconddev.xianghui.performance.entity.po.EbTableScoreCoefficientPO">
|
||||
<id property="id" column="id"/>
|
||||
<result property="zxfs" column="zxfs"/>
|
||||
<result property="zdfs" column="zdfs"/>
|
||||
<result property="pfxs" column="pfxs"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectScoreCoefficient" resultMap="hrKpiFlowResultMap">
|
||||
SELECT
|
||||
id,
|
||||
zxfs,
|
||||
zdfs,
|
||||
pfxs
|
||||
FROM
|
||||
uf_jxdfxs
|
||||
WHERE
|
||||
delete_type = 0
|
||||
AND TENANT_KEY = #{tenantKey}
|
||||
AND bm = #{hrKpiFlowPO.departmentId}
|
||||
AND nf = #{year}
|
||||
AND zxfs <= #{hrKpiFlowPO.score}
|
||||
AND zdfs >= #{hrKpiFlowPO.score}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
<?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.weaver.seconddev.xianghui.performance.mapper.HrKpiFlowMapper">
|
||||
|
||||
<resultMap id="hrKpiFlowResultMap" type="com.weaver.seconddev.xianghui.performance.entity.po.HrKpiFlowPO">
|
||||
<id property="id" column="id"/>
|
||||
<result property="kpiUser" column="KPI_USER"/>
|
||||
<result property="name" column="NAME"/>
|
||||
<result property="kpiCurrentStep" column="kpi_current_step"/>
|
||||
<result property="dateType" column="DATE_TYPE"/>
|
||||
<result property="flowStatus" column="flow_status"/>
|
||||
<result property="realPeriod" column="REAL_PERIOD"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="departmentId" column="department"/>
|
||||
<result property="score" column="score"/>
|
||||
<!-- 未查询的字段不需要映射,会自动为null -->
|
||||
</resultMap>
|
||||
|
||||
<select id="selectHrKpiFlowList" resultMap="hrKpiFlowResultMap">
|
||||
SELECT
|
||||
hkf.id,
|
||||
hkf.KPI_USER,
|
||||
hkf.NAME,
|
||||
hkf.kpi_current_step,
|
||||
hkf.DATE_TYPE,
|
||||
hkf.score,
|
||||
CASE
|
||||
WHEN hkf.flow_status IN ('noScore', 'noApprove')
|
||||
THEN 'scoreOverTime'
|
||||
ELSE hkf.flow_status
|
||||
END AS flow_status,
|
||||
hkf.create_time,
|
||||
hkf.REAL_PERIOD,
|
||||
CASE
|
||||
WHEN d.id = sub.id AND sub.id IS NOT NULL
|
||||
THEN NULL
|
||||
ELSE d.id
|
||||
END AS department
|
||||
FROM
|
||||
HR_KPI_FLOW hkf
|
||||
JOIN
|
||||
eteams.employee e ON hkf.kpi_user = e.id
|
||||
LEFT JOIN
|
||||
eteams.department d ON e.department = d.id
|
||||
LEFT JOIN
|
||||
eteams.department sub ON d.subcompanyid = sub.id
|
||||
WHERE
|
||||
hkf.delete_type = 0
|
||||
AND hkf.TENANT_KEY = #{tenantKey}
|
||||
AND hkf.REAL_PERIOD >= #{startDate}
|
||||
AND hkf.REAL_PERIOD <= #{endDate}
|
||||
</select>
|
||||
|
||||
<select id="findOperatorsByStepId" resultType="java.lang.Long">
|
||||
SELECT CASE WHEN hrfs.step_status='appeals' THEN Hkfo.complainant_User ELSE hkfo.OPERATER END AS OPERATER
|
||||
FROM hr_kpi_flow_step hrfs
|
||||
LEFT JOIN hr_kpi_flow_step hrfs2 ON hrfs.KPI_FLOW = hrfs2.KPI_FLOW
|
||||
and hrfs.STEP_TYPE = hrfs2.STEP_TYPE
|
||||
AND (
|
||||
(hrfs2.DISTRIBUTE_TYPE = hrfs.DISTRIBUTE_TYPE and (hrfs.next_step = hrfs2.next_step or (hrfs.next_step IS NULL
|
||||
AND hrfs2.next_step IS NULL)) and
|
||||
(hrfs2.STEP_STATUS = 'kpsing' or hrfs2.STEP_STATUS = 'kpsback'))
|
||||
or (
|
||||
hrfs2.STEP_STATUS = 'processing' or hrfs2.STEP_STATUS = 'back' or hrfs2.STEP_STATUS = 'appeals')
|
||||
)
|
||||
JOIN HR_KPI_FLOW_OPERATOR hkfo ON hkfo.KPI_FLOW_STEP = hrfs.id
|
||||
and hkfo.OPERATER is not null
|
||||
and hkfo.OPERATE_STATUS = 'opKpsStart'
|
||||
and hkfo.delete_type = 0
|
||||
and (hrfs.delete_type=0 or hrfs.delete_type is null)
|
||||
and (hrfs2.delete_type=0 or hrfs2.delete_type is null)
|
||||
and hkfo.TENANT_KEY = #{tenantKey}
|
||||
WHERE hrfs.id = #{stepId}
|
||||
and hrfs.TENANT_KEY = #{tenantKey}
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT CASE WHEN hrfs2.step_status='appeals' THEN Hkfo.complainant_User ELSE hkfo.OPERATER END AS OPERATER
|
||||
FROM hr_kpi_flow_step hrfs
|
||||
LEFT JOIN hr_kpi_flow_step hrfs2 ON hrfs.KPI_FLOW = hrfs2.KPI_FLOW
|
||||
and hrfs.STEP_TYPE = hrfs2.STEP_TYPE
|
||||
AND ((hrfs2.DISTRIBUTE_TYPE = hrfs.DISTRIBUTE_TYPE and (hrfs.next_step = hrfs2.next_step or (hrfs.next_step IS
|
||||
NULL AND hrfs2.next_step IS NULL)) and
|
||||
(hrfs2.STEP_STATUS = 'kpsing' or hrfs2.STEP_STATUS = 'kpsback'))
|
||||
or (
|
||||
hrfs2.STEP_STATUS = 'processing' or hrfs2.STEP_STATUS = 'back' or hrfs2.STEP_STATUS = 'appeals')
|
||||
)
|
||||
JOIN HR_KPI_FLOW_OPERATOR hkfo ON hkfo.KPI_FLOW_STEP = hrfs2.id
|
||||
and hkfo.OPERATER is not null
|
||||
and hkfo.OPERATE_STATUS = 'opKpsStart'
|
||||
and hkfo.delete_type = 0
|
||||
and (hrfs.delete_type=0 or hrfs.delete_type is null)
|
||||
and (hrfs2.delete_type=0 or hrfs2.delete_type is null)
|
||||
and hkfo.TENANT_KEY = #{tenantKey}
|
||||
WHERE hrfs.id = #{stepId}
|
||||
and hrfs.TENANT_KEY = #{tenantKey}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue