#HJ-20# 重构代码路径,同意增加dito路径,方便部署
parent
07435a0b2f
commit
e44c8c6d29
@ -0,0 +1,9 @@
|
||||
package com.api.dito.excel;
|
||||
|
||||
import com.engine.dito.excel.web.ImportExcelAction;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
@Path("/dito/import")
|
||||
public class ImportExcelActionApi extends ImportExcelAction {
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.customization.sendtodo;
|
||||
package com.customization.dito.sendtodo;
|
||||
|
||||
import com.sun.jersey.core.util.Base64;
|
||||
import okhttp3.*;
|
@ -1,4 +1,4 @@
|
||||
package com.customization.sendtodo;
|
||||
package com.customization.dito.sendtodo;
|
||||
|
||||
import com.sun.jersey.core.util.Base64;
|
||||
import okhttp3.*;
|
@ -1,11 +1,11 @@
|
||||
package com.customization.sendtodo;
|
||||
package com.customization.dito.sendtodo;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.interfaces.comInfo.PropBean;
|
||||
import weaver.interfaces.iwhalecloud.util.RSAUtils;
|
||||
import weaver.interfaces.dito.comInfo.PropBean;
|
||||
import weaver.interfaces.dito.util.RSAUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
@ -1,4 +1,4 @@
|
||||
package com.customization.sendtodo;
|
||||
package com.customization.dito.sendtodo;
|
||||
|
||||
|
||||
import weaver.general.BaseBean;
|
@ -1,6 +1,5 @@
|
||||
package com.customization.sendtodo;
|
||||
package com.customization.dito.sendtodo;
|
||||
|
||||
import com.engine.common.util.ParamUtil;
|
||||
import com.engine.core.cfg.annotation.CommandDynamicProxy;
|
||||
import com.engine.core.interceptor.AbstractCommandProxy;
|
||||
import com.engine.core.interceptor.Command;
|
@ -1,9 +1,8 @@
|
||||
package com.customization.sendtodo;
|
||||
package com.customization.dito.sendtodo;
|
||||
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.interfaces.comInfo.PropBean;
|
||||
import weaver.interfaces.dito.comInfo.PropBean;
|
||||
|
||||
|
||||
public class SendPortalTodoRunnable implements Runnable{
|
@ -1,4 +1,4 @@
|
||||
package com.customization.sendtodo;
|
||||
package com.customization.dito.sendtodo;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
@ -0,0 +1,164 @@
|
||||
package com.engine.dito.excel.cmd;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.dito.comInfo.PropBean;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class ImportExcelDeptUtil {
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param datalists
|
||||
*/
|
||||
public void operateHrmdepartmentExcel(List<Map<String, String>> datalists)
|
||||
{
|
||||
|
||||
int scount = 0;
|
||||
int fcount = 0;
|
||||
for (int i = 0; i < datalists.size(); i++)
|
||||
{
|
||||
Map<String, String> m = datalists.get(i);
|
||||
m.forEach((key, value) -> {
|
||||
System.out.println(key + ":" + value);
|
||||
});
|
||||
int ORG_LEVEL = Util.getIntValue(m.get("org_level"));
|
||||
String ORG_ID = m.get("org_id");
|
||||
|
||||
String ORG_TYPE = m.get("org_type");
|
||||
String PARENT_ORG_ID = m.get("parent_org_id");
|
||||
String ORG_CODE = m.get("org_code");
|
||||
String ORG_NAME = m.get("org_name");
|
||||
|
||||
//状态正常
|
||||
String canceled = "";
|
||||
|
||||
//一级部门
|
||||
if (ORG_LEVEL == 1) {
|
||||
String subcompany = PropBean.getUfPropValue("excel.subcompany"); //"59";
|
||||
String supdepid = PropBean.getUfPropValue("excel.supdepid"); //0;
|
||||
boolean flag = insertDepartment(ORG_NAME, ORG_CODE, canceled, subcompany, supdepid, ORG_ID);
|
||||
if (flag) {
|
||||
scount++;
|
||||
} else {
|
||||
fcount++;
|
||||
}
|
||||
}
|
||||
|
||||
//下及部门
|
||||
if (ORG_LEVEL > 1) {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
map = getSubcompanyid1(datalists, PARENT_ORG_ID);
|
||||
String subcompany = map.get("subcompanyid1");
|
||||
String supdepid = map.get("supdepid");
|
||||
boolean flag = insertDepartment(ORG_NAME, ORG_CODE, canceled, subcompany, supdepid, ORG_ID);
|
||||
if (flag) {
|
||||
scount++;
|
||||
} else {
|
||||
fcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param lists
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
private Map<String, String> getSubcompanyid1(List<Map<String, String>> lists, String id) {
|
||||
Map<String, String> res = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String subcompanyid1 = "";
|
||||
String supdepid = "";
|
||||
for (int i = 0; i < lists.size(); i++) {
|
||||
Map<String, String> m = lists.get(i);
|
||||
String ORG_ID = m.get("org_id");
|
||||
|
||||
String ORG_CODE = m.get("org_code");
|
||||
|
||||
if (ORG_ID.equals(id)) {
|
||||
rs.execute("select id,subcompanyid1 from hrmdepartment where departmentcode = '" + ORG_CODE + "'");
|
||||
while (rs.next()) {
|
||||
supdepid = Util.null2String(rs.getString("id"));
|
||||
subcompanyid1 = Util.null2String(rs.getString("subcompanyid1"));
|
||||
res.put("supdepid", supdepid);
|
||||
res.put("subcompanyid1", subcompanyid1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param ORG_NAME
|
||||
* @param ORG_CODE
|
||||
* @param canceled
|
||||
* @param subcompanyid1
|
||||
* @param supdepid
|
||||
* @param ORG_ID
|
||||
* @return
|
||||
*/
|
||||
private boolean insertDepartment(String ORG_NAME, String ORG_CODE, String canceled, String subcompanyid1, String supdepid, String ORG_ID) {
|
||||
RecordSet rs = new RecordSet();
|
||||
boolean flag = false;
|
||||
BaseBean bb = new BaseBean();
|
||||
String deptid = "" ;
|
||||
String sql = "select id from hrmdepartment where departmentcode = ?";
|
||||
rs.executeQuery(sql,ORG_CODE);
|
||||
if (rs.next()){
|
||||
deptid = Util.null2String(rs.getString("id"));
|
||||
}
|
||||
if(StringUtils.isEmpty(deptid)){
|
||||
String deptUpdateSql = " update hrmdepartment set departmentmark=?,departmentname=?,canceled=?," +
|
||||
" subcompanyid1=?,showorder=?, supdepid=? where id = ? ";
|
||||
|
||||
flag = rs.executeUpdate(deptUpdateSql,new Object[]{ORG_NAME,ORG_NAME,canceled,subcompanyid1,ORG_ID,supdepid,deptid});
|
||||
|
||||
}else{
|
||||
String deptInsertSql = " insert into hrmdepartment(departmentmark,departmentname,departmentcode," +
|
||||
" canceled,subcompanyid1,supdepid,showorder) values(?,?,?,?,?,?,?) ";
|
||||
flag = rs.executeUpdate(deptInsertSql, new Object[]{ORG_NAME, ORG_NAME, ORG_CODE, canceled, subcompanyid1, supdepid, ORG_ID});
|
||||
if(flag){
|
||||
sql = "select id from hrmdepartment where departmentcode = ?";
|
||||
rs.executeQuery(sql,ORG_CODE);
|
||||
if (rs.next()){
|
||||
deptid = Util.null2String(rs.getString("id"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(flag){
|
||||
String departmentdefinedid = "" ;
|
||||
sql = " select id from hrmdepartmentdefined where deptid= ?";
|
||||
rs.executeQuery(sql,new Object[]{deptid});
|
||||
if (rs.next()){
|
||||
departmentdefinedid = Util.null2String(rs.getString("id"));
|
||||
}
|
||||
bb.writeLog("departmentdefinedid:"+departmentdefinedid);
|
||||
if(StringUtils.isNotEmpty(departmentdefinedid)){
|
||||
sql = " update hrmdepartmentdefined set orgid = ? where deptid = ?" ;
|
||||
bb.writeLog("sql:"+sql);
|
||||
rs.executeUpdate(sql,new Object[]{ORG_ID,deptid});
|
||||
}else{
|
||||
sql = " insert into hrmdepartmentdefined(deptid,orgid) values(?,?) " ;
|
||||
bb.writeLog("sql:"+sql);
|
||||
rs.executeUpdate(sql,new Object[]{deptid,ORG_ID});
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
package com.engine.dito.excel.cmd;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.TimeUtil;
|
||||
import weaver.general.Util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
public class ImportExcelPostUtil {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(ImportExcelPostUtil.class);
|
||||
|
||||
/***
|
||||
*
|
||||
* @param datalists
|
||||
*/
|
||||
public void operatePostExcel(List<Map<String, String>> datalists)
|
||||
{
|
||||
int scount = 0;
|
||||
int fcount = 0;
|
||||
|
||||
String creater = "1";
|
||||
String created = TimeUtil.getCurrentTimeString();
|
||||
String modified = TimeUtil.getCurrentTimeString();
|
||||
String modifier = "1";
|
||||
|
||||
|
||||
for (int i = 0; i < datalists.size(); i++) {
|
||||
Map<String, String> m = datalists.get(i);
|
||||
String SYS_POST_CODE = Util.null2String(m.get("SYS_POST_CODE"));
|
||||
String SYS_POST_NAME = Util.null2String(m.get("SYS_POST_NAME"));
|
||||
String IS_SYNC = Util.null2String(m.get("IS_SYNC"));
|
||||
if (!"YES".equals(IS_SYNC)) {
|
||||
continue;
|
||||
}
|
||||
String allname = SYS_POST_NAME;
|
||||
String ORG_ID = Util.null2String(m.get("ORG_ID"));
|
||||
Map<String, String> res = getSubcompanyid1(ORG_ID);
|
||||
String deptid = Util.null2String(res.get("deptid"));
|
||||
|
||||
boolean flag = insertPost(allname, creater, created, modified, modifier, SYS_POST_CODE, deptid);
|
||||
if (flag) {
|
||||
scount++;
|
||||
} else {
|
||||
fcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private boolean insertPost(String jobtitlename, String creater, String created, String modified, String modifier, String sysPostCode, String departmentId) {
|
||||
RecordSet rs = new RecordSet();
|
||||
String jobactivitiesid = "233";
|
||||
|
||||
boolean iflag = false;
|
||||
String jobtitlesid = "";
|
||||
String sql = "select id from hrmjobtitles where jobtitlecode = ?";
|
||||
rs.executeQuery(sql,new Object[]{sysPostCode});
|
||||
while (rs.next()){
|
||||
jobtitlesid = Util.null2String(rs.getString("id"));
|
||||
}
|
||||
if(StringUtils.isNotEmpty(jobtitlesid)){
|
||||
String updateHrmjobactivitiesSl = "update hrmjobtitles set jobtitlemark=?,jobtitlename=?,modified=?,modifier=? where id=?";
|
||||
iflag = rs.executeUpdate(updateHrmjobactivitiesSl,jobtitlename,jobtitlename,modified,modifier,jobtitlesid);
|
||||
|
||||
}else{
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
String insertHrmjobactivitiesSql = " insert into hrmjobtitles(jobtitlemark,jobtitlename,jobactivityid,jobdepartmentid,jobtitlecode,created,creater,modified,modifier,uuid) values(?,?,?,?,?,?,?,?,?,?)";
|
||||
iflag = rs.executeUpdate(insertHrmjobactivitiesSql, new Object[]{jobtitlename, jobtitlename, jobactivitiesid, departmentId, sysPostCode, created, creater, modified, modifier, uuid});
|
||||
|
||||
}
|
||||
return iflag;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param ORG_ID
|
||||
* @return
|
||||
*/
|
||||
private Map<String, String> getSubcompanyid1(String ORG_ID) {
|
||||
Map<String, String> res = new HashMap<String, String>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = " select h.id,h.SUBCOMPANYID1 from hrmdepartmentdefined t inner join hrmdepartment h on h.id = t.deptid where orgid = ? " ;
|
||||
rs.executeQuery(sql,new Object[]{ORG_ID});
|
||||
if (rs.next()) {
|
||||
String deptid = Util.null2String(rs.getString("id"));
|
||||
String subcompanyid1 = Util.null2String(rs.getString("subcompanyid1"));
|
||||
res.put("deptid", deptid);
|
||||
res.put("subcompanyid1", subcompanyid1);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
package com.engine.dito.excel.cmd;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.TimeUtil;
|
||||
import weaver.general.Util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class ImportExcelResourceUtil {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(ImportExcelResourceUtil.class);
|
||||
|
||||
/***
|
||||
*
|
||||
* @param datalists
|
||||
*/
|
||||
public void operateHrmdepartmentExcel(List<Map<String, String>> datalists)
|
||||
{
|
||||
int scount = 0;
|
||||
int fcount = 0;
|
||||
for (int i = 0; i < datalists.size(); i++) {
|
||||
Map<String, String> h = datalists.get(i);
|
||||
//部门id
|
||||
String ORG_ID = Util.null2String(h.get("org_id"));
|
||||
String STAFF_CODE = Util.null2String(h.get("staff_code"));
|
||||
String systemlanguage = "8" ;
|
||||
String locationid = "2" ;
|
||||
String seclevel = "20" ;
|
||||
String createrid = "1" ;
|
||||
String lastmodid = "1" ;
|
||||
|
||||
String pwd = "1";
|
||||
String creator = "1";
|
||||
String jobTitleId = "464";
|
||||
|
||||
String currentDate = TimeUtil.getCurrentDateString();//当前日期
|
||||
String currentDateTime = TimeUtil.getCurrentTimeString(); //当前时间
|
||||
|
||||
String password = DigestUtils.md5Hex(pwd).toUpperCase(); //MD5加密
|
||||
|
||||
String STAFF_ID = Util.null2String(h.get("staff_id"));
|
||||
String STAFF_NAME = Util.null2String(h.get("staff_name"));
|
||||
String E_MAIL = Util.null2String(h.get("e_mail"));
|
||||
String MOBILE_PHONE = Util.null2String(h.get("mobile_phone"));
|
||||
String STATUS_CD = Util.null2String(h.get("status_cd"));
|
||||
String status = "1";
|
||||
if("1100".equals(STATUS_CD) || "1200".equals(STATUS_CD) || "1300".equals(STATUS_CD)){
|
||||
status = "5";
|
||||
}
|
||||
|
||||
Map<String,String> res = getSubcompanyid1(ORG_ID);
|
||||
String deptId = Util.null2String(res.get("deptid"));
|
||||
String subcompanyid1 = Util.null2String(res.get("subcompanyid1"));
|
||||
if(StringUtils.isEmpty(deptId)) continue;
|
||||
|
||||
boolean flag = insertHrmresource( STAFF_CODE, password, STAFF_NAME, deptId, subcompanyid1, creator, E_MAIL, MOBILE_PHONE, jobTitleId, status,
|
||||
STAFF_ID, systemlanguage, currentDate, currentDateTime, locationid, seclevel, createrid, lastmodid);
|
||||
if(flag){
|
||||
scount++;
|
||||
}else{
|
||||
fcount++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param ORG_ID
|
||||
* @return
|
||||
*/
|
||||
private Map<String, String> getSubcompanyid1(String ORG_ID)
|
||||
{
|
||||
Map<String, String> res = new HashMap<String, String>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = " select h.id,h.SUBCOMPANYID1 from hrmdepartmentdefined t inner join hrmdepartment h on h.id = t.deptid where orgid = ? " ;
|
||||
rs.executeQuery(sql,new Object[]{ORG_ID});
|
||||
if (rs.next()) {
|
||||
String deptid = Util.null2String(rs.getString("id"));
|
||||
String subcompanyid1 = Util.null2String(rs.getString("subcompanyid1"));
|
||||
res.put("deptid", deptid);
|
||||
res.put("subcompanyid1", subcompanyid1);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param STAFF_CODE
|
||||
* @param password
|
||||
* @param STAFF_NAME
|
||||
* @param deptId
|
||||
* @param subcompanyid1
|
||||
* @param creator
|
||||
* @param E_MAIL
|
||||
* @param MOBILE_PHONE
|
||||
* @param jobTitleId
|
||||
* @param status
|
||||
* @param STAFF_ID
|
||||
* @param systemlanguage
|
||||
* @param currentDate
|
||||
* @param currentDateTime
|
||||
* @param locationid
|
||||
* @param seclevel
|
||||
* @param createrid
|
||||
* @param lastmodid
|
||||
* @return
|
||||
*/
|
||||
private boolean insertHrmresource(String STAFF_CODE,String password,String STAFF_NAME,String deptId,String subcompanyid1,String creator,String E_MAIL,String MOBILE_PHONE,String jobTitleId,String status,
|
||||
String STAFF_ID,String systemlanguage,String currentDate,String currentDateTime,String locationid,String seclevel,String createrid,String lastmodid) {
|
||||
RecordSet rs = new RecordSet();
|
||||
boolean flag = false;
|
||||
String loginid = "";
|
||||
String sql = " select loginid from hrmresource where workcode=?" ;
|
||||
|
||||
rs.executeQuery(sql,new Object[]{STAFF_CODE});
|
||||
if(rs.next()){
|
||||
loginid = Util.null2String(rs.getString("loginid"));
|
||||
}
|
||||
|
||||
if(!"".equals(loginid)){
|
||||
String userUpdateSql = " update hrmresource set lastname=?,departmentid=?,subcompanyid1=?," +
|
||||
" creater=?,email=?,mobile=?,jobtitle=?,status=?,dsporder=?,lastmoddate=?,modified=? where workcode=? ";
|
||||
|
||||
|
||||
flag = rs.executeUpdate(userUpdateSql,new Object[]{STAFF_NAME,deptId,subcompanyid1,creator,E_MAIL,
|
||||
MOBILE_PHONE,jobTitleId,status,STAFF_ID,currentDate,currentDateTime,STAFF_CODE});
|
||||
|
||||
}else{
|
||||
rs.executeProc("HrmResourceMaxId_Get", "");
|
||||
rs.next();
|
||||
String id = "" + rs.getInt(1);
|
||||
String userInsertSql = " insert into hrmresource(id,loginid,password,workcode,lastname,departmentid,subcompanyid1," +
|
||||
"creater,email,mobile,jobtitle,status,dsporder,systemlanguage,createdate,lastmoddate,created,modified," +
|
||||
"locationid,seclevel,createrid,lastmodid) " +
|
||||
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
flag = rs.executeUpdate(userInsertSql,new Object[]{id,STAFF_CODE,password,STAFF_CODE,STAFF_NAME,deptId,subcompanyid1,
|
||||
creator,E_MAIL,MOBILE_PHONE,jobTitleId,status,STAFF_ID,systemlanguage,currentDate,currentDate,currentDateTime,currentDateTime,
|
||||
locationid,seclevel,createrid,lastmodid});
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,189 @@
|
||||
package com.engine.dito.excel.cmd;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
public class ImportExcelRoleUtil {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(ImportExcelRoleUtil.class);
|
||||
|
||||
/***
|
||||
*
|
||||
* @param datalists
|
||||
*/
|
||||
public void operateRoleExcel(List<Map<String, String>> datalists)
|
||||
{
|
||||
int scount = 0;
|
||||
int fcount = 0;
|
||||
for (int i = 0; i < datalists.size(); i++) {
|
||||
Map<String, String> m = datalists.get(i);
|
||||
String SYS_ROLE_CODE = Util.null2String(m.get("SYS_ROLE_CODE"));
|
||||
String SYS_ROLE_NAME = Util.null2String(m.get("SYS_ROLE_NAME"));
|
||||
String IS_SYNC = Util.null2String(m.get("IS_SYNC"));
|
||||
if(!"YES".equals(IS_SYNC)){
|
||||
continue;
|
||||
}
|
||||
boolean flag = insertRole(SYS_ROLE_CODE, SYS_ROLE_NAME);
|
||||
if (flag) {
|
||||
scount++;
|
||||
} else {
|
||||
fcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @param sysRoleCode
|
||||
* @param sysRoleName
|
||||
* @return
|
||||
*/
|
||||
private boolean insertRole(String sysRoleCode, String sysRoleName) {
|
||||
boolean flag = false;
|
||||
RecordSet rs = new RecordSet();
|
||||
String rolesmark = sysRoleName;
|
||||
String rolesname = sysRoleName;
|
||||
String type = "0";
|
||||
String subcompanyid = "0";
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
String queryRoleSql = "select id from hrmroles where ecology_pinyin_search=?";
|
||||
rs.executeQuery(queryRoleSql, sysRoleCode);
|
||||
String id = "";
|
||||
if (rs.next()) {
|
||||
id = rs.getString("id");
|
||||
}
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
String insertHrmrolesSql = " insert into hrmroles(rolesmark,rolesname,type,subcompanyid,ecology_pinyin_search,uuid) values(?,?,?,?,?,?)";
|
||||
flag = rs.executeUpdate(insertHrmrolesSql, new Object[]{rolesmark, rolesname, type, subcompanyid, sysRoleCode, uuid});
|
||||
} else {
|
||||
String updateHrmrolesSql = " update hrmroles set rolesmark=?,rolesname=? where id=?";
|
||||
flag = rs.executeUpdate(updateHrmrolesSql, sysRoleName, sysRoleName, id);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param datalists
|
||||
*/
|
||||
public void operateUserRoleExcel(List<Map<String, String>> datalists)
|
||||
{
|
||||
|
||||
// for (int i = 0; i < datalists.size(); i++) {
|
||||
// Map<String, String> m = datalists.get(i);
|
||||
// String SYS_ROLE_ID = Util.null2String(m.get("SYS_ROLE_ID"));
|
||||
// String SYS_USER_ID = Util.null2String(m.get("SYS_USER_ID"));
|
||||
// String SYS_ROLE_CODE = getRoleCode(rolelists,SYS_ROLE_ID);
|
||||
// String SYS_USER_CODE = getUserCode(userlists,SYS_USER_ID);
|
||||
// if (!"".equals(SYS_ROLE_CODE) && !"".equals(SYS_USER_CODE)) {
|
||||
// boolean flag = insertRoleUser(SYS_ROLE_CODE, SYS_USER_CODE);
|
||||
// if (flag) {
|
||||
// scount++;
|
||||
// } else {
|
||||
// fcount++;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
private boolean insertRoleUser(String systemUserCode, String roleCode) {
|
||||
boolean flag = false;
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
String userId = "";
|
||||
String roleId = "";
|
||||
String rolelevel = "2"; //总部=2;分部=1;部门=0
|
||||
String resourcetype = "1"; //1=人力资源
|
||||
|
||||
|
||||
String sql = " select id from hrmresource where loginid=?";
|
||||
rs.executeQuery(sql, new Object[]{systemUserCode});
|
||||
if (rs.next()) {
|
||||
userId = Util.null2String(rs.getString("id"));
|
||||
}
|
||||
String queryRoleIdSql = "select id from hrmroles where ecology_pinyin_search=?";
|
||||
rs.executeQuery(queryRoleIdSql, roleCode);
|
||||
if (rs.next()) {
|
||||
roleId = rs.getString("id");
|
||||
}
|
||||
|
||||
if (!"".equals(userId) && !"".equals(roleId)) {
|
||||
//查看是否已存在角色用户关系
|
||||
String releationId = "";
|
||||
String ifExistSql = "select id from hrmrolemembers where roleid=? and resourceid=?";
|
||||
rs.executeQuery(ifExistSql, roleId, userId);
|
||||
if (rs.next()) {
|
||||
releationId = rs.getString("id");
|
||||
}
|
||||
|
||||
if (!"".equals(releationId)) {
|
||||
|
||||
String delHrmrolemembersSql = " delete from hrmrolemembers where id = ?";
|
||||
flag = rs.executeUpdate(delHrmrolemembersSql, releationId);
|
||||
|
||||
} else {
|
||||
|
||||
String insertHrmrolemembersSql = "insert into hrmrolemembers(roleid,resourceid,rolelevel,resourcetype,uuid) values(?,?,?,?,?)";
|
||||
flag = rs.executeUpdate(insertHrmrolemembersSql, roleId, userId, rolelevel, resourcetype, UUID.randomUUID().toString());
|
||||
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param userid
|
||||
* @return
|
||||
*/
|
||||
private String getUserCode(String userid) {
|
||||
String workcode = "";
|
||||
String scopeid = "-1";
|
||||
String scope = "HrmCustomFieldByInfoType" ;
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql =" select * from cus_fielddata cf \n" +
|
||||
" inner join hrmresource h on h.id = cf.ID \n" +
|
||||
" where cf.SCOPE = ? \n" +
|
||||
" and cf.SCOPEID = ? \n" +
|
||||
" and cf.field0 = ? " ;
|
||||
rs.executeQuery(sql,new Object[]{scope,scopeid,userid});
|
||||
if(rs.next()){
|
||||
workcode = Util.null2String(rs.getString("workcode"));
|
||||
}
|
||||
return workcode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private String getRoleCode(String id) {
|
||||
String code = "";
|
||||
// RecordSet rs = new RecordSet();
|
||||
// for (int i = 0; i < lists.size(); i++) {
|
||||
// Map<String, String> m = lists.get(i);
|
||||
// String SYS_ROLE_ID = Util.null2String(m.get("SYS_ROLE_ID"));
|
||||
// String SYS_ROLE_CODE = Util.null2String(m.get("SYS_ROLE_CODE"));
|
||||
// if (SYS_ROLE_ID.equals(id)) {
|
||||
// code= SYS_ROLE_CODE;
|
||||
// }
|
||||
// }
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,184 @@
|
||||
package com.engine.dito.excel.cmd;
|
||||
|
||||
import com.engine.common.biz.AbstractCommonCommand;
|
||||
import com.engine.common.entity.BizLogContext;
|
||||
import com.engine.core.interceptor.CommandContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.interfaces.dito.comInfo.PropBean;
|
||||
import weaver.interfaces.dito.util.ReadExcel;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class ImportOrgExcelCmd extends AbstractCommonCommand<Map<String,Object>> {
|
||||
|
||||
public ImportOrgExcelCmd(Map<String,Object> params, User user) {
|
||||
this.params = params;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BizLogContext getLogContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> execute(CommandContext commandContext) {
|
||||
this.bofore();
|
||||
return null;
|
||||
}
|
||||
|
||||
public void bofore(){
|
||||
|
||||
|
||||
ReadExcel readExcel = new ReadExcel();
|
||||
RecordSet rs = new RecordSet();
|
||||
String imagefileid = Util.null2String(this.params.get("imagefileid"));
|
||||
String type = Util.null2String(this.params.get("type"));
|
||||
|
||||
if(StringUtils.isNotEmpty(imagefileid) && StringUtils.isNotEmpty(type)){
|
||||
|
||||
String imagefilename = "" ;
|
||||
String filerealpath = "" ;
|
||||
String iszip = "" ;
|
||||
String sql = " select i.imagefilename,i.filerealpath,i.iszip from imagefile i where i.imagefileid = ? " ;
|
||||
rs.executeQuery(sql,new Object[]{imagefileid});
|
||||
if(rs.next()){
|
||||
imagefilename = Util.null2String(rs.getString("imagefilename"));
|
||||
filerealpath = Util.null2String(rs.getString("filerealpath"));
|
||||
iszip = Util.null2String(rs.getString("iszip"));
|
||||
}
|
||||
|
||||
if(StringUtils.isNotEmpty(filerealpath) && StringUtils.isNotEmpty(iszip)){
|
||||
|
||||
InputStream inputstream = null;
|
||||
ZipInputStream zin = null;
|
||||
FileOutputStream fileOutputStream = null;
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
String dateTime = sdf.format(calendar.getTime());
|
||||
|
||||
|
||||
String ecology_app_root = PropBean.getUfPropValue("ecology_app_root");
|
||||
String excelupload = ecology_app_root + File.separatorChar +"filesystem"+File.separatorChar+"excelupload"+File.separatorChar+dateTime ;
|
||||
File exceluploadpath = new File(excelupload);
|
||||
if(!exceluploadpath.exists()){
|
||||
exceluploadpath.mkdir();
|
||||
}
|
||||
|
||||
try {
|
||||
if ("0".equals(iszip)){
|
||||
inputstream = new BufferedInputStream(new FileInputStream(filerealpath));
|
||||
}else{
|
||||
zin = new ZipInputStream(new FileInputStream(filerealpath));
|
||||
if (zin.getNextEntry() != null)
|
||||
{
|
||||
inputstream = new BufferedInputStream(zin);
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotEmpty(imagefilename))
|
||||
{
|
||||
String excel_upload_path = exceluploadpath.getPath() ;
|
||||
String excelpath = excel_upload_path + File.separatorChar + imagefilename ;
|
||||
int byteread;
|
||||
byte bydata[] = new byte[8*1024];
|
||||
fileOutputStream = new FileOutputStream(new File(excelpath)) ;
|
||||
while((byteread = inputstream.read(bydata)) != -1) {
|
||||
fileOutputStream.write(bydata, 0, byteread);
|
||||
fileOutputStream.flush() ;
|
||||
}
|
||||
|
||||
List<Map<String, String>> datalists = readExcel.readExcel(excel_upload_path, imagefilename, 0, 0, 0);
|
||||
operateExcel(type,datalists);
|
||||
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void operateExcel(String type,List<Map<String, String>> datalists){
|
||||
|
||||
ImportOrgExcelUtil importOrgExcelUtil = new ImportOrgExcelUtil();
|
||||
|
||||
if("1".equals(type)){
|
||||
//部门
|
||||
String departmenttable = "hrmdepartment" ;
|
||||
String departmentbaktable = "hrmdepartment_allbak" ;
|
||||
String departmentdefinedtable = "hrmdepartmentdefined" ;
|
||||
String departmentdefinedbaktable = "hrmdepartmentdefined_allbak" ;
|
||||
|
||||
boolean isExist = importOrgExcelUtil.backupTableByData(departmenttable,departmentbaktable);
|
||||
if(isExist){
|
||||
isExist = importOrgExcelUtil.backupTableByData(departmentdefinedtable,departmentdefinedbaktable);
|
||||
}
|
||||
|
||||
if(isExist){
|
||||
|
||||
}
|
||||
|
||||
}else if("2".equals(type)){
|
||||
|
||||
//岗位
|
||||
String jobtitlestable = "hrmjobtitles" ;
|
||||
String jobtitlesbaktable = "hrmjobtitles_allbak" ;
|
||||
boolean isExist = importOrgExcelUtil.backupTableByData(jobtitlestable,jobtitlesbaktable);
|
||||
if(isExist){
|
||||
|
||||
}
|
||||
|
||||
}else if("3".equals(type)){
|
||||
//人员
|
||||
String jobtitlestable = "hrmresource" ;
|
||||
String jobtitlesbaktable = "hrmresource_allbak" ;
|
||||
|
||||
String cusfielddatatable = "cus_fielddata";
|
||||
String cusfielddatatabakble = "cus_fielddata_allbak" ;
|
||||
|
||||
boolean isExist = importOrgExcelUtil.backupTableByData(jobtitlestable,jobtitlesbaktable);
|
||||
if(isExist){
|
||||
isExist = importOrgExcelUtil.backupTableByData(cusfielddatatable,cusfielddatatabakble);
|
||||
}
|
||||
|
||||
|
||||
}else if("4".equals(type)){
|
||||
|
||||
String hrmrolestable = "hrmroles";
|
||||
String hrmrolesbaktable = "hrmroles_allbak" ;
|
||||
|
||||
String hrmrolememberstable = "hrmrolemembers";
|
||||
String hrmrolemembersbaktable = "hrmrolemembers_allbak" ;
|
||||
boolean isExist = importOrgExcelUtil.backupTableByData(hrmrolestable,hrmrolesbaktable);
|
||||
if(isExist){
|
||||
isExist = importOrgExcelUtil.backupTableByData(hrmrolememberstable,hrmrolemembersbaktable);
|
||||
}
|
||||
}else if("5".equals(type)){
|
||||
|
||||
}else if("6".equals(type)){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.engine.dito.excel.service;
|
||||
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ImportExcelService {
|
||||
|
||||
Map<String,Object> importOrgExcel(Map<String,Object> datas,User user);
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.engine.dito.excel.service.impl;
|
||||
|
||||
import com.engine.dito.excel.cmd.ImportOrgExcelCmd;
|
||||
import com.engine.dito.excel.service.ImportExcelService;
|
||||
import weaver.hrm.User;
|
||||
import com.engine.core.impl.Service;
|
||||
import java.util.Map;
|
||||
|
||||
public class ImportExcelServiceImpl extends Service implements ImportExcelService {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> importOrgExcel(Map<String, Object> datas, User user) {
|
||||
return commandExecutor.execute(new ImportOrgExcelCmd(datas,user));
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.engine.dito.excel.web;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.common.util.ParamUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.dito.excel.service.ImportExcelService;
|
||||
import com.engine.dito.excel.service.impl.ImportExcelServiceImpl;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ImportExcelAction {
|
||||
|
||||
public ImportExcelService getService(){
|
||||
return (ImportExcelService) ServiceUtil.getService(ImportExcelServiceImpl.class);
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("/orgexcel")
|
||||
@Produces({MediaType.TEXT_PLAIN})
|
||||
public String importOrgExcel(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
BaseBean bb = new BaseBean();
|
||||
bb.writeLog("importExcel");
|
||||
Map<String,Object> apidatas = new HashMap<String,Object>();
|
||||
try{
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
Map<String,Object> dataMap = ParamUtil.request2Map(request);
|
||||
apidatas.putAll(getService().importOrgExcel(dataMap,user));
|
||||
apidatas.put("api_status",true);
|
||||
}catch (Exception e){
|
||||
apidatas.put("api_status",false);
|
||||
apidatas.put("api_errormsg","exception:"+e.getMessage());
|
||||
}
|
||||
bb.writeLog("apidatas:"+ JSONObject.toJSONString(apidatas));
|
||||
return JSONObject.toJSONString(apidatas);
|
||||
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.engine.ditoSsologin.constant;
|
||||
package com.engine.dito.ssologin.constant;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
@ -1,4 +1,4 @@
|
||||
package com.engine.ditoSsologin.service;
|
||||
package com.engine.dito.ssologin.service;
|
||||
|
||||
import weaver.hrm.User;
|
||||
|
@ -1,20 +1,20 @@
|
||||
package com.engine.ditoSsologin.service.impl;
|
||||
package com.engine.dito.ssologin.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cloudstore.dev.api.util.Util_DataCache;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.ditoSsologin.service.MobileSsoLoginService;
|
||||
import com.engine.dito.ssologin.service.MobileSsoLoginService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.hrm.User;
|
||||
import weaver.interfaces.comInfo.PropBean;
|
||||
import weaver.interfaces.util.HttpUtils;
|
||||
import weaver.interfaces.dito.comInfo.PropBean;
|
||||
import weaver.interfaces.dito.util.HttpUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.engine.ditoSsologin.constant.DitoConstant.*;
|
||||
import static com.engine.dito.ssologin.constant.DitoConstant.*;
|
||||
|
||||
|
||||
/**
|
@ -1,11 +1,11 @@
|
||||
package weaver.interfaces.job;
|
||||
package weaver.interfaces.dito.job;
|
||||
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.comInfo.PropBean;
|
||||
import weaver.interfaces.dito.comInfo.PropBean;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
import java.util.*;
|
||||
|
@ -1,11 +1,11 @@
|
||||
package weaver.interfaces.job;
|
||||
package weaver.interfaces.dito.job;
|
||||
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.comInfo.PropBean;
|
||||
import weaver.interfaces.dito.comInfo.PropBean;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
import weaver.general.GCONST;
|
||||
|
@ -1,10 +1,7 @@
|
||||
package weaver.interfaces.job;
|
||||
package weaver.interfaces.dito.job;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Time;
|
||||
import weaver.general.TimeUtil;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
import weaver.share.ShareManager;
|
@ -1,4 +1,4 @@
|
||||
package weaver.interfaces.util;
|
||||
package weaver.interfaces.dito.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
@ -1,4 +1,4 @@
|
||||
package weaver.interfaces.iwhalecloud.util;
|
||||
package weaver.interfaces.dito.util;
|
||||
|
||||
import java.security.KeyFactory;
|
||||
import java.security.PrivateKey;
|
@ -1,4 +1,4 @@
|
||||
package weaver.interfaces.util;
|
||||
package weaver.interfaces.dito.util;
|
||||
|
||||
/**
|
||||
* 类的详细说明
|
Loading…
Reference in New Issue