diff --git a/src/main/java/com/api/bokang/xiao/pyzl/controller/GetDocController.java b/src/main/java/com/api/bokang/xiao/pyzl/controller/GetDocController.java new file mode 100644 index 0000000..c36c29c --- /dev/null +++ b/src/main/java/com/api/bokang/xiao/pyzl/controller/GetDocController.java @@ -0,0 +1,48 @@ +package com.api.bokang.xiao.pyzl.controller; + +import aiyh.utils.Util; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import org.apache.log4j.Logger; +import weaver.conn.RecordSet; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; + +/** + * @ClassName GetDocController + * @Author 肖博亢 + * @Date 2023/6/19 12:32 + * @Description

+ **/ + +@Path("/xbk/pyzl") +public class GetDocController { + + private final Logger log = Util.getLogger(); + + @POST + @Path("/abideBy") + @Produces({"text/plain"}) + public String getAbideBy(@Context HttpServletRequest request, @Context HttpServletResponse response) { + String secId = Util.null2String(request.getParameter("secId")); + JSONArray data = new JSONArray(); + String sql = "select top(6) * from docdetail where (maincategory = 0 or maincategory is null) and (subcategory = 0 or subcategory is null) and seccategory = ? and ishistory = 0 and docstatus = 1 order by doccreatedate desc"; + RecordSet rs = new RecordSet(); + rs.executeQuery(sql, secId); + log.info("abideBy sql ==>"+sql+" secId ==>"+secId); + while(rs.next()) { + JSONObject dataJson = new JSONObject(); + dataJson.put("name", Util.null2String(rs.getString("docsubject"))); + dataJson.put("link", "/spa/document/index.jsp?id=" + Util.null2String(rs.getString("id"))); + dataJson.put("date", Util.null2String(rs.getString("doccreatedate"))); + data.add(dataJson); + } + + return data.toString(); + } +} diff --git a/src/main/java/com/api/bokang/xiao/zhenn/controller/BankController.java b/src/main/java/com/api/bokang/xiao/zhenn/controller/BankController.java index cbc3692..9a03898 100644 --- a/src/main/java/com/api/bokang/xiao/zhenn/controller/BankController.java +++ b/src/main/java/com/api/bokang/xiao/zhenn/controller/BankController.java @@ -96,7 +96,7 @@ public class BankController { String encodedFileName = URLEncoder.encode(fileName, "UTF-8"); return Response.ok(streamingOutput, MediaType.APPLICATION_OCTET_STREAM) // 指定编码方式为 UTF-8 - .header("Content-Disposition", "attachment; filename*=UTF-8''" + encodedFileName) + .header("Content-Disposition", "attachment;" + encodedFileName) .build(); }catch (Exception e){ log.error("exportExcel error ==> "+Util.getErrString(e)); diff --git a/src/main/java/com/api/bokang/xiao/zhenn/mapper/BankMapper.java b/src/main/java/com/api/bokang/xiao/zhenn/mapper/BankMapper.java index ef56c57..ab334d7 100644 --- a/src/main/java/com/api/bokang/xiao/zhenn/mapper/BankMapper.java +++ b/src/main/java/com/api/bokang/xiao/zhenn/mapper/BankMapper.java @@ -67,7 +67,7 @@ public interface BankMapper { * @return 付款信息列表 */ @Select("select id,txnamt amount,txnamt difAmount,txnamt outAmount,insid," + - " insid outFlowNo,txndate_time,actacn,tobank inCompany from uf_bank_trade_info " + + " insid outFlowNo,txndate_time,actacn,concat(toname,'-',actacn_receipt) inCompany from uf_bank_trade_info " + "where txndate_time BETWEEN #{beginDate} AND #{endDate} " + " and trncur = #{currencySpan}" + " and actacn = #{currentBankAccount}") @@ -79,7 +79,7 @@ public interface BankMapper { * @return 收款信息列表 */ @Select("select id,id payInfo,txnamt amount,txnamt difAmount,txnamt inAmount,insid," + - " insid inFlowNo,txndate_time,actacn,ibkname outCompany from uf_bank_trade_info " + + " insid inFlowNo,txndate_time,actacn,concat(acntname,'-',actacn) outCompany from uf_bank_trade_info " + "where txndate_time BETWEEN #{beginDate} AND #{endDate} " + " and trncur = #{currencySpan}" + " and actacn_receipt = #{currentBankAccount}") @@ -106,4 +106,31 @@ public interface BankMapper { " and IvFisPeriod = MONTH(#{beginDate})") double queryBankStatementBalance(Map param); + /** + *

查询流程付款信息

+ * @param param 查询参数 + * @return 付款信息列表 + */ + @Select("SELECT t.requestid requestId,t.$t{amountField} amount,t.$t{amountField} outAmount," + + " $t{inCompany} inCompany,wb.lastoperatedate outDate,$t{bankFlowField} bankFlow " + + "FROM $t{tableName} t " + + "INNER JOIN workflow_requestbase wb ON t.requestid = wb.requestid " + + "WHERE wb.currentnodetype = 3 " + + " AND wb.lastoperatedate BETWEEN #{beginDate} AND #{endDate} " + + " AND $t{currencyField} = #{currency}") + List> queryOaOtherList(Map param); + + /** + *

查询流程付款信息

+ * @param param 查询参数 + * @return 付款信息列表 + */ + @Select("SELECT t.requestid requestId,$t{amountField} amount,$t{amountField} outAmount," + + " $t{inCompany} inCompany,wb.lastoperatedate outDate,$t{bankFlowField} bankFlow " + + "FROM $t{tableName} t " + + "INNER JOIN $t{detailTable} d ON t.id = d.mainid " + + "INNER JOIN workflow_requestbase wb ON t.requestid = wb.requestid " + + "WHERE wb.currentnodetype = 3 " + + " AND wb.lastoperatedate BETWEEN #{beginDate} AND #{endDate} ") + List> queryOaOtherDetailList(Map param); } diff --git a/src/main/java/com/api/bokang/xiao/zhenn/service/BankService.java b/src/main/java/com/api/bokang/xiao/zhenn/service/BankService.java index e29fce9..ca20c93 100644 --- a/src/main/java/com/api/bokang/xiao/zhenn/service/BankService.java +++ b/src/main/java/com/api/bokang/xiao/zhenn/service/BankService.java @@ -2,23 +2,22 @@ package com.api.bokang.xiao.zhenn.service; import aiyh.utils.Util; import com.alibaba.excel.EasyExcel; -import com.alibaba.excel.ExcelWriter; -import com.alibaba.excel.support.ExcelTypeEnum; import com.alibaba.fastjson.JSON; import com.api.bokang.xiao.zhenn.mapper.BankMapper; import com.api.bokang.xiao.zhenn.util.GenerateClassUtil; +import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import weaver.bokang.xiao.common.CommonUtil; import weaver.bokang.xiao.common.mapper.WorkflowMapper; import weaver.hrm.User; -import java.io.File; import java.io.OutputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * @ClassName ContractService @@ -49,12 +48,28 @@ public class BankService { * bankAccountField:"银行账号字段", * queryTye:"1、付款账号固定;2、付款账号不固定" * }]:"付款参数条件", + * outOtherParam:[{ + * table:"流程表名", + * workflowId:"流程id", + * amountField:"金额字段名", + * bankAccountField:"银行账号字段", + * bankFlowField:"关联字段", + * detailId:"明细表ID" + * }], * inParam:[{ * table:"流程表名", * workflowId:"流程id", * amountField:"金额字段名", * bankAccountField:"银行账号字段", - * }]:"收款参数条件" + * }]:"收款参数条件", + * inOtherParam:[{ + * table:"流程表名", + * workflowId:"流程id", + * amountField:"金额字段名", + * bankAccountField:"银行账号字段", + * bankFlowField:"关联字段", + * detailId:"明细表ID" + * }] * } *

