直接上级导入功能及eid更新bug修复
parent
846d40a5ca
commit
1b17c80022
@ -0,0 +1,166 @@
|
||||
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.Util;
|
||||
import weaver.interfaces.dito.comInfo.PropBean;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class ImportExcelManagerUtil {
|
||||
|
||||
/***
|
||||
*
|
||||
* @param datalists
|
||||
*/
|
||||
public static Map<String, String> operateHrmManagerExcel(List<Map<String, String>> datalists) {
|
||||
int scount = 0;
|
||||
int fcount = 0;
|
||||
int ecount = 0;
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
bb.writeLog("operateHrmManagerExcel start");
|
||||
RecordSet recordSet = new RecordSet();
|
||||
//查询出所有eid与resourceId关联信息
|
||||
String cus_eid = PropBean.getUfPropValue("cus_eid");
|
||||
recordSet.execute("SELECT DISTINCT ID ," + cus_eid + " FROM cus_fielddata WHERE " + cus_eid + " <>''");
|
||||
HashMap<String, String> relationMap = new HashMap<>();
|
||||
while (recordSet.next()) {
|
||||
String eid = recordSet.getString(cus_eid);
|
||||
String resourceId = recordSet.getString("ID");
|
||||
relationMap.put(eid, resourceId);
|
||||
}
|
||||
|
||||
for (int i = 0; i < datalists.size(); i++) {
|
||||
try {
|
||||
Map<String, String> h = datalists.get(i);
|
||||
String userEid = Util.null2String(h.get("personno"));
|
||||
String managerEid = Util.null2String(h.get("managerno"));
|
||||
boolean flag = updateHrmresource(userEid, managerEid, relationMap);
|
||||
if (flag) {
|
||||
scount++;
|
||||
} else {
|
||||
fcount++;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
ecount++;
|
||||
}
|
||||
}
|
||||
|
||||
bb.writeLog("scount:" + scount);
|
||||
bb.writeLog("fcount:" + fcount);
|
||||
bb.writeLog("ecount:" + ecount);
|
||||
Map<String, String> dataMap = new HashMap<String, String>();
|
||||
dataMap.put("scount", scount + "");
|
||||
dataMap.put("fcount", fcount + "");
|
||||
dataMap.put("ecount", ecount + "");
|
||||
dataMap.put("count", datalists.size() + "");
|
||||
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
|
||||
private static boolean updateHrmresource(String userEid, String managerEid, HashMap<String, String> relationMap) {
|
||||
|
||||
String tableName = "updateHrmresource";
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
String nowDateTime = sdf.format(new Date());
|
||||
Map<String, String> dataMap = new HashMap<String, String>();
|
||||
dataMap.put("syndate", nowDateTime);
|
||||
dataMap.put("reqmessage", JSONObject.toJSONString(dataMap));
|
||||
dataMap.put("systable", tableName);
|
||||
boolean flag = false;
|
||||
|
||||
String userId = relationMap.get(userEid);
|
||||
String managerId = relationMap.get(managerEid);
|
||||
if (StringUtils.isEmpty(userId) || StringUtils.isEmpty(managerId)) {
|
||||
dataMap.put("errmessage", "eid在系统不存在");
|
||||
recordErrorData(dataMap);
|
||||
return false;
|
||||
}
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
RecordSet rs = new RecordSet();
|
||||
flag = rs.executeUpdate("UPDATE hrmresource SET MANAGERID=? WHERE id=?", managerId, userId);
|
||||
if (!flag) {
|
||||
dataMap.put("errmessage", "更新直接上级失败,userId:" + userId);
|
||||
recordErrorData(dataMap);
|
||||
}
|
||||
bb.writeLog(userEid + ":" + flag);
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
*/
|
||||
public static 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