红绿灯和黑名单

This commit is contained in:
方亮 2025-08-13 18:33:36 +08:00
parent 72b317f879
commit 94c197b267
20 changed files with 825 additions and 20 deletions

View File

@ -0,0 +1,93 @@
package com.bonus.bmw.controller;
import com.bonus.bmw.domain.vo.BmWorkerBlack;
import com.bonus.bmw.domain.vo.BmWorkerContract;
import com.bonus.bmw.domain.vo.BmWorkerLight;
import com.bonus.bmw.domain.vo.PmWorker;
import com.bonus.bmw.service.BmWorkerBlackService;
import com.bonus.bmw.service.impl.BmWorkerBlackServiceImpl;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
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 org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.List;
/**
* 人员黑名单失信人员
*
* @author fly
*/
@RestController
@RequestMapping("/workerBlack")
public class BmWorkerBlackController extends BaseController {
/**
* 服务对象
*/
@Autowired
private BmWorkerBlackService service;
/**
* 查询列表-黑名单人员
* @param o
* @return
* , requiresPermissions = @RequiresPermissions("system:workerLight:list")
*/
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth(isUser = false))
@GetMapping("/getWorkerBlackList")
@SysLog(title = "人员黑名单", businessType = OperaType.QUERY, logType = 0, module = "施工人员->红绿灯管理->红绿灯统计", details = "黑名单人员列表")
public TableDataInfo getWorkerBlackList(BmWorkerBlack o) {
try {
startPage();
List<BmWorkerBlack> list = service.getWorkerBlackList(o);
return getDataTable(list);
} catch (Exception e) {
logger.error(e.toString(), e);
}
return getDataTableError(new ArrayList<>());
}
/**
* 黑名单人员添加
* @param o
* @return
*/
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth)
@PostMapping("/insert")
@SysLog(title = "人员入场管理", businessType = OperaType.UPDATE, logType = 0, module = "施工人员->出入场管理->人员入场管理", details = "黑名单人员添加")
public AjaxResult insert(@Validated @RequestBody BmWorkerBlack o) {
try {
return service.insert(o);
} catch (Exception e) {
logger.error(e.toString(), e);
}
return error("系统异常,请联系管理员");
}
/**
* 黑名单人员解除
* @param o
* @return
*/
//, requiresPermissions = @RequiresPermissions("system:workerBlack:edit")
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth)
@PostMapping("/remove/{id}")
@SysLog(title = "人员黑名单", businessType = OperaType.QUERY, logType = 0, module = "施工人员->红绿灯管理->人员黑名单", details = "黑名单人员解除")
public AjaxResult edit(@PathVariable("id") String idNumber) {
try {
return toAjax(service.updateByPrimaryKey(idNumber));
} catch (Exception e) {
logger.error(e.toString(), e);
}
return error("系统异常,请联系管理员");
}
}

View File

@ -57,7 +57,7 @@ public class BmWorkerContractController extends BaseController {
} }
/** /**
* 查询列表 * 查询单人列表
* @param o * @param o
* @return * @return
* , requiresPermissions = @RequiresPermissions("system:contract:list") * , requiresPermissions = @RequiresPermissions("system:contract:list")

View File

@ -0,0 +1,95 @@
package com.bonus.bmw.controller;
import com.bonus.bmw.domain.dto.PmWorkerDto;
import com.bonus.bmw.domain.vo.BmWorkerLight;
import com.bonus.bmw.domain.vo.PmWorker;
import com.bonus.bmw.service.BmWorkerLightService;
import com.bonus.bmw.service.impl.BmWorkerLightServiceImpl;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.page.TableDataInfo;
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 org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.List;
/**
* 红绿灯统计
*
* @author fly
*/
@RestController
@RequestMapping("/workerLight")
public class BmWorkerLightController extends BaseController {
/**
* 服务对象
*/
@Autowired
private BmWorkerLightService service;
/**
* 查询列表-分公司
* @param o
* @return
* , requiresPermissions = @RequiresPermissions("system:workerLight:list")
*/
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth(isUser = false))
@GetMapping("/getSubComLightList")
@SysLog(title = "红绿灯统计", businessType = OperaType.QUERY, logType = 0, module = "施工人员->红绿灯管理->红绿灯统计", details = "分公司红绿灯统计")
public TableDataInfo getSubComLightList(BmWorkerLight o) {
try {
startPage();
List<BmWorkerLight> list = service.getSubComLightList(o);
return getDataTable(list);
} catch (Exception e) {
logger.error(e.toString(), e);
}
return getDataTableError(new ArrayList<>());
}
/**
* 查询列表-工程
* @param o
* @return
* , requiresPermissions = @RequiresPermissions("system:workerLight:list")
*/
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth(isUser = false))
@GetMapping("/getProLightList")
@SysLog(title = "红绿灯统计", businessType = OperaType.QUERY, logType = 0, module = "施工人员->红绿灯管理->红绿灯统计", details = "工程红绿灯统计")
public TableDataInfo getProLightList(BmWorkerLight o) {
try {
startPage();
List<BmWorkerLight> list = service.getProLightList(o);
return getDataTable(list);
} catch (Exception e) {
logger.error(e.toString(), e);
}
return getDataTableError(new ArrayList<>());
}
/**
* 查询列表-人员
* @param o
* @return
* , requiresPermissions = @RequiresPermissions("system:workerLight:list")
*/
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth(isUser = false))
@GetMapping("/getWorkerLightList")
@SysLog(title = "红绿灯统计", businessType = OperaType.QUERY, logType = 0, module = "施工人员->红绿灯管理->红绿灯统计", details = "人员红绿灯统计")
public TableDataInfo getWorkerLightList(BmWorkerLight o) {
try {
startPage();
List<BmWorkerLight> list = service.getWorkerLightList(o);
return getDataTable(list);
} catch (Exception e) {
logger.error(e.toString(), e);
}
return getDataTableError(new ArrayList<>());
}
}

