Pārlūkot izejas kodu

fix:日期格式转换

aihua 3 gadi atpakaļ
vecāks
revīzija
7d06a97d86

+ 4 - 5
src/main/java/com/chinaitop/depot/risk/controller/RiskManagementController.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
4
 import com.chinaitop.depot.risk.model.RiskManagement;
4
 import com.chinaitop.depot.risk.model.RiskManagement;
5
 import com.chinaitop.depot.risk.service.RiskManagementService;
5
 import com.chinaitop.depot.risk.service.RiskManagementService;
6
 import com.chinaitop.depot.unissoft.model.ResponseEntity;
6
 import com.chinaitop.depot.unissoft.model.ResponseEntity;
7
+import com.chinaitop.depot.utils.ParameterUtil;
7
 import com.github.pagehelper.PageHelper;
8
 import com.github.pagehelper.PageHelper;
8
 import com.github.pagehelper.PageInfo;
9
 import com.github.pagehelper.PageInfo;
9
 import com.google.common.collect.Maps;
10
 import com.google.common.collect.Maps;
@@ -55,15 +56,13 @@ public class RiskManagementController {
55
         }
56
         }
56
         Map<String, Object> queryMap = Maps.newHashMap();
57
         Map<String, Object> queryMap = Maps.newHashMap();
57
         if (StringUtils.isNotBlank(startDate)) {
58
         if (StringUtils.isNotBlank(startDate)) {
58
-            queryMap.put("startDate", startDate);
59
+            queryMap.put("startDate", ParameterUtil.string2datetime(startDate));
59
         }
60
         }
60
         if (StringUtils.isNotBlank(endDate)) {
61
         if (StringUtils.isNotBlank(endDate)) {
61
-            queryMap.put("endDate", endDate);
62
+            queryMap.put("endDate", ParameterUtil.string2datetime(endDate));
62
         }
63
         }
63
         queryMap.put("orgId", orgId);
64
         queryMap.put("orgId", orgId);
64
-        List<RiskManagement> list = riskManagementService.selectListPage(queryMap);
65
-        PageInfo<RiskManagement> pageInfo = new PageInfo<>(list);
66
-        return ResponseEntity.ok(pageInfo);
65
+        return ResponseEntity.ok(new PageInfo<>(riskManagementService.selectListPage(queryMap)));
67
     }
66
     }
68
 
67
 
69
     @RequestMapping(value = "/saveData", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
68
     @RequestMapping(value = "/saveData", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)

+ 3 - 2
src/main/java/com/chinaitop/depot/risk/controller/ViolationWarningAlarmController.java

@@ -5,6 +5,7 @@ import com.chinaitop.depot.risk.model.RiskManagement;
5
 import com.chinaitop.depot.risk.model.ViolationWarningAlarm;
5
 import com.chinaitop.depot.risk.model.ViolationWarningAlarm;
6
 import com.chinaitop.depot.risk.service.ViolationWarningAlarmService;
6
 import com.chinaitop.depot.risk.service.ViolationWarningAlarmService;
7
 import com.chinaitop.depot.unissoft.model.ResponseEntity;
7
 import com.chinaitop.depot.unissoft.model.ResponseEntity;
8
+import com.chinaitop.depot.utils.ParameterUtil;
8
 import com.github.pagehelper.PageHelper;
9
 import com.github.pagehelper.PageHelper;
9
 import com.github.pagehelper.PageInfo;
10
 import com.github.pagehelper.PageInfo;
10
 import com.google.common.collect.Maps;
11
 import com.google.common.collect.Maps;
@@ -57,10 +58,10 @@ public class ViolationWarningAlarmController {
57
         }
58
         }
58
         Map<String, Object> queryMap = Maps.newHashMap();
59
         Map<String, Object> queryMap = Maps.newHashMap();
59
         if (StringUtils.isNotBlank(startDate)) {
60
         if (StringUtils.isNotBlank(startDate)) {
60
-            queryMap.put("startDate", startDate);
61
+            queryMap.put("startDate", ParameterUtil.string2datetime(startDate));
61
         }
62
         }
62
         if (StringUtils.isNotBlank(endDate)) {
63
         if (StringUtils.isNotBlank(endDate)) {
63
-            queryMap.put("endDate", endDate);
64
+            queryMap.put("endDate", ParameterUtil.string2datetime(endDate));
64
         }
65
         }
