Compare commits

...

2 Commits

Author SHA1 Message Date
ic_excellent 2ce07ae713 Merge branch 'dev' of https://gitea.yeyaguitu.cn/ecology/ebu_ecology_dev1 into dev 2023-07-03 13:46:07 +08:00
ic_excellent bf14d9baa3 功能提交 2023-07-03 13:43:58 +08:00
26 changed files with 5111 additions and 14 deletions

View File

@ -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 <h1></h1>
**/
@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();
}
}

View File

@ -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));

View File

@ -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<String, Object> param);
/**
* <h2></h2>
* @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<Map<String, Object>> queryOaOtherList(Map<String, Object> param);
/**
* <h2></h2>
* @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<Map<String, Object>> queryOaOtherDetailList(Map<String, Object> param);
}

View File

@ -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"
* }]
* }
* </p
*
@ -69,6 +84,8 @@ public class BankService {
String bankAccount = Util.null2String(param.get("currentBankAccount"));
List<Map<String,Object>> outParam = (List<Map<String, Object>>) param.get("outParam");
List<Map<String,Object>> inParam = (List<Map<String, Object>>) param.get("inParam");
List<Map<String,Object>> inOtherParam = (List<Map<String, Object>>) param.get("inOtherParam");
List<Map<String,Object>> outOtherParam = (List<Map<String, Object>>) param.get("outOtherParam");
//查询数据
List<Map<String, Object>> oaOutList = outParam.stream()
.flatMap(item -> {
@ -89,6 +106,30 @@ public class BankService {
return tempOutList.stream();
})
.collect(Collectors.toList());
List<Map<String, Object>> 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<Map<String, Object>> 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<Map<String, Object>> 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<Map<String, Object>> bankOutList = bankMapper.queryBankOutInfo(param);
List<Map<String, Object>> bankInList = bankMapper.queryBankInInfo(param);
List<Map<String, Object>> bankTempOutList = bankMapper.queryBankOutInfo(param);
List<Map<String, Object>> bankTempInList = bankMapper.queryBankInInfo(param);
//将银行流水信息进行分组有Insid为一组走银企直联无Insid代收划转为一组
Map<Boolean, List<Map<String, Object>>> bankOutMap = bankTempOutList.stream().collect(Collectors.partitioningBy(item -> StringUtils.isNotBlank(Util.null2String(item.get("insid")))));
Map<Boolean, List<Map<String, Object>>> bankInMap = bankTempInList.stream().collect(Collectors.partitioningBy(item -> StringUtils.isNotBlank(Util.null2String(item.get("insid")))));
List<Map<String, Object>> bankOutList = bankOutMap.get(true);
List<Map<String, Object>> bankInList = bankInMap.get(true);
//过滤出银行流水中的代收部分即insid为空的部分
List<Map<String, Object>> bankOutOtherList = bankOutMap.get(false);
List<Map<String, Object>> bankInOtherList = bankInMap.get(false);
//计算有差异的集合
List<Map<String, Object>> bankOutOtherTable = CommonUtil.difference(bankOutOtherList, oaOutOtherList, map -> map.get("id"));
List<Map<String, Object>> bankInOtherTable = CommonUtil.difference(bankInOtherList, oaInOtherList, map -> map.get("id"));
List<Map<String, Object>> oaOutTable = CommonUtil.difference(oaOutList, bankOutList, map -> map.get("insid"));
List<Map<String, Object>> bankOutTable = CommonUtil.difference(bankOutList,oaOutList, map -> map.get("insid"));
List<Map<String, Object>> bankInTable = CommonUtil.difference(bankInList,oaInList, map -> map.get("payInfo"));
List<Map<String, Object>> bankOutTempTable = CommonUtil.difference(bankOutList,oaOutList, map -> map.get("insid"));
List<Map<String, Object>> bankInTempTable = CommonUtil.difference(bankInList,oaInList, map -> map.get("payInfo"));
List<Map<String, Object>> oaInTable = new ArrayList<>();
//合并代收和走银企的部分
List<Map<String, Object>> bankInTable = Stream.concat(bankInTempTable.stream(), bankInOtherTable.stream())
.collect(Collectors.toList());
List<Map<String, Object>> 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<Object> 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);
}

View File

@ -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;

File diff suppressed because it is too large Load Diff

View File

@ -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 删除分部收发文员sqldelete 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<receiverid1.length;i++){
receiverid = receiverid1[i];
String[] receiverid2 = Util.TokenizerString2(receiverid,"_");
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,'1')", id,receiverid2[1]);
}
if(receiverid2[0].equals("公司函")&&!isInsertgsh){
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]);
isInsertgsh = true;
}
if(receiverid2[0].equals("空")&&!isInsertnull){
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]);
isInsertnull = true;
}
}
}
}
}else{
String supsubcomid = "";
int id = 0;
rs.executeQuery("select supsubcomid from hrmsubcompany where id=?", subcompanyid1);
if (rs.next()) {
supsubcomid = Util.null2String(rs.getString("supsubcomid"));
}
rs.writeLog("syncSingleSubUnitData supsubcomid =" + supsubcomid);
if (supsubcomid.equals("0")) {
rs.executeQuery("select id from docreceiveunit where distinguish=0 and relativesub is null and subcompanyid=? and (canceled is null or canceled<>'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;i<receiverid1.length;i++){
receiverid = receiverid1[i];
String[] receiverid2 = Util.TokenizerString2(receiverid,"_");
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,'1')", newid,receiverid2[1]);
}
if(receiverid2[0].equals("公司函")&&!isInsertgsh){
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]);
isInsertgsh = true;
}
if(receiverid2[0].equals("空")&&!isInsertnull){
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]);
isInsertnull = true;
}
}
}
}
}
retFlag = true;
return retFlag;
}
/**
*
* @param subcompanyid1 id
* @param departmentname
* @param receiverids
* @return
*/
public boolean syncSingleDepUnitData(int departmentid,String departmentname,String receiverids){
boolean retFlag = false;
RecordSet rs = new RecordSet();
String issynchronizefromexchange ="";
boolean isSycnSeconedDep = false;//是否同步二级及以下部门
rs.executeQuery("select * from uf_tbsystemparam ");
if(rs.next()){
isSycnSeconedDep = Util.null2String(rs.getString("paramvalue")).equals("1");
}
rs.writeLog("syncSingleDepUnitData start departmentid="+departmentid+",departmentname="+departmentname+",receiverids="+receiverids+",isSycnSeconedDep="+isSycnSeconedDep);
int subcompanyid1 = 0; //所属分部
int supdepid = 0;//上级部门
rs.executeQuery("select subcompanyid1,supdepid from hrmdepartment where id=?",departmentid);
if(rs.next()){
subcompanyid1 = Util.getIntValue(rs.getString("subcompanyid1"),-1);
supdepid = Util.getIntValue(rs.getString("supdepid"),-1);
}
//判断是否二级部门,二级及以下部门,在新建或编辑时若无对应收发文单位匹配时,均不自动增加对应收发文单位
if(supdepid>0){//是二级部门
//如果开启了同步二级及以下部门
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<Map<String,String>> list){
boolean retFlag = false;
//List<Map<String,String>> list = new ArrayList(Map<String,String>);
Map<String,String> map= new HashMap<String,String>();
int subcompanyid1 = 0;
String departmentname = "";
String receiverids = "";
String departmentid = "";
RecordSet rs = new RecordSet();
rs.writeLog("syncDepsUnitData start");
for(int i=0;i<list.size();i++){
map = list.get(i);
departmentid = map.get("departmentid");
subcompanyid1 = Util.getIntValue(map.get("subcompanyid"),-1);
departmentname = map.get("departmentname");
receiverids = map.get("receiverids");
boolean flag = syncSingleDepUnitData(subcompanyid1,departmentname,receiverids);
if(flag){
retFlag = flag;
}
}
rs.writeLog("syncDepsUnitData end");
return retFlag;
}
/**
* list
* @param list
* @return
*/
public boolean syncSubsUnitData(List<Map<String,String>> list){
boolean retFlag = false;
//List<Map<String,String>> list = new ArrayList(Map<String,String>);
Map<String,String> map= new HashMap<String,String>();
//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<list.size();i++){
map = list.get(i);
subcompanyid1 = Util.getIntValue(map.get("subcompanyid"),-1);
subcompanyname = map.get("subcompanyname");
receiverids = map.get("receiverids");
boolean flag = syncSingleSubUnitData(subcompanyid1,subcompanyname,receiverids);
if(flag){
retFlag = flag;
}
}
rs.writeLog("syncSubsUnitData end");
return retFlag;
}
}

