1.自定义报表,模板选择修改

2.自定义报告调度,更具部门绑定来选择监测点
3.技术监督附件代码更新
This commit is contained in:
wr
2023-09-14 19:14:08 +08:00
parent b701132711
commit 3aa0dc8eeb
24 changed files with 235 additions and 205 deletions

View File

@@ -3,6 +3,8 @@ package com.njcn.device.pq.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.pq.api.fallback.DeptLineFeignClientFallbackFactory;
import com.njcn.device.pq.pojo.po.DeptLine;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
@@ -34,4 +36,7 @@ public interface DeptLineFeignClient {
*/
@PostMapping("getLineByDeptRelation")
HttpResult<Map<String,List<String>>> getLineByDeptRelation(@RequestParam("devDataType") Integer devDataType);
@PostMapping("/getLineByLineIds")
HttpResult<DeptLine> getLineByLineIds(@RequestParam("id") String ids);
}

View File

@@ -5,6 +5,7 @@ import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.pq.api.DeptLineFeignClient;
import com.njcn.device.biz.utils.DeviceEnumUtil;
import com.njcn.device.pq.pojo.po.DeptLine;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -55,6 +56,12 @@ public class DeptLineFeignClientFallbackFactory implements FallbackFactory<DeptL
log.error("{}异常,降级处理,异常为:{}", "获取部门和监测点的关系(分稳态暂态)", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<DeptLine> getLineByLineIds(String ids) {
log.error("{}异常,降级处理,异常为:{}", "根据监测点id集合查询部门信息id", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -7,6 +7,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.common.utils.LogUtil;
import com.njcn.device.pq.pojo.po.DeptLine;
import com.njcn.device.pq.service.DeptLineService;
import com.njcn.web.controller.BaseController;
import com.njcn.web.pojo.param.DeptLineParam;
@@ -117,5 +118,11 @@ public class DeptLineController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, map, methodDescribe);
}
@PostMapping("/getLineByLineIds")
@ApiOperation("根据监测点获取部门id")
public HttpResult<DeptLine> getLineByLineIds(@RequestParam("id") String ids) {
String methodDescribe = getMethodDescribe("getLineByLineIds");
DeptLine lineByLineIds = deptLineService.getLineByLineIds(ids);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, lineByLineIds, methodDescribe);
}
}

View File

@@ -92,4 +92,10 @@ public interface DeptLineService extends IService<DeptLine> {
Map<String, List<String>> orgSubStationGet(List<Integer> devType);
/**
* 根据监测点id集合查询部门信息id
* @param ids 部门ids
* @return 查询结果
*/
DeptLine getLineByLineIds(String ids);
}

View File

@@ -1,5 +1,6 @@
package com.njcn.device.pq.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.device.biz.pojo.dto.TerminalGetBase;
@@ -103,6 +104,12 @@ public class DeptLineServiceImpl extends ServiceImpl<DeptLineMapper, DeptLine> i
return deptLines.stream ().collect (Collectors.groupingBy (TerminalGetBase::getUnitId, Collectors.mapping (TerminalGetBase::getLedgerId,Collectors.toList ())));
}
@Override
public DeptLine getLineByLineIds(String ids) {
return this.getOne(new LambdaQueryWrapper<DeptLine>()
.eq(DeptLine::getLineId,ids)
);
}
}

View File

