测试用例活动单元
This commit is contained in:
parent
f0f7591ed3
commit
467edd7002
|
|
@ -0,0 +1,239 @@
|
|||
package com.dkl.large.controller;
|
||||
|
||||
import com.dkl.common.core.domain.AjaxResult;
|
||||
import com.dkl.common.core.page.TableDataInfo;
|
||||
import com.dkl.large.domain.DklActivity;
|
||||
import com.dkl.large.service.IDklActivityService;
|
||||
import com.koal.kms.sdk.ed.KmsSdkException;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* 大客流活动控制器单元测试
|
||||
*
|
||||
* @author Test
|
||||
* @date 2025-05-27
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class DklActivityControllerTest {
|
||||
|
||||
@Mock
|
||||
private IDklActivityService dklActivityService;
|
||||
|
||||
@InjectMocks
|
||||
private DklActivityController dklActivityController;
|
||||
|
||||
@Mock
|
||||
private Authentication authentication;
|
||||
|
||||
private DklActivity testActivity;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
// 初始化测试数据
|
||||
testActivity = new DklActivity();
|
||||
testActivity.setId(1);
|
||||
testActivity.setActivityName("测试活动");
|
||||
testActivity.setDelFlag("0");
|
||||
testActivity.setCreateTime(new Date());
|
||||
testActivity.setCreateBy("admin");
|
||||
testActivity.setDeptId(1L);
|
||||
|
||||
// 模拟SecurityContext(解决getUsername/getDeptId等方法权限问题)
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
when(authentication.getName()).thenReturn("admin");
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试查询活动列表接口
|
||||
*/
|
||||
@Test
|
||||
void testList() throws KmsSdkException {
|
||||
// 模拟数据
|
||||
List<DklActivity> activityList = new ArrayList<>();
|
||||
activityList.add(testActivity);
|
||||
when(dklActivityService.selectDklActivityList(any(DklActivity.class))).thenReturn(activityList);
|
||||
|
||||
// 执行测试
|
||||
TableDataInfo result = dklActivityController.list(testActivity);
|
||||
|
||||
// 断言结果
|
||||
assertNotNull(result);
|
||||
assertEquals(1, result.getRows().size());
|
||||
assertEquals(testActivity.getActivityName(), ((DklActivity) result.getRows().get(0)).getActivityName());
|
||||
verify(dklActivityService, times(1)).selectDklActivityList(any(DklActivity.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试查询所有未删除活动接口
|
||||
*/
|
||||
@Test
|
||||
void testListAll() throws KmsSdkException {
|
||||
// 模拟数据
|
||||
List<DklActivity> activityList = new ArrayList<>();
|
||||
activityList.add(testActivity);
|
||||
when(dklActivityService.selectDklActivityList(any(DklActivity.class))).thenReturn(activityList);
|
||||
|
||||
// 执行测试
|
||||
TableDataInfo result = dklActivityController.listAll(testActivity);
|
||||
|
||||
// 断言结果(验证delFlag被设置为0)
|
||||
assertNotNull(result);
|
||||
assertEquals("0", testActivity.getDelFlag());
|
||||
assertEquals(1, result.getRows().size());
|
||||
verify(dklActivityService, times(1)).selectDklActivityList(any(DklActivity.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试获取活动详情接口
|
||||
*/
|
||||
@Test
|
||||
void testGetInfo() throws KmsSdkException {
|
||||
// 模拟数据
|
||||
when(dklActivityService.selectDklActivityById(anyInt())).thenReturn(testActivity);
|
||||
|
||||
// 执行测试
|
||||
AjaxResult result = dklActivityController.getInfo(1);
|
||||
|
||||
// 断言结果
|
||||
assertTrue(result.isSuccess());
|
||||
assertEquals(testActivity.getId(), ((DklActivity) result.getData()).getId());
|
||||
verify(dklActivityService, times(1)).selectDklActivityById(anyInt());
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试新增活动接口(名称唯一)
|
||||
*/
|
||||
@Test
|
||||
void testAdd_Success() throws KmsSdkException {
|
||||
// 模拟数据
|
||||
when(dklActivityService.checkActivityNameUnique(any(DklActivity.class))).thenReturn(true);
|
||||
when(dklActivityService.insertDklActivity(any(DklActivity.class))).thenReturn(1);
|
||||
|
||||
// 执行测试
|
||||
AjaxResult result = dklActivityController.add(testActivity);
|
||||
|
||||
// 断言结果
|
||||
assertTrue(result.isSuccess());
|
||||
assertEquals(1, result.getData());
|
||||
verify(dklActivityService, times(1)).checkActivityNameUnique(any(DklActivity.class));
|
||||
verify(dklActivityService, times(1)).insertDklActivity(any(DklActivity.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试新增活动接口(名称重复)
|
||||
*/
|
||||
@Test
|
||||
void testAdd_Fail_NameDuplicate() throws KmsSdkException {
|
||||
// 模拟数据
|
||||
when(dklActivityService.checkActivityNameUnique(any(DklActivity.class))).thenReturn(false);
|
||||
|
||||
// 执行测试
|
||||
AjaxResult result = dklActivityController.add(testActivity);
|
||||
|
||||
// 断言结果
|
||||
assertFalse(result.isSuccess());
|
||||
assertEquals("新增大客流活动'测试活动'失败,名称已存在", result.getMsg());
|
||||
verify(dklActivityService, times(1)).checkActivityNameUnique(any(DklActivity.class));
|
||||
verify(dklActivityService, never()).insertDklActivity(any(DklActivity.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试修改活动接口(名称唯一)
|
||||
*/
|
||||
@Test
|
||||
void testEdit_Success() throws KmsSdkException {
|
||||
// 模拟数据
|
||||
when(dklActivityService.checkActivityNameUnique(any(DklActivity.class))).thenReturn(true);
|
||||
when(dklActivityService.updateDklActivity(any(DklActivity.class))).thenReturn(1);
|
||||
|
||||
// 执行测试
|
||||
AjaxResult result = dklActivityController.edit(testActivity);
|
||||
|
||||
// 断言结果
|
||||
assertTrue(result.isSuccess());
|
||||
assertEquals(1, result.getData());
|
||||
verify(dklActivityService, times(1)).checkActivityNameUnique(any(DklActivity.class));
|
||||
verify(dklActivityService, times(1)).updateDklActivity(any(DklActivity.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试删除活动接口
|
||||
*/
|
||||
@Test
|
||||
void testRemove() {
|
||||
// 模拟数据
|
||||
int[] ids = {1, 2};
|
||||
when(dklActivityService.deleteDklActivityByIds(any(int[].class))).thenReturn(2);
|
||||
|
||||
// 执行测试
|
||||
AjaxResult result = dklActivityController.remove(ids);
|
||||
|
||||
// 断言结果
|
||||
assertTrue(result.isSuccess());
|
||||
assertEquals(2, result.getData());
|
||||
verify(dklActivityService, times(1)).deleteDklActivityByIds(any(int[].class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试导入活动数据接口
|
||||
*/
|
||||
@Test
|
||||
void testImportData() throws Exception {
|
||||
// 模拟文件和数据
|
||||
MultipartFile mockFile = mock(MultipartFile.class);
|
||||
InputStream inputStream = new ByteArrayInputStream("test".getBytes());
|
||||
when(mockFile.getInputStream()).thenReturn(inputStream);
|
||||
|
||||
List<DklActivity> importList = new ArrayList<>();
|
||||
importList.add(testActivity);
|
||||
when(dklActivityService.importDate(anyList(), anyString())).thenReturn("导入成功,共导入1条数据");
|
||||
|
||||
// 执行测试
|
||||
AjaxResult result = dklActivityController.importData(mockFile);
|
||||
|
||||
// 断言结果
|
||||
assertTrue(result.isSuccess());
|
||||
assertEquals("导入成功,共导入1条数据", result.getData());
|
||||
verify(dklActivityService, times(1)).importDate(anyList(), anyString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试导出活动列表接口
|
||||
*/
|
||||
@Test
|
||||
void testExport() throws KmsSdkException {
|
||||
// 模拟数据
|
||||
List<DklActivity> activityList = new ArrayList<>();
|
||||
activityList.add(testActivity);
|
||||
when(dklActivityService.selectDklActivityList(any(DklActivity.class))).thenReturn(activityList);
|
||||
|
||||
HttpServletResponse response = new MockHttpServletResponse();
|
||||
|
||||
// 执行测试(无返回值,验证方法调用即可)
|
||||
dklActivityController.export(response, testActivity);
|
||||
|
||||
// 断言结果
|
||||
assertEquals("0", testActivity.getDelFlag());
|
||||
verify(dklActivityService, times(1)).selectDklActivityList(any(DklActivity.class));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
package com.dkl.large.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.dkl.common.annotation.Excel;
|
||||
import com.dkl.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 大客流活动表 dkl_activity
|
||||
*
|
||||
* @author Dkl
|
||||
* @date 2025-05-27
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class DklActivity extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** id */
|
||||
private int id;
|
||||
|
||||
/** 活动名称 */
|
||||
@Excel(name = "活动名称")
|
||||
private String activityName;
|
||||
|
||||
/** 节假日名称 */
|
||||
@Excel(name = "节假日名称")
|
||||
private String holidayName;
|
||||
|
||||
/** 地址 */
|
||||
@Excel(name = "地址")
|
||||
private String address;
|
||||
|
||||
/** 区域 */
|
||||
// @Excel(name = "区域")
|
||||
private String region;
|
||||
|
||||
/** 区域名称 */
|
||||
@Excel(name = "区域")
|
||||
@TableField(exist = false)
|
||||
private String regionname;
|
||||
/** 重点日标识 */
|
||||
@Excel(name = "重点日标识", readConverterExp = "Y=是,N=否")
|
||||
private String isKeyDay;
|
||||
|
||||
/** 开始时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date startTime;
|
||||
|
||||
/** 结束时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date endTime;
|
||||
|
||||
/** 值班人员 */
|
||||
@Excel(name = "值班人员")
|
||||
private String dutyPeople;
|
||||
|
||||
/** 值班联系方式 */
|
||||
@Excel(name = "值班联系方式")
|
||||
private String dutyPhone;
|
||||
|
||||
/** 经度 */
|
||||
@Excel(name = "经度")
|
||||
private String lng;
|
||||
|
||||
/** 纬度 */
|
||||
@Excel(name = "纬度")
|
||||
private String lat;
|
||||
|
||||
/** 删除状态 */
|
||||
// @Excel(name = "删除状态")
|
||||
private String delFlag;
|
||||
|
||||
/** 最大承载量 */
|
||||
@Excel(name = "最大承载量")
|
||||
private int loadBearingMax;
|
||||
|
||||
/** 最大承载量 */
|
||||
@Excel(name = "活动内容")
|
||||
private String activityText;
|
||||
|
||||
/** 部门id */
|
||||
// @Excel(name = "部门id")
|
||||
private Long deptId;
|
||||
|
||||
/** 占比 */
|
||||
@TableField(exist = false)
|
||||
private String capacityFactor;
|
||||
|
||||
/** 图标 */
|
||||
@TableField(exist = false)
|
||||
private String icon;
|
||||
|
||||
/** 人数 */
|
||||
@TableField(exist = false)
|
||||
private String numberPeople;
|
||||
|
||||
/** 筛选时间 */
|
||||
@TableField(exist = false)
|
||||
private String filterTime;
|
||||
|
||||
private String sigenCode;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,119 @@
|
|||
package com.dkl.large.mapper;
|
||||
|
||||
import com.dkl.large.domain.DklActivity;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 大客流活动Mapper接口
|
||||
*
|
||||
* @author Dkl
|
||||
* @date 2025-05-27
|
||||
*/
|
||||
public interface DklActivityMapper
|
||||
{
|
||||
/**
|
||||
* 查询大客流活动
|
||||
*
|
||||
* @param id 大客流活动主键
|
||||
* @return 大客流活动
|
||||
*/
|
||||
public DklActivity selectDklActivityById(int id);
|
||||
|
||||
/**
|
||||
* 查询大客流活动列表
|
||||
*
|
||||
* @param dklActivity 大客流活动
|
||||
* @return 大客流活动集合
|
||||
*/
|
||||
public List<DklActivity> selectDklActivityList(DklActivity dklActivity);
|
||||
|
||||
/**
|
||||
* 新增大客流活动
|
||||
*
|
||||
* @param dklActivity 大客流活动
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertDklActivity(DklActivity dklActivity);
|
||||
|
||||
/**
|
||||
* 修改大客流活动
|
||||
*
|
||||
* @param dklActivity 大客流活动
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDklActivity(DklActivity dklActivity);
|
||||
|
||||
/**
|
||||
* 删除大客流活动
|
||||
*
|
||||
* @param id 大客流活动主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDklActivityById(int id);
|
||||
|
||||
/**
|
||||
* 批量删除大客流活动
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDklActivityByIds(int[] ids);
|
||||
|
||||
/**
|
||||
* @Author :rq
|
||||
* @Description :大屏预警信息统计
|
||||
* @Date :2025/06/09 10:22
|
||||
* @Param :[]
|
||||
* @return :java.util.List<com.dkl.large.domain.DklActivity>
|
||||
**/
|
||||
public List<DklActivity> ativityEarlyWarning(DklActivity dklActivity);
|
||||
/**
|
||||
* @Author :rq
|
||||
* @Description :大屏重点场所热力图/景区热力图
|
||||
* @Date :2025/06/09 13:22
|
||||
* @Param :[]
|
||||
* @return :java.util.List<com.dkl.large.domain.DklActivity>
|
||||
**/
|
||||
public List<DklActivity> thermogramStatistics(DklActivity dklActivity);
|
||||
|
||||
/**
|
||||
* @Author :rq
|
||||
* @Description :大客流总数区域展示
|
||||
* @Date :2025/06/09 15:42
|
||||
* @Param :[dklActivity]
|
||||
* @return :java.util.List<com.dkl.large.domain.DklActivity>
|
||||
**/
|
||||
public List<DklActivity> regionalStatistics(DklActivity dklActivity);
|
||||
|
||||
|
||||
/***
|
||||
* @Author :rq
|
||||
* @Description :获取监测点数量
|
||||
* @Date :2025/06/13 11:00
|
||||
* @Param :[]
|
||||
* @return :int
|
||||
**/
|
||||
public String getActivityCount();
|
||||
|
||||
/**
|
||||
* @Author :rq
|
||||
* @Description :大客流活动统计首页
|
||||
* @Date :2025/07/11 10:42
|
||||
* @Param :[dklActivity]
|
||||
* @return :java.util.List<com.dkl.large.domain.DklActivity>
|
||||
**/
|
||||
public List<DklActivity> homeActivityStatistics(DklActivity dklActivity);
|
||||
/**
|
||||
* @Author :rq
|
||||
* @Description :大客流活动人数统计首页
|
||||
* @Date :2025/07/11 15:42
|
||||
* @Param :[dklActivity]
|
||||
* @return :java.util.List<com.dkl.large.domain.DklActivity>
|
||||
**/
|
||||
public List<DklActivity> homeActivityStatisticsPeople(DklActivity dklActivity);
|
||||
|
||||
public DklActivity checkActivityNameUnique(@Param("activityName") String activityName);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
package com.dkl.large.service;
|
||||
|
||||
import com.koal.kms.sdk.ed.KmsSdkException;
|
||||
import com.dkl.common.core.domain.entity.SysUser;
|
||||
import com.dkl.large.domain.DklActivity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 大客流活动Service接口
|
||||
*
|
||||
* @author Dkl
|
||||
* @date 2025-05-27
|
||||
*/
|
||||
public interface IDklActivityService
|
||||
{
|
||||
/**
|
||||
* 查询大客流活动
|
||||
*
|
||||
* @param id 大客流活动主键
|
||||
* @return 大客流活动
|
||||
*/
|
||||
public DklActivity selectDklActivityById(int id) throws KmsSdkException;
|
||||
|
||||
/**
|
||||
* 查询大客流活动列表
|
||||
*
|
||||
* @param dklActivity 大客流活动
|
||||
* @return 大客流活动集合
|
||||
*/
|
||||
public List<DklActivity> selectDklActivityList(DklActivity dklActivity) throws KmsSdkException;
|
||||
public String selectDklActivityListMessage(DklActivity dklActivity) throws KmsSdkException;
|
||||
/**
|
||||
* 新增大客流活动
|
||||
*
|
||||
* @param dklActivity 大客流活动
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertDklActivity(DklActivity dklActivity) throws KmsSdkException;
|
||||
|
||||
/**
|
||||
* 修改大客流活动
|
||||
*
|
||||
* @param dklActivity 大客流活动
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDklActivity(DklActivity dklActivity) throws KmsSdkException;
|
||||
|
||||
/**
|
||||
* 批量删除大客流活动
|
||||
*
|
||||
* @param ids 需要删除的大客流活动主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDklActivityByIds(int[] ids);
|
||||
|
||||
/**
|
||||
* 删除大客流活动信息
|
||||
*
|
||||
* @param id 大客流活动主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDklActivityById(int id);
|
||||
|
||||
/**
|
||||
* @Author :rq
|
||||
* @Description :大屏预警信息统计
|
||||
* @Date :2025/06/09 10:22
|
||||
* @Param :[]
|
||||
* @return :java.util.List<com.dkl.large.domain.DklActivity>
|
||||
**/
|
||||
List<DklActivity> ativityEarlyWarning(DklActivity dklActivity);
|
||||
/**
|
||||
* @Author :rq
|
||||
* @Description :大屏重点场所热力图/景区热力图
|
||||
* @Date :2025/06/09 13:22
|
||||
* @Param :[]
|
||||
* @return :java.util.List<com.dkl.large.domain.DklActivity>
|
||||
**/
|
||||
public List<DklActivity> thermogramStatistics(DklActivity dklActivity);
|
||||
|
||||
/**
|
||||
* @Author :rq
|
||||
* @Description :大客流活动统计首页
|
||||
* @Date :2025/07/11 10:42
|
||||
* @Param :[dklActivity]
|
||||
* @return :java.util.List<com.dkl.large.domain.DklActivity>
|
||||
**/
|
||||
public List<DklActivity> homeActivityStatistics(DklActivity dklActivity);
|
||||
/**
|
||||
* @Author :rq
|
||||
* @Description :大客流活动人数统计首页
|
||||
* @Date :2025/07/11 15:42
|
||||
* @Param :[dklActivity]
|
||||
* @return :java.util.List<com.dkl.large.domain.DklActivity>
|
||||
**/
|
||||
public List<DklActivity> homeActivityStatisticsPeople(DklActivity dklActivity);
|
||||
/**
|
||||
* 导入数据
|
||||
*
|
||||
* @param activityList 数据列表
|
||||
* @param operName 操作用户
|
||||
* @return 结果
|
||||
*/
|
||||
public String importDate(List<DklActivity> activityList,String operName) throws KmsSdkException;
|
||||
|
||||
|
||||
public boolean checkActivityNameUnique(DklActivity dklActivity);
|
||||
}
|
||||
|
|
@ -0,0 +1,486 @@
|
|||
package com.dkl.large.service.impl;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.koal.kms.sdk.ed.KmsSdkException;
|
||||
import com.dkl.common.annotation.DataScope;
|
||||
import com.dkl.common.constant.UserConstants;
|
||||
import com.dkl.common.core.domain.entity.SysDictData;
|
||||
import com.dkl.common.core.domain.entity.SysUser;
|
||||
import com.dkl.common.exception.ServiceException;
|
||||
import com.dkl.common.utils.DateUtils;
|
||||
import com.dkl.common.utils.SecurityUtils;
|
||||
import com.dkl.common.utils.StringUtils;
|
||||
import com.dkl.common.utils.bean.BeanValidators;
|
||||
import com.dkl.large.domain.DklActivity;
|
||||
import com.dkl.large.mapper.DklActivityMapper;
|
||||
import com.dkl.large.service.IDklActivityService;
|
||||
import com.dkl.large.utli.EnciphermentUtil;
|
||||
import com.dkl.system.mapper.SysDictDataMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import static com.dkl.common.utils.SecurityUtils.getDeptId;
|
||||
import static com.dkl.common.utils.SecurityUtils.getUsername;
|
||||
import static org.springframework.util.SerializationUtils.serialize;
|
||||
|
||||
/**
|
||||
* 大客流活动Service业务层处理
|
||||
*
|
||||
* @author Dkl
|
||||
* @date 2025-05-27
|
||||
*/
|
||||
@Service
|
||||
public class DklActivityServiceImpl implements IDklActivityService
|
||||
{
|
||||
@Autowired
|
||||
private DklActivityMapper dklActivityMapper;
|
||||
|
||||
@Autowired
|
||||
private SysDictDataMapper sysDictDataMapper;
|
||||
@Autowired
|
||||
static EnciphermentUtil enciphermentUtil;
|
||||
//手机号正则
|
||||
private static final String PHONE_REGEX = "^((0\\d{2,3}-\\d{7,8})|(1[3456789]\\d{9}))$";
|
||||
//经度
|
||||
private static final String LNG_REGEX = "^-?\\d{1,3}(\\.\\d+)?$";
|
||||
//维度
|
||||
private static final String LAT_REGEX = "^-?\\d{1,2}(\\.\\d+)?$";
|
||||
/**
|
||||
* 查询大客流活动
|
||||
*
|
||||
* @param id 大客流活动主键
|
||||
* @return 大客流活动
|
||||
*/
|
||||
@Override
|
||||
public DklActivity selectDklActivityById(int id) throws KmsSdkException {
|
||||
DklActivity dklActivityInfo =dklActivityMapper.selectDklActivityById(id);
|
||||
if (StringUtils.isNotEmpty(dklActivityInfo.getDutyPeople())&&StringUtils.isNotEmpty(dklActivityInfo.getDutyPhone())) {
|
||||
String dutyPeople = dklActivityInfo.getDutyPeople();
|
||||
String dutyPhone = dklActivityInfo.getDutyPhone();
|
||||
dklActivityInfo.setDutyPeople(EnciphermentUtil.kmsDencrypt(dutyPeople));
|
||||
dklActivityInfo.setDutyPhone(EnciphermentUtil.kmsDencrypt(dutyPhone));
|
||||
}
|
||||
return dklActivityInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询大客流活动列表
|
||||
*
|
||||
* @param dklActivity 大客流活动
|
||||
* @return 大客流活动
|
||||
*/
|
||||
@Override
|
||||
public List<DklActivity> selectDklActivityList(DklActivity dklActivity) throws KmsSdkException {
|
||||
List<DklActivity> list = dklActivityMapper.selectDklActivityList(dklActivity);
|
||||
for (DklActivity dklActivityInfo : list) {
|
||||
if (StringUtils.isNotEmpty(dklActivityInfo.getDutyPeople())&&("0").equals(dklActivityInfo.getDelFlag())) {
|
||||
String dutyPeople = dklActivityInfo.getDutyPeople();
|
||||
dklActivityInfo.setDutyPeople(EnciphermentUtil.kmsDencrypt(dutyPeople));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(dklActivityInfo.getDutyPhone())&&("0").equals(dklActivityInfo.getDelFlag())) {
|
||||
String dutyPhone = dklActivityInfo.getDutyPhone();
|
||||
dklActivityInfo.setDutyPhone(EnciphermentUtil.kmsDencrypt(dutyPhone));
|
||||
}
|
||||
// if (StringUtils.isNotEmpty(dklActivityInfo.getSigenCode())&&("0").equals(dklActivityInfo.getDelFlag())) {
|
||||
// byte[] bytes = serialize(dklActivityInfo.getDutyPeople()+","+dklActivityInfo.getDutyPhone());
|
||||
// boolean isor = EnciphermentUtil.verifySign(bytes,dklActivityInfo.getSigenCode());
|
||||
// if (isor) {
|
||||
// dklActivityList.add(dklActivityInfo);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String selectDklActivityListMessage(DklActivity dklActivity) throws KmsSdkException {
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
List<DklActivity> list = dklActivityMapper.selectDklActivityList(dklActivity);
|
||||
for (DklActivity dklActivityInfo : list) {
|
||||
if (StringUtils.isNotEmpty(dklActivityInfo.getDutyPeople())&&("0").equals(dklActivityInfo.getDelFlag())) {
|
||||
String dutyPeople = dklActivityInfo.getDutyPeople();
|
||||
dklActivityInfo.setDutyPeople(EnciphermentUtil.kmsDencrypt(dutyPeople));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(dklActivityInfo.getDutyPhone())&&("0").equals(dklActivityInfo.getDelFlag())) {
|
||||
String dutyPhone = dklActivityInfo.getDutyPhone();
|
||||
dklActivityInfo.setDutyPhone(EnciphermentUtil.kmsDencrypt(dutyPhone));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(dklActivityInfo.getSigenCode())&&("0").equals(dklActivityInfo.getDelFlag())) {
|
||||
byte[] bytes = serialize(dklActivityInfo.getDutyPeople()+","+dklActivityInfo.getDutyPhone());
|
||||
String isor = EnciphermentUtil.kmsSign(bytes);
|
||||
if (!isor.equals(dklActivityInfo.getSigenCode())) {
|
||||
successMsg.append("活动名称为"+dklActivityInfo.getActivityName()+"的数据被篡改");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return successMsg.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增大客流活动
|
||||
*
|
||||
* @param dklActivity 大客流活动
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertDklActivity(DklActivity dklActivity) throws KmsSdkException {
|
||||
|
||||
|
||||
String dutyPeople = dklActivity.getDutyPeople();
|
||||
String dutyPhone = dklActivity.getDutyPhone();
|
||||
dklActivity.setDutyPeople(EnciphermentUtil.kmsEncrypt(dutyPeople));
|
||||
dklActivity.setDutyPhone(EnciphermentUtil.kmsEncrypt(dutyPhone));
|
||||
// (序列化)
|
||||
byte[] bytes = serialize(dutyPeople+","+dutyPhone);
|
||||
String sigenCode = EnciphermentUtil.kmsSign(bytes);
|
||||
dklActivity.setSigenCode(sigenCode);
|
||||
return dklActivityMapper.insertDklActivity(dklActivity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改大客流活动
|
||||
*
|
||||
* @param dklActivity 大客流活动
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateDklActivity(DklActivity dklActivity) throws KmsSdkException {
|
||||
dklActivity.setUpdateTime(DateUtils.getNowDate());
|
||||
String dutyPeople = dklActivity.getDutyPeople();
|
||||
String dutyPhone = dklActivity.getDutyPhone();
|
||||
dklActivity.setDutyPeople(EnciphermentUtil.kmsEncrypt(dutyPeople));
|
||||
dklActivity.setDutyPhone(EnciphermentUtil.kmsEncrypt(dutyPhone));
|
||||
// (序列化)
|
||||
byte[] bytes = serialize(dutyPeople+","+dutyPhone);
|
||||
String sigenCode = EnciphermentUtil.kmsSign(bytes);
|
||||
dklActivity.setSigenCode(sigenCode);
|
||||
return dklActivityMapper.updateDklActivity(dklActivity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除大客流活动
|
||||
*
|
||||
* @param ids 需要删除的大客流活动主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDklActivityByIds(int[] ids)
|
||||
{
|
||||
return dklActivityMapper.deleteDklActivityByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除大客流活动信息
|
||||
*
|
||||
* @param id 大客流活动主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDklActivityById(int id)
|
||||
{
|
||||
return dklActivityMapper.deleteDklActivityById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author :rq
|
||||
* @Description :大屏预警信息统计
|
||||
* @Date :2025/06/09 10:22
|
||||
* @Param :[]
|
||||
* @return :java.util.List<com.dkl.large.domain.DklActivity>
|
||||
**/
|
||||
@Override
|
||||
public List<DklActivity> ativityEarlyWarning(DklActivity dklActivity) {
|
||||
return dklActivityMapper.ativityEarlyWarning(dklActivity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author :rq
|
||||
* @Description :大屏重点场所热力图/景区热力图
|
||||
* @Date :2025/06/09 13:22
|
||||
* @Param :[]
|
||||
* @return :java.util.List<com.dkl.large.domain.DklActivity>
|
||||
**/
|
||||
@Override
|
||||
public List<DklActivity> thermogramStatistics(DklActivity dklActivity) {
|
||||
return dklActivityMapper.thermogramStatistics(dklActivity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DklActivity> homeActivityStatistics(DklActivity dklActivity) {
|
||||
return dklActivityMapper.homeActivityStatistics(dklActivity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DklActivity> homeActivityStatisticsPeople(DklActivity dklActivity) {
|
||||
return dklActivityMapper.homeActivityStatisticsPeople(dklActivity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String importDate(List<DklActivity> activityList, String operName) throws KmsSdkException {
|
||||
//区域集合
|
||||
List<SysDictData> areaDict=sysDictDataMapper.selectDictDataByType("activity_area");
|
||||
//所有大客流活动
|
||||
DklActivity dklActivity = new DklActivity();
|
||||
dklActivity.setDelFlag("0");
|
||||
List<DklActivity> activitys= dklActivityMapper.selectDklActivityList(dklActivity);
|
||||
if (StringUtils.isNull(activityList) || activityList.size() == 0) {
|
||||
throw new ServiceException("导入数据不能为空!");
|
||||
}
|
||||
int successNum = 0;
|
||||
int failureNum = 0;
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder failureMsg = new StringBuilder();
|
||||
for (int i = 0; i < activityList.size(); i++) {
|
||||
try
|
||||
{
|
||||
//活动名称
|
||||
if (StringUtils.isEmpty(activityList.get(i).getActivityName())){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1) + "条数据活动名称为空");
|
||||
}else{
|
||||
if (activityList.get(i).getActivityName().length()>=30){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1) + "条数据活动名称长度过长");
|
||||
}
|
||||
}
|
||||
|
||||
//节假日名称
|
||||
if (StringUtils.isEmpty(activityList.get(i).getHolidayName())){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1) + "条数据节假日名称为空");
|
||||
}else{
|
||||
if (activityList.get(i).getHolidayName().length()>=30){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" +(i+1)+ "条数据节假日名称长度过长");
|
||||
}
|
||||
}
|
||||
|
||||
//地址
|
||||
if (StringUtils.isEmpty(activityList.get(i).getAddress())){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1)+ "条数据地址为空");
|
||||
}else{
|
||||
if (activityList.get(i).getAddress().length()>=30){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1) + "条数据地址长度过长");
|
||||
}
|
||||
}
|
||||
|
||||
//区域
|
||||
if (StringUtils.isEmpty(activityList.get(i).getRegionname())){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1)+ "条数据区域为空");
|
||||
}else{
|
||||
if (activityList.get(i).getRegionname().length()>=30){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" +(i+1) + "条数据区域长度过长");
|
||||
}else{
|
||||
for (SysDictData sysDictData : areaDict) {
|
||||
if (sysDictData.getDictLabel().equals(activityList.get(i).getRegionname())) {
|
||||
activityList.get(i).setRegion(sysDictData.getDictValue());
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if (StringUtils.isEmpty(activityList.get(i).getRegion())){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" +(i+1) + "条数据区域未找到");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//重点日标识
|
||||
if (StringUtils.isEmpty(activityList.get(i).getIsKeyDay())){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1) + "条数据重点日标识为空");
|
||||
}else{
|
||||
if (activityList.get(i).getIsKeyDay().length()>=30){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" +(i+1)+ "条数据重点日标识长度过长");
|
||||
}else{
|
||||
if (!("Y").equals(activityList.get(i).getIsKeyDay())&&!("N").equals(activityList.get(i).getIsKeyDay())) {
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1) + "条数据重点日标识有误");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//开始时间
|
||||
if (StringUtils.isEmpty(activityList.get(i).getStartTime().toString())){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1) + "条数据开始时间为空,时间应该为yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
|
||||
//结束时间
|
||||
if (StringUtils.isEmpty(activityList.get(i).getEndTime().toString())){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1) + "条数据结束时间为空,时间应该为yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
|
||||
//值班人员
|
||||
if (StringUtils.isEmpty(activityList.get(i).getDutyPeople())){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1) + "条数据值班人员为空");
|
||||
}else{
|
||||
if (activityList.get(i).getDutyPeople().length()>=30){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1) + "条数据值班人员长度过长");
|
||||
}
|
||||
}
|
||||
|
||||
//值班联系方式
|
||||
if (StringUtils.isEmpty(activityList.get(i).getDutyPhone())){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1) + "条数据值班联系方式为空");
|
||||
}else{
|
||||
if (activityList.get(i).getDutyPhone().length()>=30){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1) + "条数据值班联系方式长度过长");
|
||||
}else if (!Pattern.matches(PHONE_REGEX, activityList.get(i).getDutyPhone())){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1) + "条数据值班联系方式有误");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//经度
|
||||
if (StringUtils.isEmpty(activityList.get(i).getLng())){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1) + "条数据经度为空");
|
||||
}else{
|
||||
if (activityList.get(i).getLng().length()>=30){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1) + "条数据经度长度过长");
|
||||
}else if (!Pattern.matches(LNG_REGEX, activityList.get(i).getLng())){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1) + "条数据值经度有误");
|
||||
}
|
||||
}
|
||||
|
||||
//纬度
|
||||
if (StringUtils.isEmpty(activityList.get(i).getLat())){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1) + "条数据纬度为空");
|
||||
}else{
|
||||
if (activityList.get(i).getLat().length()>=30){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1) + "条数据纬度长度过长");
|
||||
}else if (!Pattern.matches(LAT_REGEX, activityList.get(i).getLat())){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1) + "条数据值纬度有误");
|
||||
}
|
||||
}
|
||||
|
||||
//纬度
|
||||
if (activityList.get(i).getLoadBearingMax()<=0){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1) + "条数据最大承载量为空");
|
||||
}else{
|
||||
if (activityList.get(i).getLoadBearingMax()>=999999999){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1) + "条数据最大承载量长度过长");
|
||||
}
|
||||
}
|
||||
|
||||
//活动内容
|
||||
if (StringUtils.isEmpty(activityList.get(i).getActivityText())){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" +(i+1) + "条数据活动内容为空");
|
||||
}else{
|
||||
if (activityList.get(i).getActivityText().length()>=30){
|
||||
failureNum++;
|
||||
failureMsg.append("<br/> 第" + (i+1)+ "条数据活动内容长度过长");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
failureNum++;
|
||||
String msg = "<br/>" + failureNum + "导入失败:";
|
||||
failureMsg.append(msg + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
if (failureNum > 0)
|
||||
{
|
||||
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||
throw new ServiceException(failureMsg.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
List<DklActivity> lists = Stream.of(activitys, activityList)
|
||||
.flatMap(Collection::stream)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
boolean hasDuplicates = lists.stream()
|
||||
.map(DklActivity::getActivityName)
|
||||
.distinct()
|
||||
.count() != lists.size();
|
||||
if(hasDuplicates){
|
||||
failureMsg.insert(0, "很抱歉,导入失败!共导入数据中有和系统原数据名称相同的数据");
|
||||
throw new ServiceException(failureMsg.toString());
|
||||
|
||||
}else{
|
||||
for (DklActivity activity :activityList){
|
||||
//添加系统信息
|
||||
activity.setDelFlag("0");
|
||||
activity.setCreateTime(new Date());
|
||||
activity.setCreateBy(getUsername());
|
||||
activity.setDeptId(getDeptId());
|
||||
activity.setUpdateTime(new Date());
|
||||
activity.setUpdateBy(getUsername());
|
||||
String dutyPeople = activity.getDutyPeople();
|
||||
String dutyPhone = activity.getDutyPhone();
|
||||
activity.setDutyPeople(EnciphermentUtil.kmsEncrypt(dutyPeople));
|
||||
activity.setDutyPhone(EnciphermentUtil.kmsEncrypt(dutyPhone));
|
||||
//
|
||||
// if (StringUtils.isNotEmpty(dklActivityInfo.getDutyPeople())&&("0").equals(dklActivityInfo.getDelFlag())) {
|
||||
// String dutyPeople = dklActivityInfo.getDutyPeople();
|
||||
// dklActivityInfo.setDutyPeople(EnciphermentUtil.kmsDencrypt(dutyPeople));
|
||||
// }
|
||||
// if (StringUtils.isNotEmpty(dklActivityInfo.getDutyPhone())&&("0").equals(dklActivityInfo.getDelFlag())) {
|
||||
// String dutyPhone = dklActivityInfo.getDutyPhone();
|
||||
// dklActivityInfo.setDutyPhone(EnciphermentUtil.kmsDencrypt(dutyPhone));
|
||||
// }
|
||||
// if (StringUtils.isNotEmpty(dklActivityInfo.getSigenCode())&&("0").equals(dklActivityInfo.getDelFlag())) {
|
||||
// byte[] bytes = serialize(dklActivityInfo.getDutyPeople()+","+dklActivityInfo.getDutyPhone());
|
||||
// String isor = EnciphermentUtil.kmsSign(bytes);
|
||||
// if (!isor.equals(dklActivityInfo.getSigenCode())) {
|
||||
// successMsg.append("活动名称为"+dklActivityInfo.getActivityName()+"的数据被篡改");
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// (序列化)
|
||||
byte[] bytes = serialize(dutyPeople+","+dutyPhone);
|
||||
String sigenCode = EnciphermentUtil.kmsSign(bytes);
|
||||
activity.setSigenCode(sigenCode);
|
||||
dklActivityMapper.insertDklActivity(activity);
|
||||
}
|
||||
successMsg.insert(0, "恭喜您,数据已全部导入成功!");
|
||||
}
|
||||
}
|
||||
|
||||
return successMsg.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkActivityNameUnique(DklActivity dklActivity) {
|
||||
Long activityId = StringUtils.isNull(dklActivity.getId()) ? -1L : dklActivity.getId();
|
||||
DklActivity info =dklActivityMapper.checkActivityNameUnique(dklActivity.getActivityName());
|
||||
if (StringUtils.isNotNull(info) && info.getId() != activityId)
|
||||
{
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,331 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.dkl.large.mapper.DklActivityMapper">
|
||||
|
||||
<resultMap type="DklActivity" id="DklActivityResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="activityName" column="activity_name" />
|
||||
<result property="holidayName" column="holiday_name" />
|
||||
<result property="address" column="address" />
|
||||
<result property="region" column="region" />
|
||||
<result property="isKeyDay" column="is_key_day" />
|
||||
<result property="startTime" column="start_time" />
|
||||
<result property="endTime" column="end_time" />
|
||||
<result property="dutyPeople" column="duty_people" />
|
||||
<result property="dutyPhone" column="duty_phone" />
|
||||
<result property="lng" column="lng" />
|
||||
<result property="lat" column="lat" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="loadBearingMax" column="load_bearing_max" />
|
||||
<result property="activityText" column="activity_text" />
|
||||
<result property="sigenCode" column="sigen_code" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectDklActivityVo">
|
||||
select da.id, da.activity_name, da.holiday_name, da.address, da.region, da.is_key_day, da.start_time, da.end_time,
|
||||
da.duty_people, da.duty_phone, da.lng, da.lat, da.create_by, da.create_time, da.update_by, da.update_time,
|
||||
da.del_flag,da.load_bearing_max,da.activity_text,sdd.dict_label as regionname,da.sigen_code from dkl_activity da
|
||||
left join sys_dept d on da.dept_id = d.dept_id
|
||||
LEFT JOIN sys_dict_data sdd ON sdd.dict_value = da.region
|
||||
AND sdd.dict_type = 'activity_area'
|
||||
</sql>
|
||||
|
||||
<select id="selectDklActivityList" parameterType="DklActivity" resultMap="DklActivityResult">
|
||||
<include refid="selectDklActivityVo"/>
|
||||
<where>
|
||||
<if test="activityName != null and activityName != ''"> and da.activity_name like concat('%', #{activityName}, '%')</if>
|
||||
<if test="holidayName != null and holidayName != ''"> and da.holiday_name like concat('%', #{holidayName}, '%')</if>
|
||||
<if test="address != null and address != ''"> and da.address = #{address}</if>
|
||||
<if test="region != null and region != ''"> and da.region = #{region}</if>
|
||||
<if test="isKeyDay != null and isKeyDay != ''"> and da.is_key_day = #{isKeyDay}</if>
|
||||
<if test="dutyPeople != null and dutyPeople != ''"> and da.duty_people = #{dutyPeople}</if>
|
||||
<if test="dutyPhone != null and dutyPhone != ''"> and da.duty_phone = #{dutyPhone}</if>
|
||||
<if test="lng != null and lng != ''"> and da.lng = #{lng}</if>
|
||||
<if test="lat != null and lat != ''"> and da.lat = #{lat}</if>
|
||||
<if test="delFlag != null and delFlag != ''"> and da.del_flag = #{delFlag}</if>
|
||||
<if test="deptId != null "> and da.dept_id = #{deptId}</if>
|
||||
<if test="loadBearingMax != null and loadBearingMax != ''"> and da.load_bearing_max = #{loadBearingMax}</if>
|
||||
<if test="activityText != null and activityText != ''"> and da.activity_text = #{activityText}</if>
|
||||
<if test="startTime != null and endTime != null ">
|
||||
AND da.start_time BETWEEN #{startTime} and #{endTime}
|
||||
</if>
|
||||
</where>
|
||||
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
order by da.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectDklActivityById" parameterType="int" resultMap="DklActivityResult">
|
||||
<include refid="selectDklActivityVo"/>
|
||||
where da.id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertDklActivity" parameterType="DklActivity" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into dkl_activity
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="activityName != null">activity_name,</if>
|
||||
<if test="holidayName != null">holiday_name,</if>
|
||||
<if test="address != null">address,</if>
|
||||
<if test="region != null">region,</if>
|
||||
<if test="isKeyDay != null">is_key_day,</if>
|
||||
<if test="startTime != null">start_time,</if>
|
||||
<if test="endTime != null">end_time,</if>
|
||||
<if test="dutyPeople != null">duty_people,</if>
|
||||
<if test="dutyPhone != null">duty_phone,</if>
|
||||
<if test="lng != null">lng,</if>
|
||||
<if test="lat != null">lat,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="loadBearingMax != null">load_bearing_max,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
<if test="activityText != null">activity_text,</if>
|
||||
<if test="sigenCode != null">sigen_code,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="activityName != null">#{activityName},</if>
|
||||
<if test="holidayName != null">#{holidayName},</if>
|
||||
<if test="address != null">#{address},</if>
|
||||
<if test="region != null">#{region},</if>
|
||||
<if test="isKeyDay != null">#{isKeyDay},</if>
|
||||
<if test="startTime != null">#{startTime},</if>
|
||||
<if test="endTime != null">#{endTime},</if>
|
||||
<if test="dutyPeople != null">#{dutyPeople},</if>
|
||||
<if test="dutyPhone != null">#{dutyPhone},</if>
|
||||
<if test="lng != null">#{lng},</if>
|
||||
<if test="lat != null">#{lat},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="loadBearingMax != null">#{loadBearingMax},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
<if test="activityText != null">#{activityText},</if>
|
||||
<if test="sigenCode != null">#{sigenCode},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateDklActivity" parameterType="DklActivity">
|
||||
update dkl_activity
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="activityName != null">activity_name = #{activityName},</if>
|
||||
<if test="holidayName != null">holiday_name = #{holidayName},</if>
|
||||
<if test="address != null">address = #{address},</if>
|
||||
<if test="region != null">region = #{region},</if>
|
||||
<if test="isKeyDay != null">is_key_day = #{isKeyDay},</if>
|
||||
<if test="startTime != null">start_time = #{startTime},</if>
|
||||
<if test="endTime != null">end_time = #{endTime},</if>
|
||||
<if test="dutyPeople != null">duty_people = #{dutyPeople},</if>
|
||||
<if test="dutyPhone != null">duty_phone = #{dutyPhone},</if>
|
||||
<if test="lng != null">lng = #{lng},</if>
|
||||
<if test="lat != null">lat = #{lat},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="loadBearingMax != null">load_bearing_max = #{loadBearingMax},</if>
|
||||
<if test="activityText != null">activity_text = #{activityText},</if>
|
||||
<if test="sigenCode != null">sigen_code = #{sigenCode},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteDklActivityById" parameterType="int">
|
||||
update dkl_activity set del_flag = 2 where id = #{id}
|
||||
</delete>
|
||||
|
||||
<update id="deleteDklActivityByIds" parameterType="int">
|
||||
update dkl_activity set del_flag = 2 where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
<!-- delete from dkl_activity where id in-->
|
||||
<!-- <foreach item="id" collection="array" open="(" separator="," close=")">-->
|
||||
<!-- #{id}-->
|
||||
<!-- </foreach>-->
|
||||
</update>
|
||||
|
||||
<select id="ativityEarlyWarning" parameterType="DklActivity" resultMap="DklActivityResult">
|
||||
SELECT
|
||||
da.ID,
|
||||
da.load_bearing_max ,
|
||||
da.activity_name,
|
||||
SUM ( T.numberPeople ) AS numberPeople,
|
||||
CAST ( SUM ( T.numberPeople ) / da.load_bearing_max AS DECIMAL ( 10, 3 ) )*100 AS capacityFactor,
|
||||
(
|
||||
SELECT
|
||||
icon
|
||||
FROM
|
||||
dkl_warning_threshold
|
||||
WHERE
|
||||
CAST ( SUM ( T.numberPeople ) / da.load_bearing_max AS DECIMAL ( 10, 3 ) ) >= max_capacity
|
||||
AND CAST ( SUM ( T.numberPeople ) / da.load_bearing_max AS DECIMAL ( 10, 3 ) ) <= min_capacity
|
||||
) as icon
|
||||
FROM
|
||||
dkl_activity AS da
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
dv.activity_id AS activityId,
|
||||
dvd.video_id AS videoId,
|
||||
SUM ( dvd.number_people ) AS numberPeople
|
||||
FROM
|
||||
dkl_video_data AS dvd
|
||||
LEFT JOIN dkl_video AS dv ON dv."id" = dvd.video_id
|
||||
AND dv.del_flag = '0'
|
||||
WHERE
|
||||
dvd.del_flag = '0'
|
||||
<if test="filterTime != null">
|
||||
AND dvd.acquisition_time >= DATE_TRUNC( 'day', #{filterTime} :: DATE )
|
||||
AND dvd.acquisition_time < DATE_TRUNC( 'day', #{filterTime} :: DATE + INTERVAL '1 day' )
|
||||
</if>
|
||||
GROUP BY
|
||||
dv.activity_id,
|
||||
dvd.video_id
|
||||
) AS T ON da.ID = T.activityId
|
||||
WHERE
|
||||
da.del_flag = '0'
|
||||
GROUP BY
|
||||
da.ID
|
||||
ORDER BY numberPeople
|
||||
</select>
|
||||
|
||||
|
||||
<select id="thermogramStatistics" parameterType="DklActivity" resultMap="DklActivityResult">
|
||||
SELECT
|
||||
da.ID,
|
||||
da.load_bearing_max ,
|
||||
da.activity_name ,
|
||||
da.lng,
|
||||
da.lat,
|
||||
SUM ( T.numberPeople ) AS numberPeople,
|
||||
CAST ( SUM ( T.numberPeople ) / da.load_bearing_max AS DECIMAL ( 10, 3 ) )*100 AS capacityFactor
|
||||
FROM
|
||||
dkl_activity AS da
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
dv.activity_id AS activityId,
|
||||
dvd.video_id AS videoId,
|
||||
SUM ( dvd.number_people ) AS numberPeople
|
||||
FROM
|
||||
dkl_video_data AS dvd
|
||||
LEFT JOIN dkl_video AS dv ON dv."id" = dvd.video_id
|
||||
AND dv.del_flag = '0'
|
||||
WHERE
|
||||
dvd.del_flag = '0'
|
||||
<if test="filterTime != null">
|
||||
AND dvd.acquisition_time >= DATE_TRUNC( 'day', #{filterTime} :: DATE )
|
||||
AND dvd.acquisition_time < DATE_TRUNC( 'day', #{filterTime} :: DATE + INTERVAL '1 day' )
|
||||
</if>
|
||||
GROUP BY
|
||||
dv.activity_id,
|
||||
dvd.video_id
|
||||
) AS T ON da.ID = T.activityId
|
||||
WHERE
|
||||
da.del_flag = '0'
|
||||
<if test="isKeyDay==1">
|
||||
AND da.is_key_day=#{isKeyDay}
|
||||
</if>
|
||||
GROUP BY
|
||||
da.ID
|
||||
ORDER BY numberPeople
|
||||
</select>
|
||||
|
||||
<select id="regionalStatistics" parameterType="DklActivity" resultMap="DklActivityResult">
|
||||
SELECT
|
||||
da.region,
|
||||
sdd.dict_label as regionname,
|
||||
SUM ( T.numberPeople ) AS numberPeople
|
||||
FROM
|
||||
dkl_activity AS da
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
dv.activity_id AS activityId,
|
||||
dvd.video_id AS videoId,
|
||||
SUM ( dvd.number_people ) AS numberPeople
|
||||
FROM
|
||||
dkl_video_data AS dvd
|
||||
LEFT JOIN dkl_video AS dv ON dv."id" = dvd.video_id
|
||||
AND dv.del_flag = '0'
|
||||
WHERE
|
||||
dvd.del_flag = '0'
|
||||
<if test="filterTime != null">
|
||||
AND dvd.acquisition_time >= DATE_TRUNC( 'day', #{filterTime} :: DATE )
|
||||
AND dvd.acquisition_time < DATE_TRUNC( 'day', #{filterTime} :: DATE + INTERVAL '1 day' )
|
||||
</if>
|
||||
GROUP BY
|
||||
dv.activity_id,
|
||||
dvd.video_id
|
||||
) AS T ON da.ID = T.activityId
|
||||
LEFT JOIN sys_dict_data sdd ON sdd.dict_value = da.region
|
||||
AND sdd.dict_type = 'activity_area'
|
||||
WHERE
|
||||
da.del_flag = '0'
|
||||
GROUP BY
|
||||
da.region,
|
||||
sdd.dict_label
|
||||
ORDER BY
|
||||
numberPeople
|
||||
|
||||
</select>
|
||||
|
||||
<select id="getActivityCount" parameterType="string">
|
||||
SELECT COUNT(*) FROM dkl_activity WHERE del_flag = '0'
|
||||
</select>
|
||||
|
||||
<select id="homeActivityStatistics" parameterType="DklActivity" resultMap="DklActivityResult" >
|
||||
SELECT
|
||||
da.region,
|
||||
count( da.region) AS numberPeople,
|
||||
sdd.dict_label AS regionname
|
||||
FROM
|
||||
dkl_activity AS da
|
||||
LEFT JOIN sys_dict_data sdd ON sdd.dict_value = da.region
|
||||
AND sdd.dict_type = 'activity_area'
|
||||
WHERE
|
||||
da.del_flag = '0'
|
||||
<if test="startTime != null and endTime != null ">
|
||||
AND da.start_time BETWEEN #{startTime} and #{endTime}
|
||||
</if>
|
||||
GROUP BY
|
||||
da.region,
|
||||
sdd.dict_label
|
||||
</select>
|
||||
|
||||
<select id="homeActivityStatisticsPeople" parameterType="DklActivity" resultMap="DklActivityResult" >
|
||||
SELECT
|
||||
da.region,
|
||||
sdd.dict_label as regionname,
|
||||
SUM ( da.load_bearing_max ) AS numberPeople
|
||||
FROM
|
||||
dkl_activity AS da
|
||||
LEFT JOIN sys_dict_data sdd ON sdd.dict_value = da.region
|
||||
AND sdd.dict_type = 'activity_area'
|
||||
WHERE
|
||||
da.del_flag = '0'
|
||||
<if test="startTime != null and endTime != null ">
|
||||
AND da.start_time BETWEEN #{startTime} and #{endTime}
|
||||
</if>
|
||||
|
||||
GROUP BY
|
||||
da.region,
|
||||
sdd.dict_label
|
||||
|
||||
</select>
|
||||
|
||||
<select id="checkActivityNameUnique" resultMap="DklActivityResult">
|
||||
<include refid="selectDklActivityVo"/>
|
||||
where da.activity_name=#{activityName} and da.del_flag = '0' limit 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Binary file not shown.
Loading…
Reference in New Issue