View File

@ -9,7 +9,6 @@ import weaver.bokang.xiao.tbxc.mapper.FormFieldMapper;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.definedfield.HrmDeptFieldManager;
import weaver.hrm.definedfield.HrmDeptFieldManagerE9;
import weaver.hrm.definedfield.HrmFieldComInfo;
import weaver.hrm.definedfield.HrmFieldGroupComInfo;

View File

@ -9,7 +9,6 @@ import weaver.bokang.xiao.tbxc.mapper.FormFieldMapper;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.company.SubCompanyComInfo;
import weaver.hrm.definedfield.HrmDeptFieldManager;
import weaver.hrm.definedfield.HrmDeptFieldManagerE9;
import weaver.hrm.definedfield.HrmFieldComInfo;
import weaver.hrm.definedfield.HrmFieldGroupComInfo;

View File

@ -1,11 +1,15 @@
package weaver.bokang.xiao.common;
import aiyh.utils.Util;
import org.apache.log4j.Logger;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
import java.io.StringReader;
import java.lang.reflect.Field;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.function.BiPredicate;
import java.util.function.Function;
@ -18,6 +22,8 @@ import java.util.function.Function;
**/
public class CommonUtil {
public static final Logger logger = Util.getLogger();
/**
* <h2></h2>
* @param tableName
@ -230,4 +236,29 @@ public class CommonUtil {
throw new NoSuchFieldException(fieldName);
}
}
public static int getDateInfo(String dateString, int field){
Map<Integer, String> 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;
}
}
}

View File

@ -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 <h1></h1>
**/
@Data
public class ApiConfig {
private int id;
private String requestUnique;
private String apiDesc;
private List<ApiConfigDetail> apiConfigDetailList;
}

View File

@ -0,0 +1,18 @@
package weaver.bokang.xiao.dloa.entity;
import lombok.Data;
/**
* @ClassName ApiConfigDetail
* @Author
* @Date 2023/6/21 15:51
* @Description <h1></h1>
**/
@Data
public class ApiConfigDetail {
private int id;
private String paramName;
private String paramValue;
private String paramDesc;
private String paramStatus;
}

View File

@ -0,0 +1,23 @@
package weaver.bokang.xiao.dloa.entity;
import lombok.Data;
/**
* @ClassName LogEntity
* @Author
* @Date 2023/6/21 15:55
* @Description <h1></h1>
**/
@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;
}

