|
@@ -6,13 +6,17 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportPageReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportPageReqVO;
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotrydailyreport.vo.IotRyDailyReportTaskCountVO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotrydailyreport.IotRyDailyReportDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotrydailyreport.IotRyDailyReportDO;
|
|
import org.apache.ibatis.annotations.Mapper;
|
|
import org.apache.ibatis.annotations.Mapper;
|
|
import org.apache.ibatis.annotations.Param;
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
|
+import org.apache.ibatis.annotations.Select;
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 瑞鹰日报 Mapper
|
|
* 瑞鹰日报 Mapper
|
|
@@ -58,7 +62,8 @@ public interface IotRyDailyReportMapper extends BaseMapperX<IotRyDailyReportDO>
|
|
.eqIfPresent(IotRyDailyReportDO::getProcessInstanceId, reqVO.getProcessInstanceId())
|
|
.eqIfPresent(IotRyDailyReportDO::getProcessInstanceId, reqVO.getProcessInstanceId())
|
|
.eqIfPresent(IotRyDailyReportDO::getAuditStatus, reqVO.getAuditStatus())
|
|
.eqIfPresent(IotRyDailyReportDO::getAuditStatus, reqVO.getAuditStatus())
|
|
.betweenIfPresent(IotRyDailyReportDO::getCreateTime, reqVO.getCreateTime())
|
|
.betweenIfPresent(IotRyDailyReportDO::getCreateTime, reqVO.getCreateTime())
|
|
- .orderByDesc(IotRyDailyReportDO::getId));
|
|
|
|
|
|
+ .orderByDesc(IotRyDailyReportDO::getCreateTime)
|
|
|
|
+ .orderByAsc(IotRyDailyReportDO::getId));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -88,10 +93,11 @@ public interface IotRyDailyReportMapper extends BaseMapperX<IotRyDailyReportDO>
|
|
* @return 最新日报记录
|
|
* @return 最新日报记录
|
|
*/
|
|
*/
|
|
default IotRyDailyReportDO selectLatestReportBeforeDate(Long deptId, Long taskId, LocalDateTime dateTime) {
|
|
default IotRyDailyReportDO selectLatestReportBeforeDate(Long deptId, Long taskId, LocalDateTime dateTime) {
|
|
|
|
+ String dateStr = dateTime != null ? dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) : "";
|
|
return selectOne(new LambdaQueryWrapperX<IotRyDailyReportDO>()
|
|
return selectOne(new LambdaQueryWrapperX<IotRyDailyReportDO>()
|
|
.eqIfPresent(IotRyDailyReportDO::getDeptId, deptId)
|
|
.eqIfPresent(IotRyDailyReportDO::getDeptId, deptId)
|
|
.eqIfPresent(IotRyDailyReportDO::getTaskId, taskId)
|
|
.eqIfPresent(IotRyDailyReportDO::getTaskId, taskId)
|
|
- .lt(IotRyDailyReportDO::getCreateTime, dateTime)
|
|
|
|
|
|
+ .apply(StrUtil.isNotBlank(dateStr), "DATE(create_time) < {0}", dateStr)
|
|
.orderByDesc(IotRyDailyReportDO::getCreateTime)
|
|
.orderByDesc(IotRyDailyReportDO::getCreateTime)
|
|
.last("limit 1"));
|
|
.last("limit 1"));
|
|
}
|
|
}
|
|
@@ -104,4 +110,74 @@ public interface IotRyDailyReportMapper extends BaseMapperX<IotRyDailyReportDO>
|
|
*/
|
|
*/
|
|
List<IotRyDailyReportDO> selectListGrouped(@Param("reqVO") IotRyDailyReportPageReqVO reqVO);
|
|
List<IotRyDailyReportDO> selectListGrouped(@Param("reqVO") IotRyDailyReportPageReqVO reqVO);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 查询每个施工队伍的 上井次完井时间
|
|
|
|
+ * @param reqVO
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ List<IotRyDailyReportDO> latestWellDoneTimes(@Param("reqVO") IotRyDailyReportPageReqVO reqVO);
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询指定部门、指定时间段 填写的日报记录的 ’月进尺数据‘(逻辑细则:reportDate 所在的月份与数据表的字段 construction_start_date
|
|
|
|
+ * 所在的月份相匹配 且 create_time < reportDate 的记录的 ’daily_footage‘ 字段值累加计算得出
|
|
|
|
+ * @param deptId
|
|
|
|
+ * @param reportDate
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ default BigDecimal monthlyFootages(Long deptId, LocalDateTime reportDate) {
|
|
|
|
+ if (reportDate == null) {
|
|
|
|
+ return BigDecimal.ZERO;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int year = reportDate.getYear();
|
|
|
|
+ int month = reportDate.getMonthValue();
|
|
|
|
+
|
|
|
|
+ List<IotRyDailyReportDO> list = selectList(new LambdaQueryWrapperX<IotRyDailyReportDO>()
|
|
|
|
+ .eq(ObjUtil.isNotNull(deptId), IotRyDailyReportDO::getDeptId, deptId)
|
|
|
|
+ .lt(IotRyDailyReportDO::getCreateTime, reportDate)
|
|
|
|
+ .apply("YEAR(construction_start_date) = {0}", year)
|
|
|
|
+ .apply("MONTH(construction_start_date) = {0}", month));
|
|
|
|
+
|
|
|
|
+ return list.stream()
|
|
|
|
+ .map(IotRyDailyReportDO::getDailyFootage)
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询每个施工队伍的 历史 年进尺
|
|
|
|
+ * @param deptId 部门ID
|
|
|
|
+ * @param reportDate 报告日期
|
|
|
|
+ * @return 年进尺总和
|
|
|
|
+ */
|
|
|
|
+ default BigDecimal annualFootages(Long deptId, LocalDateTime reportDate) {
|
|
|
|
+ if (reportDate == null) {
|
|
|
|
+ return BigDecimal.ZERO;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int year = reportDate.getYear();
|
|
|
|
+
|
|
|
|
+ List<IotRyDailyReportDO> list = selectList(new LambdaQueryWrapperX<IotRyDailyReportDO>()
|
|
|
|
+ .eq(ObjUtil.isNotNull(deptId), IotRyDailyReportDO::getDeptId, deptId)
|
|
|
|
+ .lt(IotRyDailyReportDO::getCreateTime, reportDate)
|
|
|
|
+ .apply("YEAR(construction_start_date) = {0}", year));
|
|
|
|
+
|
|
|
|
+ return list.stream()
|
|
|
|
+ .map(IotRyDailyReportDO::getDailyFootage)
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 按部门统计任务数量
|
|
|
|
+ * @return 部门任务统计列表
|
|
|
|
+ */
|
|
|
|
+ @Select("SELECT " +
|
|
|
|
+ "dept_id as deptId, " +
|
|
|
|
+ "COUNT(DISTINCT CASE WHEN task_id IS NOT NULL THEN task_id END) as totalTaskCount, " +
|
|
|
|
+ "COUNT(DISTINCT CASE WHEN rig_status = 12 AND task_id IS NOT NULL THEN task_id END) as completedTaskCount " +
|
|
|
|
+ "FROM rq_iot_ry_daily_report " +
|
|
|
|
+ "WHERE deleted = 0 " +
|
|
|
|
+ "GROUP BY dept_id")
|
|
|
|
+ List<IotRyDailyReportTaskCountVO> countTasksByDept();
|
|
}
|
|
}
|