信银知识产权局

main
ic_excellent 2023-04-20 14:18:27 +08:00
parent ed3b04b6d5
commit c9aee48ecd
60 changed files with 2806 additions and 89 deletions

View File

@ -124,7 +124,7 @@ public class YearReviewController {
try{
log.info("into getWorkflowTop success params ==> "+param);
User loginUser = HrmUserVarify.getUser(request, response);
loginUser.setLoginid("9");
loginUser.setLoginid("8");
param.put("workflowIds",workflowIds);
if(!param.containsKey("limit")){
param.put("limit",3);

View File

@ -125,14 +125,14 @@ public interface ReviewMapper {
* @return
*/
@Select("select " +
" wrb.workflowid,wb.workflowname,count(*) wcount " +
" wrb.workflowid,wb.workflowname workflowName,count(*) wcount " +
"from workflow_requestoperatelog wfo " +
"inner join workflow_requestbase wrb on wfo.requestid = wrb.requestid " +
"inner join workflow_base wb on wrb.workflowid = wb.id " +
"inner join workflow_nodebase wnb on wfo.nodeid = wnb.id " +
"where (wfo.operatorid <> wrb.creater || (wfo.operatorid = wrb.creater && wnb.isstart <> 1)) " +
" and (wfo.operatedate between #{param.startDate} and #{param.endDate}) " +
" and operatorid = #{uid} and workflowid not in (${param.workflowIds}) " +
" and operatorid = #{uid} and workflowid not in ($t{param.workflowIds}) " +
"group by workflowid " +
"order by wcount desc " +
"limit ${param.limit}")

View File

@ -6,6 +6,7 @@ import com.api.bokang.xiao.porsche_review.service.ReviewService;
import io.swagger.models.auth.In;
import org.apache.log4j.Logger;
import weaver.hrm.User;
import weaver.workflow.request.RequestLogOperateName;
import java.util.HashMap;
import java.util.List;
@ -60,12 +61,18 @@ public class ReviewServiceImpl implements ReviewService {
@Override
public List<Map<String, Object>> getCreateTop5(Map<String, Object> param, User user) {
return reviewMapper.queryCreateTop5(param,user.getUID());
List<Map<String, Object>> maps = reviewMapper.queryCreateTop5(param, user.getUID());
maps.forEach(item -> item.put("workflowName",Util.formatMultiLang(Util.null2String(item.get("workflowName")),"8")));
log.info("maps ==>"+maps);
return maps;
}
@Override
public List<Map<String, Object>> getOperateTop5(Map<String, Object> param, User user) {
return reviewMapper.queryOperateTop5(param,user.getUID());
List<Map<String, Object>> maps = reviewMapper.queryOperateTop5(param, user.getUID());
maps.forEach(item -> item.put("workflowName",Util.formatMultiLang(Util.null2String(item.get("workflowName")),"8")));
log.info("maps ==>"+maps);
return maps;
}
@Override

View File

@ -1,64 +0,0 @@
package com.api.bokang.xiao.xhny_report;
import aiyh.utils.Util;
import org.apache.log4j.Logger;
import weaver.general.StaticObj;
import weaver.interfaces.datasource.DataSource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
/**
* @ClassName ReportController
* @Author
* @Date 2023/3/20 15:49
* @Description <h1></h1>
**/
@Path("/xbk/xhny_report")
public class ReportController {
private final Logger log = Util.getLogger();
/**
* <h2></h2>
* @param request
* @param response
* @return
*/
@Path("/testDataSource")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String testDataSource(@Context HttpServletRequest request, @Context HttpServletResponse response){
DataSource ds = (DataSource) StaticObj.getServiceByFullname(("datasource.NCC"),DataSource.class);
Connection conn = null ;
// CallableStatement对象
CallableStatement callableStatement = null;
// 结果集对象
ResultSet resultSet = null;
try{
conn = ds.getConnection();
callableStatement = conn.prepareCall("{CALL kd_po_nastnumAndnassistnum(?,?,?)}");
callableStatement.setString(1,"GC736");
callableStatement.setString(2,"2023-01-01");
callableStatement.setString(3,"2023-04-01");
resultSet = callableStatement.executeQuery();
if(resultSet.next()){
log.info("数据源请求结果 ==>"+resultSet.getString("nrate"));
}
} catch (Exception e) {
log.error("远程调用存储过程失败 ==>"+Util.getErrString(e));
}
return "查看日志信息";
}
}

View File

@ -0,0 +1,124 @@
package com.api.bokang.xiao.zscq.controller;
import aiyh.utils.ApiResult;
import aiyh.utils.Util;
import com.api.bokang.xiao.zscq.service.ReserveService;
import com.api.bokang.xiao.zscq.service.impl.ReserveServiceImpl;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.apache.log4j.Logger;
import weaver.file.ImageFileManager;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.xiao.commons.config.entity.WeaverFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* @ClassName ReserveSelectController
* @Author
* @Date 2023/4/12 17:42
* @Description <h1></h1>
**/
@Path("/xbk/zscq")
public class ReserveSelectController {
private final Logger log = Util.getLogger();
private final ReserveService reserveService = new ReserveServiceImpl();
/**
* <h2></h2>
* @param request
* @param response
* @return
*/
@Path("/reserveSelect")
@POST
@Produces(MediaType.APPLICATION_JSON)
public String reserveSelect(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) {
try{
log.info("====== into getReportData success =======");
log.info("param:"+param);
User loginUser = HrmUserVarify.getUser(request, response);
List<Map<String, Object>> result = reserveService.reserveSelect(param);
return ApiResult.success(result);
}catch (Exception e){
log.error("获取搜索组件信息 ==> "+ Util.getErrString(e));
return ApiResult.error(e.getMessage());
}
}
//@GET
//@Path("/batch")
//@Produces(MediaType.APPLICATION_OCTET_STREAM)
//public void downloadFiles(@QueryParam("ids") String ids, @Context HttpServletResponse response) {
// try {
// log.info("Start downloading files: {}"+ids);
// // 解析文件ID列表
// List<Long> idList = Arrays.stream(ids.split(","))
// .map(Long::parseLong)
// .collect(Collectors.toList());
//
// // 生成压缩文件名
// String zipFileName = "attachments.zip";
//
// // 设置响应头,告诉浏览器该响应体是一个附件,浏览器会自动下载该响应体
// response.setContentType(MediaType.APPLICATION_OCTET_STREAM);
// response.setHeader("Content-Disposition", "attachment; filename=\"" + zipFileName + "\"");
//
// // 创建压缩输出流
// try (ZipOutputStream zipOutputStream = new ZipOutputStream(response.getOutputStream())) {
//
// // 遍历文件ID列表将对应的文件加入到压缩文件中
// for (Long id : idList) {
// // 通过ID获取文件信息
// WeaverFile file = WeaverFileUtil.getFileMsgById(id);
//
// // 获取文件名和后缀名
// String fileName = file.getName();
// String fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1);
//
// // 创建一个ZipEntry表示压缩文件中的一个文件
// ZipEntry zipEntry = new ZipEntry(fileName);
// zipEntry.setSize(file.getSize());
// zipEntry.setTime(System.currentTimeMillis());
//
// // 将ZipEntry添加到压缩输出流中
// zipOutputStream.putNextEntry(zipEntry);
//
// // 将文件内容写入到压缩输出流中
// byte[] buffer = new byte[BUFFER_SIZE];
// int len;
// try (InputStream inputStream = file.getInputStream()) {
// while ((len = inputStream.read(buffer)) > 0) {
// zipOutputStream.write(buffer, 0, len);
// }
// }
// zipOutputStream.closeEntry();
// }
//
// // 刷新压缩输出流
// zipOutputStream.flush();
// }
// log.info("Finish downloading files: {}"+ids);
// } catch (Exception e) {
// log.error("下载附件异常: {}"+Util.getErrString(e));
// // 如果出现异常,返回一个空的响应体
// response.reset();
// response.setContentType(MediaType.APPLICATION_OCTET_STREAM);
// response.setContentLength(0);
// }
//}
}

View File

@ -0,0 +1,55 @@
package com.api.bokang.xiao.zscq.mapper;
import aiyh.utils.annotation.recordset.*;
import java.util.List;
import java.util.Map;
/**
* @ClassName ReserveSelectMapper
* @Author
* @Date 2023/4/14 10:28
* @Description <h1></h1>
**/
@SqlMapper
public interface ReserveSelectMapper {
/**
* <h2></h2>
* @param requestId id
* @return
*/
@Select("select operator userId,operatortype userType from workflow_requestlog where requestid=#{requestId}" +
" and (logtype='2' or logtype='0' or logtype='3' or logtype='e') " +
" and exists(select 1 from workflow_currentoperator where requestid=workflow_requestlog.requestid and userid=workflow_requestlog.operator and usertype=workflow_requestlog.operatortype and isremark='2' and preisremark='0' and operatedate is not null and operatedate>' ') " +
" group by operator,operatortype order by max(logid) desc")
Map<String,Integer> queryRequestMsg(@ParamMapper("requestId")String requestId);
/**
* <h2></h2>
* @param requestId id
* @return
*/
@Select("select userid userId,usertype userType from workflow_currentoperator where requestid = #{requestId} and isremark = '2' and preisremark='0' and operatedate is not null and operatedate>' ' order by operatedate desc ,operatetime desc")
Map<String,Integer> queryOperator(@ParamMapper("requestId")String requestId);
/**
* <h2></h2>
* @param param
* @return
*/
@Select("select id, $t{applicationNoField}, $t{workflowInfoField}, $t{checkResultField} from $t{modeTableName} where $t{dateField} = #{datePicker}")
@CaseConversion(value = false)
List<Map<String, Object>> queryModeList(Map<String, Object> param);
/**
* <h2></h2>
* @param forceOverList id
* @param param
* @return
*/
@Update("update $t{param.modeTableName} set $t{param.checkResultField} = #{param.repossessedValue} " +
" where $t{param.workflowInfoField} in (${doRepossessedList})")
boolean updateRepossessed(@ParamMapper("doRepossessedList") List<String> forceOverList,
@ParamMapper("param") Map<String, Object> param);
}

View File

@ -0,0 +1,25 @@
package com.api.bokang.xiao.zscq.service;
import aiyh.utils.Util;
import org.apache.log4j.Logger;
import java.util.List;
import java.util.Map;
/**
* @ClassName ReserveService
* @Author
* @Date 2023/4/12 17:44
* @Description <h1></h1>
**/
public interface ReserveService {
Logger log = Util.getLogger();
/**
* <h2></h2>
* @param param
* @return
*/
List<Map<String,Object>> reserveSelect(Map<String,Object> param);
}

View File

@ -0,0 +1,114 @@
package com.api.bokang.xiao.zscq.service.impl;
import aiyh.utils.Util;
import com.api.bokang.xiao.zscq.mapper.ReserveSelectMapper;
import com.api.bokang.xiao.zscq.service.ReserveService;
import weaver.hrm.User;
import weaver.workflow.workflow.RequestForceDrawBack;
import weaver.workflow.workflow.WfForceDrawBack;
import weaver.workflow.workflow.WfForceOver;
import weaver.workflow.workflow.WfFunctionManageUtil;
import java.util.*;
import java.util.stream.Collectors;
/**
* @ClassName ReserveServiceImpl
* @Author
* @Date 2023/4/14 10:11
* @Description <h1></h1>
**/
public class ReserveServiceImpl implements ReserveService {
private final ReserveSelectMapper reserveSelectMapper = Util.getMapper(ReserveSelectMapper.class);
private final WfForceOver wfForceOver = new WfForceOver();
private final WfFunctionManageUtil wfFunctionManageUtil = new WfFunctionManageUtil();
private final WfForceDrawBack wfForceDrawBack = new WfForceDrawBack();
private final RequestForceDrawBack requestForceDrawBack = new RequestForceDrawBack();
/**
* <h2></>
* @param requestIdList id
* @param user
* @return
*/
private List<Map<String,Object>> doRepossessed(List<Integer> requestIdList, User user){
return requestIdList.stream().map(item -> {
Map<String,Object> repossessedResult = new HashMap<>();
boolean flag = doRepossessedSign(item, user);
repossessedResult.put(String.valueOf(item),flag);
return repossessedResult;
}).collect(Collectors.toList());
}
/**
* <h2></>
* @param requestId id
* @param user
* @return
*/
private boolean doRepossessedSign(int requestId,User user){
//查询最后一个操作者
Map<String, Integer> operateInfo = reserveSelectMapper.queryRequestMsg(String.valueOf(requestId));
log.info(" doRepossessedSign operateInfo ==>"+operateInfo);
if(Objects.isNull(operateInfo)){
operateInfo = reserveSelectMapper.queryOperator(String.valueOf(requestId));
}
int tempUser = operateInfo.get("userId");
int tempUserType = operateInfo.get("userType");
boolean canForceDrawBack = false;
if(RequestForceDrawBack.isOldRequest(requestId) == RequestForceDrawBack.OLDDATA){
canForceDrawBack = wfForceDrawBack.isHavePurview(requestId, user.getUID(), Integer.parseInt(user.getLogintype()), tempUser, tempUserType);
}else{
canForceDrawBack = RequestForceDrawBack.isHavePurview(user.getUID(), requestId, true);
}
if (canForceDrawBack && wfFunctionManageUtil.haveOtherOperationRight(requestId)) {
int result = requestForceDrawBack.foreceDrawBack(user, requestId, true, tempUser, tempUserType);
return requestForceDrawBack.isAddInOperateSuccess();
}else{
return false;
}
}
/**
* <h2></>
* @param requestIdList id
* @param user
*/
private void doForceOver(ArrayList<String> requestIdList, User user){
wfForceOver.doForceOver(requestIdList,user);
}
@Override
public List<Map<String, Object>> reserveSelect(Map<String, Object> param) {
List<Map<String, Object>> result = new ArrayList<>();
List<Map<String,Object>> modeList = reserveSelectMapper.queryModeList(param);
String checkResultField = Util.null2String(param.get("checkResultField"));
String workflowInfoField = Util.null2String(param.get("workflowInfoField"));
String checkResultValue = Util.null2String(param.get("checkResultValue"));
if(Objects.nonNull(modeList) && !modeList.isEmpty()){
ArrayList<String> forceOverList = new ArrayList<>();
List<Integer> doRepossessedList = new ArrayList<>();
for (Map<String, Object> modeInfo : modeList) {
String checkResult = Util.null2String(modeInfo.get(checkResultField));
int requestId = Util.getIntValue(Util.null2String(modeInfo.get(workflowInfoField)));
if(checkResult.equals(checkResultValue)){
forceOverList.add(requestId+"");
}else {
doRepossessedList.add(requestId);
}
}
log.info(String.format("doRepossessedList ==> %s forceOverList ==> %s",doRepossessedList,forceOverList));
result = doRepossessed(doRepossessedList, new User(1));
log.info("撤回处理结果 ==>"+result);
doForceOver(forceOverList,new User(1));
boolean flag = reserveSelectMapper.updateRepossessed(forceOverList, param);
log.info("更新检查结果字段结果 ==>"+flag);
}
return result;
}
}

View File

@ -0,0 +1,76 @@
package com.api.bokang.xiao.zxyh.generate_code.controller;
import aiyh.utils.ApiResult;
import aiyh.utils.Util;
import com.api.bokang.xiao.zxyh.generate_code.service.GenerateContractNoService;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.apache.log4j.Logger;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
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;
import javax.ws.rs.core.MediaType;
import java.util.Map;
/**
* @ClassName GenerateContractNo
* @Author
* @Date 2023/3/23 15:26
* @Description <h1></h1>
**/
@Path("/xbk/zxyh_generate")
public class GenerateContractNoController {
private final Logger log = Util.getLogger();
private final GenerateContractNoService generateContractNoService = new GenerateContractNoService();
/**
* <h2></h2>
* @param request
* @param response
* @return
*/
@Path("/generateCode")
@POST
@Produces(MediaType.APPLICATION_JSON)
public String generateCode(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) {
try{
log.info("========= into generateCode success ==========");
log.info("param:"+param);
User loginUser = HrmUserVarify.getUser(request, response);
return ApiResult.success(generateContractNoService.generateCode(param));
}catch (Exception e){
log.error("generateCode error ==>"+Util.getErrString(e));
return ApiResult.error();
}
}
/**
* <h2></h2>
* @param request
* @param response
* @return
*/
@Path("/deleteCode")
@POST
@Produces(MediaType.APPLICATION_JSON)
public String deleteCode(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) {
try{
log.info("========= into deleteCode success ==========");
log.info("param:"+param);
User loginUser = HrmUserVarify.getUser(request, response);
return ApiResult.success(generateContractNoService.deleteContractCode(param));
}catch (Exception e){
log.error("generateCode error ==>"+Util.getErrString(e));
return ApiResult.error();
}
}
}

View File

@ -0,0 +1,44 @@
package com.api.bokang.xiao.zxyh.generate_code.mapper;
import aiyh.utils.annotation.recordset.Delete;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
import aiyh.utils.annotation.recordset.Update;
import java.util.Map;
/**
* @ClassName GenerateMapper
* @Author
* @Date 2023/3/23 15:38
* @Description <h1></h1>
**/
@SqlMapper
public interface GenerateMapper {
/**
* <h2></h2>
* @param param
* @return
*/
@Update("update uf_contract_num_log set workflow_info = #{workflowInfo},file_info = #{fileInfo},detail_id = #{detailId}," +
"row_id = #{rowId},contract_name = #{contractName},contract_num = #{contractNum},flow_num = #{flowNum} where id = #{dataId}")
boolean updateContractLog(Map<String,Object> param);
/**
* <h2></h2>
* @return
*/
@Select("select max(flow_num) from uf_contract_num_log")
int getMaxFlow();
/**
* <h2></h2>
* @param param
* @return
*/
@Delete("delete from uf_contract_num_log where workflow_info = #{workflowInfo} and file_info = #{fileInfo} and detail_id = #{detailId} " +
" and row_id = #{rowId} and contract_num = #{contractNum} ")
boolean deleteContractFileCode(Map<String, Object> param);
}

View File

@ -0,0 +1,67 @@
package com.api.bokang.xiao.zxyh.generate_code.service;
import aiyh.utils.Util;
import com.api.bokang.xiao.zxyh.generate_code.mapper.GenerateMapper;
import org.apache.log4j.Logger;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
/**
* @ClassName GenerateContractNoService
* @Author
* @Date 2023/3/23 15:52
* @Description <h1></h1>
**/
public class GenerateContractNoService {
private final GenerateMapper generateMapper = Util.getMapper(GenerateMapper.class);
private final Logger log = Util.getLogger();
private final static String FORMAT_STRING = "yyyyMM";
private final static String DEFAULT_STR = "YYHT";
private final static String TABLE_NAME = "uf_contract_num_log";
private final static Integer FLOW_LENGTH = 3;
public String generateCode(Map<String,Object> param){
int maxFlow = generateMapper.getMaxFlow();
maxFlow = Math.max(maxFlow,0);
maxFlow++;
String contractNo = "";
String formatDate = this.getFormatDate(new Date(), FORMAT_STRING);
StringBuilder flowStr = new StringBuilder(maxFlow + "");
//长度不足补0
if(flowStr.length() < FLOW_LENGTH){
for (int i = flowStr.length(); i < FLOW_LENGTH; i++) {
flowStr.insert(0, "0");
}
}
contractNo = DEFAULT_STR + formatDate + flowStr;
log.info(" contractFileNo ==>"+contractNo);
int dataId = Util.getModeDataId(TABLE_NAME, 1);
param.put("dataId",dataId);
param.put("contractNum",contractNo);
param.put("flowNum",maxFlow);
boolean updateFlag = generateMapper.updateContractLog(param);
Util.rebuildModeDataShareByAsync(1,TABLE_NAME,dataId);
if(updateFlag){
return contractNo;
}
return "";
}
public boolean deleteContractCode(Map<String,Object> param){
return generateMapper.deleteContractFileCode(param);
}
private String getFormatDate(Date date, String formatString){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(formatString);
return simpleDateFormat.format(date);
}
}

View File

@ -0,0 +1,55 @@
package com.api.bokang.xiao.zxyh.remind.controller;
import aiyh.utils.ApiResult;
import aiyh.utils.Util;
import com.api.bokang.xiao.zxyh.remind.service.RemindService;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.apache.log4j.Logger;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
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;
import javax.ws.rs.core.MediaType;
import java.util.List;
import java.util.Map;
/**
* @ClassName RemindController
* @Author
* @Date 2023/4/18 9:59
* @Description <h1></h1>
**/
@Path("/xbk/remind")
public class RemindController {
private final Logger log = Util.getLogger();
private final RemindService remindService = new RemindService();
/**
* <h2></h2>
* @param request
* @param response
* @return
*/
@Path("/getRemindList")
@POST
@Produces(MediaType.APPLICATION_JSON)
public String getRemindList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody Map<String,Object> param) {
try{
log.info("========= into getRemindList success ==========");
log.info("param:"+param);
User loginUser = HrmUserVarify.getUser(request, response);
List<Map<String,Object>> remindList = remindService.getRemindList(param,loginUser);
return ApiResult.success(remindList);
}catch (Exception e){
log.error("getRemindList error ==>"+Util.getErrString(e));
return ApiResult.error();
}
}
}

View File

@ -0,0 +1,32 @@
package com.api.bokang.xiao.zxyh.remind.mapper;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
import java.util.List;
import java.util.Map;
/**
* @ClassName RemindMapper
* @Author
* @Date 2023/4/18 9:59
* @Description <h1></h1>
**/
@SqlMapper
public interface RemindMapper {
/**
* <h2></h2>
* @param param
* @return
*/
@Select("select distinct wr.REQUESTID as requestId, " +
" wr.REQUESTNAME, " +
" wr.requestnamenew as requestName, " +
" wc.RECEIVEDATE as receiveDate, " +
" datediff(now(),wc.RECEIVEDATE) as overDays " +
"from workflow_requestbase wr " +
"inner join workflow_currentoperator wc on wr.REQUESTID = wc.REQUESTID and wr.CURRENTNODEID = wc.NODEID " +
"where wr.WORKFLOWID in ($t{workflowIds}) and wc.NODEID in ($t{nodeIds}) and wr.CREATER = #{userId} and datediff(now(),wc.RECEIVEDATE) > #{dayLimit}")
List<Map<String, Object>> queryRemindList(Map<String,Object> param);
}

View File

@ -0,0 +1,27 @@
package com.api.bokang.xiao.zxyh.remind.service;
import aiyh.utils.Util;
import com.api.bokang.xiao.zxyh.remind.mapper.RemindMapper;
import org.apache.log4j.Logger;
import weaver.hrm.User;
import java.util.List;
import java.util.Map;
/**
* @ClassName RemindService
* @Author
* @Date 2023/4/18 9:59
* @Description <h1></h1>
**/
public class RemindService {
private final Logger log = Util.getLogger();
private final RemindMapper remindMapper = Util.getMapper(RemindMapper.class);
public List<Map<String, Object>> getRemindList(Map<String, Object> param, User loginUser) {
param.put("userId",loginUser.getUID());
return remindMapper.queryRemindList(param);
}
}

View File

@ -0,0 +1,25 @@
package weaver.bokang.xiao.common.mapper;
import aiyh.utils.annotation.recordset.ParamMapper;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
import java.util.Map;
/**
* @ClassName HrmMapper
* @Author
* @Date 2023/4/3 20:21
* @Description <h1></h1>
**/
@SqlMapper
public interface HrmMapper {
/**
* <h2>id</h2>
* @param departId id
* @return
*/
@Select("select * from hrmDepartment where id = #{departId}")
Map<String,Object> getDepartInfoById(@ParamMapper("departId")int departId);
}

View File

@ -0,0 +1,35 @@
package weaver.bokang.xiao.common.mapper;
import aiyh.utils.annotation.recordset.ParamMapper;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
import java.util.Map;
/**
* @ClassName ModeMapper
* @Author
* @Date 2023/4/3 17:44
* @Description <h1></h1>
**/
@SqlMapper
public interface ModeMapper {
/**
* <h2></h2>
* @param tableName
* @param param
* @return
*/
@Select("select * from $t{tableName} where $t{param.fieldName} = #{param.fieldValue}")
Map<String,Object> queryModeDataInfo(@ParamMapper("tableName") String tableName,
@ParamMapper("param") Map<String,Object> param);
/**
* <h2>formId</h2>
* @param formId id
* @return
*/
@Select("select tablename from workflow_bill where id = #{formId}")
String queryTableName(@ParamMapper("tableName") String formId);
}

View File

@ -0,0 +1,56 @@
package weaver.bokang.xiao.deg_repeat_check.action;
import aiyh.utils.Util;
import aiyh.utils.action.SafeCusBaseAction;
import aiyh.utils.annotation.ActionDesc;
import aiyh.utils.annotation.ActionOptionalParam;
import aiyh.utils.annotation.PrintParamMark;
import aiyh.utils.excention.CustomerException;
import lombok.Setter;
import weaver.bokang.xiao.deg_repeat_check.mapper.RepeatCheckMapper;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import java.util.Map;
/**
* @ClassName RepeatCheckAction
* @Author
* @Date 2023/3/31 15:19
* @Description <h1></h1>
**/
@ActionDesc(value = "流程编号重复校验",author = "bokang.xiao")
@Setter
public class RepeatCheckAction extends SafeCusBaseAction {
@ActionOptionalParam(value = "bh",desc = "流程编号字段")
@PrintParamMark
private String workflowNumField = "bh";
@ActionOptionalParam(value = "bh",desc = "建模编号字段")
@PrintParamMark
private String modeNumField = "bh";
@ActionOptionalParam(value = "uf_xszktz",desc = "建模表名")
@PrintParamMark
private String modeTableName = "uf_xszktz";
@ActionOptionalParam(value = "编号重复,不允许提交",desc = "建模表名")
@PrintParamMark
private String errorMsg = "编号重复,不允许提交";
private final RepeatCheckMapper repeatCheckMapper = Util.getMapper(RepeatCheckMapper.class);
@Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
log.info(String.format("=================== {%s} {requestId : %s} begin ======================", this.getClass().getName(),requestId));
Map<String, String> mainTable = this.getMainTableValue(requestInfo);
String workflowNum = Util.null2String(mainTable.get(workflowNumField));
int workflowCount = repeatCheckMapper.getWorkflowCount(billTable,workflowNumField,requestId, workflowNum);
int modeCount = repeatCheckMapper.getModeCount(modeTableName,modeNumField,workflowNum);
log.info(String.format("workflowCount:[%s] workflowNum:[%s] modeCount:[%s]",workflowCount,workflowNum,modeCount));
if(workflowCount > 0 || modeCount > 0){
throw new CustomerException(errorMsg);
}
}
}

View File

@ -0,0 +1,48 @@
package weaver.bokang.xiao.deg_repeat_check.mapper;
import aiyh.utils.annotation.recordset.ParamMapper;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
/**
* @ClassName RepeatCheckMapper
* @Author
* @Date 2023/3/31 15:23
* @Description <h1></h1>
**/
@SqlMapper
public interface RepeatCheckMapper {
/**
* <h2></h2>
* @param tableName
* @param fieldName
* @param requestId requestId
* @param number
* @return
*/
@Select("select count(1) " +
"from $t{tableName} main " +
" inner join workflow_currentoperator wco on main.REQUESTID = wco.REQUESTID " +
" inner join workflow_nodebase wnb on wco.NODEID = wnb.id " +
"where $t{fieldName} = #{number} and main.REQUESTID <> #{requestId} and wnb.ISSTART <> 1")
int getWorkflowCount(@ParamMapper("tableName")String tableName,
@ParamMapper("fieldName")String fieldName,
@ParamMapper("requestId")String requestId,
@ParamMapper("number")String number);
/**
* <h2></h2>
* @param tableName
* @param fieldName
* @param number
* @return
*/
@Select("select count(1) " +
"from $t{tableName} main where main.bh = #{number}")
int getModeCount(@ParamMapper("tableName")String tableName,
@ParamMapper("fieldName")String fieldName,
@ParamMapper("number")String number);
}

View File

@ -0,0 +1,22 @@
package weaver.bokang.xiao.xhny_mode.entity;
import lombok.Data;
/**
* @ClassName SqlConditionDtEntity
* @Author
* @Date 2023/4/9 13:15
* @Description <h1></h1>
**/
@Data
public class SqlConditionDtEntity {
/** 数据库字段名 */
private String fieldName;
/** 条件类型 */
private Integer cusCondition;
/** 文本框 */
private String cusText;
}

View File

@ -0,0 +1,29 @@
package weaver.bokang.xiao.xhny_mode.entity;
import lombok.Data;
import java.util.List;
/**
* @ClassName SqlConditonEntity
* @Author
* @Date 2023/4/9 13:15
* @Description <h1></h1>
**/
@Data
public class SqlConditionEntity {
/** 选择查询 */
private String selectInfo;
/** 唯一标识 */
private String uniqueCode;
/** 说明 */
private String description;
/** 配置明细 */
private List<SqlConditionDtEntity> sqlConditionDtEntityList;
}

View File

@ -0,0 +1,58 @@
package weaver.bokang.xiao.xhny_mode.mapper;
import aiyh.utils.annotation.recordset.*;
import weaver.bokang.xiao.xhny_mode.entity.SqlConditionDtEntity;
import weaver.bokang.xiao.xhny_mode.entity.SqlConditionEntity;
import java.util.List;
import java.util.Map;
/**
* @ClassName SearchMapper
* @Author
* @Date 2023/4/3 21:33
* @Description <h1></h1>
**/
@SqlMapper
public interface SearchMapper {
/**
* <h2>id</h2>
* @param userId id
* @return
*/
@Select("select departmentcode from HrmDepartment where departmentmark = ("+
" select lastname from hrmresource where id = #{userId})")
String getDepartCode(@ParamMapper("userId")int userId);
/**
* <h2>sql</h2>
* @param customId id
* @return
*/
@Select("select * from uf_sql_config where select_info = #{customId}")
@CollectionMappings({
@CollectionMapping(column = "id",property = "sqlConditionDtEntityList",id = @Id(value = Integer.class,methodId = 1))
})
SqlConditionEntity querySqlCondition(@ParamMapper("customId")String customId);
/**
* <h2></h2>
* @param mainId id
* @return
*/
@CollectionMethod(1)
@Select("select * from uf_sql_config_dt1 where mainid = #{mainId}")
List<SqlConditionDtEntity> querySqlConditionDt(@ParamMapper("mainId")int mainId);
/**
* <h2>sql</h2>
* @param cusSql sql
* @param param
* @param cusParam
* @return
*/
@Select(custom = true)
String executeCusSql(@SqlString String cusSql, @ParamMapper("user") Map<String,Object> param, @ParamMapper("cusParam")Map<String,Object> cusParam);
}

View File

@ -0,0 +1,49 @@
package weaver.bokang.xiao.xhny_mode.search;
import java.util.*;
import aiyh.utils.Util;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.bokang.xiao.common.mapper.HrmMapper;
import weaver.bokang.xiao.xhny_mode.entity.SqlConditionDtEntity;
import weaver.bokang.xiao.xhny_mode.entity.SqlConditionEntity;
import weaver.bokang.xiao.xhny_mode.mapper.SearchMapper;
import weaver.bokang.xiao.xhny_mode.service.SqlConditionGenerate;
import weaver.hrm.User;
import weaver.formmode.customjavacode.AbstractCustomSqlConditionJavaCode;
/**
*
*
*
* class
* class
* java
* @author Administrator
*
*/
public class CustomSearchDepart extends AbstractCustomSqlConditionJavaCode {
private final Logger logger = Util.getLogger();
private final SqlConditionGenerate sqlConditionGenerate = new SqlConditionGenerate();
/**
* SQL
* @param param
* param()
* user
*
* @return
* : t1.a = '1' and t1.b = '3' and t1.c like '%22%'
* t1
*/
public String generateSqlCondition(Map<String, Object> param) throws Exception {
logger.info(String.format("search before Param ==> %s", param));
return sqlConditionGenerate.getSqlCondition(param);
}
}

View File

@ -0,0 +1,19 @@
package weaver.bokang.xiao.xhny_mode.service;
/**
* @ClassName CusFunction
* @Author
* @Date 2023/4/9 14:42
* @Description <h1></h1>
**/
public interface CusFunction <R,P,Q,K>{
/**
* <h2></h2>
* @param p
* @param q
* @param k
* @return
*/
R apply(P p,Q q,K k);
}

View File

@ -0,0 +1,124 @@
package weaver.bokang.xiao.xhny_mode.service;
import aiyh.utils.Util;
import aiyh.utils.annotation.MethodRuleNo;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.bokang.xiao.xhny_mode.entity.SqlConditionDtEntity;
import weaver.bokang.xiao.xhny_mode.entity.SqlConditionEntity;
import weaver.bokang.xiao.xhny_mode.mapper.SearchMapper;
import weaver.hrm.User;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* @ClassName SqlConditonGenerate
* @Author
* @Date 2023/4/9 13:35
* @Description <h1></h1>
**/
public class SqlConditionGenerate {
public final Map<Integer, CusFunction<String,SqlConditionDtEntity,Map<String,Object>, String>> METHOD_MAP = new HashMap<>();
private final SearchMapper searchMapper = Util.getMapper(SearchMapper.class);
private final Logger logger = Util.getLogger();
{
try {
Class<SqlConditionGenerate> sqlConditionGenerate = SqlConditionGenerate.class;
Method[] methods = sqlConditionGenerate.getDeclaredMethods();
for (Method method : methods) {
if (method.isAnnotationPresent(MethodRuleNo.class)) {
MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class);
int value = annotation.value();
METHOD_MAP.put(value, (sqlConditionDtEntity,userInfo, sqlCondition) -> {
try {
return (String) method.invoke(this,sqlConditionDtEntity,userInfo,sqlCondition);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
});
}
}
}catch (Exception exception){
logger.error("SqlConditionGenerate init error !!! "+Util.getErrString(exception));
}
}
/**
* <h2>sql</h2>
* @param param
* @return sql
*/
public String getSqlCondition(Map<String, Object> param){
String sqlCondition = "";
try {
User user = (User) param.get("user");
String customId = Util.null2String(param.get("customid"));
logger.info("userId ==>" + user.getUID() + " customId==>" + customId);
SqlConditionEntity sqlConditionEntity = searchMapper.querySqlCondition(customId);
Map<String,Object> userInfo = new HashMap<>(8);
userInfo.put("userId",user.getUID());
userInfo.put("departmentId",user.getUserDepartment());
userInfo.put("subCompanyId",user.getUserSubCompany1());
userInfo.put("loginId",user.getLoginid());
if(Objects.nonNull(sqlConditionEntity)){
List<SqlConditionDtEntity> sqlConditionDtEntityList = sqlConditionEntity.getSqlConditionDtEntityList();
if(!sqlConditionDtEntityList.isEmpty()){
for (SqlConditionDtEntity sqlConditionDtEntity : sqlConditionDtEntityList) {
CusFunction<String, SqlConditionDtEntity, Map<String,Object>, String> conditionFunction = this.METHOD_MAP.get(sqlConditionDtEntity.getCusCondition());
if(Objects.nonNull(conditionFunction)){
sqlCondition = conditionFunction.apply(sqlConditionDtEntity,userInfo,sqlCondition);
}
}
}
if(StringUtils.isNotBlank(sqlCondition)){
sqlCondition = sqlCondition.replaceFirst(" and "," ");
}
}
}catch (Exception e){
logger.error("生成sql条件异常 ==>"+Util.getErrString(e));
}
logger.info(String.format("sqlCondition ==> %s",sqlCondition));
return sqlCondition;
}
@MethodRuleNo(value = 0,desc = "默认值")
public String defaultValue(SqlConditionDtEntity sqlConditionDtEntity,Map<String,Object> userInfo,String sqlCondition){
String fieldName = sqlConditionDtEntity.getFieldName();
String cusText = sqlConditionDtEntity.getCusText();
cusText = Util.sbc2dbcCase(cusText);
sqlCondition += " and t1." + fieldName + " = " + cusText;
return sqlCondition;
}
@MethodRuleNo(value = 1,desc = "用户信息")
public String userInfo(SqlConditionDtEntity sqlConditionDtEntity,Map<String,Object> userInfo,String sqlCondition){
String fieldName = sqlConditionDtEntity.getFieldName();
String cusText = sqlConditionDtEntity.getCusText();
cusText = Util.sbc2dbcCase(cusText);
sqlCondition += " and t1." + fieldName + " = " + userInfo.get(cusText);
return sqlCondition;
}
@MethodRuleNo(value = 2,desc = "自定义sql")
public String cusSql(SqlConditionDtEntity sqlConditionDtEntity,Map<String,Object> userInfo,String sqlCondition){
String fieldName = sqlConditionDtEntity.getFieldName();
String cusText = sqlConditionDtEntity.getCusText();
cusText = Util.sbc2dbcCase(cusText);
if(StringUtils.isBlank(fieldName)) {
sqlCondition += cusText;
}else {
String value = searchMapper.executeCusSql(cusText, userInfo, new HashMap<>(8));
sqlCondition += " and t1." + fieldName + " = " + value;
}
return sqlCondition;
}
}

View File

@ -4,6 +4,7 @@ import aiyh.utils.annotation.recordset.SqlDbFieldAnn;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import java.util.Objects;
@ -15,6 +16,7 @@ import java.util.Objects;
**/
@Getter
@Setter
@ToString
@NoArgsConstructor
public class QuotaData {

View File

@ -33,6 +33,10 @@ public class VendorMarkReportDt {
@SqlDbFieldAnn("ms")
private String desc;
/** 描述 */
@SqlDbFieldAnn("mxx")
private String detailDesc;
/** 权重 */
@SqlDbFieldAnn("qz")
private Double weight;

View File

@ -35,8 +35,8 @@ public interface VendorReportMapper {
* @param vendorMarkReportDtList
* @return
*/
@BatchInsert("insert into uf_vendorMarkReport_dt1 (xm,ms,qz,sjdf,mainid) " +
"values(#{item.project},#{item.desc},#{item.weight},#{item.score},#{mainId})")
@BatchInsert("insert into uf_vendorMarkReport_dt1 (xm,ms,qz,sjdf,mxx,mainid) " +
"values(#{item.project},#{item.desc},#{item.weight},#{item.score},#{item.detailDesc},#{mainId})")
boolean insertReportDt(@BatchSqlArgs List<VendorMarkReportDt> vendorMarkReportDtList,@ParamMapper("mainId") int mainId);
/**

View File

@ -60,10 +60,22 @@ public class GenerateReportSchedule extends CusBaseCronJob {
return;
}
log.info("询价单信息 sourceTrackingDataList ==>"+ JSON.toJSONString(sourceTrackingDataList));
//生成报表数据
doGenerateReport(sourceTrackingDataList,scoreChain);
}
/**
* <h2></h2>
* @param sourceTrackingDataList
* @param scoreChain
*/
private void doGenerateReport(List<SourceTrackingData> sourceTrackingDataList,AbstractScoreChain scoreChain){
for (SourceTrackingData sourceTrackingData : sourceTrackingDataList) {
List<VendorEntity> sourceVendorList = sourceTrackingData.getSourceVendorList();
//待评分供应商数据初始化
List<VendorMarkReport> vendorMarkReportList = sourceVendorList.stream().map(item -> VendorMarkReport.builder()
.supplier(item.getVendorId())
.supplierCode(item.getVendorCode())
.evaluationStartDate(sourceTrackingData.getQuotaBeginDate())
.evaluationEndDate(sourceTrackingData.getQuotaEndDate())
.sourceTrackingCode(sourceTrackingData.getSourceTrackingCode())

View File

@ -43,6 +43,10 @@ public class ScoreChainPattern {
SCORE_CHAIN_MAP.put(11,new SortingServiceChain());
}
/**
* <h2></h2>
* @return
*/
public static AbstractScoreChain getScoreChain(){
List<ConfigEntity> configEntities = VENDOR_MAPPER.queryVendorConfig();
if(configEntities.isEmpty()){

View File

@ -9,7 +9,6 @@ import weaver.bokang.xiao.xhny_report.service.store.VendorStore;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**

View File

@ -4,6 +4,7 @@ import aiyh.utils.Util;
import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData;
import weaver.bokang.xiao.xhny_report.entity.pojo.*;
import weaver.bokang.xiao.xhny_report.service.util.VendorUtil;
import weaver.conn.RecordSetDataSource;
import weaver.general.StaticObj;
import weaver.interfaces.datasource.DataSource;
@ -29,9 +30,11 @@ public class ArrivalRateChain extends AbstractScoreChain{
@Override
public void handle(List<VendorMarkReport> vendorMarkReportList, SourceTrackingData sourceTrackingData) {
//具体评分逻辑
logger.info(" DeliveryCycleChain deal 到货率评分 ");
Map<Integer, ConfigEntity> configEntityMap = this.configEntityMap;
for (VendorMarkReport vendorMarkReport : vendorMarkReportList) {
double arrivalRate = this.getArrivalRateByCall(vendorMarkReport.getSupplierCode(), sourceTrackingData.getQuotaBeginDate(), sourceTrackingData.getQuotaEndDate());
logger.info(String.format("调用存储过程获取到货率 [供应商:%s,到货率:%s]",vendorMarkReport.getSupplierCode(),arrivalRate));
int scoreId = 0;
if(arrivalRate >= 1){
//到货率100%
@ -82,6 +85,13 @@ public class ArrivalRateChain extends AbstractScoreChain{
}
} catch (Exception e) {
logger.error("远程调用存储过程失败 ==>"+ Util.getErrString(e));
}finally {
try{
assert conn != null;
conn.close();
}catch (Exception e){
logger.error("关闭连接异常 ==>"+Util.getErrString(e));
}
}
return arrivalRate;
}

View File

@ -23,6 +23,7 @@ public class BadCountChain extends AbstractScoreChain{
@Override
public void handle(List<VendorMarkReport> vendorMarkReportList, SourceTrackingData sourceTrackingData) {
//具体评分逻辑
logger.info(" BadCountChain deal 不良品数评分 ");
for (VendorMarkReport vendorMarkReport : vendorMarkReportList) {
Map<String,Object> queryParam = new HashMap<>();
queryParam.put("beginDate",sourceTrackingData.getQuotaBeginDate());

View File

@ -1,5 +1,6 @@
package weaver.bokang.xiao.xhny_report.service.chain;
import com.alibaba.fastjson.JSON;
import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData;
import weaver.bokang.xiao.xhny_report.entity.pojo.*;
import weaver.bokang.xiao.xhny_report.service.util.VendorUtil;
@ -37,16 +38,18 @@ public class MoneyAmountChain extends AbstractScoreChain{
}
//求出每个供应商都报价的物料(求交集)
List<QuotaData> retainQuotaList = VendorUtil.retainElementList(sourceList);
logger.info(String.format("交集数据 ==> %s", JSON.toJSONString(retainQuotaList)));
if(!retainQuotaList.isEmpty()){
//统计报价总和
//统计交集部分物料报价总和
Map<Integer, Double> quotaScoreMap = vendorQuotaMap.entrySet().stream()
.collect(Collectors.toMap(
Map.Entry::getKey,
v -> v.getValue().stream().filter(retainQuotaList::contains).mapToDouble(QuotaData::getQuotaValue).sum())
);
logger.info("统计交集部分物料报价总和 ==>"+quotaScoreMap);
//统计报价最小值
Optional<Map.Entry<Integer, Double>> min = quotaScoreMap.entrySet().stream().min(Map.Entry.comparingByValue());
logger.info("报价最低值 ==>"+min);
if(min.isPresent()){
double minValue = min.get().getValue();
for (VendorMarkReport vendorMarkReport : vendorMarkReportList) {

View File

@ -1,5 +1,6 @@
package weaver.bokang.xiao.xhny_report.service.chain;
import com.alibaba.fastjson.JSON;
import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData;
import weaver.bokang.xiao.xhny_report.entity.pojo.ConfigEntity;
import weaver.bokang.xiao.xhny_report.entity.pojo.QuotaData;
@ -41,18 +42,26 @@ public class QuotationNumberChain extends AbstractScoreChain{
}
//求出每个供应商都报价的物料(求交集)
List<QuotaData> retainQuotaList = VendorUtil.retainElementList(sourceList);
logger.info(String.format("交集数据 ==> %s", JSON.toJSONString(retainQuotaList)));
if(!retainQuotaList.isEmpty()) {
//过滤出交集部分的物料报价
Map<Integer, List<QuotaData>> materialQuotaMap = quotaDataList.stream()
.filter(retainQuotaList::contains)
.collect(Collectors.groupingBy(QuotaData::getMaterialId));
//统计每个物料报价的最低值
Map<Integer, Double> materialMinMap = materialQuotaMap.entrySet().stream().collect(Collectors.toMap(
//统计交集部分每个物料报价的最低值
Map<Integer, Double> materialMinMap = quotaDataList.stream()
//过滤出交集部分
.filter(retainQuotaList::contains)
//按物料id分组
.collect(Collectors.groupingBy(QuotaData::getMaterialId))
.entrySet()
//重新组合key:物料id;value:报价最低值)
.stream().collect(Collectors.toMap(
Map.Entry::getKey,
//取报价最低值
v -> v.getValue().stream()
.min(Comparator.comparing(QuotaData::getQuotaValue))
.get().getQuotaValue()
));
.get().getQuotaValue())
);
logger.info("每个物料的报价最低值 ==>"+materialMinMap);
//统计每个供应商报价最低物料数量
Map<Integer, Integer> minQuotaCount = vendorQuotaMap.entrySet().stream().collect(Collectors.toMap(
Map.Entry::getKey,
@ -62,6 +71,8 @@ public class QuotationNumberChain extends AbstractScoreChain{
return materialMinMap.containsKey(materialId) && new BigDecimal(quotaValue).compareTo(BigDecimal.valueOf(materialMinMap.get(materialId))) == 0;
}).count()
));
logger.info("每个供应商报价最低次数 ==>"+minQuotaCount);
//统计出报价最低 最多的次数
Integer maxCount = minQuotaCount.entrySet().stream().max(Map.Entry.comparingByValue()).get().getValue();
for (Map.Entry<Integer, Integer> entry : minQuotaCount.entrySet()) {
@ -73,6 +84,7 @@ public class QuotationNumberChain extends AbstractScoreChain{
vendorScoreMap.put(entry.getKey(),19);
}
}
}
//整理评分数据
for (VendorMarkReport vendorMarkReport : vendorMarkReportList) {

View File

@ -1,5 +1,6 @@
package weaver.bokang.xiao.xhny_report.service.chain;
import com.alibaba.fastjson.JSON;
import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData;
import weaver.bokang.xiao.xhny_report.entity.pojo.ConfigEntity;
import weaver.bokang.xiao.xhny_report.entity.pojo.MaterialEntity;
@ -41,15 +42,18 @@ public class TopThirtyChain extends AbstractScoreChain{
}
//求出每个供应商都报价的物料(求交集)
List<QuotaData> retainQuotaList = VendorUtil.retainElementList(sourceList);
logger.info(String.format("交集数据 ==> %s", JSON.toJSONString(retainQuotaList)));
if(!retainQuotaList.isEmpty()){
//过滤top30的物料信息
Map<String, Double> topThirtyMaterial = this.vendorStore.getTopThirtyMaterial();
Map<Integer, String> mappingMaterial = sourceTrackingData.getSourceMaterialList().stream().collect(Collectors.toMap(MaterialEntity::getMaterialId, MaterialEntity::getMaterialCode));
//过滤出包含top30的部分
List<QuotaData> collect = retainQuotaList.stream().filter(item -> {
Integer materialId = item.getMaterialId();
String materialCode = mappingMaterial.get(materialId);
return topThirtyMaterial.containsKey(materialCode);
}).collect(Collectors.toList());
logger.info(String.format("包含top30的交集数据 ==> %s", JSON.toJSONString(collect)));
if(!collect.isEmpty()) {
//统计报价总和
Map<Integer, Double> quotaScoreMap = vendorQuotaMap.entrySet().stream()
@ -57,9 +61,10 @@ public class TopThirtyChain extends AbstractScoreChain{
Map.Entry::getKey,
v -> v.getValue().stream().filter(collect::contains).mapToDouble(QuotaData::getQuotaValue).sum())
);
logger.info("统计交集部分物料报价总和 ==>"+quotaScoreMap);
//统计报价最小值
Optional<Map.Entry<Integer, Double>> min = quotaScoreMap.entrySet().stream().min(Map.Entry.comparingByValue());
logger.info("报价最低值 ==>"+min);
if (min.isPresent()) {
double minValue = min.get().getValue();
for (VendorMarkReport vendorMarkReport : vendorMarkReportList) {

View File

@ -31,6 +31,7 @@ public class VendorStore {
/** 公司信息 */
private List<CompanyEntity> companyEntityList;
/** 公司数据 */
private Map<Integer,CompanyEntity> companyMap = new HashMap<>();
/** 数据源名称 */
@ -40,9 +41,11 @@ public class VendorStore {
private static final VendorMapper VENDOR_MAPPER = Util.getMapper(VendorMapper.class);
/** top30物料数据 */
private final Map<String,Double> topThirtyMaterial = new HashMap<>();
private VendorStore(){
//this.init();
}
@ -54,7 +57,7 @@ public class VendorStore {
companyMap = companyEntityList.stream().collect(Collectors.toMap(CompanyEntity::getId, item -> item));
}
this.queryTopThirtyMaterial();
logger.info(String.format("公共数据初始化成功 VendorStore init success !! [VENDOR_MAPPER:%s \n topThirtyMaterial:%s]", JSON.toJSONString(VENDOR_MAPPER), JSON.toJSONString(topThirtyMaterial)));
logger.info(String.format("公共数据初始化成功 VendorStore init success !! [companyMap:%s \n topThirtyMaterial:%s \n datasource:%s]", JSON.toJSONString(companyMap), JSON.toJSONString(topThirtyMaterial),this.dataSource));
}catch (Exception exception){
logger.error("VendorStore 初始化异常 ==>"+Util.getErrString(exception));
}

View File

@ -1,7 +1,7 @@
package weaver.bokang.xiao.xhny_report.service.util;
import com.cloudstore.dev.api.util.EMManager;
import weaver.bokang.xiao.xhny_report.entity.pojo.ConfigEntity;
import weaver.bokang.xiao.xhny_report.entity.pojo.QuotaData;
import weaver.bokang.xiao.xhny_report.entity.pojo.VendorMarkReport;
import weaver.bokang.xiao.xhny_report.entity.pojo.VendorMarkReportDt;
@ -48,6 +48,7 @@ public class VendorUtil {
VendorMarkReportDt.builder()
.score(score)
.project(configEntity.getChildItem())
.detailDesc(configEntity.getDetail())
.weight(configEntity.getWeight())
.desc(desc).build());
double totalScore = vendorMarkReport.getTotalScore();

View File

@ -0,0 +1,167 @@
package weaver.bokang.xiao.zscq.action;
import aiyh.utils.Util;
import aiyh.utils.action.SafeCusBaseAction;
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 com.gbasedbt.base64.BASE64Encoder;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import weaver.bokang.xiao.common.mapper.WorkflowMapper;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import weaver.xiao.commons.config.entity.RequestMappingConfig;
import weaver.xiao.commons.config.entity.ResponseMapping;
import weaver.xiao.commons.config.service.DealWithMapping;
import weaver.xiao.commons.utils.SqlUtil;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @ClassName OneNetcomAction
* @Author
* @Date 2023/3/27 14:04
* @Description <h1>action</h1>
**/
@Setter
@ActionDesc(value = "一网通接口调用action",author = "bokang.xiao")
public class OneNetComAction extends SafeCusBaseAction {
/** 受理接口唯一标识 */
@PrintParamMark
@ActionOptionalParam(value = "",desc = "受理接口唯一标识")
private String acceptUnique;
/** 办理接口唯一标识 */
@PrintParamMark
@ActionOptionalParam(value = "",desc = "受理接口唯一标识")
private String handleUnique;
@RequiredMark("网关应用app_ID")
@PrintParamMark
private String appId;
@RequiredMark("网关应用app_key")
@PrintParamMark
private String appKey;
/** 网关调用受理接口的apiId */
@PrintParamMark
@ActionOptionalParam(value = "",desc = "网关调用受理接口的apiId")
private String acceptApiName;
/** 网关调用办理接口的apiId */
@PrintParamMark
@ActionOptionalParam(value = "",desc = "网关调用办理接口的apiId")
private String handleApiName;
private final WorkflowMapper workflowMapper = Util.getMapper(WorkflowMapper.class);
private final DealWithMapping dealWithMapping = new DealWithMapping();
private final HttpUtils httpUtils = new HttpUtils();
private final SqlUtil sqlUtil = new SqlUtil();
@Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
log.info(String.format("=================== {%s} {requestId : %s} begin ======================", this.getClass().getName(),requestId));
Map<String, Object> workflowMessage = workflowMapper.queryWorkflowByRequestId(requestId, billTable);
dealWithMapping.setMainTable(billTable);
try{
if(StringUtils.isNotBlank(acceptUnique) && StringUtils.isNotBlank(acceptApiName)) {
requestHandle(workflowMessage,acceptUnique,acceptApiName,requestId,billTable,"受理请求");
}
if(StringUtils.isNotBlank(handleUnique) && StringUtils.isNotBlank(handleApiName)) {
requestHandle(workflowMessage,handleUnique,handleApiName,requestId,billTable,"处理请求");
}
}catch (IOException exception){
log.error("请求发送异常 ==>"+Util.getErrString(exception));
throw new CustomerException("请求发送异常");
}
}
/**
* <h2></h2>
* @param workflowMessage
* @param uniqueCode
* @param apiName apiId
* @param requestId id
* @param billTable
* @param desc
* @throws IOException
*/
private void requestHandle(Map<String, Object> workflowMessage,
String uniqueCode,String apiName,
String requestId,String billTable,
String desc) throws IOException {
RequestMappingConfig requestMappingConfig = dealWithMapping.treeDealWithUniqueCode(uniqueCode);
Map<String, Object> requestParam = dealWithMapping.getRequestParam(workflowMessage, requestMappingConfig);
Map<String,String> header = this.getHeader(apiName);
ResponeVo responeVo = httpUtils.apiPost(requestMappingConfig.getRequestUrl(), requestParam,header);
if(responeVo.getCode() == 200){
Map<String,Object> result = responeVo.getResponseMap();
int requestCode = Util.getIntValue(Util.null2String(result.get("code")));
String message = Util.null2String(result.get("msg"));
if(requestCode == 200){
List<ResponseMapping> responseMappingList = requestMappingConfig.getResponseMappingList();
Map<String, Map<String, Object>> writeBackMessage = dealWithMapping.dealResponse(responseMappingList, result);
log.info("回写信息 writeBackMessage ==>"+ JSON.toJSONString(writeBackMessage));
Map<String, Object> updateMsg = writeBackMessage.get(billTable);
Map<String,Object> whereParam = new HashMap<>();
whereParam.put("requestid",requestId);
sqlUtil.updateMode(billTable, updateMsg, whereParam);
}else {
throw new CustomerException(desc+"请求失败 ==>"+message);
}
}else {
throw new CustomerException(desc+" 状态码不为200");
}
}
/**
* <h2></h2>
* @param apiName apiId
* @return
*/
public Map<String,String> getHeader(String apiName){
Map<String, String> header = new HashMap<>();
try {
String timestamp = String.valueOf(System.currentTimeMillis()/1000);
String stringToSign = appId + apiName + timestamp;
SecretKeySpec keySpec = new SecretKeySpec(appKey.getBytes(StandardCharsets.UTF_8), "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, keySpec);
byte[] bytes = cipher.doFinal(stringToSign.getBytes(StandardCharsets.UTF_8));
String signature = new BASE64Encoder().encode(bytes);
signature = signature.replace("\n", "").replace("\r", "");
header.put("Content-Type", "application/json");
header.put("appid", appId);
header.put("apiName", apiName);
header.put("signature", signature);
}catch (Exception e){
log.info("获取请求头异常 ==>"+Util.getErrString(e));
throw new CustomerException("获取请求头异常 ==>"+e.getMessage());
}
return header;
}
}

View File

@ -0,0 +1,48 @@
package weaver.bokang.xiao.zscq.action;
import aiyh.utils.ThreadPoolConfig;
import aiyh.utils.Util;
import aiyh.utils.action.SafeCusBaseAction;
import aiyh.utils.annotation.ActionDesc;
import aiyh.utils.annotation.PrintParamMark;
import aiyh.utils.annotation.RequiredMark;
import lombok.Setter;
import weaver.bokang.xiao.zscq.mapper.StatusMapper;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import java.util.concurrent.ExecutorService;
/**
* @ClassName StatusChangeAction
* @Author
* @Date 2023/4/7 12:42
* @Description <h1></h1>
**/
@Setter
@ActionDesc(value = "更新抄送的流程为已读",author = "bokang.xiao")
public class StatusChangeAction extends SafeCusBaseAction {
@RequiredMark("用户id集合 , 分割")
@PrintParamMark
private String userIds;
private String sleepMillis;
private StatusMapper statusMapper = Util.getMapper(StatusMapper.class);
private ExecutorService threadPoolInstance = ThreadPoolConfig.createThreadPoolInstance();
@Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
threadPoolInstance.execute(() -> {
try {
Thread.sleep(Util.getIntValue(sleepMillis,1000));
log.info("更新抄送流程为已读 ==>"+requestId+" userIds ==>"+userIds);
statusMapper.changeWorkflowStatus(requestId,userIds);
} catch (InterruptedException e) {
log.error("线程修改抄送流程状态失败==>"+Util.getErrString(e));
}
});
}
}

View File

@ -0,0 +1,31 @@
package weaver.bokang.xiao.zscq.config.entity;
import lombok.Data;
/**
* @ClassName AssignmentEntity
* @Author
* @Date 2023/4/4 15:42
* @Description <h1></h1>
**/
@Data
public class AssignmentEntity {
/** 赋值字段 */
private String assignmentField;
/** 值选择 */
private Integer valueSelect;
/** 源字段 */
private String sourceField;
/** 赋值字段名 */
private String assignmentFieldName;
/** 源字段名 */
private String sourceFieldName;
/** 文本框 */
private String context;
}

View File

@ -0,0 +1,37 @@
package weaver.bokang.xiao.zscq.config.entity;
import lombok.Data;
/**
* @ClassName ConditionEntity
* @Author
* @Date 2023/4/4 15:39
* @Description <h1></h1>
**/
@Data
public class ConditionEntity {
/** 条件类型 */
private Integer conditionType;
/** 条件 */
private Integer conditionValue;
/** 源字段 */
private String conditionSourceField;
/** 值类型 */
private Integer valueType;
/** 目标字段 */
private String conditionTargetField;
/** 源字段名 */
private String conditionSourceFieldName;
/** 目标字段名 */
private String conditionTargetFieldName;
/** 文本框 */
private String cusText;
}

View File

@ -0,0 +1,49 @@
package weaver.bokang.xiao.zscq.config.entity;
import lombok.Data;
import java.util.List;
/**
* @ClassName UpdateModeConf
* @Author
* @Date 2023/4/4 15:32
* @Description <h1></h1>
**/
@Data
public class UpdateModeConf {
/** 源建模 */
private String sourceMode;
/** 触发建模 */
private String targetMode;
/** 说明 */
private String description;
/** 唯一标识 */
private String uniqueCode;
/** 源表名 */
private String sourceTableName;
/** 触发表名 */
private String targetTableName;
/** 数据写入方式 */
private Integer dataInType;
/** 自定义操作类全路径 */
private String operatePath;
/** 无条件触发 */
private Integer noRule;
/** 条件列表 */
private List<ConditionEntity> conditionList;
/** 赋值列表 */
private List<AssignmentEntity> assignmentList;
}

View File

@ -0,0 +1,20 @@
package weaver.bokang.xiao.zscq.config.function;
/**
* @ClassName ConditionFunction
* @Author
* @Date 2023/4/4 17:58
* @Description <h1></h1>
**/
@FunctionalInterface
public interface ConditionFunction <R,P,Q,K>{
/**
* <h2></h2>
* @param p
* @param q
* @param k
* @return
*/
R apply(P p,Q q,K k);
}

View File

@ -0,0 +1,36 @@
package weaver.bokang.xiao.zscq.config.function;
import aiyh.utils.Util;
import org.apache.log4j.Logger;
import java.util.Map;
/**
* @ClassName CusOperateInterface
* @Author
* @Date 2023/4/7 14:52
* @Description <h1></h1>
**/
public interface CusOperateInterface {
Logger logger = Util.getLogger();
/**
* <h2><h2/>
*
* <p>
* whereParam: key
* param{
* tableName:"更新数据表名",
* whereSql:"条件sql",
* operatePath:"接口全路径类名"
* }
* pathParam:
* </p>
*
* @param whereParam
* @param param
* @param pathParam
*/
void execute(Map<String,Object> whereParam, Map<String,String> param,Map<String,String> pathParam);
}

View File

@ -0,0 +1,80 @@
package weaver.bokang.xiao.zscq.config.mapper;
import aiyh.utils.annotation.recordset.*;
import weaver.bokang.xiao.zscq.config.entity.AssignmentEntity;
import weaver.bokang.xiao.zscq.config.entity.ConditionEntity;
import weaver.bokang.xiao.zscq.config.entity.UpdateModeConf;
import java.util.List;
import java.util.Map;
/**
* @ClassName UpdateModeMapper
* @Author
* @Date 2023/4/4 15:47
* @Description <h1></h1>
**/
@SqlMapper
public interface UpdateModeMapper {
/**
* <h2>formId</h2>
* @param formId id
* @return
*/
@Select("select * from uf_update_mode_conf where source_mode = #{formId}")
@CollectionMappings({
@CollectionMapping(property = "conditionList", column = "id", id = @Id(value = Integer.class, methodId = 1)),
@CollectionMapping(property = "assignmentList", column = "id", id = @Id(value = Integer.class, methodId = 2)),
})
List<UpdateModeConf> queryUpdateModeConfByFormId(@ParamMapper("formId")String formId);
/**
* <h2></h2>
* @param mainId id
* @return
*/
@Select("select * from uf_update_mode_conf_dt1 where mainid = #{mainId}")
@CollectionMethod(1)
List<ConditionEntity> queryConditionList(@ParamMapper("mainId")int mainId);
/**
* <h2></h2>
* @param mainId id
* @return
*/
@Select("select * from uf_update_mode_conf_dt2 where mainid = #{mainId}")
@CollectionMethod(2)
List<AssignmentEntity> queryAssignmentList(@ParamMapper("mainId")int mainId);
/**
* <h2>sql</h2>
* @param cusSql sql
* @param param
* @param cusParam
* @return
*/
@Select(custom = true)
String executeCusSql(@SqlString String cusSql, @ParamMapper("param")Map<String,Object> param,Map<String,Object> cusParam);
/**
* <h2>sql</h2>
* @param cusSql sql
* @param whereParam
* @param cusParam
* @return
*/
@Select(custom = true)
Map<String,Object> executeCusSqlMap(@SqlString String cusSql, @ParamMapper("whereParam")Map<String,Object> whereParam,@ParamMapper("cusParam")Map<String,Object> cusParam);
/**
* <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);
}

View File

@ -0,0 +1,83 @@
package weaver.bokang.xiao.zscq.config.process;
import aiyh.utils.Util;
import aiyh.utils.annotation.MethodRuleNo;
import org.apache.log4j.Logger;
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;
/**
* @ClassName ConditionTargetProcess
* @Author
* @Date 2023/4/4 17:54
* @Description <h1>sql</h1>
**/
public class ConditionTargetProcess {
public static final Map<Integer, ConditionFunction<String,Map<String,Object>,Map<String,Object>,String>> TARGET_MODE_METHOD_MAP = new HashMap<>();
public static final Logger logger = Util.getLogger();
static {
try {
Class<ConditionTargetProcess> valueRuleMethodClass = ConditionTargetProcess.class;
Method[] methods = valueRuleMethodClass.getDeclaredMethods();
for (Method method : methods) {
if (method.isAnnotationPresent(MethodRuleNo.class)) {
MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class);
int value = annotation.value();
TARGET_MODE_METHOD_MAP.put(value, (whereParam,param,whereSql) -> {
try {
return (String) method.invoke(null,whereParam,param,whereSql);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
});
}
}
}catch (Exception exception){
logger.error("ConditionTargetProcess init error !!! "+Util.getErrString(exception));
}
}
/**
* <h2></h2>
* @param whereParam
* @param param
* @param whereSql sql
* @return sql
*/
@MethodRuleNo(value = 0, desc = "等于")
public static String equals(Map<String,Object> whereParam,Map<String,Object> param,String whereSql) {
String conditionValue = Util.null2String(param.get("conditionValue"));
String targetFieldName = Util.null2String(param.get("targetFieldName"));
String targetStr = " and "+targetFieldName+" = #{whereParam."+targetFieldName+"}";
whereSql += targetStr;
whereParam.put(targetFieldName,conditionValue);
return whereSql;
}
/**
* <h2></h2>
* @param whereParam
* @param param
* @param whereSql sql
* @return sql
*/
@MethodRuleNo(value = 1, desc = "不等于")
public static String noEquals(Map<String,Object> whereParam,Map<String,Object> param,String whereSql) {
String sourceFieldName = Util.null2String(param.get("sourceValue"));
String conditionValue = Util.null2String(param.get("conditionValue"));
String targetFieldName = Util.null2String(param.get("targetFieldName"));
String targetStr = " and "+sourceFieldName+" <> #{whereParam."+targetFieldName+"}";
whereSql += targetStr;
whereParam.put(targetFieldName,conditionValue);
return whereSql;
}
}

View File

@ -0,0 +1,71 @@
package weaver.bokang.xiao.zscq.config.process;
import aiyh.utils.Util;
import aiyh.utils.annotation.MethodRuleNo;
import org.apache.log4j.Logger;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;
/**
* @ClassName ConditionValueProcess
* @Author
* @Date 2023/4/4 16:19
* @Description <h1></h1>
**/
public class ConditionValueProcess {
public static final Map<Integer, BiFunction<String,String, Boolean>> SOURCE_MODE_METHOD_MAP = new HashMap<>();
public static final Logger logger = Util.getLogger();
static {
try {
Class<ConditionValueProcess> valueRuleMethodClass = ConditionValueProcess.class;
Method[] methods = valueRuleMethodClass.getDeclaredMethods();
for (Method method : methods) {
if (method.isAnnotationPresent(MethodRuleNo.class)) {
MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class);
int value = annotation.value();
SOURCE_MODE_METHOD_MAP.put(value, (sourceValue, conditionValue) -> {
try {
return (Boolean) method.invoke(null,sourceValue, conditionValue);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
});
}
}
}catch (Exception exception){
logger.error("ConditionValueProcess init error !!! "+Util.getErrString(exception));
}
}
/**
* <h2></h2>
* @param sourceValue
* @param value
* @return
*/
@MethodRuleNo(value = 0, desc = "等于")
public static boolean equals(String sourceValue, String value) {
return sourceValue.equals(value);
}
/**
* <h2></h2>
* @param sourceValue
* @param value
* @return
*/
@MethodRuleNo(value = 1, desc = "不等于")
public static boolean noEquals(String sourceValue, String value) {
return !sourceValue.equals(value);
}
}

View File

@ -0,0 +1,229 @@
package weaver.bokang.xiao.zscq.config.process;
import aiyh.utils.Util;
import aiyh.utils.annotation.MethodRuleNo;
import aiyh.utils.excention.CustomerException;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.bokang.xiao.zscq.config.function.ConditionFunction;
import weaver.bokang.xiao.zscq.config.function.CusOperateInterface;
import weaver.bokang.xiao.zscq.config.mapper.UpdateModeMapper;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* @ClassName DataTypeProcess
* @Author
* @Date 2023/4/6 13:10
* @Description <h1></h1>
**/
public class DataTypeProcess {
public static final Map<Integer, ConditionFunction<Boolean,Map<String,Object>,Map<String,Object>, Map<String,String>>> SOURCE_MODE_METHOD_MAP = new HashMap<>();
private static final UpdateModeMapper UPDATE_MODE_MAPPER = Util.getMapper(UpdateModeMapper.class);
public static final Logger logger = Util.getLogger();
static {
try {
Class<DataTypeProcess> valueRuleMethodClass = DataTypeProcess.class;
Method[] methods = valueRuleMethodClass.getDeclaredMethods();
for (Method method : methods) {
if (method.isAnnotationPresent(MethodRuleNo.class)) {
MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class);
int value = annotation.value();
SOURCE_MODE_METHOD_MAP.put(value, (updateParam, whereParam,param) -> {
try {
return (boolean) method.invoke(null,updateParam, whereParam,param);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
});
}
}
}catch (Exception exception){
logger.error("DataTypeProcess init error !!! "+Util.getErrString(exception));
}
}
/**
* <h2></h2>
* @param updateParam
* @param whereParam
* @param param
* @return
*/
@MethodRuleNo(value = 0, desc = "更新")
public static boolean update(Map<String,Object> updateParam, Map<String,Object> whereParam,Map<String,String> param) {
String tableName = Util.null2String(param.get("tableName"));
String whereSql = Util.null2String(param.get("whereSql"));
String updateSql = DataTypeProcess.buildUpdateSql(tableName, updateParam);
if(!"".equals(whereSql)){
whereSql = whereSql.replaceFirst(" and "," where ");
}
updateSql = updateSql + whereSql;
logger.info("updateSql ==>"+updateSql);
return UPDATE_MODE_MAPPER.executeUpdateCusSql(updateSql, updateParam, whereParam);
}
/**
* <h2></h2>
* @param updateParam
* @param whereParam
* @param param
* @return
*/
@MethodRuleNo(value = 1, desc = "插入")
public static boolean insert(Map<String,Object> updateParam, Map<String,Object> whereParam,Map<String,String> param) {
String tableName = Util.null2String(param.get("tableName"));
String modeId = Util.getModeIdByTableName(tableName);
int dataId = Util.getModeDataId(tableName, Util.getIntValue(modeId), 1);
whereParam.clear();
whereParam.put("id",dataId);
String updateSql = buildUpdateSql(tableName, updateParam);
String whereSql = DataTypeProcess.buildWhereSql(whereParam);
updateSql = updateSql + " " + whereSql;
logger.info("updateSql ==>"+updateSql);
return UPDATE_MODE_MAPPER.executeUpdateCusSql(updateSql,updateParam,whereParam);
}
/**
* <h2></h2>
* @param updateParam
* @param whereParam
* @param param
* @return
*/
@MethodRuleNo(value = 2,desc = "自定义操作")
public static boolean cusOperate(Map<String,Object> updateParam, Map<String,Object> whereParam,Map<String,String> param) {
String operatePath = Util.null2String(param.get("operatePath"));
if(StringUtils.isBlank(operatePath)){
throw new CustomerException("操作全路径不能为空");
}
Map<String,String> pathParam = new HashMap<>();
try {
CusOperateInterface cusInterfaceObj = getCusInterfaceObj(operatePath, CusOperateInterface.class, pathParam);
cusInterfaceObj.execute(whereParam,param,pathParam);
}catch (Exception e){
logger.error("自定义处理类执行异常 ==>"+Util.getErrString(e));
throw new CustomerException(e);
}
return true;
}
/**
* <h2></h2>
* @param updateParam
* @param whereParam
* @param param
* @return
*/
@MethodRuleNo(value = 3,desc = "插入并执行自定义操作")
public static boolean cusAndUpdate(Map<String,Object> updateParam, Map<String,Object> whereParam,Map<String,String> param) {
return update(updateParam,whereParam,param) && cusOperate(updateParam,whereParam,param);
}
/**
* <h2></h2>
* @param updateParam
* @param whereParam
* @param param
* @return
*/
@MethodRuleNo(value = 4,desc = "插入并执行自定义操作")
public static boolean cusAndInsert(Map<String,Object> updateParam, Map<String,Object> whereParam,Map<String,String> param) {
return insert(updateParam,whereParam,param) && cusOperate(updateParam,whereParam,param);
}
/**
* <h2>sql</h2>
* @param tableName
* @param updateParam
* @return
*/
public static String buildUpdateSql(String tableName, Map<String, Object> updateParam){
StringBuilder updateBuilder = new StringBuilder("update ");
updateBuilder.append(tableName).append(" set ");
Set<Map.Entry<String, Object>> updateEntries = updateParam.entrySet();
for (Map.Entry<String, Object> updateEntry : updateEntries) {
if("cusSql".equals(updateEntry.getKey())){
updateBuilder.append(updateEntry.getValue());
continue;
}
updateBuilder.append(updateEntry.getKey())
.append(" = ")
.append("#{updateParam.").append(updateEntry.getKey()).append("},");
}
return updateBuilder.substring(0, updateBuilder.length() - 1) + " ";
}
/**
* <h2>sql</h2>
* @param whereParam
* @return
*/
public static String buildWhereSql(Map<String, Object> whereParam){
StringBuilder whereBuilder = new StringBuilder();
Set<Map.Entry<String, Object>> whereEntries = whereParam.entrySet();
for (Map.Entry<String, Object> whereEntry : whereEntries) {
if("cusSql".equals(whereEntry.getKey())){
whereBuilder.append(" and ").append(whereEntry.getValue());
continue;
}
whereBuilder.append(" and ")
.append(whereEntry.getKey())
.append("#{whereParam.").append(whereEntry.getKey()).append("},");
}
String fixStr = whereBuilder.toString();
if(!"".equals(fixStr)){
fixStr = fixStr.replaceFirst(" and "," where ");
}
return fixStr;
}
/**
* <h2></h2>
* @param path
* @param clazz
* @param pathParamMap
* @return
* @param <T>
*/
public static <T> T getCusInterfaceObj(String path, Class<T> clazz, Map<String, String> pathParamMap) {
path = Util.sbc2dbcCase(path);
String[] split = path.split("\\?");
String classPath = split[0];
Class<?> aClass;
try {
aClass = Class.forName(classPath);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("未能找到自定义接口:" + classPath);
}
if (!clazz.isAssignableFrom(aClass)) {
throw new IllegalArgumentException("自定义接口:" + classPath + " 不是"
+ clazz.getName() + "的子类或实现类!");
}
Constructor<?> constructor;
try {
constructor = aClass.getConstructor();
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException(classPath + "没有空参构造方法,无法获取构造方法对象!");
}
T o;
try {
o = (T) constructor.newInstance();
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
throw new IllegalArgumentException("无法构造" + classPath + "对象!");
}
pathParamMap.putAll(Util.parseCusInterfacePathParam(path));
return o;
}
}

View File

@ -0,0 +1,107 @@
package weaver.bokang.xiao.zscq.config.process;
import aiyh.utils.Util;
import aiyh.utils.annotation.MethodRuleNo;
import aiyh.utils.excention.CustomerException;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.bokang.xiao.zscq.config.entity.AssignmentEntity;
import weaver.bokang.xiao.zscq.config.entity.ConditionEntity;
import weaver.bokang.xiao.zscq.config.mapper.UpdateModeMapper;
import weaver.general.TimeUtil;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;
/**
* @ClassName ValueSelectProcess
* @Author
* @Date 2023/4/6 12:42
* @Description <h1> - </h1>
**/
public class ValueSelectProcess {
public static final Map<Integer, BiFunction<Map<String,Object>, AssignmentEntity, String>> SOURCE_MODE_METHOD_MAP = new HashMap<>();
private static final UpdateModeMapper UPDATE_MODE_MAPPER = Util.getMapper(UpdateModeMapper.class);
public static final Logger logger = Util.getLogger();
static {
try {
Class<ValueSelectProcess> valueRuleMethodClass = ValueSelectProcess.class;
Method[] methods = valueRuleMethodClass.getDeclaredMethods();
for (Method method : methods) {
if (method.isAnnotationPresent(MethodRuleNo.class)) {
MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class);
int value = annotation.value();
SOURCE_MODE_METHOD_MAP.put(value, (modeMap, assignment) -> {
try {
return (String) method.invoke(null,modeMap, assignment);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
});
}
}
}catch (Exception exception){
logger.error("ValueTypeProcess init error !!! "+Util.getErrString(exception));
}
}
/**
* <h2></h2>
* @param modeMap
* @param assignment
* @return
*/
@MethodRuleNo(value = 0, desc = "默认值")
public static String defaultValue(Map<String,Object> modeMap,AssignmentEntity assignment) {
return assignment.getContext();
}
/**
* <h2></h2>
* @param modeMap
* @param assignment
* @return
*/
@MethodRuleNo(value = 1, desc = "建模字段")
public static String modeField(Map<String,Object> modeMap,AssignmentEntity assignment) {
return Util.null2String(modeMap.get(assignment.getSourceFieldName()));
}
/**
* <h2>sql</h2>
* @param modeMap
* @param assignment
* @return
*/
@MethodRuleNo(value = 2, desc = "自定义sql")
public static String cusSql(Map<String,Object> modeMap,AssignmentEntity assignment) {
String cusSqlStr = Util.null2String(assignment.getContext());
cusSqlStr = Util.dbc2sbcCase(cusSqlStr);
if(StringUtils.isBlank(cusSqlStr)){
throw new CustomerException("选择自定义sql时sql字符串不能为空");
}
if(!cusSqlStr.startsWith("select ")){
throw new CustomerException("选择自定义sql时不允许执行除select之外的其他危险操作 ");
}
return UPDATE_MODE_MAPPER.executeCusSql(cusSqlStr, modeMap,new HashMap<>());
}
/**
* <h2></h2>
* @param modeMap
* @param assignment
* @return
*/
@MethodRuleNo(value = 3, desc = "当前时间")
public static String currentTime(Map<String,Object> modeMap,AssignmentEntity assignment) {
return TimeUtil.getCurrentTimeString();
}
}

View File

@ -0,0 +1,106 @@
package weaver.bokang.xiao.zscq.config.process;
import aiyh.utils.Util;
import aiyh.utils.annotation.MethodRuleNo;
import aiyh.utils.excention.CustomerException;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.bokang.xiao.zscq.config.entity.ConditionEntity;
import weaver.bokang.xiao.zscq.config.mapper.UpdateModeMapper;
import weaver.general.TimeUtil;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;
/**
* @ClassName ValueTypeProcess
* @Author
* @Date 2023/4/4 16:18
* @Description <h1> - </h1>
**/
public class ValueTypeProcess {
public static final Map<Integer,BiFunction<Map<String,Object>, ConditionEntity, String>> SOURCE_MODE_METHOD_MAP = new HashMap<>();
private static final UpdateModeMapper UPDATE_MODE_MAPPER = Util.getMapper(UpdateModeMapper.class);
public static final Logger logger = Util.getLogger();
static {
try {
Class<ValueTypeProcess> valueRuleMethodClass = ValueTypeProcess.class;
Method[] methods = valueRuleMethodClass.getDeclaredMethods();
for (Method method : methods) {
if (method.isAnnotationPresent(MethodRuleNo.class)) {
MethodRuleNo annotation = method.getAnnotation(MethodRuleNo.class);
int value = annotation.value();
SOURCE_MODE_METHOD_MAP.put(value, (modeMap, condition) -> {
try {
return (String) method.invoke(null,modeMap, condition);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
});
}
}
}catch (Exception exception){
logger.error("ValueTypeProcess init error !!! "+Util.getErrString(exception));
}
}
/**
* <h2></h2>
* @param modeMap
* @param condition
* @return
*/
@MethodRuleNo(value = 0, desc = "默认值")
public static String defaultValue(Map<String,Object> modeMap,ConditionEntity condition) {
return condition.getCusText();
}
/**
* <h2></h2>
* @param modeMap
* @param condition
* @return
*/
@MethodRuleNo(value = 1, desc = "建模字段")
public static String modeField(Map<String,Object> modeMap,ConditionEntity condition) {
return Util.null2String(modeMap.get(condition.getConditionSourceFieldName()));
}
/**
* <h2>sql</h2>
* @param modeMap
* @param condition
* @return
*/
@MethodRuleNo(value = 2, desc = "自定义sql")
public static String cusSql(Map<String,Object> modeMap,ConditionEntity condition) {
String cusSqlStr = Util.null2String(condition.getCusText());
cusSqlStr = Util.dbc2sbcCase(cusSqlStr);
if(StringUtils.isBlank(cusSqlStr)){
throw new CustomerException("选择自定义sql时sql字符串不能为空");
}
if(!cusSqlStr.startsWith("select ")){
throw new CustomerException("选择自定义sql时不允许执行除select之外的其他危险操作 ");
}
return UPDATE_MODE_MAPPER.executeCusSql(cusSqlStr, modeMap,new HashMap<>());
}
/**
* <h2></h2>
* @param modeMap
* @param condition
* @return
*/
@MethodRuleNo(value = 3, desc = "当前时间")
public static String currentTime(Map<String,Object> modeMap,ConditionEntity condition) {
return TimeUtil.getCurrentTimeString();
}
}

View File

@ -0,0 +1,116 @@
package weaver.bokang.xiao.zscq.config.service;
import aiyh.utils.Util;
import com.alibaba.fastjson.JSON;
import org.apache.log4j.Logger;
import weaver.bokang.xiao.zscq.config.entity.AssignmentEntity;
import weaver.bokang.xiao.zscq.config.entity.ConditionEntity;
import weaver.bokang.xiao.zscq.config.entity.UpdateModeConf;
import weaver.bokang.xiao.zscq.config.function.ConditionFunction;
import weaver.bokang.xiao.zscq.config.mapper.UpdateModeMapper;
import weaver.bokang.xiao.zscq.config.process.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.BiFunction;
import java.util.stream.Collectors;
/**
* @ClassName ModeChangeService
* @Author
* @Date 2023/4/6 11:28
* @Description <h1></h1>
**/
public class ModeChangeService {
public final Logger logger = Util.getLogger();
private final UpdateModeMapper updateModeMapper = Util.getMapper(UpdateModeMapper.class);
/**
* <h2></h2>
* @param modeMap
* @param formId id
*/
public void changeOtherMode(Map<String,Object> modeMap, String formId){
List<UpdateModeConf> updateModeConfList = updateModeMapper.queryUpdateModeConfByFormId(formId);
if(Objects.isNull(updateModeConfList) || updateModeConfList.isEmpty()){
logger.error(String.format("此表单建模[%s] 未配置相关更新信息,请检查!!!",formId));
return;
}
logger.info("配置信息 updateModeConfList==>"+ JSON.toJSONString(updateModeConfList));
for (UpdateModeConf updateModeConf : updateModeConfList) {
List<ConditionEntity> conditionList = updateModeConf.getConditionList();
List<AssignmentEntity> assignmentList = updateModeConf.getAssignmentList();
Integer dataInType = updateModeConf.getDataInType();
Integer noRule = updateModeConf.getNoRule();
if(noRule == 0 && conditionList.isEmpty()){
logger.error(String.format("没有条件设置,不允许建模 %s 更新",updateModeConf.getTargetTableName()));
continue;
}
//条件sql
String whereSql = "";
//条件数据
Map<String,Object> whereParam = new HashMap<>(8);
//赋值数据
Map<String,Object> assignmentMap = new HashMap<>(8);
if(Objects.nonNull(conditionList) && !conditionList.isEmpty()){
Map<Integer, List<ConditionEntity>> collect = conditionList.stream().collect(Collectors.groupingBy(ConditionEntity::getConditionType));
//获取源建模数据判断条件配置列表
List<ConditionEntity> sourceConditions = collect.get(0);
//获取目标建模条件生成配置列表
List<ConditionEntity> targetConditions = collect.get(1);
boolean flag = false;
//判断源建模数据是否需要触发更新
if(Objects.nonNull(sourceConditions) && !sourceConditions.isEmpty()) {
for (ConditionEntity sourceCondition : sourceConditions) {
BiFunction<Map<String, Object>, ConditionEntity, String> valueFunction = ValueTypeProcess.SOURCE_MODE_METHOD_MAP.get(sourceCondition.getValueType());
BiFunction<String, String, Boolean> conditionFunction = ConditionValueProcess.SOURCE_MODE_METHOD_MAP.get(sourceCondition.getConditionValue());
String sourceValue = Util.null2String(modeMap.get(sourceCondition.getConditionSourceFieldName()));
String conditionValue = valueFunction.apply(modeMap, sourceCondition);
Boolean result = conditionFunction.apply(sourceValue, conditionValue);
if (result) {
flag = true;
break;
}
}
if (flag) {
continue;
}
}
//根据配置信息生成条件sql
if(Objects.nonNull(targetConditions) && !targetConditions.isEmpty()) {
for (ConditionEntity targetCondition : targetConditions) {
BiFunction<Map<String, Object>, ConditionEntity, String> valueFunction = ValueTypeProcess.SOURCE_MODE_METHOD_MAP.get(targetCondition.getValueType());
ConditionFunction<String, Map<String, Object>, Map<String, Object>, String> conditionFunction = ConditionTargetProcess.TARGET_MODE_METHOD_MAP.get(targetCondition.getConditionValue());
String sourceValue = Util.null2String(modeMap.get(targetCondition.getConditionSourceFieldName()));
String conditionValue = valueFunction.apply(modeMap, targetCondition);
Map<String, Object> param = new HashMap<>(8);
param.put("sourceValue", sourceValue);
param.put("conditionValue", conditionValue);
param.put("targetFieldName", targetCondition.getConditionTargetFieldName());
whereSql = conditionFunction.apply(whereParam, param, whereSql);
}
}
}
//根据赋值配置组装数据
if(Objects.nonNull(assignmentList) && !assignmentList.isEmpty()){
for (AssignmentEntity assignmentEntity : assignmentList) {
BiFunction<Map<String, Object>, AssignmentEntity, String> valueFunction = ValueSelectProcess.SOURCE_MODE_METHOD_MAP.get(assignmentEntity.getValueSelect());
String assignmentValue = valueFunction.apply(modeMap, assignmentEntity);
assignmentMap.put(assignmentEntity.getAssignmentFieldName(),assignmentValue);
}
}
//执行数据操作
ConditionFunction<Boolean, Map<String, Object>, Map<String, Object>, Map<String,String>> dataInFunction = DataTypeProcess.SOURCE_MODE_METHOD_MAP.get(dataInType);
Map<String,String> tableMap = new HashMap<>(8);
tableMap.put("tableName",updateModeConf.getTargetTableName());
tableMap.put("whereSql",whereSql);
tableMap.put("operatePath",updateModeConf.getOperatePath());
boolean executeFlag = dataInFunction.apply(assignmentMap, whereParam, tableMap);
logger.info("更新结果 executeFlag ==>"+executeFlag);
}
}
}

View File

@ -0,0 +1,144 @@
package weaver.bokang.xiao.zscq.expand;
import aiyh.utils.Util;
import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.bokang.xiao.common.mapper.ModeMapper;
import weaver.bokang.xiao.zscq.config.service.ModeChangeService;
import weaver.bokang.xiao.zscq.fun.DataControlFunction;
import weaver.bokang.xiao.zscq.store.TableNameStore;
import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import java.util.*;
/**
* @ClassName DataControlExpand
* @Author
* @Date 2023/4/3 10:42
* @Description <h1></h1>
**/
public class DataControlExpand extends AbstractModeExpandJavaCodeNew {
private final Logger logger = Util.getLogger();
private final ModeMapper modeMapper = Util.getMapper(ModeMapper.class);
private final TableNameStore tableNameStore = TableNameStore.getInstance();
private final ModeChangeService modeChangeService = new ModeChangeService();
private final Map<Integer, DataControlFunction<RequestInfo,User,String>> importTypeMap = new HashMap<>();
{
//手动新增处理方式
importTypeMap.put(0,this::normalAdd);
//导入追加处理方式
importTypeMap.put(1,this::importAddDeal);
//导入覆盖处理方式
importTypeMap.put(2,this::importCoverDeal);
//导入更新处理方式
importTypeMap.put(3,this::importUpdateDeal);
}
/**
*
* @param param
* param()
* user
* importtype () 1 2,3(int)param.get("importtype")
* ()a=1param.get("a")
* b=2,param.get("b")
* @return
*/
@Override
public Map<String, String> doModeExpand(Map<String, Object> param) {
Map<String, String> result = new HashMap<>(8);
try {
User user = (User)param.get("user");
int importType = Util.getIntValue(String.valueOf(param.get("importtype")),0);
RequestInfo requestInfo = (RequestInfo)param.get("RequestInfo");
String formId = Util.null2String(param.get("formid"));
logger.info("requestInfo ==>"+JSON.toJSONString(requestInfo));
if(Objects.nonNull(requestInfo)){
DataControlFunction<RequestInfo, User, String> dataControlFunction = importTypeMap.get(importType);
if(Objects.nonNull(dataControlFunction)) {
dataControlFunction.deal(requestInfo, user, formId);
}
}
} catch (Exception e) {
logger.error("建模节点后附件操作执行失败==>"+Util.getErrString(e));
result.put("errmsg",e.getMessage());
result.put("flag", "false");
}
return result;
}
/**
* <h2></h2>
* @param requestInfo
* @param user
* @param formId id
*/
public void normalDeal(RequestInfo requestInfo,User user,String formId){
String modeId = requestInfo.getWorkflowid();
String dataId = requestInfo.getRequestid();
String tableName = Util.null2String(tableNameStore.getTableNameStore().get(formId));
if(StringUtils.isBlank(tableName)){
tableName = modeMapper.queryTableName(formId);
tableNameStore.getTableNameStore().put(formId,tableName);
}
logger.info(String.format("建模id [modeId:%s],[dataId:%s],[tableName:%s]",modeId,dataId,tableName));
Map<String,Object> queryParam = new HashMap<>();
queryParam.put("fieldName","id");
queryParam.put("fieldValue",dataId);
Map<String, Object> modeData = modeMapper.queryModeDataInfo(tableName, queryParam);
if(Objects.nonNull(modeData)){
modeChangeService.changeOtherMode(modeData,formId);
}
}
/**
* <h2></h2>
* @param requestInfo
* @param user
* @param formId id
*/
public void normalAdd(RequestInfo requestInfo,User user,String formId){
normalDeal(requestInfo,user,formId);
}
/**
* <h2></h2>
* @param requestInfo
* @param user
* @param formId id
*/
public void importAddDeal(RequestInfo requestInfo,User user,String formId){
normalDeal(requestInfo,user,formId);
}
/**
* <h2></h2>
* @param requestInfo
* @param user
* @param formId id
*/
public void importCoverDeal(RequestInfo requestInfo,User user,String formId){
normalDeal(requestInfo,user,formId);
}
/**
* <h2></h2>
* @param requestInfo
* @param user
* @param formId id
*/
public void importUpdateDeal(RequestInfo requestInfo,User user,String formId){
normalDeal(requestInfo,user,formId);
}
}

View File

@ -0,0 +1,19 @@
package weaver.bokang.xiao.zscq.fun;
/**
* @ClassName DataControlFunction
* @Author
* @Date 2023/4/4 15:03
* @Description <h1></h1>
**/
@FunctionalInterface
public interface DataControlFunction<P,Q,T> {
/**
* <h2></h2>
* @param p
* @param q
* @param t
*/
void deal(P p,Q q,T t);
}

View File

@ -0,0 +1,46 @@
package weaver.bokang.xiao.zscq.fun;
import aiyh.utils.Util;
import weaver.bokang.xiao.zscq.config.function.CusOperateInterface;
import weaver.bokang.xiao.zscq.config.mapper.UpdateModeMapper;
import weaver.hrm.User;
import weaver.workflow.workflow.WfForceOver;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* @ClassName WorkflowOverOperate
* @Author
* @Date 2023/4/7 15:01
* @Description <h1></h1>
**/
public class WorkflowOverOperate implements CusOperateInterface {
private final UpdateModeMapper updateModeMapper = Util.getMapper(UpdateModeMapper.class);
@Override
public void execute(Map<String, Object> whereParam, Map<String, String> param, Map<String, String> pathParam) {
logger.info(String.format("WorkflowOverOperate 自定义处理 whereParam[%s],param:[%s],pathParam:[%s]",whereParam,param,pathParam));
String tableName = Util.null2String(param.get("tableName"));
String whereSql = Util.null2String(param.get("whereSql"));
if(!"".equals(whereSql)){
whereSql = whereSql.replaceFirst(" and "," where ");
}
String querySql = "select * from " + tableName +whereSql;
Map<String, Object> modeData = updateModeMapper.executeCusSqlMap(querySql, whereParam,new HashMap<>());
logger.info("modeData ==>"+modeData);
if(Objects.nonNull(modeData)){
String workflowField = Util.null2String(pathParam.get("workflowField"));
String requestId = Util.null2String(modeData.get(workflowField));
logger.info("流程强制归档 ==>"+requestId);
//流程强制归档
WfForceOver wfForceOver = new WfForceOver();
ArrayList arrayList = new ArrayList();
arrayList.add(requestId);
wfForceOver.doForceOver(arrayList,new User(1));
}
}
}

View File

@ -0,0 +1,26 @@
package weaver.bokang.xiao.zscq.mapper;
import aiyh.utils.annotation.recordset.ParamMapper;
import aiyh.utils.annotation.recordset.SqlMapper;
import aiyh.utils.annotation.recordset.Update;
/**
* @ClassName StatusMapper
* @Author
* @Date 2023/4/7 12:45
* @Description <h1></h1>
**/
@SqlMapper
public interface StatusMapper {
/**
* <h2></h2>
* @param requestId id
* @param userIds id
* @return
*/
@Update("update workflow_currentoperator set viewtype = -2,isremark = 2 " +
"where REQUESTID = #{requestId} and userid in ($t{userIds}) and isremark = 8")
boolean changeWorkflowStatus(@ParamMapper("requestId")String requestId,@ParamMapper("userIds") String userIds);
}

View File

@ -0,0 +1,47 @@
package weaver.bokang.xiao.zscq.store;
import aiyh.utils.Util;
import com.alibaba.fastjson.JSON;
import lombok.Getter;
import org.apache.log4j.Logger;
import weaver.bokang.xiao.xhny_report.entity.pojo.CompanyEntity;
import weaver.bokang.xiao.xhny_report.mapper.VendorMapper;
import weaver.general.StaticObj;
import weaver.interfaces.datasource.DataSource;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @ClassName VendorStore
* @Author
* @Date 2023/3/17 18:31
* @Description <h1></h1>
**/
@Getter
public class TableNameStore {
private final Map<String,String> tableNameStore = new HashMap<>();
private static final Logger logger = Util.getLogger();
private TableNameStore(){}
public static TableNameStore getInstance(){
return VendorStoreHolder.VENDOR_STORE;
}
private static class VendorStoreHolder{
private VendorStoreHolder(){
}
private static final TableNameStore VENDOR_STORE = new TableNameStore();
}
}

View File

@ -0,0 +1,38 @@
package weaver.bokang.xiao.zxyh;
import aiyh.utils.Util;
import aiyh.utils.action.SafeCusBaseAction;
import aiyh.utils.annotation.ActionDesc;
import aiyh.utils.excention.CustomerException;
import lombok.Setter;
import weaver.bokang.xiao.zxyh.mapper.WorkflowMapper;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* @ClassName RepeatSubmitAction
* @Author
* @Date 2023/4/17 9:57
* @Description <h1></h1>
**/
@Setter
@ActionDesc(value = "同一流程提交限制",author = "bokang.xiao")
public class RepeatSubmitAction extends SafeCusBaseAction {
private final WorkflowMapper workflowMapper = Util.getMapper(WorkflowMapper.class);
@Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
log.info(String.format("=================== {%s} {requestId : %s,userId: %s} begin ======================", this.getClass().getName(),requestId,user.getUID()));
List<Map<String, Object>> maps = workflowMapper.queryNoCompleteCount(workflowId + "", user.getUID());
if(Objects.nonNull(maps) && !maps.isEmpty()){
Map<String, Object> workflowInfo = maps.get(0);
String errorMsg = "您发起的流程: "+Util.null2String(workflowInfo.get("requestname"))+" (requestId:"+Util.null2String(workflowInfo.get("requestid"))+") 未归档!不允许再次发起流程";
throw new CustomerException(errorMsg);
}
}
}

View File

@ -0,0 +1,27 @@
package weaver.bokang.xiao.zxyh.mapper;
import aiyh.utils.annotation.recordset.ParamMapper;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
import java.util.List;
import java.util.Map;
/**
* @ClassName WorkflowMapper
* @Author
* @Date 2023/4/17 10:02
* @Description <h1></h1>
**/
@SqlMapper
public interface WorkflowMapper {
/**
* <h2></h2>
* @param workflowId id
* @param userId id
* @return
*/
@Select("select requestid,requestname,currentnodeid from workflow_requestbase where workflowid = #{workflowId} and creater = #{userId} and currentnodetype <> 3")
List<Map<String,Object>> queryNoCompleteCount(@ParamMapper("workflowId")String workflowId, @ParamMapper("userId") int userId);
}

View File

@ -111,7 +111,7 @@ public class DealWithMapping extends ToolUtil {
continue;
}
if ("DOUBLE".equalsIgnoreCase(type)) {
map.put(key, rs.getDouble(i));
map.put(key,Util.getDoubleValue(rs.getString(i)));
continue;
}
if ("DECIMAL".equalsIgnoreCase(type) || "NUMERIC".equalsIgnoreCase(type)) {
@ -442,6 +442,9 @@ public class DealWithMapping extends ToolUtil {
tempList.add(map);
}
}
else {
tempList.add(o);
}
}
// tempList.addAll(list);
requestParam.put(paramName, tempList);
@ -533,6 +536,9 @@ public class DealWithMapping extends ToolUtil {
tempList.add(map);
}
}
else{
tempList.add(o);
}
}
// tempList.addAll(list);
requestParam.put(paramName, tempList);

View File

@ -11,22 +11,32 @@ import bokang.xiao.entity.TeacherEntity;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import com.api.bokang.xiao.porsche_review.mapper.ReviewMapper;
import com.api.bokang.xiao.porsche_review.service.impl.ReviewServiceImpl;
import com.api.bokang.xiao.wx_report.mapper.ReportMapper;
import com.api.bokang.xiao.wx_report.service.ReportService;
import com.api.bokang.xiao.wx_report.service.impl.ReportServiceImpl;
import com.api.bokang.xiao.zscq.service.ReserveService;
import com.api.bokang.xiao.zscq.service.impl.ReserveServiceImpl;
import org.apache.log4j.Logger;
import org.apache.poi.ss.usermodel.Workbook;
import org.junit.Test;
import weaver.bokang.xiao.common.mapper.ModeMapper;
import weaver.bokang.xiao.deg_repeat_check.action.RepeatCheckAction;
import weaver.bokang.xiao.xhny_mode.search.CustomSearchDepart;
import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData;
import weaver.bokang.xiao.xhny_report.schedule.GenerateReportSchedule;
import weaver.bokang.xiao.xhny_report.service.chain.AbstractScoreChain;
import weaver.bokang.xiao.xhny_report.service.ScoreChainPattern;
import weaver.bokang.xiao.zscq.action.OneNetComAction;
import weaver.bokang.xiao.zscq.action.StatusChangeAction;
import weaver.bokang.xiao.zscq.config.service.ModeChangeService;
import weaver.bokang.xiao.zxyh.RepeatSubmitAction;
import weaver.conn.RecordSet;
import weaver.conn.RecordSetDataSource;
import weaver.general.StaticObj;
import weaver.hrm.User;
import weaver.integration.util.SessionUtil;
import weaver.interfaces.datasource.DataSource;
import weaver.workflow.workflow.WfForceOver;
import weaver.workflow.workflow.WorkflowVersion;
import weaver.xiao.commons.utils.DocImageFileUtil;
@ -47,7 +57,9 @@ public class NormalTest extends BaseTest {
@Test
public void testWord(){
GenerateFileUtil.createCronJobDocument(GenerateReportSchedule.class);
//GenerateFileUtil.createCronJobDocument(GenerateReportSchedule.class);
//GenerateFileUtil.createActionDocument(OneNetComAction.class);
GenerateFileUtil.createActionDocument(RepeatSubmitAction.class);
}
@Test
@ -73,6 +85,51 @@ public class NormalTest extends BaseTest {
System.out.println(map);
}
@Test
public void testReq() throws IOException {
OneNetComAction oneNetComAction = new OneNetComAction();
oneNetComAction.setAcceptApiName("7aeef960-bd05-11eb-8742-b3a71c8ea78a");
oneNetComAction.setAppId("47689022-11cc-43c9-a31a-212df7cf4188");
oneNetComAction.setAppKey("4dd90db2a76042fc811715dc58e0f9b9");
Map<String, String> header = oneNetComAction.getHeader("7aeef960-bd05-11eb-8742-b3a71c8ea78a");
HttpUtils httpUtils = new HttpUtils();
Map<String,Object> param = new HashMap<>();
param.put("applyNo","030244223000002");
param.put("result","受理");
ResponeVo responeVo1 = httpUtils.apiPost("http://183.194.243.82/clientgateway/", param, header);
System.out.println(responeVo1);
ResponeVo responeVo = httpUtils.apiPostObject("http://183.194.243.82/clientgateway/", "{" +
"\"applyNo\": \"030244223000002\"," +
"\"result\" : \"受理\"," +
"\"method\" : \"窗口受理\"," +
"\"suggestion\" : \"受理\"," +
"\"opDepartCode\" : \"SHZCSH\"," +
"\"opDepartName\" : \"上海市知识产权局\"," +
"\"opUserId\": \"229726\"," +
"\"opUsername\": \"李四\"," +
"\"opTime\": \"2018-09-09 23:31:22\"" +
"}", header);
System.out.println(responeVo);
}
@Test
public void testFilter(){
List<Map<String,Integer>> list = new ArrayList<>();
for (int i = 0; i < 4; i++) {
Map<String,Integer> map = new HashMap<>();
map.put("id",1);
if(i == 3){
map.put("id",-1);
}
list.add(map);
}
long id = list.stream().filter(item -> item.get("id") == 2).count();
System.out.println(list);
list.sort(Comparator.comparingInt(o -> weaver.general.Util.getIntValue(o.get("id"))));
System.out.println(list);
}
@Test
public void testDataSource(){
DataSource ds = (DataSource) StaticObj.getServiceByFullname(("datasource.NCC"),DataSource.class);
@ -240,4 +297,48 @@ public class NormalTest extends BaseTest {
GenerateFileUtil.createCronJobDocument();
}
@Test
public void testUpdateModeConf(){
ModeChangeService modeChangeService = new ModeChangeService();
Map<String,Object> queryParam = new HashMap<>();
queryParam.put("fieldName","uuid");
queryParam.put("fieldValue","mqErrorLogModelId");
ModeMapper mapper = Util.getMapper(ModeMapper.class);
Map<String, Object> modeData = mapper.queryModeDataInfo("uf_systemconfig", queryParam);
modeChangeService.changeOtherMode(modeData,"-18");
}
@Test
public void testOver(){
WfForceOver wfForceOver = new WfForceOver();
ArrayList arrayList = new ArrayList();
arrayList.add("342350");
wfForceOver.doForceOver(arrayList,new User(1));
}
@Test
public void testRes(){
ReserveService reserveService = new ReserveServiceImpl();
Map<String,Object> param = new HashMap<>();
param.put("modeTableName","uf_contract_num_log");
param.put("dateField","month");
param.put("checkResultField","detail_id");
param.put("workflowInfoField","workflow_info");
param.put("checkResultValue","1");
param.put("repossessedValue","0");
param.put("applicationNoField","contract_num");
param.put("datePicker","2023-04");
reserveService.reserveSelect(param);
}
@Test
public void testSqlCondition() throws Exception {
Map<String,Object> param = new HashMap<>();
param.put("user",new User(45));
param.put("customid",2);
CustomSearchDepart customSearchDepart = new CustomSearchDepart();
String s = customSearchDepart.generateSqlCondition(param);
}
}