View File

@ -0,0 +1,74 @@
package com.bonus.bmw.domain.vo;
import lombok.Data;
/**
* 人员黑名单失信人员
*/
@Data
public class BmWorkerBlack {
/**
* 编号
*/
private Integer id;
/**
* 施工人员id
*/
private Integer workerId;
/**
* 身份证
*/
private String idNumber;
/**
* 姓名
*/
private String name;
/**
* 岗位
*/
private String postName;
/**
* 工程
*/
private String proName;
/**
* 分包
*/
private String subName;
/**
* 理由
*/
private String reason;
/**
* 开始时间
*/
private String startTime;
/**
* 结束时间
*/
private String endTime;
/**
* 是否解除 0 未解除 1 已解除
*/
private Integer isRemove;
/**
* 创建人
*/
private String createUser;
/**
* 修改人
*/
private String updateUser;
}

View File

@ -118,4 +118,6 @@ public class BmWorkerContract {
*/ */
private String isActive; private String isActive;
private String einStatus;
} }

View File

@ -0,0 +1,101 @@
package com.bonus.bmw.domain.vo;
import java.util.Date;
import lombok.Data;
/**
* 所有在场人员实时信息表-离场就删除
*/
@Data
public class BmWorkerLight {
/**
* 工程
*/
private String proName;
/**
* 工程id
*/
private Integer proId;
/**
* 班组
*/
private String teamName;
/**
* 班组id
*/
private Integer teamId;
/**
* 分包
*/
private String subName;
/**
* 分包id
*/
private Integer subId;
/**
* 工种
*/
private String postName;
/**
* 工种id
*/
private Integer postId;
/**
* 1 黄灯 2 绿灯
*/
private Integer lightStatus;
/**
* 分公司
*/
private String subComName;
/**
* 分公司id
*/
private String subComId;
/**
* 手机号
*/
private String phone;
/**
* 姓名
*/
private String name;
/**
* 身份证号
*/
private String idNumber;
/**
* 在场人员数量
*/
private String einNum;
/**
* 黄灯数量
*/
private String yellowNum;
/**
* 绿灯数量
*/
private String greenNum;
public String getSubComId() {
return subComId;
}
public void setSubComId(String subComId) {
this.subComId = subComId;
}
}

View File

@ -1,6 +1,8 @@
package com.bonus.bmw.domain.vo; package com.bonus.bmw.domain.vo;
import java.util.Date; import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
/** /**
@ -56,11 +58,13 @@ public class PmWorker {
/** /**
* 有效期开始时间 * 有效期开始时间
*/ */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date startTime; private Date startTime;
/** /**
* 有效期结束时间 * 有效期结束时间
*/ */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date endTime; private Date endTime;
/** /**

View File

@ -0,0 +1,40 @@
package com.bonus.bmw.mapper;
import com.bonus.bmw.domain.vo.BmWorkerBlack;
import com.bonus.bmw.domain.vo.BmWorkerLight;
import com.bonus.bmw.domain.vo.PmWorker;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface BmWorkerBlackMapper {
/**
* update record
* @param idNumber the updated record
* @return update count
*/
int updateByPrimaryKey(String idNumber);
/**
* select by primary key
* @param o primary key
* @return object by primary key
*/
List<BmWorkerBlack> getWorkerBlackList(BmWorkerBlack o);
/**
* select by primary key
* @param idNumber primary key
* @return object by primary key
*/
BmWorkerBlack getWorkerBlackByNumber(String idNumber);
/**
* insert record to table
* @param o the record to insert
* @return insert count
*/
int insert(BmWorkerBlack o);
}

