Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
haungxing 7 months ago
parent
commit
50bc543ab2
  1. 35
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java
  2. 2
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/constant/TicketConstant.java
  3. 4
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java
  4. 5
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/MergeDocUtils.java
  5. 12
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/ObjectUtils.java
  6. BIN
      hzims-service/ticket/src/main/resources/template/水力机械工作票模版.docx

35
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java

@ -10,7 +10,6 @@ import com.hnac.hzims.equipment.entity.EmParamEntity;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.hzimsweather.feign.IHeWeatherWeatherClient;
import com.hnac.hzims.hzimsweather.vo.RainFallCountByMonthVo;
import com.hnac.hzims.operational.config.vo.StationRealVo;
import com.hnac.hzims.operational.fill.entity.RainfallEntity;
import com.hnac.hzims.operational.home.wind.RainMon;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
@ -40,7 +39,7 @@ import com.hnac.hzinfo.sdk.core.response.Result;
import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient;
import com.hnac.hzinfo.sdk.v5.device.dto.ReductionDataDTO;
import com.hnac.hzinfo.sdk.v5.device.vo.ReductionDataVO;
import lombok.Getter;
import io.undertow.util.CopyOnWriteMap;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
@ -113,8 +112,6 @@ public class RealTargetServiceImpl implements RealTargetService {
@Value("${hzims.operation.realIdKey}")
public String real_id_cofig_final;
// 创建线程池
ExecutorService pool = new ThreadPoolExecutor(8, 8, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("load-power-data-pool-%d").build(), new ThreadPoolExecutor.AbortPolicy());
private final static String recent_year_power_data = "hzims:operation:key:power:data";
private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key";
@ -126,6 +123,9 @@ public class RealTargetServiceImpl implements RealTargetService {
private final static String load_photovoltaic_real_key = "hzims:operation:photovoltaic:real:key";
private final static String load_photovoltaic_target_key = "hzims:operation:photovoltaic:target:key";
// 创建线程池
private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("load-power-data-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy());
@Override
public void loadEmInfo(String param) {
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
@ -1227,7 +1227,6 @@ public class RealTargetServiceImpl implements RealTargetService {
public void loadPowerData(String param, List<Integer> types, Integer serveType, int year) {
// 站点查询
List<StationEntity> stations = stationService.list(new LambdaQueryWrapper<StationEntity>() {{
eq(StationEntity::getDataOrigin,HomePageConstant.DATA_ORIGIN);
if (ObjectUtil.isNotEmpty(serveType)) {
eq(StationEntity::getServeType, serveType);
}
@ -1248,14 +1247,13 @@ public class RealTargetServiceImpl implements RealTargetService {
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00";
// 存储数据map :<站点id,<月份,发电量>>
Map<Long, Map<String, Float>> powerMap = new ConcurrentHashMap<>();
Map<Long, Map<String, Float>> powerMap = new CopyOnWriteMap<>();
// 将站点切割
int limit = countStep(stations.size());
List<List<StationEntity>> limits = Stream.iterate(0, n -> n + 1).limit(limit).parallel().map(a -> stations.stream().skip((long) a * 5).limit(5).parallel().collect(Collectors.toList())).collect(Collectors.toList());
// 线程数量
List<List<StationEntity>> limits = Stream.iterate(0, n -> n + 1).limit(limit).parallel().map(a -> stations.stream().skip((long) a * 3).limit(3).parallel().collect(Collectors.toList())).collect(Collectors.toList());
CountDownLatch countDownLatch = new CountDownLatch(limits.size());
pool.execute(()->{
for(List<StationEntity> item : limits){
for(List<StationEntity> item : limits){
pool.submit(()->{
item.forEach(station->{
// 站点设备集合
List<EminfoAndEmParamVo> stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList());
@ -1266,20 +1264,22 @@ public class RealTargetServiceImpl implements RealTargetService {
powerMap.put(station.getId(),generateMap);
});
countDownLatch.countDown();
}
});
// 等待所有线程执行完成
log.error("pool_item_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList()));
});
}
//所有模板数据获取完成后释放锁
try {
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
pool.shutdown();
redisTemplate.opsForValue().set(recent_year_power_data, powerMap);
}
@Override
public void loadPowerDataNew(List<Integer> types, Integer serveType, int year) {
// 站点查询
List<StationEntity> stationList = stationService.list(new LambdaQueryWrapper<StationEntity>() {{
@ -1426,7 +1426,6 @@ public class RealTargetServiceImpl implements RealTargetService {
*/
private Map<String, Float> getGenerateYear(StationEntity station,List<EminfoAndEmParamVo> devices, String start, String end) {
List<PowerMonthVo> datas = new ArrayList<>();
long l = System.currentTimeMillis();
// 设备采集发电量
if(CollectionUtil.isNotEmpty(devices)){
devices.forEach(device->{
@ -1447,17 +1446,11 @@ public class RealTargetServiceImpl implements RealTargetService {
}).collect(Collectors.toList()));
});
}
long l2 = System.currentTimeMillis();
log.info("getGenerateYear接口,"+station.getName()+"-设备采集发电量数据耗时:"+(l2-l));
// 补充填报数据
datas.addAll(this.generateFill(station,start,end));
long l3 = System.currentTimeMillis();
log.info("getGenerateYear接口,"+station.getName()+":补充填报数据"+(l3-l2));
if(CollectionUtil.isEmpty(datas)){
return null;
}
long l4 = System.currentTimeMillis();
log.info("getGenerateYear接口,"+station.getName()+":接口总耗时"+(l4-l));
return datas.stream().collect(Collectors.toMap(PowerMonthVo::getStrMonth, PowerMonthVo::getPower, Float::sum));
}
/**

2
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/constant/TicketConstant.java

@ -12,7 +12,7 @@ public class TicketConstant {
/**
* window操作系统工作票访问路径
*/
public static final String TICKET_WINDOW_PATH = "E:/project/HZIMS/hzims-service/ticket/src/main/resources/template/";
public static final String TICKET_WINDOW_PATH = "D:/Java/hzims-back/hzims-service/ticket/src/main/resources/template/";
/**
* Liunx操作系统工作票访问路径

4
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java

@ -321,7 +321,7 @@ public class FirstWorkTicketServiceImpl extends BaseServiceImpl<WorkTicketInfoMa
return pdfSavePath;
}
else {
return "E://template/";
return "D://template/";
}
}
@ -394,9 +394,11 @@ public class FirstWorkTicketServiceImpl extends BaseServiceImpl<WorkTicketInfoMa
if(Func.isNotEmpty(finish.getLicensorEndTime())) {
if(workTicketInfoEntity.getIsOffline()) {
params.put("licensorName2",finish.getEndLicensorName());
params.put("licensorNameEnd",finish.getFinishLicensorName());
}
else {
params.put("licensorName2",params.get("licensorName"));
params.put("licensorNameEnd",params.get("licensorName"));
}
params.put("groundNum",finish.getGroundNum());
params.put("dismantleNum",finish.getDismantleNum());

5
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/MergeDocUtils.java

@ -49,12 +49,13 @@ public class MergeDocUtils {
doc = documentList.get(0);
if (i == 0) {
//首页直接分页,不再插入首页文档内容
documentList.get(i).createParagraph().createRun().addBreak(BreakType.PAGE);
// 去除增加得分页2024.0424
// documentList.get(i).createParagraph().createRun().addBreak(BreakType.PAGE);
} else if (i == documentList.size() - 1) {
//尾页不再分页,直接插入最后文档内容
appendBody(doc, documentList.get(i));
} else {
documentList.get(i).createParagraph().createRun().addBreak(BreakType.PAGE);
// documentList.get(i).createParagraph().createRun().addBreak(BreakType.PAGE);
appendBody(doc, documentList.get(i));
}
}

12
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/ObjectUtils.java

@ -76,12 +76,12 @@ public class ObjectUtils {
*/
public static Map LocalDateConvertMap(LocalDateTime dateTime,String prefix,String split) {
HashMap<String, Object> result = new HashMap<String, Object>() {{
put(prefix + split + "year", dateTime.getYear());
put(prefix + split + "month", dateTime.getMonthValue());
put(prefix + split + "day", dateTime.getDayOfMonth());
put(prefix + split + "hour", dateTime.getHour());
put(prefix + split + "minuter", dateTime.getMinute());
put(prefix + split + "second", dateTime.getSecond());
put(prefix + split + "year",String.format("%02d", dateTime.getYear()));
put(prefix + split + "month",String.format("%02d",dateTime.getMonthValue()));
put(prefix + split + "day",String.format("%02d", dateTime.getDayOfMonth()));
put(prefix + split + "hour",String.format("%02d", dateTime.getHour()));
put(prefix + split + "minuter", String.format("%02d",dateTime.getMinute()));
put(prefix + split + "second",String.format("%02d",dateTime.getSecond()));
}};
return result;
}

BIN
hzims-service/ticket/src/main/resources/template/水力机械工作票模版.docx

Binary file not shown.
Loading…
Cancel
Save