|
|
@ -50,6 +50,8 @@ import org.springblade.flow.core.feign.IFlowClient; |
|
|
|
import org.springblade.flow.core.utils.FlowUtil; |
|
|
|
import org.springblade.flow.core.utils.FlowUtil; |
|
|
|
import org.springblade.flow.core.vo.ComleteTask; |
|
|
|
import org.springblade.flow.core.vo.ComleteTask; |
|
|
|
import org.springblade.system.cache.DictCache; |
|
|
|
import org.springblade.system.cache.DictCache; |
|
|
|
|
|
|
|
import org.springblade.system.entity.Dept; |
|
|
|
|
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
|
import org.springblade.system.user.cache.UserCache; |
|
|
|
import org.springblade.system.user.cache.UserCache; |
|
|
|
import org.springblade.system.user.entity.User; |
|
|
|
import org.springblade.system.user.entity.User; |
|
|
|
import org.springblade.system.user.feign.IUserClient; |
|
|
|
import org.springblade.system.user.feign.IUserClient; |
|
|
@ -57,6 +59,7 @@ import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream; |
|
|
|
import javax.servlet.ServletOutputStream; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
import javax.xml.ws.WebServiceException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.net.URLEncoder; |
|
|
@ -85,6 +88,8 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
|
|
|
|
|
|
|
|
private final IUserClient userClient; |
|
|
|
private final IUserClient userClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final ISysClient sysClient; |
|
|
|
|
|
|
|
|
|
|
|
private final OperPhenomenonMapper operPhenomenonMapper; |
|
|
|
private final OperPhenomenonMapper operPhenomenonMapper; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -118,6 +123,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public LambdaQueryWrapper<OperDefectEntity> getQueryWrapper(OperDefectVO defectVO) { |
|
|
|
public LambdaQueryWrapper<OperDefectEntity> getQueryWrapper(OperDefectVO defectVO) { |
|
|
|
LambdaQueryWrapper<OperDefectEntity> queryWrapper = Condition.getQueryWrapper(new OperDefectEntity(), defectVO); |
|
|
|
LambdaQueryWrapper<OperDefectEntity> queryWrapper = Condition.getQueryWrapper(new OperDefectEntity(), defectVO); |
|
|
@ -180,6 +186,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
queryWrapper.orderByDesc(OperDefectEntity::getCreateTime); |
|
|
|
queryWrapper.orderByDesc(OperDefectEntity::getCreateTime); |
|
|
|
return queryWrapper; |
|
|
|
return queryWrapper; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 处理问题 |
|
|
|
* 处理问题 |
|
|
|
* |
|
|
|
* |
|
|
@ -238,19 +245,19 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
* @param month 格式:"2021-01" |
|
|
|
* @param month 格式:"2021-01" |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Map<String, Object> getDefectStatistics(String month) { |
|
|
|
public Map<String, Object> getDefectStatistics(String month, String deptId) { |
|
|
|
Map<String, Object> re = new HashMap<>(); |
|
|
|
Map<String, Object> re = new HashMap<>(); |
|
|
|
re.put("currentMonth", getCurrentMonthStatic(month)); |
|
|
|
re.put("currentMonth", getCurrentMonthStatic(month, deptId)); |
|
|
|
re.put("severalMonths", getStatisticBySeveralMonth(month)); |
|
|
|
re.put("severalMonths", getStatisticBySeveralMonth(month, deptId)); |
|
|
|
re.put("manageIndex", getManageIndexStatistic(month)); |
|
|
|
re.put("manageIndex", getManageIndexStatistic(month, deptId)); |
|
|
|
re.put("repeat", getRepeatStatistic(month)); |
|
|
|
re.put("repeat", getRepeatStatistic(deptId)); |
|
|
|
return re; |
|
|
|
return re; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void exportFualtMonthExcel(HttpServletResponse response, String month) throws IOException { |
|
|
|
public void exportFualtMonthExcel(HttpServletResponse response, String month, String deptId) throws IOException { |
|
|
|
Map<String, Object> re = new HashMap<>(); |
|
|
|
Map<String, Object> re = new HashMap<>(); |
|
|
|
re = this.getDefectStatistics(month); |
|
|
|
re = this.getDefectStatistics(month, deptId); |
|
|
|
//获取数据
|
|
|
|
//获取数据
|
|
|
|
List<OperDefectRatioDTO> currentMonth = (List<OperDefectRatioDTO>) re.get("currentMonth"); |
|
|
|
List<OperDefectRatioDTO> currentMonth = (List<OperDefectRatioDTO>) re.get("currentMonth"); |
|
|
|
List<OperDefectRatioDTO> severalMonths = (List<OperDefectRatioDTO>) re.get("severalMonths"); |
|
|
|
List<OperDefectRatioDTO> severalMonths = (List<OperDefectRatioDTO>) re.get("severalMonths"); |
|
|
@ -785,8 +792,24 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
* @param month |
|
|
|
* @param month |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<OperDefectRatioDTO> getCurrentMonthStatic(String month) { |
|
|
|
private List<OperDefectRatioDTO> getCurrentMonthStatic(String month, String deptId) { |
|
|
|
List<OperDefectStatisticsStatusDTO> statisticByMonth = this.baseMapper.getStatisticByMonth(month, AuthUtil.getDeptId()); |
|
|
|
List<String> createDeptList = new ArrayList<>(); |
|
|
|
|
|
|
|
List<String> deptList = new ArrayList<>(); |
|
|
|
|
|
|
|
R<List<Dept>> res = sysClient.getDeptByCurrentUser(); |
|
|
|
|
|
|
|
if (res.isSuccess() && CollectionUtil.isNotEmpty(res.getData())) { |
|
|
|
|
|
|
|
deptList = res.getData().stream().map(Dept::getId).map(s -> s.toString()).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
throw new WebServiceException("该用户没有此权限"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtil.isNotBlank(deptId)) { |
|
|
|
|
|
|
|
if (deptList.contains(deptId)) { |
|
|
|
|
|
|
|
createDeptList.add(deptId); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
//拿到用户当前及其以下的机构
|
|
|
|
|
|
|
|
createDeptList.addAll(deptList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<OperDefectStatisticsStatusDTO> statisticByMonth = this.baseMapper.getStatisticByMonth(month, createDeptList); |
|
|
|
return getRatioStatic(statisticByMonth); |
|
|
|
return getRatioStatic(statisticByMonth); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -796,7 +819,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
* @param month "2021-01" |
|
|
|
* @param month "2021-01" |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<OperDefectRatioDTO> getStatisticBySeveralMonth(String month) { |
|
|
|
private List<OperDefectRatioDTO> getStatisticBySeveralMonth(String month, String deptId) { |
|
|
|
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; |
|
|
@ -811,8 +834,23 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
throw new ServiceException("日期转换失败"); |
|
|
|
throw new ServiceException("日期转换失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
log.error("firstMonth:" + firstMonth + "; end=" + dateFormat.format(date)); |
|
|
|
log.error("firstMonth:" + firstMonth + "; end=" + dateFormat.format(date)); |
|
|
|
|
|
|
|
List<String> createDeptList = new ArrayList<>(); |
|
|
|
List<OperDefectStatisticsStatusDTO> statisticBySeveralMonth = this.baseMapper.getStatisticBySeveralMonth(firstMonth, dateFormat.format(date), AuthUtil.getDeptId()); |
|
|
|
List<String> deptList = new ArrayList<>(); |
|
|
|
|
|
|
|
R<List<Dept>> res = sysClient.getDeptByCurrentUser(); |
|
|
|
|
|
|
|
if (res.isSuccess() && CollectionUtil.isNotEmpty(res.getData())) { |
|
|
|
|
|
|
|
deptList = res.getData().stream().map(Dept::getId).map(s -> s.toString()).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
throw new WebServiceException("该用户没有此权限"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtil.isNotBlank(deptId)) { |
|
|
|
|
|
|
|
if (deptList.contains(deptId)) { |
|
|
|
|
|
|
|
createDeptList.add(deptId); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
//拿到用户当前及其以下的机构
|
|
|
|
|
|
|
|
createDeptList.addAll(deptList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<OperDefectStatisticsStatusDTO> statisticBySeveralMonth = this.baseMapper.getStatisticBySeveralMonth(firstMonth, dateFormat.format(date), createDeptList); |
|
|
|
return getRatioStatic(statisticBySeveralMonth); |
|
|
|
return getRatioStatic(statisticBySeveralMonth); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -822,9 +860,25 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
* @param month |
|
|
|
* @param month |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private OperDefectManageIndexDTO getManageIndexStatistic(String month) { |
|
|
|
private OperDefectManageIndexDTO getManageIndexStatistic(String month, String deptId) { |
|
|
|
OperDefectManageIndexDTO manageIndex = new OperDefectManageIndexDTO(); |
|
|
|
OperDefectManageIndexDTO manageIndex = new OperDefectManageIndexDTO(); |
|
|
|
List<Integer> list = this.baseMapper.getManageIndex(month, AuthUtil.getDeptId()); |
|
|
|
List<String> createDeptList = new ArrayList<>(); |
|
|
|
|
|
|
|
List<String> deptList = new ArrayList<>(); |
|
|
|
|
|
|
|
R<List<Dept>> res = sysClient.getDeptByCurrentUser(); |
|
|
|
|
|
|
|
if (res.isSuccess() && CollectionUtil.isNotEmpty(res.getData())) { |
|
|
|
|
|
|
|
deptList = res.getData().stream().map(Dept::getId).map(s -> s.toString()).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
throw new WebServiceException("该用户没有此权限"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtil.isNotBlank(deptId)) { |
|
|
|
|
|
|
|
if (deptList.contains(deptId)) { |
|
|
|
|
|
|
|
createDeptList.add(deptId); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
//拿到用户当前及其以下的机构
|
|
|
|
|
|
|
|
createDeptList.addAll(deptList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<Integer> list = this.baseMapper.getManageIndex(month, createDeptList); |
|
|
|
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)); |
|
|
@ -840,50 +894,67 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取重复缺陷等级统计数据 |
|
|
|
* 获取重复缺陷等级统计数据 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param month |
|
|
|
* @param deptId |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<OperDefectRepeatRatioDTO> getRepeatStatistic(String month) { |
|
|
|
private List<OperDefectRepeatRatioDTO> getRepeatStatistic(String deptId) { |
|
|
|
List<OperDefectRepeatRatioDTO> re = new ArrayList<>(); |
|
|
|
List<OperDefectRepeatRatioDTO> re = new ArrayList<>(); |
|
|
|
|
|
|
|
List<String> createDeptList = new ArrayList<>(); |
|
|
|
List<OperDefectStatisticsCodeDTO> repetStatistics = this.baseMapper.getRepetStatistics(AuthUtil.getDeptId()); |
|
|
|
List<String> deptList ; |
|
|
|
//总缺陷数
|
|
|
|
R<List<Dept>> res = sysClient.getDeptByCurrentUser(); |
|
|
|
int total = repetStatistics.stream().mapToInt(OperDefectStatisticsCodeDTO::getDefectNum).sum(); |
|
|
|
if (res.isSuccess() && CollectionUtil.isNotEmpty(res.getData())) { |
|
|
|
//总重复缺陷数
|
|
|
|
deptList = res.getData().stream().map(Dept::getId).map(s -> s.toString()).collect(Collectors.toList()); |
|
|
|
int totalRepeat = repetStatistics.stream().filter(s -> s.getDefectNum() > 1 && s.getDefectLevel() != null).collect(Collectors.summingInt(OperDefectStatisticsCodeDTO::getDefectNum)); |
|
|
|
} else { |
|
|
|
//等级重复统计
|
|
|
|
throw new WebServiceException("该用户没有此权限"); |
|
|
|
Map<String, IntSummaryStatistics> repeatList = repetStatistics.stream().filter(s -> s.getDefectNum() > 1 && s.getDefectLevel() != null).collect(Collectors.groupingBy(OperDefectStatisticsCodeDTO::getDefectLevel, Collectors.summarizingInt(OperDefectStatisticsCodeDTO::getDefectNum))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OperDefectRepeatRatioDTO one = new OperDefectRepeatRatioDTO(); |
|
|
|
|
|
|
|
one.setDefectLevel(DefectConstant.DefectLevelEnum.ONE.getStatus()); |
|
|
|
|
|
|
|
if (repeatList.get(one.getDefectLevel()) != null) { |
|
|
|
|
|
|
|
one.setHappenNum(repeatList.get(one.getDefectLevel()).getSum()); |
|
|
|
|
|
|
|
one.setHappenRatio(one.getHappenNum() / Double.valueOf(total)); |
|
|
|
|
|
|
|
one.setRepeatRatio(one.getHappenNum() / Double.valueOf(totalRepeat)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtil.isNotBlank(deptId)) { |
|
|
|
OperDefectRepeatRatioDTO two = new OperDefectRepeatRatioDTO(); |
|
|
|
if (deptList.contains(deptId)) { |
|
|
|
two.setDefectLevel(DefectConstant.DefectLevelEnum.TWO.getStatus()); |
|
|
|
createDeptList.add(deptId); |
|
|
|
if (repeatList.get(two.getDefectLevel()) != null) { |
|
|
|
} |
|
|
|
two.setHappenNum(repeatList.get(two.getDefectLevel()).getSum()); |
|
|
|
} else { |
|
|
|
two.setHappenRatio(two.getHappenNum() / Double.valueOf(total)); |
|
|
|
//拿到用户当前及其以下的机构
|
|
|
|
two.setRepeatRatio(two.getHappenNum() / Double.valueOf(totalRepeat)); |
|
|
|
createDeptList.addAll(deptList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(createDeptList)) { |
|
|
|
|
|
|
|
List<OperDefectStatisticsCodeDTO> repetStatistics = this.baseMapper.getRepetStatistics(createDeptList); |
|
|
|
|
|
|
|
//总缺陷数
|
|
|
|
|
|
|
|
int total = repetStatistics.stream().mapToInt(OperDefectStatisticsCodeDTO::getDefectNum).sum(); |
|
|
|
|
|
|
|
//总重复缺陷数
|
|
|
|
|
|
|
|
int totalRepeat = repetStatistics.stream().filter(s -> s.getDefectNum() > 1 && s.getDefectLevel() != null).collect(Collectors.summingInt(OperDefectStatisticsCodeDTO::getDefectNum)); |
|
|
|
|
|
|
|
//等级重复统计
|
|
|
|
|
|
|
|
Map<String, IntSummaryStatistics> repeatList = repetStatistics.stream().filter(s -> s.getDefectNum() > 1 && s.getDefectLevel() != null).collect(Collectors.groupingBy(OperDefectStatisticsCodeDTO::getDefectLevel, Collectors.summarizingInt(OperDefectStatisticsCodeDTO::getDefectNum))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OperDefectRepeatRatioDTO one = new OperDefectRepeatRatioDTO(); |
|
|
|
|
|
|
|
one.setDefectLevel(DefectConstant.DefectLevelEnum.ONE.getStatus()); |
|
|
|
|
|
|
|
if (repeatList.get(one.getDefectLevel()) != null) { |
|
|
|
|
|
|
|
one.setHappenNum(repeatList.get(one.getDefectLevel()).getSum()); |
|
|
|
|
|
|
|
one.setHappenRatio(one.getHappenNum() / Double.valueOf(total)); |
|
|
|
|
|
|
|
one.setRepeatRatio(one.getHappenNum() / Double.valueOf(totalRepeat)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
OperDefectRepeatRatioDTO three = new OperDefectRepeatRatioDTO(); |
|
|
|
OperDefectRepeatRatioDTO two = new OperDefectRepeatRatioDTO(); |
|
|
|
three.setDefectLevel(DefectConstant.DefectLevelEnum.THREE.getStatus()); |
|
|
|
two.setDefectLevel(DefectConstant.DefectLevelEnum.TWO.getStatus()); |
|
|
|
if (repeatList.get(three.getDefectLevel()) != null) { |
|
|
|
if (repeatList.get(two.getDefectLevel()) != null) { |
|
|
|
three.setHappenNum(repeatList.get(three.getDefectLevel()).getSum()); |
|
|
|
two.setHappenNum(repeatList.get(two.getDefectLevel()).getSum()); |
|
|
|
three.setHappenRatio(three.getHappenNum() / Double.valueOf(total)); |
|
|
|
two.setHappenRatio(two.getHappenNum() / Double.valueOf(total)); |
|
|
|
three.setRepeatRatio(three.getHappenNum() / Double.valueOf(totalRepeat)); |
|
|
|
two.setRepeatRatio(two.getHappenNum() / Double.valueOf(totalRepeat)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
OperDefectRepeatRatioDTO addUp = OperDefectRepeatRatioDTO.builder().defectLevel("合计").happenNum(one.getHappenNum() + two.getHappenNum() + three.getHappenNum()).happenRatio(one.getHappenRatio() + two.getHappenRatio() + three.getHappenRatio()).repeatRatio(1.00).build(); |
|
|
|
OperDefectRepeatRatioDTO three = new OperDefectRepeatRatioDTO(); |
|
|
|
if (addUp.getHappenNum().equals(0L)) { |
|
|
|
three.setDefectLevel(DefectConstant.DefectLevelEnum.THREE.getStatus()); |
|
|
|
addUp.setRepeatRatio(0.0); |
|
|
|
if (repeatList.get(three.getDefectLevel()) != null) { |
|
|
|
} |
|
|
|
three.setHappenNum(repeatList.get(three.getDefectLevel()).getSum()); |
|
|
|
|
|
|
|
three.setHappenRatio(three.getHappenNum() / Double.valueOf(total)); |
|
|
|
|
|
|
|
three.setRepeatRatio(three.getHappenNum() / Double.valueOf(totalRepeat)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
re.addAll(Arrays.asList(one, two, three, addUp)); |
|
|
|
OperDefectRepeatRatioDTO addUp = OperDefectRepeatRatioDTO.builder().defectLevel("合计").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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
re.addAll(Arrays.asList(one, two, three, addUp)); |
|
|
|
|
|
|
|
} |
|
|
|
return re; |
|
|
|
return re; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|