七天未打卡和一些导入导出

This commit is contained in:
方亮 2025-08-18 16:19:52 +08:00
parent 5830c60d9e
commit c396998300
18 changed files with 481 additions and 23 deletions

View File

@ -92,6 +92,26 @@ public class BmWorkerAttController extends BaseController {
return getDataTableError(new ArrayList<>());
}
/**
* 七日未打卡统计班组
* @param o
* @return
* , requiresPermissions = @RequiresPermissions("system:workerLight:list")
*/
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth(isUser = false))
@GetMapping("/getSevenNotAttListByTeam")
@SysLog(title = "七日未打卡统计(班组)", businessType = OperaType.QUERY, logType = 0, module = "施工人员->考勤管理->考勤统计", details = "七日未打卡统计(班组)")
public TableDataInfo getSevenNotAttListByTeam(BmWorkerAtt o) {
try {
startPage();
List<BmWorkerAtt> list = service.getSevenNotAttListByTeam(o);
return getDataTable(list);
} catch (Exception e) {
logger.error(e.toString(), e);
}
return getDataTableError(new ArrayList<>());
}
/**
* 查询列表-班组下人员列表
* @param o
@ -131,4 +151,7 @@ public class BmWorkerAttController extends BaseController {
}
return getDataTableError(new ArrayList<>());
}
}

View File

@ -10,10 +10,12 @@ import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import com.bonus.common.security.annotation.InnerAuth;
import com.bonus.common.security.annotation.RequiresPermissionsOrInnerAuth;
import com.bonus.common.security.utils.SecurityUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
@ -105,5 +107,23 @@ public class BmWorkerBlackController extends BaseController {
}
}
/**
* 导入数据
*/
@PostMapping("/workerBlackImport")
@SysLog(title = "失信人员导入", businessType = OperaType.IMPORT, logType = 0, module = "施工人员->红绿灯管理->失信人员管理", details = "失信人员导入")
public AjaxResult workerEinImport(MultipartFile file, boolean updateSupport) throws Exception {
try {
ExcelUtil<BmWorkerBlack> util = new ExcelUtil<>(BmWorkerBlack.class);
List<BmWorkerBlack> workerList = util.importExcel(file.getInputStream());
String message = service.importWorkerBlack(workerList, updateSupport);
return success(message);
} catch (Exception e) {
logger.error(e.toString(), e);
return error(e.getMessage());
}
}
}

View File

@ -18,6 +18,8 @@ import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import com.bonus.common.security.annotation.InnerAuth;
import com.bonus.common.security.annotation.RequiresPermissionsOrInnerAuth;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.system.api.domain.SysUser;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -195,5 +197,23 @@ public class PmWorkerController extends BaseController {
}
}
/**
* 导入数据
*/
@PostMapping("/workerEinImport")
@SysLog(title = "人员信息导入", businessType = OperaType.IMPORT, logType = 0, module = "施工人员->红绿灯管理->入场管理", details = "人员信息导入")
public AjaxResult workerEinImport(MultipartFile file, boolean updateSupport) throws Exception {
try {
ExcelUtil<PmWorker> util = new ExcelUtil<>(PmWorker.class);
List<PmWorker> workerList = util.importExcel(file.getInputStream());
String message = service.importWorker(workerList, updateSupport);
return success(message);
} catch (Exception e) {
logger.error(e.toString(), e);
return error(e.getMessage());
}
}
}

View File

