超期,临期计算修改

master
Zangzhipeng 1 year ago
parent 32f7283e89
commit 800535903e
  1. 31
      hiatmp-base/src/main/java/com/hisense/hiatmp/base/controller/HighDangerController.java
  2. 87
      hiatmp-base/src/main/resources/sql-mapper/HighDangerMapper.xml
  3. 11
      hiatmp-model/src/main/java/com/hisense/hiatmp/model/common/HighDangerBase.java

@ -21,6 +21,8 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.nio.file.Path;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
@Slf4j
@ -54,8 +56,6 @@ public class HighDangerController {
public ServerResponse<?> getHighDealt(@RequestBody HighDangerBaseVO highDangerBaseVO,
@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize){
// // 分页
// PageHelper.startPage(pageNum, pageSize);
// 获取当前操作的对象,用于查找对应的部门
Operator operatorById = operatorMapper.getOperatorById(highDangerBaseVO.getCusername());
@ -66,7 +66,32 @@ public class HighDangerController {
// 将要查询的状态和部门id查询数据库,获得隐患排查表
List<HighDangerBase> statusCounts = highDangerMapper.getHigDangerDealt(highDangerBaseVO.getStatus(),cdepartmentid,page);
return ServerResponse.ok(statusCounts);
for (HighDangerBase base : statusCounts) {
Date nowDate = new Date();
Date pcEndTime = base.getPcEndTime();
if(pcEndTime != null){
long diff = nowDate.getTime() - pcEndTime.getTime();
long diffDays = diff / (24 * 60 * 60 * 1000);
// 定义日期格式
int comparison = nowDate.compareTo(pcEndTime);
if(comparison < 0) { // 超期
base.setDeadline(diffDays);
base.setDeadlineStatus("超期" + diffDays + "天");
} else if(comparison > 0 && diffDays <= 3) { // 临期
base.setDeadline(diffDays);
base.setDeadlineStatus("临期" + diffDays + "天");
} else { // 正常
base.setDeadline(diffDays);
base.setDeadlineStatus("正常");
}
}else{
base.setDeadlineStatus("无排查结束时间");
}
}
PageInfo<HighDangerBase> pageInfo = new PageInfo<>(statusCounts);
return ServerResponse.ok(pageInfo);
}
// 查询临期 & 超期任务

@ -115,14 +115,21 @@
<select id="getHigDangerDealt" resultType="com.hisense.hiatmp.model.common.HighDangerBase">
SELECT *
FROM tht_hidden_danger_base hdb
LEFT JOIN tht_hidden_danger_road hdr ON hdb.business_id = hdr.business_id
AND hdb.pc_count = hdr.pc_count
LEFT JOIN department dp ON hdb.handle_dept = dp.cdepartmentid
LEFT JOIN enum_type et ON et.ENUMTYPEID = '6601'
AND et.enumvalue = hdb.status
LEFT JOIN tht_hidden_danger_road hdr ON hdb.business_id = hdr.business_id
AND hdb.pc_count = hdr.pc_count
LEFT JOIN department dp ON hdb.handle_dept = dp.cdepartmentid
LEFT JOIN enum_type et ON et.ENUMTYPEID = '6601'
AND et.enumvalue = hdb.status
WHERE hdb.handle_dept = #{cdepartmentid}
AND hdb.status = #{status}
ORDER BY hdb.PC_END_TIME DESC
<if test="status != null and status != ''">
AND hdb.status = #{status}
</if>
-- ORDER BY hdb.PC_END_TIME::timestamp DESC
ORDER BY
CASE
WHEN hdb.PC_END_TIME IS NULL THEN 1
ELSE 0
END, hdb.PC_END_TIME DESC
</select>
<select id="getHigDangerDying" resultType="com.hisense.hiatmp.model.common.HighDangerBase">
@ -234,8 +241,7 @@
<insert id="insertSectionInfo">
insert into tht_section_info
values (
nextval('test_id_seq'),
values (nextval('test_id_seq'),
#{businessId},
#{roadType},
#{roadWidth},
@ -244,31 +250,27 @@
#{sideProtec},
#{centerSeparate},
#{designSpeed},
#{limitSpeed}
)
#{limitSpeed})
RETURNING #{businessId};
</insert>
<update id="updateSectionInfo">
update tht_section_info
set
"ROAD_TYPE" = #{roadType},
"ROAD_WIDTH" = #{roadWidth},
"LANE_COUNT" = #{laneCount},
"ROAD_STRUCTURE" = #{roadStructure},
"SIDE_PROTEC" = #{sideProtec},
set "ROAD_TYPE" = #{roadType},
"ROAD_WIDTH" = #{roadWidth},
"LANE_COUNT" = #{laneCount},
"ROAD_STRUCTURE" = #{roadStructure},
"SIDE_PROTEC" = #{sideProtec},
"CENTER_SEPARATE" = #{centerSeparate},
"DESIGN_SPEED" = #{designSpeed},
"LIMIT_SPEED" = #{limitSpeed}
where
"BUSINESS_ID" = #{businessId}
"DESIGN_SPEED" = #{designSpeed},
"LIMIT_SPEED" = #{limitSpeed}
where "BUSINESS_ID" = #{businessId}
</update>
<insert id="insertSectionTraffic">
insert into tht_section_traffic
values (
nextval('test_id_seq1'),
values (nextval('test_id_seq1'),
#{businessId},
#{passingTrend},
#{maxTraffic},
@ -278,42 +280,41 @@
#{largeVehicleRate},
#{vehicleTraffic},
#{lastModeUser},
#{lastModeDate}
)
#{lastModeDate})
</insert>
<update id="updateSectionTraffic">
update tht_section_traffic
set
"PASSING_TREND" = #{passingTrend},
"MAX_TRAFFIC" = #{maxTraffic},
"PEAK_TRAFFIC" = #{peakTraffic},
"PEAK_HOURS" = #{peakHours},
"NORMAL_TRAFFIC" = #{normalTraffic},
set "PASSING_TREND" = #{passingTrend},
"MAX_TRAFFIC" = #{maxTraffic},
"PEAK_TRAFFIC" = #{peakTraffic},
"PEAK_HOURS" = #{peakHours},
"NORMAL_TRAFFIC" = #{normalTraffic},
"LARGE_VEHICLE_RATE" = #{largeVehicleRate},
"NONVEHICLE_TRAFFIC" = #{vehicleTraffic},
"LAST_MOD_USER" = #{lastModeUser},
"LAST_MOD_DATE" = #{lastModeDate}
where
"BUSINESS_ID" = #{businessId}
"LAST_MOD_USER" = #{lastModeUser},
"LAST_MOD_DATE" = #{lastModeDate}
where "BUSINESS_ID" = #{businessId}
</update>
<update id="updateTemporary">
update tht_hidden_danger_base
set
status = '99'
where
business_id = #{businessId}
set status = '99'
where business_id = #{businessId}
</update>
<insert id="saveHiddenDataCollectConfig">
INSERT INTO tht_hidden_data_collect_config_copy2 (nid, itemid, order, type, name, standar, unit, pic1_address, pic2_address)
VALUES (nextval('test_id_seq2'),, #{itemid}, #{order}, #{type}, #{name}, #{standar}, #{unit}, #{pic1Address}, #{pic2Address})
INSERT INTO tht_hidden_data_collect_config_copy2 (nid, itemid, order, type, name, standar, unit, pic1_address,
pic2_address)
VALUES (nextval('test_id_seq2'), , #{itemid}, #{order}, #{type}, #{name}, #{standar}, #{unit}, #{pic1Address},
#{pic2Address})
</insert>
<insert id="saveDangerExtra">
INSERT INTO tht_hidden_danger_extra (nid, key_investigation, danger_item, danger_desc, image_list, information, business_id)
VALUES (nextval('test_id_seq3'),, #{key_investigation}, #{danger_item}, #{danger_desc}, #{image_list}, #{information}, #{business_id})
INSERT INTO tht_hidden_danger_extra (nid, key_investigation, danger_item, danger_desc, image_list, information,
business_id)
VALUES (nextval('test_id_seq3'), , #{key_investigation}, #{danger_item}, #{danger_desc}, #{image_list},
#{information}, #{business_id})
</insert>
</mapper>

@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@Data
public class HighDangerBase implements Serializable {
@ -76,7 +78,8 @@ public class HighDangerBase implements Serializable {
/**
* pc_end_time
*/
private String pcEndTime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date pcEndTime;
/**
* zl_start_time
@ -163,4 +166,10 @@ public class HighDangerBase implements Serializable {
*/
private String lastModDate;
// 临期时间
private Long deadline;
// 临期状态
private String deadlineStatus;
}

Loading…
Cancel
Save