人员入场上传

This commit is contained in:
方亮 2025-08-12 18:35:03 +08:00
parent 755ec8021b
commit 8a6fdf641a
15 changed files with 1085 additions and 4 deletions

View File

@ -0,0 +1,123 @@
package com.bonus.bmw.controller;
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.service.impl.PmWorkerServiceImpl;
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;
/**
* 人员基础信息表(pm_worker)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/worker")
public class PmWorkerController extends BaseController {
/**
* 服务对象
*/
@Autowired
private PmWorkerServiceImpl service;
/**
* 通过主键查询单条数据
*
* @param id 主键
* @return 单条数据
*/
@GetMapping("selectOne")
public PmWorker selectOne(Integer id) {
return service.selectByPrimaryKey(id);
}
/**
* 查询列表
* @param o
* @return
* , requiresPermissions = @RequiresPermissions("system:workerEin:list")
*/
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth(isUser = false))
@GetMapping("/list")
@SysLog(title = "人员入场管理", businessType = OperaType.QUERY, logType = 0, module = "施工人员->出入场管理->人员入场管理", details = "查询人员入场列表")
public TableDataInfo list(PmWorkerDto o) {
try {
startPage();
List<PmWorker> list = service.selectWorkList(o);
return getDataTable(list);
} catch (Exception e) {
logger.error(e.toString(), e);
}
return getDataTableError(new ArrayList<>());
}
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth)
@PostMapping("/insert")
@SysLog(title = "人员入场管理", businessType = OperaType.UPDATE, logType = 0, module = "施工人员->出入场管理->人员入场管理", details = "新增人员入场")
public AjaxResult insert(@Validated @RequestBody PmWorker o) {
try {
return service.insert(o);
} catch (Exception e) {
logger.error(e.toString(), e);
}
return error("系统异常,请联系管理员");
}
//, requiresPermissions = @RequiresPermissions("system:wageCard:edit")
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth)
@PostMapping("/select/{id}")
@SysLog(title = "人员入场管理", businessType = OperaType.UPDATE, logType = 0, module = "施工人员->出入场管理->人员入场管理", details = "修改人员入场")
public AjaxResult select(@PathVariable("id") Integer id) {
try {
AjaxResult ajax = AjaxResult.success();
PmWorker worker = service.selectByPrimaryKey(id);
ajax.put("data", worker);
return ajax;
} catch (Exception e) {
logger.error(e.toString(), e);
}
return error("系统异常,请联系管理员");
}
//, requiresPermissions = @RequiresPermissions("system:wageCard:edit")
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth)
@PostMapping("/edit")
@SysLog(title = "人员入场管理", businessType = OperaType.UPDATE, logType = 0, module = "施工人员->出入场管理->人员入场管理", details = "修改人员入场")
public AjaxResult edit(@Validated @RequestBody PmWorker o) {
try {
return toAjax(service.updateByPrimaryKey(o));
} catch (Exception e) {
logger.error(e.toString(), e);
}
return error("系统异常,请联系管理员");
}
//, requiresPermissions = @RequiresPermissions("system:contract:remove")
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth)
@PostMapping("/delete/{id}")
@SysLog(title = "人员入场管理", businessType = OperaType.DELETE, logType = 0, module = "施工人员->出入场管理->人员入场管理", details = "删除人员")
public AjaxResult remove(@PathVariable("id") Integer id) {
try {
return toAjax(service.deleteByPrimaryKey(id));
} catch (Exception e) {
logger.error(e.toString(), e);
}
return error("系统异常,请联系管理员");
}
}

View File

@ -0,0 +1,56 @@
package com.bonus.bmw.domain.dto;
import lombok.Data;
import java.util.Date;
/**
* 人员基础信息表
*/
@Data
public class PmWorkerDto {
/**
* 编号
*/
private Integer id;
/**
* 姓名
*/
private String name;
/**
* 身份证
*/
private String idNumber;
/**
* 手机号
*/
private String phone;
/**
* 项目名称
*/
private String proId;
/**
* 分包名称
*/
private String subId;
/**
* 班组名称
*/
private String teamId;
/**
* 岗位名称
*/
private String postId;
/**
* 入场状态
*/
private Integer einStatus;
}