65
         if (StringUtils.isNotBlank(violationType)) {
66
         if (StringUtils.isNotBlank(violationType)) {
66
             queryMap.put("violationType", violationType);
67
             queryMap.put("violationType", violationType);

+ 4 - 4
src/main/java/com/chinaitop/depot/risk/mapper/RiskManagementMapper.xml

@@ -22,11 +22,11 @@
22
             risk_management
22
             risk_management
23
         where
23
         where
24
             org_id = #{orgId}
24
             org_id = #{orgId}
25
-        <if test="startDate != null and endDate != null" >
26
-            and create_time BETWEEN #{startDate} AND #{endDate}
25
+        <if test="startDate != null" >
26
+            <![CDATA[ and create_time >= #{startDate} ]]>
27
         </if>
27
         </if>
28
-        <if test="startDate != null and endDate != null" >
29
-            and create_time &lt;= #{endDate}
28
+        <if test="endDate != null" >
29
+            <![CDATA[ and create_time <= #{endDate} ]]>
30
         </if>
30
         </if>
31
     </select>
31
     </select>
32
 
32
 

+ 7 - 4
src/main/java/com/chinaitop/depot/risk/mapper/ViolationWarningAlarmMapper.xml

@@ -3,7 +3,7 @@
3
 <mapper namespace="com.chinaitop.depot.risk.mapper.ViolationWarningAlarmMapper">
3
 <mapper namespace="com.chinaitop.depot.risk.mapper.ViolationWarningAlarmMapper">
4
     <resultMap id="BaseResultMap" type="com.chinaitop.depot.risk.model.ViolationWarningAlarm">
4
     <resultMap id="BaseResultMap" type="com.chinaitop.depot.risk.model.ViolationWarningAlarm">
5
         <id column="id" property="id" jdbcType="INTEGER"/>
5
         <id column="id" property="id" jdbcType="INTEGER"/>
6
-        <result column="publish_time" property="alarmPublishTime" jdbcType="VARCHAR"/>
6
+        <result column="publish_time" property="alarmPublishTime" jdbcType="TIMESTAMP"/>
7
         <result column="offender" property="offender" jdbcType="VARCHAR"/>
7
         <result column="offender" property="offender" jdbcType="VARCHAR"/>
8
         <result column="library_point_name" property="involvingLibraryPoints" jdbcType="VARCHAR"/>
8
         <result column="library_point_name" property="involvingLibraryPoints" jdbcType="VARCHAR"/>
9
         <result column="violation_type" property="violationType" jdbcType="VARCHAR"/>
9
         <result column="violation_type" property="violationType" jdbcType="VARCHAR"/>
@@ -37,8 +37,11 @@
37
         storage_pre_violation
37
         storage_pre_violation
38
         where
38
         where
39
         org_id = #{orgId}
39
         org_id = #{orgId}
40
-        <if test="startDate != null and endDate != null" >
41
-            and publish_time BETWEEN #{startDate} AND #{endDate}
40
+        <if test="startDate != null">
41
+           <![CDATA[ and publish_time >= #{startDate} ]]>
42
+        </if>
43
+        <if test="endDate != null">
44
+           <![CDATA[ and publish_time <= #{endDate} ]]>
42
         </if>
45
         </if>
43
         <if test="violationType != null" >
46
         <if test="violationType != null" >
44
             and violation_type = #{violationType}
47
             and violation_type = #{violationType}
@@ -54,7 +57,7 @@
54
         dispose_content, subject_type,
57
         dispose_content, subject_type,
55
         dispose_time, status, org_id, create_time)
58
         dispose_time, status, org_id, create_time)
56
         VALUES (#{id,jdbcType=INTEGER},
59
         VALUES (#{id,jdbcType=INTEGER},
57
-        #{alarmPublishTime,jdbcType=VARCHAR},
60
+        #{alarmPublishTime,jdbcType=TIMESTAMP},
58
         #{offender,jdbcType=VARCHAR},
61
         #{offender,jdbcType=VARCHAR},
59
         #{involvingLibraryPoints,jdbcType=VARCHAR},
62
         #{involvingLibraryPoints,jdbcType=VARCHAR},
60
         #{violationType,jdbcType=VARCHAR},
63
         #{violationType,jdbcType=VARCHAR},

+ 5 - 2
src/main/java/com/chinaitop/depot/risk/model/RiskManagement.java

@@ -1,5 +1,6 @@
1
 package com.chinaitop.depot.risk.model;
1
 package com.chinaitop.depot.risk.model;
2
 
2
 
3
+import com.fasterxml.jackson.annotation.JsonFormat;
3
 import lombok.Data;
4
 import lombok.Data;
4
 import lombok.experimental.Accessors;
5
 import lombok.experimental.Accessors;
5
 
6
 
@@ -82,10 +83,12 @@ public class RiskManagement {
82
     /**
83
     /**
83
      * 创建时间
84
      * 创建时间
84
      */
85
      */
85
-    private String createTime;
86
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
87
+    private Date createTime;
86
 
88
 
87
     /**
89
     /**
88
      * 修改时间
90
      * 修改时间
89
      */
91
      */
90
-    private String modifyTime;
92
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
93
+    private Date modifyTime;
91
 }
94
 }

+ 5 - 1
src/main/java/com/chinaitop/depot/risk/model/ViolationWarningAlarm.java

@@ -1,10 +1,13 @@
1
 package com.chinaitop.depot.risk.model;
1
 package com.chinaitop.depot.risk.model;
2
 
2
 
3
+import com.fasterxml.jackson.annotation.JsonFormat;
3
 import lombok.AllArgsConstructor;
4
 import lombok.AllArgsConstructor;
4
 import lombok.Builder;
5
 import lombok.Builder;
5
 import lombok.Data;
6
 import lombok.Data;
6
 import lombok.NoArgsConstructor;
7
 import lombok.NoArgsConstructor;
7
 
8
 
9
+import java.util.Date;
10
+
8
 /**
11
 /**
9
  * 违规预警
12
  * 违规预警
10
  * @author aihua
13
  * @author aihua
@@ -22,7 +25,8 @@ public class ViolationWarningAlarm {
22
     /**
25
     /**
23
      * 违规发布时间
26
      * 违规发布时间
24
      */
27
      */
25
-    private String alarmPublishTime;
28
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
29
+    private Date alarmPublishTime;
26
     /**
30
     /**
27
      * 违规主题类型 当前默认是 单位
31
      * 违规主题类型 当前默认是 单位
28
      */
32
      */

+ 2 - 1
src/main/java/com/chinaitop/depot/risk/service/impl/ContentPreControlAndViolationWarningAlarmServiceImpl.java

@@ -7,6 +7,7 @@ import com.chinaitop.depot.risk.model.ViolationWarningAlarm;
7
 import com.chinaitop.depot.risk.request.ContentPreControlAndViolationWarningAlarmReq;
7
 import com.chinaitop.depot.risk.request.ContentPreControlAndViolationWarningAlarmReq;
8
 import com.chinaitop.depot.risk.service.ContentPreControlAndViolationWarningAlarmService;
8
 import com.chinaitop.depot.risk.service.ContentPreControlAndViolationWarningAlarmService;
9
 import com.chinaitop.depot.utils.DateUtil;
9
 import com.chinaitop.depot.utils.DateUtil;
10
+import com.chinaitop.depot.utils.ParameterUtil;
10
 import lombok.RequiredArgsConstructor;
11
 import lombok.RequiredArgsConstructor;
11
 import org.springframework.stereotype.Service;
12
 import org.springframework.stereotype.Service;
12
 
13
 
@@ -36,7 +37,7 @@ public class ContentPreControlAndViolationWarningAlarmServiceImpl implements Con
36
                 .createTime(DateUtil.getNow())
37
                 .createTime(DateUtil.getNow())
37
                 .build())).ifPresent(contentPreControlAlarmMapper::insert);
38
                 .build())).ifPresent(contentPreControlAlarmMapper::insert);
38
         Optional.ofNullable(alarmReq).flatMap(req -> Optional.ofNullable(req.getViolationWarningAlarm()).map(violationAlarm -> ViolationWarningAlarm.builder()
39
         Optional.ofNullable(alarmReq).flatMap(req -> Optional.ofNullable(req.getViolationWarningAlarm()).map(violationAlarm -> ViolationWarningAlarm.builder()
39
-                .alarmPublishTime(violationAlarm.getAlarmPublishTime())
40
+                .alarmPublishTime(ParameterUtil.string2datetime(violationAlarm.getAlarmPublishTime()))
40
                 .violationSubjectType("单位")
41
                 .violationSubjectType("单位")
41
                 .offender(violationAlarm.getOffender())
42
                 .offender(violationAlarm.getOffender())
42
                 .violationType(violationAlarm.getViolationType())
43
                 .violationType(violationAlarm.getViolationType())

+ 3 - 2
src/main/java/com/chinaitop/depot/risk/service/impl/RiskManagementServiceImpl.java

@@ -8,6 +8,7 @@ import lombok.RequiredArgsConstructor;
8
 import lombok.extern.slf4j.Slf4j;
8
 import lombok.extern.slf4j.Slf4j;
9
 import org.springframework.stereotype.Service;
9
 import org.springframework.stereotype.Service;
10
 
10
 
11
+import java.util.Date;
11
 import java.util.List;
12
 import java.util.List;
12
 import java.util.Map;
13
 import java.util.Map;
13
 
14
 
@@ -39,7 +40,7 @@ public class RiskManagementServiceImpl implements RiskManagementService {
39
      */
40
      */
40
     @Override
41
     @Override
41
     public void saveData(RiskManagement riskManagement) {
42
     public void saveData(RiskManagement riskManagement) {
42
-        riskManagement.setCreateTime(DateUtil.getNow());
43
+        riskManagement.setCreateTime(new Date());
43
         riskManagementMapper.insert(riskManagement);
44
         riskManagementMapper.insert(riskManagement);
44
     }
45
     }
45
 
46
 
@@ -49,7 +50,7 @@ public class RiskManagementServiceImpl implements RiskManagementService {
49
      */
50
      */
50
     @Override
51
     @Override
51
     public void updateDate(RiskManagement riskManagement) {
52
     public void updateDate(RiskManagement riskManagement) {
52
-        riskManagement.setModifyTime(DateUtil.getNow());
53
+        riskManagement.setModifyTime(new Date());
53
         riskManagementMapper.updateById(riskManagement);
54
         riskManagementMapper.updateById(riskManagement);
54
     }
55
     }
55
 
56