#HJ-23# 提交最新的代码
parent
a249954a76
commit
984bf49d29
@ -0,0 +1,300 @@
|
||||
package com.engine.dito.excel.cmd;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.formmode.setup.ModeRightInfo;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.TimeUtil;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.dito.comInfo.PropBean;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class ImportExcelUserPostUtil {
|
||||
|
||||
/***
|
||||
*
|
||||
* @param datalists
|
||||
*/
|
||||
public Map<String,String> operatePostExcel(List<Map<String, String>> datalists)
|
||||
{
|
||||
int scount = 0;
|
||||
int fcount = 0;
|
||||
int ecount = 0;
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
String currentDateTime = TimeUtil.getCurrentTimeString(); //当前时间
|
||||
String updateStaff = "1";
|
||||
String tableName = "system_user_post";
|
||||
|
||||
for (int i = 0; i < datalists.size(); i++)
|
||||
{
|
||||
try{
|
||||
Map<String, String> m = datalists.get(i);
|
||||
String SYS_POST_CODE = Util.null2String(m.get("sys_post_code"));
|
||||
String SYS_USER_CODE = Util.null2String(m.get("sys_user_code"));
|
||||
|
||||
String jobtitlesId = "" ;
|
||||
if(StringUtils.isNotEmpty(SYS_POST_CODE))
|
||||
{
|
||||
String queryRoleIdSql = " select id from hrmjobtitles where jobtitlecode=? ";
|
||||
bb.writeLog("queryRoleIdSql:" + queryRoleIdSql);
|
||||
rs.executeQuery(queryRoleIdSql, new Object[]{SYS_POST_CODE});
|
||||
if (rs.next()) {
|
||||
jobtitlesId = rs.getString("id");
|
||||
}
|
||||
}
|
||||
|
||||
String userId = "" ;
|
||||
if(StringUtils.isNotEmpty(SYS_USER_CODE))
|
||||
{
|
||||
String sql = " select id from hrmresource where workcode=?";
|
||||
bb.writeLog("sql:" + sql);
|
||||
rs.executeQuery(sql, new Object[]{SYS_USER_CODE});
|
||||
if (rs.next()) {
|
||||
userId = Util.null2String(rs.getString("id"));
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotEmpty(userId))
|
||||
{
|
||||
String updateUserJobSql = " update hrmresource set jobtitle=?,modified=?,modifier=? where id=? ";
|
||||
bb.writeLog("updateUserJobSql:"+updateUserJobSql);
|
||||
boolean flag = rs.executeUpdate(updateUserJobSql,new Object[]{jobtitlesId,currentDateTime,updateStaff,userId});
|
||||
bb.writeLog(" updateUserJobFlag: "+flag);
|
||||
if(!flag){
|
||||
Map<String,String> dataMap = new HashMap<String,String>();
|
||||
dataMap.put("syndate",currentDateTime);
|
||||
dataMap.put("reqmessage", JSONObject.toJSONString(m));
|
||||
dataMap.put("errmessage","更新人员岗位sql执行错误");
|
||||
dataMap.put("systable",tableName);
|
||||
recordErrorData(dataMap);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
ecount++;
|
||||
}
|
||||
}
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
map.put("scount",scount+"");
|
||||
map.put("fcount",fcount+"");
|
||||
map.put("ecount",ecount+"");
|
||||
return map;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param
|
||||
* @param creater
|
||||
* @param created
|
||||
* @param modified
|
||||
* @param modifier
|
||||
* @param sysPostCode
|
||||
* @param departmentId
|
||||
* @param SYS_POST_DESC
|
||||
* @return
|
||||
*/
|
||||
private boolean insertUserPost(String SYS_POST_NAME, String creater, String created, String modified, String modifier, String sysPostCode, String departmentId,String SYS_POST_DESC) {
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
String defaultJobActivityId = "" ;
|
||||
String defaultJobActivityName = PropBean.getUfPropValue("defaultJobActivityName");
|
||||
if(StringUtils.isNotEmpty(defaultJobActivityName))
|
||||
{
|
||||
String sql = " select * from hrmjobactivities where jobactivityname = ?" ;
|
||||
rs.executeQuery(sql,new Object[]{defaultJobActivityName});
|
||||
if(rs.next()){
|
||||
defaultJobActivityId = Util.null2String(rs.getString("id"));
|
||||
}
|
||||
if(StringUtils.isEmpty(defaultJobActivityId))
|
||||
{
|
||||
String defaultJobGroupsId = getDefaultJobGroupsId(created,creater) ;
|
||||
if(StringUtils.isNotEmpty(defaultJobGroupsId))
|
||||
{
|
||||
defaultJobActivityId = getDefaultJobActivityId(defaultJobActivityName,created,creater,defaultJobGroupsId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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,SYS_POST_DESC,SYS_POST_NAME,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[]{SYS_POST_DESC, SYS_POST_NAME, defaultJobActivityId, 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 t.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;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getDefaultJobGroupsId(String created,String creater){
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
String defaultJobGroupsId = "" ;
|
||||
try{
|
||||
String defaultJobGroupsName = PropBean.getUfPropValue("defaultJobGroupsName");
|
||||
if(StringUtils.isNotEmpty(defaultJobGroupsName))
|
||||
{
|
||||
String sql = " select id from hrmjobgroups where jobgroupname = ?" ;
|
||||
rs.executeQuery(sql,new Object[]{defaultJobGroupsName});
|
||||
if(rs.next()){
|
||||
defaultJobGroupsId = Util.null2String(rs.getString("id"));
|
||||
}
|
||||
if(StringUtils.isEmpty(defaultJobGroupsId))
|
||||
{
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
sql = " insert into hrmjobgroups(jobgroupname,jobgroupremark,created,creater,uuid) values(?,?,?,?,?) ";
|
||||
boolean flag = rs.executeUpdate(sql,new Object[]{defaultJobGroupsName,defaultJobGroupsName,created,creater,uuid});
|
||||
if(flag){
|
||||
sql = " select id from hrmjobgroups where jobgroupname = ?" ;
|
||||
rs.executeQuery(sql,new Object[]{defaultJobGroupsName});
|
||||
if(rs.next()){
|
||||
defaultJobGroupsId = Util.null2String(rs.getString("id"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return defaultJobGroupsId;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getDefaultJobActivityId(String defaultJobActivityName,String created,String creater,String defaultJobGroupsId){
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
String defaultJobActivityId = "" ;
|
||||
try{
|
||||
if(StringUtils.isNotEmpty(defaultJobActivityName))
|
||||
{
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
String sql = " insert into hrmjobactivities(jobactivitymark,jobactivityname,jobgroupid,created,creater,uuid) values(?,?,?,?,?,?) ";
|
||||
boolean flag = rs.executeUpdate(sql,new Object[]{defaultJobActivityName,defaultJobActivityName,defaultJobGroupsId,created,creater,uuid});
|
||||
if(flag){
|
||||
sql = " select id from hrmjobgroups where jobgroupname = ?" ;
|
||||
rs.executeQuery(sql,new Object[]{defaultJobActivityName});
|
||||
if(rs.next()){
|
||||
defaultJobActivityId = Util.null2String(rs.getString("id"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return defaultJobActivityId;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* @param dataMap
|
||||
*/
|
||||
public void recordErrorData(Map<String,String> dataMap){
|
||||
|
||||
String uftable = "uf_orgmq" ;
|
||||
RecordSet rs = new RecordSet();
|
||||
BaseBean bb = new BaseBean();
|
||||
ModeRightInfo mode=new ModeRightInfo();
|
||||
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");//当前时间日期
|
||||
SimpleDateFormat sdf2 = new SimpleDateFormat("HH:mm:ss");
|
||||
|
||||
int formmodeid = 0 ;
|
||||
String modedatacreater = "1" ;
|
||||
String modedatacreatertype = "0" ;
|
||||
String modedatacreatedate = sdf1.format(new Date());
|
||||
String modedatacreatetime = sdf2.format(new Date());
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
|
||||
try {
|
||||
|
||||
String sql =" select k.id from modeinfo k \n" +
|
||||
" inner join workflow_bill l on formid = l.id\n" +
|
||||
" where l.tablename = ? " ;
|
||||
rs.executeQuery(sql,new Object[]{uftable});
|
||||
if(rs.next()){
|
||||
formmodeid = Util.getIntValue(Util.null2String(rs.getString("id")));
|
||||
}
|
||||
|
||||
String syndate = Util.null2String(dataMap.get("syndate"));
|
||||
String reqmessage = Util.null2String(dataMap.get("reqmessage"));
|
||||
String errmessage = Util.null2String(dataMap.get("errmessage"));
|
||||
String systable = Util.null2String(dataMap.get("systable"));
|
||||
|
||||
int bool = 0;
|
||||
sql =" insert into "+uftable+"(uuid,formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime,syndate,reqmessage,errmessage,systable)" +
|
||||
" values(?,?,?,?,?,?,?,?,?,?)" ;
|
||||
boolean flag = rs.executeUpdate(sql,new Object[]{uuid,formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime,syndate,reqmessage,errmessage,systable});
|
||||
bb.writeLog("sql;"+sql);
|
||||
if(flag){
|
||||
bool++;
|
||||
}
|
||||
bb.writeLog("bool;"+bool);
|
||||
if(bool>0)
|
||||
{
|
||||
String dataid = "";
|
||||
sql = " select * from "+uftable+" where uuid=? ";
|
||||
bb.writeLog("sql:" + sql);
|
||||
rs.executeQuery(sql,new Object[]{uuid});
|
||||
if (rs.next()) {
|
||||
dataid = Util.null2String(rs.getString("id"));
|
||||
}
|
||||
bb.writeLog("sql:" + sql);
|
||||
bb.writeLog("dataid:" + dataid);
|
||||
bb.writeLog("modeid:" + formmodeid);
|
||||
if (org.apache.commons.lang.StringUtils.isNotEmpty(dataid))
|
||||
{
|
||||
mode.setNewRight(true);
|
||||
mode.editModeDataShare(Integer.valueOf(modedatacreater), formmodeid, Integer.parseInt(dataid));
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
bb.writeLog("e:"+e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue