Browse Source

导入数据条数提示

数据日历接口
develop
lau572 2 months ago
parent
commit
ad887b7093
  1. 10
      zc-business/src/main/java/com/zc/business/controller/DcSdhsEventController.java
  2. 5
      zc-business/src/main/java/com/zc/business/mapper/DcSdhsEventMapper.java
  3. 2
      zc-business/src/main/java/com/zc/business/service/IDcSdhsEventService.java
  4. 37
      zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java
  5. 6
      zc-business/src/main/resources/mapper/business/DcSdhsEventMapper.xml

10
zc-business/src/main/java/com/zc/business/controller/DcSdhsEventController.java

@ -378,4 +378,14 @@ public class DcSdhsEventController extends BaseController {
return toAjax(dcSdhsEventService.deleteDcSdhsEventByIds(ids));
}
/**
* 查询数据日历
*/
@ApiOperation("查询数据日历")
@GetMapping("/getDataCalendar/{month}")
public AjaxResult getDataCalendar(@ApiParam(name = "month", value = "月份", required = true) @PathVariable("month") String month)
{
return dcSdhsEventService.getDataCalendar(month);
}
}

5
zc-business/src/main/java/com/zc/business/mapper/DcSdhsEventMapper.java

@ -71,7 +71,7 @@ public interface DcSdhsEventMapper
* @param
* @return 结果
*/
public boolean batchInsert(List<DcSdhsEvent> dcSdhsEventList);
public int batchInsert(List<DcSdhsEvent> dcSdhsEventList);
boolean deleteByTimeRange(@Param("startTime") String startTime,@Param("endTime") String endTime);
@ -81,4 +81,7 @@ public interface DcSdhsEventMapper
List<Map<String,Object>> selectAccidentType(@Param("type") String type,@Param("thisTime") String thisTime, @Param("lastTime") String lastTime);
List<String> getDataCalendar(@Param("month") String month);
}

2
zc-business/src/main/java/com/zc/business/service/IDcSdhsEventService.java

@ -154,4 +154,6 @@ public interface IDcSdhsEventService
* @return 结果
*/
int deleteDcSdhsEventById(Long id);
AjaxResult getDataCalendar(String month);
}

37
zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java

@ -92,24 +92,20 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService {
//根据开始事件验重,如果有时间重复的则本次不导入
List<Date> timeList = dcSdhsEventMapper.selectTimeList();
if (timeList != null && timeList.size() > 0 && importData != null && importData.size() > 0){
List<String> duplicateData = new ArrayList<>();
for (DcSdhsEvent importDatum : importData) {
if (timeList.contains(importDatum.getStartTime())){
duplicateData.add(df.format(importDatum.getStartTime()));
}
}
if (duplicateData.size() > 0){
return AjaxResult.error("本次导入含有重复数据",duplicateData);
}
}
//整理数据后批量插入数据库
List<String> duplicateData = new ArrayList<>();
List<DcSdhsEvent> eventList = new ArrayList<>();
if (importData != null && importData.size() > 0) {
for (DcSdhsEvent dcSdhsEvent : importData) {
if (timeList != null && timeList.size() > 0){
if (timeList.contains(dcSdhsEvent.getStartTime())){
duplicateData.add(df.format(dcSdhsEvent.getStartTime()));
continue;
}
}
//是否多车事故
String carNum = dcSdhsEvent.getCarNum();
if (StringUtils.isNotEmpty(carNum)) {
@ -170,9 +166,9 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService {
}
//保存至数据库
int successNum = 0;
if (eventList.size() > 0) {
dcSdhsEventMapper.batchInsert(eventList);
//redisCache.setCacheList(RedisKeyConstants.SDHS_EVENT, eventList);
successNum = dcSdhsEventMapper.batchInsert(eventList);
}
Map<String, Object> fileInfo = new HashMap<>();
@ -184,7 +180,12 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService {
fileInfo.put("uploadTime", updateTime);
redisCache.setCacheMapValue(RedisKeyConstants.SDHS_EVENT_FILE, now.getTime(), fileInfo);
return AjaxResult.success("导入成功");
Map<String,Object> result = new HashMap<>();
result.put("successNum",successNum);
result.put("errorNum",duplicateData.size());
return AjaxResult.success(result);
}
/**
@ -2232,4 +2233,10 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService {
{
return dcSdhsEventMapper.deleteDcSdhsEventById(id);
}
@Override
public AjaxResult getDataCalendar(String month){
List<String> list = dcSdhsEventMapper.getDataCalendar(month);
return AjaxResult.success(list);
}
}

6
zc-business/src/main/resources/mapper/business/DcSdhsEventMapper.xml

@ -171,6 +171,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
group by event_subclass) t3
on t1.event_subclass = t3.event_subclass
</select>
<select id="getDataCalendar" resultType="java.lang.String">
SELECT DATE_FORMAT(start_time,'%Y-%m-%d') dateTime
FROM `dc_sdhs_event`
where DATE_FORMAT(start_time,'%Y-%m') = #{month}
GROUP BY dateTime
</select>
<insert id="insertDcSdhsEvent" parameterType="DcSdhsEvent" useGeneratedKeys="true" keyProperty="id">
insert into dc_sdhs_event

Loading…
Cancel
Save