Compare commits

...

2 Commits

@ -1,6 +1,6 @@
<component name="ArtifactManager">
<artifact type="jar" name="weaver-develop:jar">
<output-path>$PROJECT_DIR$/out/artifacts/weaver_develop_jar</output-path>
<output-path>$PROJECT_DIR$/../../../../weaver/ecology/WEB-INF/lib</output-path>
<root id="archive" name="weaver-develop.jar">
<element id="module-output" name="weaver-develop" />
</root>

@ -0,0 +1,4 @@
#身份证号
certificatenum=0
#编号
workcode=0

File diff suppressed because it is too large Load Diff

@ -0,0 +1,763 @@
package com.api.hrm.service;
import com.alibaba.fastjson.JSONObject;
import com.api.browser.bean.SearchConditionItem;
import com.api.hrm.bean.HrmFieldBean;
import com.api.hrm.util.*;
import com.cloudstore.dev.api.util.TextUtil;
import com.engine.common.biz.SimpleBizLogger;
import com.engine.common.constant.BizLogOperateType;
import com.engine.common.constant.BizLogSmallType4Hrm;
import com.engine.common.constant.BizLogType;
import com.engine.common.entity.BizLogContext;
import com.engine.common.util.LogUtil;
import com.engine.common.util.ParamUtil;
import com.engine.hrm.biz.HrmFieldManager;
import com.engine.hrm.util.face.HrmFaceCheckManager;
import weaver.common.DateUtil;
import weaver.common.StringUtil;
import weaver.conn.RecordSet;
import weaver.docs.docs.CustomFieldManager;
import weaver.encrypt.EncryptUtil;
import weaver.file.FileUpload;
import weaver.file.ImageFileManager;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.hrm.common.DbFunctionUtil;
import weaver.hrm.definedfield.HrmFieldGroupComInfo;
import weaver.hrm.moduledetach.ManageDetachComInfo;
import weaver.hrm.resource.AllManagers;
import weaver.hrm.resource.CustomFieldTreeManager;
import weaver.hrm.resource.HrmListValidate;
import weaver.hrm.resource.ResourceComInfo;
import weaver.hrm.settings.HrmSettingsComInfo;
import weaver.systeminfo.SysMaintenanceLog;
import weaver.systeminfo.SystemEnv;
import weaver.systeminfo.systemright.CheckSubCompanyRight;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.*;
/***
*
* @author lvyi
*
*/
public class HrmResourcePersonalService extends BaseBean {
private static final char separator = Util.getSeparator() ;
private String today = DateUtil.getCurrentDate();
/**
*
* @param request
* @param response
* @return
*/
public String getResourcePesonalView(HttpServletRequest request, HttpServletResponse response){
User user = HrmUserVarify.getUser(request, response);
HrmSettingsComInfo hrmSettingsComInfo = new HrmSettingsComInfo();
HrmResourceBaseService hrmResourceBaseService = new HrmResourceBaseService();
HrmFieldManager hfm = new HrmFieldManager("HrmCustomFieldByInfoType",1);
String checkIsEdit = hrmSettingsComInfo.getCheckIsEdit();
new BaseBean().writeLog("checkIsEdit==="+checkIsEdit);
Map<String,Object> retmap = new HashMap<String,Object>();
Map<String,Object> result = new HashMap<String,Object>();
try{
String id = Util.null2String(request.getParameter("id"));
if(id.length()==0){
id = ""+user.getUID();
}
boolean isSelf = false;
if (id.equals("" + user.getUID())) {
isSelf = true;
}
if (id.equals("")) id = String.valueOf(user.getUID());
String status = "";
String subcompanyid = "", departmentId = "";
RecordSet rs = new RecordSet();
HttpSession session = request.getSession(true);
rs.executeSql("select subcompanyid1, status, departmentId from hrmresource where id = " + id);
if (rs.next()) {
status = Util.toScreen(rs.getString("status"), user.getLanguage());
subcompanyid = Util.toScreen(rs.getString("subcompanyid1"), user.getLanguage());
departmentId = StringUtil.vString(rs.getString("departmentId"));
if (subcompanyid == null || subcompanyid.equals("") || subcompanyid.equalsIgnoreCase("null"))
subcompanyid = "-1";
}
int operatelevel = -1;
//人力资源模块是否开启了管理分权,如不是,则不显示框架,直接转向到列表页面(新的分权管理)
int hrmdetachable = 0;
ManageDetachComInfo ManageDetachComInfo = new ManageDetachComInfo();
boolean isUseHrmManageDetach = ManageDetachComInfo.isUseHrmManageDetach();
if (isUseHrmManageDetach) {
hrmdetachable = 1;
} else {
hrmdetachable = 0;
}
if (hrmdetachable == 1) {
CheckSubCompanyRight CheckSubCompanyRight = new CheckSubCompanyRight();
operatelevel = CheckSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(), "HrmResourceEdit:Edit", Util.getIntValue(subcompanyid));
} else {
if (HrmUserVarify.checkUserRight("HrmResourceEdit:Edit", user, departmentId)) {
operatelevel = 2;
}
}
Map<String, Object> buttons = new Hashtable<String, Object>();
if (((isSelf&&hrmResourceBaseService.isHasModify(1)) || operatelevel > 0) && !status.equals("10")) {
buttons.put("hasEdit", true);
buttons.put("hasSave", true);
}
HrmListValidate HrmListValidate = new HrmListValidate();
AllManagers AllManagers = new AllManagers();
boolean isManager = false;
AllManagers.getAll(id);
if (id.equals("" + user.getUID())) {
isSelf = true;
}
while (AllManagers.next()) {
String tempmanagerid = AllManagers.getManagerID();
if (tempmanagerid.equals("" + user.getUID())) {
isManager = true;
}
}
if ((isSelf || operatelevel >= 0) && HrmListValidate.isValidate(11)) {
result.put("buttons", buttons);
Map<String,Object> tmp = getFormFields(request, response, false);
result.put("conditions", tmp.get("conditions"));
result.put("tables", tmp.get("tables"));
result.put("id", id);
}else{
result.put("hasRight", false);
}
//
// if(HrmUserVarify.checkUserRight("HrmResourceEdit:Edit",user)||(isSelf&&hrmResourceBaseService.isHasModify(1))) {
// buttons.put("hasEdit", true);
// buttons.put("hasSave", true);
// }
}catch (Exception e) {
writeLog(e);
}
retmap.put("result", result);
return JSONObject.toJSONString(retmap);
}
/**
*
* @param request
* @param response
* @return
*/
public Map<String,Object> getFormFields(HttpServletRequest request, HttpServletResponse response, boolean isAdd){
User user = HrmUserVarify.getUser(request, response);
Map<String,Object> result = new HashMap<String,Object>();
List<Object> lsGroup = new ArrayList<Object>();
Map<String,Object> groupitem = null;
List<Object> itemlist = null;
try{
String id = Util.null2String(request.getParameter("id"));
int viewAttr = Util.getIntValue(request.getParameter("viewAttr"),1);
if(isAdd)viewAttr=2;
if(id.length()==0){
id = ""+user.getUID();
}
boolean isSelf = false;
if (id.equals("" + user.getUID())) {
isSelf = true;
}
String subcompanyid = "", departmentId = "";
RecordSet recordSet = new RecordSet();
//不能直接判断是否有人力资源维护权限,也需要根据分权进行判断
boolean canEdit = false;
recordSet.executeSql("select subcompanyid1, status, departmentId from hrmresource where id = " + id);
if (recordSet.next()) {
subcompanyid = Util.toScreen(recordSet.getString("subcompanyid1"), user.getLanguage());
departmentId = StringUtil.vString(recordSet.getString("departmentId"));
if (subcompanyid == null || subcompanyid.equals("") || subcompanyid.equalsIgnoreCase("null"))
subcompanyid = "-1";
}
int operatelevel = -1;
//人力资源模块是否开启了管理分权,如不是,则不显示框架,直接转向到列表页面(新的分权管理)
int hrmdetachable = 0;
ManageDetachComInfo ManageDetachComInfo = new ManageDetachComInfo();
boolean isUseHrmManageDetach = ManageDetachComInfo.isUseHrmManageDetach();
if (isUseHrmManageDetach) {
hrmdetachable = 1;
} else {
hrmdetachable = 0;
}
if (hrmdetachable == 1) {
CheckSubCompanyRight CheckSubCompanyRight = new CheckSubCompanyRight();
operatelevel = CheckSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(), "HrmResourceEdit:Edit", Util.getIntValue(subcompanyid));
} else {
if (HrmUserVarify.checkUserRight("HrmResourceEdit:Edit", user, departmentId)) {
operatelevel = 2;
}
}
if(operatelevel>0){
canEdit = true;
}
int scopeId = 1;
HrmFieldGroupComInfo HrmFieldGroupComInfo = new HrmFieldGroupComInfo();
HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo();
HrmFieldManager hfm = new HrmFieldManager("HrmCustomFieldByInfoType",scopeId);
CustomFieldManager cfm = new CustomFieldManager("HrmCustomFieldByInfoType",scopeId);
if(viewAttr!=1)hfm.isReturnDecryptData(true);
hfm.getHrmData(Util.getIntValue(id));
cfm.getCustomData(Util.getIntValue(id));
HrmListValidate hrmListValidate = new HrmListValidate();
while(HrmFieldGroupComInfo.next()){
int grouptype = Util.getIntValue(HrmFieldGroupComInfo.getType());
if(grouptype!=scopeId)continue;
int grouplabel = Util.getIntValue(HrmFieldGroupComInfo.getLabel());
int groupid = Util.getIntValue(HrmFieldGroupComInfo.getid());
hfm.getCustomFields(groupid);
groupitem = new HashMap<String,Object>();
itemlist = new ArrayList<Object>();
groupitem.put("title", SystemEnv.getHtmlLabelName(grouplabel, user.getLanguage()));
groupitem.put("defaultshow", true);
if(groupid==4){
groupitem.put("hide", (!isAdd&&!canEdit&&isSelf&&viewAttr==2&&hfm.getContactEditCount()==0)||!hrmListValidate.isValidate(42));
}else{
groupitem.put("hide", (!isAdd&&!canEdit&&isSelf&&viewAttr==2&&hfm.getContactEditCount()==0)||!Util.null2String(HrmFieldGroupComInfo.getIsShow()).equals("1"));
}
groupitem.put("items", itemlist);
lsGroup.add(groupitem);
while(hfm.next()){
int tmpviewattr = viewAttr;
String fieldName=hfm.getFieldname();
String cusFieldname = "";
String fieldValue="";
if(hfm.isBaseField(fieldName)){
fieldValue = hfm.getHrmData(fieldName);
}else{
fieldValue = Util.null2String(new EncryptUtil().decrypt("cus_fielddata","field" + hfm.getFieldid(),"HrmCustomFieldByInfoType",""+scopeId,cfm.getData("field" + hfm.getFieldid()),viewAttr==2,true));
cusFieldname = "customfield"+hfm.getFieldid();
if(isAdd) cusFieldname = "customfield_1_"+hfm.getFieldid();
}
if(!hfm.isUse()||(!isAdd&&viewAttr==2&&!canEdit&&isSelf&&!hfm.isModify())){
HrmFieldBean hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname(cusFieldname.length() > 0 ? cusFieldname : fieldName);
hrmFieldBean.setFieldhtmltype("1");
hrmFieldBean.setType("1");
if(!isAdd){
hrmFieldBean.setFieldvalue(fieldValue);
}
hrmFieldBean.setIsFormField(true);
SearchConditionItem searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
Map<String, Object> otherParams = new HashMap<String, Object>();
otherParams.put("hide", true);
searchConditionItem.setOtherParams(otherParams);
itemlist.add(searchConditionItem);
continue;
}
org.json.JSONObject hrmFieldConf = hfm.getHrmFieldConf(fieldName);
HrmFieldBean hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldid((String)hrmFieldConf.get("id"));
hrmFieldBean.setFieldname(cusFieldname.length()>0?cusFieldname:fieldName);
hrmFieldBean.setFieldlabel(hfm.getLable());
hrmFieldBean.setFieldhtmltype((String)hrmFieldConf.get("fieldhtmltype"));
hrmFieldBean.setType((String)hrmFieldConf.get("type"));
hrmFieldBean.setDmlurl((String)hrmFieldConf.get("dmlurl"));
hrmFieldBean.setIssystem(""+(Integer)hrmFieldConf.get("issystem"));
if(!isAdd){
hrmFieldBean.setFieldvalue(fieldValue);
}
hrmFieldBean.setIsFormField(true);
if(viewAttr==2 && ((String)hrmFieldConf.get("ismand")).equals("1")){
tmpviewattr=3;
if(hrmFieldBean.getFieldhtmltype().equals("3")){
hrmFieldBean.setRules("required|string");
// if (hrmFieldBean.getType().equals("2")||hrmFieldBean.getType().equals("161")||hrmFieldBean.getType().equals("162")) {
// hrmFieldBean.setRules("required|string");
// }else{
// hrmFieldBean.setRules("required|integer");
// }
}else if(hrmFieldBean.getFieldhtmltype().equals("4")||
hrmFieldBean.getFieldhtmltype().equals("5")){
hrmFieldBean.setRules("required|integer");
} else if (hrmFieldBean.getFieldhtmltype().equals("1") && hrmFieldBean.getType().equals("2")) {
hrmFieldBean.setRules("required|integer");
}else{
hrmFieldBean.setRules("required|string");
}
}
SearchConditionItem searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
if(searchConditionItem==null)continue;
if(searchConditionItem.getBrowserConditionParam()!=null){
searchConditionItem.getBrowserConditionParam().setViewAttr(tmpviewattr);
}
searchConditionItem.setViewAttr(tmpviewattr);
itemlist.add(searchConditionItem);
}
if(itemlist.size()==0)lsGroup.remove(groupitem);
}
result.put("conditions", lsGroup);
//明细信息
List<Object> lsTable = new ArrayList<Object>();
List<HrmFieldBean> titles = null;
Map<String,Object> table = null;
Map<String,Object> maptab = null;
HrmFieldBean hrmFieldBean = null;
List<Map<String,Object>> columns = null;
List<Map<String,Object>> datas = null;
Map<String,Object> data = null;
result.put("tables",lsTable);
//标头信息--家庭信息
HrmFieldDetailComInfo HrmFieldDetailComInfo = new HrmFieldDetailComInfo();
LinkedHashMap<String, List<HrmFieldBean>> detialTable = HrmFieldDetailComInfo.getDetialTable(""+scopeId, viewAttr, "80%");
Iterator<Map.Entry<String, List<HrmFieldBean>>> entries = detialTable.entrySet().iterator();
while(entries.hasNext()){
Map.Entry<String, List<HrmFieldBean>> entry = entries.next();
String tablename = entry.getKey();
titles = entry.getValue();
table = new HashMap<String,Object>();
columns = HrmFieldUtil.getHrmDetailTable(titles, null, user);
table.put("columns", columns);
datas = new ArrayList<Map<String,Object>>();
RecordSet rs = new RecordSet();
String sql = "select * from "+tablename+" where resourceid = "+id;
rs.executeSql(sql);
while(rs.next()){
data = new HashMap<String,Object>();
for(HrmFieldBean fieldInfo :titles){
if (!isAdd){
data.put(fieldInfo.getFieldname(), TextUtil.toBase64ForMultilang(Util.null2String(rs.getString(fieldInfo.getFieldname()))));
}
}
datas.add(data);
}
table.put("datas", datas);
table.put("rownum","rownum");
maptab = new Hashtable<String, Object>();
String tablabel = HrmResourceDetailTab.HrmResourceDetailTabInfo.get(tablename.toUpperCase());
maptab.put("tabname", SystemEnv.getHtmlLabelNames(tablabel,user.getLanguage()));
maptab.put("hide", (!hrmListValidate.isValidate(45)||(!isAdd&&!canEdit&&isSelf&&viewAttr==2)));
maptab.put("tabinfo", table);
lsTable.add(maptab);
}
//自定义信息
RecordSet RecordSet = new RecordSet();
CustomFieldTreeManager CustomFieldTreeManager = new CustomFieldTreeManager();
LinkedHashMap<String,String> ht = new LinkedHashMap<String,String>();
RecordSet.executeSql("select id, formlabel,viewtype from cus_treeform where parentid="+scopeId+" order by scopeorder");
while(RecordSet.next()){
if(RecordSet.getInt("viewtype")!=1)continue;
titles = new ArrayList<HrmFieldBean>();
int subId = RecordSet.getInt("id");
CustomFieldManager cfm2 = new CustomFieldManager("HrmCustomFieldByInfoType",subId);
cfm2.getCustomFields();
CustomFieldTreeManager.getMutiCustomData("HrmCustomFieldByInfoType", subId, Util.getIntValue(id,0));
int colcount1 = 0 ;
int rowcount = 0;
int col = 0;
while(cfm2.next()){
rowcount++;
if(!cfm2.isUse()||(!isAdd&&viewAttr==2&&!canEdit&&isSelf&&!cfm2.isModify()))continue;
col++;
}
if(rowcount==0)continue;
cfm2.beforeFirst();
ht.put("cus_list_" + subId, RecordSet.getString("formlabel"));
cfm2.beforeFirst();
while (cfm2.next()) {
if(!cfm2.isUse()||(!isAdd&&viewAttr==2&&!canEdit&&isSelf&&!cfm2.isModify()))continue;
int tmpviewattr = viewAttr;
//创建表头
String fieldname = "customfield" + cfm2.getId() + "_" + subId;
if (isAdd) fieldname = "customfield_1_" + cfm2.getId() + "_" + subId;
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldid("" + cfm2.getId());
hrmFieldBean.setFieldname(fieldname);
hrmFieldBean.setFieldlabel(cfm2.getLable());
hrmFieldBean.setFieldhtmltype(cfm2.getHtmlType());
hrmFieldBean.setType("" + cfm2.getType());
hrmFieldBean.setDmlurl(cfm2.getDmrUrl());
if (viewAttr == 2 && cfm2.isMand()) {
tmpviewattr = 3;
hrmFieldBean.setRules("required|string");
}
hrmFieldBean.setViewAttr(tmpviewattr);
hrmFieldBean.setWidth("80%");
titles.add(hrmFieldBean);
}
table = new HashMap<String, Object>();
if(col>0){
columns = HrmFieldUtil.getHrmDetailTable(titles, null, user);
table.put("columns", columns);
}
datas = new ArrayList<Map<String, Object>>();
cfm2.beforeFirst();
while (CustomFieldTreeManager.nextMutiData()) {
data = new HashMap<String, Object>();
while (cfm2.next()) {
// if(!cfm2.isUse()||(!isAdd&&viewAttr==2&&!canEdit&&isSelf&&!cfm2.isModify()))continue;
int fieldid = cfm2.getId(); //字段id
int type = cfm2.getType();
String dmlurl = cfm2.getDmrUrl();
int fieldhtmltype = Util.getIntValue(cfm2.getHtmlType());
String fieldname = "customfield" + cfm2.getId() + "_" + subId;
if (isAdd) fieldname = "customfield_1_" + cfm2.getId() + "_" + subId;
String fieldvalue = "";
if (!isAdd){
fieldvalue = Util.null2String(CustomFieldTreeManager.getMutiData("field" + fieldid));
}
data.put(fieldname, fieldvalue);
if (cfm2.getHtmlType().equals("1") && cfm2.getType() == 1) {
data.put(fieldname, TextUtil.toBase64ForMultilang(Util.null2String(fieldvalue)));
} else if (cfm2.getHtmlType().equals("3")) {
String fieldshowname = hfm.getFieldvalue(user, dmlurl, fieldid, fieldhtmltype, type, fieldvalue, 0);
data.put(fieldname, fieldvalue);
data.put(fieldname + "span", fieldshowname);
} else if (cfm2.getHtmlType().equals("4")) {
data.put(fieldname, fieldvalue.equals("1"));
} else if(cfm2.getHtmlType().equals("6")){
List<Object> filedatas = new ArrayList<Object>();
if(Util.null2String(fieldvalue).length()>0) {
Map<String, Object> filedata = null;
String[] tmpIds = Util.splitString(Util.null2String(fieldvalue), ",");
for (int i = 0; i < tmpIds.length; i++) {
String fileid = tmpIds[i];
ImageFileManager manager = new ImageFileManager();
manager.getImageFileInfoById(Util.getIntValue(fileid));
String filename = manager.getImageFileName();
String extname = filename.contains(".") ? filename.substring(filename.lastIndexOf(".") + 1) : "";
filedata = new HashMap<String, Object>();
filedata.put("acclink", "/weaver/weaver.file.FileDownload?fileid=" + fileid);
filedata.put("fileExtendName", extname);
filedata.put("fileid", fileid);
filedata.put("filelink", "/spa/document/index2file.jsp?imagefileId=" + fileid + "#/main/document/fileView");
filedata.put("filename", filename);
filedata.put("filesize", manager.getImgsize());
filedata.put("imgSrc", "");
filedata.put("isImg", "");
filedata.put("loadlink", "/weaver/weaver.file.FileDownload?fileid=" + fileid + "&download=1");
filedata.put("showDelete", viewAttr==2);
filedata.put("showLoad", "true");
filedatas.add(filedata);
}
}
data.put(fieldname, filedatas);
}
//只允许有权限的人删除明细行,没有权限的人只能修改不能删除
if (canEdit) {
data.put("viewAttr", 2);
} else {
data.put("viewAttr", 1);
}
}
cfm2.beforeFirst();
datas.add(data);
}
table.put("datas", datas);
table.put("rownum", "nodesnum_" + subId);
maptab = new Hashtable<String, Object>();
RecordSet rs = new RecordSet();
rs.executeSql("select id, formlabel from cus_treeform where parentid=" + scopeId + " and id=" + subId + " order by scopeorder");
if (rs.next()) {
maptab.put("tabname", rs.getString("id"));
maptab.put("tabname", rs.getString("formlabel"));
}
maptab.put("hide", col == 0);
maptab.put("tabinfo", table);
lsTable.add(maptab);
}
}catch (Exception e) {
writeLog(e);
}
return result;
}
/***
*
* @param request
* @param response
* @return
*/
public Map<String,String> addResourcePersonal(String id, HttpServletRequest request, HttpServletResponse response){
Map<String,String> retmap = new HashMap<String,String>();
try{
User user = HrmUserVarify.getUser(request, response);
RecordSet rs = new RecordSet();
ResourceComInfo ResourceComInfo = new ResourceComInfo();
CustomFieldTreeManager CustomFieldTreeManager = new CustomFieldTreeManager();
String para = "";
FileUpload fu = new FileUpload(request);
//String id = Util.null2String(fu.getParameter("id"));
String birthday = Util.fromScreen3(fu.getParameter("birthday"),user.getLanguage());
String folk = Util.fromScreen3(fu.getParameter("folk"),user.getLanguage()) ; /*民族*/
String nativeplace = Util.fromScreen3(fu.getParameter("nativeplace"),user.getLanguage()) ; /*籍贯*/
String regresidentplace = Util.fromScreen3(fu.getParameter("regresidentplace"),user.getLanguage()) ; /*户口所在地*/
String maritalstatus = Util.fromScreen3(fu.getParameter("maritalstatus"),user.getLanguage());
String policy = Util.fromScreen3(fu.getParameter("policy"),user.getLanguage()) ; /*政治面貌*/
String bememberdate = Util.fromScreen3(fu.getParameter("bememberdate"),user.getLanguage()) ; /*入团日期*/
String bepartydate = Util.fromScreen3(fu.getParameter("bepartydate"),user.getLanguage()) ; /*入党日期*/
String islabourunion = Util.fromScreen3(fu.getParameter("islabouunion"),user.getLanguage()) ;
String educationlevel = Util.fromScreen3(fu.getParameter("educationlevel"),user.getLanguage()) ;/*学历*/
String degree = Util.fromScreen3(fu.getParameter("degree"),user.getLanguage()) ; /*学位*/
String healthinfo = Util.fromScreen3(fu.getParameter("healthinfo"),user.getLanguage()) ;/*健康状况*/
String height = Util.null2o(fu.getParameter("height")) ;/*身高*/
String weight = Util.null2o(fu.getParameter("weight")) ;
String residentplace = Util.fromScreen3(fu.getParameter("residentplace"),user.getLanguage()) ; /*现居住地*/
String homeaddress = Util.fromScreen3(fu.getParameter("homeaddress"),user.getLanguage()) ;
String tempresidentnumber = Util.fromScreen3(fu.getParameter("tempresidentnumber"),user.getLanguage()) ;
String certificatenum = Util.fromScreen3(fu.getParameter("certificatenum"),user.getLanguage()) ;/*证件号码*/
certificatenum=certificatenum.trim();
String tempcertificatenum=certificatenum;
SimpleBizLogger logger = new SimpleBizLogger();
Map<String, Object> params = ParamUtil.request2Map(request);
BizLogContext bizLogContext = new BizLogContext();
bizLogContext.setLogType(BizLogType.HRM);//模块类型
bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_RSOURCE_CARD);//所属大类型
bizLogContext.setBelongTypeTargetName(SystemEnv.getHtmlLabelName(15687, user.getLanguage()));
bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_RSOURCE_CARD_PERSONAL);//当前小类型
bizLogContext.setOperateType(BizLogOperateType.ADD);
bizLogContext.setParams(params);//当前request请求参数
logger.setUser(user);//当前操作人
String cusFieldNames = ServiceUtil.getCusFieldNames("HrmCustomFieldByInfoType",1,"b");
String mainSql = "select a.*"+(cusFieldNames.length()>0?","+cusFieldNames:"")+" from hrmresource a left join cus_fielddata b on a.id=b.id and b.scope='HrmCustomFieldByInfoType' and b.scopeid=1 where a.id="+id;
logger.setMainSql(mainSql,"id");//主表sql
logger.setMainPrimarykey("id");//主日志表唯一key
logger.setMainTargetNameColumn("lastname");//当前targetName对应的列对应日志中的对象名
logger.before(bizLogContext);//写入操作前日志
int msg=0;
if(!certificatenum.equals("")){
rs.executeSql("select accounttype,certificatenum from HrmResource where id="+id);
String accountType = "", tempCertificatenum = "";
if(rs.next()){
accountType = Util.null2String(rs.getString("accounttype"));
tempCertificatenum = Util.null2String(rs.getString("certificatenum"));
}
if(!accountType.equals("1")) {
rs.executeSql("select id from HrmResource where id<>"+id+" and certificatenum='"+certificatenum+"' and accounttype != '1'");
if(rs.next()){
msg=1;
tempcertificatenum = tempCertificatenum;
}
}
}
para = ""+id+ separator+birthday+separator+folk+separator+nativeplace+separator+regresidentplace+separator+
maritalstatus+ separator+policy+separator+bememberdate+separator+bepartydate+separator+islabourunion+
separator+educationlevel+separator+degree+separator+healthinfo+separator+height+separator+weight+
separator+residentplace+separator+homeaddress+separator+tempresidentnumber+separator+tempcertificatenum;
int userid = user.getUID();
String userpara = ""+userid+separator+today;
rs.executeProc("HrmResourcePersonalInfo_Insert",para);
rs.executeProc("HrmResource_ModInfo",""+id+separator+userpara);
int rownum = Util.getIntValue(fu.getParameter("rownum"),user.getLanguage()) ;
String prefix = "" ;
if(Boolean.TRUE.equals(HrmResourceAddService.saveStatusThreadLocal.get())){
prefix="person_" ;
}
for(int i = 0;i<rownum;i++){
String member = Util.fromScreen3(fu.getParameter("member_"+i),user.getLanguage());
String title = Util.fromScreen3(fu.getParameter("title_"+i),user.getLanguage());
String company = Util.fromScreen3(fu.getParameter(prefix+"company_"+i),user.getLanguage());
String jobtitle = Util.fromScreen3(fu.getParameter(prefix+"jobtitle_"+i),user.getLanguage());
String address = Util.fromScreen3(fu.getParameter("address_"+i),user.getLanguage());
String info = member+title+company+jobtitle+address;
if(!(info.trim().equals(""))){
para = ""+id+separator+member+separator+title+separator+company+separator+jobtitle+separator+address;
rs.executeProc("HrmFamilyInfo_Insert",para);
}
}
//处理自定义字段 add by wjy
CustomFieldTreeManager.editCustomDataE9Add("HrmCustomFieldByInfoType", 1, fu, Util.getIntValue(id,0));
CustomFieldTreeManager.editMutiCustomDataeE9Add("HrmCustomFieldByInfoType", 1, fu, Util.getIntValue(id,0));
rs.execute("update HrmResource set "+ DbFunctionUtil.getUpdateSetSql(rs.getDBType(),user.getUID())+" where id="+id) ;
rs.execute("update HrmResourceManager set "+ DbFunctionUtil.getUpdateSetSql(rs.getDBType(),user.getUID())+" where id="+id) ;
LogUtil.writeBizLog(logger.getBizLogContexts());
if(msg==1){
retmap.put("status", "-1");
}else{
retmap.put("status", "1");
}
}catch (Exception e) {
writeLog("新建人员个人信息错误:"+e);
retmap.put("status", "-1");
}
return retmap;
}
/**
*
* @param request
* @param response
* @return
*/
public Map<String,Object> editResourcePersonal(HttpServletRequest request, HttpServletResponse response){
Map<String,Object> retmap = new HashMap<String,Object>();
HrmSettingsComInfo hrmSettingsComInfo = new HrmSettingsComInfo();
try{
User user = HrmUserVarify.getUser(request, response);
RecordSet rs = new RecordSet();
ResourceComInfo ResourceComInfo = new ResourceComInfo();
CustomFieldTreeManager CustomFieldTreeManager = new CustomFieldTreeManager();
SysMaintenanceLog SysMaintenanceLog = new SysMaintenanceLog();
String para = "";
FileUpload fu = new FileUpload(request);
String id = Util.null2String(fu.getParameter("id"));
if (!HrmUserVarify.checkUserRight("HrmResourceEdit:Edit", user)) {
if (!id.equals(user.getUID() + "")) {
retmap.put("status", "-1");
retmap.put("message", ""+ SystemEnv.getHtmlLabelName(22620,weaver.general.ThreadVarLanguage.getLang())+"");
return retmap;
}
}
String birthday = Util.fromScreen3(fu.getParameter("birthday"),user.getLanguage());
String folk = Util.fromScreen3(fu.getParameter("folk"),user.getLanguage()) ; /*民族*/
String nativeplace = Util.fromScreen3(fu.getParameter("nativeplace"),user.getLanguage()) ; /*籍贯*/
String regresidentplace = Util.fromScreen3(fu.getParameter("regresidentplace"),user.getLanguage()) ; /*户口所在地*/
String maritalstatus = Util.fromScreen3(fu.getParameter("maritalstatus"),user.getLanguage());
String policy = Util.fromScreen3(fu.getParameter("policy"),user.getLanguage()) ; /*政治面貌*/
String bememberdate = Util.fromScreen3(fu.getParameter("bememberdate"),user.getLanguage()) ; /*入团日期*/
String bepartydate = Util.fromScreen3(fu.getParameter("bepartydate"),user.getLanguage()) ; /*入党日期*/
String islabourunion = Util.fromScreen3(fu.getParameter("islabouunion"),user.getLanguage()) ;
String educationlevel = Util.fromScreen3(fu.getParameter("educationlevel"),user.getLanguage()) ;/*学历*/
String degree = Util.fromScreen3(fu.getParameter("degree"),user.getLanguage()) ; /*学位*/
String healthinfo = Util.fromScreen3(fu.getParameter("healthinfo"),user.getLanguage()) ;/*健康状况*/
String height = Util.null2o(fu.getParameter("height")) ;/*身高*/
String weight = Util.null2o(fu.getParameter("weight")) ;
String residentplace = Util.fromScreen3(fu.getParameter("residentplace"),user.getLanguage()) ; /*现居住地*/
String homeaddress = Util.fromScreen3(fu.getParameter("homeaddress"),user.getLanguage()) ;
String tempresidentnumber = Util.fromScreen3(fu.getParameter("tempresidentnumber"),user.getLanguage()) ;
String certificatenum = Util.fromScreen3(fu.getParameter("certificatenum"),user.getLanguage()) ;/*证件号码*/
certificatenum=certificatenum.trim();
String tempcertificatenum=certificatenum;
SimpleBizLogger logger = new SimpleBizLogger();
Map<String, Object> params = ParamUtil.request2Map(request);
BizLogContext bizLogContext = new BizLogContext();
bizLogContext.setLogType(BizLogType.HRM);//模块类型
bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_RSOURCE_CARD);//所属大类型
bizLogContext.setBelongTypeTargetName(SystemEnv.getHtmlLabelName(15687, user.getLanguage()));
bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_RSOURCE_CARD_PERSONAL);//当前小类型
bizLogContext.setParams(params);//当前request请求参数
logger.setUser(user);//当前操作人
String cusFieldNames = ServiceUtil.getCusFieldNames("HrmCustomFieldByInfoType",1,"b");
String mainSql = "select a.*"+(cusFieldNames.length()>0?","+cusFieldNames:"")+" from hrmresource a left join cus_fielddata b on a.id=b.id and b.scope='HrmCustomFieldByInfoType' and b.scopeid=1 where a.id="+id;
logger.setMainSql(mainSql,"id");//主表sql
logger.setMainPrimarykey("id");//主日志表唯一key
logger.setMainTargetNameColumn("lastname");//当前targetName对应的列对应日志中的对象名
logger.before(bizLogContext);//写入操作前日志
int msg=0;
if(!certificatenum.equals("")&&isNeedCheck(user,id,"certificatenum")){
rs.executeSql("select accounttype,certificatenum from HrmResource where id="+id);
String accountType = "", tempCertificatenum = "";
if(rs.next()){
accountType = Util.null2String(rs.getString("accounttype"));
tempCertificatenum = Util.null2String(rs.getString("certificatenum"));
}
if(!accountType.equals("1")) {
rs.executeSql("select id from HrmResource where id<>"+id+" and certificatenum='"+certificatenum+"' and (accounttype != '1' or accounttype is null)"+(new ServiceUtil().needCheckDismiss("certificatenum")?"":" and status in(0,1,2,3) "));
if(rs.next()){
msg=1;
tempcertificatenum = tempCertificatenum;
retmap.put("status", "-1");
retmap.put("message", ""+ SystemEnv.getHtmlLabelName(83521,weaver.general.ThreadVarLanguage.getLang())+"");
return retmap;
}
}
}
para = ""+id+ separator+birthday+separator+folk+separator+nativeplace+separator+regresidentplace+separator+
maritalstatus+ separator+policy+separator+bememberdate+separator+bepartydate+separator+islabourunion+
separator+educationlevel+separator+degree+separator+healthinfo+separator+height+separator+weight+
separator+residentplace+separator+homeaddress+separator+tempresidentnumber+separator+tempcertificatenum;
rs.executeProc("HrmResourcePersonalInfo_Insert",para);
int userid = user.getUID();
String userpara = ""+userid+separator+today;
rs.executeProc("HrmResource_ModInfo",""+id+separator+userpara);
int rownum = Util.getIntValue(fu.getParameter("rownum"),user.getLanguage()) ;
rs.executeProc("HrmFamilyInfo_Delete",""+id);
for(int i = 0;i<rownum;i++){
String member = Util.fromScreen3(fu.getParameter("member_"+i),user.getLanguage());
String title = Util.fromScreen3(fu.getParameter("title_"+i),user.getLanguage());
String company = Util.fromScreen3(fu.getParameter("company_"+i),user.getLanguage());
String jobtitle = Util.fromScreen3(fu.getParameter("jobtitle_"+i),user.getLanguage());
String address = Util.fromScreen3(fu.getParameter("address_"+i),user.getLanguage());
String sonBirthday = Util.fromScreen3(fu.getParameter("birthday_"+i),user.getLanguage());
String WhetherChildren = Util.fromScreen3(fu.getParameter("WhetherChildren_"+i),user.getLanguage());
if("".equals(WhetherChildren)){
WhetherChildren = "0";
}
String info = member+title+company+jobtitle+address+sonBirthday+WhetherChildren;
if(!info.trim().equals("")){
para = "INSERT INTO HrmFamilyInfo ( resourceid, member, title, company, jobtitle, address,birthday,WhetherChildren) VALUES ( ?,?, ?,?, ?, ?,?,? ) ";
rs.executeUpdate(para,id,member,title,company,jobtitle,address,sonBirthday,WhetherChildren);
}
}
ResourceComInfo.updateResourceInfoCache(id);
//处理自定义字段 add by wjy
CustomFieldTreeManager.editCustomData("HrmCustomFieldByInfoType", 1, fu, Util.getIntValue(id,0));
CustomFieldTreeManager.setIsE9(true);
CustomFieldTreeManager.editMutiCustomData("HrmCustomFieldByInfoType", 1, fu, Util.getIntValue(id,0));
// 个人信息不需要清理人力资源缓存 ResourceComInfo.removeResourceCache();
rs.execute("update HrmResource set "+ DbFunctionUtil.getUpdateSetSql(rs.getDBType(),user.getUID())+" where id="+id) ;
rs.execute("update HrmResourceManager set "+ DbFunctionUtil.getUpdateSetSql(rs.getDBType(),user.getUID())+" where id="+id) ;
HrmFaceCheckManager.sync(id,HrmFaceCheckManager.getOptUpdate(),
"hrm_e9_HrmResourcePersonalService_editResourcePersonal",HrmFaceCheckManager.getOaResource());
LogUtil.writeBizLog(logger.getBizLogContexts());
retmap.put("status", "1");
}catch (Exception e) {
writeLog("编辑人员个人信息错误:"+e);
retmap.put("status", "-1");
}
return retmap;
}
public boolean isNeedCheck(User user,String id,String fieldName){
RecordSet rs = new RecordSet();
boolean flag = true;
try {
if (!HrmUserVarify.checkUserRight("HrmResourceEdit:Edit", user)) {
if (id.equals(user.getUID() + "")) {
rs.executeQuery("select isModify from hrm_formfield where fieldName = ?", fieldName);
if (rs.next()) {
int isModify = rs.getInt("isModify");
if (isModify == 0) flag = false;
}
}
}
}catch (Exception e){
writeLog(e);
}
return flag;
}
}