View File

@ -0,0 +1,16 @@
package com.bonus.bmw.mapper;
import com.bonus.bmw.domain.vo.BmWorkerLight;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface BmWorkerLightMapper {
List<BmWorkerLight> getSubComLightList(BmWorkerLight o);
List<BmWorkerLight> getProLightList(BmWorkerLight o);
List<BmWorkerLight> getWorkerLightList(BmWorkerLight o);
}

View File

@ -78,4 +78,12 @@ public interface PmWorkerMapper {
* @return * @return
*/ */
void updateEinRecordLast(Integer id); void updateEinRecordLast(Integer id);
/**
* update record
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKey(PmWorker record);
} }

View File

@ -0,0 +1,26 @@
package com.bonus.bmw.service;
import com.bonus.bmw.domain.vo.BmWorkerBlack;
import com.bonus.bmw.domain.vo.BmWorkerLight;
import com.bonus.common.core.web.domain.AjaxResult;
import java.util.List;
public interface BmWorkerBlackService{
int updateByPrimaryKey(String idNumber);
/**
* 黑名单人员列表
* @param o
* @return
*/
List<BmWorkerBlack> getWorkerBlackList(BmWorkerBlack o);
/**
* 黑名单人员添加
* @param o
* @return
*/
AjaxResult insert(BmWorkerBlack o);
}

View File

@ -0,0 +1,29 @@
package com.bonus.bmw.service;
import com.bonus.bmw.domain.vo.BmWorkerLight;
import java.util.List;
public interface BmWorkerLightService{
/**
* 分公司红绿灯统计
* @param o
* @return
*/
List<BmWorkerLight> getSubComLightList(BmWorkerLight o);
/**
* 工程红绿灯统计
* @param o
* @return
*/
List<BmWorkerLight> getProLightList(BmWorkerLight o);
/**
* 人员红绿灯统计
* @param o
* @return
*/
List<BmWorkerLight> getWorkerLightList(BmWorkerLight o);
}

View File

