bug修改

dev
IT-xiaoXiong 2021-12-09 22:14:48 +08:00
parent 79c79d1218
commit 7efbec9808
8 changed files with 3077 additions and 2966 deletions

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,7 @@
package com.api.aiyh_pcn.fadada.web;
import aiyh.utils.ApiResult;
import aiyh.utils.Util;
import aiyh.utils.zwl.common.ToolUtil;
import com.alibaba.fastjson.JSON;
import com.api.aiyh_pcn.fadada.dao.FaDDContractMapping;
import com.api.aiyh_pcn.fadada.entity.UfContractInfoDTO;
import com.api.aiyh_pcn.fadada.service.impl.FaDDContractService;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.h2.util.StringUtils;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -20,157 +10,169 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;
import java.util.HashMap;
import java.util.Map;
import org.h2.util.StringUtils;
import com.alibaba.fastjson.JSON;
import com.api.aiyh_pcn.fadada.dao.FaDDContractMapping;
import com.api.aiyh_pcn.fadada.entity.UfContractInfoDTO;
import com.api.aiyh_pcn.fadada.service.impl.FaDDContractService;
import aiyh.utils.ApiResult;
import aiyh.utils.Util;
import aiyh.utils.zwl.common.ToolUtil;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
/**
* @author EBU7-dev1-ayh
* @create 2021/11/3 0003 14:49
* fadada
* @create 2021/11/3 0003 14:49 fadada
*/
@Path("/v2/fadada")
public class FaDDContractController {
private final FaDDContractService faDDService = new FaDDContractService();
private final FaDDContractMapping faDDContractMapping = new FaDDContractMapping();
private final ToolUtil toolUtil = new ToolUtil();
private final FaDDContractService faDDService = new FaDDContractService();
private final FaDDContractMapping faDDContractMapping = new FaDDContractMapping();
private final ToolUtil toolUtil = new ToolUtil();
/**
*
*
* @param workflowId
* id
* @return id
*/
@Path("/getAllVersion/{workflowId}/{markOnly}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String getAllVersion(@PathParam("workflowId") String workflowId, @PathParam("markOnly") String markOnly) {
try {
Map<String, Object> allVersion = faDDService.getAllVersion(workflowId);
return ApiResult.success(allVersion);
} catch (Exception e) {
toolUtil.writeErrorLog("错误:" + e.toString());
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param workflowId id
* @return id
*/
@Path("/getAllVersion/{workflowId}/{markOnly}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String getAllVersion(@PathParam("workflowId") String workflowId, @PathParam("markOnly") String markOnly) {
try {
Map<String, Object> allVersion = faDDService.getAllVersion(workflowId);
return ApiResult.success(allVersion);
} catch (Exception e) {
toolUtil.writeErrorLog("错误:" + e.toString());
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param params
* @return
*/
@Path("/callback/signed")
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String signedCallBack(@RequestBody Map<String, Object> params) {
toolUtil.writeErrorLog("回调方法,获取到的请求参数:" + JSON.toJSONString(params));
Map<String, Object> result = new HashMap<>();
result.put("code", 200);
result.put("msg", "操作成功!");
String resultCode = String.valueOf(params.get("resultCode"));
if (!"1".equals(resultCode)) {
// 签署失败
toolUtil.writeErrorLog("合同回调:签署失败,失败信息:" + JSON.toJSONString(params));
return JSON.toJSONString(result);
}
String contractNo = String.valueOf(params.get("docNo"));
faDDService.signedCallBack(contractNo);
return JSON.toJSONString(result);
}
/**
*
*
* @param requestId
* @param workflowId
* @return
*/
@Path("/isAllSigned/{workflowId}/{requestId}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String querySignedStatus(@PathParam("requestId") String requestId,
@PathParam("workflowId") String workflowId) {
Map<String, Object> result = faDDService.querySignedStatus(requestId);
return ApiResult.success(result);
}
/**
*
* @param params
* @return
*/
@Path("/callback/signed")
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String signedCallBack(@RequestBody Map<String, Object> params) {
toolUtil.writeErrorLog("回调方法,获取到的请求参数:" + JSON.toJSONString(params));
Map<String, Object> result = new HashMap<>();
result.put("code", 200);
result.put("msg", "操作成功!");
String resultCode = String.valueOf(params.get("resultCode"));
if(!"1".equals(resultCode)){
// 签署失败
toolUtil.writeErrorLog("合同回调:签署失败,失败信息:" + JSON.toJSONString(params));
return JSON.toJSONString(result);
}
String contractNo = String.valueOf(params.get("docNo"));
faDDService.signedCallBack(contractNo);
return JSON.toJSONString(result);
}
/**
*
*
* @param workflowId
* id
* @param requestId
* id
* @return
*/
@Path("/signedContract/own/{requestId}/{workflowId}")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String signedContractOwn(@Context HttpServletRequest request, @Context HttpServletResponse response,
@PathParam("workflowId") String workflowId, @PathParam("requestId") String requestId) {
// TODO 更换labelIndex
User user = HrmUserVarify.getUser(request, response);
try {
faDDService.signedContractOwn(requestId, user);
} catch (Exception e) {
return ApiResult.error(Util.getHtmlLabelName(-87658, user.getLanguage(), "合同签署失败!"));
}
return ApiResult.success(Util.getHtmlLabelName(-87657, user.getLanguage(), "本方签署成功!"));
}
/**
*
*
* @param requestId
* id
* @return
*/
@Path("/signedContract/{requestId}")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String signedContract(@Context HttpServletRequest request, @Context HttpServletResponse response,
@PathParam("requestId") String requestId) {
return ApiResult.success("没有催一催接口还点!淦!等法大大调整,额。。。具体啥时候好我也不知道,反正不关我的事!");
}
/**
*
* @param requestId
* @param workflowId
* @return
*/
@Path("/isAllSigned/{workflowId}/{requestId}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String querySignedStatus(@PathParam("requestId") String requestId, @PathParam("workflowId") String workflowId){
Map<String, Object> result = faDDService.querySignedStatus(requestId);
return ApiResult.success(result);
}
/**
*
*
* @param workflowId id
* @param requestId id
* @return
*/
@Path("/signedContract/own/{requestId}/{workflowId}")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String signedContractOwn(@Context HttpServletRequest request, @Context HttpServletResponse response,
@PathParam("workflowId") String workflowId, @PathParam("requestId") String requestId) {
// TODO 更换labelIndex
User user = HrmUserVarify.getUser(request, response);
try {
faDDService.signedContractOwn(requestId, user);
}catch (Exception e){
return ApiResult.error(Util.getHtmlLabelName(-87658,user.getLanguage(),"合同签署失败!"));
}
return ApiResult.success(Util.getHtmlLabelName(-87657,user.getLanguage(),"本方签署成功!"));
}
/**
*
*
* @param requestId id
* @return
*/
@Path("/signedContract/{requestId}")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String signedContract(@Context HttpServletRequest request, @Context HttpServletResponse response,
@PathParam("requestId") String requestId) {
return ApiResult.success("没有催一催接口还点!淦!等法大大调整,额。。。具体啥时候好我也不知道,反正不关我的事!");
}
/**
*
*
* @param requestId id
* @return
*/
@Path("/contract/download/{requestId}")
@GET
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response contractDownload(@PathParam("requestId") String requestId) {
toolUtil.writeErrorLog("进入请求方法获取到请求id" + requestId);
try {
UfContractInfoDTO ufContractInfoDTO = faDDContractMapping.queryContractInfoByRequestId(requestId);
StreamingOutput contractZipStream = faDDService.download4mFDD(ufContractInfoDTO);
String requestTitle = Util.null2String(Util.getRequestTitleById(String.valueOf(requestId)));
if(StringUtils.isNullOrEmpty(requestTitle)){
requestTitle = "contracts";
}
if(Util.null2String(ufContractInfoDTO.getContractNo()).split(",").length >= 2){
// 多文件
return Response.ok(contractZipStream, MediaType.APPLICATION_OCTET_STREAM)
.type("application/zip")
.header("Content-Disposition", "attachment;filename=" + requestTitle + ".zip").build();
}else{
// 单文件
return Response.ok(contractZipStream, MediaType.APPLICATION_OCTET_STREAM)
.type("application/pdf")
.header("Content-Disposition", "attachment;filename=" + requestTitle + ".pdf").build();
}
} catch (Exception e) {
toolUtil.writeErrorLog("文件流转换失败," + e);
return Response.ok(ApiResult.error("出现错误,错误原因: " + e), MediaType.TEXT_PLAIN).build();
}
}
/**
*
*
* @param requestId
* id
* @return
*/
@Path("/contract/download/{requestId}")
@GET
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response contractDownload(@PathParam("requestId") String requestId) {
toolUtil.writeErrorLog("进入请求方法获取到请求id" + requestId);
try {
UfContractInfoDTO ufContractInfoDTO = faDDContractMapping.queryContractInfoByRequestId(requestId);
StreamingOutput contractZipStream = faDDService.download4mFDD(ufContractInfoDTO);
// String requestTitle =
// Util.null2String(Util.getRequestTitleById(String.valueOf(requestId)));
String requestTitle = ufContractInfoDTO.getFileName();
if (StringUtils.isNullOrEmpty(requestTitle)) {
requestTitle = "contracts.pdf";
}
if (Util.null2String(ufContractInfoDTO.getContractNo()).split(",").length >= 2) {
// 多文件
return Response.ok(contractZipStream, MediaType.APPLICATION_OCTET_STREAM).type("application/zip")
.header("Content-Disposition", "attachment;filename=" + requestTitle + ".zip").build();
} else {
// 单文件
return Response.ok(contractZipStream, MediaType.APPLICATION_OCTET_STREAM).type("application/pdf")
.header("Content-Disposition", "attachment;filename=" + requestTitle).build();
}
} catch (Exception e) {
toolUtil.writeErrorLog("文件流转换失败," + e);
return Response.ok(ApiResult.error("出现错误,错误原因: " + e), MediaType.TEXT_PLAIN).build();
}
}
}

View File

@ -1,19 +1,11 @@
package com.api.aiyh_pcn.fadada.web;
import aiyh.utils.ApiResult;
import aiyh.utils.Util;
import aiyh.utils.mapUtil.ParaMap;
import aiyh.utils.sqlUtil.sqlResult.impl.PrepSqlResultImpl;
import aiyh.utils.zwl.common.ToolUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.api.aiyh_pcn.fadada.dao.FaDDServiceMapping;
import com.api.aiyh_pcn.fadada.service.impl.FaDDServiceImpl;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.h2.util.StringUtils;
import weaver.conn.RecordSet;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -22,236 +14,252 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import org.h2.util.StringUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.api.aiyh_pcn.fadada.dao.FaDDServiceMapping;
import com.api.aiyh_pcn.fadada.service.impl.FaDDServiceImpl;
import aiyh.utils.ApiResult;
import aiyh.utils.Util;
import aiyh.utils.mapUtil.ParaMap;
import aiyh.utils.sqlUtil.sqlResult.impl.PrepSqlResultImpl;
import aiyh.utils.zwl.common.ToolUtil;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import weaver.conn.RecordSet;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
/**
* @author EBU7-dev1-ayh
* @create 2021/9/28 0028 16:05
*
* @create 2021/9/28 0028 16:05
*/
@Path("/fadada")
public class FaDDController {
private final FaDDServiceImpl faDDService = new FaDDServiceImpl();
private final FaDDServiceMapping faDDServiceMapping = new FaDDServiceMapping();
private final ToolUtil toolUtil = new ToolUtil();
private final FaDDServiceImpl faDDService = new FaDDServiceImpl();
private final FaDDServiceMapping faDDServiceMapping = new FaDDServiceMapping();
private final ToolUtil toolUtil = new ToolUtil();
/**
*
*
* @param workflowId id
* @return
*/
@GET
@Path("/getConfig/{workflowId}")
public String getConfig(@PathParam("workflowId") String workflowId) {
try {
Map<String, Object> configParam = faDDService.getConfigParam(workflowId);
return ApiResult.success(configParam);
} catch (Exception e) {
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param workflowId
* id
* @return
*/
@GET
@Path("/getConfig/{workflowId}")
public String getConfig(@PathParam("workflowId") String workflowId) {
try {
Map<String, Object> configParam = faDDService.getConfigParam(workflowId);
return ApiResult.success(configParam);
} catch (Exception e) {
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param params
* @return
*/
@Path("/signature")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String checkCertification(@RequestBody Map<String, Object> params) {
try {
Map<String, Object> certificationResult = faDDService.checkCertification(params);
return ApiResult.success(certificationResult);
} catch (Exception e) {
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param params
*
* @return
*/
@Path("/signature")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String checkCertification(@RequestBody Map<String, Object> params) {
try {
Map<String, Object> certificationResult = faDDService.checkCertification(params);
return ApiResult.success(certificationResult);
} catch (Exception e) {
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param workflowId id
* @param requestId id
* @return
*/
@Path("/signedContract/{languageGroupId}/{requestId}/{workflowId}")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String signedContract(@Context HttpServletRequest request, @Context HttpServletResponse response,
@PathParam("workflowId") String workflowId, @PathParam("requestId") String requestId,
@PathParam("languageGroupId") int languageGroupId) {
User user = HrmUserVarify.getUser(request, response);
try {
faDDService.queryContractStatus(workflowId, requestId,0);
Map<String, String> language = Util.queryLanguage(languageGroupId, user.getLanguage());
String info = language.get("rushInfo");
return ApiResult.success(info);
} catch (Exception e) {
toolUtil.writeErrorLog("错误:" + e);
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param workflowId
* id
* @param requestId
* id
* @return
*/
@Path("/signedContract/{languageGroupId}/{requestId}/{workflowId}")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String signedContract(@Context HttpServletRequest request, @Context HttpServletResponse response,
@PathParam("workflowId") String workflowId, @PathParam("requestId") String requestId,
@PathParam("languageGroupId") int languageGroupId) {
User user = HrmUserVarify.getUser(request, response);
try {
faDDService.queryContractStatus(workflowId, requestId, 0);
Map<String, String> language = Util.queryLanguage(languageGroupId, user.getLanguage());
String info = language.get("rushInfo");
return ApiResult.success(info);
} catch (Exception e) {
toolUtil.writeErrorLog("错误:" + e);
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param workflowId id
* @param requestId id
* @return
*/
@Path("/signedContract/own/{languageGroupId}/{requestId}/{workflowId}")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String signedContractOwn(@Context HttpServletRequest request, @Context HttpServletResponse response,
@PathParam("workflowId") String workflowId, @PathParam("requestId") String requestId,
@PathParam("languageGroupId") int languageGroupId) {
User user = HrmUserVarify.getUser(request, response);
try {
faDDService.signedContractOwn(workflowId, requestId);
String mainTable = faDDServiceMapping.getMainTable(workflowId);
// TODO 更新本方签署
PrepSqlResultImpl sqlResult = Util.createSqlBuilder().updateSql(mainTable, ParaMap.create()
.put("signed_oneself", 1), Util.createPrepWhereImpl().whereAnd("requestid").whereEqual(requestId));
RecordSet rs = new RecordSet();
rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs());
Map<String, String> language = Util.queryLanguage(languageGroupId, user.getLanguage());
String info = language.get("contractSignedInfo");
return ApiResult.success(info);
} catch (Exception e) {
toolUtil.writeErrorLog("错误:" + e.toString());
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param workflowId
* id
* @param requestId
* id
* @return
*/
@Path("/signedContract/own/{languageGroupId}/{requestId}/{workflowId}")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String signedContractOwn(@Context HttpServletRequest request, @Context HttpServletResponse response,
@PathParam("workflowId") String workflowId, @PathParam("requestId") String requestId,
@PathParam("languageGroupId") int languageGroupId) {
User user = HrmUserVarify.getUser(request, response);
try {
faDDService.signedContractOwn(workflowId, requestId);
String mainTable = faDDServiceMapping.getMainTable(workflowId);
// TODO 更新本方签署
PrepSqlResultImpl sqlResult =
Util.createSqlBuilder().updateSql(mainTable, ParaMap.create().put("signed_oneself", 1),
Util.createPrepWhereImpl().whereAnd("requestid").whereEqual(requestId));
RecordSet rs = new RecordSet();
rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs());
Map<String, String> language = Util.queryLanguage(languageGroupId, user.getLanguage());
String info = language.get("contractSignedInfo");
return ApiResult.success(info);
} catch (Exception e) {
toolUtil.writeErrorLog("错误:" + e.toString());
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param requestId id
* @return
*/
@Path("/contract/download/{workflowId}/{requestId}")
@GET
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response contractDownload(@PathParam("requestId") String requestId, @PathParam("workflowId") String workflowId) {
toolUtil.writeErrorLog("进入请求方法获取到请求id" + requestId);
try {
StreamingOutput contractZipStream = faDDService.contractDownload(requestId, workflowId);
return Response.ok(contractZipStream, MediaType.APPLICATION_OCTET_STREAM)
.type("application/zip")
.header("Content-Disposition", "attachment;filename=contracts.zip").build();
} catch (Exception e) {
toolUtil.writeErrorLog("转换失败," + e.toString());
return Response.ok(ApiResult.error("出现错误,错误原因: " + e),MediaType.APPLICATION_JSON).build();
}
}
/**
*
*
* @param requestId
* id
* @return
*/
@Path("/contract/download/{workflowId}/{requestId}")
@GET
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response contractDownload(@PathParam("requestId") String requestId,
@PathParam("workflowId") String workflowId) {
toolUtil.writeErrorLog("进入请求方法获取到请求id" + requestId);
try {
StreamingOutput contractZipStream = faDDService.contractDownload(requestId, workflowId);
return Response.ok(contractZipStream, MediaType.APPLICATION_OCTET_STREAM).type("application/zip")
.header("Content-Disposition", "attachment;filename=contracts.zip").build();
} catch (Exception e) {
toolUtil.writeErrorLog("转换失败," + e.toString());
return Response.ok(ApiResult.error("出现错误,错误原因: " + e), MediaType.APPLICATION_JSON).build();
}
}
/**
*
*
* @param workflowId id
* @return id
*/
@Path("/getAllVersion/{workflowId}/{markOnly}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String getAllVersion(@PathParam("workflowId") String workflowId, @PathParam("markOnly") String markOnly) {
try {
Map<String, Object> allVersion = faDDService.getAllVersion(workflowId, markOnly);
return ApiResult.success(allVersion);
} catch (Exception e) {
toolUtil.writeErrorLog("错误:" + e.toString());
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param workflowId
* id
* @return id
*/
@Path("/getAllVersion/{workflowId}/{markOnly}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String getAllVersion(@PathParam("workflowId") String workflowId, @PathParam("markOnly") String markOnly) {
try {
Map<String, Object> allVersion = faDDService.getAllVersion(workflowId, markOnly);
return ApiResult.success(allVersion);
} catch (Exception e) {
toolUtil.writeErrorLog("错误:" + e.toString());
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param requestId
* id
* @return
*/
@Path("/isAllSigned/{workflowId}/{requestId}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String isAllSinged(@PathParam("requestId") String requestId, @PathParam("workflowId") String workflowId) {
try {
faDDService.queryContractStatus(workflowId, requestId, 1);
boolean isAllSinged = faDDService.isAllSinged(requestId, workflowId);
boolean isSingedOneself = faDDService.isSingedOneself(requestId, workflowId);
Map<String, Object> result =
ParaMap.create().put("isAllSinged", isAllSinged).put("isSingedOneself", isSingedOneself);
return ApiResult.success(result);
} catch (Exception e) {
toolUtil.writeErrorLog("错误:" + e);
return ApiResult.error(e.toString());
}
}
/**
*
*
* @param requestId id
* @return
*/
@Path("/isAllSigned/{workflowId}/{requestId}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String isAllSinged(@PathParam("requestId") String requestId, @PathParam("workflowId") String workflowId) {
try {
faDDService.queryContractStatus(workflowId,requestId,1);
boolean isAllSinged = faDDService.isAllSinged(requestId, workflowId);
boolean isSingedOneself = faDDService.isSingedOneself(requestId, workflowId);
Map<String, Object> result = ParaMap.create().put("isAllSinged", isAllSinged)
.put("isSingedOneself", isSingedOneself);
return ApiResult.success(result);
} catch (Exception e) {
toolUtil.writeErrorLog("错误:" + e);
return ApiResult.error(e.toString());
}
}
@Path("/getLanguage/{languageGroupId}")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String getLanguage(@Context HttpServletRequest request, @Context HttpServletResponse response,
@PathParam("languageGroupId") int languageGroupId) {
User user = HrmUserVarify.getUser(request, response);
Map<String, String> map = Util.queryLanguage(languageGroupId, user.getLanguage());
return ApiResult.success(map);
}
@Path("/callback/signed")
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String callBackSigned(@RequestBody Map<String, Object> params) {
toolUtil.writeErrorLog("回调方法:" + JSONObject.toJSONString(params));
Map<String, Object> result = new HashMap<>();
String bizContent = String.valueOf(params.get("bizContent"));
if (StringUtils.isNullOrEmpty(bizContent)) {
toolUtil.writeErrorLog("参数没获取到!");
result.put("code", "200");
result.put("msg", "操作失败!");
return JSONObject.toJSONString(result);
}
byte[] decode = Base64.getDecoder().decode(bizContent.getBytes(StandardCharsets.UTF_8));
String decodeStr = null;
try {
decodeStr = new String(decode, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
String jsonStr = null;
try {
jsonStr = URLDecoder.decode(decodeStr, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
JSONObject jsonObject = JSON.parseObject(jsonStr);
String resultCode = String.valueOf(jsonObject.getString("resultCode"));
String docNo = String.valueOf(jsonObject.getString("docNo"));
if (!"1".equals(resultCode)) {
toolUtil.writeErrorLog("重复签署合同!" + docNo);
}
// Util.createSqlBuilder().updateSql()
@Path("/getLanguage/{languageGroupId}")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String getLanguage(@Context HttpServletRequest request, @Context HttpServletResponse response,
@PathParam("languageGroupId") int languageGroupId) {
User user = HrmUserVarify.getUser(request, response);
Map<String, String> map = Util.queryLanguage(languageGroupId, user.getLanguage());
return ApiResult.success(map);
}
@Path("/callback/signed")
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String callBackSigned(@RequestBody Map<String, Object> params){
toolUtil.writeErrorLog("回调方法:" + JSONObject.toJSONString(params));
Map<String,Object> result = new HashMap<>();
String bizContent = String.valueOf(params.get("bizContent"));
if(StringUtils.isNullOrEmpty(bizContent)){
toolUtil.writeErrorLog("参数没获取到!");
result.put("code","200");
result.put("msg","操作失败!");
return JSONObject.toJSONString(result);
}
byte[] decode = Base64.getDecoder().decode(bizContent.getBytes(StandardCharsets.UTF_8));
String decodeStr = null;
try {
decodeStr = new String(decode,"UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
String jsonStr = null;
try {
jsonStr = URLDecoder.decode(decodeStr, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
JSONObject jsonObject = JSON.parseObject(jsonStr);
String resultCode = String.valueOf(jsonObject.getString("resultCode"));
String docNo = String.valueOf(jsonObject.getString("docNo"));
if(!"1".equals(resultCode)){
toolUtil.writeErrorLog("重复签署合同!" + docNo);
}
// Util.createSqlBuilder().updateSql()
this.toolUtil.writeErrorLog(jsonObject.toJSONString());
result.put("code","200");
result.put("msg","操作成功!");
return JSONObject.toJSONString(result);
}
this.toolUtil.writeErrorLog(jsonObject.toJSONString());
result.put("code", "200");
result.put("msg", "操作成功!");
return JSONObject.toJSONString(result);
}
}

View File

@ -1,49 +1,44 @@
package com.api.aiyh_pcn.patentWall.dao;
import java.util.List;
import java.util.Map;
import aiyh.utils.Util;
import aiyh.utils.zwl.common.ToolUtil;
import com.api.aiyh_pcn.patentWall.dto.FilterWhere;
import com.api.aiyh_pcn.patentWall.vo.PatentVO;
import weaver.conn.RecordSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author EBU7-dev1-ayh
* @create 2021/11/25 0025 15:28
*/
public class PatentWallMapping {
private final ToolUtil toolUtil = new ToolUtil();
private final ToolUtil toolUtil = new ToolUtil();
public List<Map<String, Object>> getAllList(String tableName){
RecordSet rs = new RecordSet();
String query = "select * from " + tableName;
rs.executeQuery(query);
return Util.recordSet2MapList(rs);
}
public List<Map<String, Object>> getAllList(String tableName) {
RecordSet rs = new RecordSet();
String query = "select * from " + tableName;
rs.executeQuery(query);
return Util.recordSet2MapList(rs);
}
public List<Map<String,Object>> getListByFilterWhere(StringBuilder whereBuilder,List<String> args, String tableName) {
RecordSet rs = new RecordSet();
String query = "select * from " + tableName + whereBuilder.toString().replace(" where add "," where ");
rs.executeQuery(query,args);
toolUtil.writeDebuggerLog(String.format("执行SQL {%s} ---> 参数: {%s}",query,args));
return Util.recordSet2MapList(rs);
}
public List<Map<String, Object>> getListByFilterWhere(StringBuilder whereBuilder, List<String> args,
String tableName) {
RecordSet rs = new RecordSet();
String query = "select * from " + tableName + whereBuilder.toString().replace(" where add ", " where ");
rs.executeQuery(query, args);
toolUtil.writeDebuggerLog(String.format("执行SQL {%s} ---> 参数: {%s}", query, args));
return Util.recordSet2MapList(rs);
}
public List<Map<String,Object>> getSelectOptions(String dataResource, String dbFieldName) {
RecordSet rs = new RecordSet();
String query = "select wbf.id,wbf.fieldname,wbf.fieldlabel,wb.tablename, " +
"ws.selectname,ws.selectvalue " +
"from workflow_billfield wbf " +
"left join workflow_bill wb on wbf.billid = wb.id " +
"left join workflow_selectitem ws on ws.fieldid = wbf.id " +
"where wb.tablename = ? and fieldname = ? ";
rs.executeQuery(query,dataResource,dbFieldName);
toolUtil.writeDebuggerLog(String.format("执行SQL {%s} ---> 参数: {%s}",query,dataResource + " -- " + dbFieldName));
return Util.recordSet2MapList(rs);
}
public List<Map<String, Object>> getSelectOptions(String dataResource, String dbFieldName) {
RecordSet rs = new RecordSet();
String query = "select wbf.id,wbf.fieldname,wbf.fieldlabel,wb.tablename, " + "ws.selectname,ws.selectvalue "
+ "from workflow_billfield wbf " + "left join workflow_bill wb on wbf.billid = wb.id "
+ "left join workflow_selectitem ws on ws.fieldid = wbf.id " + "where wb.tablename = ? and fieldname = ? ";
rs.executeQuery(query, dataResource, dbFieldName);
toolUtil
.writeDebuggerLog(String.format("执行SQL {%s} ---> 参数: {%s}", query, dataResource + " -- " + dbFieldName));
return Util.recordSet2MapList(rs);
}
}

View File

@ -27,341 +27,345 @@ import java.util.regex.Pattern;
* @author EBU7-dev1-ayh
* @create 2021/11/25 0025 15:23
*/
public class PatentWallService {
private final PatentWallMapping patentWallMapping = new PatentWallMapping();
private final ToolUtil toolUtil = new ToolUtil();
private Map<String, Object> patentWallConf;
private Map<String, Object> patentWallSearchConf;
private final RecordSet rs = new RecordSet();
private final PatentWallMapping patentWallMapping = new PatentWallMapping();
private final ToolUtil toolUtil = new ToolUtil();
private Map<String, Object> patentWallConf;
private Map<String, Object> patentWallSearchConf;
private final RecordSet rs = new RecordSet();
/**
*
*
* @param prefix
* @return
*/
public List<SearchInputVO> getSearchList(String prefix, int languageId) {
Map<String, Object> patentWallSearchConf = getPatentWallSearchConf(prefix + ".search");
String dataResource = String.valueOf(patentWallSearchConf.get("dataResource"));
List<Map<String, Object>> inputs =
(List<Map<String, Object>>) patentWallSearchConf.get("inputs");
List<SearchInputVO> searchInputList = new ArrayList<>();
for (Map<String, Object> input : inputs) {
SearchInputVO searchInputVO = new SearchInputVO();
int type = Integer.parseInt(Util.null2DefaultStr(input.get("type"), "0"));
String dbFieldName = Util.null2String(input.get("dbFieldName"));
String value = Util.null2String(input.get("value"));
String labelName = Util.null2String(input.get("labelName"));
Integer labelIndex = Integer.valueOf(Util.null2DefaultStr(input.get("labelIndex"), "0"));
Integer searchType = Integer.valueOf(Util.null2DefaultStr(input.get("searchType"), "0"));
Boolean multiple = Boolean.valueOf(Util.null2DefaultStr(input.get("multiple"), "false"));
searchInputVO.setType(type);
searchInputVO.setLabelName(labelName);
searchInputVO.setSearchType(searchType);
searchInputVO.setDbFieldName(dbFieldName);
searchInputVO.setLabelIndex(labelIndex);
searchInputVO.setLabelIndex(labelIndex);
searchInputVO.setMultiple(multiple);
searchInputVO.setValue(value);
searchInputList.add(searchInputVO);
switch (type) {
case 1:
// 下拉框 查询options
List<SelectOptionsVo> optionsVos =
getSelectOptions(dataResource, dbFieldName, languageId);
searchInputVO.setSelectOptions(optionsVos);
case 2:
// 单行文本
break;
case 3:
// 日期
case 4:
// 单人力资源
break;
case 5:
// 多人力资源
break;
case 6:
// 流程路径
break;
case 7:
// 多流程路径
break;
default:
toolUtil.writeDebuggerLog("未匹配输入框类型!请检查配置文件是否正确!");
break;
}
}
return searchInputList;
}
/**
*
*
* @param prefix
* @return
*/
public List<SearchInputVO> getSearchList(String prefix,int languageId) {
Map<String, Object> patentWallSearchConf = getPatentWallSearchConf(prefix + ".search");
String dataResource = String.valueOf(patentWallSearchConf.get("dataResource"));
List<Map<String, Object>> inputs = (List<Map<String, Object>>) patentWallSearchConf.get("inputs");
List<SearchInputVO> searchInputList = new ArrayList<>();
for (Map<String, Object> input : inputs) {
SearchInputVO searchInputVO = new SearchInputVO();
int type = Integer.parseInt(Util.null2DefaultStr(input.get("type"), "0"));
String dbFieldName = Util.null2String(input.get("dbFieldName"));
String value = Util.null2String(input.get("value"));
String labelName = Util.null2String(input.get("labelName"));
Integer labelIndex = Integer.valueOf(Util.null2DefaultStr(input.get("labelIndex"),"0"));
Integer searchType = Integer.valueOf(Util.null2DefaultStr(input.get("searchType"),"0"));
Boolean multiple = Boolean.valueOf(Util.null2DefaultStr(input.get("multiple"),"false"));
searchInputVO.setType(type);
searchInputVO.setLabelName(labelName);
searchInputVO.setSearchType(searchType);
searchInputVO.setDbFieldName(dbFieldName);
searchInputVO.setLabelIndex(labelIndex);
searchInputVO.setLabelIndex(labelIndex);
searchInputVO.setMultiple(multiple);
searchInputVO.setValue(value);
searchInputList.add(searchInputVO);
switch (type) {
case 1:
// 下拉框 查询options
List<SelectOptionsVo> optionsVos = getSelectOptions(dataResource, dbFieldName,languageId);
searchInputVO.setSelectOptions(optionsVos);
case 2:
// 单行文本
break;
case 3:
// 日期
case 4:
// 单人力资源
break;
case 5:
// 多人力资源
break;
case 6:
// 流程路径
break;
case 7:
// 多流程路径
break;
default:
toolUtil.writeDebuggerLog("未匹配输入框类型!请检查配置文件是否正确!");
break;
}
}
return searchInputList;
}
private List<SelectOptionsVo> getSelectOptions(
String dataResource, String dbFieldName, int languageId) {
List<Map<String, Object>> selectOptions =
patentWallMapping.getSelectOptions(dataResource, dbFieldName);
List<SelectOptionsVo> optionsVos = new ArrayList<>();
SelectOptionsVo optionsDefault = new SelectOptionsVo();
optionsDefault.setSelected(true);
optionsDefault.setKey("");
optionsDefault.setShowname("");
optionsVos.add(optionsDefault);
for (Map<String, Object> selectOption : selectOptions) {
SelectOptionsVo optionsVo = new SelectOptionsVo();
optionsVo.setSelected(false);
optionsVo.setKey(Util.null2DefaultStr(selectOption.get("selectvalue"), ""));
String selectName = Util.null2DefaultStr(selectOption.get("selectname"), "");
String showName = selectName;
if (selectName.startsWith("~`~`") && selectName.endsWith("`~`~")) {
String pattern = "(`~`" + languageId + " )(?<label>(\\w*|\\W*|[\\u4e00-\\u9fa5]*))(`~`)";
Pattern compile = Pattern.compile(pattern);
Matcher matcher = compile.matcher(selectName);
if (matcher.find()) {
showName = matcher.group("label");
}
}
optionsVo.setShowname(showName);
optionsVos.add(optionsVo);
}
return optionsVos;
}
private List<SelectOptionsVo> getSelectOptions(String dataResource, String dbFieldName, int languageId) {
List<Map<String, Object>> selectOptions = patentWallMapping.getSelectOptions(dataResource, dbFieldName);
List<SelectOptionsVo> optionsVos = new ArrayList<>();
SelectOptionsVo optionsDefault = new SelectOptionsVo();
optionsDefault.setSelected(true);
optionsDefault.setKey("");
optionsDefault.setShowname("");
optionsVos.add(optionsDefault);
for (Map<String, Object> selectOption : selectOptions) {
SelectOptionsVo optionsVo = new SelectOptionsVo();
optionsVo.setSelected(false);
optionsVo.setKey(Util.null2DefaultStr(selectOption.get("selectvalue"),""));
String selectName = Util.null2DefaultStr(selectOption.get("selectname"), "");
String showName = selectName;
if (selectName.startsWith("~`~`") && selectName.endsWith("`~`~")) {
String pattern = "(`~`" + languageId + " )(?<label>(\\w*|\\W*|[\\u4e00-\\u9fa5]*))(`~`)";
Pattern compile = Pattern.compile(pattern);
Matcher matcher = compile.matcher(selectName);
if (matcher.find()) {
showName = matcher.group("label");
}
}
optionsVo.setShowname(showName);
optionsVos.add(optionsVo);
}
return optionsVos;
}
/**
*
*
* @param filterWheres
* @param prefix
* @return
*/
public List<PatentVO> getList(List<FilterWhere> filterWheres, String prefix) {
Map<String, Object> patentWallConf = getPatentWallConf(prefix + ".voMapping");
List<Map<String, Object>> dataList;
toolUtil.writeDebuggerLog(String.format("查询数据,接收到的过滤信息为: %s", JSON.toJSONString(filterWheres)));
if (filterWheres == null || filterWheres.isEmpty()) {
// 查询全部
dataList = patentWallMapping.getAllList(Util.null2String(patentWallConf.get("dataResource")));
} else {
// 筛选查询
dataList =
handleFilterWhere(filterWheres, Util.null2String(patentWallConf.get("dataResource")));
}
List<PatentVO> list = new ArrayList<>();
List<String> args = new ArrayList<>();
RecordSet rs = new RecordSet();
for (Map<String, Object> data : dataList) {
Map<String, Object> config = new HashMap<>(patentWallConf);
for (Map.Entry<String, Object> entry : patentWallConf.entrySet()) {
String patentVoField = entry.getKey();
// linkList
String parsing = null;
// 值解析
if ("linkList".equals(patentVoField)) {
List<LinkUrlVO> linkUrlVOS = new ArrayList<>();
List<Map<String, Object>> linkUrlList = (List<Map<String, Object>>) entry.getValue();
for (Map<String, Object> linkUrlMap : linkUrlList) {
LinkUrlVO linkUrlVO = new LinkUrlVO();
BeanInfo beanInfo = null;
try {
beanInfo = Introspector.getBeanInfo(LinkUrlVO.class, Object.class);
} catch (IntrospectionException e) {
e.printStackTrace();
toolUtil.writeDebuggerLog("获取beanInfo错误");
continue;
}
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
String keyName = propertyDescriptor.getName();
String parsingValue = String.valueOf(linkUrlMap.get(keyName));
parsingValue = handleParsingConf(parsingValue, data, args);
// 清除参数信息
args.clear();
if (propertyDescriptor.getPropertyType().equals(Integer.class)) {
try {
propertyDescriptor
.getWriteMethod()
.invoke(linkUrlVO, Integer.valueOf(parsingValue));
} catch (IllegalAccessException | InvocationTargetException e) {
toolUtil.writeErrorLog("设置值失败调用beanInfo的set方法错误");
e.printStackTrace();
}
} else {
try {
propertyDescriptor.getWriteMethod().invoke(linkUrlVO, parsingValue);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
toolUtil.writeErrorLog("设置值失败调用beanInfo的set方法错误");
}
}
}
linkUrlVOS.add(linkUrlVO);
}
config.replace(patentVoField, linkUrlVOS);
} else {
parsing = String.valueOf(entry.getValue());
parsing = handleParsingConf(parsing, data, args);
// 修改数据
config.replace(patentVoField, parsing);
// 清除参数信息
args.clear();
}
}
PatentVO patentVO = null;
try {
patentVO = Util.mapToObject(config, PatentVO.class);
} catch (Exception e) {
e.printStackTrace();
toolUtil.writeErrorLog("map转为PatentVO失败");
}
list.add(patentVO);
}
return list;
}
/**
*
*
* @param filterWheres
* @param prefix
* @return
*/
public List<PatentVO> getList(List<FilterWhere> filterWheres, String prefix) {
Map<String, Object> patentWallConf = getPatentWallConf(prefix + ".voMapping");
List<Map<String, Object>> dataList;
toolUtil.writeDebuggerLog(String.format("查询数据,接收到的过滤信息为: %s", JSON.toJSONString(filterWheres)));
if (filterWheres == null || filterWheres.isEmpty()) {
// 查询全部
dataList = patentWallMapping.getAllList(Util.null2String(patentWallConf.get("dataResource")));
} else {
// 筛选查询
dataList = handleFilterWhere(filterWheres
, Util.null2String(patentWallConf.get("dataResource")));
}
List<PatentVO> list = new ArrayList<>();
List<String> args = new ArrayList<>();
RecordSet rs = new RecordSet();
for (Map<String, Object> data : dataList) {
Map<String, Object> config = new HashMap<>(patentWallConf);
for (Map.Entry<String, Object> entry : patentWallConf.entrySet()) {
String patentVoField = entry.getKey();
// linkList
String parsing = null;
// 值解析
if("linkList".equals(patentVoField)){
List<LinkUrlVO> linkUrlVOS = new ArrayList<>();
List<Map<String,Object>> linkUrlList = (List<Map<String, Object>>) entry.getValue();
for (Map<String, Object> linkUrlMap : linkUrlList) {
LinkUrlVO linkUrlVO = new LinkUrlVO();
BeanInfo beanInfo = null;
try {
beanInfo = Introspector.getBeanInfo(LinkUrlVO.class, Object.class);
} catch (IntrospectionException e) {
e.printStackTrace();
toolUtil.writeDebuggerLog("获取beanInfo错误");
continue;
}
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
String keyName = propertyDescriptor.getName();
String parsingValue = String.valueOf(linkUrlMap.get(keyName));
parsingValue = handleParsingConf(parsingValue,data,args);
// 清除参数信息
args.clear();
if(propertyDescriptor.getPropertyType().equals(Integer.class)){
try {
propertyDescriptor.getWriteMethod().invoke(linkUrlVO,Integer.valueOf(parsingValue));
} catch (IllegalAccessException | InvocationTargetException e) {
toolUtil.writeErrorLog("设置值失败调用beanInfo的set方法错误");
e.printStackTrace();
}
}else {
try {
propertyDescriptor.getWriteMethod().invoke(linkUrlVO,parsingValue);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
toolUtil.writeErrorLog("设置值失败调用beanInfo的set方法错误");
}
}
}
linkUrlVOS.add(linkUrlVO);
}
config.replace(patentVoField, linkUrlVOS);
}else{
parsing = String.valueOf(entry.getValue());
parsing = handleParsingConf(parsing,data,args);
// 修改数据
config.replace(patentVoField, parsing);
// 清除参数信息
args.clear();
}
public String handleParsingConf(String parsing, Map<String, Object> data, List<String> args) {
// 值解析
// 解析 ${}类型的参数,直接替换
String pattern = "\\$\\{(?<field>(\\s|\\S)+?)}";
Pattern compile = Pattern.compile(pattern);
Matcher matcher = compile.matcher(parsing);
while (matcher.find()) {
parsing = parsing.replaceFirst(pattern, Util.null2String(data.get(matcher.group("field"))));
}
// 解析#{}类型的参数,替换为?并按照顺序收集args
pattern = "#\\{(?<field>(\\s|\\S)+?)}";
compile = Pattern.compile(pattern);
matcher = compile.matcher(parsing);
while (matcher.find()) {
parsing = parsing.replaceFirst(pattern, "?");
args.add(Util.null2String(data.get(matcher.group("field"))));
}
// 解析#sql{}类型的参数并执行SQL获取到SQL的值
pattern = "#sql\\{(?<sqlStr>([\\s\\S])+?)}";
compile = Pattern.compile(pattern);
matcher = compile.matcher(parsing);
while (matcher.find()) {
String sqlStr = matcher.group("sqlStr");
toolUtil.writeDebuggerLog(String.format("执行SQL {%s} ---> 参数: {%s}", sqlStr, args));
rs.executeQuery(sqlStr, args);
rs.next();
parsing = parsing.replaceFirst(pattern, Util.null2String(rs.getString(1)));
;
}
return parsing;
}
}
PatentVO patentVO = null;
try {
patentVO = Util.mapToObject(config, PatentVO.class);
} catch (Exception e) {
e.printStackTrace();
toolUtil.writeErrorLog("map转为PatentVO失败");
}
list.add(patentVO);
}
return list;
}
public List<Map<String, Object>> handleFilterWhere(
List<FilterWhere> filterWheres, String tableName) {
StringBuilder whereBuilder = new StringBuilder(" where ");
List<String> args = new ArrayList<>();
for (FilterWhere filterWhere : filterWheres) {
whereBuilder.append(" add ");
if (filterWhere.getSearchType() == 1) {
// 等于
whereBuilder.append(filterWhere.getDbField()).append(" = ? ");
args.add(filterWhere.getValue());
continue;
}
if (filterWhere.getSearchType() == 2) {
// 大于
whereBuilder.append(filterWhere.getDbField()).append(" > ?");
args.add(filterWhere.getValue());
continue;
}
if (filterWhere.getSearchType() == 3) {
// 小于
whereBuilder.append(filterWhere.getDbField()).append(" < ?");
args.add(filterWhere.getValue());
continue;
}
if (filterWhere.getSearchType() == 4) {
// in
whereBuilder
.append(filterWhere.getDbField())
.append(" in ( ")
.append(filterWhere.getValue())
.append(") ");
continue;
}
if (filterWhere.getSearchType() == 5) {
// 日期大于
whereBuilder
.append(" DATE_FORMAT(")
.append(filterWhere.getDbField())
.append(",'%y-%m-%d') > ")
.append("DATE_FORMAT(?,'%y-%m-%d')");
args.add(filterWhere.getValue());
continue;
}
if (filterWhere.getSearchType() == 6) {
// 日期小于
whereBuilder
.append(" DATE_FORMAT(")
.append(filterWhere.getDbField())
.append(",'%y-%m-%d') < ")
.append("DATE_FORMAT(?,'%y-%m-%d')");
args.add(filterWhere.getValue());
continue;
}
if (filterWhere.getSearchType() == 7) {
// 日期等于
whereBuilder
.append(" DATE_FORMAT(")
.append(filterWhere.getDbField())
.append(",'%y-%m-%d') = ")
.append("DATE_FORMAT(?,'%y-%m-%d')");
args.add(filterWhere.getValue());
continue;
}
if (filterWhere.getSearchType() == 8) {
// 日期范围
whereBuilder
.append(" DATE_FORMAT(")
.append(filterWhere.getDbField())
.append(",'%y-%m-%d') between ")
.append("DATE_FORMAT(?,'%y-%m-%d')")
.append(" and DATE_FORMAT(?,'%y-%m-%d')");
args.add(filterWhere.getValue().split("&")[0]);
args.add(filterWhere.getValue().split("&")[1]);
continue;
}
}
return patentWallMapping.getListByFilterWhere(whereBuilder, args, tableName);
}
public String handleParsingConf(String parsing, Map<String, Object> data,List<String> args){
// 值解析
// 解析 ${}类型的参数,直接替换
String pattern = "\\$\\{(?<field>(\\s|\\S)+?)}";
Pattern compile = Pattern.compile(pattern);
Matcher matcher = compile.matcher(parsing);
while (matcher.find()) {
parsing = parsing.replaceFirst(pattern, Util.null2String(data.get(matcher.group("field"))));
}
// 解析#{}类型的参数,替换为?并按照顺序收集args
pattern = "#\\{(?<field>(\\s|\\S)+?)}";
compile = Pattern.compile(pattern);
matcher = compile.matcher(parsing);
while (matcher.find()) {
parsing = parsing.replaceFirst(pattern, "?");
args.add(Util.null2String(data.get(matcher.group("field"))));
}
// 解析#sql{}类型的参数并执行SQL获取到SQL的值
pattern = "#sql\\{(?<sqlStr>([\\s\\S])+?)}";
compile = Pattern.compile(pattern);
matcher = compile.matcher(parsing);
while (matcher.find()) {
String sqlStr = matcher.group("sqlStr");
toolUtil.writeDebuggerLog(String.format("执行SQL {%s} ---> 参数: {%s}", sqlStr, args));
rs.executeQuery(sqlStr, args);
rs.next();
parsing = parsing.replaceFirst(pattern, Util.null2String(rs.getString(1)));;
}
return parsing;
}
/**
*
*
* @return
*/
private Map<String, Object> getPatentWallConf(String prefix) {
synchronized (this) {
if (this.patentWallConf == null) {
this.patentWallConf = Util.readProperties2Map("PatentWall", "aiyh." + prefix);
}
if (this.patentWallConf == null) {
return new HashMap<>(0);
}
return new HashMap<>(this.patentWallConf);
}
}
public void clearPatentWallConf() {
this.patentWallConf = null;
}
public List<Map<String, Object>> handleFilterWhere(List<FilterWhere> filterWheres, String tableName) {
StringBuilder whereBuilder = new StringBuilder(" where ");
List<String> args = new ArrayList<>();
for (FilterWhere filterWhere : filterWheres) {
whereBuilder.append(" add ");
if (filterWhere.getSearchType() == 1) {
// 等于
whereBuilder.append(filterWhere.getDbField())
.append(" = ? ");
args.add(filterWhere.getValue());
continue;
}
if (filterWhere.getSearchType() == 2) {
// 大于
whereBuilder.append(filterWhere.getDbField())
.append(" > ?");
args.add(filterWhere.getValue());
continue;
}
if (filterWhere.getSearchType() == 3) {
// 小于
whereBuilder.append(filterWhere.getDbField())
.append(" < ?");
args.add(filterWhere.getValue());
continue;
}
if (filterWhere.getSearchType() == 4) {
// in
whereBuilder.append(filterWhere.getDbField())
.append(" in ( ")
.append(filterWhere.getValue())
.append(") ");
continue;
}
if (filterWhere.getSearchType() == 5) {
// 日期大于
whereBuilder.append(" DATE_FORMAT(")
.append(filterWhere.getDbField())
.append(",'%y-%m-%d') > ")
.append("DATE_FORMAT(?,'%y-%m-%d')");
args.add(filterWhere.getValue());
continue;
}
if (filterWhere.getSearchType() == 6) {
// 日期小于
whereBuilder.append(" DATE_FORMAT(")
.append(filterWhere.getDbField())
.append(",'%y-%m-%d') < ")
.append("DATE_FORMAT(?,'%y-%m-%d')");
args.add(filterWhere.getValue());
continue;
}
if (filterWhere.getSearchType() == 7) {
// 日期等于
whereBuilder.append(" DATE_FORMAT(")
.append(filterWhere.getDbField())
.append(",'%y-%m-%d') = ")
.append("DATE_FORMAT(?,'%y-%m-%d')");
args.add(filterWhere.getValue());
continue;
}
if (filterWhere.getSearchType() == 8) {
// 日期范围
whereBuilder.append(" DATE_FORMAT(")
.append(filterWhere.getDbField())
.append(",'%y-%m-%d') between ")
.append("DATE_FORMAT(?,'%y-%m-%d')")
.append(" and DATE_FORMAT(?,'%y-%m-%d')");
args.add(filterWhere.getValue().split("&")[0]);
args.add(filterWhere.getValue().split("&")[1]);
continue;
}
}
return patentWallMapping.getListByFilterWhere(whereBuilder, args, tableName);
}
/**
*
*
* @return
*/
private Map<String, Object> getPatentWallConf(String prefix) {
synchronized (this) {
if (this.patentWallConf == null) {
this.patentWallConf = Util.readProperties2Map("PatentWall", "aiyh." + prefix);
}
if (this.patentWallConf == null) {
return new HashMap<>(0);
}
return new HashMap<>(this.patentWallConf);
}
}
public void clearPatentWallConf() {
this.patentWallConf = null;
}
/**
*
*
* @return
*/
private Map<String, Object> getPatentWallSearchConf(String prefix) {
synchronized (this) {
if (this.patentWallSearchConf == null) {
this.patentWallSearchConf = Util.readProperties2Map("PatentWall", "aiyh." + prefix);
}
if (this.patentWallSearchConf == null) {
return new HashMap<>(0);
}
return new HashMap<>(this.patentWallSearchConf);
}
}
public void clearPatentWallSerachConf() {
this.patentWallSearchConf = null;
}
/**
*
*
* @return
*/
private Map<String, Object> getPatentWallSearchConf(String prefix) {
synchronized (this) {
if (this.patentWallSearchConf == null) {
this.patentWallSearchConf = Util.readProperties2Map("PatentWall", "aiyh." + prefix);
}
if (this.patentWallSearchConf == null) {
return new HashMap<>(0);
}
return new HashMap<>(this.patentWallSearchConf);
}
}
public void clearPatentWallSerachConf() {
this.patentWallSearchConf = null;
}
}

File diff suppressed because it is too large Load Diff