@ -111,6 +111,11 @@ public class BmWorkerAtt {
*/
private String greenNum;
/**
* 班组数
*/
private Integer sevenNotAttNum;
/**
* 日期

View File

@ -26,49 +26,49 @@ public class BmWorkerBlack {
/**
* 身份证
*/
@Excel(name = "身份证号", type = Excel.Type.EXPORT, sort = 3)
@Excel(name = "身份证号", sort = 3)
private String idNumber;
/**
* 姓名
*/
@Excel(name = "姓名", type = Excel.Type.EXPORT, sort = 2)
@Excel(name = "姓名", sort = 2)
private String name;
/**
* 岗位
*/
@Excel(name = "岗位", type = Excel.Type.EXPORT, sort = 4)
@Excel(name = "工种", sort = 4)
private String postName;
/**
* 工程
*/
@Excel(name = "工程", type = Excel.Type.EXPORT, sort = 5)
@Excel(name = "工程名称", sort = 5)
private String proName;
/**
* 分包
*/
@Excel(name = "分包", type = Excel.Type.EXPORT, sort = 6)
@Excel(name = "所属分包单位", sort = 6)
private String subName;
/**
* 理由
*/
@Excel(name = "事件", type = Excel.Type.EXPORT, sort = 7)
@Excel(name = "事件", sort = 7)
private String reason;
/**
* 开始时间
*/
@Excel(name = "开始时间", type = Excel.Type.EXPORT, sort = 8)
@Excel(name = "开始时间", sort = 8)
private String startTime;
/**
* 结束时间
*/
@Excel(name = "结束时间", type = Excel.Type.EXPORT, sort = 9)
@Excel(name = "结束时间", sort = 9)
private String endTime;
/**

View File

@ -26,13 +26,13 @@ public class PmWorker {
/**
* 姓名
*/
@Excel(name = "姓名", type = Excel.Type.EXPORT, sort = 2)
@Excel(name = "姓名", sort = 2)
private String name;
/**
* 身份证
*/
@Excel(name = "身份证", type = Excel.Type.EXPORT, sort = 3)
@Excel(name = "身份证", sort = 3)
private String idNumber;
/**
@ -58,28 +58,33 @@ public class PmWorker {
/**
* 民族
*/
@Excel(name = "民族", type = Excel.Type.IMPORT)
private String nation;
/**
* 签发机关
*/
@Excel(name = "签发机关", type = Excel.Type.IMPORT)
private String issuingAuthority;
/**
* 有效期开始时间
*/
@Excel(name = "生效日期", type = Excel.Type.IMPORT)
@JsonFormat(pattern = "yyyy-MM-dd")
private Date startTime;
/**
* 有效期结束时间
*/
@Excel(name = "失效日期", type = Excel.Type.IMPORT)
@JsonFormat(pattern = "yyyy-MM-dd")
private Date endTime;
/**
* 家庭住址
*/
@Excel(name = "身份证住址", type = Excel.Type.IMPORT)
private String address;
/**

View File

@ -34,4 +34,12 @@ public interface BmWorkerAttMapper {
* @return
*/
List<BmWorkerAtt> getWorkerAttListById(BmWorkerAtt o);
/**
* 查询班组七天未打卡人员数量
* @param o
*
*/
List<BmWorkerAtt> getTeamAttListBySevenNotAtt(BmWorkerAtt o);
List<BmWorkerAtt> getSevenNotAttListByTeam(BmWorkerAtt o);
}

View File

@ -37,4 +37,11 @@ public interface BmWorkerBlackMapper {
* @return insert count
*/
int insert(BmWorkerBlack o);
/**
* insert record to table selective
* @param o the record to insert
* @return insert count
*/
void updateBasicWorkerBlackData(BmWorkerBlack worker);
}

View File

@ -86,4 +86,20 @@ public interface PmWorkerMapper {
* @return update count
*/
int updateByPrimaryKey(PmWorker record);
/**
* 导入插入基础数据
*
* @param worker
* @return
*/
int insertBasicWorkerData(PmWorker worker);
/**
* 导入更新基础数据
*
* @param worker
* @return
*/
void updateBasicWorkerData(PmWorker worker);
}

View File

@ -40,4 +40,11 @@ public interface BmWorkerAttService {
* @return
*/
List<BmWorkerAtt> getWorkerAttListById(BmWorkerAtt o);
/**
* 七日未打卡统计班组
* @param o
* @return
*/
List<BmWorkerAtt> getSevenNotAttListByTeam(BmWorkerAtt o);
}

View File

@ -23,4 +23,12 @@ public interface BmWorkerBlackService{
* @return
*/
AjaxResult insert(BmWorkerBlack o);
/**
* 黑名单人员导入
* @param workerList
* @param updateSupport
* @return
*/
String importWorkerBlack(List<BmWorkerBlack> workerList, boolean updateSupport);
}

