app功能合并
This commit is contained in:
@@ -62,6 +62,11 @@
|
||||
<artifactId>common-poi</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>harmonic-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.njcn.csharmonic.api;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.fallback.CsAlarmFeignClientFallbackFactory;
|
||||
import com.njcn.csharmonic.pojo.po.CsAlarm;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_HARMONIC_BOOT, path = "/csAlarm", fallbackFactory = CsAlarmFeignClientFallbackFactory.class,contextId = "csAlarm")
|
||||
public interface CsAlarmFeignClient {
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/addList")
|
||||
@ApiOperation("批量写入数据")
|
||||
@ApiImplicitParam(name = "list", value = "参数", required = true)
|
||||
HttpResult<Boolean> addList(@RequestBody List<CsAlarm> list);
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryListByTime")
|
||||
@ApiOperation("按日期查询数据")
|
||||
@ApiImplicitParam(name = "time", value = "时间", required = true)
|
||||
HttpResult<List<CsAlarm>> queryListByTime(@RequestParam("time") String time);
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/deleteListByTime")
|
||||
@ApiOperation("按日期删除数据")
|
||||
@ApiImplicitParam(name = "time", value = "时间", required = true)
|
||||
HttpResult<Boolean> deleteListByTime(@RequestParam("time") String time);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.njcn.csharmonic.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.fallback.CsHarmonicFeignClientFallbackFactory;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonic;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_HARMONIC_BOOT, path = "/csHarmonic", fallbackFactory = CsHarmonicFeignClientFallbackFactory.class,contextId = "csHarmonic")
|
||||
public interface CsHarmonicFeignClient {
|
||||
|
||||
@PostMapping("/addList")
|
||||
@ApiOperation("批量写入数据")
|
||||
HttpResult<Boolean> addList(@RequestBody List<CsHarmonic> list);
|
||||
|
||||
@PostMapping("/queryListByTime")
|
||||
@ApiOperation("按日期查询数据")
|
||||
HttpResult<List<CsHarmonic>> queryListByTime(@RequestParam(value = "time") String time);
|
||||
|
||||
|
||||
@PostMapping("/deleteListByTime")
|
||||
@ApiOperation("按日期删除数据")
|
||||
HttpResult<Boolean> deleteListByTime(@RequestParam(value = "time") String time);
|
||||
|
||||
}
|
||||
@@ -1,19 +1,13 @@
|
||||
package com.njcn.csharmonic.api;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
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.csdevice.pojo.vo.DataGroupEventVO;
|
||||
import com.njcn.csharmonic.api.fallback.EventFeignClientFallbackFactory;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryPage;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -40,4 +34,11 @@ public interface EventFeignClient {
|
||||
|
||||
@PostMapping("/getEventByTime")
|
||||
HttpResult<List<CsEventPO>> getEventByTime(@RequestParam(name = "lineList", required = false) List<String> lineList,@RequestParam("startTime") String startTime,@RequestParam("endTime") String endTime);
|
||||
|
||||
@PostMapping("/getDevAlarmList")
|
||||
HttpResult<List<CsEventPO>> getDevAlarmList(@RequestBody CsEventUserQueryParam param);
|
||||
|
||||
@PostMapping("/getEventByIdList")
|
||||
HttpResult<List<CsEventPO>> getEventByIdList(@RequestBody List<String> list);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.fallback.EventUserFeignClientFallbackFactory;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -20,4 +21,10 @@ public interface EventUserFeignClient {
|
||||
|
||||
@PostMapping("/queryEventList")
|
||||
HttpResult<List<EventDetailVO>> queryEventList(@RequestBody CsEventUserQueryParam csEventUserQueryParam) ;
|
||||
|
||||
@PostMapping("/addUserEventList")
|
||||
HttpResult<Boolean> addUserEventList(@RequestBody List<CsEventUserPO> list);
|
||||
|
||||
@PostMapping("/deleteByIds")
|
||||
HttpResult<Boolean> deleteByIds(@RequestBody List<String> eventList);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.njcn.csharmonic.api;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.fallback.EventUserFeignClientFallbackFactory;
|
||||
import com.njcn.csharmonic.pojo.po.PqSensitiveUser;
|
||||
import com.njcn.device.biz.pojo.po.PqSensitiveUser;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.njcn.csharmonic.api;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
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.csharmonic.api.fallback.RStatLimitRateDClientFallbackFactory;
|
||||
import com.njcn.csharmonic.pojo.param.RStatLimitQueryParam;
|
||||
import com.njcn.csharmonic.pojo.param.StatSubstationBizBaseParam;
|
||||
import com.njcn.csharmonic.pojo.po.RStatLimitRateDPO;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_HARMONIC_BOOT, path = "", fallbackFactory = RStatLimitRateDClientFallbackFactory.class,contextId = "")
|
||||
|
||||
public interface RStatLimitRateDFeignClient {
|
||||
|
||||
@PostMapping("/limitRateD/monitorIdsGetLimitRateInfo")
|
||||
HttpResult<List<RStatLimitRateDPO>> monitorIdsGetLimitRateInfo(@RequestBody RStatLimitQueryParam rStatLimitQueryParam);
|
||||
|
||||
@PostMapping("/harmonic/getLinesRate")
|
||||
HttpResult<List<RStatLimitRateDPO>> getLinesRate(@RequestBody StatSubstationBizBaseParam param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.njcn.csharmonic.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.fallback.SysExcelClientFallbackFactory;
|
||||
import com.njcn.harmonic.pojo.po.excel.SysExcel;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_HARMONIC_BOOT, path = "/sysExcel", fallbackFactory = SysExcelClientFallbackFactory.class,contextId = "sysExcel")
|
||||
|
||||
public interface SysExcelFeignClient {
|
||||
|
||||
@PostMapping("/querySysExcel")
|
||||
@ApiOperation("查询")
|
||||
HttpResult<List<SysExcel>> querySysExcel();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.njcn.csharmonic.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.fallback.SysExcelRelationClientFallbackFactory;
|
||||
import com.njcn.harmonic.common.pojo.vo.ReportTemplateVO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_HARMONIC_BOOT, path = "/sysExcelRelation", fallbackFactory = SysExcelRelationClientFallbackFactory.class,contextId = "sysExcelRelation")
|
||||
|
||||
public interface SysExcelRelationFeignClient {
|
||||
|
||||
@PostMapping("/queryList")
|
||||
HttpResult<List<ReportTemplateVO>> queryList(@RequestParam("id") String id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.njcn.csharmonic.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.CsAlarmFeignClient;
|
||||
import com.njcn.csharmonic.pojo.po.CsAlarm;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CsAlarmFeignClientFallbackFactory implements FallbackFactory<CsAlarmFeignClient> {
|
||||
@Override
|
||||
public CsAlarmFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new CsAlarmFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> addList(List<CsAlarm> list) {
|
||||
log.error("{}异常,降级处理,异常为:{}","批量写入数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<CsAlarm>> queryListByTime(String time) {
|
||||
log.error("{}异常,降级处理,异常为:{}","按日期查询数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> deleteListByTime(String time) {
|
||||
log.error("{}异常,降级处理,异常为:{}","按日期删除数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.njcn.csharmonic.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.CsHarmonicFeignClient;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonic;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CsHarmonicFeignClientFallbackFactory implements FallbackFactory<CsHarmonicFeignClient> {
|
||||
@Override
|
||||
public CsHarmonicFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new CsHarmonicFeignClient() {
|
||||
@Override
|
||||
public HttpResult<Boolean> addList(List<CsHarmonic> list) {
|
||||
log.error("{}异常,降级处理,异常为:{}","批量写入数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<CsHarmonic>> queryListByTime(String time) {
|
||||
log.error("{}异常,降级处理,异常为:{}","按日期查询数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> deleteListByTime(String time) {
|
||||
log.error("{}异常,降级处理,异常为:{}","按日期删除数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.pojo.vo.DataGroupEventVO;
|
||||
import com.njcn.csharmonic.api.EventFeignClient;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryPage;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -58,6 +59,18 @@ public class EventFeignClientFallbackFactory implements FallbackFactory<EventFei
|
||||
log.error("{}异常,降级处理,异常为:{}","根据时间获取无波形的暂态事件",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<CsEventPO>> getDevAlarmList(CsEventUserQueryParam param) {
|
||||
log.error("{}异常,降级处理,异常为:{}","获取设备运行告警事件数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<CsEventPO>> getEventByIdList(List<String> list) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据事件id集合获取事件详情异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.EventUserFeignClient;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -32,6 +33,18 @@ public class EventUserFeignClientFallbackFactory implements FallbackFactory<Even
|
||||
log.error("{}异常,降级处理,异常为:{}","获取当天事件未读消息未读消息",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> addUserEventList(List<CsEventUserPO> list) {
|
||||
log.error("{}异常,降级处理,异常为:{}","新增数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> deleteByIds(List<String> eventList) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据id删除数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.PqSensitiveUserFeignClient;
|
||||
import com.njcn.csharmonic.pojo.po.PqSensitiveUser;
|
||||
import com.njcn.device.biz.pojo.po.PqSensitiveUser;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.njcn.csharmonic.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.RStatLimitRateDFeignClient;
|
||||
import com.njcn.csharmonic.pojo.param.RStatLimitQueryParam;
|
||||
import com.njcn.csharmonic.pojo.param.StatSubstationBizBaseParam;
|
||||
import com.njcn.csharmonic.pojo.po.RStatLimitRateDPO;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class RStatLimitRateDClientFallbackFactory implements FallbackFactory<RStatLimitRateDFeignClient> {
|
||||
@Override
|
||||
public RStatLimitRateDFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new RStatLimitRateDFeignClient() {
|
||||
@Override
|
||||
public HttpResult<List<RStatLimitRateDPO>> monitorIdsGetLimitRateInfo(RStatLimitQueryParam rStatLimitQueryParam) {
|
||||
log.error("{}异常,降级处理,异常为:{}","获取指定日期超标监测点详细信息数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<RStatLimitRateDPO>> getLinesRate(StatSubstationBizBaseParam param) {
|
||||
log.error("{}异常,降级处理,异常为:{}","获取越限监测点越限次数异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.njcn.csharmonic.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.SysExcelFeignClient;
|
||||
import com.njcn.harmonic.pojo.po.excel.SysExcel;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SysExcelClientFallbackFactory implements FallbackFactory<SysExcelFeignClient> {
|
||||
@Override
|
||||
public SysExcelFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new SysExcelFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<List<SysExcel>> querySysExcel() {
|
||||
log.error("{}异常,降级处理,异常为:{}","查询模板信息异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.njcn.csharmonic.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csharmonic.api.SysExcelRelationFeignClient;
|
||||
import com.njcn.harmonic.common.pojo.vo.ReportTemplateVO;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SysExcelRelationClientFallbackFactory implements FallbackFactory<SysExcelRelationFeignClient> {
|
||||
@Override
|
||||
public SysExcelRelationFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new SysExcelRelationFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<List<ReportTemplateVO>> queryList(String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}","查询模板关系数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -45,4 +45,7 @@ public class CsEventUserQueryPage extends CsEventUserQueryParam{
|
||||
|
||||
@ApiModelProperty(value = "测点id")
|
||||
private String lineId;
|
||||
|
||||
@ApiModelProperty(value = "排序字段 0:发生时间 1:幅值 2:持续时间")
|
||||
private Integer sortField;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.csharmonic.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class PhaseData implements Serializable {
|
||||
|
||||
public String time;
|
||||
public String value;
|
||||
public String phasic;
|
||||
public String valueType;
|
||||
public double overLimitValue;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.njcn.csharmonic.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Data
|
||||
public class UnReadEventDto implements Serializable {
|
||||
|
||||
private String deviceId;
|
||||
|
||||
private Integer count;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.njcn.csharmonic.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-03-16
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("cs_alarm")
|
||||
public class CsAlarm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 告警事件id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 设备id集合
|
||||
*/
|
||||
private String devList;
|
||||
|
||||
/**
|
||||
* 发生时间
|
||||
*/
|
||||
private LocalDate time;
|
||||
|
||||
/**
|
||||
* 中断事件描述
|
||||
*/
|
||||
private String interruptEvent;
|
||||
|
||||
/**
|
||||
* 中断事件描述
|
||||
*/
|
||||
private String alarmEvent;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.njcn.csharmonic.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-03-13
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("cs_harmonic")
|
||||
public class CsHarmonic implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 稳态事件id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 监测点id
|
||||
*/
|
||||
private String lineId;
|
||||
|
||||
/**
|
||||
* 发生时间
|
||||
*/
|
||||
private LocalDate time;
|
||||
|
||||
/**
|
||||
* 事件描述
|
||||
*/
|
||||
private String tag;
|
||||
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import static com.baomidou.mybatisplus.annotation.IdType.ASSIGN_ID;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* 该实体类已废弃,使用com.njcn.device.biz.pojo.po包下的PqSensitiveUser
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
@@ -21,6 +21,7 @@ import static com.baomidou.mybatisplus.annotation.IdType.ASSIGN_ID;
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("pq_sensitive_user")
|
||||
@Deprecated
|
||||
public class PqSensitiveUser extends BaseEntity implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.njcn.csharmonic.pojo.vo;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Data
|
||||
public class AlarmVO implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "事件id")
|
||||
private String eventId;
|
||||
|
||||
@ApiModelProperty(value = "时间")
|
||||
private String date;
|
||||
|
||||
@ApiModelProperty(value = "告警设备台数")
|
||||
private Integer warnNums;
|
||||
|
||||
@ApiModelProperty(value = "告警设备id集合")
|
||||
private List<String> devIds;
|
||||
|
||||
@ApiModelProperty(value = "是否读取 0:未读取 1:读取")
|
||||
private Integer isRead;
|
||||
|
||||
@Data
|
||||
public static class AlarmDetail implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "工程名称")
|
||||
private String engineeringName;
|
||||
|
||||
@ApiModelProperty(value = "项目名称")
|
||||
private String projectName;
|
||||
|
||||
@ApiModelProperty(value = "设备名称")
|
||||
private String devName;
|
||||
|
||||
@ApiModelProperty(value = "告警次数")
|
||||
private Integer warnCounts = 0;
|
||||
|
||||
@ApiModelProperty(value = "告警详情")
|
||||
private List<WarnDetail> warnDetails = new ArrayList<>();
|
||||
|
||||
@ApiModelProperty(value = "中断次数")
|
||||
private Integer interruptCounts = 0;
|
||||
|
||||
@ApiModelProperty(value = "中断详情")
|
||||
private List<String> interruptDetails = new ArrayList<>();
|
||||
|
||||
@Data
|
||||
public static class WarnDetail implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "告警事件时间")
|
||||
private String warnEventTime;
|
||||
|
||||
@ApiModelProperty(value = "告警事件描述")
|
||||
private String warnEventDesc;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.njcn.csharmonic.pojo.vo;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Data
|
||||
public class HarmonicDetailVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "指标")
|
||||
private String targetName;
|
||||
|
||||
@ApiModelProperty(value = "越限详情")
|
||||
private List<HarmDetail> harmDetailList;
|
||||
|
||||
|
||||
@Data
|
||||
public static class HarmDetail implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "越限时间")
|
||||
private String statisticsTime;
|
||||
|
||||
@ApiModelProperty(value = "数据类型")
|
||||
private String valueType;
|
||||
|
||||
@ApiModelProperty(value = "A相数据")
|
||||
private String dataA;
|
||||
|
||||
@ApiModelProperty(value = "B相数据")
|
||||
private String dataB;
|
||||
|
||||
@ApiModelProperty(value = "C相数据")
|
||||
private String dataC;
|
||||
|
||||
@ApiModelProperty(value = "总相数据")
|
||||
private String dataT;
|
||||
|
||||
@ApiModelProperty(value = "限值")
|
||||
private Double overLimitData;
|
||||
|
||||
@ApiModelProperty(value = "是否有T相")
|
||||
private Boolean hasT;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.njcn.csharmonic.pojo.vo;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Data
|
||||
public class HarmonicVO implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "稳态数量")
|
||||
private Integer harmonicNums = 0;
|
||||
|
||||
@ApiModelProperty(value = "越限天数")
|
||||
private Integer overDays = 0;
|
||||
|
||||
@ApiModelProperty(value = "越限监测点数")
|
||||
private Integer overLineNums = 0;
|
||||
|
||||
@ApiModelProperty(value = "越限监测点数")
|
||||
private List<LineHarmonicDetail> list = new ArrayList<>();
|
||||
|
||||
@Data
|
||||
public static class LineHarmonicDetail implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "事件id")
|
||||
private String eventId;
|
||||
|
||||
@ApiModelProperty(value = "工程名称")
|
||||
private String engineeringName;
|
||||
|
||||
@ApiModelProperty(value = "项目名称")
|
||||
private String projectName;
|
||||
|
||||
@ApiModelProperty(value = "设备名称")
|
||||
private String devName;
|
||||
|
||||
@ApiModelProperty(value = "统计日期")
|
||||
private LocalDate statisticsDate;
|
||||
|
||||
@ApiModelProperty(value = "监测点id")
|
||||
private String lineId;
|
||||
|
||||
@ApiModelProperty(value = "监测点名称")
|
||||
private String lineName;
|
||||
|
||||
@ApiModelProperty(value = "越限描述")
|
||||
private String overLimitDesc;
|
||||
|
||||
@ApiModelProperty(value = "是否读取 0:未读取 1:读取")
|
||||
private Integer isRead;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
//package com.njcn.csharmonic.utils.report;
|
||||
//
|
||||
///**
|
||||
// * @author hongawen
|
||||
// * @date: 2020/8/20 13:36
|
||||
// */
|
||||
//public class ClearPathUtil {
|
||||
//
|
||||
// /**
|
||||
// * 针对漏洞,新增的特殊字符替换的扫描方法
|
||||
// */
|
||||
// public static String cleanString(String str) {
|
||||
// if (str == null) {
|
||||
// return null;
|
||||
// }
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// for (int i = 0; i < str.length(); ++i) {
|
||||
// sb.append(cleanChar(str.charAt(i)));
|
||||
// }
|
||||
// return sb.toString();
|
||||
// }
|
||||
//
|
||||
// private static char cleanChar(char ch) {
|
||||
//
|
||||
// // 0 - 9
|
||||
// for (int i = 48; i < 58; ++i) {
|
||||
// if (ch == i) {
|
||||
// return (char) i;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 'A' - 'Z'
|
||||
// for (int i = 65; i < 91; ++i) {
|
||||
// if (ch == i) {
|
||||
// return (char) i;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 'a' - 'z'
|
||||
// for (int i = 97; i < 123; ++i) {
|
||||
// if (ch == i) {
|
||||
// return (char) i;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // other valid characters
|
||||
// switch (ch) {
|
||||
// case '/':
|
||||
// return '/';
|
||||
// case '.':
|
||||
// return '.';
|
||||
// case '-':
|
||||
// return '-';
|
||||
// case '_':
|
||||
// return '_';
|
||||
// case ',':
|
||||
// return ',';
|
||||
// case ' ':
|
||||
// return ' ';
|
||||
// case '!':
|
||||
// return '!';
|
||||
// case '@':
|
||||
// return '@';
|
||||
// case '#':
|
||||
// return '#';
|
||||
// case '$':
|
||||
// return '$';
|
||||
// case '%':
|
||||
// return '%';
|
||||
// case '^':
|
||||
// return '^';
|
||||
// case '&':
|
||||
// return '&';
|
||||
// case '*':
|
||||
// return '*';
|
||||
// case '(':
|
||||
// return '(';
|
||||
// case ')':
|
||||
// return ')';
|
||||
// case '+':
|
||||
// return '+';
|
||||
// case '=':
|
||||
// return '=';
|
||||
// case ':':
|
||||
// return ':';
|
||||
// case ';':
|
||||
// return ';';
|
||||
// case '?':
|
||||
// return '?';
|
||||
// case '"':
|
||||
// return '"';
|
||||
// case '<':
|
||||
// return '<';
|
||||
// case '>':
|
||||
// return '>';
|
||||
// case '`':
|
||||
// return '`';
|
||||
// case '\\':
|
||||
// return '/';
|
||||
// case 'I':
|
||||
// return 'I';
|
||||
// case 'Ⅱ':
|
||||
// return 'Ⅱ';
|
||||
// case 'Ⅲ':
|
||||
// return 'Ⅲ';
|
||||
// case 'Ⅳ':
|
||||
// return 'Ⅳ';
|
||||
// case 'Ⅴ':
|
||||
// return 'Ⅴ';
|
||||
// case 'Ⅵ':
|
||||
// return 'Ⅵ';
|
||||
// case 'Ⅶ':
|
||||
// return 'Ⅶ';
|
||||
// case 'Ⅷ':
|
||||
// return 'Ⅷ';
|
||||
// case 'Ⅸ':
|
||||
// return 'Ⅸ';
|
||||
//
|
||||
// case 'V':
|
||||
// return 'V';
|
||||
// case 'X':
|
||||
// return 'X';
|
||||
// case 'Ⅹ':
|
||||
// return 'Ⅹ';
|
||||
// default:
|
||||
// if (isChineseChar(ch)) {
|
||||
// return ch;
|
||||
// }
|
||||
// return '%';
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 根据Unicode编码判断中文汉字和符号
|
||||
// private static boolean isChineseChar(char c) {
|
||||
// Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
|
||||
// return ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
|
||||
// || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B
|
||||
// || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS
|
||||
// || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -1,83 +0,0 @@
|
||||
//package com.njcn.csharmonic.utils.report;
|
||||
//
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.apache.poi.openxml4j.opc.OPCPackage;
|
||||
//import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
//import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||
//import org.apache.xmlbeans.XmlException;
|
||||
//import org.apache.xmlbeans.XmlToken;
|
||||
//import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
|
||||
//import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D;
|
||||
//import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline;
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//import java.io.InputStream;
|
||||
//
|
||||
//@Slf4j
|
||||
//public class CustomXWPFDocument extends XWPFDocument {
|
||||
// // 日志记录
|
||||
// public CustomXWPFDocument(InputStream in) throws IOException {
|
||||
// super(in);
|
||||
// }
|
||||
//
|
||||
// public CustomXWPFDocument() {
|
||||
// super();
|
||||
// }
|
||||
//
|
||||
// public CustomXWPFDocument(OPCPackage pkg) throws IOException {
|
||||
// super(pkg);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param id
|
||||
// * @param width
|
||||
// * 宽
|
||||
// * @param height
|
||||
// * 高
|
||||
// * @param paragraph
|
||||
// * 段落
|
||||
// */
|
||||
// public void createPicture(int id, int width, int height,String blipId, XWPFParagraph paragraph) {
|
||||
// final int EMU = 9525;
|
||||
// width *= EMU;
|
||||
// height *= EMU;
|
||||
//// String blipId = getAllPictures().get(id).getPackageRelationship().getId();
|
||||
// CTInline inline = paragraph.createRun().getCTR().addNewDrawing().addNewInline();
|
||||
// String picXml = "" + "<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">"
|
||||
// + " <a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">"
|
||||
// + " <pic:pic xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">"
|
||||
// + " <pic:nvPicPr>" + " <pic:cNvPr id=\"" + id + "\" name=\"Generated\"/>"
|
||||
// + " <pic:cNvPicPr/>" + " </pic:nvPicPr>" + " <pic:blipFill>"
|
||||
// + " <a:blip r:embed=\"" + blipId
|
||||
// + "\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"/>"
|
||||
// + " <a:stretch>" + " <a:fillRect/>" + " </a:stretch>"
|
||||
// + " </pic:blipFill>" + " <pic:spPr>" + " <a:xfrm>"
|
||||
// + " <a:off x=\"0\" y=\"0\"/>" + " <a:ext cx=\"" + width + "\" cy=\""
|
||||
// + height + "\"/>" + " </a:xfrm>" + " <a:prstGeom prst=\"rect\">"
|
||||
// + " <a:avLst/>" + " </a:prstGeom>" + " </pic:spPr>"
|
||||
// + " </pic:pic>" + " </a:graphicData>" + "</a:graphic>";
|
||||
//
|
||||
// inline.addNewGraphic().addNewGraphicData();
|
||||
// XmlToken xmlToken = null;
|
||||
// try {
|
||||
// xmlToken = XmlToken.Factory.parse(picXml);
|
||||
// } catch (XmlException xe) {
|
||||
// log.error("生成报表发生异常,异常是"+xe.getMessage());
|
||||
// }
|
||||
// inline.set(xmlToken);
|
||||
//
|
||||
// inline.setDistT(0);
|
||||
// inline.setDistB(0);
|
||||
// inline.setDistL(0);
|
||||
// inline.setDistR(0);
|
||||
//
|
||||
// CTPositiveSize2D extent = inline.addNewExtent();
|
||||
// extent.setCx(width);
|
||||
// extent.setCy(height);
|
||||
//
|
||||
// CTNonVisualDrawingProps docPr = inline.addNewDocPr();
|
||||
// docPr.setId(id);
|
||||
// docPr.setName("图片" + id);
|
||||
// docPr.setDescr("测试");
|
||||
// }
|
||||
//}
|
||||
@@ -1,28 +0,0 @@
|
||||
//package com.njcn.csharmonic.utils.report;
|
||||
//
|
||||
//import java.math.BigDecimal;
|
||||
//
|
||||
///**
|
||||
// * @author hongawen(创建) -----denghuajun(移植使用)
|
||||
// * @Date: 2018/8/27 11:29
|
||||
// */
|
||||
//public class FloatUtils {
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 保留传入进来的float的两位小数,四舍五入的方式
|
||||
// *
|
||||
// * @param data Float参数
|
||||
// */
|
||||
// public static float get2Float(Float data) {
|
||||
// if (data == null || data.isNaN() || data.isInfinite()) {
|
||||
// return 0f;
|
||||
// }
|
||||
// int scale = 2;//设置位数
|
||||
// int roundingMode = 4;//表示四舍五入,可以选择其他舍值方式,例如去尾,等等.
|
||||
// BigDecimal bd = new BigDecimal(data);
|
||||
// bd = bd.setScale(scale, roundingMode);
|
||||
// data = bd.floatValue();
|
||||
// return data;
|
||||
// }
|
||||
//}
|
||||
@@ -1,224 +0,0 @@
|
||||
//package com.njcn.csharmonic.utils.report;
|
||||
//
|
||||
//import cn.hutool.core.util.ObjectUtil;
|
||||
//import lombok.SneakyThrows;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//
|
||||
//import java.io.File;
|
||||
//import java.io.IOException;
|
||||
//import java.io.InputStream;
|
||||
//import java.text.SimpleDateFormat;
|
||||
//import java.util.*;
|
||||
//
|
||||
///**
|
||||
// * @author wr
|
||||
// * @description
|
||||
// * @date 2023/4/10 17:39
|
||||
// */
|
||||
//@Slf4j
|
||||
//public class PubUtils {
|
||||
// public static boolean createFile(String destFileName) {
|
||||
// File file = new File(destFileName);
|
||||
// if (file.exists()) {
|
||||
// log.warn("创建单个文件" + destFileName + "失败,目标文件已存在!");
|
||||
// return false;
|
||||
// }
|
||||
// if (destFileName.endsWith(File.separator)) {
|
||||
// log.warn("创建单个文件" + destFileName + "失败,目标文件不能为目录!");
|
||||
// return false;
|
||||
// }
|
||||
// //判断目标文件所在的目录是否存在
|
||||
// if (!file.getParentFile().exists()) {
|
||||
// //如果目标文件所在的目录不存在,则创建父目录
|
||||
// log.warn("目标文件所在目录不存在,准备创建它!");
|
||||
// if (!file.getParentFile().mkdirs()) {
|
||||
// log.warn("创建目标文件所在目录失败!");
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// //创建目标文件
|
||||
// try {
|
||||
// if (file.createNewFile()) {
|
||||
// log.warn("创建单个文件" + destFileName + "成功!");
|
||||
// return true;
|
||||
// } else {
|
||||
// log.warn("创建单个文件" + destFileName + "失败!");
|
||||
// return false;
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// log.warn("创建单个文件" + destFileName + "失败!" + e.getMessage());
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 读取配置文件
|
||||
// *
|
||||
// * @param cl 类名字
|
||||
// * @param strPropertiesName 配置文件名称
|
||||
// */
|
||||
// public static Properties readProperties(ClassLoader cl, String strPropertiesName) {
|
||||
// Properties pros = new Properties();
|
||||
// InputStream in = null;
|
||||
// try {
|
||||
// in = cl.getResourceAsStream(strPropertiesName);
|
||||
// pros.load(in);
|
||||
// } catch (Exception e) {
|
||||
// log.error("读取配置文件失败失败:" + e.getMessage());
|
||||
// } finally {
|
||||
// if (in != null) {
|
||||
// PubUtils.safeClose(in, "安全关闭读取配置文件失败,异常为:");
|
||||
// }
|
||||
// }
|
||||
// return pros;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 安全关闭InputStream
|
||||
// *
|
||||
// * @param s
|
||||
// */
|
||||
// public static void safeClose(InputStream s, String strError) {
|
||||
// if (s != null) {
|
||||
// try {
|
||||
// s.close();
|
||||
// } catch (IOException e) {
|
||||
// log.error(strError + e.toString());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static Double dataLimits(Double data) {
|
||||
// if (ObjectUtil.isNotNull(data)) {
|
||||
// return data > 100 ? 100 : data;
|
||||
// }
|
||||
// return data;
|
||||
// }
|
||||
//
|
||||
// @SneakyThrows
|
||||
// public static List<String> getIntervalTime(String startTime, String endTime) {
|
||||
// List<String> times = new ArrayList<>();
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
||||
// Date start = sdf.parse(startTime);
|
||||
// Date end = sdf.parse(endTime);
|
||||
// // 同月
|
||||
// if (start.getTime() == end.getTime()) {
|
||||
// String time = startTime.substring(0, 7);
|
||||
// times.add(time);
|
||||
// } else if (start.getYear() == end.getYear()) {
|
||||
// // 同年
|
||||
// int startM = start.getMonth() + 1;
|
||||
// int endM = end.getMonth() + 1;
|
||||
// int temp = endM - startM;
|
||||
// for (int i = 0; i <= temp; i++) {
|
||||
// String time = start.getYear() + 1900 + "";
|
||||
// int month = startM + i;
|
||||
// if (month < 10) {
|
||||
// time = time + "-0" + month;
|
||||
// } else {
|
||||
// time = time + "-" + month;
|
||||
// }
|
||||
// times.add(time);
|
||||
// }
|
||||
// } else {
|
||||
// // 不同年!!!!这里忽略了年份之间跨年的情况
|
||||
// int startY = start.getYear() + 1900;
|
||||
// int startM = start.getMonth() + 1;
|
||||
// int endY = end.getYear() + 1900;
|
||||
// int endM = end.getMonth() + 1;
|
||||
// int tempS = 12 - startM;
|
||||
// // 连续的年份
|
||||
// if (endY - startY == 1) {
|
||||
// // 第一年的时间获取
|
||||
// for (int i = 0; i <= tempS; i++) {
|
||||
// int month = startM + i;
|
||||
// String time = startY + "-";
|
||||
// if (month < 10) {
|
||||
// time = time + "0" + month;
|
||||
// } else {
|
||||
// time = time + month;
|
||||
// }
|
||||
// times.add(time);
|
||||
// }
|
||||
// // 第二年的时间获取
|
||||
//
|
||||
// for (int i = 1; i <= endM; i++) {
|
||||
// String time = endY + "-";
|
||||
// if (i < 10) {
|
||||
// time = time + "0" + i;
|
||||
// } else {
|
||||
// time = time + i;
|
||||
// }
|
||||
// times.add(time);
|
||||
// }
|
||||
// } else {
|
||||
// // 不连续的年份
|
||||
// // 第一年的时间获取
|
||||
// for (int i = 0; i <= tempS; i++) {
|
||||
// int month = startM + i;
|
||||
// String time = startY + "-";
|
||||
// if (month < 10) {
|
||||
// time = time + "0" + month;
|
||||
// } else {
|
||||
// time = time + month;
|
||||
// }
|
||||
// times.add(time);
|
||||
// }
|
||||
// int tempY = endY - startY;
|
||||
// // 中间年份的时间
|
||||
// for (int i = 1; i < tempY; i++) {
|
||||
// for (int j = 1; j <= 12; j++) {
|
||||
// String time = startY + i + "-";
|
||||
// if (j < 10) {
|
||||
// time = time + "0" + j;
|
||||
// } else {
|
||||
// time = time + j;
|
||||
// }
|
||||
// times.add(time);
|
||||
// }
|
||||
// }
|
||||
// // 最后一年的时间获取
|
||||
// for (int i = 1; i <= endM; i++) {
|
||||
// String time = endY + "-";
|
||||
// if (i < 10) {
|
||||
// time = time + "0" + i;
|
||||
// } else {
|
||||
// time = time + i;
|
||||
// }
|
||||
// times.add(time);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// return times;
|
||||
// }
|
||||
//
|
||||
// @SneakyThrows
|
||||
// public static List<String> getIntervalDateTime(Integer startTime, int beginDay, Integer endTime, Integer dd) {
|
||||
// List<String> list = new ArrayList<>();
|
||||
// Calendar calendar = Calendar.getInstance(Locale.CHINA);
|
||||
// calendar.set(startTime, endTime - 1, 1);
|
||||
// //年份
|
||||
// int year = calendar.get(Calendar.YEAR);
|
||||
// //月份
|
||||
// int month = calendar.get(Calendar.MONTH) + 1;
|
||||
// for (int i = beginDay; i <= dd; i++) {
|
||||
// String date = null;
|
||||
// if (month < 10 && i < 10) {
|
||||
// date = year + "-0" + month + "-0" + i;
|
||||
// }
|
||||
// if (month < 10 && i >= 10) {
|
||||
// date = year + "-0" + month + "-" + i;
|
||||
// }
|
||||
// if (month >= 10 && i < 10) {
|
||||
// date = year + "-" + month + "-0" + i;
|
||||
// }
|
||||
// if (month >= 10 && i >= 10) {
|
||||
// date = year + "-" + month + "-" + i;
|
||||
// }
|
||||
//
|
||||
// list.add(date);
|
||||
// }
|
||||
// return list;
|
||||
// }
|
||||
//}
|
||||
@@ -1,30 +0,0 @@
|
||||
//package com.njcn.csharmonic.utils.report;
|
||||
//
|
||||
///**
|
||||
// * 数据公共工具类
|
||||
// *
|
||||
// * @author qijian
|
||||
// * @version 1.0.0
|
||||
// * @createTime 2022/10/14 - 10:07
|
||||
// */
|
||||
//public class PublicDataUtils {
|
||||
// /**
|
||||
// * 功能:下划线命名转驼峰命名
|
||||
// * 将下划线替换为空格,将字符串根据空格分割成数组,再将每个单词首字母大写
|
||||
// * @param s
|
||||
// * @return
|
||||
// */
|
||||
// public static String underCamel(String s)
|
||||
// {
|
||||
// String separator = "_";
|
||||
// String under="";
|
||||
// s = s.toLowerCase().replace(separator, " ");
|
||||
// String sarr[]=s.split(" ");
|
||||
// for(int i=0;i<sarr.length;i++)
|
||||
// {
|
||||
// String w=sarr[i].substring(0,1).toUpperCase()+sarr[i].substring(1);
|
||||
// under +=w;
|
||||
// }
|
||||
// return under;
|
||||
// }
|
||||
//}
|
||||
@@ -1,25 +0,0 @@
|
||||
//package com.njcn.csharmonic.utils.report;
|
||||
//
|
||||
//import com.alibaba.fastjson.serializer.JSONSerializer;
|
||||
//import com.alibaba.fastjson.serializer.ObjectSerializer;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//import java.lang.reflect.Type;
|
||||
//import java.sql.Timestamp;
|
||||
//
|
||||
//@Component
|
||||
//public class TimestampAsLongSerializer implements ObjectSerializer {
|
||||
//
|
||||
// @Override
|
||||
// public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
|
||||
// if (object instanceof Timestamp) {
|
||||
// Timestamp timestamp = (Timestamp) object;
|
||||
// // 将Timestamp转换为时间戳(毫秒数)
|
||||
// long time = timestamp.getTime();
|
||||
// serializer.write(time);
|
||||
// } else {
|
||||
// serializer.write(object);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -1,427 +0,0 @@
|
||||
//package com.njcn.csharmonic.utils.report;
|
||||
//
|
||||
//import cn.hutool.core.collection.CollUtil;
|
||||
//import com.njcn.oss.constant.OssPath;
|
||||
//import com.njcn.oss.utils.FileStorageUtil;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.apache.poi.xwpf.usermodel.*;
|
||||
//import org.apache.tomcat.util.http.fileupload.IOUtils;
|
||||
//import org.springframework.core.io.ClassPathResource;
|
||||
//import org.springframework.core.io.Resource;
|
||||
//import org.springframework.core.io.ResourceLoader;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//import org.springframework.util.FileCopyUtils;
|
||||
//
|
||||
//import javax.servlet.ServletOutputStream;
|
||||
//import javax.servlet.http.HttpServletResponse;
|
||||
//import java.io.*;
|
||||
//import java.util.*;
|
||||
//import java.util.Map.Entry;
|
||||
//import java.util.regex.Matcher;
|
||||
//import java.util.regex.Pattern;
|
||||
//
|
||||
//@Slf4j
|
||||
//@Component
|
||||
//@RequiredArgsConstructor
|
||||
//public class WordUtil2 {
|
||||
//
|
||||
//
|
||||
// private final ResourceLoader resourceLoader;
|
||||
// private final FileStorageUtil fileStorageUtil;
|
||||
//
|
||||
//
|
||||
// public void getWord(String path, Map<String, Object> params, String fileName,List<List<String[]>> tableList, HttpServletResponse response)
|
||||
// throws Exception {
|
||||
// byte[] docBytes = null;
|
||||
//
|
||||
// path = ClearPathUtil.cleanString(path);
|
||||
// InputStream is = null;
|
||||
// CustomXWPFDocument doc = null;
|
||||
// //读取报告模板
|
||||
// try {
|
||||
// Resource resource = resourceLoader.getResource("classpath:" + path);
|
||||
// if (!resource.exists()) {
|
||||
// throw new FileNotFoundException("模板文件未找到: " + path);
|
||||
// }
|
||||
// is = resource.getInputStream();
|
||||
// doc = new CustomXWPFDocument(is);
|
||||
// if(CollUtil.isNotEmpty(tableList)){
|
||||
// this.replaceInTable(doc, params,tableList);
|
||||
// }else{
|
||||
// this.replaceInTable(doc, params);
|
||||
// }
|
||||
// // 替换表格里面的变量
|
||||
// this.replaceInPara(doc, params); // 替换文本里面的变量
|
||||
// } catch (IOException e) {
|
||||
// getError("获取报告模板异常,原因为:" + e);
|
||||
// } finally {
|
||||
// if (null != is) {
|
||||
// is.close();
|
||||
// }
|
||||
// }
|
||||
// try {
|
||||
// ServletOutputStream outputStream = response.getOutputStream();
|
||||
// response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
|
||||
// response.setContentType("application/octet-stream;charset=UTF-8");
|
||||
// doc.write(outputStream);
|
||||
// outputStream.close();
|
||||
// } catch (Exception e) {
|
||||
// getError("输出稳态报告异常,原因为:" + e);
|
||||
// } finally {
|
||||
// if (doc != null) {
|
||||
// doc.close();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// // 辅助方法:字节数组转十六进制(便于打印排查)
|
||||
// private static String bytesToHex(byte[] bytes) {
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// for (byte b : bytes) {
|
||||
// sb.append(String.format("%02X ", b));
|
||||
// }
|
||||
// return sb.toString().trim();
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// public InputStream getReportFile(String path, Map<String, Object> params, List<List<String[]>> tableList)
|
||||
// throws Exception {
|
||||
// path = ClearPathUtil.cleanString(path);
|
||||
// InputStream inStream = null,in = null;
|
||||
// CustomXWPFDocument doc = null;
|
||||
// //读取报告模板
|
||||
// try {
|
||||
// inStream = new ClassPathResource(path).getInputStream();
|
||||
// doc = new CustomXWPFDocument(inStream);
|
||||
// this.replaceInTable(doc,params,tableList);
|
||||
// this.replaceInPara(doc, params);
|
||||
// } catch (IOException e) {
|
||||
// getError("获取报告模板异常,原因为:" + e);
|
||||
// } finally {
|
||||
// if (null != inStream) {
|
||||
// inStream.close();
|
||||
// }
|
||||
// }
|
||||
// try {
|
||||
// //临时缓冲区
|
||||
// ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
// doc.write(out);
|
||||
// byte[] docByteAry = out.toByteArray();
|
||||
// in = new ByteArrayInputStream(docByteAry);
|
||||
// out.close();
|
||||
// } catch (Exception e) {
|
||||
// getError("输出稳态报告异常,原因为:" + e);
|
||||
// } finally {
|
||||
// if (doc != null) {
|
||||
// doc.close();
|
||||
// }
|
||||
// }
|
||||
// return in;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// public String getReportFileUrl(String path,String fileName,List<List<String[]>> tableList, Map<String, Object> params)
|
||||
// throws Exception {
|
||||
// path = ClearPathUtil.cleanString(path);
|
||||
// InputStream inStream = null,in = null;
|
||||
// CustomXWPFDocument doc = null;
|
||||
// //读取报告模板
|
||||
// try {
|
||||
// inStream = new ClassPathResource(path).getInputStream();;
|
||||
// doc = new CustomXWPFDocument(inStream);
|
||||
// if(CollUtil.isNotEmpty(tableList)){
|
||||
// this.replaceInTable(doc, params,tableList);
|
||||
// }else{
|
||||
// this.replaceInTable(doc, params);
|
||||
// }
|
||||
// this.replaceInPara(doc, params); // 替换文本里面的变量
|
||||
// //临时缓冲区
|
||||
// ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
// doc.write(out);
|
||||
// byte[] docByteAry = out.toByteArray();
|
||||
// in = new ByteArrayInputStream(docByteAry);
|
||||
// out.close();
|
||||
// } catch (IOException e) {
|
||||
// getError("获取报告模板异常,原因为:" + e);
|
||||
// } finally {
|
||||
// if (null != inStream) {
|
||||
// inStream.close();
|
||||
// }
|
||||
// if (doc != null) {
|
||||
// doc.close();
|
||||
// }
|
||||
// }
|
||||
// //上传文件服务器
|
||||
// return fileStorageUtil.uploadStreamSpecifyName(in, OssPath.ONLINE_REPORT, fileName);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private static void getError(String e) {
|
||||
// log.error(e);
|
||||
// }
|
||||
// /**
|
||||
// * 替换段落里面的变量
|
||||
// *
|
||||
// * @param doc 要替换的文档
|
||||
// * @param params 参数
|
||||
// */
|
||||
// private void replaceInPara(CustomXWPFDocument doc, Map<String, Object> params) {
|
||||
// Iterator<XWPFParagraph> iterator = doc.getParagraphsIterator();
|
||||
// List<XWPFParagraph> paragraphList = new ArrayList<>();
|
||||
// XWPFParagraph para;
|
||||
// while (iterator.hasNext()) {
|
||||
// para = iterator.next();
|
||||
// paragraphList.add(para);
|
||||
// }
|
||||
// processParagraphs(paragraphList, params, doc);
|
||||
// }
|
||||
//
|
||||
// private void replaceInTable(CustomXWPFDocument doc, Map<String, Object> params) {
|
||||
// Iterator<XWPFTable> it = doc.getTablesIterator();
|
||||
// while (it.hasNext()) {
|
||||
// XWPFTable table = it.next();
|
||||
// List<XWPFTableRow> rows = table.getRows();
|
||||
// for (XWPFTableRow row : rows) {
|
||||
// List<XWPFTableCell> cells = row.getTableCells();
|
||||
// for (XWPFTableCell cell : cells) {
|
||||
// List<XWPFParagraph> paragraphListTable = cell.getParagraphs();
|
||||
// processParagraphs(paragraphListTable, params, doc);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static void processParagraphs(List<XWPFParagraph> paragraphList, Map<String, Object> param,
|
||||
// CustomXWPFDocument doc) {
|
||||
// if (paragraphList != null && paragraphList.size() > 0) {
|
||||
// for (XWPFParagraph paragraph : paragraphList) {
|
||||
// List<XWPFRun> runs = paragraph.getRuns();
|
||||
// if (runs.size() > 0) {
|
||||
// for (XWPFRun run : runs) {
|
||||
// String bflag = "";
|
||||
// String text = run.getText(0);
|
||||
// if (text != null) {
|
||||
// boolean isSetText = false;
|
||||
// for (Entry<String, Object> entry : param.entrySet()) {
|
||||
// String key = entry.getKey();
|
||||
// if (text.indexOf(key) != -1) {
|
||||
// isSetText = true;
|
||||
// Object value = entry.getValue();
|
||||
// if (value instanceof String) {// 文本替换
|
||||
// text = text.replace(key, value.toString());
|
||||
// } else if (value instanceof Map) {// 图片替换
|
||||
// text = text.replace(key, "");
|
||||
// Map pic = (Map) value;
|
||||
// int width = Integer.parseInt(pic.get("width").toString());
|
||||
// int height = Integer.parseInt(pic.get("height").toString());
|
||||
// int picType = getPictureType(pic.get("type").toString());
|
||||
// byte[] byteArray = (byte[]) pic.get("content");
|
||||
// ByteArrayInputStream byteInputStream = new ByteArrayInputStream(byteArray);
|
||||
// try {
|
||||
// String s = doc.addPictureData(byteInputStream, picType);
|
||||
//
|
||||
// doc.createPicture(doc.getAllPictures().size() - 1, width, height,
|
||||
// s,paragraph);
|
||||
// bflag = "break";
|
||||
// } catch (Exception e) {
|
||||
// getError("文本替换发生异常,异常是" + e.getMessage());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (isSetText) {
|
||||
// run.setText(text, 0);
|
||||
// }
|
||||
// }
|
||||
// if (bflag == "break") {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 替换段落里面的变量
|
||||
// *
|
||||
// * @param para 要替换的段落
|
||||
// * @param params 参数
|
||||
// */
|
||||
// private void replaceInPara(XWPFParagraph para, Map<String, Object> params, CustomXWPFDocument doc) {
|
||||
// List<XWPFRun> runs;
|
||||
// Matcher matcher;
|
||||
// // if (this.matcher(para.getParagraphText()).find()) {
|
||||
// runs = para.getRuns();
|
||||
// int start = -1;
|
||||
// int end = -1;
|
||||
// String str = "";
|
||||
// for (int i = 0; i < runs.size(); i++) {
|
||||
// XWPFRun run = runs.get(i);
|
||||
// String runText = run.toString();
|
||||
// if ('$' == runText.charAt(0) && '{' == runText.charAt(1)) {
|
||||
// start = i;
|
||||
// }
|
||||
// if ((start != -1)) {
|
||||
// str += runText;
|
||||
// }
|
||||
// if ('}' == runText.charAt(runText.length() - 1)) {
|
||||
// if (start != -1) {
|
||||
// end = i;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (int i = start; i <= end; i++) {
|
||||
// para.removeRun(i);
|
||||
// i--;
|
||||
// end--;
|
||||
// }
|
||||
//
|
||||
// for (Entry<String, Object> entry : params.entrySet()) {
|
||||
// String key = entry.getKey();
|
||||
// if (str.indexOf(key) != -1) {
|
||||
// Object value = entry.getValue();
|
||||
// if (value instanceof String) {
|
||||
// str = str.replace(key, value.toString());
|
||||
// para.createRun().setText(str, 0);
|
||||
// break;
|
||||
// } else if (value instanceof Map) {
|
||||
// str = str.replace(key, "");
|
||||
// Map pic = (Map) value;
|
||||
// int width = Integer.parseInt(pic.get("width").toString());
|
||||
// int height = Integer.parseInt(pic.get("height").toString());
|
||||
// int picType = getPictureType(pic.get("type").toString());
|
||||
// byte[] byteArray = (byte[]) pic.get("content");
|
||||
// ByteArrayInputStream byteInputStream = new ByteArrayInputStream(byteArray);
|
||||
// try {
|
||||
// // int ind = doc.addPicture(byteInputStream,picType);
|
||||
// // doc.createPicture(ind, width , height,para);
|
||||
// String s = doc.addPictureData(byteInputStream, picType);
|
||||
// doc.createPicture(doc.getAllPictures().size() - 1, width, height,s, para);
|
||||
// para.createRun().setText(str, 0);
|
||||
// break;
|
||||
// } catch (Exception e) {
|
||||
// getError("文件替换发生异常,异常是" + e.getMessage());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// // }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 为表格插入数据,行数不够添加新行
|
||||
// *
|
||||
// * @param table 需要插入数据的表格
|
||||
// * @param tableList 插入数据集合
|
||||
// */
|
||||
// private static void insertTable(XWPFTable table, List<String[]> tableList) {
|
||||
// //删除占位符行数
|
||||
// table.removeRow(1);
|
||||
// if (CollUtil.isNotEmpty(tableList)) {
|
||||
// // 创建行,根据需要插入的数据添加新行,不处理表头
|
||||
// for (int i = 0; i < tableList.size(); i++) {
|
||||
// XWPFTableRow row = table.createRow();
|
||||
// List<XWPFTableCell> cells = row.getTableCells();
|
||||
// for (int j = 0; j < cells.size(); j++) {
|
||||
// String s = tableList.get(i)[j];
|
||||
// XWPFTableCell cell = cells.get(j);
|
||||
// cell.removeParagraph(0);
|
||||
// XWPFParagraph paragraph = cell.addParagraph();
|
||||
// paragraph.setAlignment(ParagraphAlignment.CENTER);
|
||||
// // 在段落中添加文本
|
||||
// XWPFRun run = paragraph.createRun();
|
||||
// run.setText(s);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 替换表格里面的变量
|
||||
// *
|
||||
// * @param doc 要替换的文档
|
||||
// * @param tableList 存放数据顺序要与表格一致
|
||||
// * @param params 参数
|
||||
// */
|
||||
// private void replaceInTable(CustomXWPFDocument doc, Map<String, Object> params, List<List<String[]>> tableList) {
|
||||
// Iterator<XWPFTable> iterator = doc.getTablesIterator();
|
||||
// XWPFTable table;
|
||||
// List<XWPFTableRow> rows;
|
||||
// List<XWPFTableCell> cells;
|
||||
// List<XWPFParagraph> paras;
|
||||
// Integer num=0;
|
||||
// while (iterator.hasNext()) {
|
||||
// table = iterator.next();
|
||||
// if (table.getRows().size() > 1) {
|
||||
// // 判断表格是需要替换还是需要插入,判断逻辑有$为替换,表格无$为插入
|
||||
// if (this.matcher(table.getText()).find()||this.matcherS(table.getText()).find()) {
|
||||
// rows = table.getRows();
|
||||
// for (XWPFTableRow row : rows) {
|
||||
// cells = row.getTableCells();
|
||||
// for (XWPFTableCell cell : cells) {
|
||||
// List<XWPFParagraph> paragraphListTable = cell.getParagraphs();
|
||||
// processParagraphs(paragraphListTable, params, doc);
|
||||
// }
|
||||
// }
|
||||
// }else {
|
||||
// if (CollUtil.isNotEmpty(tableList.get(num))){
|
||||
// insertTable(table, tableList.get(num)); // 插入数据
|
||||
// }
|
||||
// num++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 正则匹配字符串
|
||||
// *
|
||||
// * @param str
|
||||
// * @return
|
||||
// */
|
||||
// private Matcher matcher(String str) {
|
||||
// Pattern pattern = Pattern.compile("\\$\\{(.+?)\\}", Pattern.CASE_INSENSITIVE);
|
||||
// Matcher matcher = pattern.matcher(str);
|
||||
// return matcher;
|
||||
// }
|
||||
// private Matcher matcherS(String str) {
|
||||
// Pattern pattern = Pattern.compile("\\$(.*?)\\$");
|
||||
// Matcher matcher = pattern.matcher(str);
|
||||
// return matcher;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 根据图片类型,取得对应的图片类型代码
|
||||
// *
|
||||
// * @param picType
|
||||
// * @return int
|
||||
// */
|
||||
// private static int getPictureType(String picType) {
|
||||
// int res = CustomXWPFDocument.PICTURE_TYPE_PICT;
|
||||
// if (picType != null) {
|
||||
// if (picType.equalsIgnoreCase("image/png")) {
|
||||
// res = CustomXWPFDocument.PICTURE_TYPE_PNG;
|
||||
// } else if (picType.equalsIgnoreCase("image/dib")) {
|
||||
// res = CustomXWPFDocument.PICTURE_TYPE_DIB;
|
||||
// } else if (picType.equalsIgnoreCase("image/emf")) {
|
||||
// res = CustomXWPFDocument.PICTURE_TYPE_EMF;
|
||||
// } else if (picType.equalsIgnoreCase("image/jpg") || picType.equalsIgnoreCase("image/jpeg")) {
|
||||
// res = CustomXWPFDocument.PICTURE_TYPE_JPEG;
|
||||
// } else if (picType.equalsIgnoreCase("image/wmf")) {
|
||||
// res = CustomXWPFDocument.PICTURE_TYPE_WMF;
|
||||
// }
|
||||
// }
|
||||
// return res;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
Reference in New Issue
Block a user