diff --git a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/common/service/CommonService.java b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/common/service/CommonService.java new file mode 100644 index 0000000..c5354d1 --- /dev/null +++ b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/common/service/CommonService.java @@ -0,0 +1,9 @@ +package com.weaver.seconddev.jcl.common.service; + +import java.util.Map; + +public interface CommonService { + Map updateCommon(Map param); + + Map insertCommon(Map param); +} diff --git a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/common/service/impl/CommonServiceImpl.java b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/common/service/impl/CommonServiceImpl.java new file mode 100644 index 0000000..af6f39a --- /dev/null +++ b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/common/service/impl/CommonServiceImpl.java @@ -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 updateCommon(Map param) { + String tableName = CommonUtils.null2String(param.get("tableName")); + Map dataMap = (Map)param.get("dataMap"); + Map condition = (Map)param.get("condition"); + String updateSql = "update "+tableName+" set "; + for (Map.Entry 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 e : condition.entrySet()){ + updateSql = updateSql + " and "+ e.getKey()+"='"+e.getValue()+"'"; + } + log.info("makeUpdateSql : [{}]",updateSql); + return databaseUtils.execute(updateSql); + } + + @Override + public Map insertCommon(Map param) { + + Map dataMap = (Map)param.get("dataMap"); + String tableName = CommonUtils.null2String(param.get("tableName")); + + String insertSql = "insert into "+tableName; + String key = "("; + String value = "("; + List dataList = Lists.newArrayList(); + for (Map.Entry 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); + } +} diff --git a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/controller/EmployeeInformationController.java b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/controller/EmployeeInformationController.java index 46865b8..e4678e3 100644 --- a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/controller/EmployeeInformationController.java +++ b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/controller/EmployeeInformationController.java @@ -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 getInformation(@RequestBody Employee employee){ log.error("getInformation Employee:[{}]",employee); Map actionMap = new HashMap<>(); - List> 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 getPendingEmployment(@RequestBody Employee employee){ + log.error("getInformation Employee:[{}]",employee); + Map actionMap = new HashMap<>(); + List> resultList = employeeInformationService.getPendingEmployment(employee); actionMap.put("resultList",resultList); return actionMap; } + + /** + * 获得待入职员工共信息 + * @return + */ + @WeaPermission(publicPermission = true) + @Produces(MediaType.APPLICATION_JSON) + @PostMapping("/getPendingEmployment") + public Map updatePendingEmploy(@RequestBody PendingEmployee employee){ + log.error("getInformation Employee:[{}]",employee); + Map actionMap = new HashMap<>(); + //List> resultList = employeeInformationService.getPendingEmployment(employee); + // actionMap.put("resultList",resultList); + + return actionMap; + } } diff --git a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/entity/Employee.java b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/entity/Employee.java index 8279630..ab92d62 100644 --- a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/entity/Employee.java +++ b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/entity/Employee.java @@ -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; } diff --git a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/entity/PendingEmployee.java b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/entity/PendingEmployee.java new file mode 100644 index 0000000..4c5cd2f --- /dev/null +++ b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/entity/PendingEmployee.java @@ -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; +} diff --git a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/EmployeeInformationService.java b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/EmployeeInformationService.java index 22e066c..674a796 100644 --- a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/EmployeeInformationService.java +++ b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/EmployeeInformationService.java @@ -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> getInformation(Employee employee); + List> getPendingEmployment(Employee employee); + + void updatePendingEmploy(PendingEmployee pendingEmployee); } diff --git a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/impl/EmployeeInformationServiceImpl.java b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/impl/EmployeeInformationServiceImpl.java index 136a235..ebae137 100644 --- a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/impl/EmployeeInformationServiceImpl.java +++ b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/impl/EmployeeInformationServiceImpl.java @@ -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> 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 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> recordList = databaseUtils.getSqlList(sql,paramList); if (recordList.size() > 0){ Map 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> 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> 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> 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> getPendingEmployment(Employee employee) { + String sql = "select * from uf_jcl_rzgl where (delete_type is null or delete_type=false) and ("; + List 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> 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> 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 dataMap = CommonUtils.getUpdataParam(pendingEmployee); + Map condition = Maps.newHashMap(); + condition.put("id",pendingEmployee.getId()); + Map param = Maps.newHashMap(); + param.put("tableName","uf_jcl_rzgl"); + param.put("dataMap",dataMap); + param.put("condition",condition); + commonService.updateCommon(param); + } } diff --git a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/util/CommonUtils.java b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/util/CommonUtils.java index 8bfd43e..8af3fce 100644 --- a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/util/CommonUtils.java +++ b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/util/CommonUtils.java @@ -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 getUpdataParam(Object obj){ + Map 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; + } + } diff --git a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/util/DatabaseUtils.java b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/util/DatabaseUtils.java index 7151340..abaaecd 100644 --- a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/util/DatabaseUtils.java +++ b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/util/DatabaseUtils.java @@ -248,6 +248,26 @@ public class DatabaseUtils { return dataSetService.executeSql(executeSqlEntity); } + public Map 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 execute(String sql,List paramList) { + //执行sql 参数sourceType groupId sql + List 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 executeForQuery(String sourceType, String groupId, String sql,List sqlparam) { //执行sql 参数sourceType groupId sql sqlparam