> outParam = (List>) param.get("outParam"); List> inParam = (List>) param.get("inParam"); + List> inOtherParam = (List>) param.get("inOtherParam"); + List> outOtherParam = (List>) param.get("outOtherParam"); //查询数据 List> oaOutList = outParam.stream() .flatMap(item -> { @@ -89,6 +106,30 @@ public class BankService { return tempOutList.stream(); }) .collect(Collectors.toList()); + List> oaOutOtherList = outOtherParam.stream().flatMap(item -> { + item.put("beginDate", Util.null2String(param.get("beginDate"))); + item.put("endDate", Util.null2String(param.get("endDate"))); + String detailId = Util.null2String(item.get("detailId")); + if(StringUtils.isNotBlank(detailId)){ + String table = Util.null2String(item.get("tableName")); + String detailTale = table + "_" + detailId; + item.put("detailTable",detailTale); + return bankMapper.queryOaOtherDetailList(item).stream(); + } + return bankMapper.queryOaOtherList(item).stream(); + }).collect(Collectors.toList()); + List> oaInOtherList = inOtherParam.stream().flatMap(item -> { + item.put("beginDate", Util.null2String(param.get("beginDate"))); + item.put("endDate", Util.null2String(param.get("endDate"))); + String detailId = Util.null2String(item.get("detailId")); + if(StringUtils.isNotBlank(detailId)){ + String table = Util.null2String(item.get("tableName")); + String detailTale = table + "_" + detailId; + item.put("detailTable",detailTale); + return bankMapper.queryOaOtherDetailList(item).stream(); + } + return bankMapper.queryOaOtherList(item).stream(); + }).collect(Collectors.toList()); List> oaInList = inParam.stream() .flatMap(item -> { item.put("currentBankAccount",bankAccount); @@ -101,13 +142,28 @@ public class BankService { return bankMapper.queryOaInBank(item).stream(); }) .collect(Collectors.toList()); - List> bankOutList = bankMapper.queryBankOutInfo(param); - List> bankInList = bankMapper.queryBankInInfo(param); + List> bankTempOutList = bankMapper.queryBankOutInfo(param); + List> bankTempInList = bankMapper.queryBankInInfo(param); + //将银行流水信息进行分组,有Insid为一组(走银企直联),无Insid(代收,划转)为一组 + Map>> bankOutMap = bankTempOutList.stream().collect(Collectors.partitioningBy(item -> StringUtils.isNotBlank(Util.null2String(item.get("insid"))))); + Map>> bankInMap = bankTempInList.stream().collect(Collectors.partitioningBy(item -> StringUtils.isNotBlank(Util.null2String(item.get("insid"))))); + List> bankOutList = bankOutMap.get(true); + List> bankInList = bankInMap.get(true); + //过滤出银行流水中的代收部分(即insid为空的部分) + List> bankOutOtherList = bankOutMap.get(false); + List> bankInOtherList = bankInMap.get(false); //计算有差异的集合 + List> bankOutOtherTable = CommonUtil.difference(bankOutOtherList, oaOutOtherList, map -> map.get("id")); + List> bankInOtherTable = CommonUtil.difference(bankInOtherList, oaInOtherList, map -> map.get("id")); List> oaOutTable = CommonUtil.difference(oaOutList, bankOutList, map -> map.get("insid")); - List> bankOutTable = CommonUtil.difference(bankOutList,oaOutList, map -> map.get("insid")); - List> bankInTable = CommonUtil.difference(bankInList,oaInList, map -> map.get("payInfo")); + List> bankOutTempTable = CommonUtil.difference(bankOutList,oaOutList, map -> map.get("insid")); + List> bankInTempTable = CommonUtil.difference(bankInList,oaInList, map -> map.get("payInfo")); List> oaInTable = new ArrayList<>(); + //合并代收和走银企的部分 + List> bankInTable = Stream.concat(bankInTempTable.stream(), bankInOtherTable.stream()) + .collect(Collectors.toList()); + List> bankOutTable = Stream.concat(bankOutTempTable.stream(), bankOutOtherTable.stream()) + .collect(Collectors.toList()); //银行信息 bankBaseInfo.put("bankName",currentBankSpan); bankBaseInfo.put("bankAccount",bankAccount); @@ -186,6 +242,7 @@ public class BankService { classMessage.put("className",className); Class aClass = GenerateClassUtil.generateClassByMap(classMessage); List objects = GenerateClassUtil.covertClassList(dataSource, aClass); + log.info("excel List detail ==>"+objects); log.info("excel List ==>"+objects.size()); EasyExcel.write(outputStream, aClass).sheet("Sheet1").doWrite(objects); } diff --git a/src/main/java/com/api/bokang/xiao/zhenn/util/GenerateClassUtil.java b/src/main/java/com/api/bokang/xiao/zhenn/util/GenerateClassUtil.java index 6fc9271..fa4f2f7 100644 --- a/src/main/java/com/api/bokang/xiao/zhenn/util/GenerateClassUtil.java +++ b/src/main/java/com/api/bokang/xiao/zhenn/util/GenerateClassUtil.java @@ -88,6 +88,18 @@ public class GenerateClassUtil { annotationsAttribute.addAnnotation(annotation); field.getFieldInfo().addAttribute(annotationsAttribute); } + + // 添加 toString 方法 + CtMethod toStringMethod = CtNewMethod.make( + "public String toString() { return \"" + className + " {\" + " + + columns.stream() + .map(c -> "\""+ c.get("dataIndex") + ": \" + get" + + StringUtils.capitalize(c.get("dataIndex")) + "()") + .collect(Collectors.joining(" + \", \" + ")) + + " + \"}\"; }", + cc); + cc.addMethod(toStringMethod); + Class aClass = cc.toClass(); CLASS_MAP.put(className,aClass); return aClass; diff --git a/src/main/java/com/api/doc/search/service/DocSearchService.java b/src/main/java/com/api/doc/search/service/DocSearchService.java new file mode 100644 index 0000000..eebb829 --- /dev/null +++ b/src/main/java/com/api/doc/search/service/DocSearchService.java @@ -0,0 +1,2591 @@ +package com.api.doc.search.service; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.api.browser.bean.BrowserBean; +import com.api.browser.util.BoolAttr; +import com.cloudstore.dev.api.dao.Dao_TableSqlServer; +import com.engine.doc.util.DocApplySettingUtil; +import com.engine.doc.util.DocEncryptUtil; +import weaver.conn.RecordSet; +import weaver.docs.DocShare; +import weaver.docs.category.SecCategoryCustomSearchComInfo; +import weaver.docs.category.SecCategoryDocPropertiesComInfo; +import weaver.docs.docSubscribe.DocSubscribe; +import weaver.docs.docs.CustomFieldManager; +import weaver.docs.docs.DocComInfo; +import weaver.docs.docs.DocManager; +import weaver.docs.docs.DocViewer; +import weaver.docs.search.DocSearchComInfo; +import weaver.docs.tools.UserDefaultManager; +import weaver.fullsearch.util.SearchBrowserUtils; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.general.TimeUtil; +import weaver.hrm.User; +import weaver.share.ShareManager; +import weaver.splitepage.transform.SptmForDoc; +import weaver.system.SysRemindWorkflow; +import weaver.systeminfo.SystemEnv; +import weaver.systeminfo.setting.HrmUserSettingComInfo; + +import com.alibaba.fastjson.JSONArray; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.service.impl.DocFullSearchUtil; +import com.api.doc.search.bean.SecTreeNode; +import com.api.doc.search.util.ConditionUtil; +import com.api.doc.search.util.DocCondition; +import com.api.doc.search.util.DocSptm; +import com.api.doc.search.util.DocTableType; +import com.api.doc.search.util.FullSearchUtil; +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.util.ParamUtil; +import com.engine.doc.util.CheckPermission; +import com.engine.hrm.biz.HrmClassifiedProtectionBiz; + +/** + * 列表 tableString + * @author wangqs + * */ +public class DocSearchService { + + public static boolean thumbnail = false; + //文档操作:批准,拒绝,收回,请求 + public static final String SUBSCRIBE_OPERATE_APRROVE="approve"; + public static final String SUBSCRIBE_OPERATE_REJECT="reject"; + public static final String SUBSCRIBE_OPERATE_GETBACK="getback"; + public static final String SUBSCRIBE_OPERATE_ADD="add"; + + private boolean isChatcooper = false; + + public String getChatcooper(){ + String chatcooperFlag = Util.null2String(new BaseBean().getPropValue("docpreview","chatcooperFlag")); + return chatcooperFlag.isEmpty() ? "5Y2P5ZCM5paH5qGj" : chatcooperFlag; + } + + + /** + * 查询文档列表 + * @author wangqs + * @throws Exception + * */ + public Map getDocList(String detailWhere,String shareTable,int seccategory,DocTableType docTableType,User user,Map otherParams) throws Exception{ + Map apidatas = new HashMap(); + + otherParams = otherParams == null ? new HashMap() : otherParams; + /** + * 前端组件要求:col中的column必须唯一 + * */ + String currentdate = TimeUtil.getCurrentDateString(); + String sqlFrom = "from DocDetail t1 "; + if(shareTable != null && !shareTable.isEmpty()){ + sqlFrom += ",(" + shareTable + ") t2"; + } + //String sqlFrom =shareTable; + String browser = ""; + String backFields = "t1.id,t1.id docstatus_id,t1.seccategory,t1.docvestin,t1.doclastmoddate,t1.doclastmodtime,t1.docsubject,t1.docextendname,t1.doccreaterid,t1.secretLevel,t1.usertype"; + backFields += ",t1.ownerid,t1.docstatus,t1.doccreatedate,t1.doccreatetime,t1.accessorycount,t1.replaydoccount,t1.sumDownload,t1.sumReadCount,t1.sumMark,t1.docpubdate,t1.docpubtime,t1.docapprovedate,t1.docapprovetime"; + String outFields = ""; + String tabletype = ""; + String orderBy = "doclastmoddate,doclastmodtime,id"; + String order = "desc"; + String colString = ""; + String operateString = ""; + + RecordSet rs = new RecordSet(); + String dbtype = rs.getDBType(); + + String isnull = "isnull"; + if("oracle".equals(dbtype)){ //isoracle + isnull = "nvl"; + }else if("mysql".equals(dbtype)){ + isnull = "ifnull"; + } + + if(otherParams.get("__custormOrderBy") != null){ + orderBy = otherParams.get("__custormOrderBy"); + order = ""; + } + + /**查阅文档列表 和 门户more页面 先根据置顶排序*/ + if(docTableType == DocTableType.SEARCH_DOC_TABLE || docTableType == DocTableType.MY_DOC_TABLE || docTableType == DocTableType.NO_READ_DOC){ + String topOrder = ""; + if(otherParams.get("__custormOrderBy") != null){ + //门户的more页面,字段传过来带有 排序方式,因此给置顶也加上降序 + topOrder = " desc"; + } + + if ("oracle".equals(dbtype)) { + orderBy = "(case when t1.istop is null then 0 else t1.istop end)"+topOrder+",(case when t1.topdate is null or t1.istop is null then '1900-01-01' else t1.topdate end)"+topOrder+",(case when t1.toptime is null or t1.istop is null then '00:00:00' else t1.toptime end)"+topOrder+"," + orderBy; + }else if ("mysql".equals(dbtype)) { + topOrder = " desc"; //mysql数据库排序字段为多个时,需要显示的设置排序方式,否则会按照默认的升序 asc + orderBy = "istop"+topOrder+",topdate"+topOrder+",toptime"+topOrder+"," + orderBy; + } else { + orderBy = "istop"+topOrder+",topdate"+topOrder+",toptime"+topOrder+"," + orderBy; + } + } + + isChatcooper = getChatcooper().equals(otherParams.get("tabTitle")); + + + String belongtoshow = ""; + String belongtoids = ""; + String account_type = ""; + String userInfoForotherpara = ""; + String popedomOtherpara = ""; + String popedomOtherpara2 = ""; + int languageid = 7; + if(user != null){ + languageid = user.getLanguage(); + HrmUserSettingComInfo userSetting=new HrmUserSettingComInfo(); + belongtoshow = userSetting.getBelongtoshowByUserId(user.getUID()+""); + belongtoids = user.getBelongtoids(); + account_type = user.getAccount_type(); + userInfoForotherpara =user.getLogintype() + "+" + user.getUID(); + popedomOtherpara = user.getLogintype() + "_" + user.getUID() + "_" + user.getSeclevel() + "_" + user.getType() + "_" + user.getUserDepartment() +"_"+ user.getUserSubCompany1(); + popedomOtherpara2 = "column:seccategory+column:docstatus+column:doccreaterid+column:ownerid+column:sharelevel+column:id"; + }else{ + languageid = DocNewsService.getOutDocLanguage(); + } + + Map colMap = new HashMap(); + List keys = new ArrayList(); // 保证 col顺序 + + boolean secretFlag = CheckPermission.isOpenSecret(); + + if(docTableType == DocTableType.MY_DOC_TABLE){ + //我的文档 + tabletype = "checkbox"; + backFields += ",t1.id replaydoccount_id,t2.sharelevel"; + backFields += ",t1.doccode,t1.docedition,t1.docdepartmentid,t1.id docedition_id,t1.invalidationdate,t1.docinvaltime,t1.keyword"; + + outFields = isnull + "((select sum(readcount) from docReadTag where userType ="+user.getLogintype()+" and docid=r.id and userid="+user.getUID()+"),0) as readCount"; + if(belongtoshow.equals("1")&&account_type.equals("0")&&!belongtoids.equals("")){ + belongtoids += ","+user.getUID(); + outFields = isnull + "((select sum(readcount) from docReadTag where userType ="+user.getLogintype()+" and docid=r.id and userid in("+belongtoids+") ),0) as readCount"; + } + colMap.put("docextendname",""); + keys.add("docextendname"); + colMap.put("id",""); + keys.add("id"); + if(secretFlag){ + colMap.put("secretLevel",""); + keys.add("secretLevel"); + } + colMap.put("ownerid",""); + keys.add("ownerid"); + colMap.put("doccreatedate",""); + keys.add("doccreatedate"); + colMap.put("doclastmoddate",""); + keys.add("doclastmoddate"); + colMap.put("docstatus",""); + keys.add("docstatus"); + colMap.put("accessorycount",""); + keys.add("accessorycount"); + colMap.put("doccreaterid",""); + keys.add("doccreaterid"); + //文档编号 OK + colMap.put("doccode",""); + keys.add("doccode"); + //文档版本OK + colMap.put("docedition",""); + keys.add("docedition"); + //部门 OK + colMap.put("docdepartmentid",""); + keys.add("docdepartmentid"); + //发布日期 OK + colMap.put("docpubdate",""); + keys.add("docpubdate"); + //审批日期 OK + colMap.put("docapprovedate",""); + keys.add("docapprovedate"); + //失效日期 OK + colMap.put("invalidationdate",""); + keys.add("invalidationdate"); + //关键字 + colMap.put("keyword",""); + keys.add("keyword"); + + }else if(docTableType == DocTableType.SEARCH_DOC_TABLE || docTableType == DocTableType.CATEGORY_DOC_TABLE || docTableType == DocTableType.NEWEST_DOC || docTableType == DocTableType.NO_READ_DOC){ + //查询文档、文档目录、最新文档(未读文档) + tabletype = "checkbox"; + backFields += ",t1.id replaydoccount_id,t2.sharelevel"; + backFields += ",t1.doccode,t1.docedition,t1.docdepartmentid,t1.id docedition_id,t1.invalidationdate,t1.docinvaltime,t1.keyword"; + //detailWhere +=" and (t1.scheduledreleasedate is null or (t1.scheduledreleasedate is not null and t1.scheduledreleasedate <='"+currentdate+"')) "; + outFields = isnull + "((select sum(readcount) from docReadTag where userType ="+user.getLogintype()+" and docid=r.id and userid="+user.getUID()+"),0) as readCount"; + if(belongtoshow.equals("1")&&account_type.equals("0")&&!belongtoids.equals("")){ + belongtoids += ","+user.getUID(); + outFields = isnull + "((select sum(readcount) from docReadTag where userType ="+user.getLogintype()+" and docid=r.id and userid in("+belongtoids+") ),0) as readCount"; + } + String getMost = Util.null2String(otherParams.get("getMost")); +// String showReply = "reply".equals(getMost) ? BoolAttr.TRUE.getStringVal(): BoolAttr.FALSE.getStringVal(); + colMap.put("docextendname",""); + keys.add("docextendname"); + if(isChatcooper){ + colMap.put("id",""); + }else{ + colMap.put("id",""); + } + keys.add("id"); + if(secretFlag){ + colMap.put("secretLevel",""); + keys.add("secretLevel"); + } + colMap.put("ownerid",""); + keys.add("ownerid"); + colMap.put("doclastmoddate",""); + keys.add("doclastmoddate"); + colMap.put("seccategory",""); + keys.add("seccategory"); + colMap.put("accessorycount",""); + keys.add("accessorycount"); + colMap.put("docstatus",""); + keys.add("docstatus"); + colMap.put("doccreatedate",""); + keys.add("doccreatedate"); +// colMap.put("replaydoccount",""); +// keys.add("replaydoccount"); + colMap.put("doccreaterid",""); + keys.add("doccreaterid"); + //文档编号 OK + colMap.put("doccode",""); + keys.add("doccode"); + //文档版本OK + colMap.put("docedition",""); + keys.add("docedition"); + //部门 OK + colMap.put("docdepartmentid",""); + keys.add("docdepartmentid"); + //发布日期 OK + colMap.put("docpubdate",""); + keys.add("docpubdate"); + //审批日期 OK + colMap.put("docapprovedate",""); + keys.add("docapprovedate"); + //失效日期 OK + colMap.put("invalidationdate",""); + keys.add("invalidationdate"); + //关键字 + colMap.put("keyword",""); + keys.add("keyword"); + if("reply".equals(getMost)){ + colMap.put("replaydoccount", getCol("replaydoccount",user,false,true)); + keys.add("replaydoccount"); + orderBy = "replaydoccount"; + }else if("read".equals(getMost)){ + colMap.put("sumReadcount", getCol("sumReadcount",user,false,true)); + keys.add("sumReadcount"); + orderBy = "sumReadcount"; + }else if("download".equals(getMost)){ + colMap.put("sumDownload", getCol("sumDownload",user,false,true)); + keys.add("sumDownload"); + orderBy = "sumDownload"; + }else if("score".equals(getMost)){ + colMap.put("sumMark", getCol("sumMark",user,false,true)); + keys.add("sumMark"); + orderBy = "sumMark"; + }else if("chatcooper".equals(getMost)){ + detailWhere += " and t1.doctype=2"; + } + + }else if(docTableType == DocTableType.DOC_RANK){ + //知识排名 + tabletype = "checkbox"; + backFields += ",t2.sharelevel"; + + outFields = isnull + "((select sum(readcount) from docReadTag where userType ="+user.getLogintype()+" and docid=r.id and userid="+user.getUID()+"),0) as readCount"; + if(belongtoshow.equals("1")&&account_type.equals("0")&&!belongtoids.equals("")){ + belongtoids += ","+user.getUID(); + outFields = isnull + "((select sum(readcount) from docReadTag where userType ="+user.getLogintype()+" and docid=r.id and userid in("+belongtoids+") ),0) as readCount"; + } + colMap.put("docextendname",""); + keys.add("docextendname"); + colMap.put("id",""); + keys.add("id"); + if(secretFlag){ + colMap.put("secretLevel",""); + keys.add("secretLevel"); + } + colMap.put("ownerid",""); + keys.add("ownerid"); + colMap.put("doccreatedate",""); + keys.add("doccreatedate"); + colMap.put("doclastmoddate",""); + keys.add("doclastmoddate"); + colMap.put("seccategory",""); + keys.add("seccategory"); + + if(otherParams == null || ("" + ConditionUtil.TAB_REPLY_RANK).equals(otherParams.get(ConditionUtil.TAB_REQ_NAME))){ + orderBy = "replaydoccount"; + colMap.put("replaydoccount",""); + keys.add("replaydoccount"); + }else if(("" + ConditionUtil.TAB_READ_RANK).equals(otherParams.get(ConditionUtil.TAB_REQ_NAME))){ + orderBy = "sumReadCount"; + colMap.put("sumReadCount",""); + keys.add("sumReadCount"); + }else if(("" + ConditionUtil.TAB_DOWNLOAD_RANK).equals(otherParams.get(ConditionUtil.TAB_REQ_NAME))){ + orderBy = "sumDownloadCount"; + + backFields += "," + isnull + "((select count(*) from downloadLog where docid=t1.id),0) as sumDownloadCount"; + + colMap.put("sumDownloadCount",""); + keys.add("sumDownloadCount"); + }else if(("" + ConditionUtil.TAB_SCORE_RANK).equals(otherParams.get(ConditionUtil.TAB_REQ_NAME))){ + orderBy = "sumMark"; + colMap.put("sumMark",""); + keys.add("sumMark"); + } + }else if(docTableType == DocTableType.DOC_SUBSCRIPTION_SUBSCRIBE){ + ShareManager shareManager=new ShareManager(); + DocSearchComInfo docSearchComInfo=new DocSearchComInfo(); + String whereclause = " where " + docSearchComInfo.FormatSQLSearch(languageid) ; + //分页控制 + UserDefaultManager userDefaultManager=new UserDefaultManager(); + //文档订阅(可订阅内容) + tabletype = "checkbox"; + String backfields ="t1.id, t1.docsubject,t1.doccreaterid,t1.doccreatedate,t1.doccreatetime,t1.doclastmoddate,t1.doclastmodtime,t1.replaydoccount,t1.docpublishtype,t1.ownerId,t1.secretLevel,t1.ownertype,t1.docstatus,t1.docextendname"; + sqlFrom = " from docdetail t1 left join "+shareManager.getShareDetailTableByUser("doc",user)+" t2 on t1.id=t2.sourceid "; + + operateString= ""; + operateString+=" "; + operateString+=" "; + operateString+=""; + + detailWhere = whereclause+" and t1.orderable = '1' and t2.sourceid is null and not exists(select 1 from docsubscribe where docid=t1.id and state in('1','2') and hrmId="+user.getUID()+")"+detailWhere.substring(19,detailWhere.length()); + + String tableString =" "+ + " "+ + " "+ + operateString+ + " "+ + " "+ + " "+ +// " "+ + (secretFlag ? ("") : "") + +// " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "+ + "
"; + + String sessionkey = DocTableType.DOC_SUBSCRIPTION_SUBSCRIBE.getPageUid() + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + //apidatas.put("tableString", tableString); + apidatas.put("sessionkey", sessionkey); + return apidatas; + + }else if(docTableType == DocTableType.DOC_SUBSCRIPTION_HISTORY){ + //文档订阅(订阅历史) + tabletype = "none"; + orderBy = "ds.subscribedate"; + + sqlFrom += ",docsubscribe ds"; + detailWhere ="where "+detailWhere +" and t1.id=ds.docid and ds.hrmId = " + user.getUID(); + + backFields ="ds.id,ds.docid,ds.docid as version_docid,ds.subscribedate,ds.approvedate,ds.state,ds.ownerid,ds.othersubscribe,ds.subscribedesc,ds.ownerType,t1.secretLevel"; + colMap.put("docid",""); +// colMap.put("docid",""); + keys.add("docid"); + if(secretFlag){ + colMap.put("secretLevel",""); + keys.add("secretLevel"); + } + colMap.put("version_docid",""); + keys.add("version_docid"); + colMap.put("subscribedate",""); + keys.add("subscribedate"); + colMap.put("approvedate",""); + keys.add("approvedate"); + colMap.put("state",""); + keys.add("state"); + colMap.put("ownerid",""); + keys.add("ownerid"); +// colMap.put("othersubscribe",""); +// keys.add("othersubscribe"); + colMap.put("subscribedesc",""); + keys.add("subscribedesc"); + + }else if(docTableType == DocTableType.DOC_SUBSCRIPTION_APPROVE){ + //文档订阅(订阅批准) + tabletype = "checkbox"; + orderBy = "ds.subscribedate"; + + sqlFrom += ",docsubscribe ds"; + backFields = "ds.id,ds.docid,ds.subscribedate,ds.approvedate,ds.searchcase,ds.othersubscribe,ds.subscribedesc,ds.hrmid, ds.subscribetype,t1.secretLevel"; + + detailWhere ="where "+detailWhere+ " and ds.docId = t1.id and ds.ownertype="+user.getLogintype()+" and ds.ownerId ="+user.getUID()+" and ds.state=1 "; +// colMap.put("id",""); +// keys.add("id"); +// colMap.put("docid",""); + colMap.put("docid",""); + keys.add("docid"); + if(secretFlag){ + colMap.put("secretLevel",""); + keys.add("secretLevel"); + } + colMap.put("subscribedate",""); + keys.add("subscribedate"); +// colMap.put("searchcase",""); +// keys.add("searchcase"); + colMap.put("hrmid",""); + keys.add("hrmid"); + colMap.put("id",""); + keys.add("id"); + colMap.put("subscribedesc",""); + keys.add("subscribedesc"); + + operateString= ""; + operateString+=" "; + operateString+=" "; + operateString+=" "; + operateString+=""; + }else if(docTableType == DocTableType.DOC_SUBSCRIPTION_BACK){ + //文档订阅(订阅收回) + tabletype = "checkbox"; + orderBy = "ds.subscribedate"; + + sqlFrom += ",docsubscribe ds"; + backFields ="ds.id,ds.docid,ds.subscribedate,ds.approvedate,ds.searchcase,ds.othersubscribe,ds.subscribedesc,ds.hrmid, ds.subscribetype,t1.id bid,t1.secretLevel"; + detailWhere ="where "+detailWhere+ " and ds.ownertype="+user.getLogintype()+" and ds.ownerId ="+user.getUID()+" and ds.state=2 and ds.docId = t1.id "; +// colMap.put("id",""); +// keys.add("id"); +// colMap.put("docid",""); + colMap.put("docid",""); + keys.add("docid"); + if(secretFlag){ + colMap.put("secretLevel",""); + keys.add("secretLevel"); + } + colMap.put("approvedate",""); + keys.add("approvedate"); + colMap.put("hrmid",""); + keys.add("hrmid"); + colMap.put("subscribedesc",""); + keys.add("subscribedesc"); +// colMap.put("searchcase",""); +// keys.add("searchcase"); + colMap.put("othersubscribe",""); + keys.add("othersubscribe"); + + operateString= ""; + operateString+=" "; + operateString+=" "; + operateString+=""; + + }if (docTableType == DocTableType.DOC_COPYMOVE || docTableType == DocTableType.DOC_BATCHSHARE) { + //移动复制、批量共享 + + tabletype = "checkbox"; + backFields += ",t1.id replaydoccount_id"; + + outFields = isnull + "((select sum(readcount) from docReadTag where userType ="+user.getLogintype()+" and docid=r.id and userid="+user.getUID()+"),0) as readCount"; + if(belongtoshow.equals("1")&&account_type.equals("0")&&!belongtoids.equals("")){ + belongtoids += ","+user.getUID(); + outFields = isnull + "((select sum(readcount) from docReadTag where userType ="+user.getLogintype()+" and docid=r.id and userid in("+belongtoids+") ),0) as readCount"; + } + colMap.put("docextendname",""); + keys.add("docextendname"); + colMap.put("id",""); + keys.add("id"); + if(secretFlag){ + colMap.put("secretLevel",""); + keys.add("secretLevel"); + } + colMap.put("ownerid",""); + keys.add("ownerid"); + colMap.put("doccreatedate",""); + keys.add("doccreatedate"); + colMap.put("doclastmoddate",""); + keys.add("doclastmoddate"); + colMap.put("docstatus",""); + keys.add("docstatus"); + colMap.put("accessorycount",""); + keys.add("accessorycount"); + + }else if(docTableType == DocTableType.DOC_OUT_TABLE){ //登录前门户more页面 + //detailWhere +=" and (t1.scheduledreleasedate is null or (t1.scheduledreleasedate is not null and t1.scheduledreleasedate <='"+currentdate+"')) "; + tabletype = "none"; + colMap.put("docextendname",""); + keys.add("docextendname"); + colMap.put("id",""); + keys.add("id"); + if(secretFlag){ + colMap.put("secretLevel",""); + keys.add("secretLevel"); + } + colMap.put("ownerid",""); + keys.add("ownerid"); + colMap.put("doccreatedate",""); + keys.add("doccreatedate"); + colMap.put("doclastmoddate",""); + keys.add("doclastmoddate"); + colMap.put("docstatus",""); + keys.add("docstatus"); + //colMap.put("accessorycount",""); + //keys.add("accessorycount"); + colMap.put("doccreaterid",""); + keys.add("doccreaterid"); + } + + /** + * 根据权限判断,有 编辑、删除、分享、显示日志 操作的table + * */ + if(docTableType == DocTableType.MY_DOC_TABLE || + docTableType == DocTableType.SEARCH_DOC_TABLE || + docTableType == DocTableType.CATEGORY_DOC_TABLE || + docTableType == DocTableType.NEWEST_DOC || + docTableType == DocTableType.NO_READ_DOC || + docTableType == DocTableType.DOC_RANK){ + operateString = ""; + operateString += " "; + operateString += " "; + operateString += " "; + operateString += " "; + operateString += " "; + operateString += ""; + } + + /** + * 有缩略图的table + */ + if(docTableType == DocTableType.MY_DOC_TABLE || + docTableType == DocTableType.SEARCH_DOC_TABLE || + docTableType == DocTableType.CATEGORY_DOC_TABLE || + docTableType == DocTableType.NEWEST_DOC || + docTableType == DocTableType.NO_READ_DOC + ){ + browser = ""; + + //图标类型 + if(colMap.get("docextendname") != null){ + String col = colMap.get("docextendname").trim(); + col = col.endsWith("/>") ? col.substring(0,col.length() - 2) : col; + col = col.endsWith(">") ? col.substring(0,col.length() - 7) : col; + col += " thumbnail=\"1\" t_type=\"img\" t_column=\"docextendname\" t_transmethod=\"com.api.doc.search.util.DocSptm.getDocThumbnail\"/>"; + colMap.put("docextendname",col); + }else{ + String col = ""; + colMap.put("docextendname",col); + keys.add("docextendname"); + } + + //标题 + if(colMap.get("id") != null){ + String col = colMap.get("id").trim(); + col = col.endsWith("/>") ? col.substring(0,col.length() - 2) : col; + col = col.endsWith(">") ? col.substring(0,col.length() - 7) : col; + col += " thumbnail=\"1\" t_type=\"title\" t_column=\"id\" t_transmethod=\"com.api.doc.search.util.DocSptm.getDocName\"/>"; + colMap.put("id",col); + }else{ + String col = ""; + colMap.put("id",col); + keys.add("id"); + } + + int showorder = 1; + + //密级 + if(colMap.get("secretLevel") != null){ + String col = colMap.get("secretLevel").trim(); + col = col.endsWith("/>") ? col.substring(0,col.length() - 2) : col; + col = col.endsWith(">") ? col.substring(0,col.length() - 7) : col; + col += " thumbnail=\"1\" t_showorder=\"" + showorder + "\" t_type=\"subtitle\" t_text=\""+SystemEnv.getHtmlLabelName(500520,languageid)+"\" t_column=\"secretLevel\" t_transmethod=\"com.api.doc.search.util.DocSptm.getSecretLevel\" t_otherpara=\""+languageid+"\"/>"; + colMap.put("secretLevel",col); + }else{ + String col = ""; + colMap.put("secretLevel",col); + keys.add("secretLevel"); + } + showorder++; + + //目录 + if(colMap.get("seccategory") != null){ + String col = colMap.get("seccategory").trim(); + col = col.endsWith("/>") ? col.substring(0,col.length() - 2) : col; + col = col.endsWith(">") ? col.substring(0,col.length() - 7) : col; + col += " thumbnail=\"1\" t_showorder=\"" + showorder + "\" t_type=\"subtitle\" t_text=\""+SystemEnv.getHtmlLabelName(92,languageid)+"\" t_column=\"seccategory\" t_transmethod=\"weaver.splitepage.transform.SptmForDoc.getAllDirName\" t_otherpara=\"column:docvestin+"+user.getUID()+"\"/>"; + colMap.put("seccategory",col); + }else{ + String col = ""; + colMap.put("seccategory",col); + keys.add("seccategory"); + } + showorder++; + + //所有者 + if(colMap.get("ownerid") != null){ + String col = colMap.get("ownerid").trim(); + col = col.endsWith("/>") ? col.substring(0,col.length() - 2) : col; + col = col.endsWith(">") ? col.substring(0,col.length() - 7) : col; + col += " thumbnail=\"1\" t_showorder=\"" + showorder + "\" t_type=\"subtitle\" t_text=\""+SystemEnv.getHtmlLabelName(79,languageid)+"\" t_column=\"ownerid\" t_transmethod=\"weaver.splitepage.transform.SptmForDoc.getName\" t_otherpara=\"column:usertype\"/>"; + colMap.put("ownerid",col); + }else{ + String col = ""; + colMap.put("ownerid",col); + keys.add("ownerid"); + } + showorder++; + + + //修改日期 + if(colMap.get("doclastmoddate") != null){ + String col = colMap.get("doclastmoddate").trim(); + col = col.endsWith("/>") ? col.substring(0,col.length() - 2) : col; + col = col.endsWith(">") ? col.substring(0,col.length() - 7) : col; + col += " thumbnail=\"1\" t_showorder=\"" + showorder + "\" t_type=\"subtitle\" t_text=\""+SystemEnv.getHtmlLabelName(723,languageid)+"\" t_column=\"doclastmoddate\" t_transmethod=\"com.engine.doc.util.TimeZoneUtil.getYmdLocaleOnlyDate\" t_otherpara=\"column:doclastmodtime\" />"; + colMap.put("doclastmoddate",col); + }else{ + String col = ""; + colMap.put("doclastmoddate",col); + keys.add("doclastmoddate"); + } + showorder++; + + //文档状态 + if(colMap.get("docstatus") != null){ + String col = colMap.get("docstatus").trim(); + col = col.endsWith("/>") ? col.substring(0,col.length() - 2) : col; + col = col.endsWith(">") ? col.substring(0,col.length() - 7) : col; + col += " thumbnail=\"1\" t_showorder=\"" + showorder + "\" t_type=\"subtitle\" t_text=\""+SystemEnv.getHtmlLabelName(602,languageid)+"\" t_column=\"docstatus_id\" t_transmethod=\"weaver.splitepage.transform.SptmForDoc.getDocStatus3\" t_otherpara=\""+languageid+"+column:docstatus+column:seccategory\"/>"; + colMap.put("docstatus",col); + }else{ + String col = ""; + colMap.put("docstatus",col); + keys.add("docstatus"); + } + + + + showorder = 1; + //回复数 + if(colMap.get("replaydoccount") != null){ + String col = colMap.get("replaydoccount").trim(); + col = col.endsWith("/>") ? col.substring(0,col.length() - 2) : col; + col = col.endsWith(">") ? col.substring(0,col.length() - 7) : col; + col += " thumbnail=\"1\" t_showorder=\"" + showorder + "\" t_icon=\"icon-document-reply\" t_type=\"foot\" t_text=\""+SystemEnv.getHtmlLabelName(18470,languageid)+"\" t_column=\"replaydoccount_id\" t_transmethod=\"weaver.splitepage.transform.SptmForDoc.getAllEditionReplaydocCount\" t_otherpara=\"column:replaydoccount\"/>"; + colMap.put("replaydoccount",col); + }else{ + String col = ""; + colMap.put("replaydoccount",col); + keys.add("replaydoccount"); + } + showorder++; + + //附件数 + if(colMap.get("accessorycount") != null){ + String col = colMap.get("accessorycount").trim(); + col = col.endsWith("/>") ? col.substring(0,col.length() - 2) : col; + col = col.endsWith(">") ? col.substring(0,col.length() - 7) : col; + col += " thumbnail=\"1\" t_showorder=\"" + showorder + "\" t_icon=\"icon-document-attachment\" t_type=\"foot\" t_text=\""+SystemEnv.getHtmlLabelName(2002,languageid)+"\" t_column=\"accessorycount\" />"; + colMap.put("accessorycount",col); + }else{ + String col = ""; + colMap.put("accessorycount",col); + keys.add("accessorycount"); + } + showorder++; + } + + for(String key : keys){ + colString += colMap.get(key); + } + + boolean useCustomSearch = false; + if(seccategory > 0){ + useCustomSearch = isUseCustomSearch(seccategory); + } + if(useCustomSearch){ + Map descMap = new HashMap(); + rs.executeQuery("select * from docseccategorydocproperty where secCategoryId = ?",seccategory); + while(rs.next()){ + String custonType = Util.null2String(rs.getString("type")); + String custonDesc = Util.null2String(rs.getString("customName")); + if(!"".equals(custonDesc)){ + descMap.put(custonType,custonDesc); + } + + } + + colString = ""; + backFields=getFilterBackFields(backFields,"t1.accessorycount"); + colString+=""; + //new BaseBean().writeLog("DocSearchService accessorycount:"+colString); + //backFields = ""; + sqlFrom += ",(select ljt1.id as docid,ljt2.* from DocDetail ljt1 LEFT JOIN cus_fielddata ljt2 ON ljt1.id=ljt2.id and ljt2.scope='DocCustomFieldBySecCategory' and ljt2.scopeid="+seccategory+") tcm"; + detailWhere += " and t1.id = tcm.docid "; + CustomFieldManager cfm = new CustomFieldManager("DocCustomFieldBySecCategory",seccategory); + SecCategoryCustomSearchComInfo sustomSearch = new SecCategoryCustomSearchComInfo(); + SecCategoryDocPropertiesComInfo scdpci = new SecCategoryDocPropertiesComInfo(); + sustomSearch.checkDefaultCustomSearch(seccategory); + rs.executeQuery("select * from DocSecCategoryCusSearch where secCategoryId = ? order by viewindex",seccategory); + while(rs.next()){ + int currDocPropertyId = rs.getInt("docPropertyId"); + int currVisible = rs.getInt("visible"); + + int currType = Util.getIntValue(scdpci.getType(currDocPropertyId+"")); + //if(currType==1) continue; + + int currIsCustom = Util.getIntValue(scdpci.getIsCustom(currDocPropertyId+"")); + + if(currVisible==1 || currType == 1 || currType == 26){ + if(currIsCustom==1){ + int tmpfieldid = Util.getIntValue(scdpci.getFieldId(currDocPropertyId+"")); + String tmpcustomName = scdpci.getCustomName(currDocPropertyId+"",user.getLanguage()); + if("oracle".equals(dbtype) || "mysql".equals(dbtype)){ + backFields= getFilterBackFields(backFields,"," + "tcm."+cfm.getFieldName(""+tmpfieldid)); + }else{ + backFields=getFilterBackFields(backFields,"cast(tcm."+cfm.getFieldName(""+tmpfieldid)+" as varchar) as "+cfm.getFieldName(""+tmpfieldid)); + } + colString +=""; + + String popedomParam = popedomOtherpara+"+"+popedomOtherpara2; + //new BaseBean().writeLog("DocSearchService 1 accessorycount:"+colString); + if(docTableType == DocTableType.DOC_COPYMOVE + || docTableType == DocTableType.NEWEST_DOC + || docTableType == DocTableType.NO_READ_DOC + || docTableType == DocTableType.SEARCH_DOC_TABLE + || docTableType == DocTableType.DOC_BATCHSHARE){ //复制移动、最新文档、未读文档、批量共享 复选框不需要验证权限 + tableString += ""; + }else if(docTableType==DocTableType.DOC_SUBSCRIPTION_APPROVE|| + docTableType==DocTableType.DOC_SUBSCRIPTION_BACK){ + tableString += ""; + }else if(docTableType==DocTableType.DOC_OUT_TABLE){ //登录前门户more + }else{ + tableString += ""; + } + tableString += ""; + + tableString += browser; + + tableString += operateString; + + tableString += "" + colString + ""; + tableString += ""; + String sessionkey = docTableType.getPageUid() + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + + //apidatas.put("tableString", tableString); + apidatas.put("sessionkey", sessionkey); + + if("1".equals(otherParams.get("showTableString"))){ + apidatas.put("tableString",tableString); + } + + //Map sharearg = new HashMap(); + //sharearg.put("hasDeleteBtn",true); + + //apidatas.put("sharearg",sharearg); + + return apidatas; + + + } + + /** + * 使用微搜查询 + * @author wangqs + * */ + public Map getDocListByFullSearch(DocTableType docTableType,User user,Map params){ + Map apidatas = new HashMap(); + /* + if(docTableType == DocTableType.SEARCH_DOC_TABLE || docTableType == DocTableType.CATEGORY_DOC_TABLE || docTableType == DocTableType.NEWEST_DOC || docTableType == DocTableType.NO_READ_DOC || docTableType == DocTableType.DOC_OUT_TABLE){ + String currentdate = TimeUtil.getCurrentDateString(); + Map scheduledreleasedateMap=new HashMap(); + scheduledreleasedateMap.put("scheduledreleasedate","1900-01-01");//t1.scheduledreleasedate is null + scheduledreleasedateMap.put("es_rangeQuery_lte_scheduledreleasedate",currentdate);//t1.scheduledreleasedate <= + params.put("scheduledreleasedateMap",scheduledreleasedateMap); + }*/ + //searchParams.put("docStatus","1,2,5"); + // searchParams.put("schemaType","DOCSEARCH"); + + + //非历史 + //searchParams.put("isHistory","0"); + //非回复 + // searchParams.put("isReply","0"); + params.put("pageId", docTableType.getPageUid()); + + String requestjson = DocFullSearchUtil.mapToSpitParam(params); + + requestjson += "+docTableTypeName:"+docTableType.name(); + + String tableString = ""; + + + String userInfoForotherpara =user.getLogintype() + "+" + user.getUID(); + + String popedomOtherpara = user.getLogintype() + "_" + user.getUID() + "_" + user.getSeclevel() + "_" + user.getType() + "_" + user.getUserDepartment() +"_"+ user.getUserSubCompany1(); + String popedomOtherpara2 = "column:seccategory+column:docstatus+column:doccreaterid+column:ownerid+column:sharelevel+column:id"; + String popedomParam = popedomOtherpara+"+"+popedomOtherpara2; + + String operateString = this.getTableOperate(user); + + + String browser = ""; + + if(docTableType == DocTableType.MY_DOC_TABLE){ //我的文档 复选框需要验证权限 + tableString += ""; + }else{ //文档查阅不需要 + tableString += ""; + } + + tableString += ""; + + if(thumbnail){ + tableString += browser; + } + + tableString += operateString; + + tableString += ""; + + int seccategory = Util.getIntValue(Util.null2String(params.get(DocCondition.SEC_CATEGORY.getName())),0); + isChatcooper = getChatcooper().equals(params.get("tabTitle")); + + boolean useCustomSearch = false; + if(seccategory > 0){ + useCustomSearch = isUseCustomSearch(seccategory); + } + if(useCustomSearch){ + tableString += getTableCustomCols(seccategory,user); + }else{ + tableString += getTableCols(docTableType,user); + + String getMost = Util.null2String(params.get("getMost")); + if("read".equals(getMost)){ + tableString += getCol("sumReadcount",user,false,false); + }else if("download".equals(getMost)){ + tableString += getCol("sumDownload",user,false,false); + }else if("score".equals(getMost)){ + tableString += getCol("sumMark",user,false,false); + } + } + + + + tableString += "" + "
"; + + + String sessionkey = docTableType.getPageUid() + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionkey, tableString); + + apidatas.put("sessionkey", sessionkey); + + return apidatas; + } + + public String getTableOperate(User user){ + String popedomOtherpara = user.getLogintype() + "_" + user.getUID() + "_" + user.getSeclevel() + "_" + user.getType() + "_" + user.getUserDepartment() +"_"+ user.getUserSubCompany1(); + String popedomOtherpara2 = "column:seccategory+column:docstatus+column:doccreaterid+column:ownerid+column:sharelevel+column:id"; + + String operateString = ""; + operateString += " "; + operateString += " "; + operateString += " "; + operateString += " "; + operateString += " "; + operateString += ""; + return operateString; + } + + public String getTableCols(DocTableType docTableType,User user){ + BaseBean bb = new BaseBean(); + String flag = Util.null2s(bb.getPropValue("doc_full_search","needCol"),"1"); + String cols = ""; + boolean secretFlag = CheckPermission.isOpenSecret(); + cols += this.getCol("docextendname",user,false,true); + cols += this.getCol("docsubject",user,false,true); + if(secretFlag){ + cols += this.getCol("secretLevel",user,false,true); + } + cols += this.getCol("ownerid",user,false,true); + if(docTableType == DocTableType.MY_DOC_TABLE){//我的文档 + cols += this.getCol("seccategory", user,true,true); + cols += this.getCol("doccreatedate", user,false,true); + cols += this.getCol("doclastmoddate", user,false,true); + cols += this.getCol("docstatus", user,false,true); + cols += this.getCol("accessorycount", user,false,false); + cols += this.getCol("replaydoccount", user,true,false); + if("1".equals(flag)) { + cols += this.getCol("doccode", user, true, false); + cols += this.getCol("docedition", user, true, false); + cols += this.getCol("docdepartmentid", user, true, false); + cols += this.getCol("docpubdate", user, true, false); + cols += this.getCol("docapprovedate", user, true, false); + cols += this.getCol("invalidationdate", user, true, false); + cols += this.getCol("keyword", user, true, false); + } + cols += this.getCol("doccreaterid", user,true,true); +// cols += this.getCol("sharelevel", user,true); +// cols += this.getCol("docstatus_num", user,true); +// cols += this.getCol("timeuse", user,true); + }else if(docTableType == DocTableType.SEARCH_DOC_TABLE){ //全部文档 + cols += this.getCol("doclastmoddate", user,false,true); + cols += this.getCol("seccategory", user,false,true); + cols += this.getCol("accessorycount", user,false,false); + cols += this.getCol("docstatus", user,false,true); + cols += this.getCol("doccreatedate", user,false,true); + cols += this.getCol("replaydoccount", user,false,false); + if("1".equals(flag)) { + cols += this.getCol("doccode", user, true, false); + cols += this.getCol("docedition", user, true, false); + cols += this.getCol("docdepartmentid", user, true, false); + cols += this.getCol("docpubdate", user, true, false); + cols += this.getCol("docapprovedate", user, true, false); + cols += this.getCol("invalidationdate", user, true, false); + cols += this.getCol("keyword", user, true, false); + } + cols += this.getCol("doccreaterid", user,true,true); +// cols += this.getCol("sharelevel", user,true); +// cols += this.getCol("docstatus_num", user,true); +// cols += this.getCol("timeuse", user,true); + } + + return cols; + } + + public String getTableCustomCols(int seccategory,User user){ + + boolean secretFlag = CheckPermission.isOpenSecret(); + String colString = ""; + + colString += this.getCol("accessorycount",user,false,true); + //backFields = ""; + CustomFieldManager cfm = new CustomFieldManager("DocCustomFieldBySecCategory",seccategory); + SecCategoryCustomSearchComInfo sustomSearch = new SecCategoryCustomSearchComInfo(); + SecCategoryDocPropertiesComInfo scdpci = new SecCategoryDocPropertiesComInfo(); + try{ + sustomSearch.checkDefaultCustomSearch(seccategory); + }catch(Exception e){ + + } + RecordSet rs = new RecordSet(); + Map descMap = new HashMap(); + rs.executeQuery("select * from docseccategorydocproperty where secCategoryId = ?",seccategory); + while(rs.next()){ + String custonType = Util.null2String(rs.getString("type")); + String custonDesc = Util.null2String(rs.getString("customName")); + if(!"".equals(custonDesc)){ + descMap.put(custonType,custonDesc); + } + + } + rs.executeQuery("select * from DocSecCategoryCusSearch where secCategoryId = ? order by viewindex",seccategory); + while(rs.next()){ + int currDocPropertyId = rs.getInt("docPropertyId"); + int currVisible = rs.getInt("visible"); + + int currType = Util.getIntValue(scdpci.getType(currDocPropertyId+"")); + //if(currType==1) continue; + + int currIsCustom = Util.getIntValue(scdpci.getIsCustom(currDocPropertyId+"")); + + if(currVisible==1 || currType == 1 || currType == 26){ + if(currIsCustom==1){ + int tmpfieldid = Util.getIntValue(scdpci.getFieldId(currDocPropertyId+"")); + String tmpcustomName = scdpci.getCustomName(currDocPropertyId+"",user.getLanguage()); + +// colString +="0&&i"; + } + + else if("doccreaterid".equals(col)){ //创建者 + colStr = "" ; + }else if("sharelevel".equals(col)){ //权限级别 + colStr = "" ; + }else if("docstatus_num".equals(col)){ //状态 + colStr = ""; + }else if("sumReadcount".equals(col)){ //阅读数 + colStr = ""; + }else if("sumDownload".equals(col)){//下载数 + colStr = ""; + }else if("sumMark".equals(col)){//总打分 + colStr = ""; + }else if("secretLevel".equals(col)){ + //密级 + colStr = ""; + } + + else if("timeuse".equals(col)){ + colStr = "";// 用时 + + } else if("doccode".equals(col)){ + colStr = ""; + + }else if("docedition".equals(col)){ + colStr = ""; + + }else if("docdepartmentid".equals(col)){ + colStr = ""; + + }else if("docpubdate".equals(col)){ + colStr = ""; + + }else if("docapprovedate".equals(col)){ + colStr = ""; + + }else if("invalidationdate".equals(col)){ + colStr = ""; + + }else if("keyword".equals(col)){ + colStr = ""; + + } + return colStr; + } + + /** + * 微搜获取数据 + * @author wangqs + * */ + public static Map getDocData(User user,Map otherparams, + HttpServletRequest request,HttpServletResponse response) throws Exception{ + //BaseBean bb = new BaseBean(); + //bb.writeLog("weaver->DocSearchService->873->otherparams->"+otherparams); + // 排序条件 + //sortParams=[{"orderkey":"docsubject","sortOrder":"descend"} + //[{"orderkey":"docsubject","sortOrder":"ascend"}] +// String sortData = Util.null2String(request.getParameter("sortParams")); + + Map resultMap = ParamUtil.request2Map(request); + List sortParamsList = JSONArray.parseArray((String) request.getParameter("sortParams")); + Map sortData = new HashMap(); + if(sortParamsList!=null && sortParamsList.size()>0){ + sortData = (Map) sortParamsList.get(0); + } + String getMost = Util.null2String(otherparams.get("getMost")); + String order = Util.null2String(sortData.get("orderkey")); + String orderby = Util.null2String(sortData.get("sortOrder")); + String getMoreOder = Util.null2String(otherparams.get("getMoreOder")); + Map sortMap = new LinkedHashMap(); + + boolean isChatCooper = false; + if("chatcooper".equals(getMost)){ + getMost = ""; + isChatCooper = true; + } + + if(!getMoreOder.isEmpty()){ + sortMap.put("istop","false"); + sortMap.put("topdate","false"); + sortMap.put("toptime","false"); + } + + /**使用微搜,我的文档、查询文档 先根据置顶排序,包括门户more页面*/ + String docTableTypeName = Util.null2String(otherparams.get("docTableTypeName")); + if("MY_DOC_TABLE".equals(docTableTypeName) || "SEARCH_DOC_TABLE".equals(docTableTypeName)) { + sortMap.put("istop","false"); + sortMap.put("topdate","false"); + sortMap.put("toptime","false"); + } + + if(!order.isEmpty() && !orderby.isEmpty()){ + String isasc = "ascend".equals(orderby) ? "true" : "false"; + if("docextendname".equals(order)){ + sortMap.put("docExtendName",isasc); + }else if("docsubject".equals(order)){ + sortMap.put("title",isasc); + }else if("ownerid".equals(order)){ + sortMap.put("ownerid",isasc); + }else if("doccreatedate".equals(order)){ + sortMap.put("createDate",isasc); + sortMap.put("createTime",isasc); + }else if("doclastmoddate".equals(order)){ + sortMap.put("lastModDate",isasc); + sortMap.put("lastModTime",isasc); + }else if("docstatus_id".equals(order)){ + sortMap.put("docStatus",isasc); + }else if("accessorycount".equals(order)){ + sortMap.put("accessoryCount",isasc); + }else if("replaydoccount".equals(order)){ + sortMap.put("replaydoccount",isasc); + }else if("seccategory".equals(order)){ + sortMap.put("secCategory",isasc); + }else if("sumReadcount".equals(order) || "sumDownload".equals(order) || "sumMark".equals(order)){ + sortMap.put(order,isasc); + } + sortMap.put("ID",isasc); + }else if(!getMost.isEmpty()){ + if("reply".equals(getMost)){ + sortMap.put("replaydoccount", "false"); + }else if("read".equals(getMost)){ + sortMap.put("sumReadcount", "false"); + }else if("download".equals(getMost)){ + sortMap.put("sumDownload", "false"); + }else if("score".equals(getMost)){ + sortMap.put("sumMark", "false"); + } + sortMap.put("ID","false"); + }else if(!getMoreOder.isEmpty()){ //默认元素 more页面,排序 + + String isasc = "asc".equals(otherparams.get("getMoreOderBy")) ? "true" : "false"; + + if("doccreatedate".equals(getMoreOder)){ + sortMap.put("createDate",isasc); + sortMap.put("createTime",isasc); + }else if("docpubdate".equals(getMoreOder)){ + sortMap.put("docpubdate",isasc); + sortMap.put("docpubtime",isasc); + }else if("docapprovedate".equals(getMoreOder)){ + sortMap.put("approvedate",isasc); + sortMap.put("docapprovetime",isasc); + }else{ + sortMap.put("lastModDate",isasc); + sortMap.put("lastModTime",isasc); + } + sortMap.put("ID",isasc); + }else{ + sortMap.put("lastModDate","false"); + sortMap.put("lastModTime","false"); + sortMap.put("ID","false"); + } + + // 分页信息 + int pageNum = Util.getIntValue(request.getParameter("min"),0); + if(pageNum <= 0){ + pageNum = Util.getIntValue((String)request.getAttribute("min"),0); + } + int pageSize = Util.getIntValue(request.getParameter("pageSize"),0); + if(pageSize <= 0){ + pageSize = Util.getIntValue((String)request.getAttribute("pageSize"),0); + } + int onlyCount = Util.getIntValue((String)request.getAttribute("onlyCount"),0); //是否只返回数量 +// bb.writeLog("weaver->DocSearchService->873->pageNum->"+pageNum); + //tableString 获取总数时,会再次走该接口,(为了提高效率,数据不再处理,直接返回总数) + onlyCount = onlyCount == 0 && pageSize <= 0 ? 1 : onlyCount; + + pageSize = pageSize <= 0 ? 10 : pageSize; + + pageNum = pageNum/pageSize + 1; + + // 搜索条件 + Map searchParams = new HashMap(); + FullSearchUtil fullSearch = new FullSearchUtil(); + searchParams = fullSearch.getParams(otherparams,user); + if(isChatCooper){ + searchParams.put("docType",2); + } + // 必须包含 + searchParams.put("loginid",user.getLoginid()); + searchParams.put("currentUserObject",user); + searchParams.put("page",pageNum); + searchParams.put("pageSize",pageSize); + //searchParams.put("docStatus","1,2,5"); + searchParams.put("schemaType","DOCSEARCH"); + + //String docTableTypeName = Util.null2String(otherparams.get("docTableTypeName")); + //我的文档 全部文档(不包含门户文档中心more页面) + if("MY_DOC_TABLE".equals(docTableTypeName) || ("SEARCH_DOC_TABLE".equals(docTableTypeName) && getMoreOder.isEmpty())) { + /**隐藏目录时,不显示对应的文档 start*/ + Map mustNotMap = new HashMap<>(); + String hideSecid = getHideSec(); + if(!"".equals(hideSecid)) { + mustNotMap.put("secCategory", hideSecid); + searchParams.put("mustNotMap", mustNotMap); + } + /**隐藏目录时,不显示对应的文档 end*/ + } + + //非历史 + //searchParams.put("isHistory","0"); + //非回复 + // searchParams.put("isReply","0"); + + // 返回结果 + Map result = new HashMap(); + + // 文档集合 + ArrayList> dataList = new ArrayList>(); + + Date d1 = new Date(); + // 查询 + /* RmiProxyFactoryBean rmiProxyFactory = new RmiProxyFactoryBean(); + rmiProxyFactory.setServiceInterface(SearchRmi.class); + rmiProxyFactory.setServiceUrl(DocFullSearchUtil.getFullSearchRMI()); + try { + rmiProxyFactory.afterPropertiesSet(); + } catch (Exception e) { + (new weaver.general.BaseBean()).writeLog("analysis获取RMI异常:" + e.getMessage()); + } + SearchRmi searchRmi = (SearchRmi) rmiProxyFactory.getObject(); + Map searchResult = searchRmi.quickSearch(searchParams, sortMap, null);*/ + + //查询2 + Map searchResult = DocFullSearchUtil.quickSearch(searchParams,sortMap,null); + + + + searchResult = searchResult == null ? new HashMap() : searchResult; + + Date d2 = new Date(); + + // 查询结果集 + List docList = (List) searchResult.get("result"); + docList = docList == null ? new ArrayList() : docList; + + // 文档总数 + int count = searchResult.get("count") == null ? 0 : Util.getIntValue(searchResult.get("count").toString(),0); + + //只取总数 + if(onlyCount == 1){ + result.put("recordCount", count); + return result; + } + + /** + * columns : + * id + * docstatus_id + * replaydoccount_id + * docextendname(缺失) + * seccategory + * docstatus + * doccreaterid + * ownerid + * usertype + * sharelevel(缺失) + * docsubject + * doccreatedate + * accessorycount + * doclastmoddate + * replaydoccount + * docvestin(缺失) + * readcount(当前人当前文档阅读数量)(缺失) + * */ + String ids = ""; + for(int i = 0 ; i < docList.size() ; i ++){ + Map docMap = (Map)docList.get(i); + Map oJson= new HashMap(); + if(Util.getIntValue(docMap.get("id")) > 0){ + ids += "," + docMap.get("id"); + } + oJson.put("id", docMap.get("id")); + oJson.put("docstatus_id", docMap.get("id")); + oJson.put("replaydoccount_id", docMap.get("id")); + + // oJson.put("docextendname", docMap.get("docExtendName") == null ? "html" : docMap.get("docExtendName")); //文档类型 + + oJson.put("docsubject", docMap.get("title")); + oJson.put("doccreaterid",docMap.get("createrId")); + oJson.put("ownerid",docMap.get("ownerid")); + oJson.put("usertype",docMap.get("usertype")); + oJson.put("doclastmoddate", docMap.get("lastModDate")); + oJson.put("seccategory",docMap.get("directoryId")); + // oJson.put("accessorycount", docMap.get("accessoryCount")); + oJson.put("docstatus", docMap.get("docStatus")); + oJson.put("doccreatedate", docMap.get("createDate")); + // oJson.put("replaydoccount", docMap.get("replaydoccount")); + oJson.put("docvestin", docMap.get("docVestIn") == null ? "0" : docMap.get("docVestIn")); + oJson.put("readCount","0"); + oJson.put("sharelevel", " "); + + // oJson.put("sumReadcount",docMap.get("sumReadcount")); + // oJson.put("sumDownload",docMap.get("sumDownload")); + // oJson.put("sumMark",docMap.get("sumMark")); + + dataList.add(oJson); + } + + if(!ids.isEmpty()){ + ids = ids.substring(1); + RecordSet rs = new RecordSet(); + if(!DocTableType.MY_DOC_TABLE.getPageUid().equals(otherparams.get("pageId"))){//有文档,并且不是我的文档 + + HrmUserSettingComInfo userSetting = new HrmUserSettingComInfo(); + String belongtoshow = userSetting.getBelongtoshowByUserId(user.getUID()+""); + String belongtoids = user.getBelongtoids(); + String account_type = user.getAccount_type(); + if(belongtoshow.equals("1")&&account_type.equals("0")&&!belongtoids.equals("")){ + belongtoids+=","+user.getUID(); + } + rs.executeQuery("select b.docid as id from docReadTag b where b.userType=" + user.getLogintype()+ + " and b.docid in (" + ids + ") and b.userid" + ((belongtoids.isEmpty() ? ("=" + user.getUID()) : (" in ("+belongtoids+")")))); + while(rs.next()){ + for(Map data : dataList){ + if(rs.getString("id").equals(data.get("id"))){ + data.put("readCount", "1"); + continue; + } + } + } + } + + + int seccategory = Util.getIntValue(request.getParameter(DocCondition.SEC_CATEGORY.getName()),0); + if(seccategory <= 0) { + seccategory = Util.getIntValue(otherparams.get(DocCondition.SEC_CATEGORY.getName()),0); + } + boolean useCustomSearch = false; + DocSearchService docSearchService = new DocSearchService(); + if(seccategory > 0){ + useCustomSearch = docSearchService.isUseCustomSearch(seccategory); + } + String sql = ""; + List columns = new ArrayList(); + columns.add("id"); + columns.add("docextendname"); + columns.add("secretLevel"); + columns.add("accessorycount"); + columns.add("replaydoccount"); + columns.add("sumReadcount"); + columns.add("sumDownload"); + columns.add("sumMark"); + columns.add("doccode"); + columns.add("id as docedition_id"); + columns.add("docdepartmentid"); + columns.add("docpubdate"); + columns.add("docapprovedate"); + columns.add("invalidationdate"); + columns.add("keyword"); + columns.add("doclastmodtime"); + columns.add("doccreatetime"); + + if(useCustomSearch){ + CustomFieldManager cfm = new CustomFieldManager("DocCustomFieldBySecCategory",seccategory); + SecCategoryCustomSearchComInfo sustomSearch = new SecCategoryCustomSearchComInfo(); + SecCategoryDocPropertiesComInfo scdpci = new SecCategoryDocPropertiesComInfo(); + sustomSearch.checkDefaultCustomSearch(seccategory); + rs.executeQuery("select * from DocSecCategoryCusSearch where secCategoryId = ? order by viewindex",seccategory); + String backFields = "t1.id,t1.docextendname,t1.secretLevel,t1.accessorycount"; + String dbtype = rs.getDBType(); + while(rs.next()){ + int currDocPropertyId = rs.getInt("docPropertyId"); + int currVisible = rs.getInt("visible"); + + int currType = Util.getIntValue(scdpci.getType(currDocPropertyId+"")); + + int currIsCustom = Util.getIntValue(scdpci.getIsCustom(currDocPropertyId+"")); + + if(currVisible==1 || currType == 1 || currType == 26){ + if(currIsCustom==1){ + int tmpfieldid = Util.getIntValue(scdpci.getFieldId(currDocPropertyId+"")); + //String tmpcustomName = scdpci.getCustomName(currDocPropertyId+"",user.getLanguage()); + if("oracle".equals(dbtype) || "mysql".equals(dbtype)){ + backFields= docSearchService.getFilterBackFields(backFields,"," + "tcm."+cfm.getFieldName(""+tmpfieldid)); + }else{ + backFields=docSearchService.getFilterBackFields(backFields,"cast(tcm."+cfm.getFieldName(""+tmpfieldid)+" as varchar) as "+cfm.getFieldName(""+tmpfieldid)); + } + columns.add(cfm.getFieldName(""+tmpfieldid)); + } else { + if(currType==1){ + } else if(currType==2){ + backFields=docSearchService.getFilterBackFields(backFields,"t1.docCode"); + columns.add("docCode"); + } else if(currType==3){ + backFields=docSearchService.getFilterBackFields(backFields,"t1.docpublishtype"); + columns.add("docpublishtype"); + } else if(currType==4){ + backFields=docSearchService.getFilterBackFields(backFields,"t1.docedition,t1.id as docedition_id"); + columns.add("docedition"); + columns.add("id as docedition_id"); + } else if(currType==5){ + } else if(currType==6){ + } else if(currType==7){ + } else if(currType==8){ + } else if(currType==9){ + backFields=docSearchService.getFilterBackFields(backFields,"t1.docdepartmentid"); + columns.add("docdepartmentid"); + } else if(currType==10){ + } else if(currType==11){ + int tmplabelid = Util.getIntValue(scdpci.getLabelId(currDocPropertyId+"")); + backFields=docSearchService.getFilterBackFields(backFields,"t1.doclangurage"); + columns.add("doclangurage"); + } else if(currType==12){ + int tmplabelid = Util.getIntValue(scdpci.getLabelId(currDocPropertyId+"")); + backFields=docSearchService.getFilterBackFields(backFields,"t1.keyword"); + columns.add("keyword"); + } else if(currType==13){ + } else if(currType==14){ + } else if(currType==15){ + backFields=docSearchService.getFilterBackFields(backFields,"t1.docapprovedate"); + columns.add("docapprovedate"); + } else if(currType==16){ + backFields=docSearchService.getFilterBackFields(backFields,"t1.docinvaldate"); + columns.add("docinvaldate"); + } else if(currType==17){ + backFields=docSearchService.getFilterBackFields(backFields,"t1.docarchivedate"); + columns.add("docarchivedate"); + } else if(currType==18){ + backFields=docSearchService.getFilterBackFields(backFields,"t1.doccanceldate"); + columns.add("doccanceldate"); + } else if(currType==19){ + backFields=docSearchService.getFilterBackFields(backFields,"t1.maindoc,t1.id as maindoc_id"); + columns.add("maindoc"); + columns.add("id as maindoc_id"); + } else if(currType==20){ + } else if(currType==21){ + } else if(currType==22){ + backFields=docSearchService.getFilterBackFields(backFields,"t1.invalidationdate"); + columns.add("invalidationdate"); + }else if(currType==24){ + backFields=docSearchService.getFilterBackFields(backFields,"t1.id as docdummy_id"); + columns.add("id as docdummy_id"); + }else if(currType==25){ + backFields=docSearchService.getFilterBackFields(backFields,"t1.canPrintedNum"); + columns.add("canPrintedNum"); + }else if(currType==26){ + } + + + } + } + } + + backFields = backFields.trim(); + backFields = backFields.endsWith(",") ? backFields.substring(0, backFields.length() - 1) : backFields; + backFields = backFields.startsWith(",") ? backFields.substring(1, backFields.length()) : backFields; + + sql = "select "+backFields+" from DocDetail t1 LEFT JOIN cus_fielddata tcm ON t1.id=tcm.id and tcm.scope='DocCustomFieldBySecCategory' where t1.id in("+ids+")"; + + }else{ + + String backFields = ""; + for(String column : columns){ + backFields += "," + column; + } + + if(backFields.isEmpty()){ + sql = "select id,docextendname,secretLevel from docdetail where id in("+ids+")"; + }else{ + backFields = backFields.substring(1); + sql = "select "+backFields+" from docdetail where id in("+ids+")"; + } + + + } + rs.executeQuery(sql); + + while(rs.next()){ + for(Map data : dataList){ + if(rs.getString("id").equals(data.get("id"))){ + for(String column : columns){ + if(column.toLowerCase().contains(" as ")){ + column = column.toLowerCase().split(" as ")[1]; + } + if(data.get(column) == null){ + data.put(column,Util.null2String(rs.getString(column))); + } + } + continue; + } + } + } + result.put("columns",columns); + } + /* Date d3 = new Date(); + long t1 = d3.getTime() - d2.getTime(); + long t2 = d2.getTime() - d1.getTime(); + for(Map data : dataList){ + data.put("timeuse",SystemEnv.getHtmlLabelName(31953,user.getLanguage())+":" + t1 + ","+SystemEnv.getHtmlLabelName(25426,user.getLanguage())+":" + t2);//微搜 未读 + + } + */ + result.put("dataAll", dataList); + result.put("recordCount", count); + return result; + + } + + public static String getHideSec(){ + String secids = ""; + RecordSet rs = new RecordSet(); + boolean openhidedoc = false; //判断应用设置是否开启隐藏文档,如果开启,才需隐藏。 + rs.executeQuery("select openhidedoc from docapplysetting where settingtype=?", DocApplySettingUtil.DOCCONTENTINFOSET); + if(rs.next()){ + openhidedoc = "1".equals(Util.null2s(rs.getString("openhidedoc"),"0")); + } + if(openhidedoc) { + rs.executeQuery("select id from docseccategory where ishidesec = 1"); + while (rs.next()) { + String secid = Util.null2String(rs.getString(1)); + secids += "," + secid; + } + } + return secids.startsWith(",") ? secids.substring(1) : secids; + } + + public static List> getSearchCondition(User user){ + return getSearchCondition(user,null); + } + + /** + * 获取公用高级搜索条件 + * @author wangqs + * */ + public static List> getSearchCondition(User user,String tableType){ + List> grouplist = new ArrayList>(); + + Map groupitem1 = new HashMap(); + List itemlist1 = new ArrayList(); + groupitem1.put("title", SystemEnv.getHtmlLabelNames(ConditionUtil.COMMON_CONDITION, user.getLanguage())); + groupitem1.put("defaultshow", true); + groupitem1.put("items", itemlist1); + grouplist.add(groupitem1); + + itemlist1.add(ConditionUtil.getCondition(DocCondition.DOC_SUBJECT,user)); + boolean secretFlag = CheckPermission.isOpenSecret(); + if(secretFlag){ + //if("batchShare".equals(tableType)){ + // itemlist1.add(ConditionUtil.getSecretLevel(user)); + //}else{ + itemlist1.add(ConditionUtil.getCondition(DocCondition.SECRET_LEVEL,user)); + //} + } + itemlist1.add(ConditionUtil.getCondition(DocCondition.DOC_CREATER_ID,user)); + itemlist1.add(ConditionUtil.getCondition(DocCondition.SEC_CATEGORY,user)); + itemlist1.add(ConditionUtil.getCondition(DocCondition.DOC_CREATEDATE_SELECT,user)); + itemlist1.add(ConditionUtil.getCondition(DocCondition.DEPARTMENT_ID,user)); + //itemlist1.add(ConditionUtil.getCondition(DocCondition.DATE2DURING,user)); + itemlist1.add(ConditionUtil.getCondition(DocCondition.DOC_LAST_MODDATE,user)); + + + Map groupitem2 = new HashMap(); + List itemlist2 = new ArrayList(); + groupitem2.put("title", SystemEnv.getHtmlLabelNames(ConditionUtil.OTHER_CONDITION,user.getLanguage())); + groupitem2.put("defaultshow", false); + groupitem2.put("items", itemlist2); + grouplist.add(groupitem2); + + itemlist2.add(ConditionUtil.getCondition(DocCondition.DOC_NO,user)); + itemlist2.add(ConditionUtil.getCondition(DocCondition.OWNER_ID,user)); + itemlist2.add(ConditionUtil.getCondition(DocCondition.OWNER_DEPARTMENT_ID,user)); + itemlist2.add(ConditionUtil.getCondition(DocCondition.OWNER_SUBCOMPANY_ID,user)); + itemlist2.add(ConditionUtil.getCondition(DocCondition.CREATER_SUBCOMPANY_ID,user)); + itemlist2.add(ConditionUtil.getCondition(DocCondition.DOC_PUBLISH_TYPE,user)); + itemlist2.add(ConditionUtil.getCondition(DocCondition.TREE_DOC_FIELD_ID,user)); + itemlist2.add(ConditionUtil.getCondition(DocCondition.KEYWORD,user)); + itemlist2.add(ConditionUtil.getCondition(DocCondition.REPLAY_DOC_COUNT,user)); + itemlist2.add(ConditionUtil.getDocStatus1(user.getLanguage())); + return grouplist; + } + + /** + * 获取公用高级搜索条件(隐藏目录) + * @author wangqs + * */ + public static List> getSearchConditionhide(User user,String tableType){ + List> grouplist = new ArrayList>(); + + Map groupitem1 = new HashMap(); + List itemlist1 = new ArrayList(); + groupitem1.put("title", SystemEnv.getHtmlLabelNames(ConditionUtil.COMMON_CONDITION, user.getLanguage())); + groupitem1.put("defaultshow", true); + groupitem1.put("items", itemlist1); + grouplist.add(groupitem1); + + itemlist1.add(ConditionUtil.getCondition(DocCondition.DOC_SUBJECT,user)); + boolean secretFlag = CheckPermission.isOpenSecret(); + if(secretFlag){ + //if("batchShare".equals(tableType)){ + // itemlist1.add(ConditionUtil.getSecretLevel(user)); + //}else{ + itemlist1.add(ConditionUtil.getCondition(DocCondition.SECRET_LEVEL,user)); + //} + } + itemlist1.add(ConditionUtil.getCondition(DocCondition.DOC_CREATER_ID,user)); + //增加属性,目录浏览框过滤隐藏目录 + SearchConditionItem searchConditionItem=ConditionUtil.getCondition(DocCondition.SEC_CATEGORY,user); + BrowserBean browserBean= searchConditionItem.getBrowserConditionParam(); + Map browserparams= browserBean.getDataParams(); + browserparams.put("ishidesec","1"); + browserBean.getCompleteParams().put("ishidesec","1"); + itemlist1.add(searchConditionItem); + itemlist1.add(ConditionUtil.getCondition(DocCondition.DOC_CREATEDATE_SELECT,user)); + itemlist1.add(ConditionUtil.getCondition(DocCondition.DEPARTMENT_ID,user)); + //itemlist1.add(ConditionUtil.getCondition(DocCondition.DATE2DURING,user)); + itemlist1.add(ConditionUtil.getCondition(DocCondition.DOC_LAST_MODDATE,user)); + + + Map groupitem2 = new HashMap(); + List itemlist2 = new ArrayList(); + groupitem2.put("title", SystemEnv.getHtmlLabelNames(ConditionUtil.OTHER_CONDITION,user.getLanguage())); + groupitem2.put("defaultshow", false); + groupitem2.put("items", itemlist2); + grouplist.add(groupitem2); + + itemlist2.add(ConditionUtil.getCondition(DocCondition.DOC_NO,user)); + itemlist2.add(ConditionUtil.getCondition(DocCondition.OWNER_ID,user)); + itemlist2.add(ConditionUtil.getCondition(DocCondition.OWNER_DEPARTMENT_ID,user)); + itemlist2.add(ConditionUtil.getCondition(DocCondition.OWNER_SUBCOMPANY_ID,user)); + itemlist2.add(ConditionUtil.getCondition(DocCondition.CREATER_SUBCOMPANY_ID,user)); + itemlist2.add(ConditionUtil.getCondition(DocCondition.DOC_PUBLISH_TYPE,user)); + itemlist2.add(ConditionUtil.getCondition(DocCondition.TREE_DOC_FIELD_ID,user)); + itemlist2.add(ConditionUtil.getCondition(DocCondition.KEYWORD,user)); + itemlist2.add(ConditionUtil.getCondition(DocCondition.REPLAY_DOC_COUNT,user)); + itemlist2.add(ConditionUtil.getDocStatus1(user.getLanguage())); + return grouplist; + } + + /** + * 是否使用微搜 + * @author wangqs + * */ + public static boolean useFullSearch(){ + BaseBean bb = new BaseBean(); + String flag = bb.getPropValue("doc_full_search","use_full_search"); + if(!"1".equals(flag)){ + return false; + } + + boolean fullSearch = SearchBrowserUtils.quickSearchValidate("DOCSEARCH","7"); + if(!fullSearch){ + return false; + } + + boolean secretFlag = CheckPermission.isOpenSecret(); + if(secretFlag && !SearchBrowserUtils.isSupportSecretLevel()){ + return false; + } + /* + if(!SearchBrowserUtils.isSupportFunction("supportDocReleasedate")){ + return false; + }*/ + return true; + } + + /** + * 操作指令 + * aprrove:批准;reject:拒绝;getback:收回订阅;add:提交订阅申请 + * @author yhw + * @throws Exception + * */ + public Map getOptionType(String subscribeIds,String operation,HttpServletRequest request,User user) throws Exception { + RecordSet rs=new RecordSet(); + Map apidatas=new HashMap(); + //String subscribeIds = Util.null2String(request.getParameter("subscribeIds")); + Calendar today = Calendar.getInstance(); + String currentData = Util.add0(today.get(Calendar.YEAR), 4) +"-"+ + Util.add0(today.get(Calendar.MONTH) + 1, 2) +"-"+ + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2) ; + char flag = 2 ; + String subScribeDescStr = "" ; + DocViewer docViewer=new DocViewer(); + DocComInfo docComInfo=new DocComInfo(); + SptmForDoc sptmForDoc=new SptmForDoc(); + SysRemindWorkflow sysRemindWorkflow=new SysRemindWorkflow(); + + if (operation.equals(DocSearchService.SUBSCRIBE_OPERATE_APRROVE)){ + ArrayList idList = Util.TokenizerString(subscribeIds,","); + for (int i=0 ;i "+docComInfo.getDocname(docId)+"   "; + + String otherSubscribeDocNames =""; + if (!"".equals(otherSubscribe)){ + + String[] tempStr = Util.TokenizerString2(otherSubscribe,","); + for (int j=0;j "+docComInfo.getDocname(docId2)+"  "; + } + } + //发送流程 + String requestname=SystemEnv.getHtmlLabelName(30041,user.getLanguage())+" "+docComInfo.getDocname(docId)+SystemEnv.getHtmlLabelName(83424,user.getLanguage()); + String remark=SystemEnv.getHtmlLabelName(83425,user.getLanguage())+" "+docComInfo.getDocname(docId)+" "+SystemEnv.getHtmlLabelName(83426,user.getLanguage())+sptmForDoc.getName1(""+user.getUID(),user.getLogintype())+SystemEnv.getHtmlLabelName(142,user.getLanguage())+"! "; + + if (!"".equals(otherSubscribeDocNames)) remark += SystemEnv.getHtmlLabelName(83427,user.getLanguage())+otherSubscribeDocNames+SystemEnv.getHtmlLabelName(83428,user.getLanguage()); + remark += SystemEnv.getHtmlLabelName(83429,user.getLanguage()); + if ("1".equals(subscribetype)){ + sysRemindWorkflow.setDocSysRemind(requestname,0,user.getUID(),subscribeHrmId,remark); + } else { + //外部用户目前没有默认提醒 + } + } + apidatas.put("api_status", true); + return apidatas; + }else if (operation.equals(DocSearchService.SUBSCRIBE_OPERATE_REJECT)){ + ArrayList idList = Util.TokenizerString(subscribeIds,","); + for (int i=0 ;i> "+SystemEnv.getHtmlLabelName(83430,user.getLanguage()); + String remark=SystemEnv.getHtmlLabelName(83431,user.getLanguage())+" <"+docName+"> "+SystemEnv.getHtmlLabelName(83426,user.getLanguage())+sptmForDoc.getName1(""+user.getUID(),user.getLogintype())+SystemEnv.getHtmlLabelName(25659,user.getLanguage())+"! "; + if ("1".equals(subscribetype)){ + sysRemindWorkflow.setDocSysRemind(requestname,0,user.getUID(),subscribeHrmId,remark); + } else { + //外部用户目前没有默认提醒 + } + + //修改subscribe表 + String updateSql = "delete from DocSubscribe where id = "+id; + rs.executeUpdate(updateSql); + } + apidatas.put("api_status", true); + return apidatas; + }else if (operation.equals(DocSearchService.SUBSCRIBE_OPERATE_GETBACK)){ //文档收回部分 + ArrayList idList = Util.TokenizerString(subscribeIds,","); + for (int i=0 ;i"); + rs.executeProc("DocSubscribe_Insert",ProcPara); + String requestname=sptmForDoc.getName1(""+user.getUID(),user.getLogintype())+SystemEnv.getHtmlLabelName(83636,user.getLanguage())+" "+docComInfo.getDocname(docId); + + String href = DocSptm.DOC_LINK + "#/main/document/subscribe?viewcondition=1"; + + String remark=SystemEnv.getHtmlLabelName(83638,user.getLanguage())+" "+SystemEnv.getHtmlLabelName(142,user.getLanguage())+""; + sysRemindWorkflow.setDocSysRemind(requestname,0,user.getUID(),owenerId,remark); + } + apidatas.put("api_status", true); + return apidatas; + } + apidatas.put("api_status", false); + return apidatas; + + } + private String getAllVersions(String docid,RecordSet rs) throws Exception{ + if(null==rs) rs=new RecordSet(); + int doceditionid=-1; + rs.executeQuery("select doceditionid from docdetail where id="+docid); + if(rs.next()) { + doceditionid=rs.getInt(1); + } + //如果有版本控制,取出该版本下的所有文档id + String docids = "" + docid; + if(doceditionid>-1){ + docids = ""; + rs.executeQuery(" select id from DocDetail where doceditionid = " + doceditionid); + while(rs.next()){ + docids+=","+rs.getString("id"); + } + } + docids = docids.startsWith(",")?docids.substring(1):docids; + return docids; + } + + /** + * 可订阅文档所有的树 + * @author yhw + * */ + public Map getTreeNode(String operation, + HttpServletRequest request, User user) throws Exception { + RecordSet rs=new RecordSet(); + Map apidatas=new HashMap(); + + //当且仅当为可订阅文档的时候有树 + if(DocSearchService.SUBSCRIBE_OPERATE_ADD.equals(operation)){ + ShareManager shareManager=new ShareManager(); + DocSearchComInfo docSearchComInfo=new DocSearchComInfo(); + String whereclause = " where " + docSearchComInfo.FormatSQLSearch(user.getLanguage()) ; + String backfields ="t1.seccategory,t1.id "; + String sqlFrom = " from docdetail t1 left join "+shareManager.getShareDetailTableByUser("doc",user)+" t2 on t1.id=t2.sourceid "; + String detailWhere = whereclause+" and t1.orderable = '1' and t2.sourceid is null and not exists(select 1 from docsubscribe where docid=t1.id and state in('1','2') and hrmId="+user.getUID()+")"; + + boolean secretFlag = CheckPermission.isOpenSecret(); + if(secretFlag){ + HrmClassifiedProtectionBiz hcpb = new HrmClassifiedProtectionBiz(); + String userSecretLevel = hcpb.getMaxResourceSecLevel(user); + detailWhere += " and t1.secretLevel>=" + Util.getIntValue(userSecretLevel,DocManager.DEFAILT_SECRET_LEVEL);// + } + + String sql="select "+backfields+sqlFrom+detailWhere+" order by t1.id desc"; + rs.executeQuery(sql); + + Map rightData = new HashMap(); + while(rs.next()){ + rightData.put(SecTreeNode.NODE_PREV + rs.getString("seccategory"),"1"); + } + + String rstype = rs.getDBType(); + Dao_TableSqlServer dao = new Dao_TableSqlServer(); + String secorderOrder = dao.getDealWithThousandsField("d.secorder","d.secorder",rstype); + sql = "select d.parentid,d.id,d.categoryname,d.ecology_pinyin_search,f.secid from DocSecCategory d " + + " left join " + + " (select distinct secid from user_favorite_category " + + " where userid=" + user.getUID() + " and usertype=" + user.getLogintype() + ") " + + " f on d.id=f.secid "; + + if(rstype.equals("oracle")){ + sql+=" where nvl(d.ishidesec,0) <>1"; + }else if(rstype.equals("mysql")){ + sql+=" where ifnull(d.ishidesec,0) <>1"; + } else { + sql+=" where ISNULL(d.ishidesec,0) <>1"; + } + sql+=" order by "+secorderOrder+" asc,d.id asc"; + rs.executeQuery(sql); + + Map allData = new HashMap(); + + List ids = new ArrayList(); + List pids = new ArrayList(); + + while(rs.next()){ + SecTreeNode treeNode = new SecTreeNode(); + allData.put(SecTreeNode.NODE_PREV + rs.getString("id"),treeNode); + + treeNode.setKey(Util.null2String(rs.getString("id"))); + treeNode.setDomid(SecTreeNode.NODE_PREV + rs.getString("id")); + treeNode.setPid(Util.null2String(rs.getString("parentid"))); + treeNode.setFav(Util.null2String(rs.getString("secid")).equals(rs.getString("id"))); + + ids.add(rs.getString("id")); + if(Util.getIntValue(treeNode.getPid(),0) == 0){ + pids.add(treeNode.getKey()); + } + + if("1".equals(rightData.get(treeNode.getDomid()))){ + treeNode.setHasRight(true); + } + + Map map = new HashMap(); + map.put("domid", treeNode.getDomid()); + map.put("keyid", treeNode.getKey() + ""); + + treeNode.setName(Util.toScreen(rs.getString("categoryname"),user.getLanguage())); + treeNode.setEcologyPinyinSearch(rs.getString("ecology_pinyin_search")); + } + + //根据有权限查看的文档的目录,逆向找到所在根(包括中间节点)(无层级关系) + Map newData = new HashMap(); + for(String key : rightData.keySet()){ + String nkey = key; + while(allData.get(nkey) != null && newData.get(nkey) == null){ + newData.put(nkey,allData.get(nkey)); + nkey = SecTreeNode.NODE_PREV + allData.get(nkey).getPid(); + } + } + + //将过滤后的节点组装成树结构(有层级关系) + for(String id : ids){ + SecTreeNode data = newData.get(SecTreeNode.NODE_PREV + id); + if(data == null) + continue; + + String keyid = SecTreeNode.NODE_PREV + data.getPid(); + if(newData.get(keyid) == null) + continue; + + newData.remove(data); + List childs = null; + if(newData.get(keyid).getChilds() == null){ + childs = new ArrayList(); + newData.get(keyid).setChilds(childs); + }else{ + childs = newData.get(keyid).getChilds(); + } + newData.get(keyid).setHaschild(true); + + childs.add(data); + } + + //将所有组装成的根节点放到treelist中 + List treeData = new ArrayList(); + for(String pid : pids){ + if(newData.get(SecTreeNode.NODE_PREV + pid) != null){ + treeData.add(newData.get(SecTreeNode.NODE_PREV + pid)); + } + } + + /** + * 前端组件要求:treedata中的树节点与treecount配对的节点才会渲染,不匹配的全部跳过 + * */ + apidatas.put("treedata",treeData); + apidatas.put("openNewWind","1"); + } + return apidatas; + } +} diff --git a/src/main/java/com/api/odoc/util/DocReceiveUnitSyncBySubUtil.java b/src/main/java/com/api/odoc/util/DocReceiveUnitSyncBySubUtil.java new file mode 100644 index 0000000..2715456 --- /dev/null +++ b/src/main/java/com/api/odoc/util/DocReceiveUnitSyncBySubUtil.java @@ -0,0 +1,376 @@ +package com.api.odoc.util; + +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.TimeUtil; +import java.util.Map; +import java.util.HashMap; +import java.util.List; +import java.util.ArrayList; +import weaver.general.Util; + +public class DocReceiveUnitSyncBySubUtil extends BaseBean { + public void syncdata(){ + String currentDate = TimeUtil.getCurrentDateString(); + String currentTime = TimeUtil.getCurrentTimeString().substring(11); + new BaseBean().writeLog("currentDate = "+currentDate+",currentTime="+currentTime); + RecordSet rs = new RecordSet(); + RecordSet rs2 = new RecordSet(); + String departmentname = ""; + String subcompanyid1 = ""; + String supdepid = ""; + String receiverids = ""; + String issynchronizefromexchange =""; + rs.executeQuery("select departmentname,subcompanyid1,supdepid from hrmdepartment where created like '%"+currentDate+"%'"); + while(rs.next()){ + departmentname = Util.null2String(rs.getString("departmentname")); + subcompanyid1 = Util.null2String(rs.getString("subcompanyid1")); + supdepid = Util.null2String(rs.getString("supdepid")); + rs2.executeQuery("select 1 from docreceiveunit where receiveunitname =? and subcompanyid=? ",departmentname,subcompanyid1); + if(rs2.next()){ + rs.writeLog("DocReceiveUnitSyncBySubUtil syncdata,此部门在收发文单位处已进行同步"); + continue; + }else{ + rs.executeUpdate("insert into DOCRECEIVEUNIT(receiveunitname,superiorunitid,receiverids,allsuperiorunitid,unitlevel,canceled,companytype,ismain,changedir,subcompanyid,canstartchildrequest,showorder,unitcode,ischange,systemcode,issynchronizefromexchange,distinguish)values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", + departmentname,0, receiverids, 0, 1, null, 0, null, null, subcompanyid1, 1, 0.0, null, null, null,issynchronizefromexchange, 1 ); + + } + } + //插入数据到部门表 + } + + /** + * 同步单个分部作为收发文单位 + * @param subcompanyid1 所在分部id + * @param subcompanyname 新增或者编辑时的分部名称 + * @param receiverids 分部的收发文员 + * @return + */ + public boolean syncSingleSubUnitData(int subcompanyid1,String subcompanyname,String receiverids){ + boolean retFlag = false; + RecordSet rs = new RecordSet(); + String issynchronizefromexchange =""; + rs.writeLog("syncSingleSubUnitData start subcompanyid1="+subcompanyid1+",subcompanyname="+subcompanyname+",receiverids="+receiverids); + rs.executeQuery("select id from docreceiveunit where relativesub=? and (canceled is null or canceled<>'1') ",subcompanyid1); + if(rs.next()){ + rs.executeQuery("select id from docreceiveunit where relativesub=? and (canceled is null or canceled<>'1') ",subcompanyid1); + while(rs.next()){ + int id = Util.getIntValue(rs.getString("id"),-1); + rs.executeUpdate("update docreceiveunit set receiverids=? where id=?",receiverids,id); + rs.executeUpdate("delete from docreceiveunit_source where unitid=? and (hrmdistinguish='0' or hrmdistinguish='' or hrmdistinguish is null) ",id); + rs.writeLog("syncSingleSubUnitData 删除分部收发文员sql:delete from docreceiveunit_source where unitid="+id+" and (hrmdistinguish='0' or hrmdistinguish='' or hrmdistinguish is null) "); + if(!receiverids.equals("")){ + String receiverid = ""; + String[] receiverid1=Util.TokenizerString2(receiverids,","); + boolean isInsertgsh = false; + boolean isInsertnull = false; + for(int i=0;i'1')", subcompanyid1); + if (!rs.next()) { + rs.executeUpdate("insert into DOCRECEIVEUNIT(receiveunitname,superiorunitid,receiverids,allsuperiorunitid,unitlevel,canceled,companytype,ismain,changedir,subcompanyid,canstartchildrequest,showorder,unitcode,ischange,systemcode,issynchronizefromexchange,distinguish,relativesub)values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", subcompanyname, 0, receiverids, 0, 1, null, 0, null, null, subcompanyid1, 1, 0.0D, null, null, null, issynchronizefromexchange, 0, subcompanyid1); + } + + rs.executeQuery("select id from docreceiveunit where distinguish=0 and relativesub =? and subcompanyid=? and (canceled is null or canceled<>'1')", subcompanyid1,subcompanyid1); + if (rs.next()) { + id = Util.getIntValue(rs.getString("id"), -1); + } + } else { + rs.executeQuery("select id from docreceiveunit where distinguish=0 and relativesub is null and subcompanyid=? and (canceled is null or canceled<>'1')", supsubcomid); + if (rs.next()) { + id = Util.getIntValue(rs.getString("id"), -1); + rs.writeLog("syncSingleSubUnitData id =" + id); + rs.executeUpdate("insert into DOCRECEIVEUNIT(receiveunitname,superiorunitid,receiverids,allsuperiorunitid,unitlevel,canceled,companytype,ismain,changedir,subcompanyid,canstartchildrequest,showorder,unitcode,ischange,systemcode,issynchronizefromexchange,distinguish,relativesub)values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", subcompanyname, id, receiverids, 0, 1, null, 0, null, null, supsubcomid, 1, 0.0D, null, null, null, issynchronizefromexchange, 0, subcompanyid1); + } + } + + + String receiverid = ""; + if(supsubcomid.equals("0")){ + rs.executeQuery("select id from docreceiveunit where receiveunitname=? and id=? and (canceled is null or canceled<>'1') order by id desc", subcompanyname,id); + }else{ + rs.executeQuery("select id from docreceiveunit where receiveunitname=? and superiorunitid=? and (canceled is null or canceled<>'1') order by id desc", subcompanyname,id); + } + if (rs.next()) { + int newid = Util.getIntValue(rs.getString("id"),-1); + rs.executeUpdate("delete from docreceiveunit_source where unitid=? ", newid); + if(!receiverids.equals("")){ + String[] receiverid1=Util.TokenizerString2(receiverids,","); + boolean isInsertgsh = false; + boolean isInsertnull = false; + for(int i=0;i0){//是二级部门 + //如果开启了同步二级及以下部门 + if(isSycnSeconedDep){ + rs.executeQuery("select id from docreceiveunit where relativedep=? and (canceled is null or canceled<>'1') ",departmentid); + if(rs.next()){//能找到匹配的单位,做更新收发文员处理 + rs.executeQuery("select id from docreceiveunit where relativedep=? and (canceled is null or canceled<>'1') ",departmentid); + while(rs.next()){ + int id = Util.getIntValue(rs.getString("id"),-1); + rs.writeLog("syncSingleDepUnitData id= "+id); + rs.executeUpdate("update docreceiveunit set receiverids=? where id=?",departmentname,receiverids,id); + rs.executeUpdate("delete from docreceiveunit_source where unitid=? and hrmdistinguish=1 ",id); + if(!receiverids.equals("")){ + String receiverid = ""; + String[] receiverid1=Util.TokenizerString2(receiverids,","); + for(int i=0;i<1;i++){ + receiverid = receiverid1[i]; + String[] receiverid2 = Util.TokenizerString2(receiverid,"_"); + if(receiverid2[0].equals("部门函")){ + rs.executeUpdate("insert into docreceiveunit_source(unitid,type,content,secLevelFrom,secLevelTo,lowerlevel,subcompanyid,departmentid,relatedlevel,hrmdistinguish) values(?,1,?,0,0,0,0,0,0,'1')", id,receiverid2[1]); + } + if(receiverid2[0].equals("公司函")&&false){ + rs.executeUpdate("insert into docreceiveunit_source(unitid,type,content,secLevelFrom,secLevelTo,lowerlevel,subcompanyid,departmentid,relatedlevel,hrmdistinguish) values(?,1,?,0,0,0,0,0,0,'0')", id,receiverid2[1]); + } + if(receiverid2[0].equals("空")){ + rs.executeUpdate("insert into docreceiveunit_source(unitid,type,content,secLevelFrom,secLevelTo,lowerlevel,subcompanyid,departmentid,relatedlevel,hrmdistinguish) values(?,1,?,0,0,0,0,0,0,'')", id,receiverid2[1]); + } + } + } + } + rs.writeLog("syncSingleDepUnitData end "); + retFlag = true; + return retFlag; + }else{//找不到此部门对应的单位,进入新建单位逻辑,把单位生成到此部门的上级部门同步过来的收发文单位下 + rs.executeQuery("select id from docreceiveunit where relativedep=? and (canceled is null or canceled<>'1') ",supdepid); + if(rs.next()){ + rs.executeUpdate("insert into DOCRECEIVEUNIT(receiveunitname,superiorunitid,receiverids,allsuperiorunitid,unitlevel,canceled,companytype,ismain,changedir,subcompanyid,canstartchildrequest,showorder,unitcode,ischange,systemcode,issynchronizefromexchange,distinguish,relativedep)values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", + departmentname,0, receiverids, 0, 1, null, 0, null, null, subcompanyid1, 1, 0.0, null, null, null,issynchronizefromexchange, 1,departmentid ); + String receiverid = ""; + rs.executeQuery("select id from docreceiveunit where receiveunitname=? and relativedep=? and (canceled is null or canceled<>'1') order by id desc",departmentname,departmentid); + if(rs.next()){ + int newid = Util.getIntValue(rs.getString("id"),-1); + rs.executeUpdate("delete from docreceiveunit_source where unitid=?",newid); + if(!receiverids.equals("")){ + String[] receiverid1=Util.TokenizerString2(receiverids,","); + for(int i=0;i<1;i++){ + receiverid = receiverid1[i]; + String[] receiverid2 = Util.TokenizerString2(receiverid,"_"); + if(receiverid2[0].equals("部门函")){ + rs.executeUpdate("insert into docreceiveunit_source(unitid,type,content,secLevelFrom,secLevelTo,lowerlevel,subcompanyid,departmentid,relatedlevel,hrmdistinguish) values(?,1,?,0,0,0,0,0,0,'1')", newid,receiverid2[1]); + } + if(receiverid2[0].equals("公司函")&&false){ + rs.executeUpdate("insert into docreceiveunit_source(unitid,type,content,secLevelFrom,secLevelTo,lowerlevel,subcompanyid,departmentid,relatedlevel,hrmdistinguish) values(?,1,?,0,0,0,0,0,0,'0')", newid,receiverid2[1]); + } + if(receiverid2[0].equals("空")){ + rs.executeUpdate("insert into docreceiveunit_source(unitid,type,content,secLevelFrom,secLevelTo,lowerlevel,subcompanyid,departmentid,relatedlevel,hrmdistinguish) values(?,1,?,0,0,0,0,0,0,'')", newid,receiverid2[1]); + } + } + } + } + rs.writeLog("syncSingleDepUnitData 此单位是二级单位,生产收发文单位,并且作为此部门的上级部门同步过来的收发文单位的下级单位"); + }else{ + rs.writeLog("syncSingleDepUnitData 此单位是二级单位,无法找到此部门的上级部门同步过来的收发文单位"); + } + retFlag = true; + rs.writeLog("syncSingleDepUnitData end "); + return retFlag; + } + }else{//未开启了同步二级及以下部门功能,不做任何操作 + rs.writeLog("syncSingleDepUnitData 此单位是二级单位,未开启同步二级及以下部门功能"); + retFlag = true; + rs.writeLog("syncSingleDepUnitData end "); + return retFlag; + } + + }else{//是一级部门 + rs.writeLog("syncSingleDepUnitData departmentid="+departmentid+",subcompanyid1="+subcompanyid1+",departmentname="+departmentname+",receiverids="+receiverids); + rs.executeQuery("select id from docreceiveunit where relativedep=? and (canceled is null or canceled<>'1') ",departmentid); + if(rs.next()){ + rs.executeQuery("select id from docreceiveunit where relativedep=? and (canceled is null or canceled<>'1') ",departmentid); + while(rs.next()){ + int id = Util.getIntValue(rs.getString("id"),-1); + rs.writeLog("syncSingleDepUnitData id= "+id); + rs.executeUpdate("update docreceiveunit set receiveunitname=?,receiverids=? where id=?",departmentname,receiverids,id); + rs.executeUpdate("delete from docreceiveunit_source where unitid=? and hrmdistinguish=1",id); + if(!receiverids.equals("")){ + String receiverid = ""; + String[] receiverid1=Util.TokenizerString2(receiverids,","); + for(int i=0;i<1;i++){ + receiverid = receiverid1[i]; + String[] receiverid2 = Util.TokenizerString2(receiverid,"_"); + if(receiverid2[0].equals("部门函")){ + rs.executeUpdate("insert into docreceiveunit_source(unitid,type,content,secLevelFrom,secLevelTo,lowerlevel,subcompanyid,departmentid,relatedlevel,hrmdistinguish) values(?,1,?,0,0,0,0,0,0,'1')", id,receiverid2[1]); + } + if(receiverid2[0].equals("公司函")&&false){ + rs.executeUpdate("insert into docreceiveunit_source(unitid,type,content,secLevelFrom,secLevelTo,lowerlevel,subcompanyid,departmentid,relatedlevel,hrmdistinguish) values(?,1,?,0,0,0,0,0,0,'0')", id,receiverid2[1]); + } + if(receiverid2[0].equals("空")){ + rs.executeUpdate("insert into docreceiveunit_source(unitid,type,content,secLevelFrom,secLevelTo,lowerlevel,subcompanyid,departmentid,relatedlevel,hrmdistinguish) values(?,1,?,0,0,0,0,0,0,'')", id,receiverid2[1]); + } + } + } + } + }else{ + rs.writeLog("syncSingleDepUnitData no id"); + rs.executeUpdate("insert into DOCRECEIVEUNIT(receiveunitname,superiorunitid,receiverids,allsuperiorunitid,unitlevel,canceled,companytype,ismain,changedir,subcompanyid,canstartchildrequest,showorder,unitcode,ischange,systemcode,issynchronizefromexchange,distinguish,relativedep)values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", + departmentname,0, receiverids, 0, 1, null, 0, null, null, subcompanyid1, 1, 0.0, null, null, null,issynchronizefromexchange, 1,departmentid ); + + String receiverid = ""; + rs.executeQuery("select id from docreceiveunit where receiveunitname=? and relativedep=? and (canceled is null or canceled<>'1') order by id desc",departmentname,departmentid); + if(rs.next()){ + int newid = Util.getIntValue(rs.getString("id"),-1); + rs.executeUpdate("delete from docreceiveunit_source where unitid=?",newid); + if(!receiverids.equals("")){ + String[] receiverid1=Util.TokenizerString2(receiverids,","); + for(int i=0;i<1;i++){ + receiverid = receiverid1[i]; + String[] receiverid2 = Util.TokenizerString2(receiverid,"_"); + if(receiverid2[0].equals("部门函")){ + rs.executeUpdate("insert into docreceiveunit_source(unitid,type,content,secLevelFrom,secLevelTo,lowerlevel,subcompanyid,departmentid,relatedlevel,hrmdistinguish) values(?,1,?,0,0,0,0,0,0,'1')", newid,receiverid2[1]); + } + if(receiverid2[0].equals("公司函")&&false){ + rs.executeUpdate("insert into docreceiveunit_source(unitid,type,content,secLevelFrom,secLevelTo,lowerlevel,subcompanyid,departmentid,relatedlevel,hrmdistinguish) values(?,1,?,0,0,0,0,0,0,'0')", newid,receiverid2[1]); + } + if(receiverid2[0].equals("空")){ + rs.executeUpdate("insert into docreceiveunit_source(unitid,type,content,secLevelFrom,secLevelTo,lowerlevel,subcompanyid,departmentid,relatedlevel,hrmdistinguish) values(?,1,?,0,0,0,0,0,0,'')", newid,receiverid2[1]); + } + } + } + } + + + } + rs.writeLog("syncSingleDepUnitData end "); + retFlag = true; + return retFlag; + } + } + + /** + * 传递了多个多个的情况下,遍历list数据,然后调用单个同步部门作为收发文单位的逻辑,给部门矩阵用 + * @param list + * @return + */ + public boolean syncDepsUnitData(List> list){ + boolean retFlag = false; + //List> list = new ArrayList(Map); + Map map= new HashMap(); + int subcompanyid1 = 0; + String departmentname = ""; + String receiverids = ""; + String departmentid = ""; + RecordSet rs = new RecordSet(); + rs.writeLog("syncDepsUnitData start"); + for(int i=0;i> list){ + boolean retFlag = false; + //List> list = new ArrayList(Map); + Map map= new HashMap(); + //map.put("subcompanyid","202"); + //map.put("subcompanyname","测试分部001"); + //map.put("receiverids","23,78"); + //list.add(map); + RecordSet rs = new RecordSet(); + rs.writeLog("syncSubsUnitData start"); + int subcompanyid1 = 0; + String subcompanyname = ""; + String receiverids = ""; + for(int i=0;i获取更新语句 * @param tableName 表名 @@ -230,4 +236,29 @@ public class CommonUtil { throw new NoSuchFieldException(fieldName); } } + + public static int getDateInfo(String dateString, int field){ + Map formatMap = new HashMap<>(); + formatMap.put(4, "yyyy"); + formatMap.put(7, "yyyy-MM"); + formatMap.put(10, "yyyy-MM-dd"); + formatMap.put(13, "yyyy-MM-dd HH"); + formatMap.put(16, "yyyy-MM-dd HH:mm"); + formatMap.put(19, "yyyy-MM-dd HH:mm:ss"); + try { + int length = dateString.length(); + String formatString = formatMap.get(length); + if (formatString == null) { + throw new IllegalArgumentException("Invalid date string length: " + length); + } + SimpleDateFormat format = new SimpleDateFormat(formatString); + Date date = format.parse(dateString); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + return calendar.get(field); + }catch (Exception e){ + logger.error("时间格式化异常 ==>"+Util.getErrString(e)); + return -1; + } + } } diff --git a/src/main/java/weaver/bokang/xiao/dloa/entity/ApiConfig.java b/src/main/java/weaver/bokang/xiao/dloa/entity/ApiConfig.java new file mode 100644 index 0000000..3e1d694 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/dloa/entity/ApiConfig.java @@ -0,0 +1,19 @@ +package weaver.bokang.xiao.dloa.entity; + +import lombok.Data; + +import java.util.List; + +/** + * @ClassName ApiConfig + * @Author 肖博亢 + * @Date 2023/6/21 15:50 + * @Description

+ **/ +@Data +public class ApiConfig { + private int id; + private String requestUnique; + private String apiDesc; + private List apiConfigDetailList; +} diff --git a/src/main/java/weaver/bokang/xiao/dloa/entity/ApiConfigDetail.java b/src/main/java/weaver/bokang/xiao/dloa/entity/ApiConfigDetail.java new file mode 100644 index 0000000..1f6acbb --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/dloa/entity/ApiConfigDetail.java @@ -0,0 +1,18 @@ +package weaver.bokang.xiao.dloa.entity; + +import lombok.Data; + +/** + * @ClassName ApiConfigDetail + * @Author 肖博亢 + * @Date 2023/6/21 15:51 + * @Description

+ **/ +@Data +public class ApiConfigDetail { + private int id; + private String paramName; + private String paramValue; + private String paramDesc; + private String paramStatus; +} diff --git a/src/main/java/weaver/bokang/xiao/dloa/entity/LogEntity.java b/src/main/java/weaver/bokang/xiao/dloa/entity/LogEntity.java new file mode 100644 index 0000000..555180b --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/dloa/entity/LogEntity.java @@ -0,0 +1,23 @@ +package weaver.bokang.xiao.dloa.entity; + +import lombok.Data; + +/** + * @ClassName LogEntity + * @Author 肖博亢 + * @Date 2023/6/21 15:55 + * @Description

+ **/ +@Data +public class LogEntity { + private int id; + private int syncType; + private String syncHrm; + private String syncDepart; + private String syncTime; + private int syncStatus; + private String failMsg; + private String requestUrl; + private String requestJson; + private String responseJson; +} diff --git a/src/main/java/weaver/bokang/xiao/dloa/mapper/SyncHrmMapper.java b/src/main/java/weaver/bokang/xiao/dloa/mapper/SyncHrmMapper.java new file mode 100644 index 0000000..9ddb8e8 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/dloa/mapper/SyncHrmMapper.java @@ -0,0 +1,52 @@ +package weaver.bokang.xiao.dloa.mapper; + +import aiyh.utils.annotation.recordset.*; +import weaver.bokang.xiao.dloa.entity.ApiConfig; +import weaver.bokang.xiao.dloa.entity.ApiConfigDetail; +import weaver.bokang.xiao.dloa.entity.LogEntity; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName SyncHrmMapper + * @Author 肖博亢 + * @Date 2023/6/21 15:52 + * @Description

+ **/ +@SqlMapper +public interface SyncHrmMapper { + + @Select("select * from uf_api_config where request_unique = #{unique}") + @CollectionMappings({ + @CollectionMapping(property = "apiConfigDetailList",column = "id",id = @Id(value = Integer.class,methodId = 1)) + }) + ApiConfig queryApiConfigByUnique(@ParamMapper("unique") String unique); + + @Select("select * from uf_api_config_dt1 where mainid = #{mainId} and param_status = 0") + @CollectionMethod(1) + List queryDetail(@ParamMapper("mainId") int mainId); + + @Select("select * from hrm_cus " + + " where created = modified and created between #{beginDate} and #{endDate}") + @ToLowerCase + List> queryHrmAddList(@ParamMapper("beginDate") String beginDate, @ParamMapper("endDate") String endDate); + + @Select("select * from hrm_cus " + + " where (modified > created and modified between #{beginDate} and #{endDate}) or (modifydate between #{beginDate} and #{endDate})") + @ToLowerCase + List> queryHrmUpdatedList(@ParamMapper("beginDate") String beginDate, @ParamMapper("endDate") String endDate); + + @Select("select * from hrmdepartment " + + " where created = modified and created between #{beginDate} and #{endDate}") + @ToLowerCase + List> queryDepartAddList(@ParamMapper("beginDate") String beginDate, @ParamMapper("endDate") String endDate); + + @Select("select * from hrmdepartment " + + " where modified > created and modified between #{beginDate} and #{endDate}") + @ToLowerCase + List> queryDepartUpdatedList(@ParamMapper("beginDate") String beginDate, @ParamMapper("endDate") String endDate); + + @Update("update uf_sync_log set sync_type = #{syncType}, sync_hrm = #{syncHrm}, sync_depart = #{syncDepart}, sync_time = #{syncTime}, sync_status = #{syncStatus}, fail_msg = #{failMsg}, request_url = #{requestUrl}, request_json = #{requestJson}, response_json = #{responseJson} where id = #{id}") + boolean updateSyncLog(LogEntity logEntity); +} diff --git a/src/main/java/weaver/bokang/xiao/dloa/schedule/HrmSyncSchedule.java b/src/main/java/weaver/bokang/xiao/dloa/schedule/HrmSyncSchedule.java new file mode 100644 index 0000000..1c80ca2 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/dloa/schedule/HrmSyncSchedule.java @@ -0,0 +1,348 @@ +package weaver.bokang.xiao.dloa.schedule; + +import aiyh.utils.Util; +import aiyh.utils.action.CusBaseCronJob; +import aiyh.utils.annotation.ActionDesc; +import aiyh.utils.annotation.ActionOptionalParam; +import aiyh.utils.annotation.PrintParamMark; +import aiyh.utils.annotation.RequiredMark; +import aiyh.utils.excention.CustomerException; +import aiyh.utils.httpUtil.ResponeVo; +import aiyh.utils.httpUtil.util.HttpUtils; +import com.alibaba.fastjson.JSON; +import lombok.Setter; +import org.apache.commons.lang3.StringUtils; +import weaver.bokang.xiao.common.CommonUtil; +import weaver.bokang.xiao.dloa.entity.ApiConfig; +import weaver.bokang.xiao.dloa.entity.ApiConfigDetail; +import weaver.bokang.xiao.dloa.entity.LogEntity; +import weaver.bokang.xiao.dloa.mapper.SyncHrmMapper; +import weaver.general.TimeUtil; +import weaver.xiao.commons.config.entity.RequestMappingConfig; +import weaver.xiao.commons.config.service.DealWithMapping; + +import java.io.IOException; +import java.util.*; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +/** + * @ClassName HrmSyncSchedule + * @Author 肖博亢 + * @Date 2023/6/21 16:03 + * @Description

+ **/ +@Setter +@ActionDesc(value = "组织架构U8同步", author = "bokang.xiao") +public class HrmSyncSchedule extends CusBaseCronJob { + + @RequiredMark("获取tradeId唯一标识") + @PrintParamMark + private String getTradeIdRequestMark; + + @RequiredMark("获取token唯一标识") + @PrintParamMark + private String getTokenRequestMark; + + @RequiredMark("添加人员请求唯一标识") + @PrintParamMark + private String hrmAddRequestMark; + + @RequiredMark("更新人员请求唯一标识") + @PrintParamMark + private String hrmUpdatedRequestMark; + + @RequiredMark("添加部门请求唯一标识") + @PrintParamMark + private String departAddRequestMark; + + @RequiredMark("更新部门请求唯一标识") + @PrintParamMark + private String departUpdatedRequestMark; + + @RequiredMark("日志模块ID") + @PrintParamMark + private String logModeId; + + @PrintParamMark + @ActionOptionalParam(value = "",desc = "同步开始日期") + private String beginDate; + + @PrintParamMark + @ActionOptionalParam(value = "",desc = "同步结束日期") + private String endDate; + + private String appToken = ""; + + private final SyncHrmMapper syncHrmMapper = Util.getMapper(SyncHrmMapper.class); + + private final HttpUtils httpUtils = new HttpUtils(); + + private final DealWithMapping dealWithMapping = new DealWithMapping(); + + private static final Map message = new HashMap<>(); + + static { + message.put(0, "人员"); + message.put(1, "部门"); + } + + + @Override + public void runCode() throws IOException { + appToken = ""; + if(StringUtils.isBlank(beginDate) && StringUtils.isBlank(endDate)){ + String currentDateString = TimeUtil.getCurrentDateString(); + currentDateString = TimeUtil.dateAdd(currentDateString,-1); + beginDate = endDate = currentDateString; + } + List> hrmAddList = syncHrmMapper.queryHrmAddList(beginDate, endDate); + List> hrmUpdatedList = syncHrmMapper.queryHrmUpdatedList(beginDate, endDate); + List> tempUpdateList = CommonUtil.difference(hrmUpdatedList, hrmAddList, map -> map.get("id")); + List> departAddList = syncHrmMapper.queryDepartAddList(beginDate, endDate); + List> departUpdatedList = syncHrmMapper.queryDepartUpdatedList(beginDate, endDate); + log.info(String.format("hrmAddList ==> %s \n hrmUpdatedList ==> %s \n departAddList ==> %s departUpdatedList ==> %s" + ,JSON.toJSONString(hrmAddList) + ,JSON.toJSONString(tempUpdateList) + ,JSON.toJSONString(departAddList) + ,JSON.toJSONString(departUpdatedList) + )); + // 同步新增人员 + if (Objects.nonNull(hrmAddList) && !hrmAddList.isEmpty()) { + RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(hrmAddRequestMark); + ApiConfig apiConfig = syncHrmMapper.queryApiConfigByUnique(hrmAddRequestMark); + syncDeal(hrmAddList, requestMappingConfig, apiConfig, 0, 0); + } + + // 同步更新人员 + if (!tempUpdateList.isEmpty()) { + RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(hrmUpdatedRequestMark); + ApiConfig apiConfig = syncHrmMapper.queryApiConfigByUnique(hrmUpdatedRequestMark); + syncDeal(tempUpdateList, requestMappingConfig, apiConfig, 0, 1); + } + + // 同步新增部门 + if (Objects.nonNull(departAddList) && !departAddList.isEmpty()) { + RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(departAddRequestMark); + ApiConfig apiConfig = syncHrmMapper.queryApiConfigByUnique(departAddRequestMark); + syncDeal(departAddList, requestMappingConfig, apiConfig, 1, 0); + } + + // 同步更新部门 + if (Objects.nonNull(departUpdatedList) && !departUpdatedList.isEmpty()) { + RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(departUpdatedRequestMark); + ApiConfig apiConfig = syncHrmMapper.queryApiConfigByUnique(departUpdatedRequestMark); + syncDeal(departUpdatedList, requestMappingConfig, apiConfig, 1, 1); + } + } + + + /** + * 同步方法 + * + * @param syncList 同步列表 + * @param requestMappingConfig 请求配置详情 + * @param apiConfig api配置信息 + * @param syncType 同步类型 0:人员; 1:部门 + * @param dataType 类型 0:新增; 1:更新 + * @throws IOException + */ + private void syncDeal(List> syncList, + RequestMappingConfig requestMappingConfig, + ApiConfig apiConfig, + int syncType, int dataType) throws IOException { + Map header = new HashMap<>(8); + header.put("Content-Type", "application/json"); + List logList = new ArrayList<>(); + for (Map syncMap : syncList) { + String requestUrl = spliceRequestUrl(requestMappingConfig.getRequestUrl(), apiConfig); + Map requestParam = dealWithMapping.getRequestParam(syncMap, requestMappingConfig); + LogEntity logEntity = new LogEntity(); + logEntity.setSyncType(syncType); + logEntity.setRequestUrl(requestUrl); + logEntity.setRequestJson(JSON.toJSONString(requestParam)); + if (syncType == 0) { + logEntity.setSyncHrm(Util.null2String(syncMap.get("id"))); + } else { + logEntity.setSyncDepart(Util.null2String(syncMap.get("id"))); + } + logEntity.setSyncTime(TimeUtil.getCurrentTimeString()); + ResponeVo responeVo = httpUtils.apiPost(requestUrl, requestParam, header); + if (responeVo.getCode() == 200) { + Map result = responeVo.getResponseMap(); + logEntity.setResponseJson(JSON.toJSONString(result)); + String errCode = Util.null2String(result.get("errcode")); + int syncResult = "0".equals(errCode) ? 0 : 1; + logEntity.setSyncStatus(syncResult); + logEntity.setFailMsg(Util.null2String(result.get("errmsg"))); + } else { + logEntity.setSyncStatus(1); + logEntity.setFailMsg("接口状态不为200"); + log.error(String.format("%s 同步发生异常 接口响应不为200 ", message.get(syncType))); + } + int dataId = Util.getModeDataId("uf_sync_log", Util.getIntValue(logModeId), 1); + logEntity.setId(dataId); + syncHrmMapper.updateSyncLog(logEntity); + logList.add(dataId); + } + Util.rebuildModeDataShareByAsyncList(1, Util.getIntValue(logModeId), logList); + } + + + /** + * 同步方法 + * + * @param syncList 同步列表 + * @param requestMappingConfig 请求配置详情 + * @param apiConfig api配置信息 + * @param syncType 同步类型 0:人员; 1:部门 + * @throws IOException + */ + private void syncAddDeal(List> syncList, + RequestMappingConfig requestMappingConfig, + ApiConfig apiConfig, + int syncType) throws IOException, InterruptedException { + Map header = new HashMap<>(8); + header.put("Content-Type", "application/json"); + List logList = new ArrayList<>(); + CountDownLatch countDownLatch = new CountDownLatch(syncList.size()); + for (Map syncMap : syncList) { + String requestUrl = spliceRequestUrl(requestMappingConfig.getRequestUrl(), apiConfig); + Map requestParam = dealWithMapping.getRequestParam(syncMap, requestMappingConfig); + LogEntity logEntity = new LogEntity(); + logEntity.setSyncType(syncType); + logEntity.setRequestUrl(requestUrl); + logEntity.setRequestJson(JSON.toJSONString(requestParam)); + if (syncType == 0) { + logEntity.setSyncHrm(Util.null2String(syncMap.get("id"))); + } else { + logEntity.setSyncDepart(Util.null2String(syncMap.get("id"))); + } + logEntity.setSyncTime(TimeUtil.getCurrentTimeString()); + ResponeVo responeVo = httpUtils.apiPost(requestUrl, requestParam, header); + if (responeVo.getCode() == 200) { + Map result = responeVo.getResponseMap(); + logEntity.setResponseJson(JSON.toJSONString(result)); + String tradeId = Util.null2String(result.get("tradeid")); + if(StringUtils.isNotBlank(tradeId)){ + String url = Util.null2String(result.get("url")); + new Thread(() -> { + try { + Thread.sleep(3000); + ResponeVo realResponse = httpUtils.apiGet(url); + if(realResponse.getCode() == 200){ + Map responseMap = realResponse.getResponseMap(); + String errCode = Util.null2String(responseMap.get("errcode")); + int syncResult = "0".equals(errCode) ? 0 : 1; + logEntity.setSyncStatus(syncResult); + logEntity.setFailMsg(Util.null2String(responseMap.get("errmsg"))); + }else { + logEntity.setSyncStatus(1); + logEntity.setFailMsg("接口状态不为200"); + log.error(String.format("%s 同步发生异常 接口响应不为200 ", message.get(syncType))); + } + int dataId = Util.getModeDataId("uf_sync_log", Util.getIntValue(logModeId), 1); + logEntity.setId(dataId); + syncHrmMapper.updateSyncLog(logEntity); + }catch (Exception e){ + log.error("线程异常 ==>"+Util.getErrString(e)); + }finally { + countDownLatch.countDown(); + } + }).start(); + continue; + }else { + logEntity.setSyncStatus(1); + logEntity.setFailMsg(Util.null2String(result.get("errmsg"))); + } + } else { + logEntity.setSyncStatus(1); + logEntity.setFailMsg("接口状态不为200"); + log.error(String.format("%s 同步发生异常 接口响应不为200 ", message.get(syncType))); + } + countDownLatch.countDown(); + int dataId = Util.getModeDataId("uf_sync_log", Util.getIntValue(logModeId), 1); + logEntity.setId(dataId); + syncHrmMapper.updateSyncLog(logEntity); + logList.add(dataId); + } + try { + boolean await = countDownLatch.await(10, TimeUnit.MINUTES); + if(await){ + Util.rebuildModeDataShareByAsyncList(1, Util.getIntValue(logModeId), logList); + }else { + log.error("非正常结束 countDownLatch不能正确释放,请检查代码!!"); + while (countDownLatch.getCount() > 0){ + countDownLatch.countDown(); + } + } + } catch (Exception e) { + throw new CustomerException(e); + } + } + + /** + * 拼接请求地址 根据apiDetail 每一项的paramName 作为键,paramValue作为值 + * + * @param url 原请求地址 + * @param apiConfig api配置信息 + * @return + */ + private String spliceRequestUrl(String url, ApiConfig apiConfig) throws IOException { + StringBuilder requestUrlBuilder = new StringBuilder(url); + List apiConfigDetailList = apiConfig.getApiConfigDetailList(); + if("".equals(appToken)){ + this.getToken(); + } + if (apiConfigDetailList != null && !apiConfigDetailList.isEmpty()) { + requestUrlBuilder.append("?"); + requestUrlBuilder.append("token").append("=").append(appToken).append("&"); + for (ApiConfigDetail apiConfigDetail : apiConfigDetailList) { + String paramName = apiConfigDetail.getParamName(); + String paramValue = apiConfigDetail.getParamValue(); + requestUrlBuilder.append(paramName).append("=").append(paramValue).append("&"); + } + if(hrmAddRequestMark.equals(apiConfig.getRequestUnique()) || departAddRequestMark.equals(apiConfig.getRequestUnique())){ + requestUrlBuilder.append("tradeid").append("=").append(getTradeId()).append("&"); + } + requestUrlBuilder.deleteCharAt(requestUrlBuilder.length() - 1); + } + return requestUrlBuilder.toString(); + } + + private void getToken() throws IOException { + RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(getTokenRequestMark); + Map requestParam = dealWithMapping.getRequestParam(new HashMap<>(), requestMappingConfig); + ResponeVo responeVo = httpUtils.apiGet(requestMappingConfig.getRequestUrl(), requestParam, new HashMap<>()); + if (responeVo.getCode() == 200) { + Map result = responeVo.getResponseMap(); + String errCode = Util.null2String(result.get("errcode")); + String errMsg = Util.null2String(result.get("errmsg")); + if("0".equals(errCode)){ + Map token = (Map) result.get("token"); + appToken = Util.null2String(token.get("id")); + }else { + throw new CustomerException("获取token错误 ==>"+errMsg); + } + } else { + throw new CustomerException("获取token发生异常 接口响应不为200"); + } + } + + private String getTradeId() throws IOException { + RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(getTradeIdRequestMark); + Map requestParam = dealWithMapping.getRequestParam(new HashMap<>(), requestMappingConfig); + requestParam.put("token",this.appToken); + ResponeVo responeVo = httpUtils.apiGet(requestMappingConfig.getRequestUrl(), requestParam, new HashMap<>()); + String tradeId = ""; + if (responeVo.getCode() == 200) { + Map result = responeVo.getResponseMap(); + String errCode = Util.null2String(result.get("errcode")); + if("0".equals(errCode)){ + Map token = (Map) result.get("trade"); + tradeId = Util.null2String(token.get("id")); + } + } + return tradeId; + } +} \ No newline at end of file diff --git a/src/main/java/weaver/bokang/xiao/shtx/entity/ExamineConfig.java b/src/main/java/weaver/bokang/xiao/shtx/entity/ExamineConfig.java new file mode 100644 index 0000000..b34c05c --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/shtx/entity/ExamineConfig.java @@ -0,0 +1,40 @@ +package weaver.bokang.xiao.shtx.entity; + +import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName ExamineConfig + * @Author 肖博亢 + * @Date 2023/6/27 17:05 + * @Description

+ **/ +@Data +public class ExamineConfig { + + /** 配置描述 */ + @SqlOracleDbFieldAnn("CONFIG_DESC") + private String configDesc; + + /** 配置代码 */ + @SqlOracleDbFieldAnn("CONFIG_CODE") + private String configCode; + + /** 模型表 */ + @SqlOracleDbFieldAnn("MODEL_TABLE") + private String modelTable; + + /** 模型表名称 */ + @SqlOracleDbFieldAnn("MODEL_TABLE_NAME") + private String modelTableName; + + /** 指标信息 */ + private Map indexInformation; + + /** 配置明细 */ + private List examineConfigDetailList; + +} diff --git a/src/main/java/weaver/bokang/xiao/shtx/entity/ExamineConfigDetail.java b/src/main/java/weaver/bokang/xiao/shtx/entity/ExamineConfigDetail.java new file mode 100644 index 0000000..c1367ad --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/shtx/entity/ExamineConfigDetail.java @@ -0,0 +1,38 @@ +package weaver.bokang.xiao.shtx.entity; + +import aiyh.utils.annotation.recordset.SqlOracleDbFieldAnn; +import lombok.Data; + +/** + * @ClassName ExamineConfigDetail + * @Author 肖博亢 + * @Date 2023/6/27 17:05 + * @Description

+ **/ +@Data +public class ExamineConfigDetail { + + /** 条件类型 */ + @SqlOracleDbFieldAnn("CONDITION_TYPE") + private int conditionType; + + /** 条件字段 */ + @SqlOracleDbFieldAnn("CONDITION_FIELD") + private String conditionField; + + /** 判断规则 */ + @SqlOracleDbFieldAnn("JUDGMENT_RULE") + private int judgmentRule; + + /** 条件脚本 */ + @SqlOracleDbFieldAnn("CONDITION_SCRIPT") + private String conditionScript; + + /** 赋值脚本 */ + @SqlOracleDbFieldAnn("ASSIGN_SCRIPT") + private String assignScript; + + /** 条件字段名称 */ + @SqlOracleDbFieldAnn("CONDITION_FIELD_NAME") + private String conditionFieldName; +} diff --git a/src/main/java/weaver/bokang/xiao/shtx/entity/ScoreDataEntity.java b/src/main/java/weaver/bokang/xiao/shtx/entity/ScoreDataEntity.java new file mode 100644 index 0000000..04e06d0 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/shtx/entity/ScoreDataEntity.java @@ -0,0 +1,21 @@ +package weaver.bokang.xiao.shtx.entity; + +import lombok.Data; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName ScoreDataEntity + * @Author 肖博亢 + * @Date 2023/6/28 16:20 + * @Description

+ **/ +@Data +public class ScoreDataEntity { + + private List> scoreList; + + private List> modeInfoUpdateList; + +} diff --git a/src/main/java/weaver/bokang/xiao/shtx/mapper/ExamineMapper.java b/src/main/java/weaver/bokang/xiao/shtx/mapper/ExamineMapper.java new file mode 100644 index 0000000..9c5ff5e --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/shtx/mapper/ExamineMapper.java @@ -0,0 +1,53 @@ +package weaver.bokang.xiao.shtx.mapper; + +import aiyh.utils.annotation.recordset.*; +import weaver.bokang.xiao.shtx.entity.ExamineConfig; +import weaver.bokang.xiao.shtx.entity.ExamineConfigDetail; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName examineMapper + * @Author 肖博亢 + * @Date 2023/6/27 17:21 + * @Description

+ **/ +@SqlMapper +public interface ExamineMapper { + + @Select("select * from uf_examine_config") + @CollectionMappings({ + @CollectionMapping(property = "apiConfigDetailList",column = "id",id = @Id(value = Integer.class,methodId = 1)) + }) + @Associations({ + @Association(property = "indexInformation",column = "CONFIG_CODE",id = @Id(value = Integer.class,methodId = 2)) + }) + List queryApiConfig(); + + @Select("select * from uf_examine_config_dt1 where mainid = #{mainId}") + @CollectionMethod(1) + ExamineConfigDetail queryDetail(@ParamMapper("mainId") int mainId); + + @Select("select * from uf_examine_config where CONFIG_CODE = #{configCode}") + @CollectionMethod(2) + @ToLowerCase + Map queryIndexInformation(@ParamMapper("configCode") int configCode); + + @Select("select mode.*,cus.field7 position,cus.field8 coefficient " + + "from $t{tableName} mode " + + "left join cus_fielddata cus on mode.$t{teacherField} = cus.id and scope = 'HrmCustomFieldByInfoType' and SCOPEID = -1 " + + "where ($t{statusField} = 1 or $t{statusField} is null) and $t{dateField} between #{beginDate} and #{endDate}") + @ToLowerCase + List> queryModeInfoList(Map param); + + /** + *

执行自定义查询sql

+ * @param cusSql 自定义sql + * @param param 参数信息 + * @return 查询结果 + */ + @Select(custom = true) + boolean executeCusSql(@SqlString String cusSql, Map param); + +} diff --git a/src/main/java/weaver/bokang/xiao/shtx/mapper/ScoreMapper.java b/src/main/java/weaver/bokang/xiao/shtx/mapper/ScoreMapper.java new file mode 100644 index 0000000..f334bcf --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/shtx/mapper/ScoreMapper.java @@ -0,0 +1,30 @@ +package weaver.bokang.xiao.shtx.mapper; + +import aiyh.utils.annotation.recordset.*; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName ScoreMapper + * @Author 肖博亢 + * @Date 2023/6/28 16:48 + * @Description

+ **/ +@SqlMapper +public interface ScoreMapper { + /** + *

执行自定义更新sql

+ * @param cusSql 自定义sql + * @param updateParam 更新参数信息 + * @param whereParam 条件参数信息 + * @return 查询结果 + */ + @Update(custom = true) + boolean executeUpdateCusSql(@SqlString String cusSql, + @ParamMapper("updateParam") Map updateParam, + @ParamMapper("whereParam")Map whereParam); + + @BatchUpdate("update $t{tableName} set $t{item.statusField} = #{item.statusValue} where id = #{item.id}") + boolean batchUpdateModeStatus(@ParamMapper("tableName") String tableName,@BatchSqlArgs List> updateList); +} diff --git a/src/main/java/weaver/bokang/xiao/shtx/schedule/ExamineSchedule.java b/src/main/java/weaver/bokang/xiao/shtx/schedule/ExamineSchedule.java new file mode 100644 index 0000000..144e7b2 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/shtx/schedule/ExamineSchedule.java @@ -0,0 +1,133 @@ +package weaver.bokang.xiao.shtx.schedule; + +import aiyh.utils.Util; +import aiyh.utils.action.CusBaseCronJob; +import aiyh.utils.annotation.ActionDesc; +import aiyh.utils.annotation.ActionOptionalParam; +import aiyh.utils.annotation.PrintParamMark; +import aiyh.utils.annotation.RequiredMark; +import lombok.Setter; +import org.apache.commons.lang3.StringUtils; +import weaver.bokang.xiao.common.CommonUtil; +import weaver.bokang.xiao.shtx.entity.ScoreDataEntity; +import weaver.bokang.xiao.shtx.mapper.ExamineMapper; +import weaver.bokang.xiao.shtx.mapper.ScoreMapper; +import weaver.bokang.xiao.shtx.util.ExamineScoreUtil; +import weaver.general.TimeUtil; + +import java.io.IOException; +import java.util.*; + +/** + * @ClassName ExamineSchedule + * @Author 肖博亢 + * @Date 2023/6/28 11:49 + * @Description

+ **/ +@Setter +@ActionDesc(value = "专技岗评分处理", author = "bokang.xiao") +public class ExamineSchedule extends CusBaseCronJob { + + @RequiredMark("评分模块ID") + @PrintParamMark + private String scoreModeId; + + @PrintParamMark + @ActionOptionalParam(value = "",desc = "开始日期") + private String beginDate; + + @PrintParamMark + @ActionOptionalParam(value = "",desc = "结束日期") + private String endDate; + + private final ExamineMapper examineMapper = Util.getMapper(ExamineMapper.class); + + private final ScoreMapper scoreMapper = Util.getTransMapper(ScoreMapper.class); + + private final ExamineScoreUtil examineScoreUtil = new ExamineScoreUtil(); + + @Override + public void runCode() throws IOException { + examineScoreUtil.init(); + if(StringUtils.isBlank(beginDate) && StringUtils.isBlank(endDate)){ + beginDate = TimeUtil.getMonthBeginDay(); + endDate = TimeUtil.getMonthEndDay(); + } + //教学情况汇总表-数据处理 + Map queryParam = new HashMap<>(); + queryParam.put("tableName","uf_qkhz"); + queryParam.put("dateField","skrq"); + queryParam.put("statusField","pfzt"); + queryParam.put("teacherField","skls"); + queryParam.put("beginDate",beginDate); + queryParam.put("endDate",endDate); + ScoreDataEntity teachingSituation = this.doScoreGenerate(queryParam); + + //课程研发表-数据处理 + queryParam.put("tableName","uf_kcyf"); + queryParam.put("dateField","kcyfsj"); + queryParam.put("statusField","pfzt"); + queryParam.put("teacherField","zz"); + ScoreDataEntity curriculumDevelopment = this.doScoreGenerate(queryParam); + + //校内外教研资活动表-数据处理 + queryParam.put("tableName","uf_xnwjy"); + queryParam.put("dateField","hdsj"); + queryParam.put("statusField","pfzt"); + queryParam.put("teacherField","ls"); + ScoreDataEntity activityInfo = this.doScoreGenerate(queryParam); + + //科研与资政表-数据处理 + queryParam.put("tableName","uf_kyzz"); + queryParam.put("dateField","skrq"); + queryParam.put("statusField","pfzt"); + queryParam.put("teacherField","skls"); + ScoreDataEntity scientificInfo = this.doScoreGenerate(queryParam); + + //科研课题表单-数据处理 + queryParam.put("tableName","uf_kykt"); + queryParam.put("dateField","jlsj"); + queryParam.put("statusField","pfzt"); + queryParam.put("teacherField","skls"); + ScoreDataEntity subjectInfo = this.doScoreGenerate(queryParam); + + //科研成果表-数据处理 + queryParam.put("tableName","uf_kycg"); + queryParam.put("dateField","jlsj"); + queryParam.put("statusField","pfzt"); + queryParam.put("teacherField","skls"); + ScoreDataEntity achievementInfo = this.doScoreGenerate(queryParam); + + Util.commitTransMapper(ScoreMapper.class); + } + + /** + * 计算专技岗分数 + * @param queryParam 查询参数 + */ + private ScoreDataEntity doScoreGenerate(Map queryParam){ + String tableName = Util.null2String(queryParam.get("tableName")); + List> list = examineMapper.queryModeInfoList(queryParam); + ScoreDataEntity scoreDataEntity = examineScoreUtil.doComputeScore(queryParam,list); + if(Objects.nonNull(scoreDataEntity)){ + List> scoreList = scoreDataEntity.getScoreList(); + List> modeInfoUpdateList = scoreDataEntity.getModeInfoUpdateList(); + List scoreIdList = new ArrayList<>(); + if(Objects.nonNull(scoreList) && !scoreList.isEmpty()){ + for (Map scoreMap : scoreList) { + int dataId = Util.getModeDataId(tableName, Util.getIntValue(scoreModeId), 1); + scoreIdList.add(dataId); + Map whereParam = new HashMap<>(); + whereParam.put("id",dataId); + String updateSql = CommonUtil.getCusUpdateSql("", scoreMap, whereParam); + scoreMapper.executeUpdateCusSql(updateSql,scoreMap,whereParam); + } + Util.rebuildModeDataShareByAsyncList(1,Util.getIntValue(scoreModeId),scoreIdList); + } + if(Objects.nonNull(modeInfoUpdateList) && !modeInfoUpdateList.isEmpty()){ + scoreMapper.batchUpdateModeStatus(tableName,modeInfoUpdateList); + } + } + return scoreDataEntity; + } +} diff --git a/src/main/java/weaver/bokang/xiao/shtx/util/ExamineScoreUtil.java b/src/main/java/weaver/bokang/xiao/shtx/util/ExamineScoreUtil.java new file mode 100644 index 0000000..3527174 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/shtx/util/ExamineScoreUtil.java @@ -0,0 +1,121 @@ +package weaver.bokang.xiao.shtx.util; + +import aiyh.utils.ScriptUtil; +import aiyh.utils.Util; +import aiyh.utils.excention.CustomerException; +import com.alibaba.fastjson.JSON; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.bokang.xiao.common.CommonUtil; +import weaver.bokang.xiao.shtx.entity.ExamineConfig; +import weaver.bokang.xiao.shtx.entity.ExamineConfigDetail; +import weaver.bokang.xiao.shtx.entity.ScoreDataEntity; +import weaver.bokang.xiao.shtx.mapper.ExamineMapper; +import weaver.bokang.xiao.shtx.util.process.JudgmentRuleProcess; + +import java.util.*; +import java.util.function.BiFunction; +import java.util.stream.Collectors; + +/** + * @ClassName ExamineScoreUtil + * @Author 肖博亢 + * @Date 2023/6/28 13:57 + * @Description

+ **/ +public class ExamineScoreUtil { + + private final ExamineMapper EXAMINE_MAPPER = Util.getMapper(ExamineMapper.class); + private Map> configExamineMap = new HashMap<>(); + + public final Logger logger = Util.getLogger(); + + public ExamineScoreUtil(){ + } + + public void init(){ + List examineConfigList = EXAMINE_MAPPER.queryApiConfig(); + if(Objects.isNull(examineConfigList) || examineConfigList.isEmpty()){ + throw new CustomerException("绩效岗配置不能为空!!!"); + } + try { + configExamineMap = examineConfigList.stream().collect(Collectors.groupingBy(ExamineConfig::getModelTableName)); + logger.error("ExamineScoreUtil 初始化成功 ==>"+ JSON.toJSONString(configExamineMap)); + }catch (Exception e){ + logger.error("ExamineScoreUtil 初始化失败 ==>"+Util.getErrString(e)); + } + } + + public ScoreDataEntity doComputeScore(Map queryParam,List> modeInfoList){ + String tableName = Util.null2String(queryParam.get("tableName")); + String dateField = Util.null2String(queryParam.get("dateField")); + String teacherField = Util.null2String(queryParam.get("teacherField")); + List examineConfigList = configExamineMap.get(tableName); + if(Objects.isNull(examineConfigList) || examineConfigList.isEmpty()){ + logger.info(String.format("没有与此建模 %s 关联的配置信息 ",examineConfigList)); + return null; + } + ScoreDataEntity scoreDataEntity = new ScoreDataEntity(); + List> scoreList = new ArrayList<>(); + List> modeInfoUpdateList = new ArrayList<>(); + scoreDataEntity.setScoreList(scoreList); + scoreDataEntity.setModeInfoUpdateList(modeInfoUpdateList); + for (Map modeInfo : modeInfoList) { + for (ExamineConfig examineConfig : examineConfigList) { + List examineConfigDetailList = examineConfig.getExamineConfigDetailList(); + for (ExamineConfigDetail examineConfigDetail : examineConfigDetailList) { + int conditionType = examineConfigDetail.getConditionType(); + boolean conditionResult = conditionType == 0 ? fieldCondition(examineConfigDetail,modeInfo) + : scriptCondition(examineConfigDetail,modeInfo); + if(conditionResult){ + Map indexInformation = examineConfig.getIndexInformation(); + String assignScript = examineConfigDetail.getAssignScript(); + double score = (double) ScriptUtil.invokeScript(assignScript, modeInfo); + Map scoreInfo = new HashMap<>(); + String dateInfo = Util.null2String(modeInfo.get(dateField)); + int month = CommonUtil.getDateInfo(dateInfo, Calendar.MONTH) + 1; + int year = CommonUtil.getDateInfo(dateInfo, Calendar.YEAR); + int quarter = month / 3 + 1; + scoreInfo.put("score_type",Util.null2String(indexInformation.get("lb"))); + scoreInfo.put("config_code",examineConfig.getConfigCode()); + scoreInfo.put("config_name",Util.null2String(indexInformation.get("sjzb"))); + scoreInfo.put("score_basis",Util.null2String(indexInformation.get("pfyj"))); + scoreInfo.put("data_source",examineConfig.getModelTable()); + scoreInfo.put("score_month",month); + scoreInfo.put("score_year",year); + scoreInfo.put("score_quarter",quarter); + scoreInfo.put("score_date",dateInfo); + scoreInfo.put("teacher",Util.null2String(modeInfo.get(teacherField))); + scoreInfo.put("coefficient",Util.getDoubleValue(Util.null2String(modeInfo.get("coefficient")))); + scoreInfo.put("position",Util.null2String(modeInfo.get("position"))); + scoreInfo.put("final_score",score); + scoreList.add(scoreInfo); + break; + } + } + } + modeInfo.put("statusValue",0); + modeInfo.put("statusField","pfzt"); + modeInfoUpdateList.add(modeInfo); + } + return scoreDataEntity; + } + + public boolean scriptCondition(ExamineConfigDetail examineConfigDetail,Map modeInfo){ + String conditionScript = examineConfigDetail.getConditionScript(); + if(StringUtils.isBlank(conditionScript)){ + return false; + } + try{ + return (boolean) ScriptUtil.invokeScript(conditionScript,modeInfo); + }catch (Exception e){ + logger.error("执行表达式异常 ==>"+Util.getErrString(e)); + return false; + } + } + + public boolean fieldCondition(ExamineConfigDetail examineConfigDetail,Map modeInfo){ + BiFunction, Boolean> fieldConditionFunction = JudgmentRuleProcess.METHOD_MAP.get(examineConfigDetail.getJudgmentRule()); + return fieldConditionFunction.apply(examineConfigDetail, modeInfo); + } +} diff --git a/src/main/java/weaver/bokang/xiao/shtx/util/process/JudgmentRuleProcess.java b/src/main/java/weaver/bokang/xiao/shtx/util/process/JudgmentRuleProcess.java new file mode 100644 index 0000000..c892667 --- /dev/null +++ b/src/main/java/weaver/bokang/xiao/shtx/util/process/JudgmentRuleProcess.java @@ -0,0 +1,76 @@ +package weaver.bokang.xiao.shtx.util.process; + +import aiyh.utils.Util; +import aiyh.utils.annotation.MethodRuleNo; +import com.icbc.api.internal.apache.http.E; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import weaver.bokang.xiao.shtx.entity.ExamineConfigDetail; +import weaver.bokang.xiao.shtx.mapper.ExamineMapper; +import weaver.bokang.xiao.zscq.config.function.ConditionFunction; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.function.BiFunction; + +/** + * @ClassName JudgmentRuleProcess + * @Author 肖博亢 + * @Date 2023/6/28 10:55 + * @Description

+ **/ +public class JudgmentRuleProcess { + + public static final Map,Boolean>> METHOD_MAP = new HashMap<>(); + + private static final ExamineMapper EXAMINE_MAPPER = Util.getMapper(ExamineMapper.class); + + public static final Logger logger = Util.getLogger(); + + static { + try { + Class judgmentRuleProcessClass = JudgmentRuleProcess.class; + Method[] methods = judgmentRuleProcessClass.getDeclaredMethods(); + for (Method method : methods) { + if (method.isAnnotationPresent(MethodRuleNo.class)) { + MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class); + int value = annotation.value(); + METHOD_MAP.put(value, (examineConfigDetail, map) -> { + try { + return (boolean) method.invoke(null,examineConfigDetail, map); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + }); + } + } + }catch (Exception exception){ + logger.error("JudgmentRuleProcess init error !!! "+Util.getErrString(exception)); + } + } + + @MethodRuleNo(value = 0,desc = "不为空判断") + public static boolean notNull(ExamineConfigDetail examineConfigDetail,Map param){ + String conditionFieldName = examineConfigDetail.getConditionFieldName(); + String conditionValue = Util.null2String(param.get(conditionFieldName)); + return StringUtils.isNotBlank(conditionValue); + } + + @MethodRuleNo(value = 0,desc = "sql判断") + public static boolean cusSql(ExamineConfigDetail examineConfigDetail,Map param){ + boolean result = false; + String conditionScript = examineConfigDetail.getConditionScript(); + if(StringUtils.isBlank(conditionScript)){ + return result; + } + try { + return EXAMINE_MAPPER.executeCusSql(conditionScript, param); + }catch (Exception e){ + logger.error("执行自定义sql判断异常 !!!"); + return result; + } + } + +} diff --git a/src/main/java/weaver/bokang/xiao/tbxc/mapper/FormFieldMapper.java b/src/main/java/weaver/bokang/xiao/tbxc/mapper/FormFieldMapper.java index 45ee62a..f6d668d 100644 --- a/src/main/java/weaver/bokang/xiao/tbxc/mapper/FormFieldMapper.java +++ b/src/main/java/weaver/bokang/xiao/tbxc/mapper/FormFieldMapper.java @@ -35,4 +35,12 @@ public interface FormFieldMapper { @Select("select is_edit from hrm_formfield where fieldid = #{formFieldId} and groupid = #{groupId}") String queryIsEdit(@ParamMapper("formFieldId") String formFieldId, @ParamMapper("groupId") int groupId); + + /** + *

查询isEdit的值

+ * @param formFieldId 字段id + * @return 值 + */ + @Select("select is_edit from hrm_formfield where fieldid = #{formFieldId}") + String queryIsEditByFieldId(@ParamMapper("formFieldId") String formFieldId); } diff --git a/src/main/java/weaver/hrm/definedfield/HrmDeptFieldManagerE9.java b/src/main/java/weaver/hrm/definedfield/HrmDeptFieldManagerE9.java new file mode 100644 index 0000000..18f31c8 --- /dev/null +++ b/src/main/java/weaver/hrm/definedfield/HrmDeptFieldManagerE9.java @@ -0,0 +1,955 @@ +package weaver.hrm.definedfield; + +import java.util.*; + +import org.json.JSONObject; + +import com.engine.hrm.entity.FieldSelectOptionBean; +import com.api.odoc.util.DocReceiveUnitSyncBySubUtil; +import weaver.bokang.xiao.tbxc.mapper.FormFieldMapper; +import weaver.conn.RecordSet; +import weaver.conn.RecordSetTrans; +import weaver.cpt.capital.CapitalComInfo; +import weaver.crm.Maint.CustomerInfoComInfo; +import weaver.docs.docs.DocComInfo; +import weaver.docs.senddoc.DocReceiveUnitComInfo; +import weaver.file.Prop; +import weaver.formmode.tree.CustomTreeUtil; +import weaver.general.BaseBean; +import weaver.general.StaticObj; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.hrm.util.html.HtmlUtil; +import weaver.interfaces.workflow.browser.Browser; +import weaver.interfaces.workflow.browser.BrowserBean; +import weaver.meeting.MeetingBrowser; +import weaver.proj.Maint.ProjectInfoComInfo; +import weaver.system.CusFormSetting; +import weaver.system.CusFormSettingComInfo; +import weaver.workflow.field.BrowserComInfo; +import weaver.workflow.workflow.WorkflowRequestComInfo; + +/** + * 人力资源分部部门自定义分组设置 + * @author lvyi + * + */ +public class HrmDeptFieldManagerE9 extends BaseBean{ + private RecordSet rs = null; + private RecordSet rsField = null; + private RecordSet rsData = null; + private int scopeid = -1; + //存储所标识的集合里的所有字段的id + private List allFiledsId = null; + private List allFiledsName = null; + private List allBaseFiledsName = null; + private HashMap allFiledsNameMap = null; + private TreeMap allFieldJsonMap=null;//以分组存字段 + private String base_datatable = null; + private String base_id = null; //关联id + private String defined_datatable = null; + private String base_definedid = null;//关联id + + public HrmDeptFieldManagerE9(int scopeid)throws Exception{ + this.scopeid = scopeid; + CusFormSettingComInfo cusFormSettingComInfo = new CusFormSettingComInfo(); + CusFormSetting cusFormSetting = cusFormSettingComInfo.getCusFormSetting("hrm", this.scopeid); + this.base_datatable = cusFormSetting.getBase_datatable(); + this.defined_datatable = cusFormSetting.getDefined_datatable(); + this.base_id = cusFormSetting.getBase_id(); + this.base_definedid = cusFormSetting.getBase_definedid(); + rsField = new RecordSet(); + rsData = new RecordSet(); + rs=new RecordSet(); + + //加载所有字段 + getAllfiledname(); + } + + private boolean isReturnDecryptData = false; + public void isReturnDecryptData(boolean isReturnDecryptData){ + this.isReturnDecryptData = isReturnDecryptData; + rsField.isReturnDecryptData(this.isReturnDecryptData); + rsData.isReturnDecryptData(this.isReturnDecryptData); + rs.isReturnDecryptData(this.isReturnDecryptData); + } + + public List getAllfiledname(){ + this.allFiledsId = new ArrayList(); + this.allFiledsName = new ArrayList(); + this.allBaseFiledsName = new ArrayList(); + this.allFiledsNameMap = new HashMap(); + RecordSet rs = new RecordSet(); + rs.executeSql("select fieldid, fieldname, issystem from hrm_formfield a, hrm_fieldgroup b where a.groupid = b.id AND b.grouptype="+this.scopeid); + while (rs.next()) { + this.allFiledsId.add(rs.getString("fieldid")); + this.allFiledsName.add(rs.getString("fieldname")); + if(rs.getString("issystem").equals("1"))allBaseFiledsName.add(rs.getString("fieldname")); + this.allFiledsNameMap.put(rs.getString("fieldid"),rs.getString("fieldname")); + } + return this.allFiledsName; + } + + /** + * 得到此集合的所有字段的属性 Json形式 + * @return + */ + public JSONObject getHrmFieldConf(String fieldid) throws Exception{ + HrmFieldComInfo hrmFieldComInfo = new HrmFieldComInfo(); + + String eleclazzname=HtmlUtil.getHtmlClassName(hrmFieldComInfo.getFieldhtmltype(fieldid)); + JSONObject jsonObject=new JSONObject(); + jsonObject.put("id", fieldid); + jsonObject.put("fieldname", hrmFieldComInfo.getFieldname(fieldid)); + jsonObject.put("fielddbtype", hrmFieldComInfo.getFielddbtype(fieldid)); + jsonObject.put("fieldhtmltype", hrmFieldComInfo.getFieldhtmltype(fieldid)); + jsonObject.put("type", hrmFieldComInfo.getFieldType(fieldid)); + jsonObject.put("dmlurl", hrmFieldComInfo.getFieldDmlurl(fieldid)); + jsonObject.put("fieldlabel", hrmFieldComInfo.getLabel(fieldid)); + + jsonObject.put("imgwidth", hrmFieldComInfo.getImgWidth(fieldid)); + jsonObject.put("imgheight", hrmFieldComInfo.getImgHeight(fieldid)); + jsonObject.put("textheight", hrmFieldComInfo.getTextheight(fieldid)); + + jsonObject.put("issystem", 1); + jsonObject.put("fieldkind", "0"); + jsonObject.put("dsporder", hrmFieldComInfo.getDsporder(fieldid)); + jsonObject.put("ismand", hrmFieldComInfo.getIsmand(fieldid)); + jsonObject.put("isused", hrmFieldComInfo.getIsused(fieldid)); + + jsonObject.put("eleclazzname", eleclazzname); + return jsonObject; + } + + public List getLsGroup() { + List ls = new ArrayList(); + RecordSet rs = new RecordSet(); + rs.executeSql("select id from hrm_fieldgroup where grouptype ="+this.scopeid+" order by grouporder "); + while (rs.next()) { + ls.add(rs.getString("id")); + } + return ls; + } + + /** + * 返回字段Id + * @return + */ + public List getLsField(String groupid) { + List ls = new ArrayList(); + RecordSet rs = new RecordSet(); + String sql = " select fieldid from hrm_formfield a, hrm_fieldgroup b " + + " where a.groupid = b.id and groupid = "+groupid + + " order by groupid, fieldorder"; + rs.executeSql(sql); + while(rs.next()){ + ls.add(rs.getString("fieldid")); + } + return ls; + } + + /** + * 取得选择字段选择项的数据 + * @param id + */ + public void getSelectItem(String id) { + List ls = new ArrayList(); + rs.executeSql("select selectvalue, selectname, listorder from hrm_selectitem where cancel =0 and fieldid=" + id + " order by listorder"); + } + + /** + * 得到字段信息的文本长度,只有为单行文档的时候有效,注意不同的文本长度表示不同的字段类型. + * @return + */ + public String getStrLength(String fielddbtype, String htmltype, String type ) { + if (htmltype.equals("1")) { + if (type.equals("1")) { + return fielddbtype.substring(fielddbtype.indexOf("(") + 1, fielddbtype.length() - 1); + } + } + return "0"; + } + + /** + * 选择项数据移动到下一行 + * @return + */ + public boolean toFirstSelect() { + return rs.first(); + } + + /** + * 选择项数据移动到下一行 + * @return + */ + public boolean nextSelect() { + return rs.next(); + } + + /** + * 得到选择项的值 + * @return + */ + public String getSelectValue() { + return rs.getString("selectvalue"); + } + + /** + * 得到选择项的显示名称 + * @return + */ + public String getSelectName() { + return rs.getString("selectname"); + } + + /** + * 是否被引用 + * @param scopeId + * @param fieldid + * @return + */ + public boolean getIsUsed(String fieldname){ + boolean isUsed = false; + RecordSet rs = new RecordSet(); + String sql = " select count(*) from "+this.defined_datatable+" where (" +fieldname+" is not null and " +fieldname+" not like '' )"; + if((rs.getDBType()).equals("oracle")){ + sql = " select count(*) from "+this.defined_datatable+" where (" +fieldname+" is not null or " +fieldname+" not like '' )"; + } + rs.executeSql(sql); + if(rs.next()){ + if(rs.getInt(1)>0){ + isUsed = true; + } + } + return isUsed; + } + + /** + * 是否被引用 + * @param scopeId + * @param fieldid + * @return + */ + public boolean getIsUsed(String fieldid,String fieldname){ + boolean isUsed = false; + RecordSet rs = new RecordSet(); + String checkSql = "select 1 from hrm_formfield where fieldid="+fieldid+" and fielddbtype='int'" ; + rs.executeSql(checkSql); + boolean isInt = rs.next() ; + + String sql = " select count(*) from "+this.defined_datatable+" where (" +fieldname+" is not null and " +fieldname+" not like '' )"; + if((rs.getDBType()).equals("oracle")){ + sql = " select count(*) from "+this.defined_datatable+" where (" +fieldname+" is not null or " +fieldname+" not like '' )"; + } + + if(isInt){ + sql += " and "+fieldname+" !=0" ; + } + + rs.executeSql(sql); + if(rs.next()){ + if(rs.getInt(1)>0){ + isUsed = true; + } + } + return isUsed; + } + + public int addField( String fieldname, String fielddbtype, String fieldhtmltype, String type, String fieldlabel, + String fieldorder, String ismand, String isuse, String groupid)throws Exception{ + return addField( fieldname, fielddbtype, fieldhtmltype, type, fieldlabel, fieldorder, ismand, isuse, groupid, null); +} + /** + * 向数据库中增加指定类型的数据字段 + * @param fielddbtype 字段的数据库类型,例如 varchar(100)、int、decimal…… + * @param fieldhtmltype 字段的类型 例如 单行文本、多行文本、选择框…… + * @param type 很据fieldhtmltype的不同代表的意义不同,对浏览框,代表的是浏览框的类型 + * @return 增加字段的id + */ + public int addField( String fieldname, String fielddbtype, String fieldhtmltype, String type, String fieldlabel, + String fieldorder, String ismand, String isuse, String groupid, String dmlUrl)throws Exception{ + int temId = -1; + rsField.executeSql("select max(fieldid) from hrm_formfield"); + if(rsField.next()){ + temId = rsField.getInt(1); + } + + if(temId == -1){ + temId = 0; + }else{ + temId ++; + } + + String sql=null; + if(fieldhtmltype.equals("6")||(fieldhtmltype.equals("3")&&(type.equals("161")||type.equals("162")))){ + String _fielddbtype=null; + boolean isoracle = (rsField.getDBType()).equals("oracle") ; + boolean isdb2 = (rsField.getDBType()).equals("db2") ; + if(fieldhtmltype.equals("6")){ + if(isoracle) _fielddbtype="varchar2(1000)"; + else if(isdb2) _fielddbtype="varchar(1000)"; + else _fielddbtype="varchar(1000)"; + }else if(type.equals("161")){ + if(isoracle) _fielddbtype="varchar2(1000)"; + else if(isdb2) _fielddbtype="varchar(1000)"; + else _fielddbtype="varchar(1000)"; + }else{ + if(isoracle) _fielddbtype="varchar2(4000)"; + else if(isdb2) _fielddbtype="varchar(2000)"; + else _fielddbtype="text"; + } + sql="alter table "+this.defined_datatable+" add "+fieldname+" "+_fielddbtype; + }else{ + sql="alter table "+this.defined_datatable+" add "+fieldname+" "+fielddbtype; + } + RecordSetTrans rst = new RecordSetTrans(); + try{ + rst.setAutoCommit(false); + rst.executeSql(sql); + sql = " insert into hrm_formfield (fieldid ,fielddbtype , fieldname ,fieldlabel ,fieldhtmltype , " + + " type, fieldorder ,ismand ,isuse ,groupid, allowhide, dmlUrl)" + + " values("+temId+",'"+fielddbtype+"','"+fieldname+"','"+fieldlabel+"','"+fieldhtmltype+"','"+type+"'," + + fieldorder+","+ismand+","+isuse+","+groupid+",1,'"+dmlUrl+"')"; + rst.executeSql(sql); + + rst.commit(); + }catch(Exception e){ + rsField.writeLog(e); + rst.rollback(); + return -1; + } + return temId; + } + public void editField( String fieldid, String fieldlabel, String fieldorder, String ismand, String isuse, String groupid){ + editField( fieldid, fieldlabel, fieldorder, ismand, isuse, groupid, null); + } + /** + * 更新字段 + * @param fieldname + * @param fieldlabel + * @param fieldorder + * @param ismand + * @param isuse + * @param groupid + */ + public void editField( String fieldid, String fieldlabel, String fieldorder, String ismand, String isuse, String groupid, String dmlUrl){ + String sql = null; + RecordSet rs = new RecordSet(); + sql = " update hrm_formfield set fieldlabel='"+fieldlabel+"',fieldorder='"+fieldorder+"',ismand='"+ismand+"'," + + " isuse='"+isuse+"',groupid='"+groupid+"'" + + " where fieldid="+fieldid; + rs.executeSql(sql); + } + +/** + * 删除字段 + * @param fieldname + */ + public void deleteFields(String fieldid) { + RecordSetTrans rst = new RecordSetTrans(); + try{ + rst.setAutoCommit(false); + rst.executeSql("delete from hrm_formfield where fieldid= "+fieldid); + String fieldname = this.allFiledsNameMap.get(fieldid); + rst.executeSql("alter table "+this.defined_datatable+" drop column "+fieldname); + rst.commit(); + }catch(Exception e){ + rsField.writeLog(e); + rst.rollback(); + } + } + + /** + * 取得自定义字段的数据 + * @param id + */ + public void getCustomData(int id) { + String fieldStr = ""; + for (int i = 0; i < this.allFiledsName.size(); i++) { + if(this.allFiledsName.get(i).equals("showid"))continue;//showid只做显示 + if(this.allFiledsName.get(i).equals("subshowid"))continue;//subshowid只做显示 + if(allBaseFiledsName.contains(this.allFiledsName.get(i))){ + fieldStr += ",a." + this.allFiledsName.get(i); + }else{ + fieldStr += ",b." + this.allFiledsName.get(i); + } + } + if (!fieldStr.equals("")) { + fieldStr = fieldStr.substring(1); + String sql ="select " + fieldStr + " from "+this.base_datatable+" a left join "+this.defined_datatable+" b " + + " on a."+this.base_id+"=b."+this.base_definedid+" where a.id = " + id; + rsData.executeSql(sql); + } + rsData.next(); + } + + /** + * 得到指定字段的自定义数据值 + * @param key + * @return + */ + public String getData(String tablename,String key) { + try { + return rsData.getString(tablename, key); + } catch (Exception e) { + rsData.writeLog(e); + return ""; + } + } + + /** + * 得到指定字段的自定义数据值 + * @param key + * @return + */ + public String getData(String key) { + try{ + return rsData.getString(key); + }catch(Exception e){ + rsData.writeLog(e); + return ""; + } + } + + /** + * 保存自定义数据 + * @param scope + * @param scopeId + * @param request + * @param dataId + */ + public void addCustomData(Map params, int dataId) throws Exception { + RecordSet rs = new RecordSet(); + RecordSet recordSet = new RecordSet(); + HrmFieldComInfo hrmFieldComInfo = new HrmFieldComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + + HrmDeptFieldManagerE9 hrm = new HrmDeptFieldManagerE9(this.scopeid); + List lsFieldid = hrm.allFiledsId; + String sql = "insert into "+this.defined_datatable; + String nameStr = ""; + String valueStr = ""; + String cusMatrixSql = "select matrixId,matrixFieldName,type,orgType from uf_sfwdwtbszb";//orgType:部门dept,分部subcom + recordSet.executeQuery(cusMatrixSql); + Map> matrixMap = new HashMap<>(); + while (recordSet.next()) { + Map fieldMap = new HashMap<>(); + String matrixFieldName = recordSet.getString("matrixFieldName"); + String type = recordSet.getString("type"); + String orgType = recordSet.getString("orgType"); + fieldMap.put("type",type); + matrixMap.put(matrixFieldName+orgType,fieldMap); + } + String orgName =""; + String receiverids =""; + boolean isNeedSynDept = this.scopeid == 5; + boolean isNeedSynSub = this.scopeid == 4; + + for(int i=0;lsFieldid!=null&&i relationMap = matrixMap.get(fieldname + "dept"); + String type = relationMap.get("type"); + String receiveridsOrigin = Util.null2String(params.get(fieldname)); + if(!"".equals(receiveridsOrigin)){ + if("".equals(receiverids)){ + receiverids += getFormatId(receiveridsOrigin, type ); + }else { + receiverids += ","+ getFormatId(receiveridsOrigin, type ); + } + } + String id = Util.null2String(dataId); + String sqls = "select departmentname from hrmdepartment where id = ?"; + rs.executeQuery(sqls, id); + if(rs.next()){ + orgName = rs.getString("departmentname");; + } + + } + + if (isNeedSynSub && (matrixMap.get(fieldname+"subcom") != null)){ + Map relationMap = matrixMap.get(fieldname + "subcom"); + String type = relationMap.get("type"); + String receiveridsOrigin = Util.null2String(params.get(fieldname)); + if(!"".equals(receiveridsOrigin)){ + if("".equals(receiverids)){ + receiverids += getFormatId(receiveridsOrigin, type ); + }else { + receiverids += ","+ getFormatId(receiveridsOrigin, type ); + } + } + + String id = Util.null2String(dataId); + String sqls = "select subcompanydesc from hrmsubcompany where id = ?"; + rs.executeQuery(sqls, id); + if(rs.next()){ + orgName = rs.getString("subcompanydesc");; + } + + + } + + if (fielddbtype.startsWith("text") || fielddbtype.startsWith("char") || + fielddbtype.startsWith("varchar")) { + valueStr += ",'" + Util.null2String(params.get(fieldname)) + "'"; + } else { + if (Util.null2String(params.get(fieldname)).equals("")) { + valueStr += ",null"; + } else { + valueStr += ",'" + Util.null2String(params.get(fieldname))+"'"; + } + } + } + rs.writeLog("add:nameStr:"+nameStr); + rs.writeLog("add:isNeedSynDept:"+isNeedSynDept); + rs.writeLog("add:isNeedSynSub:"+isNeedSynSub); + rs.writeLog("add:orgName:"+orgName); + if (!nameStr.equals("")) { + nameStr = nameStr.substring(1); + valueStr = valueStr.substring(1); + sql += "("+this.base_definedid+"," + nameStr + ") values(" + dataId + "," + valueStr + ")"; + //System.out.println("sql = " + sql); + rs.executeSql(sql); + + DocReceiveUnitSyncBySubUtil docReceiveUnitSyncBySubUtil = new DocReceiveUnitSyncBySubUtil(); + if (isNeedSynDept && !"".equals(orgName)) { + boolean success = docReceiveUnitSyncBySubUtil.syncSingleDepUnitData(dataId,orgName,receiverids); + writeLog(success+"==ADD:syncSingleDepUnitData:dataId:"+dataId+" orgName:"+orgName +" receiverids:"+receiverids); + } + if(isNeedSynSub && !"".equals(orgName)) { + boolean success = docReceiveUnitSyncBySubUtil.syncSingleSubUnitData(dataId,orgName,receiverids); + writeLog(success+"==ADDsyncSingleSubUnitData:dataId:"+dataId+" orgName:"+orgName +" receiverids:"+receiverids); + } + } + } + + /** + * 根据jsonObject 编辑自定义数据 + * @param scope + * @param scopeId + * @param request + * @param dataId + */ + public void editCustomData(com.alibaba.fastjson.JSONObject jObject)throws Exception { + + int dataId = Util.getIntValue(Util.null2String(jObject.get("id"))); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + rs.executeSql("select "+this.base_definedid+" from "+this.defined_datatable+" where "+this.base_definedid+"=" + dataId); + + if (!rs.next()) { + //如果自定义字段没有,需要先插入再更新 + String insertCusSql = "insert into "+this.defined_datatable+"("+this.base_definedid+") values("+dataId+")"; + rs1.executeSql(insertCusSql); + } + + HrmFieldComInfo hrmFieldComInfo = new HrmFieldComInfo(); + HrmDeptFieldManagerE9 hrm = new HrmDeptFieldManagerE9(this.scopeid); + List lsFieldid = hrm.allFiledsId; + String sql = "update "+this.defined_datatable+" set "; + String setStr = ""; + for(int i=0;lsFieldid!=null&&i> matrixMap = new HashMap<>(); + while (recordSet.next()) { + Map fieldMap = new HashMap<>(); + String matrixFieldName = recordSet.getString("matrixFieldName"); + String type = recordSet.getString("type"); + String orgType = recordSet.getString("orgType"); + fieldMap.put("type",type); + matrixMap.put(matrixFieldName+orgType,fieldMap); + } + String orgName =""; + String receiverids =""; + + + boolean isNeedSynDept = (this.scopeid == 5); + boolean isNeedSynSub = (this.scopeid == 4); + + + for(int i=0;lsFieldid!=null&&i relationMap = matrixMap.get(fieldname + "dept"); + String type = relationMap.get("type"); + String receiveridsOrigin = Util.null2String(params.get(fieldname)); + if(!"".equals(receiveridsOrigin)){ + if("".equals(receiverids)){ + receiverids += getFormatId(receiveridsOrigin, type ); + }else { + receiverids += ","+ getFormatId(receiveridsOrigin, type ); + } + } + + String id = Util.null2String(dataId); + orgName = departmentComInfo.getDepartmentName(id); + } + + if (isNeedSynSub && (matrixMap.get(fieldname+"subcom") != null)){ + Map relationMap = matrixMap.get(fieldname + "subcom"); + String type = relationMap.get("type"); + String receiveridsOrigin = Util.null2String(params.get(fieldname)); + + if(!"".equals(receiveridsOrigin)){ + if("".equals(receiverids)){ + receiverids += getFormatId(receiveridsOrigin, type ); + }else { + receiverids += ","+ getFormatId(receiveridsOrigin, type ); + } + } + String id = Util.null2String(dataId); + orgName = subCompanyComInfo.getSubCompanydesc(id); + + + } + + if (fielddbtype.startsWith("text") || fielddbtype.startsWith("char") || fielddbtype.startsWith("varchar")) { + setStr += "'" + Util.null2String(params.get(fieldname)) + "'"; + } else { + if (Util.null2String(params.get(fieldname)).equals("")) { + setStr += "null"; + } else { + setStr += "'"+Util.null2String(params.get(fieldname))+"' "; + } + } + } + if (!setStr.equals("")) { + setStr = setStr.substring(1); + + sql += setStr + " where "+this.base_definedid+"='" + dataId+"'"; + //System.out.println("sql = " + sql); + rs.executeUpdate(sql); + + DocReceiveUnitSyncBySubUtil docReceiveUnitSyncBySubUtil = new DocReceiveUnitSyncBySubUtil(); + if (isNeedSynDept) { + boolean success = docReceiveUnitSyncBySubUtil.syncSingleDepUnitData(dataId,orgName,receiverids); + writeLog(success+"==ADD:syncSingleDepUnitData:dataId:"+dataId+" orgName:"+orgName +" receiverids:"+receiverids); + } + if(isNeedSynSub){ + boolean success = docReceiveUnitSyncBySubUtil.syncSingleSubUnitData(dataId,orgName,receiverids); + writeLog(success+"==ADDsyncSingleSubUnitData:dataId:"+dataId+" orgName:"+orgName +" receiverids:"+receiverids); + } + } + } else { + addCustomData(params, dataId); + } + + } + + + /** + * 删除自定义数据 + * @param scope + * @param scopeId + * @param dataId + */ + public void deleteCustomData(int dataId) { + RecordSet rs = new RecordSet(); + rs.executeSql("delete from "+this.defined_datatable+" where "+this.base_definedid+"=" + dataId); + } + + /** + * 检测更新选择框的字段. + * @param fieldid 选择框对应的字段id + * @param value 选择值 + * @param name 选择显示名称 + */ + public void checkSelectField(int fieldid, List lsSelectOption) { + RecordSet rs = new RecordSet(); + String sql = ""; + List allOption = new ArrayList(); + List delOption = new ArrayList(); + sql = "select selectvalue from hrm_selectitem where fieldid=" + fieldid; + rs.executeSql(sql); + while(rs.next()){ + allOption.add(rs.getString("selectvalue")); + delOption.add(rs.getString("selectvalue")); + } + + for (int i = 0; lsSelectOption!=null &&i < lsSelectOption.size(); i++) { + FieldSelectOptionBean option = lsSelectOption.get(i); + delOption.remove(option.getId()); + } + String temStr = ""; + for (int i = 0; i < delOption.size(); i++) { + temStr = temStr + "," + delOption.get(i); + } + if (!temStr.equals("")) { + temStr = temStr.substring(1); + rs.executeSql("delete from hrm_selectitem where fieldid=" + fieldid + " and selectvalue in(" + temStr + ")"); + } + for (int i = 0; lsSelectOption!=null &&i < lsSelectOption.size(); i++) { + FieldSelectOptionBean option = lsSelectOption.get(i); + if(allOption.contains(option.getId())){ + sql = " update hrm_selectitem set selectname='" + option.getOption() + "', listorder=" + (i+1) + "," + + " isdefault='" + option.getDefault() + "', cancel='" + option.getUnuse() + "'"+ + " where fieldid=" + fieldid + " and selectvalue=" + option.getId(); + rs.executeSql(sql); + }else{ + int temId = -1; + sql = "select max(selectvalue) from hrm_selectitem where fieldid=" + fieldid; + rs.executeSql(sql); + if (rs.next()) { + temId = rs.getInt(1); + } + if (temId == -1) { + temId = 0; + } else { + temId++; + } + option.setId(""+temId); + sql = " insert into hrm_selectitem(fieldid,selectvalue,selectname,listorder,isdefault,cancel) " + + " values(" + fieldid + "," + option.getId() + ",'" + option.getOption() + "'," + (i+1) + ",'" + option.getDefault() + "','" + option.getUnuse() + "')"; + rs.executeSql(sql); + } + } + } + + public int getGroupCount(List lsField){ + int count =0; + HrmFieldComInfo hrmFieldComInfo = new HrmFieldComInfo(); + for(int i=0;lsField!=null&&ilyx04 + BrowserComInfo browserComInfo = new BrowserComInfo(); + String linkurl =browserComInfo.getLinkurl(""+fieldType); + boolean isLink=!"".equals(linkurl); + String linkurlStart=""; + String aEnd=""; + if (fieldHtmlType == 3) { + ArrayList tempshowidlist = Util.TokenizerString(fieldValue, ","); + if (fieldType == 1 || fieldType == 17) { // 人员,多人员 + ResourceComInfo resourceComInfo=new ResourceComInfo(); + for (int k = 0; k < tempshowidlist.size(); k++) { + showname += isLink?linkurlStart+tempshowidlist.get(k)+linkurlEnd+resourceComInfo.getResourcename((String) tempshowidlist.get(k)) + +aEnd+ "  ":resourceComInfo.getResourcename((String) tempshowidlist.get(k))+"  "; + if((k+1)%10==0) showname+="
"; + } + } else if (fieldType == 2 || fieldType == 19) { // 日期,时间 + // showname += preAdditionalValue; + showname += fieldValue; + } else if (fieldType == 4 || fieldType == 57) { // 部门,多部门 + DepartmentComInfo departmentComInfo=new DepartmentComInfo(); + for (int k = 0; k < tempshowidlist.size(); k++) { + showname += isLink?linkurlStart+tempshowidlist.get(k)+linkurlEnd+departmentComInfo.getDepartmentname((String) tempshowidlist.get(k)) + +aEnd+ "  ":departmentComInfo.getDepartmentname((String) tempshowidlist.get(k))+"  "; + } + } else if (fieldType == 8 || fieldType == 135) { // 项目,多项目 + ProjectInfoComInfo projectInfoComInfo=new ProjectInfoComInfo(); + for (int k = 0; k < tempshowidlist.size(); k++) { + showname += isLink?linkurlStart+tempshowidlist.get(k)+linkurlEnd+projectInfoComInfo.getProjectInfoname((String) tempshowidlist.get(k)) + +aEnd+ "  ":projectInfoComInfo.getProjectInfoname((String) tempshowidlist.get(k))+ "  "; + } + } else if (fieldType == 7 || fieldType == 18) { // 客户,多客户 + CustomerInfoComInfo customerInfoComInfo=new CustomerInfoComInfo(); + for (int k = 0; k < tempshowidlist.size(); k++) { + showname += isLink?linkurlStart+tempshowidlist.get(k)+linkurlEnd+customerInfoComInfo.getCustomerInfoname((String) tempshowidlist.get(k)) + +aEnd+ "  ":customerInfoComInfo.getCustomerInfoname((String) tempshowidlist.get(k))+ "  "; + } + } else if (fieldType == 164) { // 分部 + SubCompanyComInfo subCompanyComInfo=new SubCompanyComInfo(); + for (int k = 0; k < tempshowidlist.size(); k++) { + showname += isLink?linkurlStart+tempshowidlist.get(k)+linkurlEnd+subCompanyComInfo.getSubCompanyname((String) tempshowidlist.get(k)) + +aEnd+ "  ":subCompanyComInfo.getSubCompanyname((String) tempshowidlist.get(k)) + + "  "; + } + } else if (fieldType == 9) { // 单文档 + for (int k = 0; k < tempshowidlist.size(); k++) { + showname += isLink?linkurlStart+tempshowidlist.get(k)+linkurlEnd+new DocComInfo() + .getDocname((String) tempshowidlist.get(k))+aEnd:new DocComInfo() + .getDocname((String) tempshowidlist.get(k)); + } + } else if (fieldType == 37) { // 多文档 + DocComInfo docComInfo=new DocComInfo(); + for (int k = 0; k < tempshowidlist.size(); k++) { + showname += isLink?linkurlStart+tempshowidlist.get(k)+linkurlEnd+docComInfo.getDocname((String) tempshowidlist.get(k)) +aEnd+ "  ":docComInfo.getDocname((String) tempshowidlist.get(k)) + "  "; + } + } else if (fieldType == 23) { // 资产 + CapitalComInfo capitalComInfo=new CapitalComInfo(); + for (int k = 0; k < tempshowidlist.size(); k++) { + showname += isLink?linkurlStart+tempshowidlist.get(k)+linkurlEnd+capitalComInfo.getCapitalname((String) tempshowidlist.get(k)) + +aEnd+ "  ":capitalComInfo.getCapitalname((String) tempshowidlist.get(k)) + + "  "; + } + } else if (fieldType == 16 || fieldType == 152) { // 相关请求 + WorkflowRequestComInfo workflowRequestComInfo=new WorkflowRequestComInfo(); + for (int k = 0; k < tempshowidlist.size(); k++) { + showname += isLink?linkurlStart+tempshowidlist.get(k)+linkurlEnd+workflowRequestComInfo.getRequestName((String) tempshowidlist.get(k)) + +aEnd+ "  ":workflowRequestComInfo.getRequestName((String) tempshowidlist.get(k)) + + "  "; + } + } else if (fieldType == 142) {// 收发文单位 + DocReceiveUnitComInfo docReceiveUnitComInfo = new DocReceiveUnitComInfo(); + for (int k = 0; k < tempshowidlist.size(); k++) { + showname += isLink?linkurlStart+tempshowidlist.get(k)+linkurlEnd+docReceiveUnitComInfo.getReceiveUnitName((String) tempshowidlist.get(k)) + +aEnd+ "  ":docReceiveUnitComInfo.getReceiveUnitName((String) tempshowidlist.get(k)) + + "  "; + } + } else if (fieldType == 226 || fieldType == 227) {// -zzl系统集成浏览按钮 + showname += fieldValue; + } else if (fieldType == 268 ) {// 多星期 + showname += MeetingBrowser.getWeekNames(fieldValue, user.getLanguage()); + showname=showname.replace(",", "  "); + } else if (fieldType == 269 ) {// 多提醒方式 + showname += MeetingBrowser.getRemindNames(fieldValue, user.getLanguage()); + showname=showname.replace(",", "  "); + } else if(fieldType==161||fieldType==162){ //自定义浏览按钮 + try{ + if(Util.null2String(fielddbtype).length()==0||fielddbtype.equals("emptyVal"))return""; + Browser browser=(Browser) StaticObj.getServiceByFullname(dmlurl, Browser.class); + for(int k=0;k 0) { + receiveridsWithType += "," + type + idStr; + } else { + receiveridsWithType += type + idStr; + } + } + + return receiveridsWithType; + } +} diff --git a/src/test/java/bokang/xiao/NormalTest.java b/src/test/java/bokang/xiao/NormalTest.java index e1a85c0..65fcbb2 100644 --- a/src/test/java/bokang/xiao/NormalTest.java +++ b/src/test/java/bokang/xiao/NormalTest.java @@ -1,9 +1,11 @@ package bokang.xiao; import aiyh.utils.GenerateFileUtil; +import aiyh.utils.ScriptUtil; import aiyh.utils.Util; import aiyh.utils.httpUtil.ResponeVo; import aiyh.utils.httpUtil.util.HttpUtils; +import aiyh.utils.tool.org.apache.commons.jexl3.*; import basetest.BaseTest; import bokang.xiao.entity.CourseEntity; import bokang.xiao.entity.StudentEntity; @@ -36,10 +38,12 @@ import weaver.bokang.xiao.common.CommonUtil; import weaver.bokang.xiao.common.mapper.ModeMapper; import weaver.bokang.xiao.common.mapper.WorkflowMapper; import weaver.bokang.xiao.deg_repeat_check.action.RepeatCheckAction; +import weaver.bokang.xiao.dloa.schedule.HrmSyncSchedule; import weaver.bokang.xiao.porsche.action.DateFieldUpdateAction; import weaver.bokang.xiao.porsche.schedule.CompanyWriteBackSchedule; import weaver.bokang.xiao.porsche.schedule.SalaryUpdateSchedule; import weaver.bokang.xiao.sh_bigdata.action.DataPushAction; +import weaver.bokang.xiao.shtx.schedule.ExamineSchedule; import weaver.bokang.xiao.xhny_mode.search.CustomSearchDepart; import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; import weaver.bokang.xiao.xhny_report.schedule.GenerateReportSchedule; @@ -79,11 +83,29 @@ public class NormalTest extends BaseTest { @Test public void testWord(){ - GenerateFileUtil.createCronJobDocument(SalaryUpdateSchedule.class); + GenerateFileUtil.createCronJobDocument(ExamineSchedule.class); //GenerateFileUtil.createActionDocument(DataPushAction.class); //GenerateFileUtil.createActionDocument(DateFieldUpdateAction.class); } + @Test + public void testSchedule() throws IOException { + //HrmSyncSchedule hrmSyncSchedule = new HrmSyncSchedule(); + //hrmSyncSchedule.setBeginDate("2022-12-02"); + //hrmSyncSchedule.setEndDate("2023-04-14"); + //hrmSyncSchedule.runCode(); + Map param = new HashMap<>(); + param.put("cglx",null); + param.put("cgdj",1); + param.put("zzgxd",4); + param.put("hjjb","A"); + param.put("hjdj",1); + //String script = " cglx != null && !''.equals(cglx)"; + String script = " if (hjjb == 'A' && hjdj == 1) {x = 4}"; + boolean invokeVar = (Boolean) ScriptUtil.invokeScript(script, param); + System.out.println(invokeVar); + } + @Test public void testReport1() throws FileNotFoundException { BankService bankService = new BankService();