@ -0,0 +1,80 @@
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.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.bonus.bmw.domain.vo.BmWorkerBlack;
import com.bonus.bmw.mapper.BmWorkerBlackMapper;
import com.bonus.bmw.service.BmWorkerBlackService;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.Collections;
import java.util.List;
@Service
public class BmWorkerBlackServiceImpl implements BmWorkerBlackService{
@Autowired
private BmWorkerBlackMapper mapper;
@Override
public int updateByPrimaryKey(String idNumber) {
return mapper.updateByPrimaryKey(idNumber);
}
@Override
public List<BmWorkerBlack> getWorkerBlackList(BmWorkerBlack o) {
return mapper.getWorkerBlackList(o);
}
@Override
public AjaxResult insert(BmWorkerBlack o) {
// 添加员工时判断员工编号是否已存在
BmWorkerBlack worker = mapper.getWorkerBlackByNumber(o.getIdNumber());
if(worker != null && worker.getId() != null){
return new AjaxResult(500, "施工人员身份证已存在,当前姓名为"+worker.getName());
}
o.setCreateUser(SecurityUtils.getUsername());
int isRemove = 0;
if(!"永久".equals(o.getEndTime())){
boolean beforeToday = isBeforeToday(o.getEndTime());
if(beforeToday){
isRemove = 2;
}
}
o.setCreateUser(SecurityUtils.getUsername());
o.setIsRemove(isRemove);
int insert = mapper.insert(o);
return insert>0?new AjaxResult(200, "添加成功"):new AjaxResult(500, "添加失败");
}
/**
* 判断给定的 yyyy-MM-dd 日期是否在今天之前
* @param dateStr 日期字符串格式为 yyyy-MM-dd
* @return true 表示在今天之前false 表示等于或晚于今天或解析失败
*/
public boolean isBeforeToday(String dateStr) {
if (dateStr == null || dateStr.trim().isEmpty()) {
return false;
}
try {
LocalDate inputDate = LocalDate.parse(dateStr.trim(), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
LocalDate today = LocalDate.now();
return inputDate.isBefore(today);
} catch (DateTimeParseException e) {
// 解析出错直接返回 false也可根据需要返回 null 或抛异常
return false;
}
}
}

View File

@ -0,0 +1,39 @@
package com.bonus.bmw.service.impl;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.bonus.bmw.mapper.BmWorkerLightMapper;
import com.bonus.bmw.domain.vo.BmWorkerLight;
import com.bonus.bmw.service.BmWorkerLightService;
import java.util.Collections;
import java.util.List;
@Service
public class BmWorkerLightServiceImpl implements BmWorkerLightService{
@Autowired
private BmWorkerLightMapper mapper;
/**
* 分公司红绿灯统计
* @param o
* @return
*/
@Override
public List<BmWorkerLight> getSubComLightList(BmWorkerLight o) {
return mapper.getSubComLightList(o);
}
@Override
public List<BmWorkerLight> getProLightList(BmWorkerLight o) {
return mapper.getProLightList(o);
}
@Override
public List<BmWorkerLight> getWorkerLightList(BmWorkerLight o) {
return mapper.getWorkerLightList(o);
}
}

View File

@ -1,24 +1,13 @@
package com.bonus.bmw.service.impl; package com.bonus.bmw.service.impl;
import cn.hutool.core.date.DateUtil;
import com.bonus.bmw.domain.dto.PmWorkerDto; import com.bonus.bmw.domain.dto.PmWorkerDto;
import com.bonus.bmw.domain.vo.BmWorkerContract;
import com.bonus.bmw.domain.vo.BmWorkerWageCard;
import com.bonus.bmw.domain.vo.PmWorker; import com.bonus.bmw.domain.vo.PmWorker;
import com.bonus.bmw.mapper.PmWorkerExitMapper; import com.bonus.bmw.mapper.PmWorkerExitMapper;
import com.bonus.bmw.mapper.PmWorkerMapper;
import com.bonus.bmw.service.BmWorkerContractService; import com.bonus.bmw.service.BmWorkerContractService;
import com.bonus.bmw.service.BmWorkerWageCardService;
import com.bonus.bmw.service.PmWorkerExitService; import com.bonus.bmw.service.PmWorkerExitService;
import com.bonus.bmw.service.PmWorkerService;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import com.github.pagehelper.util.StringUtil;
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 org.springframework.transaction.annotation.Transactional;
import java.util.Collections;
import java.util.List; import java.util.List;
@Service @Service

View File

@ -78,16 +78,16 @@ public class PmWorkerServiceImpl implements PmWorkerService{
private void addWorkerWageCardDataAndContract(PmWorker record) { private void addWorkerWageCardDataAndContract(PmWorker record) {
BmWorkerWageCard bmWorkerWageCard = record.getBmWorkerWageCard(); BmWorkerWageCard bmWorkerWageCard = record.getBmWorkerWageCard();
BmWorkerContract bmWorkerContract = record.getBmWorkerContract(); BmWorkerContract bmWorkerContract = record.getBmWorkerContract();
if(StringUtil.isNotEmpty(bmWorkerWageCard.getBankCardCode())){ if(bmWorkerWageCard != null && StringUtil.isNotEmpty(bmWorkerWageCard.getBankCardCode())){
bmWorkerWageCard.setCreateUser(SecurityUtils.getUsername()); bmWorkerWageCard.setCreateUser(SecurityUtils.getUsername());
bmWorkerWageCard.setWorkerId(record.getId()); bmWorkerWageCard.setWorkerId(record.getId());
if(bmWorkerWageCard.getId() != null){ // if(bmWorkerWageCard.getId() != null){
wageCardService.updateByPrimaryKeySelective(bmWorkerWageCard); // wageCardService.updateByPrimaryKeySelective(bmWorkerWageCard);
}else{ // }else{
wageCardService.updateByPrimaryKey(bmWorkerWageCard); wageCardService.updateByPrimaryKey(bmWorkerWageCard);
// }
} }
} if(bmWorkerContract != null && StringUtil.isNotEmpty(bmWorkerContract.getContractCode())){
if(StringUtil.isNotEmpty(bmWorkerContract.getContractCode())){
bmWorkerContract.setCreateUser(SecurityUtils.getUsername()); bmWorkerContract.setCreateUser(SecurityUtils.getUsername());
bmWorkerContract.setWorkerId(record.getId()); bmWorkerContract.setWorkerId(record.getId());
contractService.updateByPrimaryKey(bmWorkerContract); contractService.updateByPrimaryKey(bmWorkerContract);
@ -122,6 +122,9 @@ public class PmWorkerServiceImpl implements PmWorkerService{
@Transactional @Transactional
@Override @Override
public int updateByPrimaryKey(PmWorker record) { public int updateByPrimaryKey(PmWorker record) {
//更新基础数据
record.setUpdateUser(SecurityUtils.getUsername());
int update = mapper.updateByPrimaryKey(record);
//更新入场记录最新记录标识 再入场清除最新标识 //更新入场记录最新记录标识 再入场清除最新标识
mapper.updateEinRecordLast(record.getId()); mapper.updateEinRecordLast(record.getId());
//已经入过场了 //已经入过场了

View File

@ -0,0 +1,74 @@
<?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.bmw.mapper.BmWorkerBlackMapper">
<resultMap id="BaseResultMap" type="com.bonus.bmw.domain.vo.BmWorkerBlack">
<!--@mbg.generated-->
<!--@Table bm_worker_black-->
<id column="id" property="id" />
<result column="worker_id" property="workerId" />
<result column="id_number" property="idNumber" />
<result column="name" property="name" />
<result column="post_name" property="postName" />
<result column="pro_name" property="proName" />
<result column="sub_name" property="subName" />
<result column="reason" property="reason" />
<result column="start_time" property="startTime" />
<result column="end_time" property="endTime" />
<result column="is_remove" property="isRemove" />
<result column="create_user" property="createUser" />
<result column="update_user" property="updateUser" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, worker_id, id_number, `name`, post_name, pro_name, sub_name, reason, start_time,
end_time, is_remove, create_user, update_user
</sql>
<update id="updateByPrimaryKey" parameterType="com.bonus.bmw.domain.vo.BmWorkerBlack">
<!--@mbg.generated-->
update bm_worker_black
set is_remove = 1
where id_number = #{idNumber}
</update>
<select id="getWorkerBlackList" resultType="com.bonus.bmw.domain.vo.BmWorkerBlack">
select
id_number,
`name`,
post_name,
pro_name,
sub_name,
reason,
start_time,
end_time,
is_remove
from bm_worker_black
<where>
<if test="name != null and name != ''">
and `name` LIKE CONCAT('%',#{name},'%')
</if>
<if test="proName != null and proName != ''">
and pro_name LIKE CONCAT('%',#{proName},'%')
</if>
<if test="subName != null and subName != ''">
and sub_name LIKE CONCAT('%',#{subName},'%')
</if>
<if test="isRemove != null and isRemove != ''">
and is_remove = #{isRemove}
</if>
</where>
</select>
<select id="getWorkerBlackByNumber" resultType="com.bonus.bmw.domain.vo.BmWorkerBlack">
select
`name`
from bm_worker_black
where id_number = #{idNumber}
</select>
<insert id="insert">
insert into bm_worker_black (id_number, `name`, post_name, pro_name, sub_name, reason, start_time,
end_time, is_remove,create_user)
values (#{idNumber}, #{name}, #{postName}, #{proName}, #{subName}, #{reason}, #{startTime},
#{endTime}, #{isRemove}, #{createUser})
</insert>
</mapper>

View File

@ -24,6 +24,8 @@
<result column="id_number" property="idNumber" /> <result column="id_number" property="idNumber" />
<result column="isSign" property="isSign" /> <result column="isSign" property="isSign" />
<result column="is_active" property="isActive" /> <result column="is_active" property="isActive" />
<result column="einStatus" property="einStatus" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
<!--@mbg.generated--> <!--@mbg.generated-->
@ -55,6 +57,7 @@
<select id="selectContractList" resultMap="BaseResultMap"> <select id="selectContractList" resultMap="BaseResultMap">
SELECT SELECT
pw.id as worker_id,
pw.`name`, pw.`name`,
pw.id_number, pw.id_number,
bwem.pro_name, bwem.pro_name,
@ -63,7 +66,8 @@
bwc.contract_code, bwc.contract_code,
bwc.contract_start_date, bwc.contract_start_date,
bwc.id, bwc.id,
if(bwc.id is null ,0,1) AS isSign if(bwc.id is null ,0,1) AS isSign,
if(bwem.worker_id is null ,2,1) AS einStatus
FROM FROM
pm_worker pw pm_worker pw
LEFT JOIN bm_worker_ein_msg bwem ON bwem.worker_id = pw.id LEFT JOIN bm_worker_ein_msg bwem ON bwem.worker_id = pw.id

View File

@ -0,0 +1,86 @@
<?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.bmw.mapper.BmWorkerLightMapper">
<resultMap id="BaseResultMap" type="com.bonus.bmw.domain.vo.BmWorkerLight">
<result column="sub_company_name" property="subComName" />
<result column="sub_com_id" property="subComId" />
<result column="pro_name" property="proName" />
<result column="pro_id" property="proId" />
<result column="team_name" property="teamName" />
<result column="sub_name" property="subName" />
<result column="post_name" property="postName" />
<result column="light_status" property="lightStatus" />
<result column="phone" property="phone" />
<result column="name" property="name" />
<result column="id_number" property="idNumber" />
<result column="einNum" property="einNum" />
<result column="yellowNum" property="yellowNum" />
<result column="greenNum" property="greenNum" />
</resultMap>
<select id="getSubComLightList" resultMap="BaseResultMap">
SELECT
psc.id as sub_com_id,
psc.sub_company_name,
COUNT(bwem.worker_id) AS einNum,
COUNT(CASE WHEN bwem.light_status = 1 THEN 1 END) AS yellowNum,
COUNT(CASE WHEN bwem.light_status = 2 THEN 1 END) AS greenNum
FROM
pm_sub_company psc
LEFT JOIN pm_project pp ON psc.id = pp.sub_com_id AND pp.is_active = 1
LEFT JOIN bm_worker_ein_msg bwem ON pp.id = bwem.pro_id
WHERE
psc.is_active = 1
GROUP BY
psc.id
</select>
<select id="getProLightList" resultMap="BaseResultMap">
SELECT
pp.id as pro_id,
pp.pro_name,
COUNT(bwem.worker_id) AS einNum,
COUNT(CASE WHEN bwem.light_status = 1 THEN 1 END) AS yellowNum,
COUNT(CASE WHEN bwem.light_status = 2 THEN 1 END) AS greenNum
FROM
pm_project pp
LEFT JOIN bm_worker_ein_msg bwem ON pp.id = bwem.pro_id
WHERE
pp.sub_com_id = #{subComId} AND pp.is_active = 1
<if test="proName != null">
AND pp.pro_name LIKE CONCAT('%', #{proName}, '%')
</if>
GROUP BY
pp.id
</select>
<select id="getWorkerLightList" resultMap="BaseResultMap">
SELECT
pw.name,
pw.id_number,
pw.phone,
bwem.pro_name,
bwem.team_name,
bwem.sub_name,
bwem.post_name,
bwem.light_status
FROM
bm_worker_ein_msg bwem
left join pm_worker pw on bwem.worker_id = pw.id
WHERE
bwem.pro_id = #{proId}
<if test="lightStatus != null">
AND bwem.light_status = #{lightStatus}
</if>
<if test="name != null and name != ''">
AND pw.name LIKE CONCAT('%', #{name}, '%')
</if>
<if test="teamId != null">
AND bwem.team_id =#{teamId}
</if>
<if test="subId != null">
AND bwem.sub_id = #{subId}
</if>
</select>
</mapper>

View File

@ -65,7 +65,6 @@
</select> </select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
update pm_worker set is_active = 0 where id = #{id}; update pm_worker set is_active = 0 where id = #{id};
update bm_worker_ein_pro set is_active = 0 where worker_id = #{id};
</delete> </delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.bonus.bmw.domain.vo.PmWorker" useGeneratedKeys="true"> <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.bonus.bmw.domain.vo.PmWorker" useGeneratedKeys="true">
<!--@mbg.generated--> <!--@mbg.generated-->
@ -162,4 +161,47 @@
<update id="updateEinRecordLast"> <update id="updateEinRecordLast">
update bm_worker_ein_pro_record set is_last = 0 where worker_id = #{id} update bm_worker_ein_pro_record set is_last = 0 where worker_id = #{id}
</update> </update>
<update id="updateByPrimaryKey">
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="phone != null and phone != ''">
phone = #{phone},
</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>
<if test="facePhoto != null and facePhoto != ''">
face_photo = #{facePhoto},
</if>
<if test="updateUser != null and updateUser != ''">
update_user = #{updateUser},
</if>
</set>
where id = #{id}
</update>
</mapper> </mapper>