View File

@ -0,0 +1,157 @@
package com.bonus.bmw.domain.vo;
import java.util.Date;
import lombok.Data;
/**
* 人员基础信息表
*/
@Data
public class PmWorker {
/**
* 编号
*/
private Integer id;
/**
* 入场项目表主键
*/
private Integer einProId;
/**
* 姓名
*/
private String name;
/**
* 身份证
*/
private String idNumber;
/**
* 性别
*/
private String sex;
/**
* 年龄
*/
private Integer age;
/**
* 手机号
*/
private String phone;
/**
* 出生日期 生日
*/
private String birthday;
/**
* 民族
*/
private String nation;
/**
* 签发机关
*/
private String issuingAuthority;
/**
* 有效期开始时间
*/
private Date startTime;
/**
* 有效期结束时间
*/
private Date endTime;
/**
* 家庭住址
*/
private String address;
/**
* 人脸照片
*/
private String facePhoto;
/**
* 入场状态 0未入场 1 已入场
*/
private Integer einStatus;
/**
* 0 默认 1 黄灯 2 绿灯 3 失信人员
*/
private Integer lightStatus;
/**
* 创建人
*/
private String createUser;
/**
* 修改人
*/
private String updateUser;
/**
* 项目名称
*/
private String proName;
/**
* 分包名称
*/
private String subName;
/**
* 班组名称
*/
private String teamName;
/**
* 岗位名称
*/
private String postName;
/**
* 项目名称
*/
private String proId;
/**
* 分包名称
*/
private String subId;
/**
* 班组名称
*/
private String teamId;
/**
* 岗位名称
*/
private String postId;
/**
* 入场时间
*/
private String einTime;
/**
* 创建时间
*/
private Integer contractId;
/**
* 合同信息
*/
private BmWorkerContract bmWorkerContract;
/**
* 工资卡信息
*/
private BmWorkerWageCard bmWorkerWageCard;
}

View File

@ -34,4 +34,11 @@ public interface BmWorkerContractMapper {
* @return
*/
List<BmWorkerContract> selectContractListByWorkerId(BmWorkerContract o);
/**
* 查询单人有效合同列表
* @param o
* @return
*/
BmWorkerContract selectContractListByWorkerIdAndValid(BmWorkerContract o);
}

View File

@ -36,4 +36,14 @@ public interface BmWorkerWageCardMapper {
* @return
*/
List<BmWorkerWageCard> selectWageCardList(BmWorkerWageCard o);
BmWorkerWageCard selectWageCardByWorkerId(BmWorkerWageCard o);
/**
* update record
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKeySelective(BmWorkerWageCard record);
}

View File

@ -0,0 +1,97 @@
package com.bonus.bmw.mapper;
import com.bonus.bmw.domain.dto.PmWorkerDto;
import com.bonus.bmw.domain.vo.PmWorker;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface PmWorkerMapper {
/**
* delete by primary key
*
* @param id primaryKey
* @return deleteCount
*/
int deleteByPrimaryKey(Integer id);
/**
* insert record to table
*
* @param record the record
* @return insert count
*/
int insert(PmWorker record);
/**
* insert record to table selective
*
* @param record the record
* @return insert count
*/
int insertSelective(PmWorker record);
/**
* select by primary key
*
* @param id primary key
* @return object by primary key
*/
PmWorker selectByPrimaryKey(Integer id);
/**
* update record selective
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKeySelective(PmWorker record);
/**
* update record
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKey(PmWorker record);
/**
* 查询人员列表
*
* @param o
* @return
*/
List<PmWorker> selectWorkList(PmWorkerDto o);
/**
* 根据身份证查询人员
*
* @param idNumber
* @return
*/
PmWorker getWorkerByNumber(String idNumber);
/**
* 插入入场实时数据信息
*
* @param record
* @return
*/
int insertEinMsg(PmWorker record);
/**
* 插入入场历史数据信息
*
* @param record
* @return
*/
int insertEinPro(PmWorker record);
/**
* 插入入场历史数据信息
*
* @param record
* @return
*/
int insertEinProRecord(PmWorker record);
}