View File

@ -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 <h1></h1>
**/
@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<ApiConfigDetail> queryDetail(@ParamMapper("mainId") int mainId);
@Select("select * from hrm_cus " +
" where created = modified and created between #{beginDate} and #{endDate}")
@ToLowerCase
List<Map<String, Object>> 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<Map<String, Object>> queryHrmUpdatedList(@ParamMapper("beginDate") String beginDate, @ParamMapper("endDate") String endDate);
@Select("select * from hrmdepartment " +
" where created = modified and created between #{beginDate} and #{endDate}")
@ToLowerCase
List<Map<String, Object>> queryDepartAddList(@ParamMapper("beginDate") String beginDate, @ParamMapper("endDate") String endDate);
@Select("select * from hrmdepartment " +
" where modified > created and modified between #{beginDate} and #{endDate}")
@ToLowerCase
List<Map<String, Object>> 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);
}

View File

@ -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 <h1></h1>
**/
@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<Integer, String> 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<Map<String, Object>> hrmAddList = syncHrmMapper.queryHrmAddList(beginDate, endDate);
List<Map<String, Object>> hrmUpdatedList = syncHrmMapper.queryHrmUpdatedList(beginDate, endDate);
List<Map<String, Object>> tempUpdateList = CommonUtil.difference(hrmUpdatedList, hrmAddList, map -> map.get("id"));
List<Map<String, Object>> departAddList = syncHrmMapper.queryDepartAddList(beginDate, endDate);
List<Map<String, Object>> 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<Map<String, Object>> syncList,
RequestMappingConfig requestMappingConfig,
ApiConfig apiConfig,
int syncType, int dataType) throws IOException {
Map<String, String> header = new HashMap<>(8);
header.put("Content-Type", "application/json");
List<Integer> logList = new ArrayList<>();
for (Map<String, Object> syncMap : syncList) {
String requestUrl = spliceRequestUrl(requestMappingConfig.getRequestUrl(), apiConfig);
Map<String, Object> 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<String, Object> 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<Map<String, Object>> syncList,
RequestMappingConfig requestMappingConfig,
ApiConfig apiConfig,
int syncType) throws IOException, InterruptedException {
Map<String, String> header = new HashMap<>(8);
header.put("Content-Type", "application/json");
List<Integer> logList = new ArrayList<>();
CountDownLatch countDownLatch = new CountDownLatch(syncList.size());
for (Map<String, Object> syncMap : syncList) {
String requestUrl = spliceRequestUrl(requestMappingConfig.getRequestUrl(), apiConfig);
Map<String, Object> 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<String, Object> 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<String, Object> 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<ApiConfigDetail> 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<String, Object> requestParam = dealWithMapping.getRequestParam(new HashMap<>(), requestMappingConfig);
ResponeVo responeVo = httpUtils.apiGet(requestMappingConfig.getRequestUrl(), requestParam, new HashMap<>());
if (responeVo.getCode() == 200) {
Map<String, Object> result = responeVo.getResponseMap();
String errCode = Util.null2String(result.get("errcode"));
String errMsg = Util.null2String(result.get("errmsg"));
if("0".equals(errCode)){
Map<String, Object> token = (Map<String, Object>) 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<String, Object> 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<String, Object> result = responeVo.getResponseMap();
String errCode = Util.null2String(result.get("errcode"));
if("0".equals(errCode)){
Map<String, Object> token = (Map<String, Object>) result.get("trade");
tradeId = Util.null2String(token.get("id"));
}
}
return tradeId;
}
}

View File

@ -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 <h1></h1>
**/
@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<String,Object> indexInformation;
/** 配置明细 */
private List<ExamineConfigDetail> examineConfigDetailList;
}

View File

@ -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 <h1></h1>
**/
@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;
}