@ -0,0 +1,757 @@
package com.api.hrm.util;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.api.browser.bean.SearchConditionItem;
import com.api.browser.bean.SearchConditionOption;
import com.api.hrm.bean.HrmFieldBean;
import com.cloudstore.dev.api.util.APPManager;
import com.cloudstore.dev.api.util.EMManager;
import com.cloudstore.dev.api.util.TextUtil;
import com.engine.common.constant.ParamConstant;
import com.engine.hrm.biz.HrmClassifiedProtectionBiz;
import net.coobird.thumbnailator.Thumbnails;
import sun.misc.BASE64Decoder;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.docs.docs.CustomFieldManager;
import weaver.encrypt.EncryptUtil;
import weaver.file.ImageFileManager;
import weaver.general.BaseBean;
import weaver.general.GCONST;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.common.DbFunctionUtil;
import weaver.hrm.common.database.dialect.DbDialectFactory;
import weaver.hrm.common.database.dialect.DialectUtil;
import weaver.hrm.definedfield.HrmDeptFieldManagerE9;
import weaver.hrm.definedfield.HrmFieldComInfo;
import weaver.hrm.definedfield.HrmFieldManager;
import weaver.hrm.online.HrmUserOnlineMap;
import weaver.hrm.resource.ResourceComInfo;
import weaver.login.LicenseCheckLogin;
import weaver.systeminfo.SysMaintenanceLog;
import weaver.systeminfo.SystemEnv;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List;
import com.engine.integration.util.StringUtils;
import java.util.concurrent.ConcurrentHashMap;
public class ServiceUtil extends BaseBean {
static final boolean isMultilang = true; //人力资源模块是否启用多语言
public String tempHrmSubCompany_table = "tempHrmSubCompany_table";
public String tempHrmDepartment_table = "tempHrmDepartment_table";
public static boolean isAdmin(String id){
if(StringUtils.isBlank(id)) return false ;
boolean isAdmin = false;
String sql = "select count(1) from hrmresourcemanager where id="+id;
RecordSet rs = new RecordSet();
rs.executeSql(sql);
if(rs.next()){
if(rs.getInt(1)>0){
isAdmin = true;
}
}
return isAdmin;
}
/**
* response.json()
*/
public static String convertChar(String str){
str = str.replace("\t", "");
str = str.replace("\r", "");
str = str.replace("\n", "");
str = str.replace("\f", "");
return str;
}
public static List<SearchConditionOption> getDateSelectFromTo(int language){
return getDateSelectFromTo(language,"0");
}
/**
* 0-1-2-3-7-4-5-8-6-
* */
public static List<SearchConditionOption> getDateSelectFromTo(int language, String defaultValue){
if(Util.null2String(defaultValue).length()==0){
defaultValue = "0";
}
List<SearchConditionOption> options = new ArrayList<SearchConditionOption>();
options.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(332, language),"0".equals(defaultValue)));
options.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(15537, language),"1".equals(defaultValue)));
options.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(15539, language),"2".equals(defaultValue)));
options.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(15541, language),"3".equals(defaultValue)));
options.add(new SearchConditionOption("7", SystemEnv.getHtmlLabelName(27347, language),"7".equals(defaultValue)));
options.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(21904, language),"4".equals(defaultValue)));
options.add(new SearchConditionOption("5", SystemEnv.getHtmlLabelName(15384, language),"5".equals(defaultValue)));
options.add(new SearchConditionOption("8", SystemEnv.getHtmlLabelName(81716, language),"8".equals(defaultValue)));
options.add(new SearchConditionOption("6", SystemEnv.getHtmlLabelName(32530, language),"6".equals(defaultValue)));
return options;
}
/**
* input
* @param item
*/
public static void addMultiLanguageProperty(SearchConditionItem item){
if(!ServiceUtil.isMultilang )return;
Map<String, Object> otherParams = item.getOtherParams();
if(otherParams == null){
otherParams = new HashMap<String, Object>();
}
otherParams.put("inputType","multilang");
otherParams.put("isBase64",true);
if(Util.null2String(item.getValue()).length()>0){
item.setValue(TextUtil.toBase64ForMultilang(Util.null2String(item.getValue())));
}
item.setOtherParams(otherParams);
}
/**
* input()
*/
public static void addMultiLanguageProperty(HrmFieldBean hrmFieldBean){
if(!ServiceUtil.isMultilang || !hrmFieldBean.getMultilang())return;
Map<String, Object> otherParams = hrmFieldBean.getOtherparam();
if(otherParams == null){
otherParams = new HashMap<String, Object>();
}
if(hrmFieldBean.getFieldhtmltype().equals("1")&&hrmFieldBean.getType().equals("1")){
otherParams.put("inputType","multilang");
otherParams.put("isBase64",true);
//hrmFieldBean.setFieldvalue(TextUtil.toBase64ForMultilang(Util.null2String(hrmFieldBean.getFieldvalue())));
}
if(hrmFieldBean.getOtherparam()!=null){
otherParams.putAll(hrmFieldBean.getOtherparam());
}
hrmFieldBean.setOtherparam(otherParams);
}
public synchronized boolean initOrgLevel(){
RecordSet rs = new RecordSet();
RecordSet rs1 = new RecordSet();
String sql = "";
boolean needInitOrgLevel = false;//当分部或者部门有修改时调整tlevel
String tlvlCondition = DbDialectFactory.get(rs.getDBType()).isNull("tlevel", 0) ;
String lastinittime = "";
sql =" select lastinittime from hrmcompany ";
rs.executeSql(sql);
if(rs.next()){
lastinittime = Util.null2String(rs.getString("lastinittime"));
}
if(lastinittime.length()==0){//首次初始化
needInitOrgLevel = true;
}else{
sql =" select count(1) from hrmsubcompany where modified>(select lastinittime from hrmcompany) ";
rs.executeSql(sql);
if(rs.next()){
needInitOrgLevel = true;
}else{
sql =" select count(1) from hrmdepartment where modified>(select lastinittime from hrmcompany) ";
rs.executeSql(sql);
if(rs.next()){
needInitOrgLevel = true;
}
}
}
if(needInitOrgLevel){
if(rs.getDBType().equals("oracle")) {
//oracle的话 tempHrmSubCompanyView是视图视图里引用了HrmSubCompany在更新的时候导致死循环了 改用临时表的方式来处理
//创建临时表
String create_tmp_table= "CREATE TABLE "+tempHrmSubCompany_table+" AS SELECT A.ID,B.templevel FROM HrmSubCompany A,tempHrmSubCompanyView B WHERE A.ID=B.ID ";
boolean isok = rs1.executeUpdate(create_tmp_table);
if(isok){
String update_sql = "update HrmSubCompany set tlevel=(select distinct templevel from "+tempHrmSubCompany_table+" where "+tempHrmSubCompany_table+".id=HrmSubCompany.id) where nvl(tlevel,0)=0 ";
isok = rs1.executeUpdate(update_sql);
//删除临时表
String drop_tmp_table = "drop table "+tempHrmSubCompany_table;
isok = rs1.executeUpdate(drop_tmp_table);
}else{
rs.executeSql("update HrmSubCompany set tlevel=(select distinct templevel from tempHrmSubCompanyView where tempHrmSubCompanyView.id=HrmSubCompany.id) where nvl(tlevel,0)=0");
}
}else if(DialectUtil.isMySql(rs.getDBType())){
rs.executeSql("update HrmSubCompany left join (select distinct templevel,id from tempHrmSubCompanyView) t on t.id=HrmSubCompany.id set tlevel=t.templevel where "+tlvlCondition+"=0");
}else {
rs.executeSql("update HrmSubCompany set tlevel=(select distinct level from tempHrmSubCompanyView where tempHrmSubCompanyView.id=HrmSubCompany.id) where isnull(tlevel,0)=0");
}
if(rs.getDBType().equals("oracle")) {
//oracle的话 tempHrmSubCompanyView是视图视图里引用了HrmSubCompany在更新的时候导致死循环了 改用临时表的方式来处理
//创建临时表
String create_tmp_table= "CREATE TABLE "+tempHrmDepartment_table+" AS SELECT A.ID,B.templevel FROM HrmDepartment A,tempHrmDepartmentView B WHERE A.ID=B.ID ";
boolean isok = rs1.executeUpdate(create_tmp_table);
if(isok){
String update_sql = "update HrmDepartment set tlevel=(select distinct templevel from "+tempHrmDepartment_table+" where "+tempHrmDepartment_table+".id=HrmDepartment.id) where nvl(tlevel,0)=0";
isok = rs1.executeUpdate(update_sql);
//删除临时表
String drop_tmp_table = "drop table "+tempHrmDepartment_table;
isok = rs1.executeUpdate(drop_tmp_table);
}else{
rs.executeSql("update HrmDepartment set tlevel=(select distinct templevel from tempHrmDepartmentView where tempHrmDepartmentView.id=HrmDepartment.id) where nvl(tlevel,0)=0");;
}
}else if(DialectUtil.isMySql(rs.getDBType())){
rs.executeSql("update HrmDepartment left join (select distinct templevel,id from tempHrmDepartmentView) t on t.id=HrmDepartment.id set tlevel=t.templevel where "+tlvlCondition+"=0");;
} else {
rs.executeSql("update HrmDepartment set tlevel=(select distinct level from tempHrmDepartmentView where tempHrmDepartmentView.id=HrmDepartment.id) where isnull(tlevel,0)=0");
}
sql =" update hrmcompany set lastinittime="+DbFunctionUtil.getCurrentFullTimeFunction(rs.getDBType());
rs.executeUpdate(sql);
}
//虚拟组织没有modified 保持原状
if(rs.getDBType().equals("oracle")) {
rs.executeSql("update HrmSubCompanyVirtual set tlevel=(select distinct templevel from tempHrmSubCompanyVirtualView where tempHrmSubCompanyVirtualView.id=HrmSubCompanyVirtual.id) where nvl(tlevel,0)=0");
}else if(DialectUtil.isMySql(rs.getDBType())){
rs.executeSql("update HrmSubCompanyVirtual left join (select distinct templevel,id from tempHrmSubCompanyVirtualView) t on t.id=HrmSubCompanyVirtual.id set tlevel=t.templevel where "+tlvlCondition+"=0");
}
else if(rs.getDBType().equals("postgresql")) {
rs.executeSql("update HrmSubCompanyVirtual set tlevel=(select distinct templevel from tempHrmSubCompanyVirtualView where tempHrmSubCompanyVirtualView.id=HrmSubCompanyVirtual.id) where isnull(tlevel,0)=0");
}
else {
rs.executeSql("update HrmSubCompanyVirtual set tlevel=(select distinct level from tempHrmSubCompanyVirtualView where tempHrmSubCompanyVirtualView.id=HrmSubCompanyVirtual.id) where isnull(tlevel,0)=0");
}
if(rs.getDBType().equals("oracle")) {
rs.executeSql("update HrmDepartmentVirtual set tlevel=(select distinct templevel from tempHrmDepartmentVirtualView where tempHrmDepartmentVirtualView.id=HrmDepartmentVirtual.id) where nvl(tlevel,0)=0");
}else if(DialectUtil.isMySql(rs.getDBType())){
rs.executeSql("update HrmDepartmentVirtual left join (select distinct templevel,id from tempHrmDepartmentVirtualView) t on t.id=HrmDepartmentVirtual.id set tlevel=t.templevel where "+tlvlCondition+"=0");
}
else if(rs.getDBType().equals("postgresql"))
{
rs.executeSql("update HrmDepartmentVirtual set tlevel=(select distinct templevel from tempHrmDepartmentVirtualView where tempHrmDepartmentVirtualView.id=HrmDepartmentVirtual.id) where isnull(tlevel,0)=0");
}
else {
rs.executeSql("update HrmDepartmentVirtual set tlevel=(select distinct level from tempHrmDepartmentVirtualView where tempHrmDepartmentVirtualView.id=HrmDepartmentVirtual.id) where isnull(tlevel,0)=0");
}
return needInitOrgLevel;
}
// 人员查看日志改造:
// 1、显示字段为操作人员、操作时间、客户端地址、查看类型{人员小卡片、人员大卡片、查询人员列表、人员导出}、被查看对象、查看对象部门、查询对象分部、备注。
// 2、按照查看类型记录不同日志内容
// (1)人员小卡片:显示其被查看对象、查看对象部门、查询对象分部对应的具体值.
// (2)人员大卡片:显示其被查看对象、查看对象部门、查询对象分部对应的具体值.
// (3)查询人员列表:被查看对象给出其查询条件统计结果集的条数-即本次查询了多少人员,然后在【备注】列显示其按照什么条件进行查询的记录下来.
// (4)人员导出:需要记录其导出结果记录的条数-即本次查询导出了多少人员,然后在【备注】列显示其按照什么条件进行查询导出的记录下来.
private static ConcurrentHashMap<String, String> userid_resourceid2time = new ConcurrentHashMap<String, String>();
public void writeHrmResourceViewLog(Map<String,Object> params, User user){
try {
RecordSet rs = new RecordSet();
ResourceComInfo resourceComInfo = new ResourceComInfo();
String sql = "";
String resourceid = Util.null2String(params.get("resourceid"));
String subcompanyid = resourceComInfo.getSubCompanyID(resourceid);
String departmentid = resourceComInfo.getDepartmentID(resourceid);
String operatortype = Util.null2String(params.get("operatortype"));
int operator = user.getUID();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
String operatetime = df.format(new Date());
String memo = Util.null2String(params.get("memo"));
int resultcount = 0;
String ip = Util.null2String(params.get(ParamConstant.PARAM_IP));
if(operatortype.equals("0")){
String key = user.getUID()+"_"+resourceid;
String time = Util.null2String(userid_resourceid2time.get(user.getUID()+"_"+resourceid));
if( time.length()>0 && DateUtil.timeInterval(time,operatetime)<2){
return;
}
userid_resourceid2time.put(key,operatetime);
}
sql = Util.null2String(params.get("resultcount"));
if(sql.length()>0){
resultcount = 0;
try{
rs.executeQuery(sql);
if(rs.next()){
resultcount = rs.getInt(1);
}
}catch (Exception e){
writeLog(e);
}
}
sql = " INSERT INTO hrmresourceviewlog(resourceid,subcompanyid,departmentid,operatortype,operator,operatetime,ip,resultcount,memo) VALUES(?,?,?,?,?,?,?,?,?)";
rs.executeUpdate(sql,resourceid,subcompanyid,departmentid,operatortype,operator,operatetime,ip,resultcount==0?null:resultcount,memo);
}catch (Exception e){
writeLog(e);
}
}
public static String getCusFieldNames(String scope, int scopeid, String ext){
String cusFieldNames = "";
String sql = "";
RecordSet rs = new RecordSet();
try{
sql = "select min(seqorder) from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid = "+ scopeid;
rs.executeQuery(sql);
String minId = "";
if(rs.next()){
minId = Util.null2String(rs.getString(1));
}
List<String> lsFieldNames = new ArrayList<>();
sql = " select * from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid="+scopeid;
// 限制数据量
if(!"".equals(minId)){
sql += " and seqorder="+minId;
}
rs.executeQuery(sql);
int colcount = rs.getColCounts();
if (rs.next()) {
for (int i=4; i<=colcount; i++) {
if(rs.getColumnName(i).toLowerCase().startsWith("field")) {
lsFieldNames.add(rs.getColumnName(i).toLowerCase());
}
}
}
ext = Util.null2String(ext);
sql = "select fieldid from cus_formfield where scope='HrmCustomFieldByInfoType' and scopeid="+scopeid;
rs.execute(sql);
while (rs.next()){
String fieldname = "field"+rs.getString("fieldid");
if(lsFieldNames.contains(fieldname)){
if(ext.length()>0){
fieldname = ext+"."+fieldname;
}
if(cusFieldNames.length()>0)cusFieldNames+=",";
cusFieldNames+=fieldname;
}
}
}catch (Exception e){
new BaseBean().writeLog(e);
}
return cusFieldNames;
}
public static Map<String,Object> requestJson2Map(HttpServletRequest request){
Map<String, Object> returnMap = new HashMap<String, Object>();
try{
InputStream inStream = request.getInputStream();
ByteArrayOutputStream outSteam = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
boolean var3 = false;
int len;
while((len = inStream.read(buffer)) != -1) {
outSteam.write(buffer, 0, len);
}
outSteam.close();
inStream.close();
String json = new String(outSteam.toByteArray(), "UTF-8");
if(Util.null2String(json).length()>0){
returnMap = JSONObject.parseObject(json, new TypeReference<Map<String, Object>>(){});
}
}catch (Exception e){
new BaseBean().writeLog(e);
}
return returnMap;
}
/**
*
* @param id
* @param para2
* @return
*/
public String getTargetName(String id, String para2){
String[] otherParams = Util.TokenizerString2(para2, "+");
return SystemEnv.getHtmlLabelNames(otherParams[0], Util.getIntValue(otherParams[1],7));
}
public String getTableColumns(String sql, String ext, String excludeColumn){
String tableColumns = "";
RecordSet rs = new RecordSet();
rs.executeQuery(sql);
int colcount = rs.getColCounts();
for (int i=1; i<=colcount; i++) {
String fieldName = rs.getColumnName(i).toLowerCase();
if((","+excludeColumn+",").indexOf(","+fieldName+",")==-1){
if(tableColumns.length()>0)tableColumns+=",";
tableColumns += ext.length()>0?ext+"."+fieldName:fieldName;
}
}
return tableColumns;
}
/**
* E9EM7线
* @param userId 线id
*/
public void emOffline(String userId){
RecordSet rs = new RecordSet();
try {
new Thread() {//以下语句执行比较久,改为异步线程处理
@Override
public void run() {
synchronized (this) {
try{
//调用EM接口使人员强制下线EM
String sysid = EMManager.getEMData().get(EMManager.ec_id); //授权使用集成系统id
writeLog("sysid----"+sysid);
Map<String, Object> offlineParams = new HashMap<>();
offlineParams.put("sysid",sysid);
offlineParams.put("userids",userId); //需要退出的人员ID多个人员用逗号分隔
offlineParams.put("client_type","1,2,3,4"); //需要退出的客户端类型0-全部(默认) 1-EM的PC客户端 2-IOS端 3-安卓端 4-web版 多个端可以用逗号分隔
APPManager appManager = new APPManager();
appManager.emOffline(offlineParams);
}catch(Exception e){
writeLog("EM强制下线失败----;;;uid="+userId+"====",e);
}
}
}
}.start();
} catch (Exception e) {
writeLog(e);
}
}
/**
* E9PC线
* @param uids
* @param application
*/
public void offLine4PC (String uids, ServletContext application){
String [] userIds = Util.TokenizerString2(uids,",");
for(String uid:userIds) {
new LicenseCheckLogin().userOffline(uid);
Map userSessions = application == null ? null : (Map) application.getAttribute("userSessions");
List<HttpSession> slist = (userSessions != null && userSessions.containsKey(uid)) ? (List<HttpSession>) userSessions.get(uid) : null;
int lsize = slist == null ? 0 : slist.size();
for (int i = 0; i < lsize; i++) {
try {
slist.get(i).setAttribute("offLine4PC", "1");
writeLog(uid + "下线成功");
} catch (IllegalStateException e) {
writeLog("E9的PC端强制下线出现异常",e);
}
}
HrmUserOnlineMap.getInstance().userOffline(uid);
}
}
public static String saveResourceImage(String imgStr){
String fileId = "";
try{
if(Util.null2String(imgStr).length() == 0) {
return "";
}
if(imgStr.startsWith("*")){
imgStr = imgStr.substring(1,imgStr.length());
}else{
imgStr = Util.splitString(imgStr,",")[1];
}
BASE64Decoder decoder = new BASE64Decoder();
byte[] b = decoder.decodeBuffer(imgStr);
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {
b[i] += 256;
}
}
UUID uuid = UUID.randomUUID();
String fileName = uuid.toString().replaceAll("-", "") + ".jpg";
ImageFileManager imageFileManager = new ImageFileManager();
imageFileManager.setImagFileName(fileName);
imageFileManager.setData(b);
fileId = ""+imageFileManager.saveImageFile();
}catch (Exception e){
new BaseBean().writeLog("saveResourceImage>>>>>>>>>>>>>>>"+e);
}
return fileId;
}
/**
* @Description
* @auther Murphy
* @date 2019/7/15 19:01
* @param
* @return java.lang.String
**/
public static String saveMessagerUrl(int imagefiledid,String userId){
String imageFilePath = "";
String imageFileName = UUID.randomUUID().toString() + ".jpg";
RecordSet recordSet = new RecordSet();
InputStream in = null;
try{
String filePath = GCONST.getRootPath() + "messager" + File.separatorChar + "usericon" + File.separatorChar + imageFileName;
ImageFileManager imageFileManager = new ImageFileManager();
in = imageFileManager.getInputStreamById(imagefiledid);
if(in != null){
reduceImg(in,filePath);
imageFilePath = "/messager/usericon/" + imageFileName;
String sql = "update hrmresource set messagerurl= ? where id=?";
recordSet.executeUpdate(sql,imageFilePath,userId);
ResourceComInfo resourceComInfo=new ResourceComInfo();
resourceComInfo.updateResourceInfoCache(userId);
}
}catch (Exception e){
recordSet.writeLog(e);
}finally{
if(in != null){
try {
in.close();
}catch(Exception ex){
recordSet.writeLog(ex);
}
}
}
return imageFilePath;
}
/**
*
* @param imgdist
*/
public static void reduceImg(InputStream in, String imgdist){
try {
// 开始读取文件并进行压缩
if(in!=null){
Thumbnails.of(in).scale(1f).outputQuality(0.8f).toFile(new File(imgdist));
}
} catch (IOException ex) {
ex.printStackTrace();
}finally{
try {
in.close();
}catch(Exception ex){
ex.printStackTrace();
}
}
}
/**
*
*
* in
* @return
*/
public static int[] getImgWidth(InputStream in) {
BufferedImage src = null;
int result[] = { 0, 0 };
try {
if(in!=null){
src = javax.imageio.ImageIO.read(in);
result[0] = src.getWidth(null); // 得到源图宽
result[1] = src.getHeight(null); // 得到源图高
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public static void updateLastDate(String id){
String current = DateUtil.getCurrentDate() ;
RecordSet rs = new RecordSet() ;
try{
rs.executeQuery("select 1 from userlastlogindate where userid=?",id) ;
if(rs.next()){
rs.executeQuery("select 1 from userlastlogindate where userid=? and lastlogindate=?",id,current) ;
if(rs.next()){
//已存在记录,不再更新
}else{
rs.executeUpdate("update userlastlogindate set lastlogindate=? where userid=?",current,id) ;
}
}else{
rs.executeUpdate("insert into userlastlogindate(userid,lastlogindate) values (?,?)",id,current) ;
}
}catch (Exception e){
rs.writeLog("ServiceUtil.updateLastDate(id) error");
rs.writeLog(e);
}
}
/**
*
* @param cmd subcom,dept,hrm,jobtitle
* @param fielddesc
* @param userlanguage
* @return
*/
public List<Map<String,String>> getCusFieldsData(String cmd,String fielddesc,int userlanguage){
Map<String,String> fieldMaps = null;
List<Map<String,String>> datas = new ArrayList<>();
String labelname = "";
try{
if("subcom".equals(cmd) || "dept".equals(cmd)){
HrmFieldComInfo HrmFieldComInfo = new HrmFieldComInfo();
int scopeid = "subcom".equals(cmd)?4:5;
HrmDeptFieldManagerE9 hfm = new HrmDeptFieldManagerE9(scopeid);
hfm.isReturnDecryptData(true);
List lsGroup = hfm.getLsGroup();
for (int tmp = 0; lsGroup != null && tmp < lsGroup.size(); tmp++) {
String groupid = (String) lsGroup.get(tmp);
List lsField = hfm.getLsField(groupid);
for (int j = 0; lsField != null && j < lsField.size(); j++) {
fieldMaps = new HashMap<>();
String fieldid = (String) lsField.get(j);
String fieldname = HrmFieldComInfo.getFieldname(fieldid);
if(fieldname.equalsIgnoreCase("limitUsers")||fieldname.equalsIgnoreCase("subshowid") || fieldname.equalsIgnoreCase("showid"))continue;
String fieldlabel = HrmFieldComInfo.getLabel(fieldid);
labelname = SystemEnv.getHtmlLabelNames(fieldlabel,userlanguage);
if(fielddesc.length()>0 && !labelname.contains(fielddesc)) continue;
String issystem = HrmFieldComInfo.getIssystem(fieldid).equals("1") ? "1" : "2";
fieldMaps.put("labelname",SystemEnv.getHtmlLabelNames(fieldlabel,userlanguage));
fieldMaps.put("fieldname",fieldname);
fieldMaps.put("issystem",issystem);
fieldMaps.put("scopeid",scopeid+"");
datas.add(fieldMaps);
}
}
labelname = SystemEnv.getHtmlLabelNames("602",userlanguage);
if(fielddesc.length()==0 || labelname.contains(fielddesc)){
fieldMaps = new HashMap<>();
fieldMaps.put("labelname",labelname);
fieldMaps.put("fieldname","canceled");
fieldMaps.put("issystem","1");
datas.add(fieldMaps);
}
}else if("hrm".equals(cmd)){
int [] scopeIds = {-1,1,3};
HrmFieldManager hfm = null;
for(int scopeId : scopeIds) {
hfm = new HrmFieldManager("HrmCustomFieldByInfoType", scopeId);
CustomFieldManager cfm = new CustomFieldManager("HrmCustomFieldByInfoType", scopeId);
hfm.getCustomFields();
while (hfm.next()) {
fieldMaps = new HashMap<>();
String fieldlabel = hfm.getLable();
String fieldName = hfm.getFieldname();
labelname = SystemEnv.getHtmlLabelNames(fieldlabel,userlanguage);
if(fielddesc.length()>0 && !labelname.contains(fielddesc)) continue;
boolean isBaseField = hfm.isBaseField(fieldName);
if("jobactivity".equals(fieldName)){
fieldName = "jobactivityid";
}
String issystem = isBaseField ? "1" : "2";
fieldMaps.put("labelname",labelname);
fieldMaps.put("fieldname",isBaseField ? fieldName:scopeId+"_"+fieldName);
fieldMaps.put("issystem",issystem);
fieldMaps.put("scopeid",scopeId+"");
datas.add(fieldMaps);
}
if(scopeId==-1){
labelname = SystemEnv.getHtmlLabelNames("409",userlanguage);
if(fielddesc.length()==0 || labelname.contains(fielddesc)){
fieldMaps = new HashMap<>();
fieldMaps.put("labelname",labelname);
fieldMaps.put("fieldname","password");
fieldMaps.put("issystem","1");
datas.add(fieldMaps);
}
labelname = SystemEnv.getHtmlLabelNames("519202",userlanguage);
if(fielddesc.length()==0 || labelname.contains(fielddesc)){
fieldMaps = new HashMap<>();
fieldMaps.put("labelname",labelname);
fieldMaps.put("fieldname","salt");
fieldMaps.put("issystem","1");
datas.add(fieldMaps);
}
labelname = SystemEnv.getHtmlLabelNames("683",userlanguage);
if(fielddesc.length()==0 || labelname.contains(fielddesc)){
fieldMaps = new HashMap<>();
fieldMaps.put("labelname",labelname);
fieldMaps.put("fieldname","seclevel");
fieldMaps.put("issystem","1");
datas.add(fieldMaps);
}
labelname = SystemEnv.getHtmlLabelNames("15513",userlanguage);
if(fielddesc.length()==0 || labelname.contains(fielddesc)){
fieldMaps = new HashMap<>();
fieldMaps.put("labelname",labelname);
fieldMaps.put("fieldname","dsporder");
fieldMaps.put("issystem","1");
datas.add(fieldMaps);
}
boolean isOpenClassification = HrmClassifiedProtectionBiz.isOpenClassification();//判断是否开启了分级保护
if(isOpenClassification){
labelname = SystemEnv.getHtmlLabelNames("130506",userlanguage);
if(fielddesc.length()==0 || labelname.contains(fielddesc)){
fieldMaps = new HashMap<>();
fieldMaps.put("labelname",labelname);
fieldMaps.put("fieldname","classification");
fieldMaps.put("issystem","1");
datas.add(fieldMaps);
}
}
}
}
}else if("jobtitle".equals(cmd)){
String[] fields = new String[]{"jobtitlemark,382413", "jobtitlename,382414", "jobtitlecode,524944", "jobactivityid,15855", "jobresponsibility,15856", "jobdoc,857", "jobcompetency,895", "jobtitleremark,454","jobgroupId,805","canceled,602"};
for (int i = 0; i < fields.length; i++) {
String[] fieldinfo = fields[i].split(",");
fieldMaps = new HashMap<>();
String fieldlabel = fieldinfo[1];
String fieldName = fieldinfo[0];
String issystem = "1";
labelname = SystemEnv.getHtmlLabelNames(fieldlabel,userlanguage);
if(fielddesc.length()>0 && !labelname.contains(fielddesc)) continue;
fieldMaps.put("labelname",labelname);
fieldMaps.put("fieldname",fieldName);
fieldMaps.put("issystem",issystem);
fieldMaps.put("scopeid","0");
datas.add(fieldMaps);
}
}
labelname = SystemEnv.getHtmlLabelNames("126059",userlanguage);
if(fielddesc.length()==0 || labelname.contains(fielddesc)){
fieldMaps = new HashMap<>();
fieldMaps.put("labelname",labelname);
fieldMaps.put("fieldname","outkey");
fieldMaps.put("issystem","1");
datas.add(fieldMaps);
}
}catch (Exception e){
e.printStackTrace();
}
return datas;
}
public boolean calClassification(String userid,String classification){
boolean flag = false;
try{
RecordSet rs = new RecordSet();
classification = ""+Util.getIntValue(classification,3);
Map<String,String> crcInfo = new EncryptUtil().getLevelCRC(userid,classification);
String encKey = Util.null2String(crcInfo.get("encKey"));
String crc = Util.null2String(crcInfo.get("crc"));
flag = rs.executeUpdate("update hrmresource set classification=?,encKey=?,crc=? where id=?",classification,encKey,crc,userid);
}catch (Exception e){
writeLog(e);
e.printStackTrace();
}
return flag;
}
public boolean needCheckDismiss(String fieldname){
RecordSet rs = new RecordSet();
String neekCheck = Util.null2String(rs.getPropValue("Others",fieldname),"1");
return "1".equals(neekCheck);
}
}

@ -0,0 +1,954 @@
package weaver.hrm.pm.action;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import com.api.hrm.bean.HrmFieldBean;
import com.api.hrm.service.HrmResourceWorkService;
import com.api.hrm.util.ServiceUtil;
import com.engine.common.service.impl.HrmCommonServiceImpl;
import com.engine.hrm.entity.RuleCodeType;
import com.engine.hrm.util.CodeRuleManager;
import com.engine.hrm.util.face.HrmFaceCheckManager;
import com.engine.hrm.util.face.ValidateFieldManager;
import com.engine.hrm.util.face.bean.CheckItemBean;
import org.apache.commons.validator.EmailValidator;
import weaver.common.DateUtil;
import weaver.common.StringUtil;
import weaver.conn.RecordSet;
import weaver.conn.RecordSetTrans;
import weaver.docs.docs.CustomFieldManager;
import weaver.file.ImageFileManager;
import weaver.general.GCONST;
import weaver.general.PasswordUtil;
import weaver.general.Util;
import weaver.hrm.common.DbFunctionUtil;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.companyvirtual.DepartmentVirtualComInfo;
import weaver.hrm.definedfield.HrmFieldManager;
import weaver.hrm.finance.SalaryManager;
import weaver.hrm.passwordprotection.manager.HrmResourceManager;
import weaver.hrm.resource.CustomFieldTreeManager;
import weaver.hrm.resource.ResourceComInfo;
import weaver.hrm.settings.ChgPasswdReminder;
import weaver.hrm.settings.RemindSettings;
import weaver.hrm.tools.HrmDateCheck;
import weaver.system.SysRemindWorkflow;
import weaver.systeminfo.SysMaintenanceLog;
import weaver.systeminfo.SystemEnv;
/**
*
* @author wcd
* @version 1.0 2015-07-07
*/
public class HrmResourceEntrantAction extends PmAction {
private Map<String, Object> baseData = new HashMap<>();
private Map<String, Object> custData = new HashMap<>();
private Map<Integer, List> hrmSelectItem = new HashMap<>();
private Map<Integer, List> cusSelectItem = new HashMap<>();
private Map<String, Map> fieldMap = new HashMap<>();
private static List donotExportFields = Arrays.asList(new String[]{"loginid", "workyear", "companyworkyear"});
private static List<String> parseList = new ArrayList(Arrays.asList("jobtitle", "locationid", "status", "accounttype", "managerid", "jobcall", "joblevel", "assistantid"));
protected int todo() {
return HRM_RESOURCE_ENTRANT;
}
protected void parse() throws Exception {
try {
writeLog("in HrmResourceEntrantAction parse " + todo());
RecordSet rs = new RecordSet();
findFields();
loadHrmSelectItem();
loadCusSelectItem();
for (String key : baseData.keySet()) {
if (parseList.contains(key))
baseData.put(key, Util.getIntValue(rsdt.getString(key), 0));
else if (key.equals("systemlanguage"))
baseData.put(key, Util.getIntValue(rsdt.getString(key), 7));
else
baseData.put(key, transValue(key));
}
for (String key : custData.keySet()) {
custData.put(key, transValue(key));
}
//处理人员照片
String resourceimageid = (String) getValue("resourceimageid");
resourceimageid = getImageIdByDocid(resourceimageid);
//考虑到流程文档权限的问题,把附件复制一份
resourceimageid = Util.null2String(ImageFileManager.copyImageFile(Util.getIntValue(resourceimageid)));
if (resourceimageid.equals("0")) {
writeLog("resourceimageid为0上传图片没有成功");
}
//处理密码
String password = (String) getValue("password");
ChgPasswdReminder reminder = new ChgPasswdReminder();
RemindSettings settings = reminder.getRemindSettings();
//判断是否开启了【启用初始密码】
String defaultPasswordEnable = Util.null2String(settings.getDefaultPasswordEnable());
//【初始密码】
String defaultPassword = Util.null2String(settings.getDefaultPassword());
//如果入职流程的密码为空。并且开启了【启用初始密码】,且初始密码不为空,则默认取初始密码作为密码
if (password.equals("") && defaultPasswordEnable.equals("1") && !defaultPassword.equals("")) {
password = defaultPassword;
}
//处理电话号码
String mobile = (String) getValue("mobile");
String telephone = (String) getValue("telephone");
CheckItemBean mobileBean = new CheckItemBean("mobile", mobile);
ValidateFieldManager.validate(mobileBean);
if (!mobileBean.isPass()) {
this.reqManager.setMessage(mobileBean.getCheckMsg());
throw new Exception(mobileBean.getCheckMsg());
}
CheckItemBean telephoneBean = new CheckItemBean("telephone", telephone);
ValidateFieldManager.validate(telephoneBean);
if (!telephoneBean.isPass()) {
this.reqManager.setMessage(telephoneBean.getCheckMsg());
throw new Exception(telephoneBean.getCheckMsg());
}
//处理姓名
String belongto = (String) getValue("belongto");
String lastname = (String) getValue("lastname");
writeLog("in HrmResourceEntrantAction lastname " + lastname + ":" + ((lastname.length() == 0)));
if (lastname.length() == 0) {
this.reqManager.setMessage(SystemEnv.getHtmlLabelName(125311,user.getLanguage()));
throw new Exception("姓名不能为空!");
}
// 基本信息
int accounttype = Util.getIntValue(Util.null2String(getValue("accounttype")), 0);
baseData.remove("accounttype");
if (accounttype == 0) belongto = "-1";
String departmentvirtualids = "";// 虚拟部门id;
boolean falg = false;
//验证用户名
String loginid = (String) getValue("loginid");
baseData.remove("loginid");
if ("".equals(loginid) && accounttype == 1) {
rs.executeSql("select loginid from HrmResource where id =" + belongto);
if (rs.next()) {
loginid = rs.getString("loginid");
}
if (!loginid.equals("")) {
String maxidsql = "select max(id) as id from HrmResource where loginid like '" + loginid + "%'";
rs.executeSql(maxidsql);
if (rs.next()) {
loginid = loginid + (rs.getInt("id") + 1);
falg = true;
}
}
}
String seclevel = (String) getValue("seclevel");
if(Math.abs(Util.getIntValue(seclevel)) > 999){
seclevel = "0";
//this.reqManager.setMessage(SystemEnv.getHtmlLabelNames("518227", user.getLanguage()));
setReqMessage(SystemEnv.getHtmlLabelName(518227, Util.getIntValue(user.getLanguage())));
throw new Exception("安全级别区间错误!");
}
String managerstr = "";
int managerid = Util.getIntValue(Util.null2String(getValue("managerid")), 0);
String sql = "select managerstr, seclevel from HrmResource where id = " + managerid;
rs.executeSql(sql);
while (rs.next()) {
String tmp_managerstr = rs.getString("managerstr");
/*********处理managerstr 不以逗号开始或者结束的情况 形如 managerstr8 begin***********/
if (!tmp_managerstr.startsWith(",")) tmp_managerstr = "," + tmp_managerstr;
if (!tmp_managerstr.endsWith(",")) tmp_managerstr = tmp_managerstr + ",";
/*********处理managerstr 不以逗号开始或者结束的情况 形如 managerstr8 end ***********/
managerstr += tmp_managerstr;
managerstr = "," + managerid + managerstr;
managerstr = managerstr.endsWith(",") ? managerstr : (managerstr + ",");
//seclevel = "".equals(seclevel) ? rs.getString("seclevel") : seclevel;
}
String departmentid = (String) getValue("departmentid");
String subcmpanyid1 = new DepartmentComInfo().getSubcompanyid1(departmentid);
if (!"".equals(loginid)) {
rs.execute("select id from HrmResource where loginid='" + loginid + "'");
if (rs.next()) {
loginid = "";
//this.reqManager.setMessage(SystemEnv.getHtmlLabelNames("412,18082", user.getLanguage()));
setReqMessage(SystemEnv.getHtmlLabelName(10000165, Util.getIntValue(user.getLanguage())));
throw new Exception("人员登录名重复!");
} else if(accounttype != 1){
if (ln.CkHrmnum() >= 0){
setReqMessage(SystemEnv.getHtmlLabelName(16078, Util.getIntValue(user.getLanguage())));
throw new Exception("有效用户数已到license上限");
}
int limitUsers = 0;
rs.execute("select limitUsers from HrmSubCompany where id=" + subcmpanyid1);
if (rs.next()) {
limitUsers = StringUtil.parseToInt(rs.getString("limitUsers"), 0);
}
if (limitUsers > 0) {
int subIdInt = Util.getIntValue(subcmpanyid1, 0);
int cnt = new HrmResourceManager().count(0, subIdInt);
if (cnt >= limitUsers) {
loginid = "";
setReqMessage(SystemEnv.getHtmlLabelName(10000166, Util.getIntValue(user.getLanguage())));
throw new Exception("人员超过分部设置的人员限制数!");
}
}
}
}
//处理系统字段数据
RecordSetTrans rst = new RecordSetTrans();
rst.setAutoCommit(false);
String para = "";
String email = (String) getValue("email");
if (!"".equals(email) && !EmailValidator.getInstance().isValid(email)) {
//this.reqManager.setMessage(SystemEnv.getHtmlLabelNames("20869,24944", user.getLanguage()));
setReqMessage(SystemEnv.getHtmlLabelName(10000167, Util.getIntValue(user.getLanguage())));
throw new Exception("邮箱格式错误!");
}
String certificatenum = Util.null2String(baseData.get("certificatenum")).trim();
if(!"".equals(certificatenum)){
rs.executeQuery("select id from HrmResource where certificatenum = ? "+(new ServiceUtil().needCheckDismiss("certificatenum")?"":" and status in(0,1,2,3) "), certificatenum);
if (rs.next()) {
certificatenum = "";
setReqMessage(SystemEnv.getHtmlLabelName(83521,weaver.general.Util.getIntValue(user.getLanguage())));
throw new Exception("身份证重复!");
}
}
//验证编号
String workcode = (String) getValue("workcode");
int jobtitle = Util.getIntValue(Util.null2String(getValue("jobtitle")), 0);
workcode = CodeRuleManager.getCodeRuleManager().generateRuleCode(RuleCodeType.USER, subcmpanyid1, departmentid, jobtitle + "", workcode);
if (!workcode.equals("")) {
rs.execute("select workcode from HrmResource where workcode ='" + workcode + "'");
if (rs.next()) {
workcode = "";
//this.reqManager.setMessage(SystemEnv.getHtmlLabelNames("714,18082", user.getLanguage()));
setReqMessage(SystemEnv.getHtmlLabelName(503017, Util.getIntValue(user.getLanguage())));
throw new Exception("编号重复!");
}
}
rs.executeProc("HrmResourceMaxId_Get", "");
rs.next();
String id = String.valueOf(rs.getInt(1));
String dsporder = String.valueOf(id);
try {
String sex = (String) getValue("sex");
int joblevel = Util.getIntValue(Util.null2String(getValue("joblevel")), 0);
int locationid = Util.getIntValue(Util.null2String(getValue("locationid")), 0);
int status = Util.getIntValue(Util.null2String(getValue("status")), 0);
int jobcall = Util.getIntValue(Util.null2String(getValue("jobcall")), 0);
int assistantid = Util.getIntValue(Util.null2String(getValue("assistantid")), 0);
String jobactivitydesc = (String) getValue("jobactivitydesc");
String workroom = (String) getValue("workroom");
String mobilecall = (String) getValue("mobilecall");
String fax = (String) getValue("fax");
int systemlanguage = Util.getIntValue(Util.null2String(getValue("systemlanguage")), 7);
int mobileshowtype = 0;
mobileshowtype = StringUtil.parseToInt(settings.getMobileShowTypeDefault(), 0);
String costcenterid = "";
para = "" + id + separator + workcode + separator + lastname + separator + sex + separator + resourceimageid
+ separator + departmentid + separator + costcenterid + separator + jobtitle + separator
+ joblevel + separator + jobactivitydesc + separator + managerid + separator + assistantid + separator
+ status + separator + locationid + separator + workroom + separator + telephone + separator
+ mobile + separator + mobilecall + separator + fax + separator + jobcall + separator
+ subcmpanyid1 + separator + managerstr + separator + accounttype + separator + belongto + separator
+ systemlanguage + separator + email + separator + dsporder + separator + mobileshowtype;
writeLog("in HrmResourceEntrantAction HrmResourceBasicInfo_Insert " + para);
rst.executeProc("HrmResourceBasicInfo_Insert", para);
if (locationid > 0)
rst.executeSql("update hrmresource set countryid=(select countryid from HrmLocations where id=" + locationid + ") where id=" + id);
if (!"".equals(loginid)) {
if ("".equals(password)) {
password = "1";
}
String[] pwds = PasswordUtil.encrypt(password);
String logidsql = "update HrmResource set loginid = ?,password =?,salt=? where id =?";
rst.executeUpdate(logidsql, loginid, pwds[0], pwds[1], id);
}
if (seclevel == null || "".equals(seclevel)) {
seclevel = "0";
}
rst.executeUpdate("update hrmresource set seclevel = ?, "+ DbFunctionUtil.getInsertUpdateSetSql(rs.getDBType(),creater) +" where id=? ", seclevel, id);
//String p_para = id + separator + departmentid + separator + subcmpanyid1 + separator + managerid + separator + seclevel + separator + managerstr + separator + "0" + separator + "0" + separator + "0" + separator + "0" + separator + "0" + separator + "0";
//System.out.println(p_para);
//rst.executeProc("HrmResourceShare", p_para);
rst.commit();
String messagerurl = (String) getValue("messagerurl");
messagerurl = getImageIdByDocid(messagerurl);
//考虑到流程文档权限的问题,把附件复制一份
messagerurl = Util.null2String(ImageFileManager.copyImageFile(Util.getIntValue(messagerurl)));
if (!"".equals(messagerurl) && !"0".equals(messagerurl)) {
messagerurl = copyFile(messagerurl);
rs.executeUpdate("update hrmresource set messagerurl = ? where id = ?", messagerurl, id);
}
try {
HrmFaceCheckManager.setUserPassowrd(id+"",password);
new ResourceComInfo().removeResourceCache();
} catch (Exception e) {
writeLog(e);
}
HrmFaceCheckManager.sync(id, HrmFaceCheckManager.getOptInsert(), this.getClass().getName(), HrmFaceCheckManager.getOaResource());
} catch (Exception e) {
rst.rollback();
writeLog(e);
throw e;
}
para = "" + id;
int userid = creater;
Calendar todaycal = Calendar.getInstance();
String today = Util.add0(todaycal.get(Calendar.YEAR), 4) + "-" + Util.add0(todaycal.get(Calendar.MONTH) + 1, 2) + "-" + Util.add0(todaycal.get(Calendar.DAY_OF_MONTH), 2);
String userpara = "" + userid + separator + today;
for (int i = 0; i < 5; i++) para += separator + "" + separator + "" + separator + "" + separator + "";
rs.executeProc("HrmResourceDefine_Update", para);
rs.executeProc("HrmResource_CreateInfo", "" + id + separator + userpara + separator + userpara);
// 改为只进行该人缓存信息的添加
new ResourceComInfo().addResourceInfoCache(id);
new SalaryManager().initResourceSalary(id);
para = "" + id + separator + managerid + separator + departmentid + separator + subcmpanyid1 + separator + "0" + separator + managerstr;
rs.executeProc("HrmResource_Trigger_Insert", para);
String sql_1 = ("insert into HrmInfoStatus (itemid,hrmid) values(1," + id + ")");
rs.executeSql(sql_1);
String sql_2 = ("insert into HrmInfoStatus (itemid,hrmid) values(2," + id + ")");
rs.executeSql(sql_2);
String sql_3 = ("insert into HrmInfoStatus (itemid,hrmid) values(3," + id + ")");
rs.executeSql(sql_3);
String sql_10 = ("insert into HrmInfoStatus (itemid,hrmid) values(10," + id + ")");
rs.executeSql(sql_10);
String name = lastname;
String SWFAccepter = "";
String SWFTitle = "";
String SWFRemark = "";
String Subject = "";
Subject = SystemEnv.getHtmlLabelName(15670, user.getLanguage());
Subject += ":" + name;
if ("1".equals(settings.getEntervalid())) {//入职提醒
/* String thesql="select distinct hrmid from HrmInfoMaintenance where id<4 or id = 10";
rs.executeSql(thesql);
String members="";
while(rs.next()){
int hrmid_tmp = Util.getIntValue(rs.getString("hrmid"));//TD9392
if(hrmid_tmp > 0 && creater != hrmid_tmp){
members += ","+rs.getString("hrmid");
}
}
if(!members.equals("")){
members = members.substring(1);
SWFAccepter=members;*/
String thesql = "select hrmids from HrmInfoMaintenance where id<4 or id = 10";
rs.executeSql(thesql);
String members = "";
/*while(rs.next()){
int hrmid_tmp = Util.getIntValue(rs.getString("hrmids"));//TD9392
if(hrmid_tmp > 0 && user.getUID() != hrmid_tmp){
members += ","+rs.getString("hrmids");
}
}*/
while (rs.next()) {
String hrmid_tmp = Util.null2String(rs.getString("hrmids"));//TD9392
if (hrmid_tmp.length() != 0) {
members += "," + rs.getString("hrmids");
}
}
if (!members.equals("")) {
members = members.substring(1);
members = duplicateRemoval(members, user.getUID() + "");
SWFAccepter = members;
SWFTitle = SystemEnv.getHtmlLabelName(15670, user.getLanguage());
SWFTitle += ":" + name;
SWFTitle += "-" + createrName;
SWFTitle += "-" + today;
// SWFRemark="<a href=/hrm/employee/EmployeeManage.jsp?hrmid="+id+">"+Util.fromScreen2(Subject,user.getLanguage())+"</a>";
SWFRemark = "<a class='wea-hrm-new-employee-set' onClick=\"openHrmNewEmployeeSetDialog(" + id + ")\" style=\"cursor:pointer;\" id = '" + id + "'>" + Util.fromScreen2(Subject, user.getLanguage()) + "</a>";
RemindWorkflowThreadUtil.remindWorkflowPool.submit(new RemindWorkflowThread(SWFTitle, 0, creater, SWFAccepter, SWFRemark));
}
}
//更新虚拟组织部门id
if (departmentvirtualids.length() > 0) {
//保存前先删除需要删除的数据因为有managerid 所以不能全部删除再保存
sql = "delete from hrmresourcevirtual where resourceid=" + id + " and departmentid not in (" + departmentvirtualids + ")";
rs.executeSql(sql);
String[] departmentvirtualid = departmentvirtualids.split(",");
for (int i = 0; departmentvirtualid != null && i < departmentvirtualid.length; i++) {
rs.executeSql(" select count(*) from HrmResourceVirtual where departmentid ='" + departmentvirtualid[i] + "' and resourceid = " + id);
if (rs.next()) {
//如果已存在 无需处理
if (rs.getInt(1) > 0) continue;
}
//写入
int tmpid = 0;
rs.executeSql("select max(id) from HrmResourceVirtual ");
if (rs.next()) {
tmpid = rs.getInt(1) + 1;
}
String subcompanyid = new DepartmentVirtualComInfo().getSubcompanyid1(departmentvirtualid[i]);
sql = " insert into HrmResourceVirtual (id,resourceid,subcompanyid,departmentid ) " + " values (" + tmpid + "," + id + "," + subcompanyid + "," + departmentvirtualid[i] + ")";
rs.executeSql(sql);
}
}
if (!"".equals(lastname)) {
String quickSearchStr = new HrmCommonServiceImpl().generateQuickSearchStr(lastname);
String sqlStr = "update HrmResource set pinyinlastname = ?, ecology_pinyin_search = ? where id = ?";
rs.executeUpdate(sqlStr, quickSearchStr, quickSearchStr, id);
}
SysMaintenanceLog log = new SysMaintenanceLog();
log.resetParameter();
log.setRelatedId(Util.getIntValue(id));
log.setRelatedName(lastname);
log.setOperateItem("29");
log.setOperateUserid(creater);
log.setClientAddress(clientIp);
log.setOperateType("1");
log.setOperateDesc("HrmResourceBasicInfo_Insert");
log.setSysLogInfo();
//个人信息
String tempcertificatenum = certificatenum;
if (!certificatenum.equals("")) {
rs.executeSql("select id from HrmResource where id<>" + id + " and certificatenum='" + certificatenum + "'");
if (rs.next()) {
rs.executeSql("select certificatenum from HrmResource where id=" + id);
if (rs.next()) {
tempcertificatenum = Util.null2String(rs.getString("certificatenum"));
}
}
}
String birthday = (String) getValue("birthday");
String folk = (String) getValue("folk");
String nativeplace = (String) getValue("nativeplace");
String regresidentplace = (String) getValue("regresidentplace");
String maritalstatus = (String) getValue("maritalstatus");
String policy = (String) getValue("policy");
String bememberdate = (String) getValue("bememberdate");
String bepartydate = (String) getValue("bepartydate");
String islabouunion = (String) getValue("islabouunion");
String educationlevel = (String) getValue("educationlevel");
String degree = (String) getValue("degree");
String healthinfo = (String) getValue("healthinfo");
String height = (String) getValue("height");
String weight = (String) getValue("weight");
String residentplace = (String) getValue("residentplace");
String homeaddress = (String) getValue("homeaddress");
String tempresidentnumber = (String) getValue("tempresidentnumber");
para = "" + id + separator + birthday + separator + folk + separator + nativeplace + separator
+ regresidentplace + separator + maritalstatus + separator + policy + separator + bememberdate + separator
+ bepartydate + separator + islabouunion + separator + educationlevel + separator + degree + separator
+ healthinfo + separator + height + separator + weight + separator + residentplace + separator
+ homeaddress + separator + tempresidentnumber + separator + tempcertificatenum;
rs.executeProc("HrmResourcePersonalInfo_Insert", para);
rs.executeProc("HrmResource_ModInfo", "" + id + separator + userpara);
log.resetParameter();
log.setRelatedId(Util.getIntValue(id));
log.setRelatedName(new ResourceComInfo().getResourcename(id));
log.setOperateItem("29");
log.setOperateUserid(creater);
log.setClientAddress(clientIp);
log.setOperateType("1");
log.setOperateDesc("HrmResourcePersonalInfo_Insert");
log.setSysLogInfo();
//工作信息
String usekind = (String) getValue("usekind");
String startdate = (String) getValue("startdate");
String probationenddate = (String) getValue("probationenddate");
String enddate = (String) getValue("enddate");
para = "" + id + separator + usekind + separator + startdate + separator + probationenddate + separator + enddate;
rs.executeProc("HrmResourceWorkInfo_Insert", para);
rs.executeProc("HrmResource_ModInfo", "" + id + separator + userpara);
log.resetParameter();
log.setRelatedId(Util.getIntValue(id));
log.setRelatedName(new ResourceComInfo().getResourcename(id));
log.setOperateItem("29");
log.setOperateUserid(creater);
log.setClientAddress(clientIp);
log.setOperateType("1");
log.setOperateDesc("HrmResourceWorkInfo_Insert");
log.setSysLogInfo();
baseData.remove("jobactivity");
baseData.remove("jobGroupId");
if (baseData.keySet().size() > 0) {
sql = "update hrmresource set ";
String sqlWhere = " where id = " + id;
String setSql = "";
for (String key : baseData.keySet()) {
setSql += ", " + key + " = ";
Map<String, Object> fieldConfig = fieldMap.get(key);
String fieldDbType = (String) fieldConfig.get("FieldDbType");
String type = Util.null2String(fieldConfig.get("Type"));
String htmltype = Util.null2String(fieldConfig.get("HtmlType"));
String value = Util.null2String(baseData.get(key));
if (htmltype.equals("6")) {
String fileid = value;
List<String> transId = new ArrayList<>();
List<String> ids = Util.splitString2List(fileid, ",");
for (String fid : ids) {
String copyId = getImageIdByDocid(fid);
//考虑到流程文档权限的问题,把附件复制一份
copyId = Util.null2String(ImageFileManager.copyImageFile(Util.getIntValue(copyId)));
if(Util.getIntValue(copyId, 0)>0)
transId.add(copyId);
}
setSql += (transId.size() == 0 ? "null" : ("'" + String.join(",", transId)) + "'");
} else if (fieldDbType.startsWith("text") || fieldDbType.startsWith("char") ||
fieldDbType.startsWith("varchar") || type.equals("161") || type.equals("162") || type.equals("257") || type.equals("256")) {
setSql += !"".equals(value) ? "'" + value + "'" : "null";
} else {
if (value.equals("")) {
setSql += "null";
} else {
setSql += value;
}
}
}
if (!"".equals(setSql)) {
setSql = setSql.substring(1);
sql += setSql + sqlWhere;
rs.executeUpdate(sql);
}
}
updateWorkInfo(id);
rs.executeUpdate("update hrmresource set " + DbFunctionUtil.getInsertUpdateSetSql(rst.getDBType(), user.getUID()) + " where id=" + id);
//保存自定义字段数据
insertCustData(log, id);
ResourceComInfo resourceComInfo = new ResourceComInfo();
try{
//登录信息签名
PasswordUtil.saveSign(""+id);
}catch (Exception e){
writeLog(e);
}
try{
String companystartdate = "";
String formsql = "select companystartdate from HrmResource where id = " + id;
System.out.println("requestId:"+requestId+":id:"+id+":formsql:"+formsql);
rs.executeQuery(formsql);
if(rs.next()){
companystartdate = Util.null2s(rs.getString("companystartdate"),"");
}
System.out.println("requestId:"+requestId+":id:"+id+":companystartdate:"+companystartdate);
if(companystartdate != null && companystartdate.length() > 0){
String changefirstdate = DateUtil.getFirstDayOfMonth(companystartdate);
String endlastdate = DateUtil.getCurrentDate();
String formInsertSql = "insert into kq_date_change_log(resourceid,changefromdate,changetodate,status) values(?,?,?,0) ";
boolean isok = rs.executeUpdate(formInsertSql, id,changefirstdate,endlastdate);
System.out.println("requestId:"+requestId+":id:"+id+":changefirstdate:"+changefirstdate+":endlastdate:"+endlastdate+":isok:"+isok);
}
}catch (Exception e){
writeLog(e);
}
}catch (Exception ex){
writeLog(ex);
throw ex;
}
}
private Object transValue(String key){
Object value = Util.null2String(rsdt.getString(key));
// Map<Integer, List> optionsMap = (key.indexOf("custField_") > -1 ? cusSelectItem : hrmSelectItem);
// try{
// if(fieldMap.containsKey(key)) {
// Map<String, Object> fieldConfig = fieldMap.get(key);
// String htmlType = Util.null2String(fieldConfig.get("HtmlType"));
// Integer fieldId = Util.getIntValue(Util.null2String(fieldConfig.get("id")));
// if (!"".equals(value.toString()) && htmlType.equals("5") && hrmSelectItem.containsKey(fieldId)) {
// List<Map> options = optionsMap.get(fieldId);
// value = options.get(Integer.parseInt(value.toString())).get("selectValue");
// }
// }
// }catch (Exception ex){
// writeLog(key, ex);
// }
return value;
}
private Object getValue(String key) throws Exception{
if(baseData.containsKey(key)){
Object value = baseData.get(key);
baseData.remove(key);
return value;
}else
return "";
}
private Object getCustValue(String key) throws Exception{
if(custData.containsKey(key)){
Object value = custData.get(key);
custData.remove(key);
return value;
}else
return "";
}
private void updateWorkInfo(String id){
SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-DD");
DecimalFormat df = new DecimalFormat("0.00");
String companyworkyear = "";
String workyear = "";
try {
String companystartdate = (String)getValue("companystartdate");
String workstartdate = (String)getValue("workstartdate");
Date today = Calendar.getInstance().getTime();
Date companyStartDate = null;
Date workStartDate = null;
Long to = 0L;
Long from = 0L;
if (!"".equals(companystartdate)) {
companyStartDate = sdf.parse(companystartdate);
to = today.getTime();
from = companyStartDate.getTime();
if(to > from){
companyworkyear = df.format((float)(to - from) / (24*3600*1000*365.0));
}
}
if(!"".equals(workstartdate)){
workStartDate = sdf.parse(workstartdate);
to = today.getTime();
from = workStartDate.getTime();
if(to > from){
workyear = df.format((float)(to - from) / (24*3600*1000*365.0));
}
}
List<String> lsParams = new ArrayList<>();
lsParams.add(companyworkyear.equals("") ? null : companyworkyear);
lsParams.add(workyear.equals("") ? null : workyear);
lsParams.add(id);
String sql = " update hrmresource set companyworkyear=?,workyear=? where id=?";
new RecordSet().executeUpdate(sql, lsParams);
HrmDateCheck hrmDateCheck = new HrmDateCheck();
hrmDateCheck.calWorkInfo(id);
}catch (Exception ex){
ex.printStackTrace();
}
}
private void insertCustData(SysMaintenanceLog log, String id) throws Exception{
editCustomDataE9Add(Util.getIntValue(id));
log.resetParameter();
log.setRelatedId(Util.getIntValue(id));
log.setRelatedName(new ResourceComInfo().getResourcename(id));
log.setOperateItem("29");
log.setOperateUserid(creater);
log.setClientAddress(clientIp);
log.setOperateType("1");
log.setOperateDesc("HrmResourceCustomerInfo_Insert");
log.setSysLogInfo();
}
/**
*
* @param dataId
*/
private void editCustomDataE9Add(int dataId) throws Exception {
String scope = "HrmCustomFieldByInfoType";
List<Integer> scopeList = new ArrayList<Integer>(Arrays.asList(-1, 1, 3));
/*RecordSet rs = new RecordSet();
List<Integer> scopeIds = new ArrayList<>();
for(Integer parentId : scopeList){
rs.executeQuery("select id from CUS_TREEFORM where scope = 'HrmCustomFieldByInfoType' and PARENTID = ? or id = ?", parentId, parentId);
while (rs.next()){
scopeIds.add(rs.getInt("id"));
}
}*/
for(Integer scopeId : scopeList){
addCustomDataE9Add(scope, scopeId, dataId);
}
}
/**
*
* @param dataId
*/
private void addCustomDataE9Add(String scope, int scopeId, int dataId) throws Exception {
RecordSet rs = new RecordSet();
CustomFieldManager cfm = new CustomFieldManager(scope, scopeId);
cfm.getCustomFields();
String sql = "insert into cus_fielddata";
String nameStr = "";
String valueStr = "";
String prefix = "custField_" + (scopeId < 0 ? "_" : "") + Math.abs(scopeId) + "_";
while (cfm.next()) {
nameStr += ",field" + cfm.getId();
String value = Util.null2String(getCustValue(prefix + cfm.getFieldDBName()));
if(cfm.getHtmlType().equals("6")) {
String fileid = Util.null2String(value);
List<String> transId = new ArrayList<>();
List<String> ids = Util.splitString2List(fileid, ",");
for(String fid : ids){
String copyId = getImageIdByDocid(fid);
//考虑到流程文档权限的问题,把附件复制一份
copyId = Util.null2String(ImageFileManager.copyImageFile(Util.getIntValue(copyId)));
if(Util.getIntValue(copyId, 0)>0)
transId.add(copyId);
}
valueStr += "," + (transId.size() == 0 ? "null" : "'" + String.join(",", transId) + "'");
} else if (cfm.getFieldDbType().startsWith("text") || cfm.getFieldDbType().startsWith("char") ||
cfm.getFieldDbType().startsWith("varchar")||cfm.getType()==161||cfm.getType()==162 || cfm.getType()==257 || cfm.getType()==256) {
valueStr += "," + (!"".equals(value) ? "'" + value + "'" : "null");
} else {
if (value.equals("")) {
valueStr += ",null";
} else {
valueStr += "," + value;
}
}
}
if (!nameStr.equals("")) {
nameStr = nameStr.substring(1);
valueStr = valueStr.substring(1);
sql += "(scope,scopeid,id," + nameStr + ") values('" + scope + "'," + scopeId + "," + dataId + "," + valueStr + ")";
RecordSet rsSel = new RecordSet();
rsSel.executeQuery("select id from cus_fielddata where scope=? and scopeid=? and id=?", scope, scopeId, dataId);
// rsSel.executeSql("select id from cus_fielddata where scope='" + scope + "' and scopeid=" + scopeId + " and id=" + dataId);
if (rsSel.next()) {//查询是否已存在数据
}else{
rs.executeSql(sql);
}
}
}
private void findFields() throws Exception{
baseData.clear();
custData.clear();
fieldMap.clear();
baseData.put("loginid", "");
baseData.put("password", "");
baseData.put("seclevel", "");
List<Integer> scopeList = new ArrayList<Integer>(Arrays.asList(-1, 1, 3));
RecordSet rs = new RecordSet();
for(Integer parentId : scopeList){
rs.executeQuery("select id from CUS_TREEFORM where scope = 'HrmCustomFieldByInfoType' and PARENTID = ? or id = ?", parentId, parentId);
while(rs.next()){
int scopeId = rs.getInt("id");
HrmFieldManager hfm = new HrmFieldManager("HrmCustomFieldByInfoType", scopeId);
hfm.getCustomFields();
while (hfm.next()) {
try {
String fieldName = hfm.getFieldname();
if (!hfm.isUse() || donotExportFields.contains(fieldName))
continue;
if(hfm.isBaseField(fieldName)){
baseData.put(fieldName, "");
}else{
fieldName = "custField_" + (scopeId < 0 ? "_" : "") + Math.abs(scopeId) + "_" + fieldName;
custData.put(fieldName, "");
}
fieldMap.put(fieldName, new HashMap());
fieldMap.get(fieldName).put("id", hfm.getFieldid());
fieldMap.get(fieldName).put("FieldDbType", hfm.getFieldDbType());
fieldMap.get(fieldName).put("Type", hfm.getType());
fieldMap.get(fieldName).put("HtmlType", hfm.getHtmlType());
} catch (Exception ex) {
writeLog(ex);
throw ex;
}
}
}
}
}
/**
*
* @param resourceimageid
* @return imageid
*/
private String getImageIdByDocid(String resourceimageid) {
String imageid = "0";
if(Util.getIntValue(Util.null2String(resourceimageid), 0)>0){
RecordSet rs1 = new RecordSet();
String imageSql = "select imagefileid from DocImageFile where docid=?";
rs1.executeQuery(imageSql, resourceimageid);
rs1.next();
imageid = StringUtil.vString(rs1.getString("imagefileid"),"0");
}
return imageid;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public String duplicateRemoval(String str,String userid) {
String[] ss = str.split(",");
List<String> list = new ArrayList<String>();
for (String s : ss) {
list.add(s.trim());
}
HashSet hs = new HashSet(list);
list.clear();
list.addAll(hs);
if(list.contains(userid))list.remove(userid);
str=list.toString().replace("[", "").replace("]", "").replace(" ", "");
return str ;
}
private String copyFile(String messagerurl){
try {
writeLog("messagerurl:" + messagerurl);
String filePath = "messager/usericon/" + UUID.randomUUID().toString().replace("-", "").toLowerCase() + ".jpg";
ImageFileManager imageFileManager = new ImageFileManager();
imageFileManager.getImageFileInfoById(Util.getIntValue(messagerurl));
InputStream inputStream = imageFileManager.getInputStream();
String filesize = imageFileManager.getFilesize();
FileOutputStream out = new FileOutputStream(new File(GCONST.getRootPath() + filePath));
byte[] buffer = new byte[Util.getIntValue(filesize)];
int len;
while ((len = inputStream.read(buffer)) > 0) {
out.write(buffer, 0, len);
}
out.close();
inputStream.close();
return "/" + filePath;
}catch (Exception ex){
writeLog(ex);
return "";
}
}
private void loadHrmSelectItem(){
try{
hrmSelectItem.clear();
RecordSet rs = new RecordSet();
rs.executeQuery("select fieldid, selectvalue, listorder from hrm_selectitem");
while(rs.next()){
int fieldId = rs.getInt("fieldid");
String selectValue = rs.getString("selectvalue");
String fieldOrder = Util.null2String(rs.getString("listorder"));
if("".equals(fieldOrder))
fieldOrder = selectValue;
Map<String, Object> data = new HashMap<>();
data.put("fieldId", fieldId);
data.put("selectValue", selectValue);
data.put("fieldOrder", fieldOrder);
if(!hrmSelectItem.containsKey(fieldId))
hrmSelectItem.put(fieldId, new ArrayList());
hrmSelectItem.get(fieldId).add(data);
}
for(Integer key : hrmSelectItem.keySet()){
hrmSelectItem.put(key, sortData(hrmSelectItem.get(key)));
}
}catch (Exception ex){
writeLog(ex);
}
}
private void loadCusSelectItem(){
try{
cusSelectItem.clear();
RecordSet rs = new RecordSet();
rs.executeQuery("select fieldid, selectvalue, fieldorder from cus_selectitem");
while(rs.next()){
int fieldId = rs.getInt("fieldid");
String selectValue = rs.getString("selectvalue");
String fieldOrder = Util.null2String(rs.getString("fieldorder"));
if("".equals(fieldOrder))
fieldOrder = selectValue;
Map<String, Object> data = new HashMap<>();
data.put("fieldId", fieldId);
data.put("selectValue", selectValue);
data.put("fieldOrder", fieldOrder);
if(!cusSelectItem.containsKey(fieldId))
cusSelectItem.put(fieldId, new ArrayList());
cusSelectItem.get(fieldId).add(data);
}
for(Integer key : cusSelectItem.keySet()){
cusSelectItem.put(key, sortData(cusSelectItem.get(key)));
}
}catch (Exception ex){
writeLog(ex);
}
}
private List sortData(List list){
Collections.sort(list, new Comparator<Map>() {
@Override
public int compare(Map o1, Map o2) {
int a = Integer.parseInt(o1.get("fieldOrder").toString());
int b = Integer.parseInt(o2.get("fieldOrder").toString());
return a - b;
}
});
return list;
}
private void setReqMessage(String context){
this.reqManager.setMessagecontent(context);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save