From 7efbec98084827b0f6c41bc26b8130853fe04a68 Mon Sep 17 00:00:00 2001 From: IT-xiaoXiong <774495953@qq.com> Date: Thu, 9 Dec 2021 22:14:48 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- com/api/aiyh_guijiu.zip | Bin 12618 -> 0 bytes .../service/impl/FaDDContractService.java | 1662 ++++++++-------- .../fadada/service/impl/FaDDServiceImpl.java | 1128 ++++++----- .../fadada/web/FaDDContractController.java | 308 +-- .../aiyh_pcn/fadada/web/FaDDController.java | 468 ++--- .../patentWall/dao/PatentWallMapping.java | 61 +- .../patentWall/service/PatentWallService.java | 658 +++--- .../AddCustomer_Action.java | 1758 +++++++++-------- 8 files changed, 3077 insertions(+), 2966 deletions(-) delete mode 100644 com/api/aiyh_guijiu.zip diff --git a/com/api/aiyh_guijiu.zip b/com/api/aiyh_guijiu.zip deleted file mode 100644 index 2a7664b8fb5a4c25c1a2d098b896d22d493a88e7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12618 zcmaL719)9q_dOh=v2EM7ZQHhOHnwdWjcqly+oVyW#`>qXx8JY#-uL3y8lgl;Mg)rXTZCY zva>a{wlH#5vvagEwYGB;Hn5|$G;lRI)3mc&AI9*b@rl3+;4czV^2;g+$LY{Ag@gIr ztiI1o7b=rCnm8Ct$Z};YqVq!7yVSJ;WZfI;Din}6@BtY#1$w=mZL^M!No%UoCxmBa z^U}RYSj!Qo3M&f)*28V)Jm+oZk|S2>-B}*V+C&isCB;#4{VFq z>Kw1zh1WpTbzSBty9}>ZB-jfy=vq9+P>fpm+0C$-RTgZzZlKupdjoMe7`au&LFocd z0pvHrh^*FfG_qHn@$p8bG0E3BhC5i9Is6#MO+Ncr?fUiBgu(1Cgdz@2Ub4`Wspx3V zRs3ydGHZ0QFFUtgYHU893tP@+LcF^q3nod z(pIIq6Wl>{rvg>u!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-@_!YDj_LGvKJ6w6iH zw(2C5Lqx&fzC`H84U}|)Cj@;zG1Q_QvxP3F?N3pvLE{_sM<6%=`-&8Jjp!xTYw&ho zQQv?aBG~vk>Cu4Bx<$gm4>AIP9}}x<+m!P`7VvgB<7H2)V@^XkgJC}Oj=%2$HSc)A! z^ig!cC?P)7K4&ih9b^}oHsj@kisOsF#+>#H#EdrP-nguh8$kExw8je zrl{5*KcEq4zs(ReulupOaw8%Kf7@7h{eDWn1Vvt*eGlS1pvMAVvfvHn4T>-vcw?HB zJ|8iGcpe2iATZKa!6bVcj7;Qv@6Y3AYdv-{wL2e*8-R5lIvWaIpEGWypb}FfMwd0k zmloI9f)<9pdUae+D7_+wK2f)6buf0UEkW&+m60#qs=CB)`Xh z&f9^-*x1Fcc1(T2e=ii%%Kjx%~f#O10*_ zO!ya3|1G)y_WYA5i$6U7p1A)M;QxfwK>r0PgAU>TbIDDweK;)m2P6Q%e{+-HkUxWI zd|%=3iO8Q$BdV10UEkvqO9`^ zg*f`xtv~C)xmmxX{)zHmq5UUH{`=r(lJ$q|{u4kpD+`6>{kE5~A^(~iy%dh8e}?hD zq}FeMzqS;zU&8B8ulGYZlD2(9v{{M+llx0LtspJMG#P{7<@ lpw;>x{t5*Mjz`xc@8?{BzIS>70KmMzaNn~^RO+9j{|DBng2w;= diff --git a/com/api/aiyh_pcn/fadada/service/impl/FaDDContractService.java b/com/api/aiyh_pcn/fadada/service/impl/FaDDContractService.java index 73f586c..e65d67c 100644 --- a/com/api/aiyh_pcn/fadada/service/impl/FaDDContractService.java +++ b/com/api/aiyh_pcn/fadada/service/impl/FaDDContractService.java @@ -38,806 +38,902 @@ import java.util.zip.ZipOutputStream; * @author EBU7-dev1-ayh * @create 2021/11/3 0003 14:51 */ - - public class FaDDContractService { - private final ToolUtil toolUtil = new ToolUtil(); - private final String contractInfoTable = "uf_contract_info"; - private final FaDDContractMapping faDDContractMapping = new FaDDContractMapping(); + private final ToolUtil toolUtil = new ToolUtil(); + private final String contractInfoTable = "uf_contract_info"; + private final FaDDContractMapping faDDContractMapping = new FaDDContractMapping(); + /** + * 获取全版本的流程id,节点id + * + * @param workflowId + * @return + */ + public Map getAllVersion(String workflowId) { + String versionStringByWfid = WorkflowVersion.getVersionStringByWfid(workflowId); + String newWorkflowId = faDDContractMapping.getAllVersion(versionStringByWfid); + String allVersion = WorkflowVersion.getVersionStringByWfid(newWorkflowId); + if (allVersion == null) { + allVersion = ""; + } + String[] split = allVersion.split(","); + Map data = new HashMap<>(); + String[] nodes = this.getNodes(workflowId); + data.put("workflowIds", split); + data.put("nodeIds", nodes); + return data; + } - /** - * 获取全版本的流程id,节点id - * - * @param workflowId - * @return - */ - public Map getAllVersion(String workflowId) { - String versionStringByWfid = WorkflowVersion.getVersionStringByWfid(workflowId); - String newWorkflowId = faDDContractMapping.getAllVersion(versionStringByWfid); - String allVersion = WorkflowVersion.getVersionStringByWfid(newWorkflowId); - if (allVersion == null) { - allVersion = ""; - } - String[] split = allVersion.split(","); - Map data = new HashMap<>(); - String[] nodes = this.getNodes(workflowId); - data.put("workflowIds", split); - data.put("nodeIds", nodes); - return data; - } + /** + * 获取节点id + * + * @param workflowId + * @return + */ + public String[] getNodes(String workflowId) { + String versionStringByWfid = WorkflowVersion.getVersionStringByWfid(workflowId); + String nods = faDDContractMapping.getNodes(versionStringByWfid); + if (nods == null) { + nods = ""; + } + return nods.split(","); + } - /** - * 获取节点id - * - * @param workflowId - * @return - */ - public String[] getNodes(String workflowId) { - String versionStringByWfid = WorkflowVersion.getVersionStringByWfid(workflowId); - String nods = faDDContractMapping.getNodes(versionStringByWfid); - if (nods == null) { - nods = ""; - } - return nods.split(","); - } + /** + * 获取替换SQL的数据 + * + * @param requestId + * @param workflowId + * @param mainTableName + * @param tableName + * @return + */ + public List> getDataArr( + String requestId, String workflowId, String mainTableName, String tableName) { + Map mainMap = faDDContractMapping.queryMainMap(requestId, mainTableName); + String mainId = Util.null2String(mainMap.get("id")); + List> detailMaps = faDDContractMapping.queryDetailMaps(mainId, tableName); + return getDataArr(requestId, workflowId, tableName, mainMap, detailMaps); + } + public List> getDataArr( + String requestId, + String workflowId, + String mainTableName, + String tableName, + List> detailMaps) { + Map mainMap = faDDContractMapping.queryMainMap(requestId, mainTableName); + String mainId = Util.null2String(mainMap.get("id")); + return getDataArr(requestId, workflowId, tableName, mainMap, detailMaps); + } - /** - * 获取替换SQL的数据 - * - * @param requestId - * @param workflowId - * @param mainTableName - * @param tableName - * @return - */ - public List> getDataArr(String requestId, String workflowId, String mainTableName, String tableName) { - Map mainMap = faDDContractMapping.queryMainMap(requestId, mainTableName); - String mainId = Util.null2String(mainMap.get("id")); - List> detailMaps = faDDContractMapping.queryDetailMaps(mainId, tableName); - return getDataArr(requestId, workflowId, tableName, mainMap, detailMaps); - } + public List> getDataArr( + String requestId, + String workflowId, + String tableName, + Map mainMap, + List> detailMaps) { + List> dataArr = new ArrayList<>(); + String dt = tableName.substring(tableName.indexOf("_dt") + 3); + String main = "main."; + String detail = "detail_" + dt + "."; + for (Map detailMap : detailMaps) { + Map data = new HashMap<>(); + for (Map.Entry entry : mainMap.entrySet()) { + data.put(main + entry.getKey(), entry.getValue()); + } + for (Map.Entry entry : detailMap.entrySet()) { + data.put(detail + entry.getKey(), entry.getValue()); + } + data.put("requestId", requestId); + data.put("workflowId", workflowId); + dataArr.add(data); + } + return dataArr; + } - public List> getDataArr(String requestId, String workflowId, String mainTableName, String tableName, List> detailMaps) { - Map mainMap = faDDContractMapping.queryMainMap(requestId, mainTableName); - String mainId = Util.null2String(mainMap.get("id")); - return getDataArr(requestId, workflowId, tableName, mainMap, detailMaps); - } + /** + * 获取处理object和List类型后的参数 + * + * @param treeList + * @param dataArr + * @return + */ + public List> objectAndListHandle( + List treeList, List> dataArr) { + List> params = new ArrayList<>(); + for (Map dataMap : dataArr) { + Map param = new HashMap<>(); + for (ApiConfigDetailDTO apiConfigDetailDTO : treeList) { + Object value; + if (apiConfigDetailDTO.getParamType() == 3) { + Map map = new HashMap<>(); + // object类型 + for (ApiConfigDetailDTO child : apiConfigDetailDTO.getChildren()) { + if (child.getChildren() == null || child.getChildren().size() == 0) { + // handleChild(child.getChildren(), dataMap) + map.put(child.getParamName(), changeRuleHandle(child, dataMap)); + } else { + map.put(child.getParamName(), handleChild(child.getChildren(), dataMap)); + } + } + value = map; + } else if (apiConfigDetailDTO.getParamType() == 4) { + String sql = apiConfigDetailDTO.getArraySql(); + String parsingSq = aiyh.utils.Util.parsingSq(sql, dataMap); + // list类型 + if (parsingSq.contains("delete") + || parsingSq.contains("update") + || parsingSq.contains("exec") + || parsingSq.contains("drop") + || parsingSq.contains("truncate")) { + value = new ArrayList<>(); + } else { + RecordSet rs = new RecordSet(); + String replace = + parsingSq + .replace("select ", "select ") + .replaceAll(" and ", " and ") + .replaceAll(" or ", " or ") + .replaceAll(" join ", " join ") + .replaceAll(" in ", " in "); + rs.executeQuery(replace); + value = aiyh.utils.Util.recordeSet2Array(rs, String.class); + } + } else { + value = changeRuleHandle(apiConfigDetailDTO, dataMap); + } + param.put(apiConfigDetailDTO.getParamName(), value); + } + params.add(param); + } + return params; + } - public List> getDataArr(String requestId, String workflowId, String tableName, - Map mainMap, List> detailMaps) { - List> dataArr = new ArrayList<>(); - String dt = tableName.substring(tableName.indexOf("_dt") + 3); - String main = "main."; - String detail = "detail_" + dt + "."; - for (Map detailMap : detailMaps) { - Map data = new HashMap<>(); - for (Map.Entry entry : mainMap.entrySet()) { - data.put(main + entry.getKey(), entry.getValue()); - } - for (Map.Entry entry : detailMap.entrySet()) { - data.put(detail + entry.getKey(), entry.getValue()); - } - data.put("requestId", requestId); - data.put("workflowId", workflowId); - dataArr.add(data); - } - return dataArr; - } + /** + * 处理子类 + * + * @param children + * @param dataMap + * @return + */ + private Object handleChild(List children, Map dataMap) { + Map params = new HashMap<>(); + for (ApiConfigDetailDTO child : children) { + Object value; + if (child.getChildren() != null) { + value = handleChild(child.getChildren(), dataMap); + } else { + value = changeRuleHandle(child, dataMap); + } + params.put(child.getParamName(), value); + } + return params; + } - /** - * 获取处理object和List类型后的参数 - * - * @param treeList - * @param dataArr - * @return - */ - public List> objectAndListHandle(List treeList, List> dataArr) { - List> params = new ArrayList<>(); - for (Map dataMap : dataArr) { - Map param = new HashMap<>(); - for (ApiConfigDetailDTO apiConfigDetailDTO : treeList) { - Object value; - if (apiConfigDetailDTO.getParamType() == 3) { - Map map = new HashMap<>(); -// object类型 - for (ApiConfigDetailDTO child : apiConfigDetailDTO.getChildren()) { - if (child.getChildren() == null || child.getChildren().size() == 0) { -// handleChild(child.getChildren(), dataMap) - map.put(child.getParamName(), changeRuleHandle(child, dataMap)); - } else { - map.put(child.getParamName(), handleChild(child.getChildren(), dataMap)); - } - } - value = map; - } else if (apiConfigDetailDTO.getParamType() == 4) { - String sql = apiConfigDetailDTO.getArraySql(); - String parsingSq = aiyh.utils.Util.parsingSq(sql, dataMap); -// list类型 - if (parsingSq.contains("delete") || parsingSq.contains("update") || - parsingSq.contains("exec") || parsingSq.contains("drop") || - parsingSq.contains("truncate")) { - value = new ArrayList<>(); - } else { - RecordSet rs = new RecordSet(); - String replace = parsingSq.replace("select ", "select ") - .replaceAll(" and ", " and ") - .replaceAll(" or ", " or ") - .replaceAll(" join ", " join ") - .replaceAll(" in ", " in "); - rs.executeQuery(replace); - value = aiyh.utils.Util.recordeSet2Array(rs, String.class); - } - } else { - value = changeRuleHandle(apiConfigDetailDTO, dataMap); - } - param.put(apiConfigDetailDTO.getParamName(), value); - } - params.add(param); - } - return params; - } + /** + * 根据转换规则生成对应的参数值 + * + * @param apiConfigDetailDTO + * @param dataMap + * @return + */ + private Object changeRuleHandle( + ApiConfigDetailDTO apiConfigDetailDTO, Map dataMap) { + Object value; + String tableName; + String table; + String sql; + String resultSql; + // 判断参数的转换规则 + switch (apiConfigDetailDTO.getChangeRule()) { + case 0: + // 不转换 + case 2: + // 流程字段值 + table = apiConfigDetailDTO.getTablename(); + if (!table.contains("_dt")) { + // 表示字段属于主表 + tableName = "main"; + } else { + // 字段属于明细表 + String dt = table.substring(table.indexOf("_dt") + 3); + tableName = "detail_" + dt; + } + value = dataMap.get(tableName + "." + apiConfigDetailDTO.getWorkflowField()); + break; + case 1: + // 固定值 + value = apiConfigDetailDTO.getParamValue(); + break; + case 3: + // 系统日期 + value = aiyh.utils.Util.getTime("yyyy-MM-dd"); + break; + case 4: + // 系统时间 + value = aiyh.utils.Util.getTime("HH:mm:ss"); + break; + case 5: + // 系统日期-时间 + value = aiyh.utils.Util.getTime("yyyy-MM-dd HH:mm:ss"); + break; + case 6: + // 自定义SQL + case 7: + // 流程字段转SQL + sql = apiConfigDetailDTO.getParamValue(); + resultSql = aiyh.utils.Util.parsingSq(sql, dataMap); + if (resultSql.contains("delete ") + || resultSql.contains("update ") + || resultSql.contains("exec ") + || resultSql.contains("drop ") + || resultSql.contains("truncate ")) { + value = null; + } else { + RecordSet rs = new RecordSet(); + String replace = + resultSql + .replace("select ", "select ") + .replaceAll(" and ", " and ") + .replaceAll(" or ", " or ") + .replaceAll(" join ", " join ") + .replaceAll(" in ", " in "); + rs.executeQuery(replace); + rs.next(); + value = aiyh.utils.Util.null2String(rs.getString(1)); + } + break; + case 8: + // + // 流程名称 + value = aiyh.utils.Util.getWorkflowNameById(String.valueOf(dataMap.get("workflowid"))); + break; + case 9: + // + // 请求标题 + value = aiyh.utils.Util.getRequestTitleById(String.valueOf(dataMap.get("requestid"))); + break; + case 10: + // 流程requestId + value = dataMap.get("requestid"); + break; + default: + value = null; + break; + } + if (apiConfigDetailDTO.getParamType() == 1) { + // Integer + value = Integer.parseInt(String.valueOf(value)); + } else if (apiConfigDetailDTO.getParamType() == 2) { + // Boolean + value = Boolean.parseBoolean(String.valueOf(value)); + } + return value; + } - /** - * 处理子类 - * - * @param children - * @param dataMap - * @return - */ - private Object handleChild(List children, Map dataMap) { - Map params = new HashMap<>(); - for (ApiConfigDetailDTO child : children) { - Object value; - if (child.getChildren() != null) { - value = handleChild(child.getChildren(), dataMap); - } else { - value = changeRuleHandle(child, dataMap); - } - params.put(child.getParamName(), value); - } - return params; - } + /** + * 合同签署回调逻辑处理 + * + * @param contractNo + */ + public void signedCallBack(String contractNo) { + // 查询合同信息表中的数据 + UfContractInfoDTO ufContractInfoDTO = faDDContractMapping.queryContractInfo(contractNo); + toolUtil.writeDebuggerLog("回调,获取到合同信息参数:" + JSON.toJSONString(ufContractInfoDTO)); + Map update = new HashMap<>(); + if (ufContractInfoDTO.getQueueSigned() == 1) { + // 属于顺序签署合同,更新单份合同已签蜀几个文件 + update.put("single_signed_num", ufContractInfoDTO.getSingleSignedNum() + 1); + toolUtil.writeDebuggerLog("单份合同签署成功"); + // 如果单份合同签署数量等于合同文件数量,表示已经签署完成 + if (ufContractInfoDTO.getSingleSignedNum() + 1 + == ufContractInfoDTO.getSingleContractFileNum()) { + toolUtil.writeDebuggerLog("单份合同全部签署成功"); + update.put("signed_num", ufContractInfoDTO.getSignedNum() + 1); + // 查询下一位合同方并发起签署 + if (ufContractInfoDTO.getSignedNum() + 1 < ufContractInfoDTO.getShouldSignedNum()) { + toolUtil.writeDebuggerLog( + "应签署合同比签署合同数量多,需要再次签署!" + (ufContractInfoDTO.getSignedNum() + 1)); + update.put("single_signed_num", 0); + nextContractSigned(ufContractInfoDTO); + } + } + // 如果合同已签数量和应签数量相同,则状态为本方待签 + if (ufContractInfoDTO.getSignedNum() + 1 == ufContractInfoDTO.getShouldSignedNum()) { + update.put("contract_status", 3); + // 判断是否控制签署规则 1-仅本方签署,2-仅对方签署,3-都签署 + if ("1".equals(Util.null2String(ufContractInfoDTO.getSignedType()))) { + update.put("contract_status", 4); + } + if ("2".equals(Util.null2String(ufContractInfoDTO.getSignedType()))) { + update.put("contract_status", 4); + // 仅对方签署完成后,添加用户信息 + // 获取配置表信息 + FaDaDaConfigDTO faDaDaConfigDTO = + faDDContractMapping.queryConfig( + String.valueOf(ufContractInfoDTO.getWorkflowType()), 4); + RecordSet rs = new RecordSet(); + String userInfo = ufContractInfoDTO.getUserInfo(); + User user = JSON.parseObject(userInfo, new TypeReference() {}); + // 获取流程中的合同字段的文档目录id + rs.executeQuery( + "select formid from workflow_base where id = ?", ufContractInfoDTO.getWorkflowType()); + String formId = Util.recordeSet2Entity(rs, String.class); + String query = + "select doccategory from workflow_fileupload where fieldid = (select id from workflow_billfield where fieldname = ? and billid = ?)"; + rs.executeQuery(query, faDaDaConfigDTO.getContractDoc(), formId); + String docCategorys = Util.null2String(Util.recordeSet2Entity(rs, String.class)); + if (StringUtils.isNullOrEmpty(docCategorys)) { + query = "select doccategory from workflow_base where id = ?"; + rs.executeQuery(query, ufContractInfoDTO.getWorkflowType()); + rs.next(); + docCategorys = Util.null2String(rs.getString(1)); + } + if (StringUtils.isNullOrEmpty(docCategorys)) { + docCategorys = ",,1"; + } + // String[] docSplit = docCategorys.split(","); + // String category = docSplit[docSplit.length - 1]; + // 下载合同到文件服务器中 + String docIds = ""; + try { + docIds = downloadContract2FileSystem(ufContractInfoDTO, docCategorys, user); + } catch (Exception e) { + toolUtil.writeErrorLog("创建文档发生错误:" + e); + } + toolUtil.writeDebuggerLog("生成的文档的id:" + docIds); + // 将id保存到流程字段中 + PrepSqlResultImpl sqlResult = + Util.createSqlBuilder() + .updateSql( + ufContractInfoDTO.getWorkflowMainTable(), + ParaMap.create().put(faDaDaConfigDTO.getContractDoc(), docIds), + Util.createPrepWhereImpl() + .whereAnd("id") + .whereEqual(ufContractInfoDTO.getMainId())); + toolUtil.writeDebuggerLog(sqlResult.getSqlStr() + ",参数:" + sqlResult.getArgs()); + rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs()); + } + } + } else { + // 全部合同一起发送的签署信息 + // 直接合同已签署+1 + update.put("signed_num", ufContractInfoDTO.getSignedNum() + 1); + // 如果已签文件数等于需要签署的合同数乘以合同文件数相等,则代表对方已经签署完毕 + if (ufContractInfoDTO.getSignedNum() + 1 + == ufContractInfoDTO.getShouldSignedNum() + * ufContractInfoDTO.getSingleContractFileNum()) { + update.put("contract_status", 3); + // 判断是否控制签署规则 1-仅本方签署,2-仅对方签署,3-都签署 + if ("1".equals(Util.null2String(ufContractInfoDTO.getSignedType()))) { + update.put("contract_status", 4); + } + if ("2".equals(Util.null2String(ufContractInfoDTO.getSignedType()))) { + update.put("contract_status", 4); + // 仅对方签署完成后,添加用户信息 + // 获取配置表信息 + FaDaDaConfigDTO faDaDaConfigDTO = + faDDContractMapping.queryConfig( + String.valueOf(ufContractInfoDTO.getWorkflowType()), 4); + RecordSet rs = new RecordSet(); + String userInfo = ufContractInfoDTO.getUserInfo(); + User user = JSON.parseObject(userInfo, new TypeReference() {}); + // 获取流程中的合同字段的文档目录id + rs.executeQuery( + "select formid from workflow_base where id = ?", ufContractInfoDTO.getWorkflowType()); + String formId = Util.recordeSet2Entity(rs, String.class); + String query = + "select doccategory from workflow_fileupload where fieldid = (select id from workflow_billfield where fieldname = ? and billid = ?)"; + rs.executeQuery(query, faDaDaConfigDTO.getContractDoc(), formId); + String docCategorys = Util.null2String(Util.recordeSet2Entity(rs, String.class)); + if (StringUtils.isNullOrEmpty(docCategorys)) { + query = "select doccategory from workflow_base where id = ?"; + rs.executeQuery(query, ufContractInfoDTO.getWorkflowType()); + rs.next(); + docCategorys = Util.null2String(rs.getString(1)); + } + if (StringUtils.isNullOrEmpty(docCategorys)) { + docCategorys = ",,1"; + } + // String[] docSplit = docCategorys.split(","); + // String category = docSplit[docSplit.length - 1]; + // 下载合同到文件服务器中 + String docIds = ""; + try { + docIds = downloadContract2FileSystem(ufContractInfoDTO, docCategorys, user); + } catch (Exception e) { + toolUtil.writeErrorLog("创建文档发生错误:" + e); + } + toolUtil.writeDebuggerLog("生成的文档的id:" + docIds); + // 将id保存到流程字段中 + PrepSqlResultImpl sqlResult = + Util.createSqlBuilder() + .updateSql( + ufContractInfoDTO.getWorkflowMainTable(), + ParaMap.create().put(faDaDaConfigDTO.getContractDoc(), docIds), + Util.createPrepWhereImpl() + .whereAnd("id") + .whereEqual(ufContractInfoDTO.getMainId())); + toolUtil.writeDebuggerLog(sqlResult.getSqlStr() + ",参数:" + sqlResult.getArgs()); + rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs()); + } + } + } - /** - * 根据转换规则生成对应的参数值 - * - * @param apiConfigDetailDTO - * @param dataMap - * @return - */ - private Object changeRuleHandle(ApiConfigDetailDTO apiConfigDetailDTO, Map dataMap) { - Object value; - String tableName; - String table; - String sql; - String resultSql; -// 判断参数的转换规则 - switch (apiConfigDetailDTO.getChangeRule()) { - case 0: -// 不转换 - case 2: -// 流程字段值 - table = apiConfigDetailDTO.getTablename(); - if (!table.contains("_dt")) { -// 表示字段属于主表 - tableName = "main"; - } else { -// 字段属于明细表 - String dt = table.substring(table.indexOf("_dt") + 3); - tableName = "detail_" + dt; - } - value = dataMap.get(tableName + "." + apiConfigDetailDTO.getWorkflowField()); - break; - case 1: -// 固定值 - value = apiConfigDetailDTO.getParamValue(); - break; - case 3: -// 系统日期 - value = aiyh.utils.Util.getTime("yyyy-MM-dd"); - break; - case 4: -// 系统时间 - value = aiyh.utils.Util.getTime("HH:mm:ss"); - break; - case 5: -// 系统日期-时间 - value = aiyh.utils.Util.getTime("yyyy-MM-dd HH:mm:ss"); - break; - case 6: -// 自定义SQL - case 7: -// 流程字段转SQL - sql = apiConfigDetailDTO.getParamValue(); - resultSql = aiyh.utils.Util.parsingSq(sql, dataMap); - if (resultSql.contains("delete ") || resultSql.contains("update ") || - resultSql.contains("exec ") || resultSql.contains("drop ") || - resultSql.contains("truncate ")) { - value = null; - } else { - RecordSet rs = new RecordSet(); - String replace = resultSql.replace("select ", "select ") - .replaceAll(" and ", " and ") - .replaceAll(" or ", " or ") - .replaceAll(" join ", " join ") - .replaceAll(" in ", " in "); - rs.executeQuery(replace); - rs.next(); - value = aiyh.utils.Util.null2String(rs.getString(1)); - } - break; - case 8: -// -// 流程名称 - value = aiyh.utils.Util.getWorkflowNameById(String.valueOf(dataMap.get("workflowid"))); - break; - case 9: -// -// 请求标题 - value = aiyh.utils.Util.getRequestTitleById(String.valueOf(dataMap.get("requestid"))); - break; - case 10: -// 流程requestId - value = dataMap.get("requestid"); - break; - default: - value = null; - break; - } - if (apiConfigDetailDTO.getParamType() == 1) { -// Integer - value = Integer.parseInt(String.valueOf(value)); - } else if (apiConfigDetailDTO.getParamType() == 2) { -// Boolean - value = Boolean.parseBoolean(String.valueOf(value)); - } - return value; - } + // 更新状态 + PrepSqlResultImpl sqlResult = + Util.createSqlBuilder() + .updateSql( + "uf_contract_info", + update, + Util.createPrepWhereImpl().whereAnd("id").whereEqual(ufContractInfoDTO.getId())); + RecordSet rs = new RecordSet(); + toolUtil.writeDebuggerLog( + String.format( + "合同签署回调,更新合同状态,更新语句{%s},更新参数{%s}", sqlResult.getSqlStr(), sqlResult.getArgs())); + rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs()); + // 查询合同状态,更新明细表 + /* Map data = new HashMap<>(); + data.put("contractNo","6a265befb3944d93a7a8b32b8d5ca33d"); + Map faResult = null; + try { + faResult = FaDDRequestUtils.queryDetailContractStatus(data); + String code = Util.null2String(faResult.get("code")); + if(!"200".equals(code)){ + throw new RuntimeException("查询合同失败,失败原因:" + faResult); + } + Map resultData = (Map) faResult.get("data"); + List> contractSignerList = (List>) resultData.get("contractSignerList"); + for (Map signer : contractSignerList) { + if("-1".equals(signer.get("isSender"))){ + continue; + } + String customerId = Util.null2String(signer.get("customerId")); + String signStatus = Util.null2String(signer.get("signStatus")); + if(!"1".equals(signStatus)){ + continue; + } + // 更新数据库 + update.clear(); + update.put("signed_status",2); + // 查询明细表id + } + } catch (JsonProcessingException e) { + e.printStackTrace(); + toolUtil.writeErrorLog("查询合同失败,失败原因:" + e); + }*/ + } - /** - * 合同签署回调逻辑处理 - * - * @param contractNo - */ - public void signedCallBack(String contractNo) { -// 查询合同信息表中的数据 - UfContractInfoDTO ufContractInfoDTO = faDDContractMapping.queryContractInfo(contractNo); - toolUtil.writeDebuggerLog("回调,获取到合同信息参数:" + JSON.toJSONString(ufContractInfoDTO)); - Map update = new HashMap<>(); - if (ufContractInfoDTO.getQueueSigned() == 1) { -// 属于顺序签署合同,更新单份合同已签蜀几个文件 - update.put("single_signed_num", ufContractInfoDTO.getSingleSignedNum() + 1); - toolUtil.writeDebuggerLog("单份合同签署成功"); -// 如果单份合同签署数量等于合同文件数量,表示已经签署完成 - if (ufContractInfoDTO.getSingleSignedNum() + 1 == ufContractInfoDTO.getSingleContractFileNum()) { - toolUtil.writeDebuggerLog("单份合同全部签署成功"); - update.put("signed_num", ufContractInfoDTO.getSignedNum() + 1); -// 查询下一位合同方并发起签署 - if (ufContractInfoDTO.getSignedNum() + 1 < ufContractInfoDTO.getShouldSignedNum()) { - toolUtil.writeDebuggerLog("应签署合同比签署合同数量多,需要再次签署!" + (ufContractInfoDTO.getSignedNum() + 1)); - update.put("single_signed_num", 0); - nextContractSigned(ufContractInfoDTO); - } - } -// 如果合同已签数量和应签数量相同,则状态为本方待签 - if (ufContractInfoDTO.getSignedNum() + 1 == ufContractInfoDTO.getShouldSignedNum()) { - update.put("contract_status", 3); - // 判断是否控制签署规则 1-仅本方签署,2-仅对方签署,3-都签署 - if ("1".equals(Util.null2String(ufContractInfoDTO.getSignedType()))) { - update.put("contract_status", 4); - } - if ("2".equals(Util.null2String(ufContractInfoDTO.getSignedType()))) { - update.put("contract_status", 4); -// 仅对方签署完成后,添加用户信息 - // 获取配置表信息 - FaDaDaConfigDTO faDaDaConfigDTO = faDDContractMapping.queryConfig(String.valueOf(ufContractInfoDTO.getWorkflowType()), 4); - RecordSet rs = new RecordSet(); - String userInfo = ufContractInfoDTO.getUserInfo(); - User user = JSON.parseObject(userInfo, new TypeReference() { - }); - // 获取流程中的合同字段的文档目录id - rs.executeQuery("select formid from workflow_base where id = ?", ufContractInfoDTO.getWorkflowType()); - String formId = Util.recordeSet2Entity(rs, String.class); - String query = "select doccategory from workflow_fileupload where fieldid = (select id from workflow_billfield where fieldname = ? and billid = ?)"; - rs.executeQuery(query, faDaDaConfigDTO.getContractDoc(), formId); - String docCategorys = Util.null2String(Util.recordeSet2Entity(rs, String.class)); - if (StringUtils.isNullOrEmpty(docCategorys)) { - query = "select doccategory from workflow_base where id = ?"; - rs.executeQuery(query, ufContractInfoDTO.getWorkflowType()); - rs.next(); - docCategorys = Util.null2String(rs.getString(1)); - } - if (StringUtils.isNullOrEmpty(docCategorys)) { - docCategorys = ",,1"; - } -// String[] docSplit = docCategorys.split(","); -// String category = docSplit[docSplit.length - 1]; -// 下载合同到文件服务器中 - String docIds = ""; - try { - docIds = downloadContract2FileSystem(ufContractInfoDTO, docCategorys, user); - } catch (Exception e) { - toolUtil.writeErrorLog("创建文档发生错误:" + e); - } - toolUtil.writeDebuggerLog("生成的文档的id:" + docIds); -// 将id保存到流程字段中 - PrepSqlResultImpl sqlResult = Util.createSqlBuilder().updateSql(ufContractInfoDTO.getWorkflowMainTable(), - ParaMap.create().put(faDaDaConfigDTO.getContractDoc(), docIds), - Util.createPrepWhereImpl().whereAnd("id").whereEqual(ufContractInfoDTO.getMainId())); - toolUtil.writeDebuggerLog(sqlResult.getSqlStr() + ",参数:" + sqlResult.getArgs()); - rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs()); + /** + * 查询下一个合同方并发起合同签署 + * + * @param ufContractInfoDTO + */ + private void nextContractSigned(UfContractInfoDTO ufContractInfoDTO) { + String query = + "select * from " + + ufContractInfoDTO.getWorkflowDetailTable() + + " where mainid = ? and signed_status is null"; + RecordSet rs = new RecordSet(); + rs.executeQuery(query, ufContractInfoDTO.getMainId()); + List> detailMaps = Util.recordSet2MapList(rs); + toolUtil.writeDebuggerLog("查询到明细数据:" + JSON.toJSONString(detailMaps)); + query = "select * from " + ufContractInfoDTO.getWorkflowMainTable() + " where requestid = ?"; + RecordSet rs1 = new RecordSet(); + rs1.executeQuery(query, ufContractInfoDTO.getWorkflowRequestId()); + Map mainMap = Util.recordSet2Map(rs1); + if (mainMap == null) { + toolUtil.writeErrorLog("mainMap 查询到null -------> " + JSON.toJSONString(ufContractInfoDTO)); + throw new RuntimeException("mainMap查询到null!"); + } + // 获取配置表信息 + FaDaDaConfigDTO faDaDaConfigDTO = + faDDContractMapping.queryConfig(String.valueOf(ufContractInfoDTO.getWorkflowType()), 3); + // 查询接口配置树形结构 + ApiConfigMainDTO apiConfigMainDTO = Util.queryApiConfigTree(faDaDaConfigDTO.getParamsConfig()); + // 查询签署数据 + List> dataArr = + getDataArr( + ufContractInfoDTO.getWorkflowRequestId(), + String.valueOf(ufContractInfoDTO.getWorkflowType()), + ufContractInfoDTO.getWorkflowMainTable(), + ufContractInfoDTO.getWorkflowDetailTable(), + detailMaps); + // 处理数据 + List> maps = objectAndListHandle(apiConfigMainDTO.getDetails(), dataArr); + if (maps == null) { + toolUtil.writeDebuggerLog("service签署合同错误,错误原因:maps为null!"); + throw new RuntimeException("service签署合同错误,错误原因:maps为null!"); + } + if (maps.size() == 0 || maps.size() <= 1) { + return; + } + Map updateData = new HashMap<>(); + Map map = maps.get(1); + // 如果进行控制签署规则 + if (faDaDaConfigDTO.getSignedType() == 1) { + if (Integer.parseInt(Util.null2String(mainMap.get(faDaDaConfigDTO.getFieldControl1()))) + == faDaDaConfigDTO.getOnlyOther()) { + // 仅对方签署 + if (maps.size() == 1) { + // map.put("signType", 1); + // 如果是最后一个人了,就直接归档 + map.put("autoArchive", 1); + } + } + } + /* if (faDaDaConfigDTO.getSignedType() == 1) { + // 需要控制签署规则 + if (Integer.parseInt(Util.null2String(mainMap.get(faDaDaConfigDTO.getFieldControl1()))) == faDaDaConfigDTO.getOnlyOther()) { + // 只需要对方签署 + map.put("autoArchive", 1); + } + // 双方签署 + }*/ + // 签署下一次 + toolUtil.writeDebuggerLog("下一个供应商签署合同,签署数据:" + JSON.toJSONString(map)); + signedRequest(map, apiConfigMainDTO); + // 将合同签署信息更新到合同信息表中 + updateData.put("single_signed_num", 0); + PrepSqlResultImpl sqlResult = + Util.createSqlBuilder() + .updateSql( + contractInfoTable, + updateData, + Util.createPrepWhereImpl() + .whereAnd("workflow_request_id") + .whereEqual(ufContractInfoDTO.getWorkflowRequestId())); + rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs()); + updateData.clear(); + // 更新明细表合同信息 明细表添加字段,signed_status(合同方签署状态) + // 签署状态,1 已发送待签署,2 已签蜀 + updateData.put("signed_status", 1); + sqlResult = + Util.createSqlBuilder() + .updateSql( + ufContractInfoDTO.getWorkflowDetailTable(), + updateData, + Util.createPrepWhereImpl() + .whereAnd("id") + .whereEqual(String.valueOf(map.get("id")))); + rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs()); + } - } - } - } else { -// 全部合同一起发送的签署信息 -// 直接合同已签署+1 - update.put("signed_num", ufContractInfoDTO.getSignedNum() + 1); -// 如果已签文件数等于需要签署的合同数乘以合同文件数相等,则代表对方已经签署完毕 - if (ufContractInfoDTO.getSignedNum() + 1 == ufContractInfoDTO.getShouldSignedNum() * ufContractInfoDTO.getSingleContractFileNum()) { - update.put("contract_status", 3); - // 判断是否控制签署规则 1-仅本方签署,2-仅对方签署,3-都签署 - if ("1".equals(Util.null2String(ufContractInfoDTO.getSignedType()))) { - update.put("contract_status", 4); - } - if ("2".equals(Util.null2String(ufContractInfoDTO.getSignedType()))) { - update.put("contract_status", 4); - // 仅对方签署完成后,添加用户信息 - // 获取配置表信息 - FaDaDaConfigDTO faDaDaConfigDTO = faDDContractMapping.queryConfig(String.valueOf(ufContractInfoDTO.getWorkflowType()), 4); - RecordSet rs = new RecordSet(); - String userInfo = ufContractInfoDTO.getUserInfo(); - User user = JSON.parseObject(userInfo, new TypeReference() { - }); - // 获取流程中的合同字段的文档目录id - rs.executeQuery("select formid from workflow_base where id = ?", ufContractInfoDTO.getWorkflowType()); - String formId = Util.recordeSet2Entity(rs, String.class); - String query = "select doccategory from workflow_fileupload where fieldid = (select id from workflow_billfield where fieldname = ? and billid = ?)"; - rs.executeQuery(query, faDaDaConfigDTO.getContractDoc(), formId); - String docCategorys = Util.null2String(Util.recordeSet2Entity(rs, String.class)); - if (StringUtils.isNullOrEmpty(docCategorys)) { - query = "select doccategory from workflow_base where id = ?"; - rs.executeQuery(query, ufContractInfoDTO.getWorkflowType()); - rs.next(); - docCategorys = Util.null2String(rs.getString(1)); - } - if (StringUtils.isNullOrEmpty(docCategorys)) { - docCategorys = ",,1"; - } -// String[] docSplit = docCategorys.split(","); -// String category = docSplit[docSplit.length - 1]; -// 下载合同到文件服务器中 - String docIds = ""; - try { - docIds = downloadContract2FileSystem(ufContractInfoDTO, docCategorys, user); - } catch (Exception e) { - toolUtil.writeErrorLog("创建文档发生错误:" + e); - } - toolUtil.writeDebuggerLog("生成的文档的id:" + docIds); -// 将id保存到流程字段中 - PrepSqlResultImpl sqlResult = Util.createSqlBuilder().updateSql(ufContractInfoDTO.getWorkflowMainTable(), - ParaMap.create().put(faDaDaConfigDTO.getContractDoc(), docIds), - Util.createPrepWhereImpl().whereAnd("id").whereEqual(ufContractInfoDTO.getMainId())); - toolUtil.writeDebuggerLog(sqlResult.getSqlStr() + ",参数:" + sqlResult.getArgs()); - rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs()); - } - } - } + /** + * 合同签署发送请求 + * + * @param map + * @param apiConfigMainDTO + */ + private void signedRequest(Map map, ApiConfigMainDTO apiConfigMainDTO) { + String contractNos = Util.null2String(map.get("contractNo")); + String[] split = contractNos.split(","); + // RecordSet rs = new RecordSet(); + for (String s : split) { + map.put("contractNo", s); + ResponeVo responeVo = FaDDRequestUtils.signedContract(map, apiConfigMainDTO.getApiUrl()); + Map response = null; + try { + response = responeVo.getEntityMap(); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + if (!"200".equals(response.get("code"))) { + toolUtil.writeDebuggerLog("法大大接口签署合同失败!"); + throw new RuntimeException("法大大接口签署合同失败!"); + } + } + } -// 更新状态 - PrepSqlResultImpl sqlResult = Util.createSqlBuilder().updateSql("uf_contract_info", update, - Util.createPrepWhereImpl().whereAnd("id").whereEqual(ufContractInfoDTO.getId())); - RecordSet rs = new RecordSet(); - toolUtil.writeDebuggerLog(String.format("合同签署回调,更新合同状态,更新语句{%s},更新参数{%s}", sqlResult.getSqlStr(), sqlResult.getArgs())); - rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs()); -// 查询合同状态,更新明细表 - /* Map data = new HashMap<>(); - data.put("contractNo","6a265befb3944d93a7a8b32b8d5ca33d"); - Map faResult = null; - try { - faResult = FaDDRequestUtils.queryDetailContractStatus(data); - String code = Util.null2String(faResult.get("code")); - if(!"200".equals(code)){ - throw new RuntimeException("查询合同失败,失败原因:" + faResult); - } - Map resultData = (Map) faResult.get("data"); - List> contractSignerList = (List>) resultData.get("contractSignerList"); - for (Map signer : contractSignerList) { - if("-1".equals(signer.get("isSender"))){ - continue; - } - String customerId = Util.null2String(signer.get("customerId")); - String signStatus = Util.null2String(signer.get("signStatus")); - if(!"1".equals(signStatus)){ - continue; - } -// 更新数据库 - update.clear(); - update.put("signed_status",2); -// 查询明细表id - } - } catch (JsonProcessingException e) { - e.printStackTrace(); - toolUtil.writeErrorLog("查询合同失败,失败原因:" + e); - }*/ - } + /** + * 查询合同的状态信息 + * + * @param requestId + * @return + */ + public Map querySignedStatus(String requestId) { + // 查询合同状态 + String query = "select * from " + contractInfoTable + " where workflow_request_id = ?"; + RecordSet rs = new RecordSet(); + rs.executeQuery(query, requestId); + Map result = Util.recordSet2Map(rs); + this.toolUtil.writeDebuggerLog(result.toString()); + boolean isAllSinged = false; + boolean isSingedOneself = false; + if (result == null) { + toolUtil.writeDebuggerLog("查询到状态为null;sql:" + query + " ---> " + requestId); + return ParaMap.create().put("isAllSinged", false).put("isSingedOneself", false); + } + // 等待对方签署 + /* if("2".equals(result.get("contract_status"))){ + isAllSinged = false; + }*/ + // 等待我方签署 + if ("3".equals(Util.null2String(result.get("contract_status")))) { + isAllSinged = true; + } + // 签署完毕 + if ("4".equals(Util.null2String(result.get("contract_status")))) { + isAllSinged = true; + isSingedOneself = true; + } + return ParaMap.create().put("isAllSinged", isAllSinged).put("isSingedOneself", isSingedOneself); + } - /** - * 查询下一个合同方并发起合同签署 - * - * @param ufContractInfoDTO - */ - private void nextContractSigned(UfContractInfoDTO ufContractInfoDTO) { - String query = "select * from " + ufContractInfoDTO.getWorkflowDetailTable() + " where mainid = ? and signed_status is null"; - RecordSet rs = new RecordSet(); - rs.executeQuery(query, ufContractInfoDTO.getMainId()); - List> detailMaps = Util.recordSet2MapList(rs); - toolUtil.writeDebuggerLog("查询到明细数据:" + JSON.toJSONString(detailMaps)); - query = "select * from " + ufContractInfoDTO.getWorkflowMainTable() + " where requestid = ?"; - RecordSet rs1 = new RecordSet(); - rs1.executeQuery(query, ufContractInfoDTO.getWorkflowRequestId()); - Map mainMap = Util.recordSet2Map(rs1); - if (mainMap == null) { - toolUtil.writeErrorLog("mainMap 查询到null -------> " + JSON.toJSONString(ufContractInfoDTO)); - throw new RuntimeException("mainMap查询到null!"); - } -// 获取配置表信息 - FaDaDaConfigDTO faDaDaConfigDTO = faDDContractMapping.queryConfig(String.valueOf(ufContractInfoDTO.getWorkflowType()), 3); -// 查询接口配置树形结构 - ApiConfigMainDTO apiConfigMainDTO = Util.queryApiConfigTree(faDaDaConfigDTO.getParamsConfig()); - // 查询签署数据 - List> dataArr = getDataArr(ufContractInfoDTO.getWorkflowRequestId(), - String.valueOf(ufContractInfoDTO.getWorkflowType()), ufContractInfoDTO.getWorkflowMainTable(), - ufContractInfoDTO.getWorkflowDetailTable(), detailMaps); -// 处理数据 - List> maps = objectAndListHandle(apiConfigMainDTO.getDetails(), dataArr); - if (maps == null) { - toolUtil.writeDebuggerLog("service签署合同错误,错误原因:maps为null!"); - throw new RuntimeException("service签署合同错误,错误原因:maps为null!"); - } - if (maps.size() == 0 || maps.size() <= 1) { - return; - } - Map updateData = new HashMap<>(); - Map map = maps.get(1); -// 如果进行控制签署规则 - if (faDaDaConfigDTO.getSignedType() == 1) { - if (Integer.parseInt(Util.null2String(mainMap.get(faDaDaConfigDTO.getFieldControl1()))) == faDaDaConfigDTO.getOnlyOther()) { -// 仅对方签署 - if (maps.size() == 1) { -// map.put("signType", 1); -// 如果是最后一个人了,就直接归档 - map.put("autoArchive", 1); - } - } - } -/* if (faDaDaConfigDTO.getSignedType() == 1) { -// 需要控制签署规则 - if (Integer.parseInt(Util.null2String(mainMap.get(faDaDaConfigDTO.getFieldControl1()))) == faDaDaConfigDTO.getOnlyOther()) { -// 只需要对方签署 - map.put("autoArchive", 1); - } -// 双方签署 - }*/ -// 签署下一次 - toolUtil.writeDebuggerLog("下一个供应商签署合同,签署数据:" + JSON.toJSONString(map)); - signedRequest(map, apiConfigMainDTO); -// 将合同签署信息更新到合同信息表中 - updateData.put("single_signed_num", 0); - PrepSqlResultImpl sqlResult = Util.createSqlBuilder().updateSql(contractInfoTable, updateData, - Util.createPrepWhereImpl().whereAnd("workflow_request_id").whereEqual(ufContractInfoDTO.getWorkflowRequestId())); - rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs()); - updateData.clear(); -// 更新明细表合同信息 明细表添加字段,signed_status(合同方签署状态) -// 签署状态,1 已发送待签署,2 已签蜀 - updateData.put("signed_status", 1); - sqlResult = Util.createSqlBuilder().updateSql(ufContractInfoDTO.getWorkflowDetailTable(), updateData, - Util.createPrepWhereImpl().whereAnd("id").whereEqual(String.valueOf(map.get("id")))); - rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs()); - } + public void signedContractOwn(String requestId, User user) { + // 查询合同信息 + UfContractInfoDTO ufContractInfoDTO = + faDDContractMapping.queryContractInfoByRequestId(requestId); + // 获取配置表信息 + FaDaDaConfigDTO faDaDaConfigDTO = + faDDContractMapping.queryConfig(String.valueOf(ufContractInfoDTO.getWorkflowType()), 4); + // 查询接口配置树形结构 + ApiConfigMainDTO apiConfigMainDTO = Util.queryApiConfigTree(faDaDaConfigDTO.getParamsConfig()); + // 查询签署数据 + List> dataArr = + getDataArr( + ufContractInfoDTO.getWorkflowRequestId(), + String.valueOf(ufContractInfoDTO.getWorkflowType()), + ufContractInfoDTO.getWorkflowMainTable(), + ufContractInfoDTO.getWorkflowDetailTable()); + // 处理数据 + List> maps = objectAndListHandle(apiConfigMainDTO.getDetails(), dataArr); + if (maps == null) { + toolUtil.writeErrorLog("service签署合同错误,错误原因:maps为null!"); + throw new RuntimeException("service签署合同错误,错误原因:maps为null!"); + } + if (maps.size() == 0) { + return; + } + Map data = maps.get(0); + String contractNos = String.valueOf(data.get("contractNo")); + String[] split = contractNos.split(","); + List downloadUrlList = new ArrayList<>(); + List viewUrlList = new ArrayList<>(); + for (String s : split) { + data.put("contractNo", s); + ResponeVo responeVo = FaDDRequestUtils.signedContract(data, apiConfigMainDTO.getApiUrl()); + Map response = null; + try { + response = responeVo.getEntityMap(); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + if (!"200".equals(response.get("code"))) { + this.toolUtil.writeErrorLog("签署参数:" + responeVo.getEntityString()); + throw new RuntimeException("本方签署失败!法大大请求接口错误!"); + } else { + Map result = (Map) response.get("data"); + downloadUrlList.add(Util.null2String(result.get("downloadUrl"))); + viewUrlList.add(Util.null2String(result.get("viewUrl"))); + } + } + // 更新合同状态 + RecordSet rs = new RecordSet(); + Map update = new HashMap<>(); + update.put("contract_status", 4); + update.put("contract_view_url", String.join(";", viewUrlList)); + update.put("contract_down_url", String.join(";", downloadUrlList)); + PrepSqlResultImpl sqlResult = + Util.createSqlBuilder() + .updateSql( + contractInfoTable, + update, + Util.createPrepWhereImpl().whereAnd("workflow_request_id").whereEqual(requestId)); + toolUtil.writeDebuggerLog(sqlResult.getSqlStr() + ",参数:" + sqlResult.getArgs()); + rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs()); + // 获取流程中的合同字段的文档目录id + rs.executeQuery( + "select formid from workflow_base where id = ?", ufContractInfoDTO.getWorkflowType()); + String formId = Util.recordeSet2Entity(rs, String.class); + String query = + "select doccategory from workflow_fileupload where fieldid = (select id from workflow_billfield where fieldname = ? and billid = ?)"; + rs.executeQuery(query, faDaDaConfigDTO.getContractDoc(), formId); + String docCategorys = Util.null2String(Util.recordeSet2Entity(rs, String.class)); + if (StringUtils.isNullOrEmpty(docCategorys)) { + query = "select doccategory from workflow_base where id = ?"; + rs.executeQuery(query, ufContractInfoDTO.getWorkflowType()); + rs.next(); + docCategorys = Util.null2String(rs.getString(1)); + } + if (StringUtils.isNullOrEmpty(docCategorys)) { + docCategorys = ",,1"; + } + // String[] docSplit = docCategorys.split(","); + // String category = docSplit[docSplit.length - 1]; + // 下载合同到文件服务器中 + String docIds = ""; + try { + docIds = downloadContract2FileSystem(ufContractInfoDTO, docCategorys, user); + } catch (Exception e) { + toolUtil.writeErrorLog("创建文档发生错误:" + e); + } + toolUtil.writeDebuggerLog("生成的文档的id:" + docIds); + // 将id保存到流程字段中 + sqlResult = + Util.createSqlBuilder() + .updateSql( + ufContractInfoDTO.getWorkflowMainTable(), + ParaMap.create().put(faDaDaConfigDTO.getContractDoc(), docIds), + Util.createPrepWhereImpl() + .whereAnd("id") + .whereEqual(ufContractInfoDTO.getMainId())); + toolUtil.writeDebuggerLog(sqlResult.getSqlStr() + ",参数:" + sqlResult.getArgs()); + rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs()); + } - /** - * 合同签署发送请求 - * - * @param map - * @param apiConfigMainDTO - */ - private void signedRequest(Map map, ApiConfigMainDTO apiConfigMainDTO) { - String contractNos = Util.null2String(map.get("contractNo")); - String[] split = contractNos.split(","); -// RecordSet rs = new RecordSet(); - for (String s : split) { - map.put("contractNo", s); - ResponeVo responeVo = FaDDRequestUtils.signedContract(map, apiConfigMainDTO.getApiUrl()); - Map response = null; - try { - response = responeVo.getEntityMap(); - } catch (JsonProcessingException e) { - e.printStackTrace(); - } - if (!"200".equals(response.get("code"))) { - toolUtil.writeDebuggerLog("法大大接口签署合同失败!"); - throw new RuntimeException("法大大接口签署合同失败!"); - } - } - } + public String downloadContract2FileSystem( + UfContractInfoDTO ufContractInfoDTO, String category, User user) { - /** - * 查询合同的状态信息 - * - * @param requestId - * @return - */ - public Map querySignedStatus(String requestId) { -// 查询合同状态 - String query = "select * from " + contractInfoTable + " where workflow_request_id = ?"; - RecordSet rs = new RecordSet(); - rs.executeQuery(query, requestId); - Map result = Util.recordSet2Map(rs); - this.toolUtil.writeDebuggerLog(result.toString()); - boolean isAllSinged = false; - boolean isSingedOneself = false; - if (result == null) { - toolUtil.writeDebuggerLog("查询到状态为null;sql:" + query + " ---> " + requestId); - return ParaMap.create().put("isAllSinged", false) - .put("isSingedOneself", false); - } -// 等待对方签署 -/* if("2".equals(result.get("contract_status"))){ - isAllSinged = false; - }*/ -// 等待我方签署 - if ("3".equals(Util.null2String(result.get("contract_status")))) { - isAllSinged = true; - } -// 签署完毕 - if ("4".equals(Util.null2String(result.get("contract_status")))) { - isAllSinged = true; - isSingedOneself = true; - } - return ParaMap.create().put("isAllSinged", isAllSinged) - .put("isSingedOneself", isSingedOneself); - } + /* ImageFileManager fileManager = new ImageFileManager(); + int fileId = fileManager.saveImageFileByInputStream(downloadContract(ufContractInfoDTO.getContractNo(), + String.valueOf(ufContractInfoDTO.getWorkflowType())), ufContractInfoDTO.getFileName());*/ + // 获取配置表信息 + FaDaDaConfigDTO faDaDaConfigDTO = + faDDContractMapping.queryConfig(String.valueOf(ufContractInfoDTO.getWorkflowType()), 5); + ApiConfigMainDTO apiConfigMainDTO = Util.queryApiConfig(faDaDaConfigDTO.getParamsConfig()); + String contractNos = Util.null2String(ufContractInfoDTO.getContractNo()); + String[] split = contractNos.split(","); + List docIds = new ArrayList<>(); + for (String contractNo : split) { + // InputStream inputStream = downloadContract(s, + // String.valueOf(ufContractInfoDTO.getWorkflowType())); + Map data = new HashMap<>(); + data.put("contractNo", contractNo); + AtomicReference content = new AtomicReference<>(); + FaDDRequestUtils.downContract( + data, + response -> { + HttpEntity entity = response.getEntity(); + if (response.getStatusLine().getStatusCode() != 200) { + throw new RuntimeException("法大大请求接口错误!"); + } + try { + content.set(entity.getContent()); + } catch (IOException e) { + e.printStackTrace(); + } + byte[] byteArray = null; + try { + byteArray = IOUtils.toByteArray(content.get()); + } catch (IOException e) { + e.printStackTrace(); + toolUtil.writeErrorLog("文件流处理错误,将inputStream转换为byte数组出错:" + e); + } + this.toolUtil.writeErrorLog(ufContractInfoDTO.toString()); + String base64 = Base64Utils.encode(byteArray); + FileProcessor fileProcessor = new FileProcessor(); + // toolUtil.writeDebuggerLog("base64:" + "base64:" + base64); + toolUtil.writeDebuggerLog("category:" + category); + // toolUtil.writeDebuggerLog("user:" + JSON.toJSONString(user)); + toolUtil.writeDebuggerLog("fileName:" + ufContractInfoDTO.getFileName()); + docIds.add( + String.valueOf( + fileProcessor.Process( + "base64:" + base64, category, user, ufContractInfoDTO.getFileName()))); + }, + apiConfigMainDTO.getApiUrl()); + } + return String.join(",", docIds); + } - public void signedContractOwn(String requestId, User user) { -// 查询合同信息 - UfContractInfoDTO ufContractInfoDTO = faDDContractMapping.queryContractInfoByRequestId(requestId); -// 获取配置表信息 - FaDaDaConfigDTO faDaDaConfigDTO = faDDContractMapping.queryConfig(String.valueOf(ufContractInfoDTO.getWorkflowType()), 4); -// 查询接口配置树形结构 - ApiConfigMainDTO apiConfigMainDTO = Util.queryApiConfigTree(faDaDaConfigDTO.getParamsConfig()); - // 查询签署数据 - List> dataArr = getDataArr(ufContractInfoDTO.getWorkflowRequestId(), - String.valueOf(ufContractInfoDTO.getWorkflowType()), ufContractInfoDTO.getWorkflowMainTable(), - ufContractInfoDTO.getWorkflowDetailTable()); -// 处理数据 - List> maps = objectAndListHandle(apiConfigMainDTO.getDetails(), dataArr); - if (maps == null) { - toolUtil.writeErrorLog("service签署合同错误,错误原因:maps为null!"); - throw new RuntimeException("service签署合同错误,错误原因:maps为null!"); - } - if (maps.size() == 0) { - return; - } - Map data = maps.get(0); - String contractNos = String.valueOf(data.get("contractNo")); - String[] split = contractNos.split(","); - List downloadUrlList = new ArrayList<>(); - List viewUrlList = new ArrayList<>(); - for (String s : split) { - data.put("contractNo", s); - ResponeVo responeVo = FaDDRequestUtils.signedContract(data, apiConfigMainDTO.getApiUrl()); - Map response = null; - try { - response = responeVo.getEntityMap(); - } catch (JsonProcessingException e) { - e.printStackTrace(); - } - if (!"200".equals(response.get("code"))) { - this.toolUtil.writeErrorLog("签署参数:" + responeVo.getEntityString()); - throw new RuntimeException("本方签署失败!法大大请求接口错误!"); - } else { - Map result = (Map) response.get("data"); - downloadUrlList.add(Util.null2String(result.get("downloadUrl"))); - viewUrlList.add(Util.null2String(result.get("viewUrl"))); - } - } -// 更新合同状态 - RecordSet rs = new RecordSet(); - Map update = new HashMap<>(); - update.put("contract_status", 4); - update.put("contract_view_url", String.join(";", viewUrlList)); - update.put("contract_down_url", String.join(";", downloadUrlList)); - PrepSqlResultImpl sqlResult = Util.createSqlBuilder().updateSql(contractInfoTable, update, - Util.createPrepWhereImpl().whereAnd("workflow_request_id").whereEqual(requestId)); - toolUtil.writeDebuggerLog(sqlResult.getSqlStr() + ",参数:" + sqlResult.getArgs()); - rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs()); -// 获取流程中的合同字段的文档目录id - rs.executeQuery("select formid from workflow_base where id = ?", ufContractInfoDTO.getWorkflowType()); - String formId = Util.recordeSet2Entity(rs, String.class); - String query = "select doccategory from workflow_fileupload where fieldid = (select id from workflow_billfield where fieldname = ? and billid = ?)"; - rs.executeQuery(query, faDaDaConfigDTO.getContractDoc(), formId); - String docCategorys = Util.null2String(Util.recordeSet2Entity(rs, String.class)); - if (StringUtils.isNullOrEmpty(docCategorys)) { - query = "select doccategory from workflow_base where id = ?"; - rs.executeQuery(query, ufContractInfoDTO.getWorkflowType()); - rs.next(); - docCategorys = Util.null2String(rs.getString(1)); - } - if (StringUtils.isNullOrEmpty(docCategorys)) { - docCategorys = ",,1"; - } -// String[] docSplit = docCategorys.split(","); -// String category = docSplit[docSplit.length - 1]; -// 下载合同到文件服务器中 - String docIds = ""; - try { - docIds = downloadContract2FileSystem(ufContractInfoDTO, docCategorys, user); - } catch (Exception e) { - toolUtil.writeErrorLog("创建文档发生错误:" + e); - } - toolUtil.writeDebuggerLog("生成的文档的id:" + docIds); -// 将id保存到流程字段中 - sqlResult = Util.createSqlBuilder().updateSql(ufContractInfoDTO.getWorkflowMainTable(), - ParaMap.create().put(faDaDaConfigDTO.getContractDoc(), docIds), - Util.createPrepWhereImpl().whereAnd("id").whereEqual(ufContractInfoDTO.getMainId())); - toolUtil.writeDebuggerLog(sqlResult.getSqlStr() + ",参数:" + sqlResult.getArgs()); - rs.executeUpdate(sqlResult.getSqlStr(), sqlResult.getArgs()); - } + public InputStream downloadContract(String contractNo, String workflowId) { + // 获取配置表信息 + FaDaDaConfigDTO faDaDaConfigDTO = faDDContractMapping.queryConfig(workflowId, 5); + ApiConfigMainDTO apiConfigMainDTO = Util.queryApiConfig(faDaDaConfigDTO.getParamsConfig()); + Map data = new HashMap<>(); + data.put("contractNo", contractNo); + AtomicReference content = new AtomicReference<>(); + FaDDRequestUtils.downContract( + data, + response -> { + HttpEntity entity = response.getEntity(); + if (response.getStatusLine().getStatusCode() != 200) { + throw new RuntimeException("法大大请求接口错误!"); + } + try { + content.set(entity.getContent()); + } catch (IOException e) { + e.printStackTrace(); + } + }, + apiConfigMainDTO.getApiUrl()); + return content.get(); + } - public String downloadContract2FileSystem(UfContractInfoDTO ufContractInfoDTO, String category, User user) { - - /* ImageFileManager fileManager = new ImageFileManager(); - int fileId = fileManager.saveImageFileByInputStream(downloadContract(ufContractInfoDTO.getContractNo(), - String.valueOf(ufContractInfoDTO.getWorkflowType())), ufContractInfoDTO.getFileName());*/ - // 获取配置表信息 - FaDaDaConfigDTO faDaDaConfigDTO = faDDContractMapping.queryConfig(String.valueOf(ufContractInfoDTO.getWorkflowType()), 5); - ApiConfigMainDTO apiConfigMainDTO = Util.queryApiConfig(faDaDaConfigDTO.getParamsConfig()); - String contractNos = Util.null2String(ufContractInfoDTO.getContractNo()); - String[] split = contractNos.split(","); - List docIds = new ArrayList<>(); - for (String contractNo : split) { -// InputStream inputStream = downloadContract(s, String.valueOf(ufContractInfoDTO.getWorkflowType())); - Map data = new HashMap<>(); - data.put("contractNo", contractNo); - AtomicReference content = new AtomicReference<>(); - FaDDRequestUtils.downContract(data, response -> { - HttpEntity entity = response.getEntity(); - if (response.getStatusLine().getStatusCode() != 200) { - throw new RuntimeException("法大大请求接口错误!"); - } - try { - content.set(entity.getContent()); - } catch (IOException e) { - e.printStackTrace(); - } - byte[] byteArray = null; - try { - byteArray = IOUtils.toByteArray(content.get()); - } catch (IOException e) { - e.printStackTrace(); - toolUtil.writeErrorLog("文件流处理错误,将inputStream转换为byte数组出错:" + e); - } - this.toolUtil.writeErrorLog(ufContractInfoDTO.toString()); - String base64 = Base64Utils.encode(byteArray); - FileProcessor fileProcessor = new FileProcessor(); -// toolUtil.writeDebuggerLog("base64:" + "base64:" + base64); - toolUtil.writeDebuggerLog("category:" + category); -// toolUtil.writeDebuggerLog("user:" + JSON.toJSONString(user)); - toolUtil.writeDebuggerLog("fileName:" + ufContractInfoDTO.getFileName()); - docIds.add(String.valueOf(fileProcessor.Process("base64:" + base64, category, user, ufContractInfoDTO.getFileName()))); - }, apiConfigMainDTO.getApiUrl()); - } - return String.join(",", docIds); - } - - public InputStream downloadContract(String contractNo, String workflowId) { -// 获取配置表信息 - FaDaDaConfigDTO faDaDaConfigDTO = faDDContractMapping.queryConfig(workflowId, 5); - ApiConfigMainDTO apiConfigMainDTO = Util.queryApiConfig(faDaDaConfigDTO.getParamsConfig()); - Map data = new HashMap<>(); - data.put("contractNo", contractNo); - AtomicReference content = new AtomicReference<>(); - FaDDRequestUtils.downContract(data, response -> { - HttpEntity entity = response.getEntity(); - if (response.getStatusLine().getStatusCode() != 200) { - throw new RuntimeException("法大大请求接口错误!"); - } - try { - content.set(entity.getContent()); - } catch (IOException e) { - e.printStackTrace(); - } - }, apiConfigMainDTO.getApiUrl()); - return content.get(); - } - - /** - * 直接从法大大系统下载文件 - * - * @param ufContractInfoDTO 合同相关信息 - * @return - */ - public StreamingOutput download4mFDD(UfContractInfoDTO ufContractInfoDTO) { - // 获取配置表信息 - FaDaDaConfigDTO faDaDaConfigDTO = faDDContractMapping.queryConfig(String.valueOf(ufContractInfoDTO.getWorkflowType()), 5); - ApiConfigMainDTO apiConfigMainDTO = Util.queryApiConfig(faDaDaConfigDTO.getParamsConfig()); - // 查询合同信息 -// UfContractInfoDTO ufContractInfoDTO = faDDContractMapping.queryContractInfoByRequestId(requestId); - String contractNos = Util.null2String(ufContractInfoDTO.getContractNo()); - String fileNames = Util.null2String(ufContractInfoDTO.getFileName()); - String[] contractNoArr = contractNos.split(","); - String[] fileNameArr = fileNames.split(","); - toolUtil.writeDebuggerLog("下载合同download4mFDD!"); - if (contractNoArr.length >= 2) { -// 多个文件,需要下载压缩包 - return outputStream -> { - ZipOutputStream zipOut = new ZipOutputStream(outputStream); - int catchLen = 10 * 1024; - for (int i = 0; i < contractNoArr.length; i++) { -// InputStream inputStream = downloadContract(contractNoArr[i], String.valueOf(ufContractInfoDTO.getWorkflowType())); - Map data = new HashMap<>(); - data.put("contractNo", contractNoArr[i]); - AtomicReference content = new AtomicReference<>(); - int finalI = i; - FaDDRequestUtils.downContract(data, response -> { - HttpEntity entity = response.getEntity(); - if (response.getStatusLine().getStatusCode() != 200) { - throw new RuntimeException("法大大请求接口错误!"); - } - try { - content.set(entity.getContent()); - zipOut.putNextEntry(new ZipEntry(fileNameArr[finalI])); - byte[] buffer = new byte[catchLen]; - int len = 0; - while ((len = content.get().read(buffer)) != -1) { - zipOut.write(buffer, 0, len); - } - content.get().close(); - zipOut.closeEntry(); - } catch (IOException e) { - e.printStackTrace(); - toolUtil.writeErrorLog("文件压缩处理出现问题!" + e); - } - }, apiConfigMainDTO.getApiUrl()); - - } - zipOut.flush(); - zipOut.close(); - outputStream.flush(); - outputStream.close(); - }; - } - return outputStream -> { - toolUtil.writeDebuggerLog("download4mFDD单文件下载!"); -// InputStream inputStream = downloadContract(contractNos,String.valueOf(ufContractInfoDTO.getWorkflowType())); - Map data = new HashMap<>(); - data.put("contractNo", contractNos); - AtomicReference content = new AtomicReference<>(); - FaDDRequestUtils.downContract(data, response -> { - HttpEntity entity = response.getEntity(); - if (response.getStatusLine().getStatusCode() != 200) { - throw new RuntimeException("法大大请求接口错误!"); - } - try { - content.set(entity.getContent()); - int catchLen = 10 * 1024; - byte[] buffer = new byte[catchLen]; - int len = 0; - while ((len = content.get().read(buffer)) != -1) { - outputStream.write(buffer, 0, len); - } - content.get().close(); - outputStream.flush(); - outputStream.close(); - } catch (IOException e) { - e.printStackTrace(); - toolUtil.writeErrorLog("单文件下载处理出现问题!" + e); - } - }, apiConfigMainDTO.getApiUrl()); - }; - - } + /** + * 直接从法大大系统下载文件 + * + * @param ufContractInfoDTO 合同相关信息 + * @return + */ + public StreamingOutput download4mFDD(UfContractInfoDTO ufContractInfoDTO) { + // 获取配置表信息 + FaDaDaConfigDTO faDaDaConfigDTO = + faDDContractMapping.queryConfig(String.valueOf(ufContractInfoDTO.getWorkflowType()), 5); + ApiConfigMainDTO apiConfigMainDTO = Util.queryApiConfig(faDaDaConfigDTO.getParamsConfig()); + // 查询合同信息 + // UfContractInfoDTO ufContractInfoDTO = + // faDDContractMapping.queryContractInfoByRequestId(requestId); + String contractNos = Util.null2String(ufContractInfoDTO.getContractNo()); + String fileNames = Util.null2String(ufContractInfoDTO.getFileName()); + String[] contractNoArr = contractNos.split(","); + String[] fileNameArr = fileNames.split(","); + toolUtil.writeDebuggerLog("下载合同download4mFDD!"); + if (contractNoArr.length >= 2) { + // 多个文件,需要下载压缩包 + return outputStream -> { + ZipOutputStream zipOut = new ZipOutputStream(outputStream); + int catchLen = 10 * 1024; + for (int i = 0; i < contractNoArr.length; i++) { + // InputStream inputStream = downloadContract(contractNoArr[i], + // String.valueOf(ufContractInfoDTO.getWorkflowType())); + Map data = new HashMap<>(); + data.put("contractNo", contractNoArr[i]); + AtomicReference content = new AtomicReference<>(); + int finalI = i; + FaDDRequestUtils.downContract( + data, + response -> { + HttpEntity entity = response.getEntity(); + if (response.getStatusLine().getStatusCode() != 200) { + throw new RuntimeException("法大大请求接口错误!"); + } + try { + content.set(entity.getContent()); + zipOut.putNextEntry(new ZipEntry(fileNameArr[finalI])); + byte[] buffer = new byte[catchLen]; + int len = 0; + while ((len = content.get().read(buffer)) != -1) { + zipOut.write(buffer, 0, len); + } + content.get().close(); + zipOut.closeEntry(); + } catch (IOException e) { + e.printStackTrace(); + toolUtil.writeErrorLog("文件压缩处理出现问题!" + e); + } + }, + apiConfigMainDTO.getApiUrl()); + } + zipOut.flush(); + zipOut.close(); + outputStream.flush(); + outputStream.close(); + }; + } + return outputStream -> { + toolUtil.writeDebuggerLog("download4mFDD单文件下载!"); + // InputStream inputStream = + // downloadContract(contractNos,String.valueOf(ufContractInfoDTO.getWorkflowType())); + Map data = new HashMap<>(); + data.put("contractNo", contractNos); + AtomicReference content = new AtomicReference<>(); + FaDDRequestUtils.downContract( + data, + response -> { + HttpEntity entity = response.getEntity(); + if (response.getStatusLine().getStatusCode() != 200) { + throw new RuntimeException("法大大请求接口错误!"); + } + try { + content.set(entity.getContent()); + int catchLen = 10 * 1024; + byte[] buffer = new byte[catchLen]; + int len = 0; + while ((len = content.get().read(buffer)) != -1) { + outputStream.write(buffer, 0, len); + } + content.get().close(); + outputStream.flush(); + outputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + toolUtil.writeErrorLog("单文件下载处理出现问题!" + e); + } + }, + apiConfigMainDTO.getApiUrl()); + }; + } } diff --git a/com/api/aiyh_pcn/fadada/service/impl/FaDDServiceImpl.java b/com/api/aiyh_pcn/fadada/service/impl/FaDDServiceImpl.java index b76ed0a..4f56cca 100644 --- a/com/api/aiyh_pcn/fadada/service/impl/FaDDServiceImpl.java +++ b/com/api/aiyh_pcn/fadada/service/impl/FaDDServiceImpl.java @@ -1,25 +1,5 @@ package com.api.aiyh_pcn.fadada.service.impl; -import aiyh.utils.Util; -import aiyh.utils.entity.ApiConfigDetailDTO; -import aiyh.utils.entity.ApiConfigMainDTO; -import aiyh.utils.httpUtil.ResponeVo; -import aiyh.utils.zwl.common.ToolUtil; -import com.alibaba.fastjson.JSONObject; -import com.api.aiyh_pcn.fadada.dao.FaDDServiceMapping; -import com.api.aiyh_pcn.fadada.entity.FaDaDaConfigDTO; -import com.api.aiyh_pcn.fadada.service.IFaDDService; -import com.api.aiyh_pcn.fadada.util.FaDDRequestUtils; -import com.api.aiyh_pcn.fadada.vo.TableFieldMappingVO; -import com.fasterxml.jackson.core.JsonProcessingException; -import org.apache.http.Header; -import org.apache.http.HeaderElement; -import org.apache.http.HttpEntity; -import org.apache.http.NameValuePair; -import weaver.conn.RecordSet; -import weaver.workflow.workflow.WorkflowVersion; - -import javax.ws.rs.core.StreamingOutput; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; @@ -29,567 +9,583 @@ import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; +import javax.ws.rs.core.StreamingOutput; + +import org.apache.http.Header; +import org.apache.http.HeaderElement; +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; + +import com.alibaba.fastjson.JSONObject; +import com.api.aiyh_pcn.fadada.dao.FaDDServiceMapping; +import com.api.aiyh_pcn.fadada.entity.FaDaDaConfigDTO; +import com.api.aiyh_pcn.fadada.service.IFaDDService; +import com.api.aiyh_pcn.fadada.util.FaDDRequestUtils; +import com.api.aiyh_pcn.fadada.vo.TableFieldMappingVO; +import com.fasterxml.jackson.core.JsonProcessingException; + +import aiyh.utils.Util; +import aiyh.utils.entity.ApiConfigDetailDTO; +import aiyh.utils.entity.ApiConfigMainDTO; +import aiyh.utils.httpUtil.ResponeVo; +import aiyh.utils.zwl.common.ToolUtil; +import weaver.conn.RecordSet; +import weaver.workflow.workflow.WorkflowVersion; + /** * @author EBU7-dev1-ayh - * @create 2021/9/30 0030 11:12 - * service + * @create 2021/9/30 0030 11:12 service */ - - public class FaDDServiceImpl implements IFaDDService { - private final FaDDServiceMapping faDDServiceMapping = new FaDDServiceMapping(); - private final ToolUtil toolUtil = new ToolUtil(); -// private final String MAIN_TABLE = "formtable_main_17"; + private final FaDDServiceMapping faDDServiceMapping = new FaDDServiceMapping(); + private final ToolUtil toolUtil = new ToolUtil(); + // private final String MAIN_TABLE = "formtable_main_17"; + @Override + public Map getConfigParam(String workflowId) { + FaDaDaConfigDTO faDaDaConfigDTO = faDDServiceMapping.queryConfig(workflowId, 0); + ApiConfigMainDTO apiConfigMainDTO = Util.queryApiConfig(faDaDaConfigDTO.getParamsConfig()); + List tableFieldMappingVOS = new ArrayList<>(); + List details = apiConfigMainDTO.getDetails(); + for (ApiConfigDetailDTO detail : details) { + TableFieldMappingVO tableFieldMappingVO = new TableFieldMappingVO(); + String tableName = ""; + String fieldName = ""; + int id = detail.getId(); + String table = detail.getTablename(); + if (!table.contains("_dt")) { + // 表示字段属于主表 + tableName = "main"; + } else { + // 字段属于明细表 + String dt = table.substring(table.indexOf("_dt") + 3); + tableName = "detail_" + dt; + } + tableFieldMappingVO.setTableName(tableName); + tableFieldMappingVO.setId(id); + int changeRule = detail.getChangeRule(); + if (changeRule == 0) { + // 不转换,需要获取到流程字段,前端获取流程字段对应的值 + fieldName = detail.getWorkflowField(); + tableFieldMappingVO.setField(fieldName); + tableFieldMappingVOS.add(tableFieldMappingVO); + } else if (changeRule == 2) { + // 流程字段值,与不转换一至 + fieldName = detail.getWorkflowField(); + tableFieldMappingVO.setField(fieldName); + tableFieldMappingVOS.add(tableFieldMappingVO); + } + if (changeRule == 7 || changeRule == 6) { + // 7 自定义SQL,与流程转SQL一样 + List tableFieldMappingVOList = new ArrayList<>(); + // 6 流程字段转SQL,需要获取SQL中的字段变量,前端通过字段变量获取值 + // 解析SQL + Map> result = Util.parsingSq2Map(detail.getParamValue()); + for (Map.Entry> entry : result.entrySet()) { + for (String field : entry.getValue()) { + TableFieldMappingVO tf = new TableFieldMappingVO(); + tf.setTableName(entry.getKey()); + tf.setField(field); + tf.setId(id); + tableFieldMappingVOList.add(tf); + } + } + tableFieldMappingVOS.addAll(tableFieldMappingVOList); + } + if (detail.getParamType() == 4) { + // 数组类型的,需要解析数组sql + List tableFieldMappingVOList = new ArrayList<>(); + Map> result = Util.parsingSq2Map(detail.getArraySql()); + for (Map.Entry> entry : result.entrySet()) { + for (String field : entry.getValue()) { + TableFieldMappingVO tf = new TableFieldMappingVO(); + tf.setTableName(entry.getKey()); + tf.setField(field); + tf.setId(id); + tableFieldMappingVOList.add(tf); + } + } + tableFieldMappingVOS.addAll(tableFieldMappingVOList); + } + } + List doDeWeight = + Util.deWeight(tableFieldMappingVOS, e -> e.getTableName() + e.getField()); + Map map = new HashMap<>(); + map.put("tableFieldMappings", doDeWeight); + String checkSource = faDaDaConfigDTO.getCheckSource(); + String sourceTable; + if (!checkSource.contains("_dt")) { + // 表示字段属于主表 + sourceTable = "main"; + map.put("isMain", true); + } else { + // 字段属于明细表 + String dt = checkSource.substring(checkSource.indexOf("_dt") + 3); + sourceTable = "detail_" + dt; + map.put("isMain", false); + } + map.put("sourceTable", sourceTable); + return map; + } - @Override - public Map getConfigParam(String workflowId) { - FaDaDaConfigDTO faDaDaConfigDTO = faDDServiceMapping.queryConfig(workflowId, 0); - ApiConfigMainDTO apiConfigMainDTO = Util.queryApiConfig(faDaDaConfigDTO.getParamsConfig()); - List tableFieldMappingVOS = new ArrayList<>(); - List details = apiConfigMainDTO.getDetails(); - for (ApiConfigDetailDTO detail : details) { - TableFieldMappingVO tableFieldMappingVO = new TableFieldMappingVO(); - String tableName = ""; - String fieldName = ""; - int id = detail.getId(); - String table = detail.getTablename(); - if (!table.contains("_dt")) { -// 表示字段属于主表 - tableName = "main"; - } else { -// 字段属于明细表 - String dt = table.substring(table.indexOf("_dt") + 3); - tableName = "detail_" + dt; - } - tableFieldMappingVO.setTableName(tableName); - tableFieldMappingVO.setId(id); - int changeRule = detail.getChangeRule(); - if (changeRule == 0) { -// 不转换,需要获取到流程字段,前端获取流程字段对应的值 - fieldName = detail.getWorkflowField(); - tableFieldMappingVO.setField(fieldName); - tableFieldMappingVOS.add(tableFieldMappingVO); - } else if (changeRule == 2) { -// 流程字段值,与不转换一至 - fieldName = detail.getWorkflowField(); - tableFieldMappingVO.setField(fieldName); - tableFieldMappingVOS.add(tableFieldMappingVO); - } - if (changeRule == 7 || changeRule == 6) { -// 7 自定义SQL,与流程转SQL一样 - List tableFieldMappingVOList = new ArrayList<>(); -// 6 流程字段转SQL,需要获取SQL中的字段变量,前端通过字段变量获取值 -// 解析SQL - Map> result = Util.parsingSq2Map(detail.getParamValue()); - for (Map.Entry> entry : result.entrySet()) { - for (String field : entry.getValue()) { - TableFieldMappingVO tf = new TableFieldMappingVO(); - tf.setTableName(entry.getKey()); - tf.setField(field); - tf.setId(id); - tableFieldMappingVOList.add(tf); - } - } - tableFieldMappingVOS.addAll(tableFieldMappingVOList); - } - if (detail.getParamType() == 4) { -// 数组类型的,需要解析数组sql - List tableFieldMappingVOList = new ArrayList<>(); - Map> result = Util.parsingSq2Map(detail.getArraySql()); - for (Map.Entry> entry : result.entrySet()) { - for (String field : entry.getValue()) { - TableFieldMappingVO tf = new TableFieldMappingVO(); - tf.setTableName(entry.getKey()); - tf.setField(field); - tf.setId(id); - tableFieldMappingVOList.add(tf); - } - } - tableFieldMappingVOS.addAll(tableFieldMappingVOList); - } - } - List doDeWeight = Util.deWeight(tableFieldMappingVOS, e -> e.getTableName() + e.getField()); - Map map = new HashMap<>(); - map.put("tableFieldMappings", doDeWeight); - String checkSource = faDaDaConfigDTO.getCheckSource(); - String sourceTable; - if (!checkSource.contains("_dt")) { -// 表示字段属于主表 - sourceTable = "main"; - map.put("isMain", true); - } else { -// 字段属于明细表 - String dt = checkSource.substring(checkSource.indexOf("_dt") + 3); - sourceTable = "detail_" + dt; - map.put("isMain", false); - } - map.put("sourceTable", sourceTable); - return map; - } + @Override + public Map checkCertification(Map params) { + Map resultMap = new HashMap<>(); + String workflowId = String.valueOf(params.get("workflowId")); + FaDaDaConfigDTO faDaDaConfigDTO = faDDServiceMapping.queryConfig(workflowId, 0); + ApiConfigMainDTO apiConfigMainDTO = Util.queryApiConfigTree(faDaDaConfigDTO.getParamsConfig()); + List> dataArr = (List>)params.get("dataArr"); + List details = apiConfigMainDTO.getDetails(); + List> datas = objectAndListHandle(details, dataArr); + List> errorList = new ArrayList<>(); + List> nonsupportList = new ArrayList<>(); + for (Map data : datas) { + System.out.println(JSONObject.toJSONString(data)); + Map result = FaDDRequestUtils.checkCompanyInfo(data); + if (result == null) { + // 未查询到数据 + errorList.add(data); + } else { + if ("1001005".equals(String.valueOf(result.get("code"))) + || !"200".equals(String.valueOf(result.get("code")))) { + // 企业信息不存在或者未认证 + nonsupportList.add(data); + } + } + } + if (errorList.size() == 0 && nonsupportList.size() == 0) { + // 所有的都通过 + resultMap.put("allPass", true); + } else { + resultMap.put("allPass", false); + resultMap.put("errorList", errorList); + resultMap.put("nonsupportList", nonsupportList); + } + return resultMap; + } - @Override - public Map checkCertification(Map params) { - Map resultMap = new HashMap<>(); - String workflowId = String.valueOf(params.get("workflowId")); - FaDaDaConfigDTO faDaDaConfigDTO = faDDServiceMapping.queryConfig(workflowId, 0); - ApiConfigMainDTO apiConfigMainDTO = Util.queryApiConfigTree(faDaDaConfigDTO.getParamsConfig()); - List> dataArr = (List>) params.get("dataArr"); - List details = apiConfigMainDTO.getDetails(); - List> datas = objectAndListHandle(details, dataArr); - List> errorList = new ArrayList<>(); - List> nonsupportList = new ArrayList<>(); - for (Map data : datas) { - System.out.println(JSONObject.toJSONString(data)); - Map result = FaDDRequestUtils.checkCompanyInfo(data); - if (result == null) { -// 未查询到数据 - errorList.add(data); - } else { - if ("1001005".equals(String.valueOf(result.get("code"))) || !"200".equals(String.valueOf(result.get("code")))) { -// 企业信息不存在或者未认证 - nonsupportList.add(data); - } - } - } - if (errorList.size() == 0 && nonsupportList.size() == 0) { -// 所有的都通过 - resultMap.put("allPass", true); - } else { - resultMap.put("allPass", false); - resultMap.put("errorList", errorList); - resultMap.put("nonsupportList", nonsupportList); - } - return resultMap; - } + private List> objectAndListHandle(List treeList, + List> dataArr) { + List> params = new ArrayList<>(); + for (Map dataMap : dataArr) { + Map param = new HashMap<>(); + for (ApiConfigDetailDTO apiConfigDetailDTO : treeList) { + Object value; + if (apiConfigDetailDTO.getParamType() == 3) { + Map map = new HashMap<>(); + // object类型 + for (ApiConfigDetailDTO child : apiConfigDetailDTO.getChildren()) { + if (child.getChildren() == null || child.getChildren().size() == 0) { + // handleChild(child.getChildren(), dataMap) + map.put(child.getParamName(), changeRuleHandle(child, dataMap)); + } else { + map.put(child.getParamName(), handleChild(child.getChildren(), dataMap)); + } + } + value = map; + } else if (apiConfigDetailDTO.getParamType() == 4) { + String sql = apiConfigDetailDTO.getArraySql(); + String parsingSq = Util.parsingSq(sql, dataMap); + // list类型 + if (parsingSq.contains("delete") || parsingSq.contains("update") || parsingSq.contains("exec") + || parsingSq.contains("drop") || parsingSq.contains("truncate")) { + value = new ArrayList<>(); + } else { + RecordSet rs = new RecordSet(); + rs.executeQuery(parsingSq.replace("select", "select")); + value = Util.recordeSet2Array(rs, String.class); + } + } else { + value = changeRuleHandle(apiConfigDetailDTO, dataMap); + } + param.put(apiConfigDetailDTO.getParamName(), value); + } + params.add(param); + } + return params; + } - private List> objectAndListHandle(List treeList, List> dataArr) { - List> params = new ArrayList<>(); - for (Map dataMap : dataArr) { - Map param = new HashMap<>(); - for (ApiConfigDetailDTO apiConfigDetailDTO : treeList) { - Object value; - if (apiConfigDetailDTO.getParamType() == 3) { - Map map = new HashMap<>(); -// object类型 - for (ApiConfigDetailDTO child : apiConfigDetailDTO.getChildren()) { - if (child.getChildren() == null || child.getChildren().size() == 0) { -// handleChild(child.getChildren(), dataMap) - map.put(child.getParamName(), changeRuleHandle(child, dataMap)); - } else { - map.put(child.getParamName(), handleChild(child.getChildren(), dataMap)); - } - } - value = map; - } else if (apiConfigDetailDTO.getParamType() == 4) { - String sql = apiConfigDetailDTO.getArraySql(); - String parsingSq = Util.parsingSq(sql, dataMap); -// list类型 - if (parsingSq.contains("delete") || parsingSq.contains("update") || - parsingSq.contains("exec") || parsingSq.contains("drop") || - parsingSq.contains("truncate")) { - value = new ArrayList<>(); - } else { - RecordSet rs = new RecordSet(); - rs.executeQuery(parsingSq.replace("select", "select")); - value = Util.recordeSet2Array(rs, String.class); - } - } else { - value = changeRuleHandle(apiConfigDetailDTO, dataMap); - } - param.put(apiConfigDetailDTO.getParamName(), value); - } - params.add(param); - } - return params; - } + private Object handleChild(List children, Map dataMap) { + Map params = new HashMap<>(); + for (ApiConfigDetailDTO child : children) { + Object value; + if (child.getChildren() != null) { + value = handleChild(child.getChildren(), dataMap); + } else { + value = changeRuleHandle(child, dataMap); + } + params.put(child.getParamName(), value); + } + return params; + } - private Object handleChild(List children, Map dataMap) { - Map params = new HashMap<>(); - for (ApiConfigDetailDTO child : children) { - Object value; - if (child.getChildren() != null) { - value = handleChild(child.getChildren(), dataMap); - } else { - value = changeRuleHandle(child, dataMap); - } - params.put(child.getParamName(), value); - } - return params; - } + private Object changeRuleHandle(ApiConfigDetailDTO apiConfigDetailDTO, Map dataMap) { + Object value; + String tableName; + String table; + String sql; + String resultSql; + // 判断参数的转换规则 + switch (apiConfigDetailDTO.getChangeRule()) { + case 0: + // 不转换 + case 2: + // 流程字段值 + table = apiConfigDetailDTO.getTablename(); + if (!table.contains("_dt")) { + // 表示字段属于主表 + tableName = "main"; + } else { + // 字段属于明细表 + String dt = table.substring(table.indexOf("_dt") + 3); + tableName = "detail_" + dt; + } + value = dataMap.get(tableName + "." + apiConfigDetailDTO.getWorkflowField()); + break; + case 1: + // 固定值 + value = apiConfigDetailDTO.getParamValue(); + break; + case 3: + // 系统日期 + value = Util.getTime("yyyy-MM-dd"); + break; + case 4: + // 系统时间 + value = Util.getTime("HH:mm:ss"); + break; + case 5: + // 系统日期-时间 + value = Util.getTime("yyyy-MM-dd HH:mm:ss"); + break; + case 6: + // 自定义SQL + case 7: + // 流程字段转SQL + sql = apiConfigDetailDTO.getParamValue(); + resultSql = Util.parsingSq(sql, dataMap); + toolUtil.writeErrorLog(dataMap.toString()); + if (resultSql.contains("delete ") || resultSql.contains("update ") || resultSql.contains("exec ") + || resultSql.contains("drop ") || resultSql.contains("truncate ")) { + value = null; + } else { + RecordSet rs = new RecordSet(); + rs.executeQuery(resultSql.replace("select", "select")); + rs.next(); + value = Util.null2String(rs.getString(1)); + toolUtil.writeErrorLog("转换值:" + value); + toolUtil.writeErrorLog("转换SQL:" + resultSql.replace("select", "select")); + } + break; + case 8: + // + // 流程名称 + value = Util.getWorkflowNameById(String.valueOf(dataMap.get("workflowid"))); + break; + case 9: + // + // 请求标题 + value = Util.getRequestTitleById(String.valueOf(dataMap.get("requestid"))); + break; + case 10: + // + // 流程requestId + value = dataMap.get("requestid"); + break; + default: + value = null; + break; + } + if (apiConfigDetailDTO.getParamType() == 1) { + // Integer + value = Integer.parseInt(String.valueOf(value)); + } else if (apiConfigDetailDTO.getParamType() == 2) { + // Boolean + value = Boolean.parseBoolean(String.valueOf(value)); + } + return value; + } - private Object changeRuleHandle(ApiConfigDetailDTO apiConfigDetailDTO, Map dataMap) { - Object value; - String tableName; - String table; - String sql; - String resultSql; -// 判断参数的转换规则 - switch (apiConfigDetailDTO.getChangeRule()) { - case 0: -// 不转换 - case 2: -// 流程字段值 - table = apiConfigDetailDTO.getTablename(); - if (!table.contains("_dt")) { -// 表示字段属于主表 - tableName = "main"; - } else { -// 字段属于明细表 - String dt = table.substring(table.indexOf("_dt") + 3); - tableName = "detail_" + dt; - } - value = dataMap.get(tableName + "." + apiConfigDetailDTO.getWorkflowField()); - break; - case 1: -// 固定值 - value = apiConfigDetailDTO.getParamValue(); - break; - case 3: -// 系统日期 - value = Util.getTime("yyyy-MM-dd"); - break; - case 4: -// 系统时间 - value = Util.getTime("HH:mm:ss"); - break; - case 5: -// 系统日期-时间 - value = Util.getTime("yyyy-MM-dd HH:mm:ss"); - break; - case 6: -// 自定义SQL - case 7: -// 流程字段转SQL - sql = apiConfigDetailDTO.getParamValue(); - resultSql = Util.parsingSq(sql, dataMap); - toolUtil.writeErrorLog(dataMap.toString()); - if (resultSql.contains("delete ") || resultSql.contains("update ") || - resultSql.contains("exec ") || resultSql.contains("drop ") || - resultSql.contains("truncate ")) { - value = null; - } else { - RecordSet rs = new RecordSet(); - rs.executeQuery(resultSql.replace("select", "select")); - rs.next(); - value = Util.null2String(rs.getString(1)); - toolUtil.writeErrorLog("转换值:" + value); - toolUtil.writeErrorLog("转换SQL:" + resultSql.replace("select", "select")); - } - break; - case 8: -// -// 流程名称 - value = Util.getWorkflowNameById(String.valueOf(dataMap.get("workflowid"))); - break; - case 9: -// -// 请求标题 - value = Util.getRequestTitleById(String.valueOf(dataMap.get("requestid"))); - break; - case 10: -// -// 流程requestId - value = dataMap.get("requestid"); - break; - default: - value = null; - break; - } - if (apiConfigDetailDTO.getParamType() == 1) { -// Integer - value = Integer.parseInt(String.valueOf(value)); - } else if (apiConfigDetailDTO.getParamType() == 2) { -// Boolean - value = Boolean.parseBoolean(String.valueOf(value)); - } - return value; - } + public void queryContractStatus(String workflowId, String requestId, int type) { + List> maps = faDDServiceMapping.queryDetailInfo(requestId, workflowId, 2); + toolUtil.writeErrorLog("maps+:" + maps); + List> notSignedContracts = new ArrayList<>(); + // 查询是是否签署 + for (Map map : maps) { + // 发送请求查询合同信息 + Map data = new HashMap<>(); + String contracts = String.valueOf(map.get("contract_no")); + if (contracts == null) { + contracts = ""; + } + String[] split = contracts.split(","); + for (String s : split) { + toolUtil.writeErrorLog(s); + data.put("contractNo", s); + Map result = null; + // List statusList = new ArrayList<>(); + try { + Map response = FaDDRequestUtils.queryContractStatus(data); + if (!"200".equals(response.get("code"))) { + throw new RuntimeException("法大大请求接口错误!"); + } + result = (Map)response.get("data"); + this.toolUtil.writeErrorLog("催一催:" + result); + } catch (RuntimeException e) { + e.printStackTrace(); + throw e; + } catch (JsonProcessingException e) { + toolUtil.writeDebuggerLog("转换错误:" + e); + } + if ("1".equals(String.valueOf(result.get("status"))) + || "6".equals(String.valueOf(result.get("status")))) { + // 发送请求催一下 签署合同 + notSignedContracts.add(map); + } else { + // 合同状态发生改变,需要修改数据库中的状态信息 百分百会出问题 + map.put("contract_status", result.get("status")); + // statusList.add() + faDDServiceMapping.updateContractStatus(map, workflowId, 3); + } + } + } + if (type == 0) { + signedContract(workflowId, requestId, notSignedContracts); + } + } + public void signedContract(String workflowId, String requestId, List> detailMaps) { + String mainTable = faDDServiceMapping.getMainTable(workflowId); + RecordSet rs = new RecordSet(); + String query = "select * from " + mainTable + " where requestid = ?"; + rs.executeQuery(query, requestId); + Map mainMap; + mainMap = Util.recordSet2Map(rs); + String mainId = ""; + if (mainMap != null) { + mainId = String.valueOf(mainMap.get("id")); + } else { + toolUtil.writeErrorLog("没有查询到相关的请求id的数据!"); + } + String detailTable1 = faDDServiceMapping.getDetailTable(workflowId, 3); + query = "select * from " + detailTable1 + " where mainid = ?"; + rs.executeQuery(query, mainId); + /*List> detailMaps; + detailMaps = Util.recordSet2MapList(rs); + if (detailMaps == null) { + toolUtil.writeErrorLog("查询明细失败!maps为null"); + return; + }*/ + FaDaDaConfigDTO faDaDaConfigDTO = faDDServiceMapping.queryConfig(workflowId, 3); + ApiConfigMainDTO apiConfigMainDTO = Util.queryApiConfigTree(faDaDaConfigDTO.getParamsConfig()); + List> dataArr = new ArrayList<>(); + String detailTable; + String dt = detailTable1.substring(detailTable1.indexOf("_dt") + 3); + detailTable = "detail_" + dt; + for (Map detailMap : detailMaps) { + Map dataMap = new HashMap<>(); + for (Map.Entry entry : detailMap.entrySet()) { + dataMap.put(detailTable + "." + entry.getKey(), entry.getValue()); + } + for (Map.Entry entry : mainMap.entrySet()) { + dataMap.put("main" + "." + entry.getKey(), entry.getValue()); + } + dataArr.add(dataMap); + } + List> maps = objectAndListHandle(apiConfigMainDTO.getDetails(), dataArr); + for (Map map : maps) { + toolUtil.writeErrorLog(map.toString()); + String contractNos = Util.null2String(map.get("contractNo")); + String[] split = contractNos.split(","); + for (String s : split) { + map.put("contractNo", s); + ResponeVo responeVo = FaDDRequestUtils.signedContract(map, apiConfigMainDTO.getApiUrl()); + Map response = null; + try { + response = responeVo.getEntityMap(); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + if (!"200".equals(response.get("code"))) { + throw new RuntimeException("法大大请求接口错误!"); + } + } + } + } - public void queryContractStatus(String workflowId, String requestId, int type) { - List> maps = faDDServiceMapping.queryDetailInfo(requestId, workflowId, 2); - toolUtil.writeErrorLog("maps+:" + maps); - List> notSignedContracts = new ArrayList<>(); -// 查询是是否签署 - for (Map map : maps) { -// 发送请求查询合同信息 - Map data = new HashMap<>(); - String contracts = String.valueOf(map.get("contract_no")); - if (contracts == null) { - contracts = ""; - } - String[] split = contracts.split(","); - for (String s : split) { - toolUtil.writeErrorLog(s); - data.put("contractNo", s); - Map result = null; -// List statusList = new ArrayList<>(); - try { - Map response = FaDDRequestUtils.queryContractStatus(data); - if (!"200".equals(response.get("code"))) { - throw new RuntimeException("法大大请求接口错误!"); - } - result = (Map) response.get("data"); - this.toolUtil.writeErrorLog("催一催:" + result); - } catch (RuntimeException e) { - e.printStackTrace(); - throw e; - } catch (JsonProcessingException e) { - toolUtil.writeDebuggerLog("转换错误:" + e); - } - if ("1".equals(String.valueOf(result.get("status"))) || "6".equals(String.valueOf(result.get("status")))) { -// 发送请求催一下 签署合同 - notSignedContracts.add(map); - } else { -// 合同状态发生改变,需要修改数据库中的状态信息 百分百会出问题 - map.put("contract_status", result.get("status")); -// statusList.add() - faDDServiceMapping.updateContractStatus(map, workflowId, 3); - } - } + public StreamingOutput contractDownload(String requestId, String workflowId) { + toolUtil.writeErrorLog("进入service方法!"); + List> maps = null; + // 查询合同信息 + try { + maps = faDDServiceMapping.queryDetailDownInfo(requestId, workflowId, 2); + } catch (Exception e) { + toolUtil.writeErrorLog(String.valueOf(faDDServiceMapping)); + toolUtil.writeErrorLog("调用错误" + e); + } + toolUtil.writeErrorLog(String.valueOf(maps)); + toolUtil.writeErrorLog(JSONObject.toJSONString(maps)); + List> finalMaps = maps; + String versionStringByWfid = WorkflowVersion.getVersionStringByWfid(workflowId); + RecordSet rs = new RecordSet(); + rs.executeQuery( + "select * from uf_contract_config where workflow_type in ( " + versionStringByWfid + " ) and api_type = ?", + 5); + rs.next(); + ApiConfigMainDTO apiConfigMainDTO = Util.queryApiConfig(rs.getString("params_config")); + return outputStream -> { + ZipOutputStream zipOut = new ZipOutputStream(outputStream); + toolUtil.writeErrorLog("进入方法!"); + int catchLen = 10 * 1024; + String base = ""; + for (Map map : finalMaps) { + base = base + map.get("gyshtfmczw") + "/"; + // 获取合同id + String contractNoStr = String.valueOf(map.get("contract_no")); + String contractNameStr = String.valueOf(map.get("file_name")); + String[] contractNos = contractNoStr.split(","); + String[] contractNames = contractNameStr.split(","); + for (int i = 0; i < contractNos.length; i++) { + String contractNo = contractNos[i]; + String contractName = contractNames[i]; + Map data = new HashMap<>(); + data.put("contractNo", contractNo); + // 下载合同 + String finalBase = base; + FaDDRequestUtils.downContract(data, response -> { + HttpEntity entity = response.getEntity(); + if (response.getStatusLine().getStatusCode() != 200) { + throw new RuntimeException("法大大请求接口错误!"); + } + InputStream content = null; + try { + content = entity.getContent(); + Header contentHeader = response.getFirstHeader("Content-disposition"); + String filename = contractName.substring(0, contractName.indexOf(".")) + ".pdf"; + if (contentHeader != null) { + HeaderElement[] values = contentHeader.getElements(); + NameValuePair param = values[0].getParameterByName("filename"); + filename = param.getValue(); + } + zipOut.putNextEntry(new ZipEntry(finalBase + filename)); + byte[] buffer = new byte[catchLen]; + int len = 0; + while ((len = content.read(buffer)) != -1) { + zipOut.write(buffer, 0, len); + } + zipOut.closeEntry(); + } catch (IOException e) { + e.printStackTrace(); + toolUtil.writeErrorLog("压缩错误!" + e + "\n"); + } + }, apiConfigMainDTO.getApiUrl()); + } + } + zipOut.flush(); + zipOut.close(); + }; + } - } - if (type == 0) { - signedContract(workflowId, requestId, notSignedContracts); - } - } + public boolean isAllSinged(String requestId, String workflowId) { + List> maps = faDDServiceMapping.queryDetailInfo(requestId, workflowId, 2); + if (maps == null || maps.size() == 0) { + return true; + } + return false; + } - public void signedContract(String workflowId, String requestId, List> detailMaps) { - String mainTable = faDDServiceMapping.getMainTable(workflowId); - RecordSet rs = new RecordSet(); - String query = "select * from " + mainTable + " where requestid = ?"; - rs.executeQuery(query, requestId); - Map mainMap; - mainMap = Util.recordSet2Map(rs); - String mainId = ""; - if (mainMap != null) { - mainId = String.valueOf(mainMap.get("id")); - } else { - toolUtil.writeErrorLog("没有查询到相关的请求id的数据!"); - } - String detailTable1 = faDDServiceMapping.getDetailTable(workflowId, 3); - query = "select * from " + detailTable1 + " where mainid = ?"; - rs.executeQuery(query, mainId); - /*List> detailMaps; - detailMaps = Util.recordSet2MapList(rs); - if (detailMaps == null) { - toolUtil.writeErrorLog("查询明细失败!maps为null"); - return; - }*/ - FaDaDaConfigDTO faDaDaConfigDTO = faDDServiceMapping.queryConfig(workflowId, 3); - ApiConfigMainDTO apiConfigMainDTO = Util.queryApiConfigTree(faDaDaConfigDTO.getParamsConfig()); - List> dataArr = new ArrayList<>(); - String detailTable; - String dt = detailTable1.substring(detailTable1.indexOf("_dt") + 3); - detailTable = "detail_" + dt; - for (Map detailMap : detailMaps) { - Map dataMap = new HashMap<>(); - for (Map.Entry entry : detailMap.entrySet()) { - dataMap.put(detailTable + "." + entry.getKey(), entry.getValue()); - } - for (Map.Entry entry : mainMap.entrySet()) { - dataMap.put("main" + "." + entry.getKey(), entry.getValue()); - } - dataArr.add(dataMap); - } - List> maps = objectAndListHandle(apiConfigMainDTO.getDetails(), dataArr); - for (Map map : maps) { - toolUtil.writeErrorLog(map.toString()); - String contractNos = Util.null2String(map.get("contractNo")); - String[] split = contractNos.split(","); - for (String s : split) { - map.put("contractNo", s); - ResponeVo responeVo = FaDDRequestUtils.signedContract(map, apiConfigMainDTO.getApiUrl()); - Map response = null; - try { - response = responeVo.getEntityMap(); - } catch (JsonProcessingException e) { - e.printStackTrace(); - } - if (!"200".equals(response.get("code"))) { - throw new RuntimeException("法大大请求接口错误!"); - } - } - } - } + public boolean isSingedOneself(String requestId, String workflowId) { + List> maps = faDDServiceMapping.querySignedInfo(requestId, workflowId); + if (maps == null || maps.size() == 0) { + return false; + } + return true; + } - public StreamingOutput contractDownload(String requestId, String workflowId) { - toolUtil.writeErrorLog("进入service方法!"); - List> maps = null; -// 查询合同信息 - try { - maps = faDDServiceMapping.queryDetailDownInfo(requestId, workflowId, 2); - } catch (Exception e) { - toolUtil.writeErrorLog(String.valueOf(faDDServiceMapping)); - toolUtil.writeErrorLog("调用错误" + e); - } - toolUtil.writeErrorLog(String.valueOf(maps)); - toolUtil.writeErrorLog(JSONObject.toJSONString(maps)); - List> finalMaps = maps; - String versionStringByWfid = WorkflowVersion.getVersionStringByWfid(workflowId); - RecordSet rs = new RecordSet(); - rs.executeQuery("select * from uf_contract_config where workflow_type in ( " + versionStringByWfid + " ) and api_type = ?", 5); - rs.next(); - ApiConfigMainDTO apiConfigMainDTO = Util.queryApiConfig(rs.getString("params_config")); - return outputStream -> { - ZipOutputStream zipOut = new ZipOutputStream(outputStream); - toolUtil.writeErrorLog("进入方法!"); - int catchLen = 10 * 1024; - String base = ""; - for (Map map : finalMaps) { - base = base + map.get("gyshtfmczw") + "/"; -// 获取合同id - String contractNoStr = String.valueOf(map.get("contract_no")); - String contractNameStr = String.valueOf(map.get("file_name")); - String[] contractNos = contractNoStr.split(","); - String[] contractNames = contractNameStr.split(","); - for (int i = 0; i < contractNos.length; i++) { - String contractNo = contractNos[i]; - String contractName = contractNames[i]; - Map data = new HashMap<>(); - data.put("contractNo", contractNo); -// 下载合同 - String finalBase = base; - FaDDRequestUtils.downContract(data, response -> { - HttpEntity entity = response.getEntity(); - if (response.getStatusLine().getStatusCode() != 200) { - throw new RuntimeException("法大大请求接口错误!"); - } - InputStream content = null; - try { - content = entity.getContent(); - Header contentHeader = response.getFirstHeader("Content-disposition"); - String filename = contractName.substring(0, contractName.indexOf(".")) + ".pdf"; - if (contentHeader != null) { - HeaderElement[] values = contentHeader.getElements(); - NameValuePair param = values[0].getParameterByName("filename"); - filename = param.getValue(); - } - zipOut.putNextEntry(new ZipEntry(finalBase + filename)); - byte[] buffer = new byte[catchLen]; - int len = 0; - while ((len = content.read(buffer)) != -1) { - zipOut.write(buffer, 0, len); - } - zipOut.closeEntry(); - } catch (IOException e) { - e.printStackTrace(); - toolUtil.writeErrorLog("压缩错误!" + e + "\n"); - } - },apiConfigMainDTO.getApiUrl()); - } - } - zipOut.flush(); - zipOut.close(); - }; - } + public void signedContractOwn(String workflowId, String requestId) { + String mainTable = faDDServiceMapping.getMainTable(workflowId); + RecordSet rs = new RecordSet(); + String query = "select * from " + mainTable + " where requestid = ?"; + rs.executeQuery(query, requestId); + Map mainMap; + mainMap = Util.recordSet2Map(rs); + String mainId = ""; + if (mainMap != null) { + mainId = String.valueOf(mainMap.get("id")); + } else { + toolUtil.writeErrorLog("没有查询到相关的请求id的数据!"); + } + String detailTable1 = faDDServiceMapping.getDetailTable(workflowId, 4); + query = "select * from " + detailTable1 + " where mainid = ?"; + rs.executeQuery(query, mainId); + List> detailMaps; + detailMaps = Util.recordSet2MapList(rs); + this.toolUtil.writeErrorLog("查询到的数据:" + detailMaps.toString()); + if (detailMaps == null) { + toolUtil.writeErrorLog("查询明细失败!maps为null"); + return; + } + FaDaDaConfigDTO faDaDaConfigDTO = faDDServiceMapping.queryConfig(workflowId, 4); + ApiConfigMainDTO apiConfigMainDTO = Util.queryApiConfigTree(faDaDaConfigDTO.getParamsConfig()); + List> dataArr = new ArrayList<>(); + String detailTable; + String dt = detailTable1.substring(detailTable1.indexOf("_dt") + 3); + detailTable = "detail_" + dt; + toolUtil.writeErrorLog("明细表:" + detailTable); + for (Map detailMap : detailMaps) { + Map dataMap = new HashMap<>(); + for (Map.Entry entry : detailMap.entrySet()) { + dataMap.put(detailTable + "." + entry.getKey(), entry.getValue()); + } + for (Map.Entry entry : mainMap.entrySet()) { + dataMap.put("main" + "." + entry.getKey(), entry.getValue()); + } + dataArr.add(dataMap); + } + toolUtil.writeErrorLog("替换参数值:" + dataArr.toString()); + List> maps = objectAndListHandle(apiConfigMainDTO.getDetails(), dataArr); + for (Map map : maps) { + this.toolUtil.writeErrorLog("签署参数:" + map.toString()); + String contractNos = Util.null2String(map.get("contractNo")); + String[] split = contractNos.split(","); + for (String s : split) { + map.put("contractNo", s); + ResponeVo responeVo = FaDDRequestUtils.signedContract(map, apiConfigMainDTO.getApiUrl()); + Map response = null; + try { + response = responeVo.getEntityMap(); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + if (!"200".equals(response.get("code"))) { + // throw new RuntimeException("法大大请求接口错误!"); + this.toolUtil.writeErrorLog("签署参数:" + responeVo.getEntityString()); + } + } + } + } + public Map getAllVersion(String workflowId, String markOnly) { + String versionStringByWfid = WorkflowVersion.getVersionStringByWfid(workflowId); + String newWorkflowId = faDDServiceMapping.getAllVersion(versionStringByWfid); + String allVersion = WorkflowVersion.getVersionStringByWfid(newWorkflowId); + if (allVersion == null) { + allVersion = ""; + } + String[] split = allVersion.split(","); + Map data = new HashMap<>(); + String[] nodes = this.getNodes(workflowId, markOnly); + data.put("workflowIds", split); + data.put("nodeIds", nodes); + return data; + } - public boolean isAllSinged(String requestId, String workflowId) { - List> maps = faDDServiceMapping.queryDetailInfo(requestId, workflowId, 2); - if (maps == null || maps.size() == 0) { - return true; - } - return false; - } - - public boolean isSingedOneself(String requestId, String workflowId) { - List> maps = faDDServiceMapping.querySignedInfo(requestId, workflowId); - if (maps == null || maps.size() == 0) { - return false; - } - return true; - } - - public void signedContractOwn(String workflowId, String requestId) { - String mainTable = faDDServiceMapping.getMainTable(workflowId); - RecordSet rs = new RecordSet(); - String query = "select * from " + mainTable + " where requestid = ?"; - rs.executeQuery(query, requestId); - Map mainMap; - mainMap = Util.recordSet2Map(rs); - String mainId = ""; - if (mainMap != null) { - mainId = String.valueOf(mainMap.get("id")); - } else { - toolUtil.writeErrorLog("没有查询到相关的请求id的数据!"); - } - String detailTable1 = faDDServiceMapping.getDetailTable(workflowId, 4); - query = "select * from " + detailTable1 + " where mainid = ?"; - rs.executeQuery(query, mainId); - List> detailMaps; - detailMaps = Util.recordSet2MapList(rs); - this.toolUtil.writeErrorLog("查询到的数据:" + detailMaps.toString()); - if (detailMaps == null) { - toolUtil.writeErrorLog("查询明细失败!maps为null"); - return; - } - FaDaDaConfigDTO faDaDaConfigDTO = faDDServiceMapping.queryConfig(workflowId, 4); - ApiConfigMainDTO apiConfigMainDTO = Util.queryApiConfigTree(faDaDaConfigDTO.getParamsConfig()); - List> dataArr = new ArrayList<>(); - String detailTable; - String dt = detailTable1.substring(detailTable1.indexOf("_dt") + 3); - detailTable = "detail_" + dt; - toolUtil.writeErrorLog("明细表:" + detailTable); - for (Map detailMap : detailMaps) { - Map dataMap = new HashMap<>(); - for (Map.Entry entry : detailMap.entrySet()) { - dataMap.put(detailTable + "." + entry.getKey(), entry.getValue()); - } - for (Map.Entry entry : mainMap.entrySet()) { - dataMap.put("main" + "." + entry.getKey(), entry.getValue()); - } - dataArr.add(dataMap); - } - toolUtil.writeErrorLog("替换参数值:" + dataArr.toString()); - List> maps = objectAndListHandle(apiConfigMainDTO.getDetails(), dataArr); - for (Map map : maps) { - this.toolUtil.writeErrorLog("签署参数:" + map.toString()); - String contractNos = Util.null2String(map.get("contractNo")); - String[] split = contractNos.split(","); - for (String s : split) { - map.put("contractNo", s); - ResponeVo responeVo = FaDDRequestUtils.signedContract(map,apiConfigMainDTO.getApiUrl()); - Map response = null; - try { - response = responeVo.getEntityMap(); - } catch (JsonProcessingException e) { - e.printStackTrace(); - } - if (!"200".equals(response.get("code"))) { -// throw new RuntimeException("法大大请求接口错误!"); - this.toolUtil.writeErrorLog("签署参数:" + responeVo.getEntityString()); - } - } - } - } - - public Map getAllVersion(String workflowId, String markOnly) { - String versionStringByWfid = WorkflowVersion.getVersionStringByWfid(workflowId); - String newWorkflowId = faDDServiceMapping.getAllVersion(versionStringByWfid); - String allVersion = WorkflowVersion.getVersionStringByWfid(newWorkflowId); - if (allVersion == null) { - allVersion = ""; - } - String[] split = allVersion.split(","); - Map data = new HashMap<>(); - String[] nodes = this.getNodes(workflowId, markOnly); - data.put("workflowIds", split); - data.put("nodeIds", nodes); - return data; - } - - public String[] getNodes(String workflowId, String markOnly) { - String versionStringByWfid = WorkflowVersion.getVersionStringByWfid(workflowId); - String nods = faDDServiceMapping.getNodes(versionStringByWfid, markOnly); - if (nods == null) { - nods = ""; - } - return nods.split(","); - } + public String[] getNodes(String workflowId, String markOnly) { + String versionStringByWfid = WorkflowVersion.getVersionStringByWfid(workflowId); + String nods = faDDServiceMapping.getNodes(versionStringByWfid, markOnly); + if (nods == null) { + nods = ""; + } + return nods.split(","); + } } - - - - diff --git a/com/api/aiyh_pcn/fadada/web/FaDDContractController.java b/com/api/aiyh_pcn/fadada/web/FaDDContractController.java index 7794381..ce7b534 100644 --- a/com/api/aiyh_pcn/fadada/web/FaDDContractController.java +++ b/com/api/aiyh_pcn/fadada/web/FaDDContractController.java @@ -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 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 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 params) { + toolUtil.writeErrorLog("回调方法,获取到的请求参数:" + JSON.toJSONString(params)); + Map 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 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 params) { - toolUtil.writeErrorLog("回调方法,获取到的请求参数:" + JSON.toJSONString(params)); - Map 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 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(); + } + } } diff --git a/com/api/aiyh_pcn/fadada/web/FaDDController.java b/com/api/aiyh_pcn/fadada/web/FaDDController.java index a60a323..3efd425 100644 --- a/com/api/aiyh_pcn/fadada/web/FaDDController.java +++ b/com/api/aiyh_pcn/fadada/web/FaDDController.java @@ -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 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 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 params) { - try { - Map 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 params) { + try { + Map 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 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 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 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 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 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 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 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 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 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 params) { + toolUtil.writeErrorLog("回调方法:" + JSONObject.toJSONString(params)); + Map 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 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 params){ - toolUtil.writeErrorLog("回调方法:" + JSONObject.toJSONString(params)); - Map 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); + } } diff --git a/com/api/aiyh_pcn/patentWall/dao/PatentWallMapping.java b/com/api/aiyh_pcn/patentWall/dao/PatentWallMapping.java index b513683..8d153a8 100644 --- a/com/api/aiyh_pcn/patentWall/dao/PatentWallMapping.java +++ b/com/api/aiyh_pcn/patentWall/dao/PatentWallMapping.java @@ -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> getAllList(String tableName){ - RecordSet rs = new RecordSet(); - String query = "select * from " + tableName; - rs.executeQuery(query); - return Util.recordSet2MapList(rs); - } + public List> getAllList(String tableName) { + RecordSet rs = new RecordSet(); + String query = "select * from " + tableName; + rs.executeQuery(query); + return Util.recordSet2MapList(rs); + } - public List> getListByFilterWhere(StringBuilder whereBuilder,List 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> getListByFilterWhere(StringBuilder whereBuilder, List 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> 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> 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); + } } diff --git a/com/api/aiyh_pcn/patentWall/service/PatentWallService.java b/com/api/aiyh_pcn/patentWall/service/PatentWallService.java index d4f8a99..7402847 100644 --- a/com/api/aiyh_pcn/patentWall/service/PatentWallService.java +++ b/com/api/aiyh_pcn/patentWall/service/PatentWallService.java @@ -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 patentWallConf; - private Map patentWallSearchConf; - private final RecordSet rs = new RecordSet(); + private final PatentWallMapping patentWallMapping = new PatentWallMapping(); + private final ToolUtil toolUtil = new ToolUtil(); + private Map patentWallConf; + private Map patentWallSearchConf; + private final RecordSet rs = new RecordSet(); + /** + * 查询搜索框配置信息 + * + * @param prefix 前缀 + * @return 配置信息 + */ + public List getSearchList(String prefix, int languageId) { + Map patentWallSearchConf = getPatentWallSearchConf(prefix + ".search"); + String dataResource = String.valueOf(patentWallSearchConf.get("dataResource")); + List> inputs = + (List>) patentWallSearchConf.get("inputs"); + List searchInputList = new ArrayList<>(); + for (Map 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 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 getSearchList(String prefix,int languageId) { - Map patentWallSearchConf = getPatentWallSearchConf(prefix + ".search"); - String dataResource = String.valueOf(patentWallSearchConf.get("dataResource")); - List> inputs = (List>) patentWallSearchConf.get("inputs"); - List searchInputList = new ArrayList<>(); - for (Map 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 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 getSelectOptions( + String dataResource, String dbFieldName, int languageId) { + List> selectOptions = + patentWallMapping.getSelectOptions(dataResource, dbFieldName); + List optionsVos = new ArrayList<>(); + SelectOptionsVo optionsDefault = new SelectOptionsVo(); + optionsDefault.setSelected(true); + optionsDefault.setKey(""); + optionsDefault.setShowname(""); + optionsVos.add(optionsDefault); + for (Map 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 + " )(?