View File

@ -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 <h1></h1>
**/
@Data
public class ScoreDataEntity {
private List<Map<String,Object>> scoreList;
private List<Map<String,Object>> modeInfoUpdateList;
}

View File

@ -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 <h1></h1>
**/
@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<ExamineConfig> 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<String,Object> 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<Map<String,Object>> queryModeInfoList(Map<String,Object> param);
/**
* <h2>sql</h2>
* @param cusSql sql
* @param param
* @return
*/
@Select(custom = true)
boolean executeCusSql(@SqlString String cusSql, Map<String,Object> param);
}

View File

@ -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 <h1></h1>
**/
@SqlMapper
public interface ScoreMapper {
/**
* <h2>sql</h2>
* @param cusSql sql
* @param updateParam
* @param whereParam
* @return
*/
@Update(custom = true)
boolean executeUpdateCusSql(@SqlString String cusSql,
@ParamMapper("updateParam") Map<String,Object> updateParam,
@ParamMapper("whereParam")Map<String,Object> whereParam);
@BatchUpdate("update $t{tableName} set $t{item.statusField} = #{item.statusValue} where id = #{item.id}")
boolean batchUpdateModeStatus(@ParamMapper("tableName") String tableName,@BatchSqlArgs List<Map<String,Object>> updateList);
}

View File

