|
@@ -1,6 +1,7 @@
|
|
|
package cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport;
|
|
package cn.iocoder.yudao.module.pms.controller.admin.iotrhdailyreport;
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
+import cn.hutool.core.util.ObjUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
@@ -23,7 +24,9 @@ import cn.iocoder.yudao.module.pms.service.iotprojectinfo.IotProjectInfoService;
|
|
|
import cn.iocoder.yudao.module.pms.service.iotprojecttask.IotProjectTaskService;
|
|
import cn.iocoder.yudao.module.pms.service.iotprojecttask.IotProjectTaskService;
|
|
|
import cn.iocoder.yudao.module.pms.service.iotrhdailyreport.IotRhDailyReportService;
|
|
import cn.iocoder.yudao.module.pms.service.iotrhdailyreport.IotRhDailyReportService;
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
|
|
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
|
|
|
+import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
@@ -36,6 +39,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
|
@@ -58,6 +62,8 @@ public class IotRhDailyReportController {
|
|
|
private IotProjectInfoService iotProjectInfoService;
|
|
private IotProjectInfoService iotProjectInfoService;
|
|
|
@Resource
|
|
@Resource
|
|
|
private IotProjectTaskService iotProjectTaskService;
|
|
private IotProjectTaskService iotProjectTaskService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private DictDataService dictDataService;
|
|
|
|
|
|
|
|
@PostMapping("/create")
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建瑞恒日报")
|
|
@Operation(summary = "创建瑞恒日报")
|
|
@@ -183,10 +189,28 @@ public class IotRhDailyReportController {
|
|
|
Map<Long, String> taskPair = new HashMap<>();
|
|
Map<Long, String> taskPair = new HashMap<>();
|
|
|
// key任务id value设计注气量
|
|
// key任务id value设计注气量
|
|
|
Map<Long, String> taskExtPropertyPair = new HashMap<>();
|
|
Map<Long, String> taskExtPropertyPair = new HashMap<>();
|
|
|
|
|
+ // key施工状态数据字典value value施工状态数据字典label
|
|
|
|
|
+ Map<String, String> constructStatusPair = new HashMap<>();
|
|
|
|
|
+ // key非生产时间原因数据字典value value非生产时间原因数据字典label
|
|
|
|
|
+ Map<String, String> nptReasonPair = new HashMap<>();
|
|
|
// 搬迁安装天数
|
|
// 搬迁安装天数
|
|
|
Map<Long, BigDecimal> relocationDaysPair = new HashMap<>();
|
|
Map<Long, BigDecimal> relocationDaysPair = new HashMap<>();
|
|
|
// key部门id value产能
|
|
// key部门id value产能
|
|
|
AtomicReference<Map<Long, BigDecimal>> capacityPair = new AtomicReference<>(new HashMap<>());
|
|
AtomicReference<Map<Long, BigDecimal>> capacityPair = new AtomicReference<>(new HashMap<>());
|
|
|
|
|
+ // 施工状态 字典数据
|
|
|
|
|
+ List<DictDataDO> constructionStatusDictData = dictDataService.getDictDataListByDictType("constructionStatus");
|
|
|
|
|
+ // 非生产时间原因 字典数据
|
|
|
|
|
+ List<DictDataDO> nptReasonDictData = dictDataService.getDictDataListByDictType("nptReason");
|
|
|
|
|
+ if (CollUtil.isNotEmpty(constructionStatusDictData)) {
|
|
|
|
|
+ constructionStatusDictData.forEach(data -> {
|
|
|
|
|
+ constructStatusPair.put(data.getValue(), data.getLabel());
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (CollUtil.isNotEmpty(nptReasonDictData)) {
|
|
|
|
|
+ nptReasonDictData.forEach(data -> {
|
|
|
|
|
+ nptReasonPair.put(data.getValue(), data.getLabel());
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
DataPermissionUtils.executeIgnore(() -> {
|
|
DataPermissionUtils.executeIgnore(() -> {
|
|
|
// 查询日报关联的项目信息
|
|
// 查询日报关联的项目信息
|
|
|
IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
|
|
IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
|
|
@@ -229,6 +253,17 @@ public class IotRhDailyReportController {
|
|
|
});
|
|
});
|
|
|
// 2. 拼接数据
|
|
// 2. 拼接数据
|
|
|
return BeanUtils.toBean(reports, IotRhDailyReportRespVO.class, (reportVO) -> {
|
|
return BeanUtils.toBean(reports, IotRhDailyReportRespVO.class, (reportVO) -> {
|
|
|
|
|
+ if (ObjUtil.isNotEmpty(reportVO.getTransitTime())) {
|
|
|
|
|
+ // 获取原始小数
|
|
|
|
|
+ BigDecimal transitTime = reportVO.getTransitTime();
|
|
|
|
|
+ // 乘以100转换为百分比数值
|
|
|
|
|
+ BigDecimal percentage = transitTime.multiply(BigDecimal.valueOf(100));
|
|
|
|
|
+ // 格式化保留2位小数
|
|
|
|
|
+ DecimalFormat df = new DecimalFormat("0.00");
|
|
|
|
|
+ String transitTimeRate = df.format(percentage) + "%";
|
|
|
|
|
+ // 赋值
|
|
|
|
|
+ reportVO.setTransitTimeRate(transitTimeRate);
|
|
|
|
|
+ }
|
|
|
// 2.1 拼接部门信息
|
|
// 2.1 拼接部门信息
|
|
|
findAndThen(deptMap, reportVO.getDeptId(), dept -> reportVO.setDeptName(dept.getName()));
|
|
findAndThen(deptMap, reportVO.getDeptId(), dept -> reportVO.setDeptName(dept.getName()));
|
|
|
// 2.2 日报关联的项目信息
|
|
// 2.2 日报关联的项目信息
|
|
@@ -241,6 +276,10 @@ public class IotRhDailyReportController {
|
|
|
findAndThen(relocationDaysPair, reportVO.getDeptId(), relocationDays -> reportVO.setRelocationDays(relocationDays));
|
|
findAndThen(relocationDaysPair, reportVO.getDeptId(), relocationDays -> reportVO.setRelocationDays(relocationDays));
|
|
|
// 2.6 产能
|
|
// 2.6 产能
|
|
|
findAndThen(capacityPair.get(), reportVO.getDeptId(), capacity -> reportVO.setCapacity(capacity));
|
|
findAndThen(capacityPair.get(), reportVO.getDeptId(), capacity -> reportVO.setCapacity(capacity));
|
|
|
|
|
+ // 施工状态 数据字典
|
|
|
|
|
+ findAndThen(constructStatusPair, reportVO.getConstructionStatus(), statusLabel -> reportVO.setConstructionStatusName(statusLabel));
|
|
|
|
|
+ // 非生产时间原因 数据字典
|
|
|
|
|
+ findAndThen(nptReasonPair, reportVO.getNptReason(), statusLabel -> reportVO.setNptReasonName(statusLabel));
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -251,10 +290,35 @@ public class IotRhDailyReportController {
|
|
|
public void exportIotRhDailyReportExcel(@Valid IotRhDailyReportPageReqVO pageReqVO,
|
|
public void exportIotRhDailyReportExcel(@Valid IotRhDailyReportPageReqVO pageReqVO,
|
|
|
HttpServletResponse response) throws IOException {
|
|
HttpServletResponse response) throws IOException {
|
|
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
|
|
+ // 根据查询参数筛选出 符合条件 的记录id 再传入 分页查询
|
|
|
|
|
+ Set<Long> projectIds = new HashSet<>();
|
|
|
|
|
+ Set<Long> taskIds = new HashSet<>();
|
|
|
|
|
+ if (StrUtil.isNotBlank(pageReqVO.getContractName())) {
|
|
|
|
|
+ IotProjectInfoPageReqVO reqVO = new IotProjectInfoPageReqVO();
|
|
|
|
|
+ reqVO.setContractName(pageReqVO.getContractName());
|
|
|
|
|
+ List<IotProjectInfoDO> projects = iotProjectInfoService.getIotProjectInfos(reqVO);
|
|
|
|
|
+ if (CollUtil.isNotEmpty(projects)) {
|
|
|
|
|
+ projects.forEach(project -> {
|
|
|
|
|
+ projectIds.add(project.getId());
|
|
|
|
|
+ });
|
|
|
|
|
+ pageReqVO.setProjectIds(projectIds);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.isNotBlank(pageReqVO.getTaskName())) {
|
|
|
|
|
+ IotProjectTaskPageReqVO reqVO = new IotProjectTaskPageReqVO();
|
|
|
|
|
+ reqVO.setSearchKey(pageReqVO.getTaskName());
|
|
|
|
|
+ List<IotProjectTaskDO> tasks = iotProjectTaskService.projectTasks(reqVO);
|
|
|
|
|
+ if (CollUtil.isNotEmpty(tasks)) {
|
|
|
|
|
+ tasks.forEach(task -> {
|
|
|
|
|
+ taskIds.add(task.getId());
|
|
|
|
|
+ });
|
|
|
|
|
+ pageReqVO.setTaskIds(taskIds);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
List<IotRhDailyReportDO> list = iotRhDailyReportService.getIotRhDailyReportPage(pageReqVO).getList();
|
|
List<IotRhDailyReportDO> list = iotRhDailyReportService.getIotRhDailyReportPage(pageReqVO).getList();
|
|
|
// 导出 Excel
|
|
// 导出 Excel
|
|
|
ExcelUtils.write(response, "瑞恒日报.xls", "数据", IotRhDailyReportRespVO.class,
|
|
ExcelUtils.write(response, "瑞恒日报.xls", "数据", IotRhDailyReportRespVO.class,
|
|
|
- BeanUtils.toBean(list, IotRhDailyReportRespVO.class));
|
|
|
|
|
|
|
+ buildRhDailyReports(list));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|