入职接口
This commit is contained in:
parent
b4a1915aaf
commit
3783ad2dc7
|
|
@ -0,0 +1,9 @@
|
|||
package com.weaver.seconddev.jcl.common.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface CommonService {
|
||||
Map<String, Object> updateCommon(Map<String,Object> param);
|
||||
|
||||
Map<String, Object> insertCommon(Map<String,Object> param);
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
package com.weaver.seconddev.jcl.common.service.impl;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.weaver.seconddev.jcl.common.service.CommonService;
|
||||
import com.weaver.seconddev.jcl.organization.util.CommonUtils;
|
||||
import com.weaver.seconddev.jcl.organization.util.DatabaseUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class CommonServiceImpl implements CommonService {
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> updateCommon(Map<String, Object> param) {
|
||||
String tableName = CommonUtils.null2String(param.get("tableName"));
|
||||
Map<String,Object> dataMap = (Map<String,Object>)param.get("dataMap");
|
||||
Map<String,Object> condition = (Map<String,Object>)param.get("condition");
|
||||
String updateSql = "update "+tableName+" set ";
|
||||
for (Map.Entry<String,Object> e : dataMap.entrySet()){
|
||||
if (e.getValue() !=null && !"".equals(e.getValue()) && !e.getKey().equals("id")){
|
||||
updateSql = updateSql + e.getKey()+"='"+e.getValue().toString()+"',";
|
||||
}
|
||||
}
|
||||
updateSql = updateSql.substring(0,updateSql.length()-1) + " where 1=1";
|
||||
for (Map.Entry<String,Object> e : condition.entrySet()){
|
||||
updateSql = updateSql + " and "+ e.getKey()+"='"+e.getValue()+"'";
|
||||
}
|
||||
log.info("makeUpdateSql : [{}]",updateSql);
|
||||
return databaseUtils.execute(updateSql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> insertCommon(Map<String, Object> param) {
|
||||
|
||||
Map<String,String> dataMap = (Map<String,String>)param.get("dataMap");
|
||||
String tableName = CommonUtils.null2String(param.get("tableName"));
|
||||
|
||||
String insertSql = "insert into "+tableName;
|
||||
String key = "(";
|
||||
String value = "(";
|
||||
List<String> dataList = Lists.newArrayList();
|
||||
for (Map.Entry<String,String> e : dataMap.entrySet()){
|
||||
if (e.getValue() != null && !"".equals(e.getValue())){
|
||||
key = key + e.getKey() +",";
|
||||
value = value + "?" +",";
|
||||
dataList.add(e.getValue());
|
||||
}
|
||||
}
|
||||
key = key.substring(0,key.length()-1) + ")";
|
||||
value = value.substring(0,value.length()-1)+")";
|
||||
insertSql = insertSql + key +" values "+value;
|
||||
log.debug("makeInsertSql : [{}]",insertSql);
|
||||
log.debug("needInsertDate: [{}]",dataList);
|
||||
return databaseUtils.execute(insertSql,dataList);
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.weaver.seconddev.jcl.organization.controller;
|
|||
|
||||
import com.weaver.common.authority.annotation.WeaPermission;
|
||||
import com.weaver.seconddev.jcl.organization.entity.Employee;
|
||||
import com.weaver.seconddev.jcl.organization.entity.PendingEmployee;
|
||||
import com.weaver.seconddev.jcl.organization.service.EmployeeInformationService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -30,7 +31,7 @@ public class EmployeeInformationController {
|
|||
private EmployeeInformationService employeeInformationService;
|
||||
|
||||
/**
|
||||
* 查询结果回写数据
|
||||
* 获得员工信息
|
||||
* @return
|
||||
*/
|
||||
@WeaPermission(publicPermission = true)
|
||||
|
|
@ -39,9 +40,40 @@ public class EmployeeInformationController {
|
|||
public Map<String, Object> getInformation(@RequestBody Employee employee){
|
||||
log.error("getInformation Employee:[{}]",employee);
|
||||
Map<String, Object> actionMap = new HashMap<>();
|
||||
List<Map<String, Object>> resultList = employeeInformationService.getInformation(employee);
|
||||
actionMap.put("userInforMation",employeeInformationService.getInformation(employee));
|
||||
actionMap.put("pendingEmployment",employeeInformationService.getPendingEmployment(employee));
|
||||
|
||||
return actionMap;
|
||||
}
|
||||
/**
|
||||
* 获得待入职员工共信息
|
||||
* @return
|
||||
*/
|
||||
@WeaPermission(publicPermission = true)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@PostMapping("/getPendingEmployment")
|
||||
public Map<String, Object> getPendingEmployment(@RequestBody Employee employee){
|
||||
log.error("getInformation Employee:[{}]",employee);
|
||||
Map<String, Object> actionMap = new HashMap<>();
|
||||
List<Map<String, Object>> resultList = employeeInformationService.getPendingEmployment(employee);
|
||||
actionMap.put("resultList",resultList);
|
||||
|
||||
return actionMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得待入职员工共信息
|
||||
* @return
|
||||
*/
|
||||
@WeaPermission(publicPermission = true)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@PostMapping("/getPendingEmployment")
|
||||
public Map<String, Object> updatePendingEmploy(@RequestBody PendingEmployee employee){
|
||||
log.error("getInformation Employee:[{}]",employee);
|
||||
Map<String, Object> actionMap = new HashMap<>();
|
||||
//List<Map<String, Object>> resultList = employeeInformationService.getPendingEmployment(employee);
|
||||
// actionMap.put("resultList",resultList);
|
||||
|
||||
return actionMap;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,33 +18,33 @@ public class Employee {
|
|||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String xm;
|
||||
private String username;
|
||||
/**
|
||||
* 员工状态
|
||||
*/
|
||||
private String ygzt;
|
||||
private String personnel_status;
|
||||
/**
|
||||
* 入职日期
|
||||
*/
|
||||
private String rzrq;
|
||||
private String hiredate;
|
||||
/**
|
||||
*手机
|
||||
*/
|
||||
private String sj_woiy;
|
||||
private String mobile;
|
||||
/**
|
||||
*邮箱
|
||||
*/
|
||||
private String yx_gvex;
|
||||
private String email;
|
||||
/**
|
||||
*身份证
|
||||
*/
|
||||
private String sfz_1mhf;
|
||||
private String id_no;
|
||||
/**
|
||||
*所属部门
|
||||
*/
|
||||
private String ssbm;
|
||||
private String department;
|
||||
/**
|
||||
*所属公司
|
||||
*/
|
||||
private String ssgs;
|
||||
private String subcompany;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
package com.weaver.seconddev.jcl.organization.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
/**
|
||||
* uf_jcl_rzgl
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PendingEmployee {
|
||||
|
||||
private String id;
|
||||
|
||||
private String glyg;
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.weaver.seconddev.jcl.organization.service;
|
||||
|
||||
import com.weaver.seconddev.jcl.organization.entity.Employee;
|
||||
import com.weaver.seconddev.jcl.organization.entity.PendingEmployee;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -9,4 +10,7 @@ public interface EmployeeInformationService {
|
|||
|
||||
List<Map<String, Object>> getInformation(Employee employee);
|
||||
|
||||
List<Map<String, Object>> getPendingEmployment(Employee employee);
|
||||
|
||||
void updatePendingEmploy(PendingEmployee pendingEmployee);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
package com.weaver.seconddev.jcl.organization.service.impl;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.weaver.seconddev.jcl.common.service.CommonService;
|
||||
import com.weaver.seconddev.jcl.organization.entity.Employee;
|
||||
import com.weaver.seconddev.jcl.organization.entity.PendingEmployee;
|
||||
import com.weaver.seconddev.jcl.organization.service.EmployeeInformationService;
|
||||
import com.weaver.seconddev.jcl.organization.util.CommonUtils;
|
||||
import com.weaver.seconddev.jcl.organization.util.DatabaseUtils;
|
||||
|
|
@ -11,39 +14,49 @@ import org.springframework.stereotype.Service;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 员工信息管理
|
||||
*/
|
||||
@Service
|
||||
public class EmployeeInformationServiceImpl implements EmployeeInformationService {
|
||||
|
||||
@Autowired
|
||||
private DatabaseUtils databaseUtils;
|
||||
@Autowired
|
||||
private CommonService commonService;
|
||||
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getInformation(Employee employee) {
|
||||
|
||||
String sql = "select * from uf_jcl_employee_information where 1=1";
|
||||
String sql = "select * from uf_jcl_employee_information where (delete_type is null or delete_type=false) and (";
|
||||
List<String> paramList = Lists.newArrayList();
|
||||
if (employee.getSj_woiy() != null){
|
||||
sql = sql+ " and sj_woiy=?";
|
||||
paramList.add(employee.getSj_woiy());
|
||||
}else if (employee.getYx_gvex() != null){
|
||||
sql = sql+ " and yx_gvex=?";
|
||||
paramList.add(employee.getYx_gvex());
|
||||
}else if (employee.getSfz_1mhf() != null){
|
||||
sql = sql+ " and sfz_1mhf=?";
|
||||
paramList.add(employee.getSfz_1mhf());
|
||||
|
||||
if (employee.getMobile() != null && !"".equals(employee.getMobile())){
|
||||
sql = sql+ " mobile=? or";
|
||||
paramList.add(employee.getMobile());
|
||||
}
|
||||
if (employee.getEmail() != null && !"".equals(employee.getEmail())){
|
||||
sql = sql+ " email=? or";
|
||||
paramList.add(employee.getEmail());
|
||||
}
|
||||
if (employee.getId_no() != null && !"".equals(employee.getId_no())){
|
||||
sql = sql+ " id_no=? or";
|
||||
paramList.add(employee.getId_no());
|
||||
}
|
||||
sql = sql.substring(0,sql.length()-2)+")";
|
||||
|
||||
|
||||
List<Map<String, Object>> recordList = databaseUtils.getSqlList(sql,paramList);
|
||||
if (recordList.size() > 0){
|
||||
Map<String, Object> userMap = recordList.get(0);
|
||||
|
||||
String ssbm= recordList.get(0).get("ssbm").toString();
|
||||
String ssbm= recordList.get(0).get("department").toString();
|
||||
|
||||
String ygzt = CommonUtils.null2String(userMap.get("ygzt"));
|
||||
String ygzt = CommonUtils.null2String(userMap.get("personnel_status"));
|
||||
if (ygzt.equals("5")){
|
||||
//离职
|
||||
sql = "select zhgzr,lzqbm from uf_jcl_lzxxjl where glyg=? ";
|
||||
sql = "select zhgzr,lzqbm from uf_jcl_lzxxjl where glyg=? and (delete_type is null or delete_type=false) ";
|
||||
List<Map<String, Object>> resignList = databaseUtils.getSqlList(sql, CommonUtils.getParamList(userMap.get("id").toString()));
|
||||
if (resignList.size() > 0){
|
||||
userMap.put("zhgzr",resignList.get(0).get("zhgzr"));
|
||||
|
|
@ -51,18 +64,67 @@ public class EmployeeInformationServiceImpl implements EmployeeInformationServic
|
|||
ssbm = CommonUtils.null2String(resignList.get(0).get("lzqbm"));
|
||||
}else if (ygzt.equals("6")){
|
||||
//退休
|
||||
sql = "select zhgzr,txqbm from uf_jcl_txxxjl where glyg=? ";
|
||||
sql = "select zhgzr,txqbm from uf_jcl_txxxjl where glyg=? and (delete_type is null or delete_type=false) ";
|
||||
List<Map<String, Object>> retireList = databaseUtils.getSqlList(sql, CommonUtils.getParamList(userMap.get("id").toString()));
|
||||
if (retireList.size() > 0){
|
||||
userMap.put("zhgzr",retireList.get(0).get("zhgzr"));
|
||||
}
|
||||
ssbm = CommonUtils.null2String(retireList.get(0).get("txqbm"));
|
||||
}
|
||||
sql = "select id,name from department where id=?";
|
||||
sql = "select id,name from eteams.department where id=?";
|
||||
List<Map<String, Object>> departmentList = databaseUtils.getSqlList(sql, CommonUtils.getParamList(ssbm));
|
||||
userMap.put("departname",departmentList.get(0).get("name"));
|
||||
if (departmentList.size() >0){
|
||||
userMap.put("departname",departmentList.get(0).get("name"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return recordList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getPendingEmployment(Employee employee) {
|
||||
String sql = "select * from uf_jcl_rzgl where (delete_type is null or delete_type=false) and (";
|
||||
List<String> paramList = Lists.newArrayList();
|
||||
|
||||
if (employee.getMobile() != null && !"".equals(employee.getMobile())){
|
||||
sql = sql+ " sj_woiy=? or";
|
||||
paramList.add(employee.getMobile());
|
||||
}
|
||||
if (employee.getEmail() != null && !"".equals(employee.getEmail())){
|
||||
sql = sql+ " yx_gvex=? or";
|
||||
paramList.add(employee.getEmail());
|
||||
}
|
||||
if (employee.getId_no() != null && !"".equals(employee.getId_no())){
|
||||
sql = sql+ " sfz_1mhf=? or";
|
||||
paramList.add(employee.getId_no());
|
||||
}
|
||||
sql = sql.substring(0,sql.length()-2)+")";
|
||||
|
||||
|
||||
List<Map<String, Object>> recordList = databaseUtils.getSqlList(sql,paramList);
|
||||
if (recordList.size() > 0){
|
||||
String ssbm= recordList.get(0).get("ssbm").toString();
|
||||
|
||||
sql = "select id,name from eteams.department where id=? ";
|
||||
List<Map<String, Object>> departmentList = databaseUtils.getSqlList(sql, CommonUtils.getParamList(ssbm));
|
||||
if (departmentList.size()>0){
|
||||
recordList.get(0).put("departname",departmentList.get(0).get("name"));
|
||||
}
|
||||
}
|
||||
return recordList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePendingEmploy(PendingEmployee pendingEmployee) {
|
||||
Map<String,Object> dataMap = CommonUtils.getUpdataParam(pendingEmployee);
|
||||
Map<String,Object> condition = Maps.newHashMap();
|
||||
condition.put("id",pendingEmployee.getId());
|
||||
Map<String,Object> param = Maps.newHashMap();
|
||||
param.put("tableName","uf_jcl_rzgl");
|
||||
param.put("dataMap",dataMap);
|
||||
param.put("condition",condition);
|
||||
commonService.updateCommon(param);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.weaver.seconddev.jcl.organization.util;
|
|||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -10,6 +11,7 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
|
@ -426,5 +428,32 @@ public class CommonUtils {
|
|||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
public static Map<String,Object> getUpdataParam(Object obj){
|
||||
Map<String,Object> dataMap = Maps.newHashMap();
|
||||
Class<?> clazz = obj.getClass();
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
try {
|
||||
// 允许访问私有字段
|
||||
field.setAccessible(true);
|
||||
|
||||
String fieldName = field.getName();
|
||||
if (fieldName.equals("id")){
|
||||
continue;
|
||||
}
|
||||
Object value = field.get(obj);
|
||||
dataMap.put(fieldName,value);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -248,6 +248,26 @@ public class DatabaseUtils {
|
|||
return dataSetService.executeSql(executeSqlEntity);
|
||||
}
|
||||
|
||||
public Map<String, Object> execute(String sql) {
|
||||
//执行sql 参数sourceType groupId sql
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(Constants.GROUP_ID);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(Constants.SOURCE_TYPE));
|
||||
|
||||
return dataSetService.executeSql(executeSqlEntity);
|
||||
}
|
||||
public Map<String, Object> execute(String sql,List<String> paramList) {
|
||||
//执行sql 参数sourceType groupId sql
|
||||
List<SqlParamEntity> sqlParamList = querySqlParamEntity(paramList);
|
||||
ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
|
||||
executeSqlEntity.setSql(base64(sql));
|
||||
executeSqlEntity.setGroupId(Constants.GROUP_ID);
|
||||
executeSqlEntity.setSourceType(SourceType.valueOf(Constants.SOURCE_TYPE));
|
||||
executeSqlEntity.setParams(sqlParamList);
|
||||
return dataSetService.executeSql(executeSqlEntity);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> executeForQuery(String sourceType, String groupId, String sql,List<SqlParamEntity> sqlparam) {
|
||||
//执行sql 参数sourceType groupId sql sqlparam
|
||||
|
|
|
|||
Loading…
Reference in New Issue