@ -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 <h1></h1>
**/
@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<String,Object> 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<String,Object> queryParam){
String tableName = Util.null2String(queryParam.get("tableName"));
List<Map<String,Object>> list = examineMapper.queryModeInfoList(queryParam);
ScoreDataEntity scoreDataEntity = examineScoreUtil.doComputeScore(queryParam,list);
if(Objects.nonNull(scoreDataEntity)){
List<Map<String, Object>> scoreList = scoreDataEntity.getScoreList();
List<Map<String, Object>> modeInfoUpdateList = scoreDataEntity.getModeInfoUpdateList();
List<Integer> scoreIdList = new ArrayList<>();
if(Objects.nonNull(scoreList) && !scoreList.isEmpty()){
for (Map<String, Object> scoreMap : scoreList) {
int dataId = Util.getModeDataId(tableName, Util.getIntValue(scoreModeId), 1);
scoreIdList.add(dataId);
Map<String,Object> 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;
}
}

View File

@ -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 <h1></h1>
**/
public class ExamineScoreUtil {
private final ExamineMapper EXAMINE_MAPPER = Util.getMapper(ExamineMapper.class);
private Map<String,List<ExamineConfig>> configExamineMap = new HashMap<>();
public final Logger logger = Util.getLogger();
public ExamineScoreUtil(){
}
public void init(){
List<ExamineConfig> 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<String,Object> queryParam,List<Map<String,Object>> modeInfoList){
String tableName = Util.null2String(queryParam.get("tableName"));
String dateField = Util.null2String(queryParam.get("dateField"));
String teacherField = Util.null2String(queryParam.get("teacherField"));
List<ExamineConfig> examineConfigList = configExamineMap.get(tableName);
if(Objects.isNull(examineConfigList) || examineConfigList.isEmpty()){
logger.info(String.format("没有与此建模 %s 关联的配置信息 ",examineConfigList));
return null;
}
ScoreDataEntity scoreDataEntity = new ScoreDataEntity();
List<Map<String,Object>> scoreList = new ArrayList<>();
List<Map<String,Object>> modeInfoUpdateList = new ArrayList<>();
scoreDataEntity.setScoreList(scoreList);
scoreDataEntity.setModeInfoUpdateList(modeInfoUpdateList);
for (Map<String, Object> modeInfo : modeInfoList) {
for (ExamineConfig examineConfig : examineConfigList) {
List<ExamineConfigDetail> examineConfigDetailList = examineConfig.getExamineConfigDetailList();
for (ExamineConfigDetail examineConfigDetail : examineConfigDetailList) {
int conditionType = examineConfigDetail.getConditionType();
boolean conditionResult = conditionType == 0 ? fieldCondition(examineConfigDetail,modeInfo)
: scriptCondition(examineConfigDetail,modeInfo);
if(conditionResult){
Map<String, Object> indexInformation = examineConfig.getIndexInformation();
String assignScript = examineConfigDetail.getAssignScript();
double score = (double) ScriptUtil.invokeScript(assignScript, modeInfo);
Map<String,Object> 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<String, Object> 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<String, Object> modeInfo){
BiFunction<ExamineConfigDetail, Map<String, Object>, Boolean> fieldConditionFunction = JudgmentRuleProcess.METHOD_MAP.get(examineConfigDetail.getJudgmentRule());
return fieldConditionFunction.apply(examineConfigDetail, modeInfo);
}
}

View File

@ -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 <h1></h1>
**/
public class JudgmentRuleProcess {
public static final Map<Integer, BiFunction<ExamineConfigDetail,Map<String, Object>,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<JudgmentRuleProcess> 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<String, Object> 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<String, Object> 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;
}
}
}

View File

@ -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);
/**
* <h2>isEdit</h2>
* @param formFieldId id
* @return
*/
@Select("select is_edit from hrm_formfield where fieldid = #{formFieldId}")
String queryIsEditByFieldId(@ParamMapper("formFieldId") String formFieldId);
}

View File

@ -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<String> allBaseFiledsName = null;
private HashMap<String, String> allFiledsNameMap = null;
private TreeMap<String, JSONObject> 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<String>();
this.allFiledsNameMap = new HashMap<String, String>();
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)intdecimal
* @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<String, Object> 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<String, Map<String,String>> matrixMap = new HashMap<>();
while (recordSet.next()) {
Map<String, String> 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<lsFieldid.size();i++ ) {
String fieldid = (String)lsFieldid.get(i);
String fieldname = hrmFieldComInfo.getFieldname(fieldid);
String issystem = hrmFieldComInfo.getIssystem(fieldid);
String fieldhtmltype = hrmFieldComInfo.getFieldhtmltype(fieldid);
if(issystem.equals("1"))continue;
nameStr += "," + fieldname;
String fielddbtype = hrmFieldComInfo.getFielddbtype(fieldid);
if (isNeedSynDept && (matrixMap.get(fieldname+"dept") != null) ){
Map<String, String> 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<String, String> 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:syncSingleDepUnitDatadataId"+dataId+" orgName:"+orgName +" receiverids:"+receiverids);
}
if(isNeedSynSub && !"".equals(orgName)) {
boolean success = docReceiveUnitSyncBySubUtil.syncSingleSubUnitData(dataId,orgName,receiverids);
writeLog(success+"==ADDsyncSingleSubUnitDatadataId"+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<lsFieldid.size();i++ ) {
String fieldid = (String)lsFieldid.get(i);
String fieldname = hrmFieldComInfo.getFieldname(fieldid);
//为了保证统一,字段名称统一小写处理
fieldname = fieldname.toLowerCase();
String fieldhtmltype = hrmFieldComInfo.getFieldhtmltype(fieldid);
String issystem = hrmFieldComInfo.getIssystem(fieldid);
String isuse = hrmFieldComInfo.getIsused(fieldid);
if(!isuse.equals("1"))continue;
if(issystem.equals("1")) continue;
setStr += "," + fieldname + "=";
String fielddbtype = hrmFieldComInfo.getFielddbtype(fieldid);
if (fielddbtype.startsWith("text") || fielddbtype.startsWith("char") || fielddbtype.startsWith("varchar")) {
setStr += "'" + Util.null2String(jObject.get(fieldname)) + "'";
} else {
if (Util.null2String(jObject.get(fieldname)).equals("")) {
setStr += "null";
} else {
setStr += Util.null2String(jObject.get(fieldname));
}
}
}
if (!setStr.equals("")) {
setStr = setStr.substring(1);
sql += setStr + " where "+this.base_definedid+"=" + dataId;
rs.executeSql(sql);
}
}
/**
*
* @param scope
* @param scopeId
* @param request
* @param dataId
*/
public void editCustomData(Map<String, Object> params, int dataId)throws Exception {
RecordSet rs = new RecordSet();
RecordSet recordSet = new RecordSet();
//添加查询mapper update by bokang.xiao
FormFieldMapper fieldMapper = aiyh.utils.Util.getMapper(FormFieldMapper.class);
rs.executeSql("select "+this.base_definedid+" from "+this.defined_datatable+" where "+this.base_definedid+"=" + dataId);
if (rs.next()) {
HrmFieldComInfo hrmFieldComInfo = new HrmFieldComInfo();
HrmDeptFieldManagerE9 hrm = new HrmDeptFieldManagerE9(this.scopeid);
List lsFieldid = hrm.allFiledsId;
String sql = "update "+this.defined_datatable+" set ";
String setStr = "";
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
String cusMatrixSql = "select matrixId,matrixFieldName,type,orgType from uf_sfwdwtbszb";//orgType:部门dept,分部subcom
recordSet.executeQuery(cusMatrixSql);
Map<String, Map<String,String>> matrixMap = new HashMap<>();
while (recordSet.next()) {
Map<String, String> 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<lsFieldid.size();i++ ) {
String fieldid = (String)lsFieldid.get(i);
String fieldname = hrmFieldComInfo.getFieldname(fieldid);
String fieldhtmltype = hrmFieldComInfo.getFieldhtmltype(fieldid);
String issystem = hrmFieldComInfo.getIssystem(fieldid);
String isuse = hrmFieldComInfo.getIsused(fieldid);
//不可编辑则跳过此字段 update by bokang.xiao
String isEdit = fieldMapper.queryIsEditByFieldId(fieldid);
if("0".equals(isEdit) || "".equals(isEdit)){
continue;
}
if(issystem.equals("1"))continue;
if(!isuse.equals("1"))continue;
setStr += "," + fieldname + "=";
String fielddbtype = hrmFieldComInfo.getFielddbtype(fieldid);
if (isNeedSynDept && (matrixMap.get(fieldname+"dept") != null) ){
Map<String, String> 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<String, String> 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:syncSingleDepUnitDatadataId"+dataId+" orgName:"+orgName +" receiverids:"+receiverids);
}
if(isNeedSynSub){
boolean success = docReceiveUnitSyncBySubUtil.syncSingleSubUnitData(dataId,orgName,receiverids);
writeLog(success+"==ADDsyncSingleSubUnitDatadataId"+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<FieldSelectOptionBean> lsSelectOption) {
RecordSet rs = new RecordSet();
String sql = "";
List<String> allOption = new ArrayList<String>();
List<String> delOption = new ArrayList<String>();
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&&i<lsField.size();i++){
String fieldid = (String)lsField.get(i);
if(hrmFieldComInfo.getIsused(fieldid).equals("1")){
count++;
}
}
return count;
}
public String getHtmlBrowserFieldvalue(User user,String dmlurl,int fieldId,
int fieldHtmlType, int fieldType, String fieldValue,String fielddbtype)
throws Exception {
RecordSet rs = new RecordSet();
String showname = "";
if(!"".equals(fieldValue)){
//<a href="/hrm/resource/HrmResource.jsp?id=360" target="_blank">lyx04</a>
BrowserComInfo browserComInfo = new BrowserComInfo();
String linkurl =browserComInfo.getLinkurl(""+fieldType);
boolean isLink=!"".equals(linkurl);
String linkurlStart="<a href=\""+linkurl;
String linkurlEnd="\" target=\"_blank\">";
String aEnd="</a>";
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+ "&nbsp;&nbsp;":resourceComInfo.getResourcename((String) tempshowidlist.get(k))+"&nbsp;&nbsp;";
if((k+1)%10==0) showname+="<br>";
}
} 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+ "&nbsp;&nbsp;":departmentComInfo.getDepartmentname((String) tempshowidlist.get(k))+"&nbsp;&nbsp;";
}
} 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+ "&nbsp;&nbsp;":projectInfoComInfo.getProjectInfoname((String) tempshowidlist.get(k))+ "&nbsp;&nbsp;";
}
} 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+ "&nbsp;&nbsp;":customerInfoComInfo.getCustomerInfoname((String) tempshowidlist.get(k))+ "&nbsp;&nbsp;";
}
} 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+ "&nbsp;&nbsp;":subCompanyComInfo.getSubCompanyname((String) tempshowidlist.get(k))
+ "&nbsp;&nbsp;";
}
} 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+ "&nbsp;&nbsp;":docComInfo.getDocname((String) tempshowidlist.get(k)) + "&nbsp;&nbsp;";
}
} 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+ "&nbsp;&nbsp;":capitalComInfo.getCapitalname((String) tempshowidlist.get(k))
+ "&nbsp;&nbsp;";
}
} 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+ "&nbsp;&nbsp;":workflowRequestComInfo.getRequestName((String) tempshowidlist.get(k))
+ "&nbsp;&nbsp;";
}
} 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+ "&nbsp;&nbsp;":docReceiveUnitComInfo.getReceiveUnitName((String) tempshowidlist.get(k))
+ "&nbsp;&nbsp;";
}
} else if (fieldType == 226 || fieldType == 227) {// -zzl系统集成浏览按钮
showname += fieldValue;
} else if (fieldType == 268 ) {// 多星期
showname += MeetingBrowser.getWeekNames(fieldValue, user.getLanguage());
showname=showname.replace(",", "&nbsp;&nbsp;");
} else if (fieldType == 269 ) {// 多提醒方式
showname += MeetingBrowser.getRemindNames(fieldValue, user.getLanguage());
showname=showname.replace(",", "&nbsp;&nbsp;");
} 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<tempshowidlist.size();k++){
try{
BrowserBean bb=browser.searchById((String)tempshowidlist.get(k));
String desc=Util.null2String(bb.getDescription());
String name=Util.null2String(bb.getName());
if(showname.equals("")){
showname += name;
}else{
showname += "," +name;
}
}catch (Exception e){
}
}
}catch(Exception e){
writeLog(e);
}
}else if(fieldType==256||fieldType==257){
CustomTreeUtil customTreeUtil = new CustomTreeUtil();
showname = customTreeUtil.getTreeFieldShowName(fieldValue,fielddbtype);
} else {
String sql = "";
String tablename = browserComInfo.getBrowsertablename(""+ fieldType);
String columname = browserComInfo.getBrowsercolumname(""+ fieldType);
String keycolumname = browserComInfo.getBrowserkeycolumname("" + fieldType);
if (columname.equals("") || tablename.equals("")
|| keycolumname.equals("") || fieldValue.equals("")) {
//writeLog("GET FIELD ERR: fieldType=" + fieldType);
} else {
sql = "select "+ columname +"," +keycolumname+" from " + tablename
+ " where " + keycolumname + " in(" + fieldValue
+ ")";
rs.executeSql(sql);
while (rs.next()) {
showname += isLink?linkurlStart+rs.getString(2)+linkurlEnd+rs.getString(1) +aEnd+ "&nbsp;&nbsp;":rs.getString(1) + "&nbsp;&nbsp;";
}
}
}
}else {
showname = fieldValue;
}
}
return showname;
}
public String getFormatId(String receiverids, String type ) {
String receiveridsWithType = "";
if("".equals(receiverids) || "".equals(type)){
return receiveridsWithType;
}
for (String idStr : receiverids.split(",")) {
if (receiveridsWithType.length() > 0) {
receiveridsWithType += "," + type + idStr;
} else {
receiveridsWithType += type + idStr;
}
}
return receiveridsWithType;
}
}

View File

@ -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<String,Object> 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();