View File

@ -34,4 +34,11 @@ public interface BmWorkerContractService{
* @return
*/
List<BmWorkerContract> selectContractListByWorkerId(BmWorkerContract o);
/**
* 根据施工人员id查询有效合同列表
* @param o
* @return
*/
BmWorkerContract selectContractListByWorkerIdAndValid(BmWorkerContract o);
}

View File

@ -13,6 +13,13 @@ public interface BmWorkerWageCardService {
*/
int updateByPrimaryKey(BmWorkerWageCard record);
/**
* 修改工资卡
* @param record
* @return
*/
int updateByPrimaryKeySelective(BmWorkerWageCard record);
/**
* 查询工资卡列表
* @param o
@ -20,6 +27,13 @@ public interface BmWorkerWageCardService {
*/
List<BmWorkerWageCard> selectWageCardList(BmWorkerWageCard o);
/**
* 查询工资卡列表
* @param o
* @return
*/
BmWorkerWageCard selectWageCardByWorkerId(BmWorkerWageCard o);
/**
* 删除工资卡
* @param id

View File

@ -0,0 +1,25 @@
package com.bonus.bmw.service;
import com.bonus.bmw.domain.dto.PmWorkerDto;
import com.bonus.bmw.domain.vo.BmWorkerWageCard;
import com.bonus.bmw.domain.vo.PmWorker;
import com.bonus.common.core.web.domain.AjaxResult;
import java.util.List;
public interface PmWorkerService{
int deleteByPrimaryKey(Integer id);
AjaxResult insert(PmWorker record);
int insertSelective(PmWorker record);
PmWorker selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(PmWorker record);
int updateByPrimaryKey(PmWorker record);
List<PmWorker> selectWorkList(PmWorkerDto o);
}

View File

@ -74,4 +74,9 @@ public class BmWorkerContractServiceImpl implements BmWorkerContractService{
return mapper.selectContractListByWorkerId(o);
}
@Override
public BmWorkerContract selectContractListByWorkerIdAndValid(BmWorkerContract o) {
return mapper.selectContractListByWorkerIdAndValid(o);
}
}

View File

@ -19,6 +19,12 @@ public class BmWorkerWageCardServiceImpl implements BmWorkerWageCardService {
@Resource
private BmWorkerWageCardMapper mapper;
/**
* 新增工资卡
*
* @param record
* @return
*/
@Override
public int updateByPrimaryKey(BmWorkerWageCard record) {
//存在则删除后新增不存在则新增
@ -30,6 +36,20 @@ public class BmWorkerWageCardServiceImpl implements BmWorkerWageCardService {
return mapper.insert(record);
}
/**
* 按需修改工资卡
*
* @param record
* @return
*/
@Override
public int updateByPrimaryKeySelective(BmWorkerWageCard record) {
record.setUpdateUser(SecurityUtils.getUsername());
//添加到文件库和minio上 TODO
return mapper.updateByPrimaryKeySelective(record);
}
/**
* 查询工资卡列表
*
@ -41,6 +61,11 @@ public class BmWorkerWageCardServiceImpl implements BmWorkerWageCardService {
return mapper.selectWageCardList(o);
}
@Override
public BmWorkerWageCard selectWageCardByWorkerId(BmWorkerWageCard o) {
return mapper.selectWageCardByWorkerId(o);
}
/**
* 删除工资卡
*

View File

@ -0,0 +1,142 @@
package com.bonus.bmw.service.impl;
import cn.hutool.core.date.DateUtil;
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.service.BmWorkerContractService;
import com.bonus.bmw.service.BmWorkerWageCardService;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import com.github.pagehelper.util.StringUtil;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.bonus.bmw.mapper.PmWorkerMapper;
import com.bonus.bmw.domain.vo.PmWorker;
import com.bonus.bmw.service.PmWorkerService;
import org.springframework.transaction.annotation.Transactional;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@Service
public class PmWorkerServiceImpl implements PmWorkerService{
@Autowired
private PmWorkerMapper mapper;
@Autowired
private BmWorkerWageCardService wageCardService;
@Autowired
private BmWorkerContractService contractService;
@Override
public int deleteByPrimaryKey(Integer id) {
return mapper.deleteByPrimaryKey(id);
}
@Override
@Transactional
public AjaxResult insert(PmWorker record) {
// 添加员工时判断员工编号是否已存在
PmWorker worker = mapper.getWorkerByNumber(record.getIdNumber());
if(worker != null && worker.getId() != null){
return new AjaxResult(500, "施工人员身份证已存在,当前系统姓名为"+worker.getName()+"如果想入场请去修改数据即可");
}
record.setCreateUser(SecurityUtils.getUsername());
int insert = mapper.insert(record);
if(insert > 0){
//入场相关数据添加
addWorkerEinData(record);
}
return new AjaxResult(200, "添加成功");
}
/**
* 基础数据添加完毕在进行入场数据添加
* @param record
*/
private void addWorkerEinData(PmWorker record) {
//工资卡和合同数据
addWorkerWageCardDataAndContract(record);
record.setEinTime(DateUtil.now());
record.setEinStatus(1);
//1.bm_worker_ein_msg
int i = mapper.insertEinMsg(record);
//2.bm_worker_ein_pro
int j = mapper.insertEinPro(record);
//3.bm_worker_ein_pro_record
int k = mapper.insertEinProRecord(record);
}
private void addWorkerWageCardDataAndContract(PmWorker record) {
BmWorkerWageCard bmWorkerWageCard = record.getBmWorkerWageCard();
BmWorkerContract bmWorkerContract = record.getBmWorkerContract();
if(StringUtil.isNotEmpty(bmWorkerWageCard.getBankCardCode())){
bmWorkerWageCard.setCreateUser(SecurityUtils.getUsername());
bmWorkerWageCard.setWorkerId(record.getId());
if(bmWorkerWageCard.getId() != null){
wageCardService.updateByPrimaryKeySelective(bmWorkerWageCard);
}else{
wageCardService.updateByPrimaryKey(bmWorkerWageCard);
}
}
if(StringUtil.isNotEmpty(bmWorkerContract.getContractCode())){
bmWorkerContract.setCreateUser(SecurityUtils.getUsername());
bmWorkerContract.setWorkerId(record.getId());
contractService.updateByPrimaryKey(bmWorkerContract);
record.setContractId(bmWorkerContract.getId());
}
}
@Override
public int insertSelective(PmWorker record) {
return mapper.insertSelective(record);
}
@Override
public PmWorker selectByPrimaryKey(Integer id) {
//人员数据
PmWorker worker = mapper.selectByPrimaryKey(id);
//查询工资卡 数据
BmWorkerWageCard wageCard = new BmWorkerWageCard();
wageCard.setWorkerId(id);
BmWorkerWageCard bmWorkerWageCard = wageCardService.selectWageCardByWorkerId(wageCard);
worker.setBmWorkerWageCard(bmWorkerWageCard);
if(worker.getEinStatus() == 1){
//查询合同数据 只有入场才会有合同
BmWorkerContract contract = new BmWorkerContract();
contract.setWorkerId(id);
BmWorkerContract workerContract = contractService.selectContractListByWorkerIdAndValid(contract);
worker.setBmWorkerContract(workerContract);
}
return worker;
}
@Override
public int updateByPrimaryKeySelective(PmWorker record) {
return mapper.updateByPrimaryKeySelective(record);
}
@Override
public int updateByPrimaryKey(PmWorker record) {
//已经入过场了
if(record.getEinStatus() == 1){
addWorkerWageCardDataAndContract(record);
}else {
addWorkerEinData(record);
}
return 1;
}
@Override
public List<PmWorker> selectWorkList(PmWorkerDto o) {
return mapper.selectWorkList(o);
}
}

View File

@ -116,4 +116,32 @@
order by
bwc.id desc
</select>
<select id="selectContractListByWorkerIdAndValid" resultMap="BaseResultMap">
SELECT
bwc.id,
bwc.contract_code,
bwc.contract_start_date,
bwc.is_active,
bwc.contract_stop_date,
bwc.contract_term_type,
bwc.contract_upload_date,
bwc.contract_invalid_date,
bwc.wage_approved_way,
bwc.wage_criterion
FROM
bm_worker_contract bwc
<where>
bwc.is_active = 1
<if test="workerId != null">
AND bwc.worker_id = #{workerId}
</if>
<if test="id != null">
AND bwc.id = #{id}
</if>
</where>
order by
bwc.id desc
limit 1
</select>
</mapper>

View File

@ -45,17 +45,61 @@
AND bwwc.is_active = 1
WHERE
pw.is_active = 1
<if test="name != null">
<if test="name != null and name != ''">
AND pw.name LIKE CONCAT('%', #{name}, '%')
</if>
<if test="idNumber != null">
<if test="idNumber != null and idNumber != ''">
AND pw.id_number LIKE CONCAT('%', #{idNumber}, '%')
</if>
<if test="phone != null">
<if test="phone != null and phone != ''">
AND pw.phone LIKE CONCAT('%', #{phone}, '%')
</if>
<if test="bankCardCode != null">
<if test="bankCardCode != null and bankCardCode != ''">
AND bwwc.bank_card_code LIKE CONCAT('%', #{bankCardCode}, '%')
</if>
<if test="workerId != null and workerId != ''">
AND bwwc.worker_id LIKE CONCAT('%', #{workerId}, '%')
</if>
</select>
<select id="selectWageCardByWorkerId" resultMap="BaseResultMap">
SELECT
pw.id as worker_id,
pw.name,
pw.id_number,
pw.phone,
bwwc.id,
bwwc.bank_card_code,
bwwc.bank_name,
bwwc.bank_branch_name,
bwwc.update_time
FROM
pm_worker pw
LEFT JOIN `bm_worker_wage_card` bwwc ON pw.id = bwwc.worker_id
AND bwwc.is_active = 1
WHERE
pw.is_active = 1
<if test="idNumber != null and idNumber != ''">
AND pw.id_number LIKE CONCAT('%', #{idNumber}, '%')
</if>
<if test="workerId != null and workerId != ''">
AND bwwc.worker_id LIKE CONCAT('%', #{workerId}, '%')
</if>
</select>
<update id="updateByPrimaryKeySelective">
update bm_worker_wage_card
<set>
<if test="bankCardCode != null and bankCardCode != ''">
bank_card_code = #{bankCardCode},
</if>
<if test="bankName != null and bankName != ''">
bank_name = #{bankName},
</if>
<if test="bankBranchName != null and bankBranchName != ''">
bank_branch_name = #{bankBranchName},
</if>
</set>
where id = #{id}
</update>
</mapper>

View File

@ -0,0 +1,341 @@
<?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.PmWorkerMapper">
<resultMap id="BaseResultMap" type="com.bonus.bmw.domain.vo.PmWorker">
<id column="id" property="id" />
<result column="name" property="name" />
<result column="id_number" property="idNumber" />
<result column="sex" property="sex" />
<result column="age" property="age" />
<result column="phone" property="phone" />
<result column="birthday" property="birthday" />
<result column="nation" property="nation" />
<result column="issuing_authority" property="issuingAuthority" />
<result column="start_time" property="startTime" />
<result column="end_time" property="endTime" />
<result column="address" property="address" />
<result column="face_photo" property="facePhoto" />
<result column="ein_status" property="einStatus" />
<result column="light_status" property="lightStatus" />
<result column="create_user" property="createUser" />
<result column="update_user" property="updateUser" />
<result column="pro_name" property="proName" />
<result column="sub_name" property="subName" />
<result column="team_name" property="teamName" />
<result column="post_name" property="postName" />
<result column="ein_time" property="einTime" />
<result column="pro_id" property="proId" />
<result column="team_id" property="teamId" />
<result column="post_id" property="postId" />
<result column="sub_id" property="subId" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, `name`, id_number, sex, age, phone, birthday, nation, issuing_authority, start_time,
end_time, address, face_photo, ein_status, light_status, create_user, update_user
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
SELECT
pw.id,
pw.`name`,
pw.id_number,
pw.sex,
pw.phone,
pw.birthday,
pw.nation,
pw.issuing_authority,
pw.start_time,
pw.end_time,
pw.address,
pw.face_photo,
bmew.pro_id,
bmew.team_id,
bmew.post_id,
bmew.sub_id,
bmew.pro_name,
bmew.sub_name,
bmew.team_name,
bmew.post_name,
IFNULL(bmew.ein_status,2) as ein_status
FROM
pm_worker pw
LEFT JOIN bm_worker_ein_msg bmew ON pw.id = bmew.worker_id
WHERE
id = #{id}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
update pm_worker set is_active = 0 where id = #{id};
update bm_worker_ein_pro set is_active = 0 where worker_id = #{id};
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.bonus.bmw.domain.vo.PmWorker" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into pm_worker (`name`, id_number, sex, age, phone, birthday, nation, issuing_authority,
start_time, end_time, address, face_photo, create_user)
values (#{name}, #{idNumber}, #{sex}, #{age}, #{phone}, #{birthday}, #{nation}, #{issuingAuthority},
#{startTime}, #{endTime}, #{address}, #{facePhoto}, #{createUser})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bonus.bmw.domain.vo.PmWorker" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into pm_worker
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">
`name`,
</if>
<if test="idNumber != null">
id_number,
</if>
<if test="sex != null">
sex,
</if>
<if test="age != null">
age,
</if>
<if test="phone != null">
phone,
</if>
<if test="birthday != null">
birthday,
</if>
<if test="nation != null">
nation,
</if>
<if test="issuingAuthority != null">
issuing_authority,
</if>
<if test="startTime != null">
start_time,
</if>
<if test="endTime != null">
end_time,
</if>
<if test="address != null">
address,
</if>
<if test="facePhoto != null">
face_photo,
</if>
<if test="einStatus != null">
ein_status,
</if>
<if test="lightStatus != null">
light_status,
</if>
<if test="createUser != null">
create_user,
</if>
<if test="updateUser != null">
update_user,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">
#{name},
</if>
<if test="idNumber != null">
#{idNumber},
</if>
<if test="sex != null">
#{sex},
</if>
<if test="age != null">
#{age},
</if>
<if test="phone != null">
#{phone},
</if>
<if test="birthday != null">
#{birthday},
</if>
<if test="nation != null">
#{nation},
</if>
<if test="issuingAuthority != null">
#{issuingAuthority},
</if>
<if test="startTime != null">
#{startTime},
</if>
<if test="endTime != null">
#{endTime},
</if>
<if test="address != null">
#{address},
</if>
<if test="facePhoto != null">
#{facePhoto},
</if>
<if test="einStatus != null">
#{einStatus},
</if>
<if test="lightStatus != null">
#{lightStatus},
</if>
<if test="createUser != null">
#{createUser},
</if>
<if test="updateUser != null">
#{updateUser},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.bonus.bmw.domain.vo.PmWorker">
<!--@mbg.generated-->
update pm_worker
<set>
<if test="name != null">
`name` = #{name},
</if>
<if test="idNumber != null">
id_number = #{idNumber},
</if>
<if test="sex != null">
sex = #{sex},
</if>
<if test="age != null">
age = #{age},
</if>
<if test="phone != null">
phone = #{phone},
</if>
<if test="birthday != null">
birthday = #{birthday},
</if>
<if test="nation != null">
nation = #{nation},
</if>
<if test="issuingAuthority != null">
issuing_authority = #{issuingAuthority},
</if>
<if test="startTime != null">
start_time = #{startTime},
</if>
<if test="endTime != null">
end_time = #{endTime},
</if>
<if test="address != null">
address = #{address},
</if>
<if test="facePhoto != null">
face_photo = #{facePhoto},
</if>
<if test="einStatus != null">
ein_status = #{einStatus},
</if>
<if test="lightStatus != null">
light_status = #{lightStatus},
</if>
<if test="createUser != null">
create_user = #{createUser},
</if>
<if test="updateUser != null">
update_user = #{updateUser},
</if>
</set>
where id = #{id}
</update>
<update id="updateByPrimaryKey" parameterType="com.bonus.bmw.domain.vo.PmWorker">
<!--@mbg.generated-->
update pm_worker
set `name` = #{name},
id_number = #{idNumber},
sex = #{sex},
age = #{age},
phone = #{phone},
birthday = #{birthday},
nation = #{nation},
issuing_authority = #{issuingAuthority},
start_time = #{startTime},
end_time = #{endTime},
address = #{address},
face_photo = #{facePhoto},
ein_status = #{einStatus},
light_status = #{lightStatus},
create_user = #{createUser},
update_user = #{updateUser}
where id = #{id}
</update>
<select id="selectWorkList" resultMap="BaseResultMap">
SELECT
pw.id,
pw.`name`,
pw.id_number,
pw.phone,
bwem.post_name,
bwem.pro_name,
bwem.sub_name,
bwem.team_name,
IFNULL(bwem.ein_status,2) as ein_status,
bwem.ein_time
FROM
pm_worker pw
LEFT JOIN bm_worker_ein_msg bwem ON pw.id = bwem.worker_id
WHERE
pw.is_active = 1
<if test="name != null and name != ''">
AND pw.`name` LIKE CONCAT('%',#{name},'%')
</if>
<if test="idNumber != null and idNumber != ''">
AND pw.id_number LIKE CONCAT('%',#{idNumber},'%')
</if>
<if test="phone != null and phone != ''">
AND pw.phone LIKE CONCAT('%',#{phone},'%')
</if>
<if test="postId != null and postId != ''">
AND bwem.post_id = #{postId}
</if>
<if test="proId != null and proId != ''">
AND bwem.pro_Id = #{proId}
</if>
<if test="subId != null and subId != ''">
AND bwem.sub_Id = #{subId}
</if>
<if test="teamId != null and teamId != ''">
AND bwem.team_Id = #{teamId}
</if>
<if test="einStatus != null and einStatus != ''">
AND IFNULL(bwem.ein_status,2) = #{einStatus}
</if>
</select>
<select id="getWorkerByNumber" resultMap="BaseResultMap">
SELECT
pw.id,
pw.`name`
FROM
pm_worker pw
WHERE
pw.id_number = #{idNumber} and pw.is_active = 1
</select>
<insert id="insertEinMsg">
INSERT INTO bm_worker_ein_msg(worker_id,post_id,post_name,pro_id,pro_name,sub_id,sub_name,team_id,team_name,ein_time
<if test="contractId != null and contractId != ''">
,contract_id
</if>
) VALUES
(#{id},#{postId},#{postName},#{proId},#{proName},#{subId},#{subName},#{teamId},#{teamName},#{einTime}
<if test="contractId != null and contractId != ''">
,#{contractId}
</if>
)
</insert>
<insert id="insertEinPro" keyColumn="einProId" keyProperty="id" useGeneratedKeys="true">
INSERT INTO bm_worker_ein_pro(worker_id,pro_id,pro_name,create_user) VALUES
(#{id},#{proId},#{proName},#{createUser})
</insert>
<insert id="insertEinProRecord">
INSERT INTO bm_worker_ein_pro_record(ein_pro_id,team_id,team_name,sub_id,sub_name,post_id,post_name,ein_time,ein_status,create_user
<if test="contractId != null and contractId != ''">
,contract_id
</if>
) VALUES
(#{einProId},#{teamId},#{teamName},#{subId},#{subName},#{postId},#{postName},#{einTime},#{einStatus},#{createUser}
<if test="contractId != null and contractId != ''">
,#{contractId}
</if>
)
</insert>
</mapper>