@@ -51,7 +51,6 @@ public class CustomReportController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType=OperateType.ADD)
@PostMapping("/addTemplate")
@ApiOperation("新增自定义报表模板")
// @ApiImplicitParam(name = "reportTemplateParam", value = "实体参数", required = true)
public HttpResult<Boolean> addCustomReportTemplate(@Validated ReportTemplateParam reportTemplateParam){
String methodDescribe = getMethodDescribe("addCustomReportTemplate");
boolean res = customReportService.addCustomReportTemplate(reportTemplateParam);
@@ -147,7 +146,6 @@ public class CustomReportController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType=OperateType.UPDATE)
@PostMapping("/updateTemplate")
@ApiOperation("修改自定义报表模板")
// @ApiImplicitParam(name = "reportTemplateParam", value = "实体参数", required = true)
public HttpResult<Boolean> updateCustomReportTemplate(@Validated ReportTemplateParam.UpdateReportTemplateParam reportTemplateParam){
String methodDescribe = getMethodDescribe("updateCustomReportTemplate");
boolean res = customReportService.updateCustomReportTemplate(reportTemplateParam);

View File

@@ -23,5 +23,5 @@ public interface ExcelRptTempMapper extends BaseMapper<ExcelRptTemp> {
List<ReportTemplateVO> getReportTemplateList(@Param("reportSearchParam")ReportSearchParam reportSearchParam);
List<ReportTemplateVO> getReportTemplateByDept(@Param("list") List<DeptDTO> list);
List<ReportTemplateVO> getReportTemplateByDept(@Param("ids") List<String> ids);
}

View File

@@ -49,8 +49,8 @@
WHERE
b.activation = 1
and b.dept_id in
<foreach collection="list" index="index" item="item" separator="," open="(" close=")">
#{item.id}
<foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</select>
</mapper>

View File

@@ -106,14 +106,4 @@ public interface CustomReportService {
List<ReportTemplateVO> getTemplateByDept(String id);
void viewCustomReportTemplateById(String id, HttpServletResponse response);
/**
* @Description: 获取数据单位树
* @param
* @return: java.util.List<com.njcn.harmonic.pojo.vo.ReportTreeVO>
* @Author: wr
* @Date: 2023/8/28 10:58
*/
List<ReportTreeVO> deviceUnitTree();
}

View File

@@ -10,7 +10,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.FileUtil;
import com.njcn.device.pq.api.DeptLineFeignClient;
import com.njcn.device.pq.api.DeviceUnitClient;
import com.njcn.device.pq.pojo.po.DeptLine;
import com.njcn.device.pq.pojo.po.PqsDeviceUnit;
import com.njcn.harmonic.enums.HarmonicResponseEnum;
import com.njcn.harmonic.mapper.DeptTempMapper;
@@ -38,9 +40,6 @@ import com.njcn.harmonic.pojo.vo.SysDeptTempVO;
import com.njcn.harmonic.service.CustomReportService;
import com.njcn.oss.constant.OssPath;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.dto.DeptDTO;
import com.njcn.web.utils.WebUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
@@ -71,8 +70,6 @@ public class CustomReportServiceImpl implements CustomReportService {
private final ExcelRptMapper excelRptMapper;
private final DeptFeignClient deptFeignClient;
private final EleEpdMapper eleEpdMapper;
private final DeptTempMapper deptTempMapper;
@@ -84,7 +81,7 @@ public class CustomReportServiceImpl implements CustomReportService {
private final DeviceUnitClient deviceUnitClient;
private final DicDataFeignClient dicDataFeignClient;
private final DeptLineFeignClient deptLineFeignClient;
@Override
public boolean addCustomReportTemplate(ReportTemplateParam reportTemplateParam) {
checkName(reportTemplateParam, false);
@@ -167,8 +164,8 @@ public class CustomReportServiceImpl implements CustomReportService {
@Override
public List<ReportTemplateVO> getTemplateByDept(String id) {
//获取子孙部门,去重
List<DeptDTO> depts = deptFeignClient.getDeptDescendantIndexes(id, WebUtil.filterDeptType()).getData().stream().distinct().collect(Collectors.toList());
return excelRptTempMapper.getReportTemplateByDept(depts);
DeptLine data = deptLineFeignClient.getLineByLineIds(id).getData();
return excelRptTempMapper.getReportTemplateByDept(Arrays.asList(data.getId()));
}
@Override
@@ -188,73 +185,6 @@ public class CustomReportServiceImpl implements CustomReportService {
}
@Override
public List<ReportTreeVO> deviceUnitTree() {
List<DictData> dictData = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEVICE_UNIT.getCode()).getData();
Map<String, String> unit = new HashMap<>();
List<String> list = dictData.stream().map(DictData::getCode).collect(Collectors.toList());
List<ReportTreeVO> info = new ArrayList<>();
List<ReportTreeVO> treeVOS = new ArrayList<>();
ReportTreeVO reportTreeVO;
for (String s : list) {
treeVOS = new ArrayList<>();
//有效值
if (s.equals(DicDataEnum.EFFECTIVE.getCode())) {
reportTreeVO = new ReportTreeVO();
reportTreeVO.setName("$" + s + "#i$");
reportTreeVO.setShowName(DicDataEnum.EFFECTIVE.getName());
treeVOS.add(reportTreeVO);
reportTreeVO = new ReportTreeVO();
reportTreeVO.setName("$" + s + "#v$");
reportTreeVO.setShowName(DicDataEnum.EFFECTIVE.getName());
treeVOS.add(reportTreeVO);
reportTreeVO = new ReportTreeVO();
reportTreeVO.setName(s);
reportTreeVO.setShowName(DicDataEnum.EFFECTIVE.getName());
reportTreeVO.setChildren(treeVOS);
info.add(reportTreeVO);
}
//功率
// if(s.equals(DicDataEnum.POWER.getCode())){
// unit.put(s+"#p",deviceUnit.getTotalActiveP());
// unit.put(s+"#q",deviceUnit.getTotalNoP());
// unit.put(s+"#s",deviceUnit.getTotalViewP());
// }
// //畸变率
// if(s.equals(DicDataEnum.DISTORTION.getCode())){
// unit.put(s+"#v",deviceUnit.getVdistortion());
// }
// //电压偏差
// if(s.equals(DicDataEnum.VOLTAGE.getCode())){
// unit.put(s+"#v",deviceUnit.getVoltageDev());
// }
// //频率
// if(s.equals(DicDataEnum.UNIT_FREQUENCY.getCode())){
// unit.put(s+"#freq",deviceUnit.getUnitFrequency());
// unit.put(s+"#freqDev",deviceUnit.getUnitFrequencyDev());
// }
// //三项不平衡度
// if(s.equals(DicDataEnum.UNBALANCE.getCode())){
// unit.put(s+"#v","%");
// unit.put(s+"#vPos",deviceUnit.getPositiveV());
// unit.put(s+"#vNeg",deviceUnit.getNoPositiveV());
// unit.put(s+"#vZero",deviceUnit.getNoPositiveV());
// unit.put(s+"#i","%");
// unit.put(s+"#iPos","A");
// unit.put(s+"#iNeg","A");
// unit.put(s+"#iZero","A");
// }
// //基波
// if(s.equals(DicDataEnum.FUND.getCode())){
// unit.put(s+"#i",deviceUnit.getIfund());
// unit.put(s+"#v",deviceUnit.getVfundEffective());
//
// }
}
return info;
}
@Override
public List<ReportTemplateVO> getTemplateList(ReportSearchParam reportSearchParam) {
return excelRptTempMapper.getReportTemplateList(reportSearchParam);
@@ -491,7 +421,7 @@ public class CustomReportServiceImpl implements CustomReportService {
});
}
if (CollUtil.isNotEmpty(endList)) {
if (CollUtil.isEmpty(endList)) {
//数据单位信息
Map<String, String> unit = unitMap(reportSearchParam.getLineId());
//进行反向赋值到模板
@@ -501,6 +431,7 @@ public class CustomReportServiceImpl implements CustomReportService {
jsonArray.forEach(item -> {
JSONObject jsonObject = (JSONObject) item;
JSONArray itemArr = (JSONArray) jsonObject.get("celldata");
String celldata = jsonObject.get("celldata").toString();
itemArr.forEach((it) -> {
if (Objects.nonNull(it) && !"null".equals(it.toString())) {
//获取到1列

View File

@@ -0,0 +1,18 @@
package com.njcn.prepare.harmonic.mapper.mysql.line;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.harmonic.pojo.po.SysDeptTemp;
import com.njcn.harmonic.pojo.vo.SysDeptTempVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Description: 自定义报告模板和部门关系
* @Author: wr
* @Date: 2023/9/14 14:02
*/
public interface DeptTempMapper extends BaseMapper<SysDeptTemp> {
}

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.harmonic.mapper.DeptTempMapper">
</mapper>

View File

@@ -20,12 +20,14 @@ import com.njcn.harmonic.enums.HarmonicResponseEnum;
import com.njcn.harmonic.pojo.dto.ReportTemplateDTO;
import com.njcn.harmonic.pojo.po.ExcelRpt;
import com.njcn.harmonic.pojo.po.ExcelRptTemp;
import com.njcn.harmonic.pojo.po.SysDeptTemp;
import com.njcn.influxdb.param.InfluxDBSqlConstant;
import com.njcn.influxdb.param.InfluxDBTableConstant;
import com.njcn.influxdb.utils.InfluxDbUtils;
import com.njcn.oss.constant.OssPath;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.prepare.harmonic.constant.AlgorithmParam;
import com.njcn.prepare.harmonic.mapper.mysql.line.DeptTempMapper;
import com.njcn.prepare.harmonic.mapper.mysql.line.ExcelRptMapper;
import com.njcn.prepare.harmonic.mapper.mysql.line.ExcelRptTempMapper;
import com.njcn.prepare.harmonic.pojo.param.LineParam;
@@ -56,45 +58,51 @@ import java.util.stream.Collectors;
public class ReportServiceImpl implements ReportService {
private final DeptLineFeignClient deptLineFeignClient;
private final InfluxDbUtils influxDbUtils;
private final ExcelRptTempMapper excelRptTempMapper;
private final ExcelRptMapper excelRptMapper;
private final DeptTempMapper deptTempMapper;
private final FileStorageUtil fileStorageUtil;
private final DeviceUnitClient deviceUnitClient;
private final DicDataFeignClient dicDataFeignClient;
@Override
@Async("asyncExecutor")
public boolean batchReport(LineParam reportParam) {
public void batchReport(LineParam reportParam) {
//查询所有已激活模板
List<ExcelRptTemp> reportTemplateList = excelRptTempMapper.getActiveTempList();
if (CollUtil.isEmpty(reportTemplateList)) {
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_ACTIVE);
}
//有监测点,匹配监测点的数据进行处理
//无监测点,查询稳态所有监测点
List<String> list = reportParam.getLineIds();
if (CollUtil.isEmpty(list)) {
list = new ArrayList<>();
Map<String, List<String>> map = deptLineFeignClient.getLineByDeptRelation(AlgorithmParam.STEADY_STATE).getData();
Collection<List<String>> values = map.values();
for (List<String> value : values) {
list.addAll(value);
}
}
//根据content进行处理
List<ReportTemplateDTO> dataList;
JSONArray jsonArray;
for (ExcelRptTemp excelRptTemp : reportTemplateList) {
//获取已绑定的部门信息
List<SysDeptTemp> sysDeptTemps = deptTempMapper.selectList(new LambdaQueryWrapper<SysDeptTemp>()
.eq(SysDeptTemp::getTempId, excelRptTemp.getId())
.eq(SysDeptTemp::getActivation, 1)
);
List<String> list = new ArrayList<>();
if (CollUtil.isNotEmpty(sysDeptTemps)) {
//筛选部门下面所包含的监测点
for (SysDeptTemp sysDeptTemp : sysDeptTemps) {
if (map.containsKey(sysDeptTemp.getDeptId())) {
list.addAll(map.get(sysDeptTemp.getDeptId()));
}
}
}
if (CollUtil.isEmpty(list)) {
continue;
}
try (InputStream fileStream = fileStorageUtil.getFileStream(excelRptTemp.getContent())) {
//获取content解析数据
jsonArray = new JSONArray(new JSONTokener(fileStream, new JSONConfig()));
@@ -150,8 +158,6 @@ public class ReportServiceImpl implements ReportService {
}
}
}
return true;
}
/**
@@ -162,7 +168,10 @@ public class ReportServiceImpl implements ReportService {
*/
private void rptBiz(LineParam reportParam, String lineId, ExcelRptTemp excelRptTemp, String afterContent) {
LambdaQueryWrapper<ExcelRpt> lambdaQuery = new LambdaQueryWrapper<>();
lambdaQuery.eq(ExcelRpt::getLineId, lineId).eq(ExcelRpt::getTempId, excelRptTemp.getId()).eq(ExcelRpt::getType, reportParam.getType()).eq(ExcelRpt::getDataDate, reportParam.getDataDate());
lambdaQuery.eq(ExcelRpt::getLineId, lineId)
.eq(ExcelRpt::getTempId, excelRptTemp.getId())
.eq(ExcelRpt::getType, reportParam.getType())
.eq(ExcelRpt::getDataDate, reportParam.getDataDate());
ExcelRpt excelRpt = excelRptMapper.selectOne(lambdaQuery);
if (excelRpt != null) {
excelRpt.setContent(afterContent);
@@ -292,6 +301,7 @@ public class ReportServiceImpl implements ReportService {
/**
* 数据单位信息
*
* @param lineID
* @return
*/
@@ -345,6 +355,7 @@ public class ReportServiceImpl implements ReportService {
}
return unit;
}
/**
* 组装influxDB查询sql查询value并封装endlist
*

View File

@@ -13,5 +13,5 @@ public interface ReportService {
* @param reportParam 参数
* @return 返回值
*/
boolean batchReport(LineParam reportParam);
void batchReport(LineParam reportParam);
}

View File

@@ -1,9 +1,9 @@
package com.njcn.process.pojo.param;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import lombok.Getter;
import lombok.Setter;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* <p>
@@ -13,31 +13,17 @@ import lombok.Setter;
* @author hongawen
* @since 2023-06-21
*/
@Getter
@Setter
@TableName("supv_file")
@Data
public class SupvFileParam {
private String id;
/**
* 附件路径
*/
private String file;
/**
* 附件名称
*/
private String attachmentName;
@ApiModelProperty(value = "业务id集合")
private List<String> ids;
@ApiModelProperty(value = "0.计划 1.问题")
private Integer type;
@ApiModelProperty(value = "区分类型")
private String attachmentType;
/**
* 计划问题id
*/
private String busiId;
}

View File

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.time.LocalDateTime;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.multipart.MultipartFile;
@@ -31,38 +32,38 @@ public class SupvFile {
@TableField(exist = false)
private String provinceId;
/**
* 附件路径
*/
@ApiModelProperty("附件路径")
private String fileUrl;
@TableField(exist = false)
private MultipartFile file;
@ApiModelProperty("业务名称")
private String busiName;
/**
* 附件名称
*/
@ApiModelProperty("附件名称")
private String attachmentName;
/**
* 0.计划 1.问题
*/
@ApiModelProperty("0.计划 1.问题")
private Integer type;
@ApiModelProperty("附件分类")
private String attachmentType;
/**
* 计划问题id
*/
@ApiModelProperty("业务id")
private String busiId;
@ApiModelProperty("上传人")
private String uploaderName;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime uploadTime;
@ApiModelProperty("上传人id")
private String uploaderId;
@ApiModelProperty("创建时间")
private LocalDateTime createTime;
@ApiModelProperty("0.未上送 1.已上送 2.取消上送")
@TableField("is_upload_head")
private Integer isUploadHead;
}

View File

@@ -1,14 +1,20 @@
package com.njcn.process.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.process.pojo.param.SupvAlarmParam;
import com.njcn.process.pojo.param.SupvFileParam;
import com.njcn.process.pojo.po.SupvAlarm;
import com.njcn.process.pojo.po.SupvFile;
import com.njcn.process.service.ISupvFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
@@ -18,6 +24,7 @@ import com.njcn.web.controller.BaseController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* <p>
@@ -50,6 +57,16 @@ public class SupvFileController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@PostMapping("list")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("查询附件信息集合")
@ApiImplicitParam(name = "param",value = "请求体",required = true)
public HttpResult<List<SupvFile>> pageAlarm(@RequestBody SupvFileParam param){
String methodDescribe = getMethodDescribe("pageAlarm");
List<SupvFile> supvFiles = iSupvFileService.listFile(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, supvFiles, methodDescribe);
}
@PostMapping("detail")
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.DOWNLOAD)
@ApiOperation("监督计划问题附件下载")

View File

@@ -89,7 +89,7 @@ public class SupvPushGwController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("推送附件接口")
@ApiImplicitParam(name = "busIds",value = "请求体",required = true)
public HttpResult<String> pushFile(@RequestBody List<String> busIds) throws IOException {
public HttpResult<String> pushFile(@RequestBody List<String> busIds) {
String methodDescribe = getMethodDescribe("pushFile");
String s = supvPushGwService.pushFile(busIds);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);

View File

@@ -2,7 +2,11 @@ package com.njcn.process.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.process.pojo.param.SupvFileParam;
import com.njcn.process.pojo.po.SupvFile;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
@@ -14,5 +18,5 @@ import com.njcn.process.pojo.po.SupvFile;
*/
public interface SupvFileMapper extends BaseMapper<SupvFile> {
SupvFile selectFile(String ids);
List<SupvFile> selectFile(@Param("param") SupvFileParam param);
}

View File

@@ -2,4 +2,26 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.process.mapper.SupvFileMapper">
<select id="selectFile" resultType="com.njcn.process.pojo.po.SupvFile">
select
sp.work_plan_name busiName,
sf.*
from
supv_file sf
INNER JOIN supv_plan sp on sp.plan_Id= sf.busi_Id
<where>
<if test="param!=null and param.ids != null and param.ids.size > 0">
AND busi_Id IN
<foreach collection='param.ids' item='item' index="index" open='(' separator=',' close=')'>
#{item}
</foreach>
</if>
<if test="param!=null and param.type != null ">
AND sf.type = #{param.type}
</if>
<if test="param!=null and param.attachmentType != null and param.attachmentType != ''">
AND sf.attachment_Type &lt;= #{param.attachmentType}
</if>
</where>
</select>
</mapper>

View File

@@ -2,10 +2,12 @@ package com.njcn.process.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.process.pojo.param.SupvFileParam;
import com.njcn.process.pojo.po.SupvFile;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* <p>
@@ -24,6 +26,7 @@ public interface ISupvFileService extends IService<SupvFile> {
*/
boolean planUpload(MultipartFile file,String planId, Integer type,String attachmentType,String uploadTime);
List<SupvFile> listFile(SupvFileParam param);
String detail(HttpServletResponse response,String busId,Integer type,String attachmentType);

View File

@@ -31,7 +31,7 @@ public interface SupvPushGwService {
* @author cdf
* @date 2023/6/28
*/
String pushFile(List<String> busIds) throws IOException;
String pushFile(List<String> busIds) ;
/**

View File

@@ -3,6 +3,7 @@ package com.njcn.process.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -10,6 +11,7 @@ import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.oss.constant.OssPath;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.process.mapper.SupvFileMapper;
import com.njcn.process.pojo.param.SupvFileParam;
import com.njcn.process.pojo.po.SupvFile;
import com.njcn.process.pojo.po.SupvPlan;
import com.njcn.process.pojo.po.SupvProblem;
@@ -67,16 +69,23 @@ public class SupvFileServiceImpl extends ServiceImpl<SupvFileMapper, SupvFile> i
if(Objects.nonNull(supvFile)){
fileStorageUtil.deleteFile(supvFile.getFileUrl());
supvFilePO.setUuid(supvFile.getUuid());
supvFilePO.setIsUploadHead(supvFile.getIsUploadHead());
fly= this.updateById(supvFilePO);
updateTime(type,planId,uploadTime,attachmentType,supvFile.getUuid());
// updateTime(type,planId,uploadTime,attachmentType,supvFile.getUuid());
}else{
supvFilePO.setCreateTime(LocalDateTime.now());
supvFilePO.setIsUploadHead(0);
fly= this.save(supvFilePO);
updateTime(type,planId,uploadTime,attachmentType,null);
// updateTime(type,planId,uploadTime,attachmentType,null);
}
return fly;
}
@Override
public List<SupvFile> listFile(SupvFileParam param) {
return this.baseMapper.selectFile(param);
}
@Override
public String detail(HttpServletResponse response,String busId, Integer type,String attachmentType) {
SupvFile supvFile = this.getOne(new LambdaQueryWrapper<SupvFile>().eq(SupvFile::getBusiId,busId).eq(SupvFile::getType,type).eq(SupvFile::getAttachmentType,attachmentType));

View File

@@ -70,7 +70,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
private final SupvProblemMapper supvProblemMapper;
private final SupvFileMapper supvFileMapper;
private final ISupvFileService supvFileService;
private final SupvReportMMapper supvReportMMapper;
@@ -92,6 +92,8 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
@Value("${gw.url}")
private String gwUrl;
@Value("${gw.code}")
private String code;
@Override
public String pushPlan(List<String> planIds) {
@@ -227,7 +229,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
List<PlanVO> planVOS = BeanUtil.copyToList(supvPlanList, PlanVO.class);
SendParam param = new SendParam();
param.setStats(planVOS);
param.setProvinceId("13B9B47F1E483324E05338297A0A0595");
param.setProvinceId(code);
String s = JSONObject.toJSONStringWithDateFormat(param, JSON.DEFFAULT_DATE_FORMAT);
log.info(Thread.currentThread().getName() + "获取返回体 接收电能质量技术监督工作计划数据接口数据:" + s + "结束----");
Map<String, String> send = send(param, getUrl(1), "pqPlanCreate");
@@ -288,7 +290,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
if (mapRe.containsKey(supvProblem.getRectificationMeasure())) {
supvProblem.setRectificationMeasure(String.format("%02d", mapRe.get(supvProblem.getRectificationMeasure()).getAlgoDescribe()));
}
supvProblem.setProvinceId("13B9B47F1E483324E05338297A0A0595");
supvProblem.setProvinceId(code);
}
if (supvProblemList.size() > 100) {
@@ -301,7 +303,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
SendParam param = new SendParam();
param.setStats(list);
param.setProvinceId("13B9B47F1E483324E05338297A0A0595");
param.setProvinceId(code);
String s = JSONObject.toJSONStringWithDateFormat(param, JSON.DEFFAULT_DATE_FORMAT);
log.info(Thread.currentThread().getName() + "获取返回体 删除电能质量技术监督工作计划接口数据:" + s + "结束----");
Map<String, String> send;
@@ -340,11 +342,11 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
}
@Override
public String pushFile(List<String> busIds) throws IOException {
public String pushFile(List<String> busIds) {
StringBuilder stringBuilder = new StringBuilder();
LambdaQueryWrapper<SupvFile> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(SupvFile::getBusiId, busIds);
List<SupvFile> supvFiles = supvFileMapper.selectList(lambdaQueryWrapper);
List<SupvFile> supvFiles = supvFileService.list(lambdaQueryWrapper);
if (supvFiles.size() > 100) {
throw new BusinessException("一次最多上送100条数据");
}
@@ -356,7 +358,6 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
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());
@@ -364,9 +365,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
stringBuilder.append("" + i + "次操作失败: 请检查上送附件类型是否正确");
continue;
}
// Map<String, String> sendFile = sendFile(getUrl(4), supvFiles.get(i));
Map<String, String> sendFile = new HashMap<>();
Map<String, String> sendFile = sendFile(getUrl(4), supvFiles.get(i));
log.info(Thread.currentThread().getName() + "获取返回体 总部提供附件接收接口,省公司调用此接口,完成附件上报响应结果:" + sendFile + "结束----");
if (sendFile.containsKey("succeed")) {
String succeed = sendFile.get("succeed");
@@ -376,6 +375,10 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
Map map = JSON.parseObject(succeed, Map.class);
String status = map.get("status").toString();
if ("000000".equals(status)) {
supvFileService.update(new LambdaUpdateWrapper<SupvFile>()
.eq(SupvFile::getUuid,supvFiles.get(i).getUuid())
.set(SupvFile::getIsUploadHead,1)
);
String result = map.get("result").toString();
Map mapCount = JSON.parseObject(result, Map.class);
String count = mapCount.get("count").toString();
@@ -403,7 +406,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
//TODO 调用上送接口
SendParam param = new SendParam();
param.setStats(supvReportMList);
param.setProvinceId("13B9B47F1E483324E05338297A0A0595");
param.setProvinceId(code);
String s = JSONObject.toJSONStringWithDateFormat(param, JSON.DEFFAULT_DATE_FORMAT);
log.info(Thread.currentThread().getName() + "获取返回体 取消电能质量技术监督工作计划接口数据:" + s + "结束----");
Map<String, String> send = send(param, getUrl(5), "pqMonthReportCreate");
@@ -454,7 +457,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
//TODO
SendParam param = new SendParam();
param.setStats(supvPlanList);
param.setProvinceId("13B9B47F1E483324E05338297A0A0595");
param.setProvinceId(code);
String s = JSONObject.toJSONStringWithDateFormat(param, JSON.DEFFAULT_DATE_FORMAT);
log.info(Thread.currentThread().getName() + "获取返回体 删除电能质量技术监督工作计划接口数据:" + s + "结束----");
Map<String, String> send = send(param, getUrl(6), "pqPlanDelete");
@@ -504,7 +507,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
List<PlanHisVO> list = BeanUtil.copyToList(supvPlanHis, PlanHisVO.class);
SendParam param = new SendParam();
param.setStats(list);
param.setProvinceId("13B9B47F1E483324E05338297A0A0595");
param.setProvinceId(code);
String s = JSONObject.toJSONStringWithDateFormat(param, JSON.DEFFAULT_DATE_FORMAT);
log.info(Thread.currentThread().getName() + "获取返回体 预告警单数据接口:" + s + "结束----");
Map<String, String> send = send(param, getUrl(7), "pqPlanCreateHis");
@@ -568,7 +571,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
List<AlarmVO> list = BeanUtil.copyToList(supvAlarms, AlarmVO.class);
SendParam param = new SendParam();
param.setStats(list);
param.setProvinceId("13B9B47F1E483324E05338297A0A0595");
param.setProvinceId(code);
String s = JSONObject.toJSONStringWithDateFormat(param, JSON.DEFFAULT_DATE_FORMAT);
log.info(Thread.currentThread().getName() + "获取返回体 工作计划变更历史数据接口:" + s + "结束----");
Map<String, String> send = send(param, getUrl(8), "pqAlarmCreate");
@@ -609,7 +612,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
List<AlarmBackVO> list = BeanUtil.copyToList(supvAlarmBacks, AlarmBackVO.class);
SendParam param = new SendParam();
param.setStats(list);
param.setProvinceId("13B9B47F1E483324E05338297A0A0595");
param.setProvinceId(code);
String s = JSONObject.toJSONStringWithDateFormat(param, JSON.DEFFAULT_DATE_FORMAT);
log.info(Thread.currentThread().getName() + "获取返回体 工作计划变更历史数据接口:" + s + "结束----");
Map<String, String> send = send(param, getUrl(9), "pqAlarmBackCreate");
@@ -709,7 +712,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
return token;
}
public Map<String, String> sendFile(String url, SupvFile supvFile) throws IOException {
public Map<String, String> sendFile(String url, SupvFile supvFile) {
String path = supvFile.getFileUrl();
if (StrUtil.isBlank(path)) {
throw new BusinessException("获取文件上传路径为空!请检查原始路径是否存在");
@@ -752,7 +755,7 @@ public class SupvPushGwServiceImpl implements SupvPushGwService {
// 设置form请求参数
builder.putParamsMap("uuid", supvFile.getFileUrl())
.putParamsMap("attachmentName", supvFile.getAttachmentName())
.putParamsMap("provinceId", "13B9B47F1E483324E05338297A0A0595")
.putParamsMap("provinceId", code)
.putParamsMap("attachmentType", supvFile.getAttachmentType())
.putParamsMap("busiId", supvFile.getBusiId())
.putParamsMap("uploaderName", supvFile.getUploaderName())