View File

@ -20,4 +20,13 @@ public interface PmWorkerService{
int updateByPrimaryKey(PmWorker record,List<WebFileDto> listFile);
List<PmWorker> selectWorkList(PmWorkerDto o);
/**
* 导入数据
*
* @param workerList 用户数据列表
* @param isUpdateSupport 是否更新支持如果已存在则进行更新数据
* @return 结果
*/
String importWorker(List<PmWorker> workerList, boolean isUpdateSupport);
}

View File

@ -36,7 +36,24 @@ public class BmWorkerAttServiceImpl implements BmWorkerAttService {
@Override
public List<BmWorkerAtt> getTeamAttList(BmWorkerAtt o) {
return mapper.getTeamAttList(o);
List<BmWorkerAtt> teamAttList = mapper.getTeamAttList(o);
//查询班组七天未打卡人员
List<BmWorkerAtt> sevenNotAttList = mapper.getTeamAttListBySevenNotAtt(o);
// teamAttList2 转为 Map<teamId, num>方便查找
Map<Integer, Integer> sevenNotAttMap = sevenNotAttList.stream()
.collect(Collectors.toMap(
BmWorkerAtt::getTeamId, // key: teamId
BmWorkerAtt::getSevenNotAttNum, // value: num
(existing, replacement) -> existing // 如果 teamId 重复保留第一个
));
// 遍历 teamAttList teamAttList2 中的 num 值赋值进去
for (BmWorkerAtt item : teamAttList) {
Integer teamId = item.getTeamId();
//找到赋值不然默认为0
item.setSevenNotAttNum(sevenNotAttMap.getOrDefault(teamId, 0)); // 赋值 num
}
return teamAttList;
}
@Override
@ -92,6 +109,12 @@ public class BmWorkerAttServiceImpl implements BmWorkerAttService {
.collect(Collectors.toList());
}
@Override
public List<BmWorkerAtt> getSevenNotAttListByTeam(BmWorkerAtt o) {
List<BmWorkerAtt> list = mapper.getSevenNotAttListByTeam(o);
return list;
}
/**
* 人员考勤统计

View File

@ -2,8 +2,13 @@ package com.bonus.bmw.service.impl;
import com.bonus.bmw.domain.vo.BmWorkerLight;
import com.bonus.bmw.domain.vo.PmWorker;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.utils.bean.BeanValidators;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
@ -12,18 +17,24 @@ import com.bonus.bmw.domain.vo.BmWorkerBlack;
import com.bonus.bmw.mapper.BmWorkerBlackMapper;
import com.bonus.bmw.service.BmWorkerBlackService;
import javax.validation.Validator;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@Service
public class BmWorkerBlackServiceImpl implements BmWorkerBlackService{
private static final Logger log = LoggerFactory.getLogger(BmWorkerBlackServiceImpl.class);
@Autowired
private BmWorkerBlackMapper mapper;
@Autowired
protected Validator validator;
@Override
public int updateByPrimaryKey(String idNumber) {
@ -42,7 +53,7 @@ public class BmWorkerBlackServiceImpl implements BmWorkerBlackService{
if(worker != null && worker.getName() != null){
return new AjaxResult(500, "施工人员身份证已存在,当前姓名为"+worker.getName());
}
o.setCreateUser(SecurityUtils.getUsername());
o.setCreateUser(SecurityUtils.getLoginUser().getSysUser().getUserName());
int isRemove = 0;
if(!"永久".equals(o.getEndTime())){
boolean beforeToday = isBeforeToday(o.getEndTime());
@ -50,12 +61,79 @@ public class BmWorkerBlackServiceImpl implements BmWorkerBlackService{
isRemove = 2;
}
}
o.setCreateUser(SecurityUtils.getUsername());
o.setCreateUser(SecurityUtils.getLoginUser().getSysUser().getUserName());
o.setIsRemove(isRemove);
int insert = mapper.insert(o);
return insert>0?new AjaxResult(200, "添加成功"):new AjaxResult(500, "添加失败");
}
@Override
public String importWorkerBlack(List<BmWorkerBlack> workerList, boolean isUpdateSupport) {
if (StringUtils.isNull(workerList) || workerList.isEmpty()) {
throw new ServiceException("导入数据不能为空!");
}
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
for (BmWorkerBlack worker : workerList) {
try {
// 验证是否存在这个用户
// 添加员工时判断员工编号是否已存在
BmWorkerBlack w = mapper.getWorkerBlackByNumber(worker.getIdNumber());
if (StringUtils.isNull(w)) {
BeanValidators.validateWithException(validator, worker);
worker.setCreateUser(SecurityUtils.getLoginUser().getSysUser().getUserName());
int isRemove = 0;
if(!"永久".equals(worker.getEndTime())){
boolean beforeToday = isBeforeToday(worker.getEndTime());
if(beforeToday){
isRemove = 2;
}
}
worker.setIsRemove(isRemove);
mapper.insert(worker);
successNum++;
successMsg.append("<br/>").append(successNum).append("、失信人员信息 ").append(worker.getName()).append(" 导入成功");
} else if (isUpdateSupport) {
BeanValidators.validateWithException(validator, worker);
worker.setUpdateUser(SecurityUtils.getLoginUser().getSysUser().getUserName());
int isRemove = 0;
if(!"永久".equals(worker.getEndTime())){
boolean beforeToday = isBeforeToday(worker.getEndTime());
if(beforeToday){
isRemove = 2;
}
}
worker.setIsRemove(isRemove);
mapper.updateBasicWorkerBlackData(worker);
successNum++;
successMsg.append("<br/>").append(successNum).append("、失信人员信息 ").append(worker.getName()).append(" 更新成功");
} else {
failureNum++;
failureMsg.append("<br/>").append(failureNum).append("、失信人员信息 ").append(worker.getName()).append(" 已存在");
}
} catch (Exception e) {
failureNum++;
String msg = "<br/>" + failureNum + "、失信人员信息 " + worker.getName() + " 导入失败:";
String message = e.getMessage();
if (message != null && message.contains(":")) {
failureMsg.append(msg).append(message.substring(message.indexOf(":") + 2).trim());
}else {
failureMsg.append(msg).append(e.getMessage());
}
log.error(msg, e);
}
}
if (failureNum > 0) {
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new ServiceException(failureMsg.toString());
} else {
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
}
return successMsg.toString();
}
/**
* 判断给定的 yyyy-MM-dd 日期是否在今天之前
* @param dateStr 日期字符串格式为 yyyy-MM-dd

View File

@ -9,11 +9,17 @@ import com.bonus.bmw.service.BmWorkerContractService;
import com.bonus.bmw.service.BmWorkerWageCardService;
import com.bonus.common.core.constant.Constants;
import com.bonus.common.core.constant.SecurityConstants;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.utils.bean.BeanValidators;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.system.api.RemoteUrkUtilsService;
import com.bonus.system.api.domain.SysUser;
import com.bonus.system.api.model.UploadFileVo;
import com.github.pagehelper.util.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
@ -25,12 +31,18 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.validation.Validator;
import java.time.LocalDate;
import java.time.Period;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class PmWorkerServiceImpl implements PmWorkerService{
private static final Logger log = LoggerFactory.getLogger(PmWorkerServiceImpl.class);
@Autowired
private PmWorkerMapper mapper;
@ -43,6 +55,9 @@ public class PmWorkerServiceImpl implements PmWorkerService{
@Autowired
private FileUploadUtils fileUploadUtils;
@Autowired
protected Validator validator;
/**
* 引入urk服务 调用考勤机服务
*/
@ -62,7 +77,7 @@ public class PmWorkerServiceImpl implements PmWorkerService{
if(worker != null && worker.getId() != null){
return new AjaxResult(500, "施工人员身份证已存在,当前系统姓名为"+worker.getName()+"如果想入场请去修改数据即可");
}
record.setCreateUser(SecurityUtils.getUsername());
record.setCreateUser(SecurityUtils.getLoginUser().getSysUser().getUserName());
int insert = mapper.insert(record);
if(insert > 0){
List<WebFileDto> collect = fileMsg.stream().filter(data -> "faceImg".equals(data.getName())).collect(Collectors.toList());
@ -104,13 +119,13 @@ public class PmWorkerServiceImpl implements PmWorkerService{
BmWorkerWageCard bmWorkerWageCard = record.getBmWorkerWageCard();
BmWorkerContract bmWorkerContract = record.getBmWorkerContract();
if(bmWorkerWageCard != null && StringUtil.isNotEmpty(bmWorkerWageCard.getBankCardCode())){
bmWorkerWageCard.setCreateUser(SecurityUtils.getUsername());
bmWorkerWageCard.setCreateUser(SecurityUtils.getLoginUser().getSysUser().getUserName());
bmWorkerWageCard.setWorkerId(record.getId());
List<WebFileDto> collect = fileMsg.stream().filter(data -> "wageCard".equals(data.getName())).collect(Collectors.toList());
wageCardService.updateByPrimaryKey(bmWorkerWageCard,collect);
}
if(bmWorkerContract != null && StringUtil.isNotEmpty(bmWorkerContract.getContractCode())){
bmWorkerContract.setCreateUser(SecurityUtils.getUsername());
bmWorkerContract.setCreateUser(SecurityUtils.getLoginUser().getSysUser().getUserName());
bmWorkerContract.setWorkerId(record.getId());
List<WebFileDto> collect = fileMsg.stream().filter(data -> "contract".equals(data.getName())).collect(Collectors.toList());
contractService.updateByPrimaryKey(bmWorkerContract,collect);
@ -150,7 +165,7 @@ public class PmWorkerServiceImpl implements PmWorkerService{
@Override
public int updateByPrimaryKey(PmWorker record,List<WebFileDto> fileMsg) {
//更新基础数据
record.setUpdateUser(SecurityUtils.getUsername());
record.setUpdateUser(SecurityUtils.getLoginUser().getSysUser().getUserName());
int update = mapper.updateByPrimaryKey(record);
//人脸照片是否修改
List<WebFileDto> collect = fileMsg.stream().filter(data -> "faceImg".equals(data.getName())).collect(Collectors.toList());
@ -197,4 +212,101 @@ public class PmWorkerServiceImpl implements PmWorkerService{
return mapper.selectWorkList(o);
}
/**
* 导入用户数据
*
* @param workerList 用户数据列表
* @param isUpdateSupport 是否更新支持如果已存在则进行更新数据
* @return 结果
*/
@Override
public String importWorker(List<PmWorker> workerList, boolean isUpdateSupport) {
if (StringUtils.isNull(workerList) || workerList.isEmpty()) {
throw new ServiceException("导入数据不能为空!");
}
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
for (PmWorker worker : workerList) {
try {
// 验证是否存在这个用户
// 添加员工时判断员工编号是否已存在
PmWorker w = mapper.getWorkerByNumber(worker.getIdNumber());
Map<String, Object> idCardInfo = getIdCardInfo(worker.getIdNumber());
if (idCardInfo == null) {
failureMsg.insert(0, "导入失败!第 " + (workerList.indexOf(worker) + 1) + " 行数据身份证号码格式不正确!");
continue;
}else {
worker.setSex(idCardInfo.get("sex").toString());
worker.setAge(Integer.parseInt(idCardInfo.get("age").toString()));
worker.setBirthday(idCardInfo.get("birthday").toString());
}
if (StringUtils.isNull(w)) {
BeanValidators.validateWithException(validator, worker);
worker.setCreateUser(SecurityUtils.getLoginUser().getSysUser().getUserName());
mapper.insertBasicWorkerData(worker);
successNum++;
successMsg.append("<br/>").append(successNum).append("、施工人员信息 ").append(worker.getName()).append(" 导入成功");
} else if (isUpdateSupport) {
BeanValidators.validateWithException(validator, worker);
worker.setId(w.getId());
worker.setUpdateUser(SecurityUtils.getLoginUser().getSysUser().getUserName());
mapper.updateBasicWorkerData(worker);
successNum++;
successMsg.append("<br/>").append(successNum).append("、施工人员信息 ").append(worker.getName()).append(" 更新成功");
} else {
failureNum++;
failureMsg.append("<br/>").append(failureNum).append("、施工人员信息 ").append(worker.getName()).append(" 已存在");
}
} catch (Exception e) {
failureNum++;
String msg = "<br/>" + failureNum + "、施工人员信息 " + worker.getName() + " 导入失败:";
String message = e.getMessage();
if (message != null && message.contains(":")) {
failureMsg.append(msg).append(message.substring(message.indexOf(":") + 2).trim());
}else {
failureMsg.append(msg).append(e.getMessage());
}
log.error(msg, e);
}
}
if (failureNum > 0) {
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new ServiceException(failureMsg.toString());
} else {
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
}
return successMsg.toString();
}
/**
* 从18位身份证号中提取年龄性别出生日期返回Map
* @param idCard 身份证号码
* @return Map包含 age, sex, birthday
* @throws IllegalArgumentException 如果身份证无效
*/
public static Map<String, Object> getIdCardInfo(String idCard) {
if (idCard == null || idCard.length() != 18) {
return null;
}
// 提取出生日期字符串第7-14位
String birthStr = idCard.substring(6, 14); // YYYYMMDD
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyyMMdd");
LocalDate birthDate = LocalDate.parse(birthStr, inputFormatter);
// 格式化为 yyyy-MM-dd
String birthday = birthDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
// 计算年龄
int age = Period.between(birthDate, LocalDate.now()).getYears();
// 判断性别第17位奇数为男偶数为女
int genderDigit = Character.getNumericValue(idCard.charAt(16));
String sex = (genderDigit % 2 == 1) ? "" : "";
// 构造返回的 Map
Map<String, Object> result = new HashMap<>();
result.put("age", age);
result.put("sex", sex);
result.put("birthday", birthday);
return result;
}
}

View File

@ -27,6 +27,7 @@
<result column="att_time" property="attTime" />
<result column="phone" property="phone" />
<result column="post_name" property="postName" />
<result column="sevenNotAttNum" property="sevenNotAttNum" />
</resultMap>
<select id="getSubComAttList" resultMap="BaseResultMap">
@ -49,8 +50,9 @@
LEFT JOIN pm_sub_team_contract bstc ON bstc.sub_id = bsc.sub_id
AND bsc.pro_id = bstc.pro_id
AND bstc.is_active = 1
LEFT JOIN bm_worker_ein_msg bwem ON pp.id = bwem.pro_id
LEFT JOIN bm_att_person bap ON bap.pro_id = pp.id AND bap.att_day = #{currentDay}
<!-- LEFT JOIN bm_worker_ein_msg bwem ON pp.id = bwem.pro_id-->
LEFT JOIN bm_worker_ein_day_record bwem ON pp.id = bwem.pro_id and bwem.ein_day = #{startDate}
LEFT JOIN bm_att_person bap ON bap.pro_id = pp.id AND bap.att_day = #{startDate}
WHERE
psc.is_active = 1
GROUP BY
@ -75,8 +77,9 @@
AND bsc.pro_id = bstc.pro_id
AND bstc.is_active = 1
LEFT JOIN pm_sub_team pst ON pst.id = bstc.team_id
LEFT JOIN bm_worker_ein_msg bwem ON pp.id = bwem.pro_id
LEFT JOIN bm_att_person bap ON bap.pro_id = pp.id AND bap.att_day = #{currentDay}
<!-- LEFT JOIN bm_worker_ein_msg bwem ON pp.id = bwem.pro_id-->
LEFT JOIN bm_worker_ein_day_record bwem ON pp.id = bwem.pro_id and bwem.ein_day = #{startDate}
LEFT JOIN bm_att_person bap ON bap.pro_id = pp.id AND bap.att_day = #{startDate}
WHERE
pp.is_active = 1
AND pp.sub_com_id = #{subComId}
@ -105,8 +108,9 @@
AND bsc.pro_id = bstc.pro_id
AND bstc.is_active = 1
LEFT JOIN pm_sub_team pst ON pst.id = bstc.team_id
LEFT JOIN bm_worker_ein_msg bwem ON pp.id = bwem.pro_id
LEFT JOIN bm_att_person bap ON bap.pro_id = pp.id AND bap.att_day = #{currentDay}
<!-- LEFT JOIN bm_worker_ein_msg bwem ON pp.id = bwem.pro_id-->
LEFT JOIN bm_worker_ein_day_record bwem ON pp.id = bwem.pro_id and bwem.ein_day = #{startDate}
LEFT JOIN bm_att_person bap ON bap.pro_id = pp.id AND bap.att_day = #{startDate}
WHERE
pp.id = #{proId}
AND pp.is_active = 1
@ -193,5 +197,47 @@
GROUP BY
bwedr.worker_id
</select>
<select id="getTeamAttListBySevenNotAtt" resultMap="BaseResultMap">
SELECT
count(0) as sevenNotAttNum,
bwem.team_id
FROM
bm_worker_ein_msg bwem
INNER JOIN (
SELECT
worker_id,
MAX(att_day) AS max_current_day
FROM
bm_att_person
WHERE
pro_id = #{proId}
GROUP BY
worker_id
) latest ON bwem.worker_id = latest.worker_id
WHERE DATEDIFF(CURDATE(), max_current_day) > 7
and bwem.pro_id = #{proId}
GROUP BY bwem.team_id
</select>
<select id="getSevenNotAttListByTeam" resultMap="BaseResultMap">
SELECT
pw.NAME,
pw.id_number,
pw.phone,
bwem.post_name,
bwem.pro_name,
bwem.sub_name,
bwem.team_name,
latest.max_current_day AS att_day
FROM
bm_worker_ein_msg bwem
INNER JOIN (SELECT worker_id, MAX(att_day) AS max_current_day FROM bm_att_person WHERE pro_id = #{proId} AND team_id = #{teamId} GROUP BY worker_id) latest ON bwem.worker_id = latest.worker_id
LEFT JOIN pm_worker pw ON pw.id = bwem.worker_id
WHERE
DATEDIFF(CURDATE(), max_current_day) > 7
AND pro_id = #{proId}
AND team_id = #{teamId}
</select>
</mapper>

View File

@ -74,4 +74,33 @@
values (#{idNumber}, #{name}, #{postName}, #{proName}, #{subName}, #{reason}, #{startTime},
#{endTime}, #{isRemove}, #{createUser})
</insert>
<update id="updateBasicWorkerBlackData">
update bm_worker_black
<set>
<if test="name != null">
`name` = #{name},
</if>
<if test="postName != null">
post_name = #{postName},
</if>
<if test="proName != null">
pro_name = #{proName},
</if>
<if test="subName != null">
sub_name = #{subName},
</if>
<if test="reason != null">
reason = #{reason},
</if>
<if test="startTime != null">
start_time = #{startTime},
</if>
<if test="endTime != null">
end_time = #{endTime},
</if>
</set>
where id_number = #{idNumber}
</update>
</mapper>

View File

@ -204,4 +204,46 @@
</set>
where id = #{id}
</update>
<insert id="insertBasicWorkerData">
insert into pm_worker (`name`, id_number, sex, age, birthday, nation, issuing_authority,
start_time, end_time, address, create_user)
values (#{name}, #{idNumber}, #{sex}, #{age},#{birthday}, #{nation}, #{issuingAuthority},
#{startTime}, #{endTime}, #{address}, #{createUser})
</insert>
<update id="updateBasicWorkerData">
update pm_worker
<set>
<if test="name != null and name != ''">
`name` = #{name},
</if>
<if test="idNumber != null and idNumber != ''">
id_number = #{idNumber},
</if>
<if test="sex != null and sex != ''">
sex = #{sex},
</if>
<if test="birthday != null and birthday != ''">
birthday = #{birthday},
</if>
<if test="nation != null and nation != ''">
nation = #{nation},
</if>
<if test="issuingAuthority != null and issuingAuthority != ''">
issuing_authority = #{issuingAuthority},
</if>
<if test="startTime != null">
start_time = #{startTime},
</if>
<if test="endTime != null">
end_time = #{endTime},
</if>
<if test="address != null and address != ''">
address = #{address},
</if>
</set>
where id = #{id}
</update>
</mapper>