|
|
|
@ -50,6 +50,8 @@ import org.springblade.flow.core.feign.IFlowClient;
|
|
|
|
|
import org.springblade.flow.core.utils.FlowUtil; |
|
|
|
|
import org.springblade.flow.core.vo.ComleteTask; |
|
|
|
|
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.entity.User; |
|
|
|
|
import org.springblade.system.user.feign.IUserClient; |
|
|
|
@ -57,6 +59,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import javax.xml.ws.WebServiceException; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.net.URLEncoder; |
|
|
|
@ -85,6 +88,8 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope
|
|
|
|
|
|
|
|
|
|
private final IUserClient userClient; |
|
|
|
|
|
|
|
|
|
private final ISysClient sysClient; |
|
|
|
|
|
|
|
|
|
private final OperPhenomenonMapper operPhenomenonMapper; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -118,6 +123,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public LambdaQueryWrapper<OperDefectEntity> getQueryWrapper(OperDefectVO defectVO) { |
|
|
|
|
LambdaQueryWrapper<OperDefectEntity> queryWrapper = Condition.getQueryWrapper(new OperDefectEntity(), defectVO); |
|
|
|
@ -180,6 +186,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope
|
|
|
|
|
queryWrapper.orderByDesc(OperDefectEntity::getCreateTime); |
|
|
|
|
return queryWrapper; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 处理问题 |
|
|
|
|
* |
|
|
|
@ -238,19 +245,19 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope
|
|
|
|
|
* @param month 格式:"2021-01" |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public Map<String, Object> getDefectStatistics(String month) { |
|
|
|
|
public Map<String, Object> getDefectStatistics(String month, String deptId) { |
|
|
|
|
Map<String, Object> re = new HashMap<>(); |
|
|
|
|
re.put("currentMonth", getCurrentMonthStatic(month)); |
|
|
|
|
re.put("severalMonths", getStatisticBySeveralMonth(month)); |
|
|
|
|
re.put("manageIndex", getManageIndexStatistic(month)); |
|
|
|
|
re.put("repeat", getRepeatStatistic(month)); |
|
|
|
|
re.put("currentMonth", getCurrentMonthStatic(month, deptId)); |
|
|
|
|
re.put("severalMonths", getStatisticBySeveralMonth(month, deptId)); |
|
|
|
|
re.put("manageIndex", getManageIndexStatistic(month, deptId)); |
|
|
|
|
re.put("repeat", getRepeatStatistic(deptId)); |
|
|
|
|
return re; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@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<>(); |
|
|
|
|
re = this.getDefectStatistics(month); |
|
|
|
|
re = this.getDefectStatistics(month, deptId); |
|
|
|
|
//获取数据
|
|
|
|
|
List<OperDefectRatioDTO> currentMonth = (List<OperDefectRatioDTO>) re.get("currentMonth"); |
|
|
|
|
List<OperDefectRatioDTO> severalMonths = (List<OperDefectRatioDTO>) re.get("severalMonths"); |
|
|
|
@ -785,8 +792,24 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope
|
|
|
|
|
* @param month |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private List<OperDefectRatioDTO> getCurrentMonthStatic(String month) { |
|
|
|
|
List<OperDefectStatisticsStatusDTO> statisticByMonth = this.baseMapper.getStatisticByMonth(month, AuthUtil.getDeptId()); |
|
|
|
|
private List<OperDefectRatioDTO> getCurrentMonthStatic(String month, String deptId) { |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -796,7 +819,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope
|
|
|
|
|
* @param month "2021-01" |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private List<OperDefectRatioDTO> getStatisticBySeveralMonth(String month) { |
|
|
|
|
private List<OperDefectRatioDTO> getStatisticBySeveralMonth(String month, String deptId) { |
|
|
|
|
Integer intervalMonth = Integer.valueOf(month.split("-")[1]); |
|
|
|
|
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
|
Date date; |
|
|
|
@ -811,8 +834,23 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope
|
|
|
|
|
throw new ServiceException("日期转换失败"); |
|
|
|
|
} |
|
|
|
|
log.error("firstMonth:" + firstMonth + "; end=" + dateFormat.format(date)); |
|
|
|
|
|
|
|
|
|
List<OperDefectStatisticsStatusDTO> statisticBySeveralMonth = this.baseMapper.getStatisticBySeveralMonth(firstMonth, dateFormat.format(date), 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> statisticBySeveralMonth = this.baseMapper.getStatisticBySeveralMonth(firstMonth, dateFormat.format(date), createDeptList); |
|
|
|
|
return getRatioStatic(statisticBySeveralMonth); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -822,9 +860,25 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope
|
|
|
|
|
* @param month |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private OperDefectManageIndexDTO getManageIndexStatistic(String month) { |
|
|
|
|
private OperDefectManageIndexDTO getManageIndexStatistic(String month, String deptId) { |
|
|
|
|
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)); |
|
|
|
|
if (!list.get(1).equals(0)) { |
|
|
|
|
manageIndex.setInTimeRatio(list.get(0).equals(0) ? 0.0 : Double.valueOf(list.get(0)) / list.get(1)); |
|
|
|
@ -840,13 +894,29 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope
|
|
|
|
|
/** |
|
|
|
|
* 获取重复缺陷等级统计数据 |
|
|
|
|
* |
|
|
|
|
* @param month |
|
|
|
|
* @param deptId |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private List<OperDefectRepeatRatioDTO> getRepeatStatistic(String month) { |
|
|
|
|
private List<OperDefectRepeatRatioDTO> getRepeatStatistic(String deptId) { |
|
|
|
|
List<OperDefectRepeatRatioDTO> re = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
List<OperDefectStatisticsCodeDTO> repetStatistics = this.baseMapper.getRepetStatistics(AuthUtil.getDeptId()); |
|
|
|
|
List<String> createDeptList = new ArrayList<>(); |
|
|
|
|
List<String> deptList ; |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
if (CollectionUtil.isNotEmpty(createDeptList)) { |
|
|
|
|
List<OperDefectStatisticsCodeDTO> repetStatistics = this.baseMapper.getRepetStatistics(createDeptList); |
|
|
|
|
//总缺陷数
|
|
|
|
|
int total = repetStatistics.stream().mapToInt(OperDefectStatisticsCodeDTO::getDefectNum).sum(); |
|
|
|
|
//总重复缺陷数
|
|
|
|
@ -884,6 +954,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl<OperDefectMapper, Ope
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
re.addAll(Arrays.asList(one, two, three, addUp)); |
|
|
|
|
} |
|
|
|
|
return re; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|