Commit 60a91d94 authored by 廖旭伟's avatar 廖旭伟

微中台数据转换功能:食品经营许可证转证照,企业法人查询

parent 88bec448
package com.mortals.xhx.module.mid.pdu;
import lombok.Data;
/**
* 业务回执数据
*/
@Data
public class BizRet {
/** 结果编码 */
private String ifResult;
/** 结果信息JSON字符串 */
private String ifResultInfo;
}
package com.mortals.xhx.module.mid.pdu;
import lombok.Data;
/**
* 微中台证照接口返回证照信息
*/
@Data
public class CertificateSurface {
/** 项目列名称 */
private String columnName;
/** 项目名称 */
private String name;
/** 项目值 */
private String value;
/** 值类型 */
private String valueType;
}
package com.mortals.xhx.module.mid.pdu;
import lombok.Data;
import java.util.List;
/**
* 微中台证照接口返回证照数据
*/
@Data
public class MidCertificateDataVO {
/** 证照类型 */
private String certificateType;
/** 证照名称 */
private String certificateName;
/** 证照持有者 */
private String certificateHolder;
/** 证照持有者编码 */
private String certificateHolderCode;
/** 证照持有者类型 */
private String certificateHolderType;
/** 发证机关 */
private String issueDept;
/** 发证机关单位编码 */
private String issueDeptCode;
/** 证照编号 */
private String certificateNumber;
/** 证照类型编码 */
private String certificateTypeCode;
/** 发证时间 */
private String issueDate;
/** 证照有效期开始时间 */
private String certificateValidateStart;
/** 证照有效期截止时间 */
private String certificateValidateEnd;
/** 证照照面信息 */
private List<CertificateSurface> surface;
}
package com.mortals.xhx.module.mid.pdu;
import lombok.Data;
@Data
public class MidCertificatePdu {
/** 证照持有者编码 */
private String certificateHolderCode;
/** 证照持有者类型 */
private String certificateHolderType;
/** 证照类型 */
private String certificateType;
/** 证照编号 */
private String certificateNumber;
/** 使用说明 */
private String useFor;
/*** 取件人姓名 */
private String pickerName;
/** 取件人证件号码 */
private String pickerIDCardNo;
/** 二维码地址 */
private String qRCodeUrl;
}
package com.mortals.xhx.module.mid.pdu;
import lombok.Data;
@Data
public class MidIfResultInfo {
private MidIfResultInfoHead head;
private MidIfResultInfoData data;
}
package com.mortals.xhx.module.mid.pdu;
import com.alibaba.fastjson.JSONPObject;
import lombok.Data;
import java.util.List;
@Data
public class MidIfResultInfoData {
private int total;
private List<MidCertificateDataVO> dataList;
private List<JSONPObject> detail;
}
package com.mortals.xhx.module.mid.pdu;
import lombok.Data;
@Data
public class MidIfResultInfoHead {
private String message;
private String status;
}
package com.mortals.xhx.module.mid.pdu;
import lombok.Data;
/**
* 微中台响应数据
*/
@Data
public class MidResponseData {
/** 响应编码 */
private String code;
/** 响应消息 */
private String msg;
/** 业务回执数据 */
private BizRet bizRet;
}
package com.mortals.xhx.module.mid.web;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.util.DateUtils;
import com.mortals.framework.web.BaseJsonBodyController;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.mid.MidReq;
import com.mortals.xhx.feign.mid.IMidFeign;
import com.mortals.xhx.module.certificate.model.CertificateCatalogEntity;
import com.mortals.xhx.module.certificate.model.CertificateCatalogQuery;
import com.mortals.xhx.module.certificate.pdu.ApplyLogPdu;
import com.mortals.xhx.module.certificate.service.CertificateCatalogService;
import com.mortals.xhx.module.mid.pdu.*;
import com.mortals.xhx.module.record.service.ApplyLogService;
import org.apache.commons.lang.StringEscapeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 微中台数据对接
*/
@RestController
@RequestMapping("mid")
public class DataInterfaceController extends BaseJsonBodyController {
@Autowired
private IMidFeign iMidFeign;
@Autowired
private ApplyLogService applyLogService;
@Autowired
private CertificateCatalogService certificateCatalogService;
@PostMapping({"certificate/spjyxkz"})
@UnAuth
public String spjyxkz(@RequestBody MidCertificatePdu midCertificatePdu){
JSONObject ret = new JSONObject();
Map<String, Object> model = new HashMap();
byte code = 1;
String busiDesc = "调用微中台接口生成证照";
try {
MidReq midReq = new MidReq();
midReq.setMethod("get");
midReq.setType(1);
midReq.setPath("/api/edge-service-agent/1.0/c8f85e91dd297c38/zzcxxfw");
JSONObject body = new JSONObject();
body.put("CertificateHolderCode",midCertificatePdu.getCertificateHolderCode());
body.put("CertificateHolderType",midCertificatePdu.getCertificateHolderType());
body.put("CertificateType",midCertificatePdu.getCertificateType());
body.put("CertificateNumber",midCertificatePdu.getCertificateNumber());
body.put("UseFor",midCertificatePdu.getUseFor());
midReq.setBody(body.toJSONString());
Rest<String> rest = iMidFeign.trans(midReq);
if(rest.getCode()==1){
//String restMsg = StringEscapeUtils.unescapeJava(rest.getMsg());
MidResponseData midResponseData = JSONObject.parseObject(rest.getMsg(),MidResponseData.class);
if(midResponseData.getCode().equals("SUCCESS") && midResponseData.getBizRet().getIfResult().equals("0")){
MidIfResultInfo midIfResultInfo = JSONObject.parseObject(midResponseData.getBizRet().getIfResultInfo(),MidIfResultInfo.class);
if(midIfResultInfo.getHead().getStatus().equals("0")){
for(MidCertificateDataVO vo:midIfResultInfo.getData().getDataList()){
ApplyLogPdu applyLogPdu = new ApplyLogPdu();
//applyLogPdu.setCatalogId();
applyLogPdu.setCertificateCode(vo.getCertificateNumber());
applyLogPdu.setCertificateName(vo.getCertificateName());
applyLogPdu.setIssueTime(DateUtils.StrToDateTime(vo.getIssueDate(),"yyyy年MM月dd日"));
applyLogPdu.setEnterpriseName(vo.getCertificateHolder());
applyLogPdu.setPrivateID(vo.getCertificateNumber());
String iDCardNo = getIDCardNo(midCertificatePdu.getCertificateHolderCode());
applyLogPdu.setPickerIDCardNo(iDCardNo); //取件人身份证号码
if(vo.getCertificateHolderType().equals("001")) {
applyLogPdu.setHolderType(2); //持有者类型,1:自然人,2:法人,3:自然人法人
applyLogPdu.setHolderIdType(2); //持有者证件类型,1:身份证,2:组织机构代码等
}else {
applyLogPdu.setHolderType(1);
applyLogPdu.setHolderIdType(1);
}
applyLogPdu.setHolderName(vo.getCertificateHolder());
applyLogPdu.setHolderIDCardNo(vo.getCertificateHolderCode());
JSONObject formContentJson = new JSONObject();
for (CertificateSurface item:vo.getSurface()){
//System.out.println(JSONObject.toJSON(item).toString());
if(item.getColumnName().equals("KZ_JingYingZheMingChen")){
formContentJson.put("i_1_经营者名称",item.getValue());
}
if(item.getColumnName().equals("KZ_XuKeZhengBianHao")){
formContentJson.put("i_2_许可证编号",item.getValue());
}
if(item.getColumnName().equals("KZ_SHXYDMSFZHM")){
formContentJson.put("i_3_社会信用代码(身份证号码)",item.getValue());
}
if(item.getColumnName().equals("KZ_RiChangJianDuGuanLiJiGou")){
formContentJson.put("i_4_日常监督管理机构",item.getValue());
}
if(item.getColumnName().equals("KZ_FaDingDaiBiaoRenFuZeRen")){
formContentJson.put("i_5_法定代表人(负责人)",item.getValue());
applyLogPdu.setPickerName(item.getValue());
}
if(item.getColumnName().equals("KZ_RiChangJianDuGuanLiRenYuan")){
formContentJson.put("i_6_日常监督管理人员",item.getValue());
}
if(item.getColumnName().equals("KZ_ZhuSuo")){
formContentJson.put("i_7_住所",item.getValue());
}
if(item.getColumnName().equals("KZ_JingYingChangSuo")){
formContentJson.put("i_8_经营场所",item.getValue());
}
if(item.getColumnName().equals("KZ_ZhuTiYeTai")){
formContentJson.put("i_9_主体业态",item.getValue());
}
if(item.getColumnName().equals("KZ_JingYingXiangMu")){
formContentJson.put("i_10_经营项目",item.getValue());
}
if(item.getColumnName().equals("KZ_FaZhengRiQi")){
formContentJson.put("i_11_发证日期",item.getValue());
}
if(item.getColumnName().equals("KZ_YouXiaoQiZhi")){
formContentJson.put("i_12_有效期至",item.getValue());
}
if(item.getColumnName().equals("KZ_TouSuJuBaoDianHua")){
formContentJson.put("i_13_投诉电话",item.getValue());
}
if(item.getColumnName().equals("KZ_FaZhengJiGuan")){
formContentJson.put("i_14_发证机关",item.getValue());
}
if(item.getColumnName().equals("KZ_QianFaRen")){
formContentJson.put("i_15_签发人",item.getValue());
}
}
//二维码地址
formContentJson.put("@qrcode_1_二维码","");
applyLogPdu.setFormContent(formContentJson.toJSONString());
applyLogService.midSaveApplyLog(applyLogPdu,1l);
ret.put("data",applyLogPdu);
model.put("message_info", "生成证照成功");
}
}else {
code = -1;
model.put("message_info", midIfResultInfo.getHead().getMessage());
}
}else {
code = -1;
model.put("message_info", "微中台食品经营许可证查询接口调用失败");
}
}else {
code = -1;
model.put("message_info", "微中台透传接口调用失败");
}
this.recordSysLog(this.request, busiDesc + " 【成功】");
}catch (Exception e){
code = -1;
model.put("message_info", "生成证照发生异常");
if(e instanceof AppException){
model.put("message_info", e.getMessage());
}
this.doException(this.request, busiDesc, model, e);
}
ret.put("code", Integer.valueOf(code));
ret.put("msg", model.remove("message_info"));
return ret.toJSONString();
}
private String getIDCardNo(String creditNo){
String iDCardNo = "";
try{
MidReq midReq = new MidReq();
midReq.setMethod("post");
midReq.setType(1);
midReq.setPath("/api/edge-service-agent/v1.0/f8f532513c862c43/qyjbxxjk");
JSONObject body = new JSONObject();
body.put("resourceId","1395585204949856258");
JSONObject param = new JSONObject();
param.put("creditNo",creditNo);
body.put("param",param);
midReq.setBody(body.toJSONString());
Rest<String> rest = iMidFeign.trans(midReq);
if(rest.getCode()==1) {
//String restMsg = StringEscapeUtils.unescapeJava(rest.getMsg());
JSONObject responseData = JSONObject.parseObject(rest.getMsg());
if(responseData.getString("code").equals("SUCCESS")){
JSONObject bizRet = responseData.getJSONObject("bizRet");
if(bizRet.getString("code").equals("SUCCESS")){
JSONObject _bizRet = bizRet.getJSONObject("bizRet");
JSONArray dataList = _bizRet.getJSONArray("data");
iDCardNo = dataList.getJSONObject(0).getString("fddbrzjhm");
}
}
}
}catch (Exception ex){
log.error("调用微中台接口查询营业执照信息出错",ex);
}
return iDCardNo;
}
public static void main(String[] agrs){
String msg = "{\"msg\":\"\",\"code\":\"SUCCESS\",\"bizRet\":{\"ifResult\":\"0\",\"ifResultInfo\":\"{\\\"head\\\":{\\\"message\\\":\\\"接口调用成功\\\",\\\"status\\\":\\\"0\\\"},\\\"data\\\":{\\\"total\\\":1,\\\"dataList\\\":[{\\\"certificateType\\\":\\\"食品经营许可证\\\",\\\"certificateName\\\":\\\"食品经营许可证\\\",\\\"certificateHolder\\\":\\\"宜宾市叙州区蟹先生餐饮店\\\",\\\"certificateHolderCode\\\":\\\"92511521MA69MX6A6C\\\",\\\"certificateHolderType\\\":\\\"001\\\",\\\"issueDept\\\":\\\"宜宾市市场监督管理局\\\",\\\"issueDeptCode\\\":\\\"11511200008702664Y\\\",\\\"certificateNumber\\\":\\\"JY25115210069695\\\",\\\"certificateTypeCode\\\":\\\"11100000MB0143028R026\\\",\\\"issueDate\\\":\\\"2022年10月11日\\\",\\\"certificateValidateStart\\\":\\\"2022年10月11日\\\",\\\"certificateValidateEnd\\\":\\\"2027年10月10日\\\",\\\"surface\\\":[{\\\"columnName\\\":\\\"KZ_FaZhengJiGuan\\\",\\\"name\\\":\\\"发证机关\\\",\\\"value\\\":\\\"宜宾市市场监督管理局\\\",\\\"valueType\\\":\\\"string\\\"},{\\\"columnName\\\":\\\"KZ_JingYingXiangMu\\\",\\\"name\\\":\\\"经营项目\\\",\\\"value\\\":\\\"热食类食品制售\\\",\\\"valueType\\\":\\\"string\\\"},{\\\"columnName\\\":\\\"KZ_JingYingZheMingChen\\\",\\\"name\\\":\\\"经营者名称\\\",\\\"value\\\":\\\"宜宾市叙州区蟹先生餐饮店\\\",\\\"valueType\\\":\\\"string\\\"},{\\\"columnName\\\":\\\"KZ_YouXiaoQiZhi\\\",\\\"name\\\":\\\"有效期至\\\",\\\"value\\\":\\\"2027-10-10\\\",\\\"valueType\\\":\\\"string\\\"},{\\\"columnName\\\":\\\"KZ_ZhuTiYeTai\\\",\\\"name\\\":\\\"主体业态\\\",\\\"value\\\":\\\"餐饮服务经营者\\\",\\\"valueType\\\":\\\"string\\\"},{\\\"columnName\\\":\\\"KZ_FaZhengRiQi\\\",\\\"name\\\":\\\"发证日期\\\",\\\"value\\\":\\\"2022-10-11\\\",\\\"valueType\\\":\\\"string\\\"},{\\\"columnName\\\":\\\"KZ_SHXYDMSFZHM\\\",\\\"name\\\":\\\"社会信用代码(身份证号码)\\\",\\\"value\\\":\\\"92511521MA69MX6A6C\\\",\\\"valueType\\\":\\\"string\\\"},{\\\"columnName\\\":\\\"KZ_XuKeZhengBianHao\\\",\\\"name\\\":\\\"许可证编号\\\",\\\"value\\\":\\\"JY25115210069695\\\",\\\"valueType\\\":\\\"string\\\"},{\\\"columnName\\\":\\\"KZ_JingYingChangSuo\\\",\\\"name\\\":\\\"经营场所\\\",\\\"value\\\":\\\"四川省宜宾市叙州区航天路中段4号莱茵春天食锦美食广场内Y3号\\\",\\\"valueType\\\":\\\"string\\\"},{\\\"columnName\\\":\\\"KZ_FaDingDaiBiaoRenFuZeRen\\\",\\\"name\\\":\\\"法定代表人(负责人)\\\",\\\"value\\\":\\\"王利\\\",\\\"valueType\\\":\\\"string\\\"},{\\\"columnName\\\":\\\"KZ_ZhuSuo\\\",\\\"name\\\":\\\"住所\\\",\\\"value\\\":\\\"四川省宜宾市叙州区航天路中段4号莱茵春天食锦美食广场内Y3号\\\",\\\"valueType\\\":\\\"string\\\"},{\\\"columnName\\\":\\\"KZ_RiChangJianDuGuanLiJiGou\\\",\\\"name\\\":\\\"日常监督管理机构\\\",\\\"value\\\":\\\"宜宾市市场监督管理局\\\",\\\"valueType\\\":\\\"string\\\"},{\\\"columnName\\\":\\\"KZ_QianFaRen\\\",\\\"name\\\":\\\"签发人\\\",\\\"value\\\":\\\"黄炳华\\\",\\\"valueType\\\":\\\"string\\\"},{\\\"columnName\\\":\\\"KZ_TouSuJuBaoDianHua\\\",\\\"name\\\":\\\"投诉举报电话\\\",\\\"value\\\":\\\"12315\\\",\\\"valueType\\\":\\\"string\\\"},{\\\"columnName\\\":\\\"KZ_RiChangJianDuGuanLiRenYuan\\\",\\\"name\\\":\\\"日常监督管理人员\\\",\\\"value\\\":\\\"吴中华;骆玲\\\",\\\"valueType\\\":\\\"string\\\"}],\\\"detail\\\":[]}]}}\"}}\n";
//String s = StringEscapeUtils.unescapeJava(msg);
MidResponseData midResponseData = JSONObject.parseObject(msg,MidResponseData.class);
if(midResponseData.getCode().equals("SUCCESS") && midResponseData.getBizRet().getIfResult().equals("0")){
MidIfResultInfo midIfResultInfo = JSONObject.parseObject(midResponseData.getBizRet().getIfResultInfo(),MidIfResultInfo.class);
if(midIfResultInfo.getHead().getStatus().equals("0")){
for(MidCertificateDataVO vo:midIfResultInfo.getData().getDataList()){
System.out.println(JSONObject.toJSON(vo).toString());
for (CertificateSurface item:vo.getSurface()){
System.out.println(JSONObject.toJSON(item).toString());
}
}
}
}
// String msg = "{\\\"msg\\\":\\\"\\\",\\\"code\\\":\\\"SUCCESS\\\",\\\"bizRet\\\":{\\\"msg\\\":\\\"\\\",\\\"code\\\":\\\"SUCCESS\\\",\\\"bizRet\\\":{\\\"data\\\":[{\\\"lastBgrq\\\":\\\"2019-12-02\\\",\\\"hyml\\\":\\\"C\\\",\\\"clrq\\\":\\\"2005-08-31 00:00:00\\\",\\\"fddbrzjhm\\\":\\\"510624195410013012\\\",\\\"qymc\\\":\\\"广汉市康达食品有限公司\\\",\\\"jlgxsj\\\":\\\"2022-07-26 13:06:19\\\",\\\"fddbrzjlx\\\":\\\"10\\\",\\\"pripid\\\":\\\"510681000012016042700371\\\",\\\"hymlmc\\\":\\\"制造业\\\",\\\"jyfw\\\":\\\"许可项目:食品生产;食品销售;食品互联网销售。(依法须经批准的项目,经相关部门批准后方可开展经营活动,具体经营项目以相关部门批准文件或许可证件为准)一般项目:食品进出口;农副产品销售;食品销售(仅销售预包装食品);食品互联网销售(仅销售预包装食品);低温仓储(不含危险化学品等需许可审批的项目)。(除依法须经批准的项目外,凭营业执照依法自主开展经营活动)\\\",\\\"lastBgsxmc\\\":\\\"高级管理人员备案(董事、监事、经理等)\\\",\\\"yzbm\\\":\\\"\\\",\\\"dz\\\":\\\"四川省德阳市广汉市兴隆镇西林村(刘家坎)\\\",\\\"scztlxmc\\\":\\\"有限责任公司(自然人投资或控股)\\\",\\\"lastBgsx\\\":\\\"70\\\",\\\"id\\\":\\\"c6521e8f-d323-445e-bf6a-a6c2e6f9e766\\\",\\\"jyztmc\\\":\\\"存续(在营、开业、在册)\\\",\\\"hydmmc\\\":\\\"肉制品及副产品加工\\\",\\\"hzrq\\\":\\\"2022-06-21\\\",\\\"jyqyks\\\":\\\"2005-08-31\\\",\\\"zczbbzmc\\\":\\\"人民币\\\",\\\"qyType\\\":\\\"1\\\",\\\"zczb\\\":1000.0,\\\"hydm\\\":\\\"1353\\\",\\\"scztlxdm\\\":\\\"1130\\\",\\\"etlTime\\\":\\\"2023-05-05 15:05:49\\\",\\\"djjg\\\":\\\"510681\\\",\\\"tyshxydm\\\":\\\"91510681X208802529\\\",\\\"zczbbz\\\":\\\"156\\\",\\\"lastBghnr\\\":\\\"刘凤兴 \\\",\\\"fddbrzjlxmc\\\":\\\"中华人民共和国居民身份证\\\",\\\"djjgmc\\\":\\\"广汉市市场监督管理局\\\",\\\"lastBgqnr\\\":\\\"刘凤兴 \\\",\\\"fddbr\\\":\\\"刘凤兴\\\",\\\"dzxzqh\\\":\\\"510681\\\",\\\"jyzt\\\":\\\"1\\\"}]}}}";
// String restMsg = StringEscapeUtils.unescapeJava(msg);
// String iDCardNo = "";
// JSONObject responseData = JSONObject.parseObject(restMsg);
// if(responseData.getString("code").equals("SUCCESS")){
// JSONObject bizRet = responseData.getJSONObject("bizRet");
// if(bizRet.getString("code").equals("SUCCESS")){
// JSONObject _bizRet = bizRet.getJSONObject("bizRet");
// JSONArray dataList = _bizRet.getJSONArray("data");
// iDCardNo = dataList.getJSONObject(0).getString("fddbrzjhm");
// }
// System.out.println(iDCardNo);
// }
}
}
...@@ -58,4 +58,12 @@ public interface ApplyLogService extends ICRUDService<ApplyLogEntity,Long>{ ...@@ -58,4 +58,12 @@ public interface ApplyLogService extends ICRUDService<ApplyLogEntity,Long>{
* @throws AppException * @throws AppException
*/ */
void apiSaveApplyLog(ApplyLogPdu pdu) throws AppException; void apiSaveApplyLog(ApplyLogPdu pdu) throws AppException;
/***
* 微中台接口数据转存
* @param pdu
* @param classifyId
* @throws AppException
*/
void midSaveApplyLog(ApplyLogPdu pdu,Long classifyId) throws AppException;
} }
\ No newline at end of file
...@@ -23,6 +23,7 @@ import com.mortals.xhx.base.system.user.service.UserService; ...@@ -23,6 +23,7 @@ import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.code.*; import com.mortals.xhx.common.code.*;
import com.mortals.xhx.common.utils.*; import com.mortals.xhx.common.utils.*;
import com.mortals.xhx.module.certificate.model.CertificateCatalogEntity; import com.mortals.xhx.module.certificate.model.CertificateCatalogEntity;
import com.mortals.xhx.module.certificate.model.CertificateCatalogQuery;
import com.mortals.xhx.module.certificate.model.CertificateClassifyEntity; import com.mortals.xhx.module.certificate.model.CertificateClassifyEntity;
import com.mortals.xhx.module.certificate.pdu.ApplyLogPdu; import com.mortals.xhx.module.certificate.pdu.ApplyLogPdu;
import com.mortals.xhx.module.certificate.service.CertificateCatalogService; import com.mortals.xhx.module.certificate.service.CertificateCatalogService;
...@@ -32,6 +33,7 @@ import com.mortals.xhx.module.record.model.ApplyLogQuery; ...@@ -32,6 +33,7 @@ import com.mortals.xhx.module.record.model.ApplyLogQuery;
import com.mortals.xhx.module.record.model.DocTemplateVO; import com.mortals.xhx.module.record.model.DocTemplateVO;
import com.mortals.xhx.module.record.model.RecordEntity; import com.mortals.xhx.module.record.model.RecordEntity;
import com.mortals.xhx.module.record.service.PrintWaitQueueService; import com.mortals.xhx.module.record.service.PrintWaitQueueService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.http.entity.ContentType; import org.apache.http.entity.ContentType;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -567,4 +569,70 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap ...@@ -567,4 +569,70 @@ public class ApplyLogServiceImpl extends AbstractCRUDServiceImpl<ApplyLogDao, Ap
} }
} }
@Override
public void midSaveApplyLog(ApplyLogPdu pdu, Long classifyId) throws AppException {
List<CertificateCatalogEntity> catalogEntityList = this.certificateCatalogService.find(new CertificateCatalogQuery().classifyId(classifyId));
if(CollectionUtils.isNotEmpty(catalogEntityList)){
for(CertificateCatalogEntity catalogEntity:catalogEntityList){
ApplyLogEntity entity = new ApplyLogEntity();
entity.setCatalogId(catalogEntity.getId());
entity.setCatalogCode(catalogEntity.getCatalogCode());
entity.setCatalogName(catalogEntity.getCatalogName());
entity.setCertificateCode(pdu.getCertificateCode());
entity.setCertificateName(pdu.getCertificateName());
entity.setHolderName(pdu.getHolderName());
entity.setHolderType(pdu.getHolderType());
entity.setHolderIdType(pdu.getHolderIdType());
entity.setHolderIDCardNo(pdu.getHolderIDCardNo());
entity.setPickerName(pdu.getPickerName());
entity.setPickerIDCardNo(pdu.getPickerIDCardNo());
entity.setIssueTime(pdu.getIssueTime());
entity.setPrivateID(pdu.getPrivateID());
entity.setEnterpriseName(pdu.getEnterpriseName());
entity.setCreateUserId(1L);
JSONObject formContent = JSONObject.parseObject(pdu.getFormContent());
Map<String,String> formMap = new HashMap<>();
formContent.forEach((key, value) -> {
//图片处理
if (key.indexOf("@image") != -1) {
String base64 = String.valueOf(value);
if(StringUtils.isEmpty(base64)){
throw new AppException("图片不能为空");
}
String imageName = new Date().getTime() + ".png";
String imagePath = "/file/uploadfile/"+imageName;
String filePath = this.filePath.endsWith("/") ? this.filePath : this.filePath + "/" + imagePath;
try{
ImageBase64.convertImg(base64.trim(),filePath);
formMap.put(key,imagePath);
}catch (Exception e){
log.error("base64图片转换异常",e.fillInStackTrace());
formMap.put(key,"");
}
}else {
formMap.put(key,String.valueOf(value));
}
});
entity.setFormContent(JSONObject.toJSONString(formMap));
JSONObject formTemplate = JSONObject.parseObject(catalogEntity.getFormContent());
JSONArray formList = formTemplate.getJSONArray("list");
JSONObject json = new JSONObject();
for (int j = 0; j < formList.size(); j++) {
JSONObject jsonObject = formList.getJSONObject(j);
String key = jsonObject.getString("id");
json.put(key,formMap.get(key));
}
entity.setFormTemplate(formTemplate.toJSONString());
try {
this.generateOriginal(entity, null);
}catch (Exception e){
log.error("微中台数据生成证照失败",e.fillInStackTrace());
throw new AppException("微中台数据生成证照失败");
}
}
}else {
throw new AppException("目录类型不正确,无法找到相应证照目录");
}
}
} }
\ No newline at end of file
package com.mortals.xhx.common.pdu.mid;
import lombok.Data;
/**
* 微中台请求接口
* @author:
* @date: 2023/3/2 18:08
*/
@Data
public class MidReq{
private String method;
private String body;
private String path;
//1 sha加密 2 rsa加密提交
private Integer type;
}
package com.mortals.xhx.feign.mid;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.mid.MidReq;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(name = "base-manager", path = "/base", fallbackFactory = MidFeignFallbackFactory.class)
public interface IMidFeign {
/**
* 微中台透传接口
* @param midReq
* @return
*/
@PostMapping(value = "/mid/trans")
Rest<String> trans(@RequestBody MidReq midReq);
}
@Slf4j
@Component
class MidFeignFallbackFactory implements FallbackFactory<IMidFeign> {
@Override
public IMidFeign create(Throwable cause) {
return new IMidFeign(){
@Override
public Rest<String> trans(MidReq midReq) {
return Rest.fail("暂时无法获取微中台透传接口,请稍后再试!");
}
};
}
}
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