|
|
@ -2,7 +2,10 @@ package com.hnac.hzims.operational.defect.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.hnac.hzims.operational.access.constants.AccessConstants; |
|
|
|
import com.hnac.hzims.operational.access.constants.AccessConstants; |
|
|
|
import com.hnac.hzims.operational.access.entity.OperAccessPlanEntity; |
|
|
|
import com.hnac.hzims.operational.access.entity.OperAccessPlanEntity; |
|
|
|
import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; |
|
|
|
import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; |
|
|
@ -36,6 +39,7 @@ import org.apache.poi.ss.util.CellRangeAddress; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
|
|
|
|
import org.springblade.core.mp.base.BaseEntity; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
@ -90,24 +94,22 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 开始问题处理流程 |
|
|
|
* 开始问题处理流程 |
|
|
|
* 问题处理流程的第一个处理节点人key 必须是 problemUser |
|
|
|
* 问题处理流程的第一个处理节点人key 必须是 problemUser |
|
|
|
|
|
|
|
* |
|
|
|
* @param |
|
|
|
* @param |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void startFlow(OperPhenomenonEntity phenomenonEntity, OperDefectEntity defectEntity){ |
|
|
|
public void startFlow(OperPhenomenonEntity phenomenonEntity, OperDefectEntity defectEntity) { |
|
|
|
User handler = UserCache.getUser(phenomenonEntity.getHandler()); |
|
|
|
User handler = UserCache.getUser(phenomenonEntity.getHandler()); |
|
|
|
String handlerName = handler == null ? "" : handler.getName(); |
|
|
|
String handlerName = handler == null ? "" : handler.getName(); |
|
|
|
String sourceName = DictCache.getValue(DefectConstant.SOURCE_CODE_DICT_KEY,phenomenonEntity.getSourceCode()); |
|
|
|
String sourceName = DictCache.getValue(DefectConstant.SOURCE_CODE_DICT_KEY, phenomenonEntity.getSourceCode()); |
|
|
|
String processName = "【" + sourceName + "】" + handlerName + " 发起的缺陷【" + phenomenonEntity.getDefectCode() + "】的问题处理流程"; |
|
|
|
String processName = "【" + sourceName + "】" + handlerName + " 发起的缺陷【" + phenomenonEntity.getDefectCode() + "】的问题处理流程"; |
|
|
|
defectEntity.setCreateUser(phenomenonEntity.getCreateUser()); |
|
|
|
defectEntity.setCreateUser(phenomenonEntity.getCreateUser()); |
|
|
|
defectEntity.setCreateDept(phenomenonEntity.getCreateDept()); |
|
|
|
defectEntity.setCreateDept(phenomenonEntity.getCreateDept()); |
|
|
|
defectEntity.setTenantId(phenomenonEntity.getTenantId()); |
|
|
|
defectEntity.setTenantId(phenomenonEntity.getTenantId()); |
|
|
|
save(defectEntity); |
|
|
|
save(defectEntity); |
|
|
|
|
|
|
|
|
|
|
|
Kv variables = Kv.create() |
|
|
|
Kv variables = Kv.create().set(ProcessConstant.TASK_VARIABLE_CREATE_USER, "taskUser_" + phenomenonEntity.getCreateUser()).set(DefectConstant.PROCESS_VARIABLE_HANDLE_USER, "taskUser_" + phenomenonEntity.getHandler()); |
|
|
|
.set(ProcessConstant.TASK_VARIABLE_CREATE_USER, "taskUser_" + phenomenonEntity.getCreateUser()) |
|
|
|
R<BladeFlow> result = flowClient.startProcessInstanceContainNameByKey(defectEntity.getProcDefId(), FlowUtil.getBusinessKey("hzims_oper_defect", String.valueOf(defectEntity.getId())), processName, variables); |
|
|
|
.set(DefectConstant.PROCESS_VARIABLE_HANDLE_USER, "taskUser_" + phenomenonEntity.getHandler()) |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
R<BladeFlow> result = flowClient.startProcessInstanceContainNameByKey(defectEntity.getProcDefId(), FlowUtil.getBusinessKey("hzims_oper_defect",String.valueOf(defectEntity.getId())), processName, variables); |
|
|
|
|
|
|
|
if (result.isSuccess()) { |
|
|
|
if (result.isSuccess()) { |
|
|
|
BladeFlow flow = result.getData(); |
|
|
|
BladeFlow flow = result.getData(); |
|
|
|
log.debug("流程已启动,流程ID:" + flow.getProcessInstanceId()); |
|
|
|
log.debug("流程已启动,流程ID:" + flow.getProcessInstanceId()); |
|
|
@ -116,7 +118,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
defectEntity.setHandleStatus(DefectConstant.DefectHandlerStatusEnum.HANDLING_STATUS.getStatus().toString()); |
|
|
|
defectEntity.setHandleStatus(DefectConstant.DefectHandlerStatusEnum.HANDLING_STATUS.getStatus().toString()); |
|
|
|
updateById(defectEntity); |
|
|
|
updateById(defectEntity); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
throw new ServiceException("开启流程失败,code="+result.getCode()); |
|
|
|
throw new ServiceException("开启流程失败,code=" + result.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@ -124,12 +126,13 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 处理问题 |
|
|
|
* 处理问题 |
|
|
|
|
|
|
|
* |
|
|
|
* @param flow |
|
|
|
* @param flow |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean handleProcess(BladeFlow flow) { |
|
|
|
public boolean handleProcess(BladeFlow flow) { |
|
|
|
if(!invalidHandleProcess(flow.getProcessInstanceId())){ |
|
|
|
if (!invalidHandleProcess(flow.getProcessInstanceId())) { |
|
|
|
throw new ServiceException("当前缺陷开具了检修计划,需等任务执行完成才能处理缺陷"); |
|
|
|
throw new ServiceException("当前缺陷开具了检修计划,需等任务执行完成才能处理缺陷"); |
|
|
|
} |
|
|
|
} |
|
|
|
ComleteTask task = new ComleteTask(); |
|
|
|
ComleteTask task = new ComleteTask(); |
|
|
@ -143,42 +146,43 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
flowClient.completeTask(task); |
|
|
|
flowClient.completeTask(task); |
|
|
|
Integer status = ProcessConstant.ProcessInstanceStatusEnum.running.ordinal(); |
|
|
|
Integer status = ProcessConstant.ProcessInstanceStatusEnum.running.ordinal(); |
|
|
|
R<String> result = flowClient.queryProcessInstanceStatus(flow.getProcessInstanceId()); |
|
|
|
R<String> result = flowClient.queryProcessInstanceStatus(flow.getProcessInstanceId()); |
|
|
|
if(result.isSuccess()){ |
|
|
|
if (result.isSuccess()) { |
|
|
|
status = ProcessConstant.ProcessInstanceStatusEnum.over.name().equals(result.getData())?ProcessConstant.ProcessInstanceStatusEnum.over.ordinal():status; |
|
|
|
status = ProcessConstant.ProcessInstanceStatusEnum.over.name().equals(result.getData()) ? ProcessConstant.ProcessInstanceStatusEnum.over.ordinal() : status; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
LambdaUpdateWrapper<OperDefectEntity> updateWrapper = new LambdaUpdateWrapper<>(); |
|
|
|
LambdaUpdateWrapper<OperDefectEntity> updateWrapper = new LambdaUpdateWrapper<>(); |
|
|
|
updateWrapper.set(OperDefectEntity::getHandleStatus,status); |
|
|
|
updateWrapper.set(OperDefectEntity::getHandleStatus, status); |
|
|
|
//第一个流程节点传
|
|
|
|
//第一个流程节点传
|
|
|
|
if(Func.isNotEmpty(map.get("actStartTime"))){ |
|
|
|
if (Func.isNotEmpty(map.get("actStartTime"))) { |
|
|
|
updateWrapper.set(OperDefectEntity::getActStartTime, map.get("actStartTime").toString()); |
|
|
|
updateWrapper.set(OperDefectEntity::getActStartTime, map.get("actStartTime").toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
//最后一个流程节点传
|
|
|
|
//最后一个流程节点传
|
|
|
|
if(Func.isNotEmpty(map.get("actEndTime"))){ |
|
|
|
if (Func.isNotEmpty(map.get("actEndTime"))) { |
|
|
|
updateWrapper.set(OperDefectEntity::getActEndTime, map.get("actEndTime").toString()); |
|
|
|
updateWrapper.set(OperDefectEntity::getActEndTime, map.get("actEndTime").toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
//最后一个流程节点传
|
|
|
|
//最后一个流程节点传
|
|
|
|
if(Func.isNotEmpty(map.get("disposeDesc"))){ |
|
|
|
if (Func.isNotEmpty(map.get("disposeDesc"))) { |
|
|
|
updateWrapper.set(OperDefectEntity::getDisposeDesc, map.get("disposeDesc").toString()); |
|
|
|
updateWrapper.set(OperDefectEntity::getDisposeDesc, map.get("disposeDesc").toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 每一个流程节点都要传,这个数据属于叠加数据,例如第一个流程节点是8小时,第二个流程节点是2小时, |
|
|
|
* 每一个流程节点都要传,这个数据属于叠加数据,例如第一个流程节点是8小时,第二个流程节点是2小时, |
|
|
|
* 第一个节点完成后存储的数据是8 第二个节点完成后存储的数据是 8,2 |
|
|
|
* 第一个节点完成后存储的数据是8 第二个节点完成后存储的数据是 8,2 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
if(Func.isNotEmpty(map.get("actHours"))){ |
|
|
|
if (Func.isNotEmpty(map.get("actHours"))) { |
|
|
|
updateWrapper.set(OperDefectEntity::getActHours, map.get("actHours").toString()); |
|
|
|
updateWrapper.set(OperDefectEntity::getActHours, map.get("actHours").toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
updateWrapper.eq(OperDefectEntity::getProcessInstanceId,flow.getProcessInstanceId()); |
|
|
|
updateWrapper.eq(OperDefectEntity::getProcessInstanceId, flow.getProcessInstanceId()); |
|
|
|
update(updateWrapper); |
|
|
|
update(updateWrapper); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取缺陷的统计月报 |
|
|
|
* 获取缺陷的统计月报 |
|
|
|
|
|
|
|
* |
|
|
|
* @param month 格式:"2021-01" |
|
|
|
* @param month 格式:"2021-01" |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Map<String, Object> getDefectStatistics(String month){ |
|
|
|
public Map<String, Object> getDefectStatistics(String month) { |
|
|
|
Map<String, Object> re = new HashMap<>(); |
|
|
|
Map<String, Object> re = new HashMap<>(); |
|
|
|
re.put("currentMonth", getCurrentMonthStatic(month)); |
|
|
|
re.put("currentMonth", getCurrentMonthStatic(month)); |
|
|
|
re.put("severalMonths", getStatisticBySeveralMonth(month)); |
|
|
|
re.put("severalMonths", getStatisticBySeveralMonth(month)); |
|
|
@ -200,11 +204,11 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
// 第一步,创建一个webbook,对应一个Excel文件
|
|
|
|
// 第一步,创建一个webbook,对应一个Excel文件
|
|
|
|
HSSFWorkbook wb = new HSSFWorkbook(); |
|
|
|
HSSFWorkbook wb = new HSSFWorkbook(); |
|
|
|
// 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet
|
|
|
|
// 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet
|
|
|
|
HSSFSheet sheet = wb.createSheet("缺陷月报("+month+")"); |
|
|
|
HSSFSheet sheet = wb.createSheet("缺陷月报(" + month + ")"); |
|
|
|
sheet.setDefaultRowHeight((short) (20*20)); |
|
|
|
sheet.setDefaultRowHeight((short) (20 * 20)); |
|
|
|
//生成当前行
|
|
|
|
//生成当前行
|
|
|
|
int currentRow = 0; |
|
|
|
int currentRow = 0; |
|
|
|
for (int col=0;col<9;col++){ |
|
|
|
for (int col = 0; col < 9; col++) { |
|
|
|
sheet.setColumnWidth(col, 3900); |
|
|
|
sheet.setColumnWidth(col, 3900); |
|
|
|
} |
|
|
|
} |
|
|
|
//创建标题行
|
|
|
|
//创建标题行
|
|
|
@ -212,13 +216,13 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
sheet.addMergedRegion(region1); |
|
|
|
sheet.addMergedRegion(region1); |
|
|
|
//参数1:起始行 参数2:终止行 参数3:起始列 参数4:终止列
|
|
|
|
//参数1:起始行 参数2:终止行 参数3:起始列 参数4:终止列
|
|
|
|
HSSFRow headTitle = sheet.createRow(currentRow); |
|
|
|
HSSFRow headTitle = sheet.createRow(currentRow); |
|
|
|
this.setFullHeadCell(wb,headTitle, (short) 9,0); |
|
|
|
this.setFullHeadCell(wb, headTitle, (short) 9, 0); |
|
|
|
HSSFCell headCell = headTitle.getCell(0); |
|
|
|
HSSFCell headCell = headTitle.getCell(0); |
|
|
|
headCell.setCellValue("缺陷月报("+month+")"); |
|
|
|
headCell.setCellValue("缺陷月报(" + month + ")"); |
|
|
|
currentRow++; |
|
|
|
currentRow++; |
|
|
|
|
|
|
|
|
|
|
|
// 本月与前几月缺陷报表比较表格设置
|
|
|
|
// 本月与前几月缺陷报表比较表格设置
|
|
|
|
currentRow = this.setCompareMonthCell(currentMonth, severalMonths,wb, sheet, new Integer(currentRow)); |
|
|
|
currentRow = this.setCompareMonthCell(currentMonth, severalMonths, wb, sheet, new Integer(currentRow)); |
|
|
|
currentRow++; |
|
|
|
currentRow++; |
|
|
|
|
|
|
|
|
|
|
|
// 管理指标(本月)设置
|
|
|
|
// 管理指标(本月)设置
|
|
|
@ -226,10 +230,10 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
currentRow++; |
|
|
|
currentRow++; |
|
|
|
|
|
|
|
|
|
|
|
// 重复分类缺陷汇总表设置
|
|
|
|
// 重复分类缺陷汇总表设置
|
|
|
|
this.setRepeatCell( repeat, wb, sheet, currentRow); |
|
|
|
this.setRepeatCell(repeat, wb, sheet, currentRow); |
|
|
|
|
|
|
|
|
|
|
|
// 下载导出
|
|
|
|
// 下载导出
|
|
|
|
String filename = "("+month+")缺陷月报表"; |
|
|
|
String filename = "(" + month + ")缺陷月报表"; |
|
|
|
// 设置头信息
|
|
|
|
// 设置头信息
|
|
|
|
response.setCharacterEncoding("UTF-8"); |
|
|
|
response.setCharacterEncoding("UTF-8"); |
|
|
|
response.setContentType("application/vnd.ms-excel"); |
|
|
|
response.setContentType("application/vnd.ms-excel"); |
|
|
@ -246,9 +250,10 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<OperDefectEntity> getDefectList(String emCode,List<String> list) { |
|
|
|
public List<OperDefectEntity> getDefectList(String emCode, List<String> list) { |
|
|
|
return this.baseMapper.selectDefectList(emCode,list); |
|
|
|
return this.baseMapper.selectDefectList(emCode, list); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<OperDefectEntity> getDefectByEmCodeList(String emCode) { |
|
|
|
public List<OperDefectEntity> getDefectByEmCodeList(String emCode) { |
|
|
|
return this.baseMapper.selectDefectByEmCodeList(emCode); |
|
|
|
return this.baseMapper.selectDefectByEmCodeList(emCode); |
|
|
@ -262,8 +267,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
|
|
|
|
|
|
|
|
defectReportsVOList = operDefectVOS.stream().map(operDefectVO -> { |
|
|
|
defectReportsVOList = operDefectVOS.stream().map(operDefectVO -> { |
|
|
|
User finder = UserCache.getUser(operDefectVO.getFinder()); |
|
|
|
User finder = UserCache.getUser(operDefectVO.getFinder()); |
|
|
|
String finderAndTime = (ObjectUtil.isNotEmpty(finder) && StringUtil.isNotBlank(finder.getName()) ? finder.getName() : operDefectVO.getFinder().toString()) |
|
|
|
String finderAndTime = (ObjectUtil.isNotEmpty(finder) && StringUtil.isNotBlank(finder.getName()) ? finder.getName() : operDefectVO.getFinder().toString()) + ":" + DateFormatUtils.format(operDefectVO.getFindTime(), DateUtil.PATTERN_DATETIME); |
|
|
|
+ ":" + DateFormatUtils.format(operDefectVO.getFindTime(), DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
String handlerAndTime = ""; |
|
|
|
String handlerAndTime = ""; |
|
|
|
if (Func.isNotEmpty(operDefectVO.getHandler())) { |
|
|
|
if (Func.isNotEmpty(operDefectVO.getHandler())) { |
|
|
|
User handler = UserCache.getUser(operDefectVO.getHandler()); |
|
|
|
User handler = UserCache.getUser(operDefectVO.getHandler()); |
|
|
@ -272,8 +276,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
handlerAndTime = String.format("%s:%s", handlerName, handleTime); |
|
|
|
handlerAndTime = String.format("%s:%s", handlerName, handleTime); |
|
|
|
} |
|
|
|
} |
|
|
|
String seriousSituation = DictCache.getValue(DefectConstant.LEVEL_CODE_DICT_KEY, operDefectVO.getDefectLevel()); |
|
|
|
String seriousSituation = DictCache.getValue(DefectConstant.LEVEL_CODE_DICT_KEY, operDefectVO.getDefectLevel()); |
|
|
|
return DefectReportsVO.builder().faultName(operDefectVO.getFaultName()).seriousSituation(seriousSituation) |
|
|
|
return DefectReportsVO.builder().faultName(operDefectVO.getFaultName()).seriousSituation(seriousSituation).finderAndTime(finderAndTime).handlerAndTime(handlerAndTime).handleSituation(operDefectVO.getConclusion()).build(); |
|
|
|
.finderAndTime(finderAndTime).handlerAndTime(handlerAndTime).handleSituation(operDefectVO.getConclusion()).build(); |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
return defectReportsVOList; |
|
|
|
return defectReportsVOList; |
|
|
@ -284,7 +287,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
LocalDate startDate = LocalDate.parse(params.get("startDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); |
|
|
|
LocalDate startDate = LocalDate.parse(params.get("startDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); |
|
|
|
LocalDate endDate = LocalDate.parse(params.get("endDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); |
|
|
|
LocalDate endDate = LocalDate.parse(params.get("endDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); |
|
|
|
List<Long> deptIdList = (List<Long>) params.get("deptId"); |
|
|
|
List<Long> deptIdList = (List<Long>) params.get("deptId"); |
|
|
|
return getFaultByFaultCode(startDate,endDate,deptIdList); |
|
|
|
return getFaultByFaultCode(startDate, endDate, deptIdList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -296,19 +299,16 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
public R<OperDefectVO> detail(OperDefectEntity defect) { |
|
|
|
public R<OperDefectVO> detail(OperDefectEntity defect) { |
|
|
|
OperDefectEntity detail = getOne(Condition.getQueryWrapper(defect)); |
|
|
|
OperDefectEntity detail = getOne(Condition.getQueryWrapper(defect)); |
|
|
|
OperDefectVO operDefectVO = null; |
|
|
|
OperDefectVO operDefectVO = null; |
|
|
|
if(ObjectUtil.isNotEmpty(detail)) { |
|
|
|
if (ObjectUtil.isNotEmpty(detail)) { |
|
|
|
operDefectVO = OperDefectWrapper.build().entityVO(detail); |
|
|
|
operDefectVO = OperDefectWrapper.build().entityVO(detail); |
|
|
|
//获取检修计划
|
|
|
|
//获取检修计划
|
|
|
|
IOperAccessPlanService planService = SpringUtil.getBean(OperAccessPlanServiceImpl.class); |
|
|
|
IOperAccessPlanService planService = SpringUtil.getBean(OperAccessPlanServiceImpl.class); |
|
|
|
OperAccessPlanEntity accessPlanEntity = planService.getOne(Wrappers.<OperAccessPlanEntity>lambdaQuery() |
|
|
|
OperAccessPlanEntity accessPlanEntity = planService.getOne(Wrappers.<OperAccessPlanEntity>lambdaQuery().eq(OperAccessPlanEntity::getDefectId, detail.getId())); |
|
|
|
.eq(OperAccessPlanEntity::getDefectId,detail.getId()) |
|
|
|
if (ObjectUtil.isNotEmpty(accessPlanEntity)) { |
|
|
|
); |
|
|
|
|
|
|
|
if(ObjectUtil.isNotEmpty(accessPlanEntity)){ |
|
|
|
|
|
|
|
operDefectVO.setAccessPlanId(accessPlanEntity.getId()); |
|
|
|
operDefectVO.setAccessPlanId(accessPlanEntity.getId()); |
|
|
|
if(ObjectUtil.isNotEmpty(accessPlanEntity.getStatus()) && accessPlanEntity.getStatus() > AccessConstants.PLAN_DRAFT){ |
|
|
|
if (ObjectUtil.isNotEmpty(accessPlanEntity.getStatus()) && accessPlanEntity.getStatus() > AccessConstants.PLAN_DRAFT) { |
|
|
|
operDefectVO.setEditStatus(0); |
|
|
|
operDefectVO.setEditStatus(0); |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
|
|
|
|
operDefectVO.setEditStatus(1); |
|
|
|
operDefectVO.setEditStatus(1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -318,6 +318,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取安全检查消缺项统计 |
|
|
|
* 获取安全检查消缺项统计 |
|
|
|
|
|
|
|
* |
|
|
|
* @param startDate 开始时间 |
|
|
|
* @param startDate 开始时间 |
|
|
|
* @param endDate 结束时间 |
|
|
|
* @param endDate 结束时间 |
|
|
|
* @param dept 机构ID |
|
|
|
* @param dept 机构ID |
|
|
@ -328,66 +329,60 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
public SafeCheckStatisticVO getDefectCheck(String startDate, String endDate, Long dept, String defectType) { |
|
|
|
public SafeCheckStatisticVO getDefectCheck(String startDate, String endDate, Long dept, String defectType) { |
|
|
|
SafeCheckStatisticVO vo = new SafeCheckStatisticVO(); |
|
|
|
SafeCheckStatisticVO vo = new SafeCheckStatisticVO(); |
|
|
|
//获取消缺总数
|
|
|
|
//获取消缺总数
|
|
|
|
LambdaQueryWrapper<OperPhenomenonEntity> wrapper = Wrappers.<OperPhenomenonEntity>lambdaQuery() |
|
|
|
LambdaQueryWrapper<OperPhenomenonEntity> wrapper = Wrappers.<OperPhenomenonEntity>lambdaQuery().eq(OperPhenomenonEntity::getCreateDept, dept).ge(OperPhenomenonEntity::getPlanStartTime, startDate).le(OperPhenomenonEntity::getPlanStartTime, endDate).eq(OperPhenomenonEntity::getIsDefect, 1); |
|
|
|
.eq(OperPhenomenonEntity::getCreateDept,dept) |
|
|
|
|
|
|
|
.ge(OperPhenomenonEntity::getPlanStartTime,startDate) |
|
|
|
|
|
|
|
.le(OperPhenomenonEntity::getPlanStartTime,endDate) |
|
|
|
|
|
|
|
.eq(OperPhenomenonEntity::getIsDefect,1); |
|
|
|
|
|
|
|
//缺陷等级为Ⅰ级缺陷时为重大缺陷 其他为一般缺陷
|
|
|
|
//缺陷等级为Ⅰ级缺陷时为重大缺陷 其他为一般缺陷
|
|
|
|
if("1".equals(defectType)){ |
|
|
|
if ("1".equals(defectType)) { |
|
|
|
vo.setProjectType(Constants.SafeCheckProjectEnum.SERIOUS_DEFECT.getType()); |
|
|
|
vo.setProjectType(Constants.SafeCheckProjectEnum.SERIOUS_DEFECT.getType()); |
|
|
|
vo.setProjectTypeName(Constants.SafeCheckProjectEnum.SERIOUS_DEFECT.getName()); |
|
|
|
vo.setProjectTypeName(Constants.SafeCheckProjectEnum.SERIOUS_DEFECT.getName()); |
|
|
|
wrapper.eq(OperPhenomenonEntity::getDefectLevel,DefectConstant.DefectLevelEnum.ONE.getStatus()); |
|
|
|
wrapper.eq(OperPhenomenonEntity::getDefectLevel, DefectConstant.DefectLevelEnum.ONE.getStatus()); |
|
|
|
} |
|
|
|
} else if ("2".equals(defectType)) { |
|
|
|
else if("2".equals(defectType)){ |
|
|
|
|
|
|
|
vo.setProjectType(Constants.SafeCheckProjectEnum.NORMAL_DEFECT.getType()); |
|
|
|
vo.setProjectType(Constants.SafeCheckProjectEnum.NORMAL_DEFECT.getType()); |
|
|
|
vo.setProjectTypeName(Constants.SafeCheckProjectEnum.NORMAL_DEFECT.getName()); |
|
|
|
vo.setProjectTypeName(Constants.SafeCheckProjectEnum.NORMAL_DEFECT.getName()); |
|
|
|
wrapper.ne(OperPhenomenonEntity::getDefectLevel,DefectConstant.DefectLevelEnum.ONE.getStatus()); |
|
|
|
wrapper.ne(OperPhenomenonEntity::getDefectLevel, DefectConstant.DefectLevelEnum.ONE.getStatus()); |
|
|
|
} |
|
|
|
} |
|
|
|
List<OperPhenomenonEntity> operPhenomenonEntities = operPhenomenonMapper.selectList(wrapper); |
|
|
|
List<OperPhenomenonEntity> operPhenomenonEntities = operPhenomenonMapper.selectList(wrapper); |
|
|
|
if(CollectionUtil.isNotEmpty(operPhenomenonEntities)){ |
|
|
|
if (CollectionUtil.isNotEmpty(operPhenomenonEntities)) { |
|
|
|
//获取消缺率
|
|
|
|
//获取消缺率
|
|
|
|
List<OperPhenomenonEntity> finishDefects = operPhenomenonEntities.stream().filter( |
|
|
|
List<OperPhenomenonEntity> finishDefects = operPhenomenonEntities.stream().filter(p -> ObjectUtil.isNotEmpty(p.getConclusionStatus()) && "1".equals(p.getConclusionStatus())).collect(Collectors.toList()); |
|
|
|
p-> ObjectUtil.isNotEmpty(p.getConclusionStatus()) && "1".equals(p.getConclusionStatus()) |
|
|
|
|
|
|
|
).collect(Collectors.toList()); |
|
|
|
|
|
|
|
vo.setTotal(operPhenomenonEntities.size()); |
|
|
|
vo.setTotal(operPhenomenonEntities.size()); |
|
|
|
vo.setQualified(finishDefects.size()); |
|
|
|
vo.setQualified(finishDefects.size()); |
|
|
|
vo.setQualifiedRate(new BigDecimal(finishDefects.size()/(double)operPhenomenonEntities.size()*100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
vo.setQualifiedRate(new BigDecimal(finishDefects.size() / (double) operPhenomenonEntities.size() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
} |
|
|
|
} |
|
|
|
return vo; |
|
|
|
return vo; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 根据流程ID判断该缺陷是否能执行 |
|
|
|
* 根据流程ID判断该缺陷是否能执行 |
|
|
|
|
|
|
|
* |
|
|
|
* @param processInstanceId 流程ID |
|
|
|
* @param processInstanceId 流程ID |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private boolean invalidHandleProcess(String processInstanceId) { |
|
|
|
private boolean invalidHandleProcess(String processInstanceId) { |
|
|
|
boolean result = true; |
|
|
|
boolean result = true; |
|
|
|
OperDefectEntity defectEntity = super.getOne(new LambdaQueryWrapper<OperDefectEntity>(){{ |
|
|
|
OperDefectEntity defectEntity = super.getOne(new LambdaQueryWrapper<OperDefectEntity>() {{ |
|
|
|
eq(OperDefectEntity::getProcessInstanceId, processInstanceId); |
|
|
|
eq(OperDefectEntity::getProcessInstanceId, processInstanceId); |
|
|
|
}}); |
|
|
|
}}); |
|
|
|
//若类型为检修
|
|
|
|
//若类型为检修
|
|
|
|
if(Func.isNotEmpty(defectEntity.getDefectCode()) && DefectConstant.DefectSourceEnum.JX.getStatus().equals(defectEntity.getDefectCode().substring(0,2))){ |
|
|
|
if (Func.isNotEmpty(defectEntity.getDefectCode()) && DefectConstant.DefectSourceEnum.JX.getStatus().equals(defectEntity.getDefectCode().substring(0, 2))) { |
|
|
|
IOperAccessPlanService planService = SpringUtil.getBean(IOperAccessPlanService.class); |
|
|
|
IOperAccessPlanService planService = SpringUtil.getBean(IOperAccessPlanService.class); |
|
|
|
List<OperAccessPlanEntity> planList = planService.list(new LambdaQueryWrapper<OperAccessPlanEntity>(){{ |
|
|
|
List<OperAccessPlanEntity> planList = planService.list(new LambdaQueryWrapper<OperAccessPlanEntity>() {{ |
|
|
|
eq(OperAccessPlanEntity::getDefectId, defectEntity.getId()); |
|
|
|
eq(OperAccessPlanEntity::getDefectId, defectEntity.getId()); |
|
|
|
}}); |
|
|
|
}}); |
|
|
|
if(CollectionUtil.isNotEmpty(planList)){ |
|
|
|
if (CollectionUtil.isNotEmpty(planList)) { |
|
|
|
//获取未审核的计划
|
|
|
|
//获取未审核的计划
|
|
|
|
List<OperAccessPlanEntity> pendingReviewList = planList.stream().filter(p->p.getStatus() != AccessConstants.PLAN_FINISH).collect(Collectors.toList()); |
|
|
|
List<OperAccessPlanEntity> pendingReviewList = planList.stream().filter(p -> p.getStatus() != AccessConstants.PLAN_FINISH).collect(Collectors.toList()); |
|
|
|
if(CollectionUtil.isNotEmpty(pendingReviewList)){ |
|
|
|
if (CollectionUtil.isNotEmpty(pendingReviewList)) { |
|
|
|
result = false; |
|
|
|
result = false; |
|
|
|
} |
|
|
|
} |
|
|
|
//获取检修计划ID集合
|
|
|
|
//获取检修计划ID集合
|
|
|
|
List<Long> planIdList = planList.stream().map(OperAccessPlanEntity::getId).collect(Collectors.toList()); |
|
|
|
List<Long> planIdList = planList.stream().map(OperAccessPlanEntity::getId).collect(Collectors.toList()); |
|
|
|
IOperAccessTaskService taskService = SpringUtil.getBean(IOperAccessTaskService.class); |
|
|
|
IOperAccessTaskService taskService = SpringUtil.getBean(IOperAccessTaskService.class); |
|
|
|
//未完成检修任务集合
|
|
|
|
//未完成检修任务集合
|
|
|
|
List<OperAccessTaskEntity> taskList = taskService.list(new LambdaQueryWrapper<OperAccessTaskEntity>(){{ |
|
|
|
List<OperAccessTaskEntity> taskList = taskService.list(new LambdaQueryWrapper<OperAccessTaskEntity>() {{ |
|
|
|
in(OperAccessTaskEntity::getPlanId, planIdList); |
|
|
|
in(OperAccessTaskEntity::getPlanId, planIdList); |
|
|
|
ne(OperAccessTaskEntity::getStatus, AccessConstants.ACCESS_TASK_STATUS_4); |
|
|
|
ne(OperAccessTaskEntity::getStatus, AccessConstants.ACCESS_TASK_STATUS_4); |
|
|
|
}}); |
|
|
|
}}); |
|
|
|
if(CollectionUtil.isNotEmpty(taskList)){ |
|
|
|
if (CollectionUtil.isNotEmpty(taskList)) { |
|
|
|
result = false; |
|
|
|
result = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -397,10 +392,11 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 创建标题单元格样式 |
|
|
|
* 创建标题单元格样式 |
|
|
|
|
|
|
|
* |
|
|
|
* @param wb |
|
|
|
* @param wb |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private HSSFCellStyle setHeadCellStyle(HSSFWorkbook wb){ |
|
|
|
private HSSFCellStyle setHeadCellStyle(HSSFWorkbook wb) { |
|
|
|
HSSFCellStyle headStyle = wb.createCellStyle(); |
|
|
|
HSSFCellStyle headStyle = wb.createCellStyle(); |
|
|
|
//设置边框
|
|
|
|
//设置边框
|
|
|
|
headStyle.setBorderLeft(BorderStyle.THIN); |
|
|
|
headStyle.setBorderLeft(BorderStyle.THIN); |
|
|
@ -425,10 +421,11 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 创建表格内容单元格样式 |
|
|
|
* 创建表格内容单元格样式 |
|
|
|
|
|
|
|
* |
|
|
|
* @param wb |
|
|
|
* @param wb |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private HSSFCellStyle setContentCellStyle(HSSFWorkbook wb){ |
|
|
|
private HSSFCellStyle setContentCellStyle(HSSFWorkbook wb) { |
|
|
|
HSSFCellStyle contentStyle = wb.createCellStyle(); |
|
|
|
HSSFCellStyle contentStyle = wb.createCellStyle(); |
|
|
|
//设置边框
|
|
|
|
//设置边框
|
|
|
|
contentStyle.setBorderLeft(BorderStyle.THIN); |
|
|
|
contentStyle.setBorderLeft(BorderStyle.THIN); |
|
|
@ -449,14 +446,15 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 设置缺陷月报表excel导出-本月与前几月缺陷报表内单元格 |
|
|
|
* 设置缺陷月报表excel导出-本月与前几月缺陷报表内单元格 |
|
|
|
|
|
|
|
* |
|
|
|
* @param sheet |
|
|
|
* @param sheet |
|
|
|
* @param currentRow |
|
|
|
* @param currentRow |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private int setCompareMonthCell(List<OperDefectRatioDTO> currentMonth, List<OperDefectRatioDTO> severalMonths, HSSFWorkbook wb,HSSFSheet sheet, int currentRow){ |
|
|
|
private int setCompareMonthCell(List<OperDefectRatioDTO> currentMonth, List<OperDefectRatioDTO> severalMonths, HSSFWorkbook wb, HSSFSheet sheet, int currentRow) { |
|
|
|
//创建当月与1-至当月表表头
|
|
|
|
//创建当月与1-至当月表表头
|
|
|
|
HSSFRow headRow = sheet.createRow(currentRow); |
|
|
|
HSSFRow headRow = sheet.createRow(currentRow); |
|
|
|
//设置表头信息
|
|
|
|
//设置表头信息
|
|
|
|
this.setFullHeadCell(wb,headRow, (short) 9,0); |
|
|
|
this.setFullHeadCell(wb, headRow, (short) 9, 0); |
|
|
|
HSSFCell compare_head1_cell1 = headRow.getCell(0); |
|
|
|
HSSFCell compare_head1_cell1 = headRow.getCell(0); |
|
|
|
compare_head1_cell1.setCellValue("指标名称"); |
|
|
|
compare_head1_cell1.setCellValue("指标名称"); |
|
|
|
HSSFCell compare_head1_cell2 = headRow.getCell(1); |
|
|
|
HSSFCell compare_head1_cell2 = headRow.getCell(1); |
|
|
@ -464,7 +462,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
HSSFCell compare_head1_cell3 = headRow.getCell(5); |
|
|
|
HSSFCell compare_head1_cell3 = headRow.getCell(5); |
|
|
|
compare_head1_cell3.setCellValue("(1-本月)累计"); |
|
|
|
compare_head1_cell3.setCellValue("(1-本月)累计"); |
|
|
|
//合并单元格
|
|
|
|
//合并单元格
|
|
|
|
CellRangeAddress head1_region1 = new CellRangeAddress((short) currentRow, (short) currentRow+1, (short) 0, (short) 0); |
|
|
|
CellRangeAddress head1_region1 = new CellRangeAddress((short) currentRow, (short) currentRow + 1, (short) 0, (short) 0); |
|
|
|
CellRangeAddress head1_region2 = new CellRangeAddress((short) currentRow, (short) currentRow, (short) 1, (short) 4); |
|
|
|
CellRangeAddress head1_region2 = new CellRangeAddress((short) currentRow, (short) currentRow, (short) 1, (short) 4); |
|
|
|
CellRangeAddress head1_region3 = new CellRangeAddress((short) currentRow, (short) currentRow, (short) 5, (short) 8); |
|
|
|
CellRangeAddress head1_region3 = new CellRangeAddress((short) currentRow, (short) currentRow, (short) 5, (short) 8); |
|
|
|
sheet.addMergedRegion(head1_region1); |
|
|
|
sheet.addMergedRegion(head1_region1); |
|
|
@ -473,7 +471,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
currentRow++; |
|
|
|
currentRow++; |
|
|
|
//创建表头
|
|
|
|
//创建表头
|
|
|
|
HSSFRow headRow2 = sheet.createRow(currentRow); |
|
|
|
HSSFRow headRow2 = sheet.createRow(currentRow); |
|
|
|
this.setFullHeadCell(wb,headRow2, (short) 9,0); |
|
|
|
this.setFullHeadCell(wb, headRow2, (short) 9, 0); |
|
|
|
//设置表头信息
|
|
|
|
//设置表头信息
|
|
|
|
HSSFCell compare_head2_cell1 = headRow2.getCell(1); |
|
|
|
HSSFCell compare_head2_cell1 = headRow2.getCell(1); |
|
|
|
compare_head2_cell1.setCellValue("发生"); |
|
|
|
compare_head2_cell1.setCellValue("发生"); |
|
|
@ -500,23 +498,20 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
compare_head2_cell8.setCellValue("比率(%)"); |
|
|
|
compare_head2_cell8.setCellValue("比率(%)"); |
|
|
|
currentRow++; |
|
|
|
currentRow++; |
|
|
|
|
|
|
|
|
|
|
|
for(int i=0;i<currentMonth.size();i++){ |
|
|
|
for (int i = 0; i < currentMonth.size(); i++) { |
|
|
|
HSSFRow row = sheet.createRow(currentRow); |
|
|
|
HSSFRow row = sheet.createRow(currentRow); |
|
|
|
this.setFullHeadCell(wb,row, (short) 9,1); |
|
|
|
this.setFullHeadCell(wb, row, (short) 9, 1); |
|
|
|
OperDefectRatioDTO currentRatioDTO = currentMonth.get(i); |
|
|
|
OperDefectRatioDTO currentRatioDTO = currentMonth.get(i); |
|
|
|
OperDefectRatioDTO severalRatioDTO = severalMonths.get(i); |
|
|
|
OperDefectRatioDTO severalRatioDTO = severalMonths.get(i); |
|
|
|
//创建表格内容第一个单元格
|
|
|
|
//创建表格内容第一个单元格
|
|
|
|
HSSFCell compare_content_cell1 = row.getCell(0); |
|
|
|
HSSFCell compare_content_cell1 = row.getCell(0); |
|
|
|
if("1".equals(currentRatioDTO.getDefectLevel())){ |
|
|
|
if ("1".equals(currentRatioDTO.getDefectLevel())) { |
|
|
|
compare_content_cell1.setCellValue("一类缺陷"); |
|
|
|
compare_content_cell1.setCellValue("一类缺陷"); |
|
|
|
} |
|
|
|
} else if ("2".equals(currentRatioDTO.getDefectLevel())) { |
|
|
|
else if("2".equals(currentRatioDTO.getDefectLevel())){ |
|
|
|
|
|
|
|
compare_content_cell1.setCellValue("二类缺陷"); |
|
|
|
compare_content_cell1.setCellValue("二类缺陷"); |
|
|
|
} |
|
|
|
} else if ("3".equals(currentRatioDTO.getDefectLevel())) { |
|
|
|
else if("3".equals(currentRatioDTO.getDefectLevel())){ |
|
|
|
|
|
|
|
compare_content_cell1.setCellValue("三类缺陷"); |
|
|
|
compare_content_cell1.setCellValue("三类缺陷"); |
|
|
|
} |
|
|
|
} else if ("合计".equals(currentRatioDTO.getDefectLevel())) { |
|
|
|
else if("合计".equals(currentRatioDTO.getDefectLevel())){ |
|
|
|
|
|
|
|
compare_content_cell1.setCellValue(currentRatioDTO.getDefectLevel()); |
|
|
|
compare_content_cell1.setCellValue(currentRatioDTO.getDefectLevel()); |
|
|
|
} |
|
|
|
} |
|
|
|
HSSFCell compare_content_cell2 = row.getCell(1); |
|
|
|
HSSFCell compare_content_cell2 = row.getCell(1); |
|
|
@ -543,14 +538,15 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 设置缺陷月报表excel导出-管理指标(本月)表内单元格 |
|
|
|
* 设置缺陷月报表excel导出-管理指标(本月)表内单元格 |
|
|
|
|
|
|
|
* |
|
|
|
* @param wb |
|
|
|
* @param wb |
|
|
|
* @param sheet |
|
|
|
* @param sheet |
|
|
|
* @param currentRow 记录表格中叠加后的数据 |
|
|
|
* @param currentRow 记录表格中叠加后的数据 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private int setManageIndexCell(OperDefectManageIndexDTO manageIndex,HSSFWorkbook wb, HSSFSheet sheet, int currentRow){ |
|
|
|
private int setManageIndexCell(OperDefectManageIndexDTO manageIndex, HSSFWorkbook wb, HSSFSheet sheet, int currentRow) { |
|
|
|
//管理指标表头
|
|
|
|
//管理指标表头
|
|
|
|
HSSFRow headRow3 = sheet.createRow(currentRow); |
|
|
|
HSSFRow headRow3 = sheet.createRow(currentRow); |
|
|
|
this.setFullHeadCell(wb,headRow3, (short) 9,0); |
|
|
|
this.setFullHeadCell(wb, headRow3, (short) 9, 0); |
|
|
|
HSSFCell manage_index_head = headRow3.getCell(0); |
|
|
|
HSSFCell manage_index_head = headRow3.getCell(0); |
|
|
|
manage_index_head.setCellValue("管理指标(本月)"); |
|
|
|
manage_index_head.setCellValue("管理指标(本月)"); |
|
|
|
CellRangeAddress head1_region4 = new CellRangeAddress((short) currentRow, (short) currentRow, (short) 0, (short) 8); |
|
|
|
CellRangeAddress head1_region4 = new CellRangeAddress((short) currentRow, (short) currentRow, (short) 0, (short) 8); |
|
|
@ -558,7 +554,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
currentRow++; |
|
|
|
currentRow++; |
|
|
|
|
|
|
|
|
|
|
|
HSSFRow headRow4 = sheet.createRow(currentRow); |
|
|
|
HSSFRow headRow4 = sheet.createRow(currentRow); |
|
|
|
this.setFullHeadCell(wb,headRow4, (short) 9,0); |
|
|
|
this.setFullHeadCell(wb, headRow4, (short) 9, 0); |
|
|
|
HSSFCell repeat_head2_cell = headRow4.getCell(0); |
|
|
|
HSSFCell repeat_head2_cell = headRow4.getCell(0); |
|
|
|
repeat_head2_cell.setCellValue("及时消除的缺陷数"); |
|
|
|
repeat_head2_cell.setCellValue("及时消除的缺陷数"); |
|
|
|
HSSFCell repeat_head2_cell2 = headRow4.getCell(2); |
|
|
|
HSSFCell repeat_head2_cell2 = headRow4.getCell(2); |
|
|
@ -585,7 +581,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
|
|
|
|
|
|
|
|
//表格内容行
|
|
|
|
//表格内容行
|
|
|
|
HSSFRow manage_index_row = sheet.createRow(currentRow); |
|
|
|
HSSFRow manage_index_row = sheet.createRow(currentRow); |
|
|
|
this.setFullHeadCell(wb,manage_index_row, (short) 9,1); |
|
|
|
this.setFullHeadCell(wb, manage_index_row, (short) 9, 1); |
|
|
|
//表格内容
|
|
|
|
//表格内容
|
|
|
|
//第一列
|
|
|
|
//第一列
|
|
|
|
CellRangeAddress manage_religon1 = new CellRangeAddress((short) currentRow, (short) currentRow, (short) 0, (short) 1); |
|
|
|
CellRangeAddress manage_religon1 = new CellRangeAddress((short) currentRow, (short) currentRow, (short) 0, (short) 1); |
|
|
@ -617,15 +613,16 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 设置缺陷月报表excel导出-重复分类缺陷汇总表内单元格 |
|
|
|
* 设置缺陷月报表excel导出-重复分类缺陷汇总表内单元格 |
|
|
|
|
|
|
|
* |
|
|
|
* @param wb |
|
|
|
* @param wb |
|
|
|
* @param sheet |
|
|
|
* @param sheet |
|
|
|
* @param currentRow 记录表格中叠加后的数据 |
|
|
|
* @param currentRow 记录表格中叠加后的数据 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private int setRepeatCell(List<OperDefectRepeatRatioDTO> repeat, HSSFWorkbook wb, HSSFSheet sheet, int currentRow){ |
|
|
|
private int setRepeatCell(List<OperDefectRepeatRatioDTO> repeat, HSSFWorkbook wb, HSSFSheet sheet, int currentRow) { |
|
|
|
//重复缺陷分类汇总表
|
|
|
|
//重复缺陷分类汇总表
|
|
|
|
//表头1
|
|
|
|
//表头1
|
|
|
|
HSSFRow repeat_head1 = sheet.createRow(currentRow); |
|
|
|
HSSFRow repeat_head1 = sheet.createRow(currentRow); |
|
|
|
this.setFullHeadCell(wb,repeat_head1, (short) 9,0); |
|
|
|
this.setFullHeadCell(wb, repeat_head1, (short) 9, 0); |
|
|
|
HSSFCell repeat_head1_cell = repeat_head1.getCell(0); |
|
|
|
HSSFCell repeat_head1_cell = repeat_head1.getCell(0); |
|
|
|
repeat_head1_cell.setCellValue("重复缺陷分类汇总表"); |
|
|
|
repeat_head1_cell.setCellValue("重复缺陷分类汇总表"); |
|
|
|
CellRangeAddress repeat_religon = new CellRangeAddress(currentRow, currentRow, (short) 0, (short) 8); |
|
|
|
CellRangeAddress repeat_religon = new CellRangeAddress(currentRow, currentRow, (short) 0, (short) 8); |
|
|
@ -637,7 +634,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
sheet.addMergedRegion(repeat_head2_cell_religon); |
|
|
|
sheet.addMergedRegion(repeat_head2_cell_religon); |
|
|
|
|
|
|
|
|
|
|
|
HSSFRow repeat_head2 = sheet.createRow(currentRow); |
|
|
|
HSSFRow repeat_head2 = sheet.createRow(currentRow); |
|
|
|
this.setFullHeadCell(wb,repeat_head2, (short) 9,0); |
|
|
|
this.setFullHeadCell(wb, repeat_head2, (short) 9, 0); |
|
|
|
HSSFCell repeat_head2_cell1 = repeat_head2.getCell(3); |
|
|
|
HSSFCell repeat_head2_cell1 = repeat_head2.getCell(3); |
|
|
|
CellRangeAddress repeat_head2_cell1_religon = new CellRangeAddress(currentRow, currentRow, (short) 3, (short) 4); |
|
|
|
CellRangeAddress repeat_head2_cell1_religon = new CellRangeAddress(currentRow, currentRow, (short) 3, (short) 4); |
|
|
|
sheet.addMergedRegion(repeat_head2_cell1_religon); |
|
|
|
sheet.addMergedRegion(repeat_head2_cell1_religon); |
|
|
@ -656,23 +653,20 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
currentRow++; |
|
|
|
currentRow++; |
|
|
|
|
|
|
|
|
|
|
|
//内容
|
|
|
|
//内容
|
|
|
|
for(int i=0;i<repeat.size();i++){ |
|
|
|
for (int i = 0; i < repeat.size(); i++) { |
|
|
|
HSSFRow repeat_row = sheet.createRow(currentRow); |
|
|
|
HSSFRow repeat_row = sheet.createRow(currentRow); |
|
|
|
this.setFullHeadCell(wb,repeat_row, (short) 9,1); |
|
|
|
this.setFullHeadCell(wb, repeat_row, (short) 9, 1); |
|
|
|
//第一列
|
|
|
|
//第一列
|
|
|
|
HSSFCell repeat_cell1 = repeat_row.getCell(0); |
|
|
|
HSSFCell repeat_cell1 = repeat_row.getCell(0); |
|
|
|
CellRangeAddress repeat_content_religon = new CellRangeAddress(currentRow, currentRow, (short) 0, (short) 2); |
|
|
|
CellRangeAddress repeat_content_religon = new CellRangeAddress(currentRow, currentRow, (short) 0, (short) 2); |
|
|
|
sheet.addMergedRegion(repeat_content_religon); |
|
|
|
sheet.addMergedRegion(repeat_content_religon); |
|
|
|
if("1".equals(repeat.get(i).getDefectLevel())){ |
|
|
|
if ("1".equals(repeat.get(i).getDefectLevel())) { |
|
|
|
repeat_cell1.setCellValue("一类缺陷"); |
|
|
|
repeat_cell1.setCellValue("一类缺陷"); |
|
|
|
} |
|
|
|
} else if ("2".equals(repeat.get(i).getDefectLevel())) { |
|
|
|
else if("2".equals(repeat.get(i).getDefectLevel())){ |
|
|
|
|
|
|
|
repeat_cell1.setCellValue("二类缺陷"); |
|
|
|
repeat_cell1.setCellValue("二类缺陷"); |
|
|
|
} |
|
|
|
} else if ("3".equals(repeat.get(i).getDefectLevel())) { |
|
|
|
else if("3".equals(repeat.get(i).getDefectLevel())){ |
|
|
|
|
|
|
|
repeat_cell1.setCellValue("三类缺陷"); |
|
|
|
repeat_cell1.setCellValue("三类缺陷"); |
|
|
|
} |
|
|
|
} else if ("合计".equals(repeat.get(i).getDefectLevel())) { |
|
|
|
else if("合计".equals(repeat.get(i).getDefectLevel())){ |
|
|
|
|
|
|
|
repeat_cell1.setCellValue(repeat.get(i).getDefectLevel()); |
|
|
|
repeat_cell1.setCellValue(repeat.get(i).getDefectLevel()); |
|
|
|
} |
|
|
|
} |
|
|
|
//第二列
|
|
|
|
//第二列
|
|
|
@ -699,17 +693,17 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 补全合并单元格时 表格行所有单元格 |
|
|
|
* 补全合并单元格时 表格行所有单元格 |
|
|
|
|
|
|
|
* |
|
|
|
* @param headRow |
|
|
|
* @param headRow |
|
|
|
* @param rowLen |
|
|
|
* @param rowLen |
|
|
|
* @param status 0:设置表头样式 1:设置内容样式 |
|
|
|
* @param status 0:设置表头样式 1:设置内容样式 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void setFullHeadCell(HSSFWorkbook wb,HSSFRow headRow,short rowLen,int status){ |
|
|
|
private void setFullHeadCell(HSSFWorkbook wb, HSSFRow headRow, short rowLen, int status) { |
|
|
|
for (int i=0;i<rowLen;i++){ |
|
|
|
for (int i = 0; i < rowLen; i++) { |
|
|
|
HSSFCell hssfcell = headRow.createCell(i); |
|
|
|
HSSFCell hssfcell = headRow.createCell(i); |
|
|
|
if(status == 0){ |
|
|
|
if (status == 0) { |
|
|
|
hssfcell.setCellStyle(this.setHeadCellStyle(wb)); |
|
|
|
hssfcell.setCellStyle(this.setHeadCellStyle(wb)); |
|
|
|
} |
|
|
|
} else if (status == 1) { |
|
|
|
else if(status == 1){ |
|
|
|
|
|
|
|
hssfcell.setCellStyle(this.setContentCellStyle(wb)); |
|
|
|
hssfcell.setCellStyle(this.setContentCellStyle(wb)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -717,12 +711,13 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 处理double数据保留两位小数 |
|
|
|
* 处理double数据保留两位小数 |
|
|
|
|
|
|
|
* |
|
|
|
* @param num |
|
|
|
* @param num |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private Double dealDouble(Double num){ |
|
|
|
private Double dealDouble(Double num) { |
|
|
|
if(num != null){ |
|
|
|
if (num != null) { |
|
|
|
BigDecimal b = new BigDecimal(num*100); |
|
|
|
BigDecimal b = new BigDecimal(num * 100); |
|
|
|
return b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
return b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
return null; |
|
|
@ -730,6 +725,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取当前月统计数据 |
|
|
|
* 获取当前月统计数据 |
|
|
|
|
|
|
|
* |
|
|
|
* @param month |
|
|
|
* @param month |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -740,13 +736,14 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 当年1月 - 当前月获取缺陷等级统计数据 |
|
|
|
* 当年1月 - 当前月获取缺陷等级统计数据 |
|
|
|
|
|
|
|
* |
|
|
|
* @param month "2021-01" |
|
|
|
* @param month "2021-01" |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<OperDefectRatioDTO> getStatisticBySeveralMonth(String month) { |
|
|
|
private List<OperDefectRatioDTO> getStatisticBySeveralMonth(String month) { |
|
|
|
Integer intervalMonth = Integer.valueOf(month.split("-")[1]); |
|
|
|
Integer intervalMonth = Integer.valueOf(month.split("-")[1]); |
|
|
|
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
Date date ; |
|
|
|
Date date; |
|
|
|
String firstMonth = month.split("-")[0] + "-01-01"; |
|
|
|
String firstMonth = month.split("-")[0] + "-01-01"; |
|
|
|
try { |
|
|
|
try { |
|
|
|
date = dateFormat.parse(firstMonth); |
|
|
|
date = dateFormat.parse(firstMonth); |
|
|
@ -757,7 +754,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
} catch (ParseException e) { |
|
|
|
} catch (ParseException e) { |
|
|
|
throw new ServiceException("日期转换失败"); |
|
|
|
throw new ServiceException("日期转换失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
log.error("firstMonth:"+firstMonth + "; end=" +dateFormat.format(date)); |
|
|
|
log.error("firstMonth:" + firstMonth + "; end=" + dateFormat.format(date)); |
|
|
|
|
|
|
|
|
|
|
|
List<OperDefectStatisticsStatusDTO> statisticBySeveralMonth = this.baseMapper.getStatisticBySeveralMonth(firstMonth, dateFormat.format(date), AuthUtil.getDeptId()); |
|
|
|
List<OperDefectStatisticsStatusDTO> statisticBySeveralMonth = this.baseMapper.getStatisticBySeveralMonth(firstMonth, dateFormat.format(date), AuthUtil.getDeptId()); |
|
|
|
return getRatioStatic(statisticBySeveralMonth); |
|
|
|
return getRatioStatic(statisticBySeveralMonth); |
|
|
@ -765,19 +762,20 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取按月管理指标统计数据 |
|
|
|
* 获取按月管理指标统计数据 |
|
|
|
|
|
|
|
* |
|
|
|
* @param month |
|
|
|
* @param month |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private OperDefectManageIndexDTO getManageIndexStatistic(String month){ |
|
|
|
private OperDefectManageIndexDTO getManageIndexStatistic(String month) { |
|
|
|
OperDefectManageIndexDTO manageIndex = new OperDefectManageIndexDTO(); |
|
|
|
OperDefectManageIndexDTO manageIndex = new OperDefectManageIndexDTO(); |
|
|
|
List<Integer> list = this.baseMapper.getManageIndex(month, AuthUtil.getDeptId()); |
|
|
|
List<Integer> list = this.baseMapper.getManageIndex(month, AuthUtil.getDeptId()); |
|
|
|
manageIndex.setInTimeNum(list.get(0)); |
|
|
|
manageIndex.setInTimeNum(list.get(0)); |
|
|
|
if(!list.get(1).equals(0)){ |
|
|
|
if (!list.get(1).equals(0)) { |
|
|
|
manageIndex.setInTimeRatio(list.get(0).equals(0)? 0.0 : Double.valueOf(list.get(0))/list.get(1)); |
|
|
|
manageIndex.setInTimeRatio(list.get(0).equals(0) ? 0.0 : Double.valueOf(list.get(0)) / list.get(1)); |
|
|
|
} |
|
|
|
} |
|
|
|
manageIndex.setHistoryRemindNum(list.get(3)); |
|
|
|
manageIndex.setHistoryRemindNum(list.get(3)); |
|
|
|
manageIndex.setMonthRemindNum(list.get(2)); |
|
|
|
manageIndex.setMonthRemindNum(list.get(2)); |
|
|
|
if(!list.get(4).equals(0)) { |
|
|
|
if (!list.get(4).equals(0)) { |
|
|
|
manageIndex.setDealRatio(list.get(1).equals(0) ? 0.0 : Double.valueOf(list.get(1)) / list.get(4)); |
|
|
|
manageIndex.setDealRatio(list.get(1).equals(0) ? 0.0 : Double.valueOf(list.get(1)) / list.get(4)); |
|
|
|
} |
|
|
|
} |
|
|
|
return manageIndex; |
|
|
|
return manageIndex; |
|
|
@ -785,67 +783,56 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取重复缺陷等级统计数据 |
|
|
|
* 获取重复缺陷等级统计数据 |
|
|
|
|
|
|
|
* |
|
|
|
* @param month |
|
|
|
* @param month |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<OperDefectRepeatRatioDTO> getRepeatStatistic(String month){ |
|
|
|
private List<OperDefectRepeatRatioDTO> getRepeatStatistic(String month) { |
|
|
|
List<OperDefectRepeatRatioDTO> re = new ArrayList<>(); |
|
|
|
List<OperDefectRepeatRatioDTO> re = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
List<OperDefectStatisticsCodeDTO> repetStatistics = this.baseMapper.getRepetStatistics(AuthUtil.getDeptId()); |
|
|
|
List<OperDefectStatisticsCodeDTO> repetStatistics = this.baseMapper.getRepetStatistics(AuthUtil.getDeptId()); |
|
|
|
//总缺陷数
|
|
|
|
//总缺陷数
|
|
|
|
int total = repetStatistics.stream().mapToInt(OperDefectStatisticsCodeDTO::getDefectNum).sum(); |
|
|
|
int total = repetStatistics.stream().mapToInt(OperDefectStatisticsCodeDTO::getDefectNum).sum(); |
|
|
|
//总重复缺陷数
|
|
|
|
//总重复缺陷数
|
|
|
|
int totalRepeat = repetStatistics |
|
|
|
int totalRepeat = repetStatistics.stream().filter(s -> s.getDefectNum() > 1 && s.getDefectLevel() != null).collect(Collectors.summingInt(OperDefectStatisticsCodeDTO::getDefectNum)); |
|
|
|
.stream() |
|
|
|
|
|
|
|
.filter(s-> s.getDefectNum() > 1 && s.getDefectLevel() != null ) |
|
|
|
|
|
|
|
.collect(Collectors.summingInt(OperDefectStatisticsCodeDTO::getDefectNum)); |
|
|
|
|
|
|
|
//等级重复统计
|
|
|
|
//等级重复统计
|
|
|
|
Map<String, IntSummaryStatistics> repeatList = repetStatistics |
|
|
|
Map<String, IntSummaryStatistics> repeatList = repetStatistics.stream().filter(s -> s.getDefectNum() > 1 && s.getDefectLevel() != null).collect(Collectors.groupingBy(OperDefectStatisticsCodeDTO::getDefectLevel, Collectors.summarizingInt(OperDefectStatisticsCodeDTO::getDefectNum))); |
|
|
|
.stream() |
|
|
|
|
|
|
|
.filter(s -> s.getDefectNum() > 1 && s.getDefectLevel() != null ) |
|
|
|
|
|
|
|
.collect(Collectors.groupingBy(OperDefectStatisticsCodeDTO::getDefectLevel, |
|
|
|
|
|
|
|
Collectors.summarizingInt(OperDefectStatisticsCodeDTO::getDefectNum))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OperDefectRepeatRatioDTO one = new OperDefectRepeatRatioDTO(); |
|
|
|
OperDefectRepeatRatioDTO one = new OperDefectRepeatRatioDTO(); |
|
|
|
one.setDefectLevel(DefectConstant.DefectLevelEnum.ONE.getStatus()); |
|
|
|
one.setDefectLevel(DefectConstant.DefectLevelEnum.ONE.getStatus()); |
|
|
|
if(repeatList.get(one.getDefectLevel()) != null){ |
|
|
|
if (repeatList.get(one.getDefectLevel()) != null) { |
|
|
|
one.setHappenNum(repeatList.get(one.getDefectLevel()).getSum()); |
|
|
|
one.setHappenNum(repeatList.get(one.getDefectLevel()).getSum()); |
|
|
|
one.setHappenRatio(one.getHappenNum()/Double.valueOf(total)); |
|
|
|
one.setHappenRatio(one.getHappenNum() / Double.valueOf(total)); |
|
|
|
one.setRepeatRatio(one.getHappenNum()/Double.valueOf(totalRepeat)); |
|
|
|
one.setRepeatRatio(one.getHappenNum() / Double.valueOf(totalRepeat)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
OperDefectRepeatRatioDTO two = new OperDefectRepeatRatioDTO(); |
|
|
|
OperDefectRepeatRatioDTO two = new OperDefectRepeatRatioDTO(); |
|
|
|
two.setDefectLevel(DefectConstant.DefectLevelEnum.TWO.getStatus()); |
|
|
|
two.setDefectLevel(DefectConstant.DefectLevelEnum.TWO.getStatus()); |
|
|
|
if(repeatList.get(two.getDefectLevel()) != null){ |
|
|
|
if (repeatList.get(two.getDefectLevel()) != null) { |
|
|
|
two.setHappenNum(repeatList.get(two.getDefectLevel()).getSum()); |
|
|
|
two.setHappenNum(repeatList.get(two.getDefectLevel()).getSum()); |
|
|
|
two.setHappenRatio(two.getHappenNum()/Double.valueOf(total)); |
|
|
|
two.setHappenRatio(two.getHappenNum() / Double.valueOf(total)); |
|
|
|
two.setRepeatRatio(two.getHappenNum()/Double.valueOf(totalRepeat)); |
|
|
|
two.setRepeatRatio(two.getHappenNum() / Double.valueOf(totalRepeat)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
OperDefectRepeatRatioDTO three = new OperDefectRepeatRatioDTO(); |
|
|
|
OperDefectRepeatRatioDTO three = new OperDefectRepeatRatioDTO(); |
|
|
|
three.setDefectLevel(DefectConstant.DefectLevelEnum.THREE.getStatus()); |
|
|
|
three.setDefectLevel(DefectConstant.DefectLevelEnum.THREE.getStatus()); |
|
|
|
if(repeatList.get(three.getDefectLevel()) != null) { |
|
|
|
if (repeatList.get(three.getDefectLevel()) != null) { |
|
|
|
three.setHappenNum(repeatList.get(three.getDefectLevel()).getSum()); |
|
|
|
three.setHappenNum(repeatList.get(three.getDefectLevel()).getSum()); |
|
|
|
three.setHappenRatio(three.getHappenNum() / Double.valueOf(total)); |
|
|
|
three.setHappenRatio(three.getHappenNum() / Double.valueOf(total)); |
|
|
|
three.setRepeatRatio(three.getHappenNum() / Double.valueOf(totalRepeat)); |
|
|
|
three.setRepeatRatio(three.getHappenNum() / Double.valueOf(totalRepeat)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
OperDefectRepeatRatioDTO addUp = OperDefectRepeatRatioDTO.builder() |
|
|
|
OperDefectRepeatRatioDTO addUp = OperDefectRepeatRatioDTO.builder().defectLevel("合计").happenNum(one.getHappenNum() + two.getHappenNum() + three.getHappenNum()).happenRatio(one.getHappenRatio() + two.getHappenRatio() + three.getHappenRatio()).repeatRatio(1.00).build(); |
|
|
|
.defectLevel("合计") |
|
|
|
if (addUp.getHappenNum().equals(0L)) { |
|
|
|
.happenNum(one.getHappenNum() + two.getHappenNum() + three.getHappenNum()) |
|
|
|
|
|
|
|
.happenRatio(one.getHappenRatio() + two.getHappenRatio() + three.getHappenRatio()) |
|
|
|
|
|
|
|
.repeatRatio(1.00) |
|
|
|
|
|
|
|
.build(); |
|
|
|
|
|
|
|
if(addUp.getHappenNum().equals(0L)){ |
|
|
|
|
|
|
|
addUp.setRepeatRatio(0.0); |
|
|
|
addUp.setRepeatRatio(0.0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
re.addAll(Arrays.asList(one,two,three,addUp)); |
|
|
|
re.addAll(Arrays.asList(one, two, three, addUp)); |
|
|
|
return re; |
|
|
|
return re; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<OperDefectRatioDTO> getRatioStatic(List<OperDefectStatisticsStatusDTO> dtos){ |
|
|
|
private List<OperDefectRatioDTO> getRatioStatic(List<OperDefectStatisticsStatusDTO> dtos) { |
|
|
|
//本月统计返回
|
|
|
|
//本月统计返回
|
|
|
|
List<OperDefectRatioDTO> re = new ArrayList<>(); |
|
|
|
List<OperDefectRatioDTO> re = new ArrayList<>(); |
|
|
|
OperDefectRatioDTO one = new OperDefectRatioDTO(); |
|
|
|
OperDefectRatioDTO one = new OperDefectRatioDTO(); |
|
|
@ -856,16 +843,14 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
three.setDefectLevel(DefectConstant.DefectLevelEnum.THREE.getStatus()); |
|
|
|
three.setDefectLevel(DefectConstant.DefectLevelEnum.THREE.getStatus()); |
|
|
|
|
|
|
|
|
|
|
|
//等级统计
|
|
|
|
//等级统计
|
|
|
|
Map<String, IntSummaryStatistics> collectLevel = dtos.stream().filter(s-> s.getDefectLevel() != null).collect(Collectors.groupingBy(OperDefectStatisticsStatusDTO::getDefectLevel, |
|
|
|
Map<String, IntSummaryStatistics> collectLevel = dtos.stream().filter(s -> s.getDefectLevel() != null).collect(Collectors.groupingBy(OperDefectStatisticsStatusDTO::getDefectLevel, Collectors.summarizingInt(OperDefectStatisticsStatusDTO::getDefectNum))); |
|
|
|
Collectors.summarizingInt(OperDefectStatisticsStatusDTO::getDefectNum))); |
|
|
|
|
|
|
|
//总缺陷数
|
|
|
|
//总缺陷数
|
|
|
|
int total = dtos.stream().mapToInt(OperDefectStatisticsStatusDTO::getDefectNum).sum(); |
|
|
|
int total = dtos.stream().mapToInt(OperDefectStatisticsStatusDTO::getDefectNum).sum(); |
|
|
|
//状态统计
|
|
|
|
//状态统计
|
|
|
|
Map<String, IntSummaryStatistics> collectStatus = dtos.stream().collect(Collectors.groupingBy(OperDefectStatisticsStatusDTO::getHandleStatus, |
|
|
|
Map<String, IntSummaryStatistics> collectStatus = dtos.stream().collect(Collectors.groupingBy(OperDefectStatisticsStatusDTO::getHandleStatus, Collectors.summarizingInt(OperDefectStatisticsStatusDTO::getDefectNum))); |
|
|
|
Collectors.summarizingInt(OperDefectStatisticsStatusDTO::getDefectNum))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (OperDefectStatisticsStatusDTO dto : dtos) { |
|
|
|
for (OperDefectStatisticsStatusDTO dto : dtos) { |
|
|
|
if(dto.getDefectLevel()!=null){ |
|
|
|
if (dto.getDefectLevel() != null) { |
|
|
|
switch (dto.getDefectLevel()) { |
|
|
|
switch (dto.getDefectLevel()) { |
|
|
|
case "1": |
|
|
|
case "1": |
|
|
|
setReturnRatio(total, one, dto, collectLevel, collectStatus); |
|
|
|
setReturnRatio(total, one, dto, collectLevel, collectStatus); |
|
|
@ -881,52 +866,70 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
int solveNum = collectStatus.get(DefectConstant.HandlerStatusEnum.FINISH_STATUS.getStatus()) == null? 0 : (int)collectStatus.get(DefectConstant.HandlerStatusEnum.FINISH_STATUS.getStatus()).getSum(); |
|
|
|
int solveNum = collectStatus.get(DefectConstant.HandlerStatusEnum.FINISH_STATUS.getStatus()) == null ? 0 : (int) collectStatus.get(DefectConstant.HandlerStatusEnum.FINISH_STATUS.getStatus()).getSum(); |
|
|
|
OperDefectRatioDTO addUp = OperDefectRatioDTO.builder() |
|
|
|
OperDefectRatioDTO addUp = OperDefectRatioDTO.builder().happenNum(total).happenRatio(total == 0 ? 0 : 1.00).defectLevel("合计").sovleRatio(solveNum == 0 ? 0 : 1.00).sovleNum(solveNum).build(); |
|
|
|
.happenNum(total) |
|
|
|
re.addAll(Arrays.asList(one, two, three, addUp)); |
|
|
|
.happenRatio(total == 0 ? 0 : 1.00) |
|
|
|
|
|
|
|
.defectLevel("合计") |
|
|
|
|
|
|
|
.sovleRatio(solveNum == 0 ? 0 : 1.00) |
|
|
|
|
|
|
|
.sovleNum(solveNum) |
|
|
|
|
|
|
|
.build(); |
|
|
|
|
|
|
|
re.addAll(Arrays.asList(one,two,three,addUp)); |
|
|
|
|
|
|
|
return re; |
|
|
|
return re; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setReturnRatio(int total, OperDefectRatioDTO ratio, OperDefectStatisticsStatusDTO dto, |
|
|
|
private void setReturnRatio(int total, OperDefectRatioDTO ratio, OperDefectStatisticsStatusDTO dto, Map<String, IntSummaryStatistics> collectLevel, Map<String, IntSummaryStatistics> collectStatus) { |
|
|
|
Map<String, IntSummaryStatistics> collectLevel, Map<String, IntSummaryStatistics> collectStatus){ |
|
|
|
if (dto.getHandleStatus().equals(DefectConstant.HandlerStatusEnum.FINISH_STATUS.getStatus())) { |
|
|
|
if(dto.getHandleStatus().equals(DefectConstant.HandlerStatusEnum.FINISH_STATUS.getStatus())) { |
|
|
|
|
|
|
|
ratio.setSovleNum(dto.getDefectNum()); |
|
|
|
ratio.setSovleNum(dto.getDefectNum()); |
|
|
|
ratio.setSovleRatio(Double.valueOf(dto.getDefectNum())/collectStatus.get(DefectConstant.HandlerStatusEnum.FINISH_STATUS.getStatus()).getSum()); |
|
|
|
ratio.setSovleRatio(Double.valueOf(dto.getDefectNum()) / collectStatus.get(DefectConstant.HandlerStatusEnum.FINISH_STATUS.getStatus()).getSum()); |
|
|
|
ratio.setHappenNum((int)collectLevel.get(dto.getDefectLevel()).getSum()); |
|
|
|
ratio.setHappenNum((int) collectLevel.get(dto.getDefectLevel()).getSum()); |
|
|
|
ratio.setHappenRatio(ratio.getHappenNum()/Double.valueOf(total)); |
|
|
|
ratio.setHappenRatio(ratio.getHappenNum() / Double.valueOf(total)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ratio.setHappenNum((int)collectLevel.get(dto.getDefectLevel()).getSum()); |
|
|
|
ratio.setHappenNum((int) collectLevel.get(dto.getDefectLevel()).getSum()); |
|
|
|
ratio.setHappenRatio(ratio.getHappenNum()/Double.valueOf(total)); |
|
|
|
ratio.setHappenRatio(ratio.getHappenNum() / Double.valueOf(total)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 更新缺陷信息 |
|
|
|
* 更新缺陷信息 |
|
|
|
|
|
|
|
* |
|
|
|
* @param entity |
|
|
|
* @param entity |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean updateDefectInfo(OperDefectEntity entity) { |
|
|
|
public boolean updateDefectInfo(OperDefectEntity entity) { |
|
|
|
return this.update(Wrappers.<OperDefectEntity>lambdaUpdate() |
|
|
|
return this.update(Wrappers.<OperDefectEntity>lambdaUpdate().set(OperDefectEntity::getActHours, entity.getActHours()).set(OperDefectEntity::getActStartTime, entity.getActStartTime()).set(OperDefectEntity::getActEndTime, entity.getActEndTime()).set(OperDefectEntity::getDisposeDesc, entity.getDisposeDesc()).eq(OperDefectEntity::getDefectCode, entity.getDefectCode())); |
|
|
|
.set(OperDefectEntity::getActHours, entity.getActHours()) |
|
|
|
|
|
|
|
.set(OperDefectEntity::getActStartTime,entity.getActStartTime()) |
|
|
|
|
|
|
|
.set(OperDefectEntity::getActEndTime,entity.getActEndTime()) |
|
|
|
|
|
|
|
.set(OperDefectEntity::getDisposeDesc,entity.getDisposeDesc()) |
|
|
|
|
|
|
|
.eq(OperDefectEntity::getDefectCode,entity.getDefectCode())); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean updateDefectHanderState(OperDefectEntity entity) { |
|
|
|
public boolean updateDefectHanderState(OperDefectEntity entity) { |
|
|
|
return this.update(Wrappers.<OperDefectEntity>lambdaUpdate() |
|
|
|
return this.update(Wrappers.<OperDefectEntity>lambdaUpdate().set(OperDefectEntity::getHandleStatus, entity.getHandleStatus()).eq(OperDefectEntity::getDefectCode, entity.getDefectCode())); |
|
|
|
.set(OperDefectEntity::getHandleStatus, entity.getHandleStatus()) |
|
|
|
} |
|
|
|
.eq(OperDefectEntity::getDefectCode,entity.getDefectCode())); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 分页查询 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param operDefectEntityPage |
|
|
|
|
|
|
|
* @param defect |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public IPage<OperDefectEntity> selectPage(Page<OperDefectEntity> operDefectEntityPage, OperDefectEntity defect) { |
|
|
|
|
|
|
|
LambdaQueryWrapper<OperDefectEntity> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
|
|
queryWrapper.like(StringUtils.isNotBlank(defect.getDefectCode()), OperDefectEntity::getDefectCode, defect.getDefectCode()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//缺陷编号
|
|
|
|
|
|
|
|
queryWrapper.ge(defect.getActStartTime() != null, OperDefectEntity::getActStartTime, defect.getActStartTime()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
queryWrapper.le(defect.getActEndTime() != null, OperDefectEntity::getActEndTime, defect.getActEndTime()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
queryWrapper.ge(defect.getStartTime() != null, OperDefectEntity::getCreateTime, defect.getStartTime()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
queryWrapper.le(defect.getEndTime() != null, OperDefectEntity::getCreateTime, defect.getEndTime()); |
|
|
|
|
|
|
|
//区域Id
|
|
|
|
|
|
|
|
queryWrapper.eq(BaseEntity::getCreateDept, defect.getCreateDept()); |
|
|
|
|
|
|
|
//年月查询
|
|
|
|
|
|
|
|
queryWrapper.apply(defect.getYearMonth() != null, "date_format(CREATE_TIME,'%Y-%m') = '" + |
|
|
|
|
|
|
|
defect.getYearMonth() + "'"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
queryWrapper.orderByDesc(OperDefectEntity::getActStartTime); |
|
|
|
|
|
|
|
return baseMapper.selectPage(operDefectEntityPage, queryWrapper); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|