Commit ee0df0de authored by shenxin's avatar shenxin

代码合并

parent f5a9fad4
......@@ -8,6 +8,9 @@ package com.mortals.xhx.common.code;
*/
public enum NodeTypeEnum {
蓉易办受理("BusiType_21","21","蓉易办受理"),
蓉易办环节("BusiType_22","22","蓉易办环节"),
已提交("BusiType_23","23","已提交"),
受理("BusiType_1","11","受理"),
审查("BusiType_13","21","审查"),
决定("BusiType_8","91","决定"),
......
package com.mortals.xhx.modules.information.task;
import cn.hutool.core.date.DateTime;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.alibaba.excel.util.CollectionUtils;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.common.code.NodeTypeEnum;
import com.mortals.xhx.common.utils.DateByAffairUtils;
import com.mortals.xhx.modules.implementlist.dao.RybMatterDao;
import com.mortals.xhx.modules.implementlist.dao.RybWorkDao;
import com.mortals.xhx.modules.implementlist.model.RybMatterListEntry;
import com.mortals.xhx.modules.implementlist.model.RybWorkEntry;
import com.mortals.xhx.modules.information.model.InformationEntity;
import com.mortals.xhx.modules.information.service.InformationService;
import com.mortals.xhx.modules.service.QueryInformationServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.stream.Collectors;
/**
* @author shenxin
* @Date: 2021/11/17-16:28
* @Description:办件数据推送蓉易办(申请并受理)
*/
@Slf4j
@Component("rybApplyAndAcceptInformationTaskImpl")
public class RybApplyAndAcceptInformationTaskImpl implements ITaskExcuteService {
@Value("${upload.AppKey}")
String AppKey;
@Autowired
private InformationService informationService;
@Autowired
private QueryInformationServiceImpl queryInformationService;
@Resource
private RybWorkDao rybWorkDao;
@Resource
private RybMatterDao rybMatterDao;
@Override
public void excuteTask(ITask task) throws AppException {
//1.查询上月的表是否存在未推送的数据
List<InformationEntity> informationEntities =
queryInformationService.queryDataThatHasNotBeenPushed(NodeTypeEnum.蓉易办受理.getCode(), "1", "0", task.getExcuteParam());
//组装申请并受理数据推送一体化平台
this.applyAndAccept(informationEntities);
}
private void applyAndAccept(List<InformationEntity> informationEntities) {
log.info("开始推送申请并受理理数据");
if(CollectionUtils.isEmpty(informationEntities)){
log.info("没有需要推送申请并受理理数据");
return;
}
List<InformationEntity> entities = informationEntities.parallelStream().map(e -> {
//组装参数
HashMap<String, Object> stringObjectHashMap = assemblyParameters(e);
if(stringObjectHashMap == null){
log.info("推送失败,没有该办件所对应的事项部门编码!");
e.setFailReason("推送失败,没有该办件所对应的事项部门编码!");
e.setIsReport("1");
e.setIsSuccess("0");
return e;
}
Map<String, String> map = (Map<String, String>) stringObjectHashMap.get("params");
e.setAcceptName(map.get("receiveusername"));
e.setAcceptId(map.get("receiveuseridcard"));
e.setAcceptPhone(map.get("receiveuserphone"));
Map<String, Object> params = new HashMap<>();
params.put("jsonData", JSONObject.toJSONString(stringObjectHashMap));
HttpRequest key = HttpUtil.createPost("https://10.1.235.51:4433/gateway/api/1/wllz/bjsqtjbsl/zs")//蓉易办
// HttpRequest key = HttpUtil.createPost("http://192.168.0.222:17011/m/supplement/test")//本地测试
.header("AppKey", AppKey)
.header("Content-Type", "application/x-www-form-urlencoded;charset=utf-8").form(params);
HttpResponse appKey = key.execute().charset("utf-8");
JSONObject jsonObject = JSONObject.parseObject(appKey.body());
log.info("响应:" + jsonObject);
JSONObject data = JSONObject.parseObject(jsonObject.getString("data"));
if ("200".equals(jsonObject.getString("code")) && "1".equals(data.getJSONObject("custom").getString("code"))) {
log.info("推送成功");
e.setIsReport("1");
e.setIsSuccess("1");
e.setBizStatus(NodeTypeEnum.蓉易办环节.getDesc());
e.setNodeType(NodeTypeEnum.蓉易办环节.getCode());
//默认区间3~20分钟
e.setCreateTime(DateByAffairUtils.getTimeByAddRandomDouble(DateTime.now(), null, null));
e.setOfficeCode(data.getJSONObject("custom").getJSONObject("content").getString("flowsn"));
} else {
log.info("推送失败:" + jsonObject);
e.setFailReason(jsonObject.toString());
e.setIsReport("1");
e.setIsSuccess("0");
}
e.setProcessStatusName(NodeTypeEnum.蓉易办受理.getValue());
return e;
}).collect(Collectors.toList());
log.info("申请受理推送完成");
informationService.update(entities, null);
}
private HashMap<String, Object> assemblyParameters(InformationEntity e) {
HashMap<String, Object> dataMap = new HashMap<>(16);
dataMap.put("token", "Epoint_WebSerivce_**##0601");
HashMap<String, Object> baseInfoMap = new HashMap<>(16);
baseInfoMap.put("projectname", e.getEventName());
baseInfoMap.put("applyway", "20");
if (e.getApplicantAttributes() == 2) {
baseInfoMap.put("applyertype", "20");
} else {
baseInfoMap.put("applyertype", "10");
baseInfoMap.put("legal", e.getLegalPerson());
baseInfoMap.put("legalpersoncardtype", "");
baseInfoMap.put("legalpersonidcard", "");
}
baseInfoMap.put("applyername", e.getApplicantName());
baseInfoMap.put("applyersex", e.getApplicantSex());
baseInfoMap.put("certtype", "22");
baseInfoMap.put("certnum", e.getApplicantCardNumbe());
baseInfoMap.put("address", "地址暂无");
baseInfoMap.put("contactmobile", e.getContactPhone());
baseInfoMap.put("contactperson", e.getContactName());
List<RybWorkEntry> workEntries = rybWorkDao.find(e.getDeptCode());
if(CollectionUtils.isEmpty(workEntries)){
return null;
}
baseInfoMap.putAll(randomlyExtractPersonnelInformation(workEntries));
baseInfoMap.put("receivedate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(e.getCreateTime()));
RybMatterListEntry entry = rybMatterDao.find(e.getEventCode()).get(0);
if (null != entry) {
baseInfoMap.put("tasktype", entry.getMatterType());
baseInfoMap.put("task_id", entry.getTaskId());
} else {
baseInfoMap.put("tasktype", "1A");
baseInfoMap.put("task_id", "123");
}
baseInfoMap.put("eventcode", entry.getMatterCode());
baseInfoMap.put("areacode", e.getAreaCode());
baseInfoMap.put("source", "MTEwNDEyOTc0MDAw");
baseInfoMap.put("contactcertnum", e.getContactIdCard());
baseInfoMap.put("contactidcard", e.getContactIdCard());
dataMap.put("params", baseInfoMap);
return dataMap;
}
private HashMap<String, String> randomlyExtractPersonnelInformation(List<RybWorkEntry> workEntries) {
HashMap<String, String> dataMap = new HashMap<>(16);
Random random = new Random();
int i = random.nextInt(workEntries.size());
dataMap.put("receiveusername", workEntries.get(i).getReceiveUserName());
dataMap.put("receiveuseridcard", workEntries.get(i).getReceiveUserIdcard());
dataMap.put("receiveuserphone", workEntries.get(i).getReceiveUserPhone());
return dataMap;
}
@Override
public void stopTask(ITask task) throws AppException {
}
}
package com.mortals.xhx.modules.information.task;
import cn.hutool.http.HttpUtil;
import com.alibaba.excel.util.CollectionUtils;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.common.code.NodeTypeEnum;
import com.mortals.xhx.modules.information.model.InformationEntity;
import com.mortals.xhx.modules.information.service.InformationService;
import com.mortals.xhx.modules.service.QueryInformationServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author shenxin
* @Date: 2021/11/17-16:28
* @Description:办件数据推送蓉易办(办件环节)
*/
@Slf4j
@Component("rybSubmitLinkDataInformationTaskImpl")
public class RybSubmitLinkDataInformationTaskImpl implements ITaskExcuteService {
@Value("${upload.AppKey}")
String AppKey;
@Autowired
private InformationService informationService;
@Autowired
private QueryInformationServiceImpl queryInformationService;
@Override
public void excuteTask(ITask task) throws AppException {
//1.查询上月的表是否存在未推送的数据
List<InformationEntity> informationEntities =
queryInformationService.queryDataThatHasNotBeenPushed(NodeTypeEnum.蓉易办环节.getCode(), "1", "1", task.getExcuteParam());
//办件环节数据推送蓉易办
this.submitLinkData(informationEntities);
}
private void submitLinkData(List<InformationEntity> informationEntities) {
log.info("开始推送申请并受理理数据");
if(CollectionUtils.isEmpty(informationEntities)){
log.info("没有需要推送办件环节数据");
return;
}
List<InformationEntity> collect = informationEntities.parallelStream().map(e -> {
//组装参数
HashMap<String, Object> stringObjectHashMap = assemblyParametersLink(e);
Map<String, Object> params = new HashMap<>();
params.put("jsonData", JSONObject.toJSONString(stringObjectHashMap));
String appKey = HttpUtil
.createPost("https://10.1.235.51:4433/gateway/api/1/wllz/bjhjgcsjts/zs").form(params)//蓉易办
// .createPost("http://192.168.0.222:17011/m/supplement/test").form(params)//测试
.header("AppKey", AppKey)
.header("Content-Type", "application/x-www-form-urlencoded;charset=utf-8")
.execute()
.charset("utf-8")
.body();
JSONObject jsonObject = JSONObject.parseObject(appKey);
e.setBizStatus(NodeTypeEnum.已提交.getDesc());
e.setNodeType(NodeTypeEnum.已提交.getCode());
if ("200".equals(jsonObject.getString("code"))) {
log.info("提交成功:" + jsonObject);
} else {
log.info("提交失败:" + jsonObject);
}
e.setProcessStatusName(NodeTypeEnum.蓉易办环节.getValue());
return e;
}).collect(Collectors.toList());
log.info("办件环节推送完成");
informationService.update(collect, null);
}
private HashMap<String, Object> assemblyParametersLink(InformationEntity e) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
HashMap<String, Object> dataMap = new HashMap<>(16);
dataMap.put("token", "Epoint_WebSerivce_**##0601");
HashMap<String, Object> baseInfoMap = new HashMap<>(16);
baseInfoMap.put("flowsn", e.getOfficeCode());
baseInfoMap.put("operatetype", "80");
baseInfoMap.put("startdate", format.format(e.getGenTime()));
baseInfoMap.put("enddate", format.format(e.getCompleteTime()));
baseInfoMap.put("operateusername", e.getAcceptName());
baseInfoMap.put("operateuserphone", e.getAcceptPhone());
baseInfoMap.put("operateuseridcard", e.getAcceptId());
baseInfoMap.put("areacode", e.getAreaCode());
baseInfoMap.put("handleTime", format.format(e.getCreateTime()));
baseInfoMap.put("nodeStatus", "1");
dataMap.put("params", baseInfoMap);
return dataMap;
}
@Override
public void stopTask(ITask task) throws AppException {
}
}
......@@ -86,6 +86,7 @@ public class InformationDataConversionListener extends AnalysisEventListener<Sup
supplementEntity.setIsSuccess("0");
supplementEntity.setCreateDate(DateTime.now());
supplementEntity.setUpdateDate(supplementEntity.getCreateDate());
supplementEntity.setPushType(TYPE);
entityList.add(supplementEntity);
eventCodeList.add(supplementEntity.getImplCode());
if(PushTypeEnum.SYTH.getStyle().equals(TYPE)){
......
......@@ -145,6 +145,12 @@ public class SupplementEntity extends BaseEntityLong{
@ExcelIgnore
private String failReason;
/**
* 推送类型
*/
@ExcelIgnore
private String pushType;
/**
* 创建时间
*/
......@@ -454,6 +460,20 @@ public class SupplementEntity extends BaseEntityLong{
public void setFailReason(String failReason) {
this.failReason = failReason;
}
/**
* 获取 推送类型
* @return String
*/
public String getPushType(){
return pushType;
}
/**
* 设置 推送类型
* @param pushType
*/
public void setPushType(String pushType){
this.pushType = pushType;
}
/**
* 获取 创建时间
* @return createDate
......@@ -525,6 +545,7 @@ public class SupplementEntity extends BaseEntityLong{
.append(",isExecute:").append(getIsExecute())
.append(",isSuccess:").append(getIsSuccess())
.append(",failReason:").append(getFailReason())
.append(",pushType:").append(getPushType())
.append(",createDate:").append(getCreateDate())
.append(",updateDate:").append(getUpdateDate())
;
......@@ -553,6 +574,7 @@ public class SupplementEntity extends BaseEntityLong{
this.isExecute = null;
this.isSuccess = null;
this.failReason = null;
this.pushType = null;
this.createDate = null;
this.updateDate = null;
}
......
package com.mortals.xhx.modules.supplement.task;
import cn.hutool.core.date.DateTime;
import com.alibaba.excel.util.CollectionUtils;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.service.ITask;
......@@ -8,11 +9,14 @@ import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.framework.util.DateUtils;
import com.mortals.xhx.common.code.ApplicantTypeEnums;
import com.mortals.xhx.common.code.NodeTypeEnum;
import com.mortals.xhx.common.code.PushTypeEnum;
import com.mortals.xhx.common.utils.DateByAffairUtils;
import com.mortals.xhx.common.utils.FilterSuppDataUtils;
import com.mortals.xhx.common.utils.SnowFlakeUtil;
import com.mortals.xhx.modules.implementlist.model.ImplementlistEntity;
import com.mortals.xhx.modules.implementlist.model.RybMatterListEntry;
import com.mortals.xhx.modules.implementlist.service.ImplementlistService;
import com.mortals.xhx.modules.implementlist.service.RybMatterListService;
import com.mortals.xhx.modules.information.dao.InformationDao;
import com.mortals.xhx.modules.information.model.InformationEntity;
import com.mortals.xhx.modules.supplement.model.SupplementEntity;
......@@ -20,8 +24,10 @@ import com.mortals.xhx.modules.supplement.model.SupplementQuery;
import com.mortals.xhx.modules.supplement.service.SupplementService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
......@@ -37,21 +43,31 @@ import java.util.stream.Collectors;
@Component("supplementTaskImpl")
public class SupplementTaskImpl implements ITaskExcuteService {
@Value("${upload.area}")
String area;
@Autowired
private SupplementService supplementService;
@Autowired
private ImplementlistService implementlistService;
@Resource
private RybMatterListService rybMatterListService;
@Autowired
private InformationDao informationDao;
@Override
public void excuteTask(ITask task) throws AppException {
//1.查询上月的表是否存在未清洗的数据
List<SupplementEntity> supplementEntities = queryDataThatHasNotBeenPushed(task.getExcuteParam());
//1.查询上月的表是否存在未清洗的数据 //蓉易办
List<SupplementEntity> ryb = queryDataThatHasNotBeenPushed(task.getExcuteParam(), 1);
//开始进行数据清洗
this.dataCleaning(supplementEntities);
this.ryb(ryb);
//1.查询上月的表是否存在未清洗的数据 //省一体化
List<SupplementEntity> syth = queryDataThatHasNotBeenPushed(task.getExcuteParam(), 2);
//开始进行数据清洗
this.dataCleaning(syth);
}
......@@ -60,6 +76,62 @@ public class SupplementTaskImpl implements ITaskExcuteService {
}
private void ryb(List<SupplementEntity> supplementEntities) {
log.info("开始清洗");
if(CollectionUtils.isEmpty(supplementEntities)){
log.info("没有需要清洗数据");
return;
}
List<InformationEntity> informationQueries = new ArrayList<>();
if (!supplementEntities.isEmpty()) {
List<SupplementEntity> collect = supplementEntities.parallelStream().map(e -> {
//TODO:查询实施清单信息,通过事项编码查询有问题(但因数据库存储的事项数据是条件过滤后的,故暂时不改动查询),后期改动
RybMatterListEntry thImplement = rybMatterListService.getThImplement(e.getImplCode());
try {
InformationEntity informationQuery = new InformationEntity();
//组装第一次业务数据(清洗后的)
informationQuery = assemblyOfficeData(informationQuery, e);
if (null != thImplement) {
informationQuery.setDeptCode(thImplement.getDeptCode());
informationQuery.setEventCode(thImplement.getMatterCode());
informationQuery.setEventName(thImplement.getMatterName());
informationQuery.setAreaCode(area);
//是否转化成功:0默认 1成功
informationQuery.setIsSuccess("1");
//是否推送(0 否 1是)
informationQuery.setIsReport("0");
//设置 失败次数 默认为0
informationQuery.setFailTimes(0);
// 是否执行转化(0.未执行 1.已执行)
e.setIsExecute("1");
//是否转化成功(0默认 1成功)
e.setIsSuccess("1");
} else {
e.setFailReason(" Err:实施清单不存在");
informationQuery.setFailReason(" Err:实施清单不存在");
informationQuery.setIsSuccess("0");
// 是否执行转化(0.未执行 1.已执行)
e.setIsExecute("1");
//是否转化成功(0默认 1成功)
e.setIsSuccess("0");
}
e.setUpdateDate(DateTime.now());
informationQueries.add(informationQuery);
return e;
} catch (Exception ex) {
e.setIsExecute("1");
e.setFailReason("转换失败");
log.error("转换失败:SupplementID:" + e.getId());
log.error("转换失败:失败原因" + ex.getMessage());
return e;
}
}).collect(Collectors.toList());
supplementService.update(collect, null);
informationDao.insertBatch(informationQueries);
log.info("清洗完成,本次清洗数量:"+ informationQueries.size());
}
}
private void dataCleaning(List<SupplementEntity> supplementEntities) {
if (!supplementEntities.isEmpty()) {
List<InformationEntity> informationQueries = new ArrayList<>();
......@@ -165,9 +237,13 @@ public class SupplementTaskImpl implements ITaskExcuteService {
informationQuery.setSystemCode(supplementEntity.getSysCode());
//测试暂时写死
if(PushTypeEnum.SYTH.getStyle().equals(supplementEntity.getPushType())){
informationQuery.setNodeType(NodeTypeEnum.受理.getCode());
informationQuery.setBizStatus(NodeTypeEnum.受理.getDesc());
}else if(PushTypeEnum.RYB.getStyle().equals(supplementEntity.getPushType())){
informationQuery.setNodeType(NodeTypeEnum.蓉易办受理.getCode());
informationQuery.setBizStatus(NodeTypeEnum.蓉易办受理.getDesc());
}
informationQuery.setProcessStatusName("申请并受理");
informationQuery.setDoThingProperty("0");
informationQuery.setApplyNum("1");
......@@ -178,11 +254,12 @@ public class SupplementTaskImpl implements ITaskExcuteService {
return informationQuery;
}
private List<SupplementEntity> queryDataThatHasNotBeenPushed(String excuteParam) {
private List<SupplementEntity> queryDataThatHasNotBeenPushed(String excuteParam, int type) {
List<SupplementEntity> supplementEntities;
SupplementQuery supplementQuery = new SupplementQuery();
supplementQuery.setIsExecute("0");
supplementQuery.setIsSuccess("0");
supplementQuery.setPushType(PushTypeEnum.getByValue(type).getStyle());
PageInfo pageInfo = new PageInfo();
pageInfo.setPrePageResult(Integer.parseInt(excuteParam));
//TODO: 条数限制
......
......@@ -44,17 +44,17 @@ public class SupplementController extends BaseCRUDJsonMappingController<Suppleme
* 导入办件信息,一阶段通过excel表格导入,放入磁盘中,在通过文件地址去获取文件内容进行数据清洗
*/
@PostMapping(value="importOfficeInformation")
public ApiRespPdu importOfficeInformation(@RequestPart("file") MultipartFile file, @RequestParam("sysCode") String sysCode ,@RequestParam("type") String type){
public ApiRespPdu importOfficeInformation(@RequestPart("file") MultipartFile file, @RequestParam("sysCode") String sysCode ,@RequestParam("type") int type){
ApiRespPdu respPdu=new ApiRespPdu();
String filePath = uploadService.saveFileUpload(file, null, null);
Map<String, String> objectObjectHashMap = new HashMap<>();
if(PushTypeEnum.SYTH.getStyle().equals(type) && StringUtils.isEmpty(sysCode)){
if(PushTypeEnum.SYTH.getValue() == type && StringUtils.isEmpty(sysCode)){
respPdu.setCode(-1);
respPdu.setMsg("缺少系统编码");
return respPdu;
}
objectObjectHashMap.put("sysCode",sysCode);
objectObjectHashMap.put("type",type);
objectObjectHashMap.put("type",PushTypeEnum.getByValue(type).getStyle());
objectObjectHashMap.put("status",ExcelUploadEnum.未处理的文件路径.getCode());
iCacheService.hset(ExcelUploadEnum.UPLOAD_PATH.getCode(),filePath,objectObjectHashMap);
respPdu.setCode(200);
......
......@@ -57,4 +57,9 @@ cookie:
domain: base.testnew.com
port: 111
upload:
path: @profiles.filepath@
path: /data-center-send/pic #新津
# path: D:/pic #金堂
area: 510132 #新津
# area: 510121 #金堂
AppKey: 834815625598599168 #新津
# AppKey: 743109085582327808 #金堂
\ No newline at end of file
......@@ -52,7 +52,7 @@
<properties>
<profiles.active>test</profiles.active>
<profiles.datasource.uri>
<![CDATA[jdbc:mysql://192.168.0.252:3306/datacenter-platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<![CDATA[jdbc:mysql://192.168.0.251:3306/xhx-base?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<profiles.datasource.username>root</profiles.datasource.username>
<profiles.datasource.password>nacos@2020</profiles.datasource.password>
<profiles.redis.uri>192.168.0.252</profiles.redis.uri>
......
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