Commit e146b07e authored by 5359's avatar 5359

正式环境参数修改

parent e069945b
......@@ -5,6 +5,8 @@ import com.hand.app.esignHclc.dto.SignUserAttachInfo;
import com.hand.app.esignHclc.dto.SignUserInfoHclc;
import com.hand.app.esignHclc.dto.SignUserFaceHclc;
import com.hand.app.esignHclc.dto.SignUserInfoHclcHis;
import com.hand.app.esignHclc.mapper.SignInfoHclcMapper;
import com.hand.app.esignHclc.mapper.SignUserInfoHclcHisMapper;
import com.hand.app.esignHclc.service.*;
import com.hand.hap.core.IRequest;
import com.hand.hap.system.controllers.BaseController;
......@@ -36,6 +38,10 @@ public class SignHclcController extends BaseController {
@Autowired
private ISignUserInfoHclcHisService signUserInfoHclcHisService;
@Autowired
private SignInfoHclcMapper signInfoHclcMapper;
@Autowired
private SignUserInfoHclcHisMapper signUserInfoHclcHisMapper;
@Autowired
private ISignUserAttachInfoService iSignUserAttachInfoService;
......@@ -51,9 +57,13 @@ public class SignHclcController extends BaseController {
public ResponseData query(HttpServletRequest request, SignUserInfoHclc dto) {
IRequest requestContext = createRequestContext(request);
List<SignUserInfoHclc> signInfoHclcs = new ArrayList<>();
String openId = dto.getOpenId();
SignUserInfoHclc signInfoHclc = signHclcService.selectByPrimaryKey(requestContext, dto);
if (Objects.nonNull(signInfoHclc)) {
//设置用户信息是否为历史备份信息
signInfoHclc.setHistoryFlag("N");
//获取人脸核验状态
if (Objects.nonNull(signInfoHclc.getFaceAuthId())) {
SignUserFaceHclc signInfoHclcFace = new SignUserFaceHclc();
......@@ -90,6 +100,24 @@ public class SignHclcController extends BaseController {
signInfoHclc.setOrgAttachmentId(signUserAttachInfos.get(0).getAttachmentIdHclc().toString());
}
}
} else {
//查询是否存在历史注册信息,用于合同查看、文件下载
List<SignUserInfoHclcHis> userInfoHclcHisList = new ArrayList<>();
SignUserInfoHclcHis signUserInfoHclcHis = new SignUserInfoHclcHis();
signUserInfoHclcHis.setOpenId(openId);
signUserInfoHclcHis.setAuthFlag("Y");
userInfoHclcHisList = signUserInfoHclcHisMapper.select(signUserInfoHclcHis);
if (userInfoHclcHisList.size() > 0) {
signInfoHclc = new SignUserInfoHclc();
//取历史注册信息中最后的一期
Optional<SignUserInfoHclcHis> maxResult = userInfoHclcHisList.stream().max(Comparator.comparing(SignUserInfoHclcHis::getHisId));
if (maxResult.isPresent()) {
signUserInfoHclcHis = maxResult.get();
BeanUtils.copyProperties(signUserInfoHclcHis, signInfoHclc);
signInfoHclc.setHistoryFlag("Y");
}
}
}
if (signInfoHclc != null) {
......@@ -222,6 +250,7 @@ public class SignHclcController extends BaseController {
map = signHclcService.deletePersonAccount(iRequest, agentSignInfo);
if ("0".equalsIgnoreCase(map.get("code").toString()) || "40051667".equalsIgnoreCase(map.get("code").toString()) || "000003".equalsIgnoreCase(map.get("code").toString())) {
signHclcService.deleteByPrimaryKey(dto);
map.put("code", "0");
} else {
signHclcService.updateByPrimaryKey(iRequest, dto);
}
......@@ -231,6 +260,7 @@ public class SignHclcController extends BaseController {
map = signHclcService.deletePersonAccount(iRequest, dto);
if ("0".equalsIgnoreCase(map.get("code").toString()) || "40051667".equalsIgnoreCase(map.get("code").toString()) || "000003".equalsIgnoreCase(map.get("code").toString())) {
signHclcService.deleteByPrimaryKey(dto);
map.put("code", "0");
}
}
......@@ -340,4 +370,50 @@ public class SignHclcController extends BaseController {
// @RequestBody(required = true) JSONObject params) {
// return signHclcService.cancelSignFlows(createRequestContext(request), params);
// }
/**
* 电子合同消息发送
*/
@RequestMapping(value = "/send/wx/message", method = RequestMethod.POST)
@ResponseBody
public JSONObject sendWxTemplateMsg(HttpServletRequest request, @RequestBody(required = true) JSONObject params) {
JSONObject json = new JSONObject();
try {
//根据客户名称,证件号码获取对应的openId信息
String idNo = params.getString("idNo");
String name = params.getString("name");
String openId = null;
SignUserInfoHclc signInfoHclc = new SignUserInfoHclc();
List<SignUserInfoHclc> infoHclcs = new ArrayList<>();
signInfoHclc.setName(name);
signInfoHclc.setIdNo(idNo);
infoHclcs = signInfoHclcMapper.select(signInfoHclc);
if (infoHclcs.size() > 0) {
openId = infoHclcs.get(0).getOpenId();
} else {
//查询历史注册信息
SignUserInfoHclcHis signUserInfoHclcHis = new SignUserInfoHclcHis();
List<SignUserInfoHclcHis> userInfoHclcHisList = new ArrayList<>();
signUserInfoHclcHis.setName(name);
signUserInfoHclcHis.setIdNo(idNo);
userInfoHclcHisList = signUserInfoHclcHisMapper.select(signUserInfoHclcHis);
if (userInfoHclcHisList.size() > 0) {
openId = userInfoHclcHisList.get(0).getOpenId();
}
}
if (openId != null) {
params.put("openId", openId);
}
json = signHclcService.sendWxTemplateMsg(params);
} catch (Exception e) {
json.put("code", "000002");
json.put("message", "微信消息发送失败");
e.printStackTrace();
}
return json;
}
}
......@@ -87,6 +87,9 @@ public class SignUserInfoHclc extends BaseDTO {
@Transient
private String mediaId;//微信图片资源id
@Transient
private String historyFlag;//微信图片资源id
public AttachmentInfo getAttachmentInfo() {
return attachmentInfo;
}
......@@ -366,4 +369,12 @@ public class SignUserInfoHclc extends BaseDTO {
public void setSealId(String sealId) {
this.sealId = sealId;
}
public String getHistoryFlag() {
return historyFlag;
}
public void setHistoryFlag(String historyFlag) {
this.historyFlag = historyFlag;
}
}
......@@ -40,4 +40,6 @@ public interface ISignInfoHclcService extends IBaseService<SignUserInfoHclc>, Pr
// JSONObject cancelSignFlows(IRequest requestContext, JSONObject params);
void postSignFlowsResult(IRequest iRequest, JSONObject params);
JSONObject sendWxTemplateMsg(JSONObject json);
}
......@@ -45,6 +45,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.io.*;
import java.util.*;
......@@ -89,6 +91,7 @@ public class SignInfoHclcServiceImpl extends BaseServiceImpl<SignUserInfoHclc> i
//公众号接口信息
public static final String wxSysName = "wxgzh_hitachics";
public static final String wxDownLoadApiName = "media_download";
public static final String wxSendTemplateApiName = "sendTemplate";
//业务系统接口信息
public static final String hclcSysName = "HCL_UPLOAD_FILE";
public static final String hclcUpLoadApiName = "upload";
......@@ -698,6 +701,54 @@ public class SignInfoHclcServiceImpl extends BaseServiceImpl<SignUserInfoHclc> i
return inputStream;
}
/***
* 发送微信模板消息;
* @param json
***/
public JSONObject sendWxTemplateMsg(JSONObject json) {
JSONObject result = new JSONObject();
if (json.getString("templateId") == null || json.getString("first") == null || json.getString("openId") == null) {
result.put("errCode", "000001");
result.put("msg", "message data is empty or templateId is empty or target user is empty");
return result;
}
//设置接口参数
JSONObject parameters = new JSONObject();
parameters.put("apiKey", apiKey);
parameters.put("templateId", json.getString("templateId"));
parameters.put("toUser", json.getString("openId"));
parameters.put("first", json.getString("first"));
parameters.put("keyword1", json.getString("keyword1"));
parameters.put("keyword2", json.getString("keyword2"));
parameters.put("keyword3", json.getString("keyword3"));
parameters.put("keyword4", json.getString("keyword4"));
parameters.put("keyword5", json.getString("keyword5"));
parameters.put("remark", json.getString("remark"));
parameters.put("url", json.getString("url"));
//初始化接口信息
String url = getApiUrl(wxSysName, wxSendTemplateApiName);
logger.debug("upload url: {}", url);
//发送http请求
SignHclcUtils signHclcUtils1 = new SignHclcUtils();
String stringResult = signHclcUtils1.postString(url, parameters, null, signHclcUtils1.APPLICATION_JSON);
//解析返回结果
JSONObject jsonResult = JSONObject.parseObject(stringResult);
if ("00".equalsIgnoreCase(jsonResult.getString("resultCode"))) {
result.put("code", "0");
result.put("message", "微信消息发送成功!");
} else {
logger.error("send wx message failed, errCode:{} ,msg:{}", jsonResult.getString("resultCode"), jsonResult.getString("resultMessage"));
result.put("code", jsonResult.getString("resultCode"));
result.put("message", "微信消息发送失败," + jsonResult.getString("resultMessage"));
}
return result;
}
// public String uploadFileToHclc(String filePath, AttachmentInfo info) {
// //todo upload file
......@@ -1182,51 +1233,43 @@ public class SignInfoHclcServiceImpl extends BaseServiceImpl<SignUserInfoHclc> i
// }
}
// //判断文字签字印章自定义模板是否存在
// if (Objects.nonNull(signInfoHclc.getSealId()) && !"-1".equalsIgnoreCase(signInfoHclc.getSealId())) {
// //获取签署文档信息
// JSONArray signDocDetails = json1.getJSONArray("signDocDetails");
// JSONArray signDocDetailsNew = new JSONArray();
// //解析签署文档信息
// for (int j = 0; j < signDocDetails.size(); j++) {
// JSONObject detail = signDocDetails.getJSONObject(j);
//
// //获取签署位置信息
// JSONArray signPos = detail.getJSONArray("signPos");
// JSONArray signPosNew = new JSONArray();
//
// for (int k = 0; k < signPos.size(); k++) {
// JSONObject pos = signPos.getJSONObject(k);
//
// //个人签字统一更换签字模板
// if (signInfoHclc.getCtitype().compareTo(1L) == 0) {
// pos.remove("sealId");
// pos.put("sealId", signInfoHclc.getSealId());
// } else {
// //企业签字判断是否存在PERSON签字,更换签字模板
// String signIdentity = pos.getString("signIdentity");
// if ("PERSON".equalsIgnoreCase(signIdentity)) {
// pos.remove("sealId");
// pos.put("sealId", signInfoHclc.getSealId());
// }
// }
//
// signPosNew.add(pos);
// }
//
// detail.remove("signPos");
// detail.put("signPos", signPosNew);
//
// signDocDetailsNew.add(detail);
// }
//
// json1.remove("signDocDetails");
// json1.put("signDocDetails", signDocDetailsNew);
//
// }
//判断文字签字印章自定义模板是否存在并且自动落章
if (json1.getBooleanValue("autoSign") && Objects.nonNull(signInfoHclc.getSealId()) && !"-1".equalsIgnoreCase(signInfoHclc.getSealId())) {
//获取签署文档信息
JSONArray signDocDetails = json1.getJSONArray("signDocDetails");
JSONArray signDocDetailsNew = new JSONArray();
//解析签署文档信息
for (int j = 0; j < signDocDetails.size(); j++) {
JSONObject detail = signDocDetails.getJSONObject(j);
// }
//获取签署位置信息
JSONArray signPos = detail.getJSONArray("signPos");
JSONArray signPosNew = new JSONArray();
for (int k = 0; k < signPos.size(); k++) {
JSONObject pos = signPos.getJSONObject(k);
//个人签字统一更换签字模板
if (signInfoHclc.getCtitype().compareTo(1L) == 0) {
pos.put("sealId", signInfoHclc.getSealId());
} else {
//企业签字判断是否存在PERSON签字,更换签字模板
String signIdentity = pos.getString("signIdentity");
if ("PERSON".equalsIgnoreCase(signIdentity)) {
pos.put("sealId", signInfoHclc.getSealId());
}
}
signPosNew.add(pos);
}
detail.put("signPos", signPosNew);
signDocDetailsNew.add(detail);
}
json1.put("signDocDetails", signDocDetailsNew);
}
json1.put("accountType", "2");
json1.remove("idNo");
......@@ -1260,7 +1303,7 @@ public class SignInfoHclcServiceImpl extends BaseServiceImpl<SignUserInfoHclc> i
result.put("subject", params.get("subject"));
//一键落章
result.put("signSceneNo", "QSCJ0001");
// result.put("signSceneNo", "QSCJ0001");
JSONObject json = new JSONObject(result);
String param = json.toString();
......@@ -1359,16 +1402,25 @@ public class SignInfoHclcServiceImpl extends BaseServiceImpl<SignUserInfoHclc> i
signFlowsInfoHclc.setContractNo(params.getString("bizNo"));
signFlowsInfoHclc.setSendFlag("N");
//初始化调用文件下载判断
// boolean downloadFlag = false;
//插入接口请求日志
signFlowsInfoHclc = iSignFlowsInfoHclcService.insertSelective(iRequest, signFlowsInfoHclc);
if ("2".equalsIgnoreCase(params.getString("status"))) {
//签署终结状态回调,获取所有签署流程文档下载地址
if ("SIGN_FLOW_FINISH".equalsIgnoreCase(params.getString("action"))) {
// if ("SIGN_FLOW_FINISH".equalsIgnoreCase(params.getString("action"))) {
Map<String, Object> map = new HashMap<>();
//获取文件下载url
map = getSignFlowDocUrls(signFlowsInfoHclc.getSignFlowId());
params.remove("finishDocUrlBeans");
params.put("finishDocUrlBeans", map.get("signDocUrlList"));
// downloadFlag = true;
}
// } else
//角色签署完成状态回调,替换用户信息
} else if ("SIGN_FLOW_UPDATE".equalsIgnoreCase(params.getString("action"))) {
if ("SIGN_FLOW_UPDATE".equalsIgnoreCase(params.getString("action"))) {
JSONObject accountInfo = params.getJSONObject("accountInfo");
SignUserInfoHclc signUserInfoHclc = new SignUserInfoHclc();
//判断是否机构用户
......@@ -1377,18 +1429,23 @@ public class SignInfoHclcServiceImpl extends BaseServiceImpl<SignUserInfoHclc> i
} else {
signUserInfoHclc.setAccountId(accountInfo.getString("authOrgId"));
}
JSONObject accountInfoNew = new JSONObject();
// if ("cab73322-8924-11ea-b71a-ec0d9ad45bf8".equalsIgnoreCase(signUserInfoHclc.getAccountId())) {
// accountInfoNew.put("ctino", "");
// accountInfoNew.put("name", "日立建机");
// } else {
//获取移动端用户信息
signUserInfoHclc = signInfoHclcMapper.selectOne(signUserInfoHclc);
//承租人签署流程 建机自动签完获取下载地址并下载
// if ("1".equalsIgnoreCase(signUserInfoHclc.getOpenId())) {
// Map<String, Object> map = new HashMap<>();
// //获取文件下载url
// map = getSignFlowDocUrls(signFlowsInfoHclc.getSignFlowId());
// params.put("finishDocUrlBeans", map.get("signDocUrlList"));
// downloadFlag = true;
// }
//设置hclc报文用户信息
accountInfoNew.put("ctino", signUserInfoHclc.getIdNo());
accountInfoNew.put("name", signUserInfoHclc.getName());
// }
params.remove("accountInfo");
params.put("accountInfo", accountInfoNew);
}
......@@ -1420,7 +1477,8 @@ public class SignInfoHclcServiceImpl extends BaseServiceImpl<SignUserInfoHclc> i
//签署终结状态回调,签署完成下载签署文件
if ("SIGN_FLOW_FINISH".equalsIgnoreCase(params.getString("action"))) {
if ("2".equalsIgnoreCase(params.getString("status"))) {
// if (downloadFlag) {
//初始化签署文件下载接口信息
String signUrl = getApiUrl(hclcSysName, signFileDownApiName);
logger.debug("sign flow url: {}", url);
......@@ -1437,6 +1495,7 @@ public class SignInfoHclcServiceImpl extends BaseServiceImpl<SignUserInfoHclc> i
logger.error("down sign file failed, errCode:{} ,msg:{}", jsonResult2.getJSONObject("error").getString("code"), jsonResult2.getJSONObject("error").getString("message"));
}
}
// }
} catch (Exception e) {
logger.error("post sign flow failed ,msg:{}", e.getMessage());
......
......@@ -117,9 +117,9 @@ public class SignHclcUtils {
inStream.close();
result = strber.toString();
if (httpResponse.getStatusLine().getStatusCode() == 200) {
logger.info("请求服务器成功, urls ={},params ={} ,contentType ={}", urls, params.toString(), contentType);
logger.info("请求服务器成功, urls ={},params ={} ,contentType ={} ,result ={}", urls, params.toString(), contentType, result);
} else {
logger.info("请求服务端失败, urls ={},params ={} ,contentType ={}", urls, params.toString(), contentType);
logger.info("请求服务端失败, urls ={},params ={} ,contentType ={} ,result ={}", urls, params.toString(), contentType, result);
}
return result;
......@@ -299,6 +299,9 @@ public class SignHclcUtils {
e2.printStackTrace();
}
}
logger.info("请求服务端成功, url ={},param ={}", url, param);
return result;
}
......@@ -347,6 +350,8 @@ public class SignHclcUtils {
if (Objects.nonNull(res.get("words_result").toString())) {
jsonObject = getJsonResult(res);
}
logger.info("OCR身份证识别成功, result ={}", jsonObject.toString());
return jsonObject;
}
......@@ -366,6 +371,11 @@ public class SignHclcUtils {
if (Objects.nonNull(res.get("words_result").toString())) {
jsonObject = getJsonResult(res);
}
if (Objects.nonNull(jsonObject.getString("社会信用代码"))) {
jsonObject.put("社会信用代码", jsonObject.getString("社会信用代码").substring(0, 18));
}
logger.info("OCR营业执照识别识别成功, result ={}", jsonObject.toString());
return jsonObject;
}
......
......@@ -11,6 +11,24 @@
</encoder>
</appender>
<appender name="REQ" class="ch.qos.logback.classic.sift.SiftingAppender">
<discriminator>
<key>logName</key>
<defaultValue>default</defaultValue>
</discriminator>
<sift>
<appender name="REQ-${logName}" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%X{userId}] [%X{requestId}] %logger - %msg%n</pattern>
</encoder>
<file>${catalina.base}/logs/hls-${logName}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${catalina.base}/logs/%d{yyyy-MM-dd}/hls-${logName}.log</fileNamePattern>
</rollingPolicy>
</appender>
</sift>
</appender>
<!-- <appender name="PLATFORM-FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%X{accountId}] [%X{requestId}] %logger - %msg%n</pattern>
......@@ -62,7 +80,7 @@
<appender-ref ref="STDOUT"/>
</logger>
<logger name="com.hand.app.esignHclc.utils.SignHclcUtils" level="INFO" additivity="false">
<appender-ref ref="STDOUT"/>
<appender-ref ref="REQ"/>
</logger>
<logger name="com.timevale" level="INFO" additivity="false">
<appender-ref ref="STDOUT"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment