Compare commits

...

2 Commits

Author SHA1 Message Date
方亮 b112bc16e8 入场,出场,合同,工资优化 2025-08-17 10:25:37 +08:00
方亮 5920e8c1b2 人员入场单日记录job 2025-08-17 10:25:00 +08:00
9 changed files with 287 additions and 28 deletions

View File

@ -57,5 +57,10 @@ public class PmWorkerDto {
*/
private Integer workerId;
/**
* 是否上传离职文件 0未上传 1已上传
*/
private String isUploadFile;
}

View File

@ -32,7 +32,7 @@ public interface PmWorkerExitMapper {
* @param einStatus
* @return
*/
int updateEinProRecordStatus(@Param("workerId") Integer id,@Param("einStatus") Integer einStatus,@Param("isUploadFile") Integer isUploadFile);
int updateEinProRecordStatus(@Param("id") Integer id,@Param("einStatus") Integer einStatus,@Param("isUploadFile") Integer isUploadFile);
List<PmWorker> selectWorkListByWorkerId(PmWorkerDto o);
}

View File

@ -10,6 +10,7 @@ import com.bonus.bmw.service.BmWorkerWageCardService;
import com.bonus.common.core.constant.Constants;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.system.api.model.LoginUser;
import com.bonus.system.api.model.UploadFileVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -40,6 +41,7 @@ public class BmWorkerWageCardServiceImpl implements BmWorkerWageCardService {
public int updateByPrimaryKey(BmWorkerWageCard record, List<WebFileDto> listFile) {
//存在则删除后新增不存在则新增
if(record.getId() != null){
LoginUser loginUser = SecurityUtils.getLoginUser();
if(record.getDelIds() != null){
//修改时删除部分图片
String[] split = record.getDelIds().split(",");
@ -59,7 +61,7 @@ public class BmWorkerWageCardServiceImpl implements BmWorkerWageCardService {
return 1;
}else{
//新增
record.setCreateUser(SecurityUtils.getUsername());
record.setCreateUser(SecurityUtils.getLoginUser().getUsername());
int insert = mapper.insert(record);
//添加到文件库和minio上
if(insert > 0){

View File

@ -29,6 +29,11 @@ public class PmWorkerExitServiceImpl implements PmWorkerExitService {
@Override
public List<PmWorker> selectWorkList(PmWorkerDto o) {
// List<PmWorker> pmWorkers = mapper.selectWorkList(o);
// pmWorkers.forEach(pmWorker -> {
// List<UploadFileVo> contractFile = fileUploadUtils.getFileList("", pmWorker.getId().toString(), Constants.FILE_UPLOAD_WORKER_EXIT, "");
// pmWorker.setFiles(contractFile);
// });
return mapper.selectWorkList(o);
}
@ -41,16 +46,20 @@ public class PmWorkerExitServiceImpl implements PmWorkerExitService {
//修改在场记录表状态
int einStatus = 2;
//是否上传文件
int isUploadFile = 1;
int k = mapper.updateEinProRecordStatus(record.getId(),einStatus,isUploadFile);
//组装数据
MultipartFile[] workerFiles = new MultipartFile[listFile.size()];
String[] type = new String[listFile.size()];
for (int i = 0; i < listFile.size(); i++) {
workerFiles[i] = listFile.get(i).getFile();
type[i] = listFile.get(i).getType();
int isUploadFile = 0;
if(!listFile.isEmpty()){
//组装数据
MultipartFile[] workerFiles = new MultipartFile[listFile.size()];
String[] type = new String[listFile.size()];
for (int i = 0; i < listFile.size(); i++) {
workerFiles[i] = listFile.get(i).getFile();
type[i] = listFile.get(i).getType();
}
List<UploadFileVo> uploadFileVos = fileUploadUtils.uploadFile(workerFiles, Constants.FILE_UPLOAD_WORKER_EXIT, record.getId().toString(), type,"", "");
isUploadFile = 1;
}
List<UploadFileVo> uploadFileVos = fileUploadUtils.uploadFile(workerFiles, Constants.FILE_UPLOAD_WORKER_EXIT, record.getId().toString(), type,"", "");
int k = mapper.updateEinProRecordStatus(record.getId(),einStatus,isUploadFile);
return k;
}
@ -85,19 +94,22 @@ public class PmWorkerExitServiceImpl implements PmWorkerExitService {
public int exitFile(PmWorkerDto o, List<WebFileDto> listFile) {
//删除文件
fileUploadUtils.delFileListById("", o.getId().toString(), Constants.FILE_UPLOAD_WORKER_EXIT,"");
//录入文件
MultipartFile[] workerFiles = new MultipartFile[listFile.size()];
String[] type = new String[listFile.size()];
for (int i = 0; i < listFile.size(); i++) {
workerFiles[i] = listFile.get(i).getFile();
type[i] = listFile.get(i).getType();
if(!listFile.isEmpty()){
//录入文件
MultipartFile[] workerFiles = new MultipartFile[listFile.size()];
String[] type = new String[listFile.size()];
for (int i = 0; i < listFile.size(); i++) {
workerFiles[i] = listFile.get(i).getFile();
type[i] = listFile.get(i).getType();
}
List<UploadFileVo> uploadFileVos = fileUploadUtils.uploadFile(workerFiles, Constants.FILE_UPLOAD_WORKER_EXIT, o.getId().toString(), type,"", "");
int einStatus = 0;
//是否上传文件
int isUploadFile = 1;
int k = mapper.updateEinProRecordStatus(o.getId(),einStatus,isUploadFile);
return !uploadFileVos.isEmpty() ?1:0;
}
List<UploadFileVo> uploadFileVos = fileUploadUtils.uploadFile(workerFiles, Constants.FILE_UPLOAD_WORKER_EXIT, o.getId().toString(), type,"", "");
int einStatus = 0;
//是否上传文件
int isUploadFile = 0;
int k = mapper.updateEinProRecordStatus(o.getId(),einStatus,isUploadFile);
return !uploadFileVos.isEmpty() ?1:0;
return 0;
}
@Override

View File

@ -28,7 +28,7 @@
pw.`name`,
pw.id_number,
pw.phone,
bwepr.id,
bwepr.id,
bwepr.pro_id,
bwepr.pro_name,
bwepr.sub_id,
@ -45,7 +45,6 @@
FROM
pm_worker pw
LEFT JOIN bm_worker_ein_pro_record bwepr ON pw.id = bwepr.worker_id
AND bwepr.is_active = 1
WHERE
pw.is_active = 1 And bwepr.is_last = 1
<if test="name != null and name != ''">
@ -72,6 +71,9 @@
<if test="einStatus != null and einStatus != ''">
AND bwepr.ein_status = #{einStatus}
</if>
<if test="isUploadFile != null and isUploadFile != ''">
AND bwepr.is_upload_file = #{isUploadFile}
</if>
</select>
<delete id="deleteEinMsgByWorkerId">
@ -79,11 +81,12 @@
</delete>
<update id="updateEinProRecordStatus">
UPDATE bm_worker_ein_pro_record SET is_upload_file = #{isUploadFile}
UPDATE bm_worker_ein_pro_record SET is_upload_file = #{isUploadFile},is_active = 0
<if test='einStatus != 0'>
, ein_status = #{einStatus}
, exit_time = NOW()
</if>
WHERE worker_id = #{workerId}
WHERE id = #{id}
</update>
<select id="selectWorkListByWorkerId" resultMap="BaseResultMap">
@ -91,12 +94,14 @@
bwepr.id,
bwepr.worker_id,
pw.`name`,
bwepr.pro_name,
bwepr.pro_name,
bwepr.sub_name,
bwepr.team_name,
bwepr.post_name,
bwepr.ein_time,
bwepr.ein_status,
bwepr.is_upload_file,
if(is_upload_file=0,DATEDIFF(NOW(), exit_time),0) as days_since_exit,
bwepr.exit_time
FROM
pm_worker pw

View File

@ -0,0 +1,77 @@
package com.bonus.job.domain;
import com.bonus.common.core.annotation.Excel;
import com.bonus.system.api.model.UploadFileVo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* 人员基础信息表
*/
@Data
public class PmWorkerJob {
/**
* 施工人员id
*/
private String workerId;
/**
* 姓名
*/
private String name;
/**
* 身份证
*/
private String idNumber;
/**
* 入场状态 0未入场 1 已入场
*/
private Integer einStatus;
/**
* 项目名称
*/
private Integer proId;
/**
* 项目名称
*/
private String proName;
/**
* 分包名称
*/
private Integer subId;
/**
* 分包名称
*/
private String subName;
/**
* 班组名称
*/
private Integer teamId;
/**
* 班组名称
*/
private String teamName;
/**
* 创建时间
*/
private Integer contractId;
/**
* 日期
*/
private String einDay;
/**
* 月份
*/
private String attMonth;
}

View File

@ -0,0 +1,27 @@
package com.bonus.job.mapper;
import com.bonus.job.domain.PmWorkerJob;
import com.bonus.job.domain.SysJob;
import com.bonus.system.api.domain.SysUser;
import java.util.List;
/**
* 调度任务信息 数据层
*
* @author bonus
*/
public interface WorkerJobMapper {
/**
* 获取人员入场记录
* @param currentDay
* @return
*/
List<PmWorkerJob> getWorkerEinDayRecord(String currentDay);
/**
* 批量插入人员入场记录
* @param workerList
*/
void insertEinDayRecord(List<PmWorkerJob> workerList);
}

View File

@ -0,0 +1,73 @@
package com.bonus.job.task;
import cn.hutool.core.date.DateUtil;
import com.bonus.job.domain.PmWorkerJob;
import com.bonus.job.mapper.WorkerJobMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* 定时任务调度测试
*
* @author bonus
*/
@Component("workerEinDayTask")
public class WorkerEinDayRecordTask{
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
@Resource
private WorkerJobMapper mapper;
/**
* 不传更新当天
*/
public void updateEinDayRecord(){
try{
List<String> dateList = new ArrayList<>();
String startDate = DateUtil.today();
dateList.add(startDate);
//更新指定日期的记录
updateWorkerEinDayRecord(dateList);
}catch (Exception e){
logger.error("人员入场更新表失败,{}",e.getMessage());
}
}
private void updateWorkerEinDayRecord(List<String> dateList) {
for (String currentDay : dateList) {
List<PmWorkerJob> workerList = mapper.getWorkerEinDayRecord(currentDay);
if (!workerList.isEmpty()) {
mapper.insertEinDayRecord(workerList);
}
}
}
/**
* 固定更新期限
*/
public void updateEinDayRecordByRange(String startDate,String endDate){
try{
List<String> dateList = new ArrayList<>();
// startDate endDate 之间的时间加入 dateList
java.util.Date start = DateUtil.parse(startDate);
java.util.Date end = DateUtil.parse(endDate);
java.util.Date currentDate = start;
while (!currentDate.after(end)) {
dateList.add(DateUtil.format(currentDate, "yyyy-MM-dd"));
currentDate = DateUtil.offsetDay(currentDate, 1);
}
//更新指定日期的记录
updateWorkerEinDayRecord(dateList);
}catch (Exception e){
logger.error("人员入场更新表失败,{}",e.getMessage());
}
}
}

View File

@ -0,0 +1,58 @@
<?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.bonus.job.mapper.WorkerJobMapper">
<select id="getWorkerEinDayRecord" resultType="com.bonus.job.domain.PmWorkerJob">
SELECT
name,
id_number as idNumber,
worker_id as workerId,
pro_id as proId,
pro_name as proName,
sub_id as subId,
sub_name as subName,
team_id as teamId,
team_name as teamName,
contract_id as contractId,
ein_day as einDay,
DATE_FORMAT(ein_day, '%Y-%m') as attMonth
FROM
(
SELECT
pw.name,
pw.id_number,
bwepr.worker_id,
bwepr.pro_id,
bwepr.pro_name,
bwepr.sub_id,
bwepr.sub_name,
bwepr.team_id,
bwepr.team_name,
bwepr.contract_id,
#{currentDay} as ein_day
FROM
bm_worker_ein_pro_record bwepr
LEFT JOIN pm_worker pw ON pw.id = bwepr.worker_id
WHERE #{currentDay} BETWEEN DATE_FORMAT(bwepr.ein_time, '%Y-%m-%d') AND
DATE_FORMAT(IFNULL(bwepr.exit_time, NOW()), '%Y-%m-%d')
ORDER BY
bwepr.worker_id,
bwepr.ein_time DESC
LIMIT 10000000
) aa
GROUP BY
aa.worker_id
</select>
<insert id="insertEinDayRecord">
replace INTO bm_worker_ein_day_record(
worker_id,id_number,name,pro_id,pro_name,sub_id,sub_name,team_id,team_name,att_month,ein_day,contract_id
) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.workerId},#{item.idNumber},#{item.name},#{item.proId},#{item.proName},#{item.subId},#{item.subName},#{item.teamId},
#{item.teamName},#{item.attMonth},#{item.einDay},#{item.contractId}
)
</foreach>
</insert>
</mapper>