1.全过程管理附件上送
This commit is contained in:
@@ -125,7 +125,6 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
|
||||
Map<String, DictData> mapSupvUserClass = supvUserClassList.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
|
||||
|
||||
|
||||
|
||||
List<DictData> supvVoltageDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
|
||||
Map<String, DictData> mapVoltage = supvVoltageDicList.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
|
||||
|
||||
@@ -185,10 +184,10 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
|
||||
}
|
||||
|
||||
|
||||
if(supvPlan.getSupvType().equals("05")){
|
||||
if (supvPlan.getSupvType().equals("05")) {
|
||||
//电容器组需要上送对象
|
||||
List<SupvPlanRel> supvPlanRelList = supvPlanRelMapper.selectList(new LambdaQueryWrapper<SupvPlanRel>().eq(SupvPlanRel::getPlanId,supvPlan.getPlanId()));
|
||||
if(CollUtil.isNotEmpty(supvPlanRelList)){
|
||||
List<SupvPlanRel> supvPlanRelList = supvPlanRelMapper.selectList(new LambdaQueryWrapper<SupvPlanRel>().eq(SupvPlanRel::getPlanId, supvPlan.getPlanId()));
|
||||
if (CollUtil.isNotEmpty(supvPlanRelList)) {
|
||||
supvPlanRelList.forEach(SupvPlanRel::prepareForSerialization);
|
||||
supvPlan.setPlanRel(supvPlanRelList);
|
||||
}
|
||||
@@ -205,18 +204,18 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
|
||||
}
|
||||
|
||||
//监督对象类型
|
||||
if(StrUtil.isNotBlank(supvPlan.getSupvObjType())){
|
||||
if(supvPlan.getSupvType().equals("01")){
|
||||
if (StrUtil.isNotBlank(supvPlan.getSupvObjType())) {
|
||||
if (supvPlan.getSupvType().equals("01")) {
|
||||
|
||||
}else if(supvPlan.getSupvType().equals("02")){
|
||||
} else if (supvPlan.getSupvType().equals("02")) {
|
||||
supvPlan.setSupvObjType(mapSubvObjType.get(supvPlan.getSupvObjType()).getValue());
|
||||
}else if(supvPlan.getSupvType().equals("03")){
|
||||
} else if (supvPlan.getSupvType().equals("03")) {
|
||||
supvPlan.setSupvObjType(mapSupvUserClass.get(supvPlan.getSupvObjType()).getValue());
|
||||
}else if(supvPlan.getSupvType().equals("04")){
|
||||
} else if (supvPlan.getSupvType().equals("04")) {
|
||||
|
||||
}else if(supvPlan.getSupvType().equals("05")){
|
||||
} else if (supvPlan.getSupvType().equals("05")) {
|
||||
|
||||
}else if(supvPlan.getSupvType().equals("06")){
|
||||
} else if (supvPlan.getSupvType().equals("06")) {
|
||||
supvPlan.setSupvObjType(mapSupvEvaluationReport.get(supvPlan.getSupvObjType()).getValue());
|
||||
}
|
||||
if (mapSubvObjType.containsKey(supvPlan.getSupvObjType())) {
|
||||
@@ -307,7 +306,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
|
||||
|
||||
|
||||
for (SupvProblem supvProblem : supvProblemList) {
|
||||
supvProblemService.checkParam(supvProblem.getPlanId(),DateUtil.formatLocalDateTime(supvProblem.getDiscoveryTime()));
|
||||
supvProblemService.checkParam(supvProblem.getPlanId(), DateUtil.formatLocalDateTime(supvProblem.getDiscoveryTime()));
|
||||
Dept dept = deptFeignClient.getDeptByCode(supvProblem.getDutyOrgId()).getData();
|
||||
supvProblem.setDutyOrgName(dept.getName());
|
||||
|
||||
@@ -381,27 +380,27 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
|
||||
}
|
||||
List<DictData> fileList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.file_type.getCode().trim()).getData();
|
||||
Map<String, DictData> mapFile = fileList.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
|
||||
DictData dictData ;
|
||||
DictData dictData;
|
||||
//TODO 调用上送接口
|
||||
for (int i = 0; i < supvFiles.size(); i++) {
|
||||
if(mapFile.containsKey(supvFiles.get(i).getAttachmentType())){
|
||||
dictData = mapFile.get(supvFiles.get(i).getAttachmentType());
|
||||
supvFiles.get(i).setAttachmentType(dictData.getValue());
|
||||
}else{
|
||||
stringBuilder.append("第" + (i+1) + "行文件上送失败: 请检查上送附件类型是否正确;</br>");
|
||||
continue;
|
||||
}
|
||||
if (mapFile.containsKey(supvFiles.get(i).getAttachmentType())) {
|
||||
dictData = mapFile.get(supvFiles.get(i).getAttachmentType());
|
||||
supvFiles.get(i).setAttachmentType(dictData.getValue());
|
||||
} else {
|
||||
stringBuilder.append("第" + (i + 1) + "行文件上送失败: 请检查上送附件类型是否正确;</br>");
|
||||
continue;
|
||||
}
|
||||
log.info(Thread.currentThread().getName() + "获取返回体 推送附件接口:" + supvFiles.get(i) + "结束----!");
|
||||
Map<String, String> sendFile = sendFile(getUrl(4), supvFiles.get(i));
|
||||
log.info(Thread.currentThread().getName() + "获取返回体 总部提供附件接收接口,省公司调用此接口,完成附件上报响应结果:" + sendFile + "结束----!");
|
||||
if (sendFile.containsKey("succeed")) {
|
||||
supvFileService.update(new LambdaUpdateWrapper<SupvFile>()
|
||||
.eq(SupvFile::getUuid,supvFiles.get(i).getUuid())
|
||||
.set(SupvFile::getIsUploadHead,1)
|
||||
.eq(SupvFile::getUuid, supvFiles.get(i).getUuid())
|
||||
.set(SupvFile::getIsUploadHead, 1)
|
||||
);
|
||||
stringBuilder.append("第" + (i+1) + "行文件上送成功:成功数据" + sendFile.get("succeed") + "条;</br>");
|
||||
stringBuilder.append("第" + (i + 1) + "行文件上送成功:成功数据" + sendFile.get("succeed") + "条;</br>");
|
||||
} else {
|
||||
stringBuilder.append("第" + (i+1) + "次行文件上送失败:" + sendFile.get("error")+";</br>");
|
||||
stringBuilder.append("第" + (i + 1) + "次行文件上送失败:" + sendFile.get("error") + ";</br>");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -458,12 +457,12 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
|
||||
if (count > 0) {
|
||||
throw new BusinessException("请选择已上送计划");
|
||||
}
|
||||
iSupvPlanService.update(new LambdaUpdateWrapper<SupvPlan>()
|
||||
iSupvPlanService.update(new LambdaUpdateWrapper<SupvPlan>()
|
||||
.set(SupvPlan::getDeleteFlag, 1)
|
||||
.set(SupvPlan::getDeleteTime, LocalDateTime.now())
|
||||
.in(SupvPlan::getPlanId, planIds)
|
||||
);
|
||||
return this.pushPlan(planIds);
|
||||
return this.pushPlan(planIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -712,32 +711,18 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
|
||||
return map;
|
||||
}
|
||||
|
||||
/* public String LoginToken() {
|
||||
String token = null;
|
||||
String clientId = "e512d3940a7d11eeae0cd6fb272b183c";
|
||||
String clientSecret = "k8cF9CgXsj/lnuP2C4Vhx8tuNsPwieBIU8n14vHL1EoWSadcX0we2wffjyTUYGsK";
|
||||
|
||||
String userUrl = "http://" + gwUrl + "/psr-auth/oauth/accessToken?grant_type={grant_type}&client_id={client_id}&client_secret={client_secret}";
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("grant_type", "credentials");
|
||||
map.put("client_id", clientId);
|
||||
map.put("client_secret", clientSecret);
|
||||
ResponseEntity<Map> userEntity = RestTemplateUtil.get(userUrl, Map.class, map);
|
||||
|
||||
if (userEntity.getStatusCodeValue() == 200) {
|
||||
log.info(Thread.currentThread().getName() + "数据:" + userEntity.getBody() + "结束----!");
|
||||
//获取返回体
|
||||
Map body = userEntity.getBody();
|
||||
token = body.get("access_token").toString();
|
||||
} else {
|
||||
throw new BusinessException("获取数据token出现未知异常!请检查ip端口是否正确!");
|
||||
}
|
||||
return token;
|
||||
}*/
|
||||
|
||||
public Map<String,String> sendFile(String url,SupvFile supvFile) throws IOException {
|
||||
/**
|
||||
* 附件推送
|
||||
*
|
||||
* @param url
|
||||
* @param supvFile
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public Map<String, String> sendFile(String url, SupvFile supvFile) throws IOException {
|
||||
//获取文件服务器地址
|
||||
Map<String,String> maps=new HashMap<>();
|
||||
Map<String, String> maps = new HashMap<>();
|
||||
String path = supvFile.getFileUrl();
|
||||
if (StrUtil.isBlank(path)) {
|
||||
maps.put("error", "获取文件上传路径为空!请检查原始路径是否存在");
|
||||
@@ -750,39 +735,42 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
|
||||
return maps;
|
||||
}
|
||||
|
||||
|
||||
Map<String,String> otherParams = new HashMap<>();
|
||||
otherParams.put("provinceId",code );
|
||||
Map<String, String> otherParams = new HashMap<>();
|
||||
otherParams.put("provinceId", code);
|
||||
otherParams.put("secretKey", GwSendUtil.secretKey);
|
||||
otherParams.put("uuid", supvFile.getUuid());
|
||||
otherParams.put("attachmentName",supvFile.getAttachmentName());
|
||||
otherParams.put("attachmentType",supvFile.getAttachmentType());
|
||||
otherParams.put("attachmentName", supvFile.getAttachmentName());
|
||||
otherParams.put("attachmentType", supvFile.getAttachmentType());
|
||||
otherParams.put("busiId", supvFile.getBusiId());
|
||||
otherParams.put("uploaderName",supvFile.getUploaderName());
|
||||
otherParams.put("uploaderName", supvFile.getUploaderName());
|
||||
String uploadTime = supvFile.getUploadTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
otherParams.put("uploadTime",uploadTime);
|
||||
otherParams.put("uploaderId",supvFile.getUploaderId());
|
||||
otherParams.put("uploadTime", uploadTime);
|
||||
otherParams.put("uploaderId", supvFile.getUploaderId());
|
||||
|
||||
|
||||
log.info("文件上报接口发送:{}",JSONObject.toJSONString(otherParams));
|
||||
byte[] bytes = IOUtils.toByteArray(in);
|
||||
String s = Base64.encodeStr(bytes, false, false);
|
||||
|
||||
int m = 1;
|
||||
String str="";
|
||||
String str = "";
|
||||
log.info("文件上报接口发送:{}", JSONObject.toJSONString(otherParams));
|
||||
for (int i = 0; i < s.length(); i += 1365000) {
|
||||
|
||||
otherParams.put("fileCount", (int) Math.ceil(s.length() / (1365000 * 1.0)) + "");
|
||||
otherParams.put("fileCurrentNum", m + "");
|
||||
str = requestCommon("pqFileFromHyCreate", url, otherParams);
|
||||
otherParams.put("fileByte", s.substring(i, Math.min(i + 1365000, s.length())));
|
||||
otherParams.put("fileCount", (int) Math.ceil(s.length() /(1365000 * 1.0)) + "");
|
||||
otherParams.put("fileCurrentNum",m + "");
|
||||
str= requestCommon("pqFileFromHyCreate", url, otherParams);
|
||||
m++;
|
||||
|
||||
}
|
||||
if(StrUtil.isNotBlank(str)) {
|
||||
if (StrUtil.isNotBlank(str)) {
|
||||
String[] split = str.split("_");
|
||||
if("succeed".equals(split[0])){
|
||||
if ("succeed".equals(split[0])) {
|
||||
maps.put("succeed", "1");
|
||||
}else{
|
||||
} else {
|
||||
maps.put("error", split[1]);
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
maps.put("error", "国网文件上传失败");
|
||||
}
|
||||
in.close();
|
||||
@@ -792,6 +780,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
|
||||
|
||||
/**
|
||||
* 文件上传请求
|
||||
*
|
||||
* @param serviceName
|
||||
* @param url
|
||||
* @param param
|
||||
@@ -812,6 +801,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
|
||||
.contentType("application/x-www-form-urlencoded;charset=utf-8") //设置请求content-type
|
||||
.putHeaderParamsMap("Content-Type", "application/x-www-form-urlencoded;charset=utf-8")
|
||||
.putHeaderParamsMap("serviceName", serviceName)
|
||||
.putHeaderParamsMap("secretKey", "lW2xr6zKjbaqVDOSgQpcGrM6Rg0=")
|
||||
.putParamsMapAll(param);
|
||||
try {
|
||||
HttpReturn ret = HttpCaller.invokeReturn(builder.build());
|
||||
@@ -824,14 +814,14 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
|
||||
String status = map.get("status").toString();
|
||||
String errors = map.get("errors").toString();
|
||||
if ("000000".equals(status)) {
|
||||
str="succeed_"+errors;
|
||||
}else{
|
||||
str="error_"+errors;
|
||||
str = "succeed_" + errors;
|
||||
} else {
|
||||
str = "error_" + errors;
|
||||
}
|
||||
} catch (HttpCallerException e) {
|
||||
// error process
|
||||
log.info(Thread.currentThread().getName() + "附件错误信息:" + e);
|
||||
str="error_"+"国网附件服务器内部错误";
|
||||
str = "error_" + "国网附件服务器内部错误";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
@@ -912,7 +902,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
|
||||
|
||||
private void checkParam(SupvPlan supvPlan) {
|
||||
//判断时间范围
|
||||
if (ObjectUtil.isAllNotEmpty(supvPlan.getEffectStartTime(), supvPlan.getEffectEndTime())||
|
||||
if (ObjectUtil.isAllNotEmpty(supvPlan.getEffectStartTime(), supvPlan.getEffectEndTime()) ||
|
||||
ObjectUtil.isAllNotEmpty(supvPlan.getEffectStartTime(), supvPlan.getReportIssueTime())
|
||||
) {
|
||||
LocalDateTime problemOcTime1 = supvPlan.getProblemOcTime();
|
||||
@@ -922,14 +912,14 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
|
||||
//问题发现时间
|
||||
DateTime problemOcTime = DateUtil.parse(DateUtil.formatLocalDateTime(problemOcTime1), "yyyy-MM-dd HH:mm:ss");
|
||||
Boolean fly = false;
|
||||
if(ObjectUtil.isNotNull(supvPlan.getEffectEndTime())){
|
||||
if (ObjectUtil.isNotNull(supvPlan.getEffectEndTime())) {
|
||||
//实施结束时间
|
||||
DateTime effectEndTime = DateUtil.parse(DateUtil.formatLocalDateTime(supvPlan.getEffectEndTime()), "yyyy-MM-dd HH:mm:ss");
|
||||
if (DateUtil.isIn(problemOcTime, effectStartTime, effectEndTime)) {
|
||||
fly = true;
|
||||
}
|
||||
}
|
||||
if(ObjectUtil.isNotNull(supvPlan.getReportIssueTime())){
|
||||
if (ObjectUtil.isNotNull(supvPlan.getReportIssueTime())) {
|
||||
//报告出具时间
|
||||
DateTime reportIssueTime = DateUtil.parse(DateUtil.formatLocalDateTime(supvPlan.getReportIssueTime()), "yyyy-MM-dd HH:mm:ss");
|
||||
if (DateUtil.isIn(problemOcTime, effectStartTime, reportIssueTime)) {
|
||||
|
||||
Reference in New Issue
Block a user