dfbb8185 kangwei

Merge remote-tracking branch 'origin/master'

2 个父辈 4ca8a4da bbf071e3
package com.skua.common.constant;
/**
* <pre>
* 常量
* </pre>
*
* @author sonin
* @version 1.0 2023/3/9 10:12
*/
public interface BusinessConstant {
String dateFormat = "yyyy-MM-dd HH:mm:ss";
String startTimeSuffix = " 00:00:00";
String endTimeSuffix = " 23:59:59";
String countSuffix = "Count";
String sumSuffix = "Sum";
}
package com.skua.modules.biz;
import java.util.Collection;
import java.util.Map;
/**
* @Author:sonin
* @Date:2025/2/18 15:35
*/
public interface IBusinessService {
Map<String, String> dictMap(String dictCode, Collection<?> inCol);
}
package com.skua.modules.biz.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.skua.modules.base.service.IBaseService;
import com.skua.modules.biz.IBusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author:sonin
* @Date:2025/2/18 15:35
*/
@Service
public class BusinessServiceImpl implements IBusinessService {
@Autowired
private IBaseService baseService;
@Override
public Map<String, String> dictMap(String dictCode, Collection<?> inCol) {
String key0, value0, table0;
QueryWrapper<?> queryWrapper0 = new QueryWrapper<>();
if ("equipment_info".equals(dictCode)) {
key0 = "id";
value0 = "equipment_name";
table0 = dictCode;
} else if ("sys_user".equals(dictCode)) {
key0 = "id";
value0 = "realname";
table0 = dictCode;
} else if ("sys_struct_dict".equals(dictCode)) {
key0 = "id";
value0 = "struct_name";
table0 = dictCode;
} else if ("equipment_category".equals(dictCode)) {
key0 = "id";
value0 = "des";
table0 = dictCode;
} else if ("evaluate_score_desc".equals(dictCode)) {
key0 = "id";
value0 = "score_desc";
table0 = dictCode;
} else if ("carbon_qualitative_desc".equals(dictCode)) {
key0 = "id";
value0 = "qualitative_desc";
table0 = dictCode;
} else if ("sys_depart".equals(dictCode)) {
key0 = "id";
value0 = "depart_name";
table0 = dictCode;
} else {
// 数据字典查询
queryWrapper0.eq("sys_dict.dict_code", dictCode);
key0 = "sys_dict_item.item_value";
value0 = "sys_dict_item.item_text";
table0 = "sys_dict inner join sys_dict_item on sys_dict.id = sys_dict_item.dict_id";
}
String sqlSelect = "select " + key0 + " as key0, " + value0 + " as value0 from " + table0;
if (inCol != null && !inCol.isEmpty()) {
queryWrapper0.in(key0, inCol);
}
List<Map<String, Object>> queryMapList0 = baseService.queryForList(sqlSelect, queryWrapper0);
Map<String, String> dictMap = new HashMap<>(10);
for (Map<String, Object> item : queryMapList0) {
dictMap.put(String.valueOf(item.get("key0")), String.valueOf(item.get("value0")));
}
return dictMap;
}
}
......@@ -6,9 +6,9 @@
<select id="topCensus" resultType="java.util.Map">
select
'年度安全隐患统计(起)' as 'name','yh' as 'code',
ifnull( SUM( CASE WHEN LEFT ( sr.rec_ord_whenlong, 7 ) = #{nowMonth} THEN 1 ELSE 0 END ),0) as now,
ifnull( SUM( CASE WHEN LEFT ( sr.rec_ord_whenlong, 4 ) = #{nowYear} THEN 1 ELSE 0 END),0) as nowYear,
ifnull( SUM( CASE WHEN LEFT ( sr.rec_ord_whenlong, 4 ) = #{lastYear} THEN 1 ELSE 0 END ),0) as last_year
ifnull( SUM( CASE WHEN LEFT ( sr.rec_ord_report_date, 7 ) = #{nowMonth} THEN 1 ELSE 0 END ),0) as now,
ifnull( SUM( CASE WHEN LEFT ( sr.rec_ord_report_date, 4 ) = #{nowYear} THEN 1 ELSE 0 END),0) as nowYear,
ifnull( SUM( CASE WHEN LEFT ( sr.rec_ord_report_date, 4 ) = #{lastYear} THEN 1 ELSE 0 END ),0) as last_year
from ajh_rectification_info sr
UNION
select
......
package com.skua.modules.report.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.skua.common.constant.BusinessConstant;
import com.skua.common.constant.ReportConstant;
import com.skua.common.report.ReportViewUtil;
import com.skua.core.context.BaseContextHandler;
import com.skua.core.context.SpringContextUtils;
import com.skua.core.util.ConvertUtils;
import com.skua.modules.base.service.IBaseService;
import com.skua.modules.biz.IBusinessService;
import com.skua.modules.report.mapper.OperationReportMapper;
import com.skua.modules.report.service.IOperationReportService;
import com.skua.modules.report.vo.*;
......@@ -22,8 +27,11 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/***
* 运营周报
......@@ -33,6 +41,10 @@ public class OperationReportServiceImpl implements IOperationReportService {
@Resource
private OperationReportMapper operationReportMapper;
@Resource
private IBaseService baseService;
@Resource
private IBusinessService businessService;
private JdbcTemplate getJdbcTemplate(){
JdbcTemplate masterDB = (JdbcTemplate) SpringContextUtils.getBean("master");
......@@ -154,7 +166,7 @@ public class OperationReportServiceImpl implements IOperationReportService {
productDataVO.setDrugDeptartList(yyhMonthDataList);
//隐患排查完成情况
// 隐患排查完成情况
List<String> deptNameList = operationReportMapper.queryDepatNameList();
productDataVO.setDangerDeptCount( 0 );
if(deptNameList != null && !deptNameList.isEmpty()){
......@@ -162,6 +174,48 @@ public class OperationReportServiceImpl implements IOperationReportService {
productDataVO.setDangerDeptNames(String.join(",",deptNameList));
}
// 翻译
Map<String, String> sysDepartDictMap = businessService.dictMap("sys_depart", null);
Map<String, String> sysUserDictMap = businessService.dictMap("sys_user", null);
// 1. 重点工作事项:取重点事项推进情况里面,当月完成的重点事项记录
QueryWrapper<?> queryWrapper1 = new QueryWrapper<>();
queryWrapper1.eq("status", "2")
.ge("end_time", startDate)
.le("end_time", endDate);
List<Map<String, Object>> queryMapList1 = baseService.queryForList("select * from f_major_issues_process", queryWrapper1);
List<Map<String, Object>> priorityWorkItemList = queryMapList1.stream().map(item -> {
Map<String, Object> entityMap = item.keySet().stream().collect(Collectors.toMap(StrUtil::toCamelCase, key -> (item.get(key) == null ? "" : item.get(key))));
entityMap.put("departName", sysDepartDictMap.get(item.get("depart_id")));
return entityMap;
}).collect(Collectors.toList());
productDataVO.setPriorityWorkItemList(priorityWorkItemList);
// 2: 隐患排查巡检:取风险点巡检记录里面巡检类型是生产巡检的数据
QueryWrapper<?> queryWrapper2 = new QueryWrapper<>();
queryWrapper2.eq("inspection_type", "1")
.eq("status", "2")
.ge("end_date", startDate + BusinessConstant.startTimeSuffix)
.le("end_date", endDate + BusinessConstant.endTimeSuffix);
List<Map<String, Object>> queryMapList2 = baseService.queryForList("select * from danger_inspection_record", queryWrapper2);
Map<String, String> recordId2CountMap;
if (!queryMapList2.isEmpty()) {
List<String> recordIdList = queryMapList2.stream().map(item -> ConvertUtils.getString(item.get("id"))).collect(Collectors.toList());
QueryWrapper<?> tmpQueryWrapper = new QueryWrapper<>();
tmpQueryWrapper.in("danger_inspection_record.id", recordIdList)
.eq("danger_inspection_item.status", "0")
.groupBy("danger_inspection_record.id");
List<Map<String, Object>> tmpQueryMapList = baseService.queryForList("select danger_inspection_record.id as id, count(*) as total from danger_inspection_item left join danger_inspection_info on danger_inspection_item.inspection_info_id = danger_inspection_info.id left join danger_inspection_record on danger_inspection_info.inspection_record_id = danger_inspection_record.id", tmpQueryWrapper);
recordId2CountMap = tmpQueryMapList.stream().collect(Collectors.toMap(item -> ConvertUtils.getString(item.get("id")), item -> ConvertUtils.getString(item.get("total"))));
} else {
recordId2CountMap = new HashMap<>();
}
List<Map<String, Object>> hiddenDangerInspectionList = queryMapList2.stream().map(item -> {
Map<String, Object> entityMap = item.keySet().stream().collect(Collectors.toMap(StrUtil::toCamelCase, key -> (item.get(key) == null ? "" : item.get(key))));
entityMap.put("departName", sysDepartDictMap.get(item.get("depart_id")));
entityMap.put("realname", sysUserDictMap.get(item.get("report_user")));
entityMap.put("exceptionCount", recordId2CountMap.getOrDefault(item.get("id"), "0"));
return entityMap;
}).collect(Collectors.toList());
productDataVO.setHiddenDangerInspectionList(hiddenDangerInspectionList);
return productDataVO;
}
......
......@@ -9,6 +9,7 @@ import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 月度生产数据报表
......@@ -60,6 +61,15 @@ public class ProductDataVO {
@ApiModelProperty(value = "药剂实际费用")
private Double drugCost;//实际发生为0.219元/吨水
// 重点工作事项
private List<Map<String, Object>> priorityWorkItemList = new ArrayList<>();
// 隐患排查巡检
private List<Map<String, Object>> hiddenDangerInspectionList = new ArrayList<>();
// 运营管理抽查情况
private List<Map<String, Object>> managementSpotCheckList = new ArrayList<>();
@ApiModelProperty(value = "实际水量同比下降--水务公司列表")
private List<FReportWaterMonthDataVO> waterDeptartList = new ArrayList<>();
......
......@@ -10,6 +10,7 @@ import javax.servlet.http.HttpServletResponse;
import cn.hutool.json.JSONObject;
import com.skua.core.context.BaseContextHandler;
import com.skua.core.query.QueryGenerator;
import com.skua.modules.equipment.service.IEquipmentAssetService;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Sheet;
......@@ -109,6 +110,8 @@ public class EquipmentController {
@Autowired
private IEquipmentInfoService equipmentInfoService;
@Autowired
private IEquipmentAssetService equipmentAssetService;
@Autowired
private Key2ValueService key2ValueService;
......@@ -212,9 +215,9 @@ public class EquipmentController {
if (equipmentStatisticDTO.getShowDepartId()) {
List<Map<String, Object>> departIdMapList = WrapperFactory.joinWrapper()
.select("count(*) as total", "depart_id as departId")
.from(EquipmentAsset.class)
.innerJoin(EquipmentInfo.class, EquipmentInfo.class.getDeclaredField("assetId"), EquipmentAsset.class.getDeclaredField("id"))
.innerJoin(EquipmentExt.class, EquipmentExt.class.getDeclaredField("infoId"), EquipmentInfo.class.getDeclaredField("id"))
.from(EquipmentInfo.class)
.leftJoin(EquipmentAsset.class, EquipmentInfo.class.getDeclaredField("assetId"), EquipmentAsset.class.getDeclaredField("id"))
.leftJoin(EquipmentExt.class, EquipmentExt.class.getDeclaredField("infoId"), EquipmentInfo.class.getDeclaredField("id"))
.where()
.eq(StringUtils.isNotEmpty(equipmentStatisticDTO.getIsSpecial()), "is_special", equipmentStatisticDTO.getIsSpecial())
.in(true,"depart_id", Arrays.asList(departs.split(",")))
......@@ -359,6 +362,7 @@ public class EquipmentController {
.groupBy("EquipmentInfo_equipmentStatus");//EquipmentInfo_isSpecial
sql = sql.replace("EquipmentInfo.maintenance_cost as EquipmentInfo_maintenanceCost,", "")
.replace("EquipmentInfo.gz_count as EquipmentInfo_gzCount,", "");
sql = sql.replaceAll("inner join", "left join");
List<Map<String, Object>> countMapList = iCommonSqlService.queryWrapperForList(sql, queryWrapper);
for (Map<String, Object> item : countMapList) {
String key = "" + item.get("EquipmentInfo_equipmentStatus");
......@@ -383,17 +387,26 @@ public class EquipmentController {
Result<?> result = new Result<>();
Equipment equipment = EquipmentUtils.equipDTO2Entity(equipmentDTO);
// todo 前端未传,特殊处理
equipment.getEquipmentInfo().setAssetId(equipment.getEquipmentAsset().getId());
// equipment.getEquipmentInfo().setAssetId(equipment.getEquipmentAsset().getId());
// equipment.getEquipmentExt().setInfoId(equipment.getEquipmentInfo().getId());
// 校验ID是否一致
JoinSqlUtils.checkSqlIdFunc(equipment);
// JoinSqlUtils.checkSqlIdFunc(equipment);
// 与点表有关联的台账不允许删除
List<SysMonitorMetricInfo> monitorMetricInfo = sysMonitorMetricInfoService.list(new QueryWrapper<SysMonitorMetricInfo>().eq("equipment_code", equipmentDTO.getEquipmentInfo().getId()));
if (monitorMetricInfo!=null&&monitorMetricInfo.size()>0) {
result.error500("与运行点表有关联的设备台账不允许删除");
return result;
}
iCrudSqlService.delete(equipment);
// iCrudSqlService.delete(equipment);
transactionTemplate.execute((transactionStatus -> {
if (StringUtils.isNotEmpty(equipment.getEquipmentInfo().getId())) {
equipmentInfoService.removeById(equipment.getEquipmentInfo().getId());
}
if (StringUtils.isNotEmpty(equipment.getEquipmentAsset().getId())) {
equipmentAssetService.removeById(equipment.getEquipmentAsset().getId());
}
return 1;
}));
return Result.ok("删除成功!");
}
......@@ -522,8 +535,8 @@ public class EquipmentController {
.select(" (SELECT MAX(real_start_time) FROM equipment_maintain_task WHERE equipment_id = equipment_info.id and results_enforcement='4') as equipmentExt_maintainLastTime ")
.select(" (select TIMESTAMPDIFF(HOUR, NOW(),(select min(start_time) from equipment_maintain_task where start_time>NOW() and equipment_id = equipment_info.id))) as equipmentExt_maintainCountdown ")
.select(" (select max(repair_date) from equipment_repair where info_id=equipment_info.id) as equipmentExt_repairLastTime ")
.from(EquipmentAsset.class)
.innerJoin(EquipmentInfo.class, EquipmentInfo::getAssetId, EquipmentAsset::getId)
.from(EquipmentInfo.class)
.leftJoin(EquipmentAsset.class, EquipmentInfo::getAssetId, EquipmentAsset::getId)
.leftJoin(EquipmentBrand.class, EquipmentInfo::getEquipmentBrand, EquipmentBrand::getId)
.leftJoin(EquipmentCategory.class, EquipmentInfo::getEquipmentType, EquipmentCategory::getId)
.where()
......
......@@ -158,19 +158,19 @@ public class InspectionAnalysisController {
@GetMapping("/getInspectionTaskIndicators")
public Result<InspectionTaskIndicatorsVO> getInspectionTaskIndicators(String startDate,String endDate){
Result<InspectionTaskIndicatorsVO> result = new Result<>();
InspectionTaskIndicatorsVO inspectionTaskIndicatorsVO = inspectionAnalysisService.getInspectionTaskIndicatorsNew(startDate,endDate);
InspectionTaskIndicatorsVO inspectionTaskIndicatorsVO = inspectionAnalysisService.getInspectionTaskIndicators(startDate,endDate);
result.setSuccess(true);
result.setResult(inspectionTaskIndicatorsVO);
return result;
}
@ApiOperation(value = "巡检分析-巡检任务指标-详情", notes = "巡检分析-巡检任务指标-详情")
@GetMapping("/getInspectionTaskIndicatorsDetail")
public Result<List<InspectionEquipIndicatorsDetailVO>> getInspectionTaskIndicatorsDetail(String departId,String startDate,String endDate){
Result<List<InspectionEquipIndicatorsDetailVO>> result = new Result<>();
public Result<List<InspectionTaskIndicatorsVO>> getInspectionTaskIndicatorsDetail(String departId,String startDate,String endDate){
Result<List<InspectionTaskIndicatorsVO>> result = new Result<>();
if(StringUtils.isEmpty(departId)){
departId = BaseContextHandler.getDeparts();
}
List<InspectionEquipIndicatorsDetailVO> dataList = inspectionAnalysisService.getInspectionTaskIndicatorsDetail( JSUtils.quoteEach(departId,",") ,startDate,endDate);
List<InspectionTaskIndicatorsVO> dataList = inspectionAnalysisService.getInspectionTaskIndicatorsDetail( JSUtils.quoteEach(departId,",") ,startDate,endDate);
result.setSuccess(true);
result.setResult(dataList);
return result;
......@@ -221,19 +221,19 @@ public class InspectionAnalysisController {
@GetMapping("/getInspectionEquipIndicators")
public Result<InspectionEquipIndicatorsVO> getInspectionEquipIndicators(String startDate, String endDate){
Result<InspectionEquipIndicatorsVO> result = new Result<>();
InspectionEquipIndicatorsVO inspectionEquipIndicatorsVO = inspectionAnalysisService.getInspectionEquipIndicatorsNew(startDate,endDate);
InspectionEquipIndicatorsVO inspectionEquipIndicatorsVO = inspectionAnalysisService.getInspectionEquipIndicators(startDate,endDate);
result.setSuccess(true);
result.setResult(inspectionEquipIndicatorsVO);
return result;
}
@ApiOperation(value = "巡检分析-巡检设备指标-详情", notes = "巡检分析-巡检设备指标-详情")
@GetMapping("/getInspectionEquipIndicatorsDetail")
public Result<List<InspectionEquipIndicatorsDetailVO>> getInspectionEquipIndicators(String departId,String startDate, String endDate){
Result<List<InspectionEquipIndicatorsDetailVO>> result = new Result<>();
public Result<List<InspectionEquipIndicatorsVO>> getInspectionEquipIndicators(String departId,String startDate, String endDate){
Result<List<InspectionEquipIndicatorsVO>> result = new Result<>();
if(StringUtils.isEmpty(departId)){
departId = BaseContextHandler.getDeparts();
}
List<InspectionEquipIndicatorsDetailVO> dataList = inspectionAnalysisService.getInspectionEquipIndicatorsDetail(JSUtils.quoteEach(departId,","),startDate,endDate);
List<InspectionEquipIndicatorsVO> dataList = inspectionAnalysisService.getInspectionEquipIndicatorsDetail(JSUtils.quoteEach(departId,","),startDate,endDate);
result.setSuccess(true);
result.setResult(dataList);
return result;
......@@ -251,7 +251,7 @@ public class InspectionAnalysisController {
@GetMapping("/getInspectionEquipOverview")
public Result<InspectionEquipOverviewVO> getInspectionEquipOverview(String startDate, String endDate){
Result<InspectionEquipOverviewVO> result = new Result<>();
InspectionEquipOverviewVO inspectionEquipOverviewVO = inspectionAnalysisService.getInspectionEquipOverviewNew(startDate,endDate);
InspectionEquipOverviewVO inspectionEquipOverviewVO = inspectionAnalysisService.getInspectionEquipOverview(startDate,endDate);
result.setSuccess(true);
result.setResult(inspectionEquipOverviewVO);
return result;
......@@ -259,15 +259,15 @@ public class InspectionAnalysisController {
@ApiOperation(value = "巡检分析-巡检设备概况-详情", notes = "巡检分析-巡检设备概况-详情")
@GetMapping("/getInspectionEquipOverviewDetail")
public Result<List<InspectionEquipIndicatorsDetailVO>> getInspectionEquipOverviewDetail(String departId,String startDate, String endDate){
Result<List<InspectionEquipIndicatorsDetailVO>> result = new Result<>();
public Result<List<InspectionEquipOverviewVO>> getInspectionEquipOverviewDetail(String departId,String startDate, String endDate){
Result<List<InspectionEquipOverviewVO>> result = new Result<>();
String departIds = departId;
if(StringUtils.isEmpty(departId)){
departIds = BaseContextHandler.getDeparts();
}else{
departIds = sysDepartService.getChildDepartId(departId);
}
List<InspectionEquipIndicatorsDetailVO> dataList = inspectionAnalysisService.getInspectionEquipOverviewDetail(departIds,startDate,endDate);
List<InspectionEquipOverviewVO> dataList = inspectionAnalysisService.getInspectionEquipOverviewDetail(departIds,startDate,endDate);
result.setSuccess(true);
result.setResult(dataList);
return result;
......
......@@ -28,7 +28,7 @@ public interface IInspectionAnalysisService {
* @param endDate
* @return
*/
List<InspectionEquipIndicatorsDetailVO> getInspectionTaskIndicatorsDetail(String departIds, String startDate, String endDate);
List<InspectionTaskIndicatorsVO> getInspectionTaskIndicatorsDetail(String departIds, String startDate, String endDate);
/***
* 巡检分析-巡检设备指标
* @param startDate
......@@ -43,7 +43,7 @@ public interface IInspectionAnalysisService {
* @param endDate
* @return
*/
List<InspectionEquipIndicatorsDetailVO> getInspectionEquipIndicatorsDetail(String departIds,String startDate, String endDate);
List<InspectionEquipIndicatorsVO> getInspectionEquipIndicatorsDetail(String departIds,String startDate, String endDate);
/***
* 巡检分析-巡检任务概况
......@@ -79,7 +79,7 @@ public interface IInspectionAnalysisService {
* @param endDate
* @return
*/
List<InspectionEquipIndicatorsDetailVO> getInspectionEquipOverviewDetail(String departIds, String startDate, String endDate);
List<InspectionEquipOverviewVO> getInspectionEquipOverviewDetail(String departIds, String startDate, String endDate);
/***
* 巡检分析-巡检任务异常项趋势
......
......@@ -34,16 +34,4 @@ public class InspectionAbnormalItemsTrendVO {
private Integer notCheckedItemsCount;
@ApiModelProperty(value = "异常项数量")
private Integer abnormalItemsCount;
public Integer getNotCheckedItemsCount() {
if (totalCount != null && checkedItemsCount != null) {
if (totalCount - checkedItemsCount < 0) {
return checkedItemsCount - totalCount;
} else {
return totalCount - checkedItemsCount;
}
} else {
return 0;
}
}
}
......
......@@ -28,4 +28,6 @@ public class InspectionEquipIndicatorsVO {
@ApiModelProperty(value = "异常项处理率")
private String processedAbnormalRate;
private String departName;
}
......
......@@ -29,4 +29,6 @@ public class InspectionEquipOverviewVO {
private Integer abnormalInspectionEquipCount;
@ApiModelProperty(value = "异常项处理率")
private String processedAbnormalRate;
private String departName;
}
......
......@@ -26,4 +26,6 @@ public class InspectionTaskIndicatorsVO {
private String abnormalRate;
@ApiModelProperty(value = "异常项处理率")
private String processedAbnormalRate;
private String departName;
}
......
......@@ -45,4 +45,32 @@ public class TaskPoolConfig {
executor.initialize();
return executor;
}
@Bean(name="taskExecutor2")
public ThreadPoolTaskExecutor taskExecutor2() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
//配置核心线程数:就是线程池中的核心线程数量,这几个核心线程,只是在没有用的时候,也不会被回收
executor.setCorePoolSize(50);
//配置最大线程数:就是线程池中可以容纳的最大线程的数量
executor.setMaxPoolSize(200);
//配置队列大小
executor.setQueueCapacity(500);
//线程池维护线程所允许的空闲时间:就是线程池中除了核心线程之外的其他的最长可以保留的时间,因为在线程池中,除了核心线程即使在无任务的情况下也不能被清除,其余的都是有存活时间的,意思就是非核心线程可以保留的最长的空闲时间
executor.setKeepAliveSeconds(60);
//配置线程池中的线程的名称前缀
executor.setThreadNamePrefix("task-executor2-");
// handler,是一种拒绝策略,我们可以在任务满了之后,拒绝执行某些任务。
// rejection-policy:当pool已经达到max size的时候,如何处理新任务
// CALLER_RUNS:不在新线程中执行任务,而是有调用者所在的线程来执行
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
// AbortPolicy:用于被拒绝任务的处理程序,它将抛出RejectedExecutionException
// CallerRunsPolicy:用于被拒绝任务的处理程序,它直接在execute方法的调用线程中运行被拒绝的任务。
// DiscardOldestPolicy:用于被拒绝任务的处理程序,它放弃最旧的未处理请求,然后重试execute。
// DiscardPolicy:用于被拒绝任务的处理程序,默认情况下它将丢弃被拒绝的任务。
//执行初始化
executor.initialize();
return executor;
}
}
\ No newline at end of file
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!