Commit 4cca406c authored by daijunxiong's avatar daijunxiong

定时任务---员工部门信息

员工花名册---统计数据为写死测试数据
parent 707e5868
package com.mortals.xhx.base.framework.config;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
/**
* @author djx
* @date 2023年04月10日 11:53
*/
@Component
public class JsonUtils {
@Autowired
private ObjectMapper objectMapper;
public String bean2Json(Object data) {
try {
String result = objectMapper.writeValueAsString(data);
return result;
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return null;
}
public <T> T json2Bean(String jsonData, Class<T> beanType) {
try {
T result = objectMapper.readValue(jsonData, beanType);
return result;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public <T> List<T> json2List(String jsonData, Class<T> beanType) {
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(List.class, beanType);
try {
List<T> resultList = objectMapper.readValue(jsonData, javaType);
return resultList;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public <K, V> Map<K, V> json2Map(String jsonData, Class<K> keyType, Class<V> valueType) {
JavaType javaType = objectMapper.getTypeFactory().constructMapType(Map.class, keyType, valueType);
try {
Map<K, V> resultMap = objectMapper.readValue(jsonData, javaType);
return resultMap;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
...@@ -94,6 +94,35 @@ public class ArtemisPostTest { ...@@ -94,6 +94,35 @@ public class ArtemisPostTest {
} }
public static String callPostApiGetDeptList() throws Exception {
/**
* https://ip:port/artemis/api/resource/v1/org/orgList
* 通过查阅AI Cloud开放平台文档或网关门户的文档可以看到获取组织列表的接口定义,该接口为POST请求的Rest接口, 入参为JSON字符串,接口协议为https。
* ArtemisHttpUtil工具类提供了doPostStringArtemis调用POST请求的方法,入参可传JSON字符串, 请阅读开发指南了解方法入参,没有的参数可传null
*/
ArtemisConfig config = new ArtemisConfig();
config.setHost("8.136.255.30:8001"); // 代理API网关nginx服务器ip端口
config.setAppKey("25128371"); // 秘钥appkey
config.setAppSecret("2m9RcPJOKq5j2QPQM4v5");// 秘钥appSecret
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/person/personList";
Map<String, String> paramMap = new HashMap<String, String>();// post请求Form表单参数
paramMap.put("pageNo", "1");
paramMap.put("pageSize", "10");
String body = JSON.toJSON(paramMap).toString();
Map<String, String> path = new HashMap<String, String>(2) {
{
put("http://", getCamsApi);
}
};
return ArtemisHttpUtil.doPostStringArtemis(config,path, body, null, null, "application/json");
}
/** /**
* 调用POST请求类型接口,这里以分页获取区域列表为例 * 调用POST请求类型接口,这里以分页获取区域列表为例
* 接口实际url:https://ip:port/artemis/api/api/resource/v1/regions * 接口实际url:https://ip:port/artemis/api/api/resource/v1/regions
......
package com.mortals.xhx.busiz.rsp;
import lombok.Data;
import java.util.List;
/**
* @author djx
* @date 2023年04月10日 11:56
*/
@Data
public class DeptHikData {
private int total;
private int pageNo;
private int pageSize;
private List<ListDept> list;
}
\ No newline at end of file
package com.mortals.xhx.busiz.rsp;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author djx
* @date 2023年04月10日 11:54
*/
@NoArgsConstructor
@Data
public class ListDept {
//部门编号--最底层
private String orgIndexCode;
//空
private String orgNo;
//部门名字--底层
private String orgName;
//部门全路径
private String orgPath;
//上级部门编号
private String parentOrgIndexCode;
//上层部门名臣
private Object parentOrgName;
//修改时间
private Object updateTime;
}
...@@ -4,22 +4,40 @@ import lombok.Data; ...@@ -4,22 +4,40 @@ import lombok.Data;
@Data @Data
public class ListItem{ public class ListItem{
//空
private Object birthday; private Object birthday;
//
private String orgName; private String orgName;
//空
private Object address; private Object address;
//空
private Object education; private Object education;
//性别
private int gender; private int gender;
//部门全路径
private String orgPath; private String orgPath;
//空
private Object nation; private Object nation;
//部门code
private String orgIndexCode; private String orgIndexCode;
private String updateTime; private String updateTime;
//证书
private String certificateNo; private String certificateNo;
//空
private Object phoneNo; private Object phoneNo;
//姓名
private String personName; private String personName;
//身份证信息
private PersonPhoto personPhoto; private PersonPhoto personPhoto;
//
private String jobNo; private String jobNo;
//海康id
private String personId; private String personId;
//指纹
private Object fingerPrint; private Object fingerPrint;
//空
private Object email; private Object email;
//
private int certificateType; private int certificateType;
} }
\ No newline at end of file
...@@ -3,101 +3,132 @@ package com.mortals.xhx.daemon.task; ...@@ -3,101 +3,132 @@ package com.mortals.xhx.daemon.task;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask; import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService; import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.base.framework.config.JsonUtils;
import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.busiz.hik.ArtemisPostTest;
import com.mortals.xhx.busiz.rsp.DeptHikData;
import com.mortals.xhx.busiz.rsp.ListDept;
import com.mortals.xhx.busiz.rsp.ListItem;
import com.mortals.xhx.busiz.rsp.PersonHikData;
import com.mortals.xhx.feign.user.IUserFeign;
import com.mortals.xhx.module.dept.dao.ibatis.DeptDaoImpl;
import com.mortals.xhx.module.dept.model.DeptEntity;
import com.mortals.xhx.module.staff.dao.ibatis.StaffDaoImpl;
import com.mortals.xhx.module.staff.model.StaffEntity;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/** /**
* 同步用户 * 同步用户
*/ */
@Slf4j @Slf4j
//@Service("SyncUserTask") @Service("SyncUserTask")
public class SyncUserTaskImpl implements ITaskExcuteService { public class SyncUserTaskImpl implements ITaskExcuteService {
@Autowired
private UserService userService;
@Autowired
private IUserFeign userFeign;
@Autowired
private JsonUtils jsonUtils;
@Autowired
private StaffDaoImpl staffDao;
@Autowired
private DeptDaoImpl deptDao;
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
log.info("同步用户"); log.info("同步用户--部门");
/*SitePdu sitePdu = new SitePdu(); try {
sitePdu.setId(1L); String resultPerson = ArtemisPostTest.callPostApiGetPersonList();
Rest<List<SitePdu>> siteRest = siteFeign.getFlatSitesBySiteId(sitePdu); PersonHikData personHikData = jsonUtils.json2Bean(resultPerson, PersonHikData.class);
if (siteRest.getCode() == YesNoEnum.YES.getValue()) { if (Objects.nonNull(personHikData)) {
log.info("站点总数量:{}", siteRest.getData().size()); for (ListItem list : personHikData.getList()) {
siteRest.getData().forEach(site -> { //根据id获取本地数据
log.info("站点名称:{}",site.getSiteName()); StaffEntity staffEntity1 = staffDao.get(Long.valueOf(list.getPersonId()));
DevicePdu devicePdu = new DevicePdu(); List<StaffEntity> staffEntitieList = staffDao.queryAllList();
devicePdu.setProductCode("ybj"); //判断本地数据是否为空
devicePdu.setSize(-1); if (Objects.isNull(staffEntity1)) {
Rest<RespData<List<DevicePdu>>> deviceRest = deviceFeign.list(devicePdu); //如果为空则将数据存入数据库
log.info("deviceRest:{}", JSON.toJSONString(deviceRest)); staffEntity1.setName(list.getPersonName());
if (YesNoEnum.YES.getValue() == deviceRest.getCode()) { staffEntity1.setRemark(list.getPersonId());
List<DevicePdu> devicePduList = deviceRest.getData().getData(); staffEntity1.setPhotoPath(list.getPersonPhoto().getPicUri());
log.info("样表机总数量:{}", devicePduList.size()); staffEntity1.setDeptName(list.getOrgName());
if (!ObjectUtils.isEmpty(devicePduList)) { staffEntity1.setDeptId(Long.valueOf(list.getOrgIndexCode()));
List<DeviceEntity> newDeviceList = devicePduList.stream().map(newDevice -> { staffEntity1.setDeptName(list.getOrgName());
DeviceEntity deviceEntity = new DeviceEntity(); if (list.getBirthday()!=null){
deviceEntity.initAttrValue(); staffEntity1.setBirthday((Date) list.getBirthday());
BeanUtils.copyProperties(newDevice, deviceEntity, BeanUtil.getNullPropertyNames(newDevice)); }
return deviceEntity; if (list.getPhoneNo()!=null){
}).collect(Collectors.toList()); staffEntity1.setPhoneNumber(String.valueOf(list.getPhoneNo()));
}
List<DeviceEntity> oldDeviceList = deviceService.find(new DeviceQuery().siteId(site.getId())); staffDao.insert(staffEntity1);
Map<String, DeviceEntity> oldDeviceMap = oldDeviceList.stream().collect(Collectors.toMap(x -> x.getDeviceCode(), y -> y, (o, n) -> n)); }
Map<String, DeviceEntity> newDeviceMap = newDeviceList.stream().collect(Collectors.toMap(x -> x.getDeviceCode(), y -> y, (o, n) -> n)); //本地数据不为空
else {
List<DeviceEntity> updateDeviceLsit = newDeviceList.stream().map(item -> { //本地数据遍历数据
if (oldDeviceMap.containsKey(item.getDeviceCode())) { for (StaffEntity staffEntity : staffEntitieList) {
item.setId(oldDeviceMap.get(item.getDeviceCode()).getId()); //如果本地的id等于海康的id
item.setDeviceId(item.getId()); if (staffEntity.getRemark().equals(list.getPersonId())) {
item.setProductCode(oldDeviceMap.get(item.getDeviceCode()).getProductCode()); //执行修改
item.setProductName(oldDeviceMap.get(item.getDeviceCode()).getProductName()); staffEntity.setName(list.getPersonName());
item.setUpdateTime(new Date()); staffEntity.setPhotoPath(list.getPersonPhoto().getPicUri());
return item; staffEntity.setDeptName(list.getOrgName());
} staffDao.update(staffEntity);
return null; }
}).filter(f -> f != null).collect(Collectors.toList()); for (ListItem item :personHikData.getList()){
//如果本地id不等于海康id并且海康id不等于本地id
List<DeviceEntity> saveDeviceList = newDeviceList.stream().map(item -> { if (!item.getPersonId().equals(staffEntity.getRemark())){
if (!oldDeviceMap.containsKey(item.getDeviceCode())) { //否则执行删除
item.setDeviceId(item.getId()); staffDao.delete(Long.valueOf(staffEntity.getRemark()));
item.setCreateUserId(1L);
item.setCreateUserName("系统管理员"); }
item.setCreateTime(new Date()); }
return item;
}
return null;
}).filter(f -> f != null).collect(Collectors.toList());
//做差集
List<Long> delDeviceList = oldDeviceList.stream().map(item -> {
if (!newDeviceMap.containsKey(item.getDeviceCode())) {
return item.getId();
}
return null;
}).filter(f -> f != null).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(updateDeviceLsit)) {
log.info("设备更新,size:{}", updateDeviceLsit.size());
deviceService.update(updateDeviceLsit);
}
if (!ObjectUtils.isEmpty(saveDeviceList)) {
log.info("设备新增,size:{}", saveDeviceList.size());
deviceService.save(saveDeviceList);
}
if (!ObjectUtils.isEmpty(delDeviceList)) {
log.info("设备删除,size:{}", delDeviceList.size());
deviceService.remove(delDeviceList,null);
}
}
} else {
log.info("设备列表查询异常,{}", JSON.toJSONString(deviceRest));
}
});
} else {
log.info("站点列表查询异常,{}", JSON.toJSONString(siteRest));
}*/
} }
}
}
}
String resultDept = ArtemisPostTest.callPostApiGetDeptList();
DeptHikData deptHikData = jsonUtils.json2Bean(resultDept,DeptHikData.class);
if (Objects.isNull(deptHikData)){
for (ListDept listDept:deptHikData.getList()){
DeptEntity deptEntity = deptDao.get(Long.valueOf(listDept.getOrgIndexCode()));
List<DeptEntity> deptEntityList = deptDao.queryAllList();
if (Objects.isNull(deptEntity)){
deptEntity.setDeptName(listDept.getOrgName());
deptEntity.setParentId(Long.valueOf(listDept.getParentOrgIndexCode()));
deptEntity.setAncestors(listDept.getOrgPath());
deptDao.insert(deptEntity);
}else {
for (DeptEntity deptEntity1 :deptEntityList){
if (!deptEntity1.getParentId().equals(listDept.getOrgIndexCode())){
deptEntity1.setAncestors(listDept.getOrgPath());
deptEntity1.setDeptName(listDept.getOrgName());
deptDao.update(deptEntity1);
}
for (ListDept dept : deptHikData.getList()){
if (!dept.getOrgIndexCode().equals(deptEntity1.getParentId())){
deptDao.delete(Long.valueOf(listDept.getOrgIndexCode()));
}
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override @Override
......
...@@ -21,4 +21,9 @@ public interface DeptDao extends ICRUDDao<DeptEntity,Long>{ ...@@ -21,4 +21,9 @@ public interface DeptDao extends ICRUDDao<DeptEntity,Long>{
*/ */
List<DeptEntity> selectChildrenDeptById(String deptId); List<DeptEntity> selectChildrenDeptById(String deptId);
/**
* 查询所有数据
* */
List<DeptEntity> queryAllList();
} }
package com.mortals.xhx.module.dept.dao.ibatis; package com.mortals.xhx.module.dept.dao.ibatis;
import org.springframework.stereotype.Repository; import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import com.mortals.xhx.module.dept.dao.DeptDao; import com.mortals.xhx.module.dept.dao.DeptDao;
import com.mortals.xhx.module.dept.model.DeptEntity; import com.mortals.xhx.module.dept.model.DeptEntity;
import java.util.Date; import org.springframework.stereotype.Repository;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import java.util.List; import java.util.List;
/** /**
* 部门信息DaoImpl DAO接口 * 部门信息DaoImpl DAO接口
...@@ -22,4 +22,9 @@ public class DeptDaoImpl extends BaseCRUDDaoMybatis<DeptEntity,Long> implements ...@@ -22,4 +22,9 @@ public class DeptDaoImpl extends BaseCRUDDaoMybatis<DeptEntity,Long> implements
return getSqlSession().selectList(getSqlId("selectChildrenDeptById"), deptId); return getSqlSession().selectList(getSqlId("selectChildrenDeptById"), deptId);
} }
@Override
public List<DeptEntity> queryAllList() {
return null;
}
} }
...@@ -2,7 +2,9 @@ package com.mortals.xhx.module.staff.dao; ...@@ -2,7 +2,9 @@ package com.mortals.xhx.module.staff.dao;
import com.mortals.framework.dao.ICRUDDao; import com.mortals.framework.dao.ICRUDDao;
import com.mortals.xhx.module.staff.model.StaffEntity; import com.mortals.xhx.module.staff.model.StaffEntity;
import java.util.List; import java.util.List;
/** /**
* 员工基本信息Dao * 员工基本信息Dao
* 员工基本信息 DAO接口 * 员工基本信息 DAO接口
...@@ -14,4 +16,9 @@ import java.util.List; ...@@ -14,4 +16,9 @@ import java.util.List;
public interface StaffDao extends ICRUDDao<StaffEntity,Long>{ public interface StaffDao extends ICRUDDao<StaffEntity,Long>{
/**
* 查询所有
* */
List<StaffEntity> queryAllList();
} }
package com.mortals.xhx.module.staff.dao.ibatis; package com.mortals.xhx.module.staff.dao.ibatis;
import org.springframework.stereotype.Repository; import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import com.mortals.xhx.module.staff.dao.StaffDao; import com.mortals.xhx.module.staff.dao.StaffDao;
import com.mortals.xhx.module.staff.model.StaffEntity; import com.mortals.xhx.module.staff.model.StaffEntity;
import java.util.Date; import org.springframework.stereotype.Repository;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import java.util.List; import java.util.List;
/** /**
* 员工基本信息DaoImpl DAO接口 * 员工基本信息DaoImpl DAO接口
...@@ -17,5 +17,8 @@ import java.util.List; ...@@ -17,5 +17,8 @@ import java.util.List;
public class StaffDaoImpl extends BaseCRUDDaoMybatis<StaffEntity,Long> implements StaffDao { public class StaffDaoImpl extends BaseCRUDDaoMybatis<StaffEntity,Long> implements StaffDao {
@Override
public List<StaffEntity> queryAllList() {
return null;
}
} }
package com.mortals.xhx.module.staff.model; package com.mortals.xhx.module.staff.model;
import java.util.Date;
import java.util.List;
import java.util.ArrayList;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.staff.model.vo.StaffVo; import com.mortals.xhx.module.staff.model.vo.StaffVo;
import java.util.Date;
/** /**
* 员工基本信息实体对象 * 员工基本信息实体对象
* *
...@@ -93,6 +89,10 @@ public class StaffEntity extends StaffVo { ...@@ -93,6 +89,10 @@ public class StaffEntity extends StaffVo {
* 备注 * 备注
*/ */
private String remark; private String remark;
/**
* 备注id
*/
private String remarkId;
/** /**
* 员工来源(1.外部,2.内部) * 员工来源(1.外部,2.内部)
*/ */
...@@ -367,6 +367,20 @@ public class StaffEntity extends StaffVo { ...@@ -367,6 +367,20 @@ public class StaffEntity extends StaffVo {
public void setRemark(String remark){ public void setRemark(String remark){
this.remark = remark; this.remark = remark;
} }
/**
* 获取 备注id
* @return String
*/
public String getRemarkId(){
return remarkId;
}
/**
* 设置 备注id
* @param remarkId
*/
public void setRemarkId(String remarkId){
this.remarkId = remarkId;
}
/** /**
* 获取 员工来源(1.外部,2.内部) * 获取 员工来源(1.外部,2.内部)
* @return Integer * @return Integer
...@@ -422,6 +436,7 @@ public class StaffEntity extends StaffVo { ...@@ -422,6 +436,7 @@ public class StaffEntity extends StaffVo {
sb.append(",regularDate:").append(getRegularDate()); sb.append(",regularDate:").append(getRegularDate());
sb.append(",leaveDate:").append(getLeaveDate()); sb.append(",leaveDate:").append(getLeaveDate());
sb.append(",remark:").append(getRemark()); sb.append(",remark:").append(getRemark());
sb.append(",remarkId:").append(getRemarkId());
sb.append(",source:").append(getSource()); sb.append(",source:").append(getSource());
return sb.toString(); return sb.toString();
} }
...@@ -466,6 +481,8 @@ public class StaffEntity extends StaffVo { ...@@ -466,6 +481,8 @@ public class StaffEntity extends StaffVo {
this.remark = ""; this.remark = "";
this.remarkId = "";
this.source = 1; this.source = 1;
} }
} }
\ No newline at end of file
package com.mortals.xhx.module.staff.model; package com.mortals.xhx.module.staff.model;
import java.util.Date;
import java.util.List; import java.util.List;
import com.mortals.xhx.module.staff.model.StaffEntity;
/** /**
* 员工基本信息查询对象 * 员工基本信息查询对象
* *
* @author zxfei * @author zxfei
* @date 2023-04-08 * @date 2023-04-10
*/ */
public class StaffQuery extends StaffEntity { public class StaffQuery extends StaffEntity {
/** 开始 序号,主键,自增长 */ /** 开始 序号,主键,自增长 */
...@@ -226,6 +224,11 @@ public class StaffQuery extends StaffEntity { ...@@ -226,6 +224,11 @@ public class StaffQuery extends StaffEntity {
/** 结束 更新时间 */ /** 结束 更新时间 */
private String updateTimeEnd; private String updateTimeEnd;
/** 备注id */
private List<String> remarkIdList;
/** 备注id排除列表 */
private List <String> remarkIdNotList;
/** 开始 员工来源(1.外部,2.内部) */ /** 开始 员工来源(1.外部,2.内部) */
private Integer sourceStart; private Integer sourceStart;
...@@ -1458,6 +1461,38 @@ public class StaffQuery extends StaffEntity { ...@@ -1458,6 +1461,38 @@ public class StaffQuery extends StaffEntity {
this.updateTimeEnd = updateTimeEnd; this.updateTimeEnd = updateTimeEnd;
} }
/**
* 获取 备注id
* @return remarkIdList
*/
public List<String> getRemarkIdList(){
return this.remarkIdList;
}
/**
* 设置 备注id
* @param remarkIdList
*/
public void setRemarkIdList(List<String> remarkIdList){
this.remarkIdList = remarkIdList;
}
/**
* 获取 备注id
* @return remarkIdNotList
*/
public List<String> getRemarkIdNotList(){
return this.remarkIdNotList;
}
/**
* 设置 备注id
* @param remarkIdNotList
*/
public void setRemarkIdNotList(List<String> remarkIdNotList){
this.remarkIdNotList = remarkIdNotList;
}
/** /**
* 获取 开始 员工来源(1.外部,2.内部) * 获取 开始 员工来源(1.外部,2.内部)
* @return sourceStart * @return sourceStart
...@@ -2202,6 +2237,25 @@ public class StaffQuery extends StaffEntity { ...@@ -2202,6 +2237,25 @@ public class StaffQuery extends StaffEntity {
} }
/**
* 设置 备注id
* @param remarkId
*/
public StaffQuery remarkId(String remarkId){
setRemarkId(remarkId);
return this;
}
/**
* 设置 备注id
* @param remarkIdList
*/
public StaffQuery remarkIdList(List<String> remarkIdList){
this.remarkIdList = remarkIdList;
return this;
}
/** /**
* 设置 员工来源(1.外部,2.内部) * 设置 员工来源(1.外部,2.内部)
* @param source * @param source
......
package com.mortals.xhx.module.staff.model.vo;
import lombok.Data;
import java.util.Date;
/**
* @author djx
* @date 2023年04月10日 14:20
*/
@Data
public class HolidayListVo {
//姓名
private String workName;
//状态
private String workStatus;
//部门
private String workDept;
//在职期限
private String workLimit;
//入职时间
private Date workBeginDay;
//转正时间
private Date workFormalDay;
//本月实际出勤天数
private String attendanceCount;
//请假天数
private String leaveCount;
//迟到早退天数
private String lateCount;
//矿工天数
private String minerCount;
//缺卡次数
private String lackCardCount;
//加班天数
private String workOverDay;
//调休
private String compensatoryDay;
//婚假
private String marriageHoliday;
//年假
private String winterHoliday;
//陪产假
private String paternityLeaveDay;
}
package com.mortals.xhx.module.staff.model.vo; package com.mortals.xhx.module.staff.model.vo;
import com.mortals.framework.model.BaseEntityLong; import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.staff.model.StaffEntity;
import lombok.Data; import lombok.Data;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* 员工基本信息视图对象 * 员工基本信息视图对象
...@@ -16,7 +14,5 @@ public class StaffVo extends BaseEntityLong { ...@@ -16,7 +14,5 @@ public class StaffVo extends BaseEntityLong {
private List <Long> idList; private List <Long> idList;
private List<HolidayListVo> holidayLists;
private List<holidayInfoVo> holidayInfoVoList;
} }
\ No newline at end of file
package com.mortals.xhx.module.staff.web; package com.mortals.xhx.module.staff.web;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.StatusEnum; import com.mortals.xhx.module.staff.model.StaffEntity;
import com.mortals.xhx.module.staff.model.vo.HolidayListVo;
import com.mortals.xhx.module.staff.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.staff.model.StaffEntity;
import com.mortals.xhx.module.staff.service.StaffService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.*; import java.util.ArrayList;
import java.util.stream.Collectors; import java.util.Date;
import com.alibaba.fastjson.JSONObject; import java.util.List;
import org.springframework.web.bind.annotation.*; import java.util.Map;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
/** /**
* *
* 员工基本信息 * 员工基本信息
...@@ -64,7 +57,26 @@ public class StaffController extends BaseCRUDJsonBodyMappingController<StaffServ ...@@ -64,7 +57,26 @@ public class StaffController extends BaseCRUDJsonBodyMappingController<StaffServ
@Override @Override
protected int infoAfter(Long id, Map<String, Object> model, StaffEntity entity, Context context) throws AppException { protected int infoAfter(Long id, Map<String, Object> model, StaffEntity entity, Context context) throws AppException {
//todo 员工统计信息 //todo 员工统计信息
entity.setHolidayInfoVoList(new ArrayList<>()); List<HolidayListVo> holidayListVos = new ArrayList<>();
HolidayListVo vo =new HolidayListVo();
vo.setWorkName("测试");
vo.setWorkStatus("正式");
vo.setWorkDept("技术部门");
vo.setWorkLimit("1003");
vo.setWorkBeginDay(new Date(2020-03-01));
vo.setWorkFormalDay(new Date(2020-04-31));
vo.setAttendanceCount("22");
vo.setLeaveCount("2");
vo.setLateCount("1");
vo.setMinerCount("1");
vo.setLackCardCount("0");
vo.setWorkOverDay("2");
vo.setCompensatoryDay("10");
vo.setMarriageHoliday("10");
vo.setWinterHoliday("10");
vo.setPaternityLeaveDay("10");
holidayListVos.add(vo);
entity.setHolidayLists(holidayListVos);
// StaffEntity cache = this.service.getCache(entity.getWorkNum()); // StaffEntity cache = this.service.getCache(entity.getWorkNum());
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
<result property="createTime" column="createTime" /> <result property="createTime" column="createTime" />
<result property="updateUserId" column="updateUserId" /> <result property="updateUserId" column="updateUserId" />
<result property="updateTime" column="updateTime" /> <result property="updateTime" column="updateTime" />
<result property="remarkId" column="remarkId" />
<result property="source" column="source" /> <result property="source" column="source" />
</resultMap> </resultMap>
...@@ -109,6 +110,9 @@ ...@@ -109,6 +110,9 @@
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('updateTime') or colPickMode == 1 and data.containsKey('updateTime')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('updateTime') or colPickMode == 1 and data.containsKey('updateTime')))">
a.updateTime, a.updateTime,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('remarkId') or colPickMode == 1 and data.containsKey('remarkId')))">
a.remarkId,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('source') or colPickMode == 1 and data.containsKey('source')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('source') or colPickMode == 1 and data.containsKey('source')))">
a.source, a.source,
</if> </if>
...@@ -117,18 +121,18 @@ ...@@ -117,18 +121,18 @@
<!-- 新增 区分主键自增加还是业务插入 --> <!-- 新增 区分主键自增加还是业务插入 -->
<insert id="insert" parameterType="StaffEntity" useGeneratedKeys="true" keyProperty="id"> <insert id="insert" parameterType="StaffEntity" useGeneratedKeys="true" keyProperty="id">
insert into mortals_xhx_staff insert into mortals_xhx_staff
(name,gender,birthday,photoPath,phoneNumber,idCard,workNum,politicalstatus,deptId,deptName,positionId,positionName,staffType,status,registerPath,entryDate,regularDate,leaveDate,remark,createUserId,createTime,updateUserId,updateTime,source) (name,gender,birthday,photoPath,phoneNumber,idCard,workNum,politicalstatus,deptId,deptName,positionId,positionName,staffType,status,registerPath,entryDate,regularDate,leaveDate,remark,createUserId,createTime,updateUserId,updateTime,remarkId,source)
VALUES VALUES
(#{name},#{gender},#{birthday},#{photoPath},#{phoneNumber},#{idCard},#{workNum},#{politicalstatus},#{deptId},#{deptName},#{positionId},#{positionName},#{staffType},#{status},#{registerPath},#{entryDate},#{regularDate},#{leaveDate},#{remark},#{createUserId},#{createTime},#{updateUserId},#{updateTime},#{source}) (#{name},#{gender},#{birthday},#{photoPath},#{phoneNumber},#{idCard},#{workNum},#{politicalstatus},#{deptId},#{deptName},#{positionId},#{positionName},#{staffType},#{status},#{registerPath},#{entryDate},#{regularDate},#{leaveDate},#{remark},#{createUserId},#{createTime},#{updateUserId},#{updateTime},#{remarkId},#{source})
</insert> </insert>
<!-- 批量新增 --> <!-- 批量新增 -->
<insert id="insertBatch" parameterType="paramDto"> <insert id="insertBatch" parameterType="paramDto">
insert into mortals_xhx_staff insert into mortals_xhx_staff
(name,gender,birthday,photoPath,phoneNumber,idCard,workNum,politicalstatus,deptId,deptName,positionId,positionName,staffType,status,registerPath,entryDate,regularDate,leaveDate,remark,createUserId,createTime,updateUserId,updateTime,source) (name,gender,birthday,photoPath,phoneNumber,idCard,workNum,politicalstatus,deptId,deptName,positionId,positionName,staffType,status,registerPath,entryDate,regularDate,leaveDate,remark,createUserId,createTime,updateUserId,updateTime,remarkId,source)
VALUES VALUES
<foreach collection="data.dataList" item="item" index="index" separator="," > <foreach collection="data.dataList" item="item" index="index" separator="," >
(#{item.name},#{item.gender},#{item.birthday},#{item.photoPath},#{item.phoneNumber},#{item.idCard},#{item.workNum},#{item.politicalstatus},#{item.deptId},#{item.deptName},#{item.positionId},#{item.positionName},#{item.staffType},#{item.status},#{item.registerPath},#{item.entryDate},#{item.regularDate},#{item.leaveDate},#{item.remark},#{item.createUserId},#{item.createTime},#{item.updateUserId},#{item.updateTime},#{item.source}) (#{item.name},#{item.gender},#{item.birthday},#{item.photoPath},#{item.phoneNumber},#{item.idCard},#{item.workNum},#{item.politicalstatus},#{item.deptId},#{item.deptName},#{item.positionId},#{item.positionName},#{item.staffType},#{item.status},#{item.registerPath},#{item.entryDate},#{item.regularDate},#{item.leaveDate},#{item.remark},#{item.createUserId},#{item.createTime},#{item.updateUserId},#{item.updateTime},#{item.remarkId},#{item.source})
</foreach> </foreach>
</insert> </insert>
...@@ -231,6 +235,9 @@ ...@@ -231,6 +235,9 @@
<if test="(colPickMode==0 and data.containsKey('updateTime')) or (colPickMode==1 and !data.containsKey('updateTime'))"> <if test="(colPickMode==0 and data.containsKey('updateTime')) or (colPickMode==1 and !data.containsKey('updateTime'))">
a.updateTime=#{data.updateTime}, a.updateTime=#{data.updateTime},
</if> </if>
<if test="(colPickMode==0 and data.containsKey('remarkId')) or (colPickMode==1 and !data.containsKey('remarkId'))">
a.remarkId=#{data.remarkId},
</if>
<if test="(colPickMode==0 and data.containsKey('source')) or (colPickMode==1 and !data.containsKey('source'))"> <if test="(colPickMode==0 and data.containsKey('source')) or (colPickMode==1 and !data.containsKey('source'))">
a.source=#{data.source}, a.source=#{data.source},
</if> </if>
...@@ -450,6 +457,13 @@ ...@@ -450,6 +457,13 @@
</if> </if>
</foreach> </foreach>
</trim> </trim>
<trim prefix="remarkId=(case" suffix="ELSE remarkId end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<if test="(colPickMode==0 and item.containsKey('remarkId')) or (colPickMode==1 and !item.containsKey('remarkId'))">
when a.id=#{item.id} then #{item.remarkId}
</if>
</foreach>
</trim>
<trim prefix="source=(case" suffix="ELSE source end),"> <trim prefix="source=(case" suffix="ELSE source end),">
<foreach collection="data.dataList" item="item" index="index" separator="" > <foreach collection="data.dataList" item="item" index="index" separator="" >
<choose> <choose>
...@@ -1100,6 +1114,27 @@ ...@@ -1100,6 +1114,27 @@
<if test="conditionParamRef.containsKey('updateTimeEnd') and conditionParamRef.updateTimeEnd != null and conditionParamRef.updateTimeEnd!=''"> <if test="conditionParamRef.containsKey('updateTimeEnd') and conditionParamRef.updateTimeEnd != null and conditionParamRef.updateTimeEnd!=''">
${_conditionType_} a.updateTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.updateTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s') ${_conditionType_} a.updateTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.updateTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s')
</if> </if>
<if test="conditionParamRef.containsKey('remarkId')">
<if test="conditionParamRef.remarkId != null and conditionParamRef.remarkId != ''">
${_conditionType_} a.remarkId like #{${_conditionParam_}.remarkId}
</if>
<if test="conditionParamRef.remarkId == null">
${_conditionType_} a.remarkId is null
</if>
</if>
<if test="conditionParamRef.containsKey('remarkIdList')">
${_conditionType_} a.remarkId in
<foreach collection="conditionParamRef.remarkIdList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('remarkIdNotList')">
${_conditionType_} a.remarkId not in
<foreach collection="conditionParamRef.remarkIdNotList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('source')"> <if test="conditionParamRef.containsKey('source')">
<if test="conditionParamRef.source != null "> <if test="conditionParamRef.source != null ">
${_conditionType_} a.source = #{${_conditionParam_}.source} ${_conditionType_} a.source = #{${_conditionParam_}.source}
...@@ -1260,6 +1295,11 @@ ...@@ -1260,6 +1295,11 @@
<if test='orderCol.updateTime != null and "DESC".equalsIgnoreCase(orderCol.updateTime)'>DESC</if> <if test='orderCol.updateTime != null and "DESC".equalsIgnoreCase(orderCol.updateTime)'>DESC</if>
, ,
</if> </if>
<if test="orderCol.containsKey('remarkId')">
a.remarkId
<if test='orderCol.remarkId != null and "DESC".equalsIgnoreCase(orderCol.remarkId)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('source')"> <if test="orderCol.containsKey('source')">
a.source a.source
<if test='orderCol.source != null and "DESC".equalsIgnoreCase(orderCol.source)'>DESC</if> <if test='orderCol.source != null and "DESC".equalsIgnoreCase(orderCol.source)'>DESC</if>
......
...@@ -56,10 +56,11 @@ client.global.set("Staff_id", JSON.parse(response.body).data.id); ...@@ -56,10 +56,11 @@ client.global.set("Staff_id", JSON.parse(response.body).data.id);
%} %}
###员工基本信息查看 ###员工基本信息查看
GET {{baseUrl}}/staff/info?id={{Staff_id}} GET {{baseUrl}}/staff/info?id=1
Authorization: {{authToken}} Authorization: {{authToken}}
Accept: application/json Accept: application/json
###员工基本信息编辑 ###员工基本信息编辑
GET {{baseUrl}}/staff/edit?id={{Staff_id}} GET {{baseUrl}}/staff/edit?id={{Staff_id}}
Authorization: {{authToken}} Authorization: {{authToken}}
......
...@@ -14,9 +14,16 @@ INSERT INTO `mortals_xhx_resource` VALUES (null, '员工基本信息-菜单管 ...@@ -14,9 +14,16 @@ INSERT INTO `mortals_xhx_resource` VALUES (null, '员工基本信息-菜单管
-- ---------------------------- -- ----------------------------
INSERT INTO `mortals_xhx_param` VALUES (null, '性别', 'Staff', 'gender', '1', '男', 1, 4, 0, 'gender', NULL, NULL, NULL); INSERT INTO `mortals_xhx_param` VALUES (null, '性别', 'Staff', 'gender', '1', '男', 1, 4, 0, 'gender', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '性别', 'Staff', 'gender', '2', '女', 1, 4, 0, 'gender', NULL, NULL, NULL); INSERT INTO `mortals_xhx_param` VALUES (null, '性别', 'Staff', 'gender', '2', '女', 1, 4, 0, 'gender', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '政治面貌 ', 'Staff', 'politicalstatus', '1', '中共党员', 1, 4, 0, 'politicalstatus', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '政治面貌 ', 'Staff', 'politicalstatus', '2', '中共预备党员', 1, 4, 0, 'politicalstatus', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '政治面貌 ', 'Staff', 'politicalstatus', '3', '共青团员', 1, 4, 0, 'politicalstatus', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '政治面貌 ', 'Staff', 'politicalstatus', '4', '群众', 1, 4, 0, 'politicalstatus', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '政治面貌 ', 'Staff', 'politicalstatus', '5', '其它', 1, 4, 0, 'politicalstatus', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '员工状态', 'Staff', 'status', '1', '正式', 1, 4, 0, 'status', NULL, NULL, NULL); INSERT INTO `mortals_xhx_param` VALUES (null, '员工状态', 'Staff', 'status', '1', '正式', 1, 4, 0, 'status', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '员工状态', 'Staff', 'status', '2', '试用', 1, 4, 0, 'status', NULL, NULL, NULL); INSERT INTO `mortals_xhx_param` VALUES (null, '员工状态', 'Staff', 'status', '2', '试用', 1, 4, 0, 'status', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '员工状态', 'Staff', 'status', '3', '离职', 1, 4, 0, 'status', NULL, NULL, NULL); INSERT INTO `mortals_xhx_param` VALUES (null, '员工状态', 'Staff', 'status', '3', '离职', 1, 4, 0, 'status', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '员工来源', 'Staff', 'source', '1', '外部', 1, 4, 0, 'source', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '员工来源', 'Staff', 'source', '2', '内部', 1, 4, 0, 'source', NULL, NULL, NULL);
-- ---------------------------- -- ----------------------------
-- 员工关怀信息菜单 SQL -- 员工关怀信息菜单 SQL
-- ---------------------------- -- ----------------------------
......
...@@ -50,12 +50,14 @@ CREATE TABLE mortals_xhx_staff( ...@@ -50,12 +50,14 @@ CREATE TABLE mortals_xhx_staff(
`createTime` datetime NOT NULL COMMENT '创建时间', `createTime` datetime NOT NULL COMMENT '创建时间',
`updateUserId` bigint(20) COMMENT '更新用户', `updateUserId` bigint(20) COMMENT '更新用户',
`updateTime` datetime COMMENT '更新时间', `updateTime` datetime COMMENT '更新时间',
`remarkId` varchar(255) COMMENT '备注id',
`source` tinyint(2) DEFAULT '1' COMMENT '员工来源(1.外部,2.内部)', `source` tinyint(2) DEFAULT '1' COMMENT '员工来源(1.外部,2.内部)',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='员工基本信息'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='员工基本信息';
-- ---------------------------- -- ----------------------------
-- 员工关怀信息表 -- 员工关怀信息表
-- ---------------------------- -- ----------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment