Commit 856b1824 authored by 赵啸非's avatar 赵啸非

添加事项材料与情形查询

parent fd592217
......@@ -30,8 +30,8 @@ import java.util.Map;
* @author: zxfei
* @date: 2022/4/20 9:24
*/
@Aspect
@Component
//@Aspect
//@Component
@Slf4j
@Order(1)
@Profile({"default", "develop", "test"})
......
package com.mortals.xhx.busiz.req.accept;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
@Data
......@@ -11,5 +12,6 @@ public class ComplexMaterialsItem {
/**
* 材料内容,base64编码附件
*/
@JSONField(serialize = false)
private String materialContent;
}
\ No newline at end of file
package com.mortals.xhx.busiz.web;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
......@@ -25,12 +26,14 @@ import com.mortals.xhx.protocol.complex.ComplexApiRest;
import com.mortals.xhx.protocol.complex.matter.model.rsp.DictInfo;
import com.mortals.xhx.protocol.complex.matter.model.rsp.MatterListInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.math3.Field;
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.io.File;
import java.util.List;
import static com.mortals.xhx.common.key.Constant.HTTP_TIMEOUT;
......@@ -293,7 +296,7 @@ public class ComplexApiController {
try {
req.setNonce(RandomUtil.randomNumbers(6));
cacheService.lpush(KEY_COMPLEX_REQ, JSONObject.toJSONString(req));
String rest = cacheService.blpop(KEY_EVENT_IMPLEMENTATION_RESP + req.getNonce(), HTTP_TIMEOUT, String.class);
String rest = cacheService.blpop(KEY_EVENT_IMPLEMENTATION_RESP + req.getNonce(), 60, String.class);
if (ObjectUtil.isEmpty(rest)) {
throw new AppException("请求访问超时");
}
......@@ -308,4 +311,14 @@ public class ComplexApiController {
}
}
public static void main(String[] args) {
File file = new File("E:\\pic\\1.png");
String encode = Base64.encode(file);
System.out.println(encode);
}
}
package com.mortals.xhx.thread;
import cn.hutool.core.codec.Base64;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.Rest;
import com.mortals.framework.service.ICacheService;
import com.mortals.xhx.busiz.req.accept.ComplexAcceptReq;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.protocol.complex.matter.model.req.*;
import com.mortals.xhx.protocol.complex.matter.model.rsp.AcceptRspInfo;
import com.mortals.xhx.protocol.complex.matter.service.IComplexMatterService;
import com.mortals.xhx.utils.SpringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.util.ObjectUtils;
import java.util.List;
import java.util.stream.Collectors;
import static com.mortals.xhx.common.key.Constant.REDIS_RESP_TIMEOUT;
import static com.mortals.xhx.common.key.RedisKey.KEY_EVENT_IMPLEMENTATION_RESP;
/**
* 自助接件服务
*
* @author: zxfei
* @date: 2023/12/3 14:04
*/
@Slf4j
public class ImplementAcceptSendTask implements Runnable {
private ComplexAcceptReq complexAcceptReq;
private String deviceLogo;
private IComplexMatterService complexMatterService;
private ICacheService cacheService;
public ImplementAcceptSendTask(String deviceLogo, ComplexAcceptReq complexAcceptReq) {
this.complexAcceptReq = complexAcceptReq;
this.deviceLogo = deviceLogo;
complexMatterService = SpringUtils.getBean(IComplexMatterService.class);
cacheService = SpringUtils.getBean(ICacheService.class);
}
@Override
public void run() {
try {
log.info("自助接件服务");
//遍历 上传附件
List<MaterialsItem> materialsItemList = complexAcceptReq.getMaterials().stream().map(item -> {
MaterialsItem materialsItem = new MaterialsItem();
//base64
String materialContent = item.getMaterialContent();
if (!ObjectUtils.isEmpty(materialContent)) {
byte[] bytes = Base64.decode(materialContent);
Rest<String> uploadFileRest = complexMatterService.uploadFile(deviceLogo, bytes, item.getUploadFileName());
if (uploadFileRest.getCode() == YesNoEnum.YES.getValue()) {
item.setMaterialPath(uploadFileRest.getData());
item.setMaterialContent("");
}
}
BeanUtils.copyProperties(item, materialsItem, BeanUtil.getNullPropertyNames(item));
return materialsItem;
}).collect(Collectors.toList());
AcceptReq acceptReq = new AcceptReq();
BeanUtils.copyProperties(complexAcceptReq, acceptReq, BeanUtil.getNullPropertyNames(complexAcceptReq));
acceptReq.setMaterials(materialsItemList);
if (!ObjectUtils.isEmpty(complexAcceptReq.getHandlings())) {
List<HandlingsItem> handlingsItemList = complexAcceptReq.getHandlings().stream().map(item -> {
HandlingsItem handlingsItem = new HandlingsItem();
BeanUtils.copyProperties(item, handlingsItem);
return handlingsItem;
}).collect(Collectors.toList());
acceptReq.setHandlings(handlingsItemList);
}
if (!ObjectUtils.isEmpty(complexAcceptReq.getApplicantLegal())) {
ApplicantLeagal applicantLeagal = new ApplicantLeagal();
BeanUtils.copyProperties(complexAcceptReq.getApplicantLegal(), applicantLeagal);
acceptReq.setApplicantLegal(applicantLeagal);
}
if (!ObjectUtils.isEmpty(complexAcceptReq.getApplicantPersonal())) {
ApplicantPersonal applicantPersonal = new ApplicantPersonal();
BeanUtils.copyProperties(complexAcceptReq.getApplicantPersonal(), applicantPersonal);
acceptReq.setApplicantPersonal(applicantPersonal);
}
Rest<List<AcceptRspInfo>> rest = complexMatterService.accept(deviceLogo, acceptReq);
cacheService.lpushForTime(KEY_EVENT_IMPLEMENTATION_RESP + complexAcceptReq.getNonce(), REDIS_RESP_TIMEOUT, JSONObject.toJSONString(rest));
/*
Rest<List<MaterialInfo>> rest = complexMatterService.getMaterialByEvent(deviceLogo, implementationReq.getEventId());
cacheService.lpushForTime(KEY_EVENT_IMPLEMENTATION_RESP + implementationReq.getNonce(), REDIS_RESP_TIMEOUT, JSONObject.toJSONString(rest));
*/
} catch (Exception e) {
log.error("发送异常:" + e);
}
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.Rest;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.util.ThreadPool;
import com.mortals.xhx.busiz.req.accept.ComplexAcceptReq;
import com.mortals.xhx.common.utils.AbstractThread;
import com.mortals.xhx.protocol.complex.matter.model.req.ImplementationReq;
import com.mortals.xhx.protocol.complex.matter.model.rsp.MatterListInfo;
......@@ -55,30 +56,34 @@ public class SendThread extends AbstractThread {
ImplementationReq implementationReq = JSONObject.parseObject(reqStr, ImplementationReq.class);
ImplementListSendTask implementListSendTask = new ImplementListSendTask(deviceCode, implementationReq);
ThreadPool.getInstance().execute(implementListSendTask);
}else if("event-implementation/get-by-id".equals(urlPath)){
} else if ("event-implementation/get-by-id".equals(urlPath)) {
ImplementationReq implementationReq = JSONObject.parseObject(reqStr, ImplementationReq.class);
ImplementDetailSendTask implementSendTask = new ImplementDetailSendTask(deviceCode, implementationReq);
ThreadPool.getInstance().execute(implementSendTask);
}else if("bus-situation-material/getSituationMaterialTreeByEventIds".equals(urlPath)){
} else if ("bus-situation-material/getSituationMaterialTreeByEventIds".equals(urlPath)) {
ImplementationReq implementationReq = JSONObject.parseObject(reqStr, ImplementationReq.class);
ImplementSituationSendTask implementSendTask = new ImplementSituationSendTask(deviceCode, implementationReq);
ThreadPool.getInstance().execute(implementSendTask);
}else if("consulting-service/getMaterialByEventAndSituation".equals(urlPath)){
} else if ("consulting-service/getMaterialByEventAndSituation".equals(urlPath)) {
ImplementationReq implementationReq = JSONObject.parseObject(reqStr, ImplementationReq.class);
EventAndSituationSendTask implementSendTask = new EventAndSituationSendTask(deviceCode, implementationReq);
ThreadPool.getInstance().execute(implementSendTask);
}else if("material/findList".equals(urlPath)){
} else if ("material/findList".equals(urlPath)) {
ImplementationReq implementationReq = JSONObject.parseObject(reqStr, ImplementationReq.class);
ImplementMaterialSendTask implementSendTask = new ImplementMaterialSendTask(deviceCode, implementationReq);
ThreadPool.getInstance().execute(implementSendTask);
}else if("event-implementation/getDynamicFormByEventIds".equals(urlPath)){
} else if ("event-implementation/getDynamicFormByEventIds".equals(urlPath)) {
ImplementationReq implementationReq = JSONObject.parseObject(reqStr, ImplementationReq.class);
ImplementDynamicFormSendTask implementSendTask = new ImplementDynamicFormSendTask(deviceCode, implementationReq);
ThreadPool.getInstance().execute(implementSendTask);
}else if("common/queryDict".equals(urlPath)){
} else if ("common/queryDict".equals(urlPath)) {
ImplementationReq implementationReq = JSONObject.parseObject(reqStr, ImplementationReq.class);
DictSendTask implementSendTask = new DictSendTask(deviceCode, implementationReq);
ThreadPool.getInstance().execute(implementSendTask);
} else if ("self-device-info/acceptHandling".equals(urlPath)) {
ComplexAcceptReq complexAcceptReq = JSONObject.parseObject(reqStr, ComplexAcceptReq.class);
ImplementAcceptSendTask acceptSendTask = new ImplementAcceptSendTask(deviceCode, complexAcceptReq);
ThreadPool.getInstance().execute(acceptSendTask);
}
......@@ -93,5 +98,4 @@ public class SendThread extends AbstractThread {
}
}
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