+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.dto.form;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.List;
+
+
+/**
+ * 预警统计表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2021-11-04
+ */
+@Data
+public class StatsResiWarnCountFormDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 组织id
+ */
+ @NotBlank(message = "用户id不能为空")
+ private String userId;
+
+
+}
\ No newline at end of file
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StatsResiWarnController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StatsResiWarnController.java
index 6a872d078d..510c434264 100644
--- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StatsResiWarnController.java
+++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StatsResiWarnController.java
@@ -23,6 +23,7 @@ import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.StatsResiListFormDTO;
+import com.epmet.dto.form.StatsResiWarnCountFormDTO;
import com.epmet.dto.form.StatsResiWarnFormDTO;
import com.epmet.dto.result.IcStatsResiResultDTO;
import com.epmet.dto.result.IcStatsResiWarnBuildingResultDTO;
@@ -83,7 +84,7 @@ public class StatsResiWarnController {
}
/**
- * 统计
+ * 统计所有
* @return
*/
@PostMapping("resiwarn")
@@ -91,5 +92,11 @@ public class StatsResiWarnController {
statsResiWarnService.resiWarn(tokenDto.getCustomerId());
return new Result();
}
+ @PostMapping("resiWarnByOne")
+ public Result resiWarnByOne(@LoginUser TokenDto tokenDto,@RequestBody StatsResiWarnCountFormDTO formDTO){
+ ValidatorUtils.validateEntity(formDTO);
+ statsResiWarnService.resiWarnByOne(tokenDto.getCustomerId(),formDTO.getUserId());
+ return new Result();
+ }
}
\ No newline at end of file
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcStatsResiWarnDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcStatsResiWarnDao.java
index 0cd26050a0..5eea1c2c44 100644
--- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcStatsResiWarnDao.java
+++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcStatsResiWarnDao.java
@@ -46,4 +46,6 @@ public interface IcStatsResiWarnDao extends BaseDao {
@Param("level")String level);
List resiWarn(@Param("tableName") String tableName,@Param("columnName") String columnName);
+ IcStatsResiWarnEntity resiWarnById(@Param("tableName") String tableName,@Param("columnName") String columnName,@Param("icStatsResiWarn") IcStatsResiWarnEntity icStatsResiWarn);
+
}
\ No newline at end of file
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StatsResiWarnService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StatsResiWarnService.java
index 5192e27981..4ef4b6722a 100644
--- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StatsResiWarnService.java
+++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StatsResiWarnService.java
@@ -38,4 +38,6 @@ public interface StatsResiWarnService{
List list(String id, String level);
void resiWarn(String customerId);
+
+ void resiWarnByOne(String customerId,String userId);
}
\ No newline at end of file
diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java
index 33d30a3212..8a8af94e2b 100644
--- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java
+++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
+import com.epmet.dao.IcResiUserDao;
import com.epmet.dao.IcStatsResiWarnDao;
import com.epmet.dto.IcResiCategoryStatsConfigDTO;
import com.epmet.dto.IcResiCategoryWarnConfigDTO;
@@ -12,6 +13,7 @@ import com.epmet.dto.result.BuildingResultDTO;
import com.epmet.dto.result.IcStatsResiResultDTO;
import com.epmet.dto.result.IcStatsResiWarnBuildingResultDTO;
import com.epmet.dto.result.IcStatsResiWarnUserResultDTO;
+import com.epmet.entity.IcResiUserEntity;
import com.epmet.entity.IcStatsResiWarnEntity;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.feign.OperCustomizeOpenFeignClient;
@@ -46,6 +48,9 @@ public class StatsResiWarnServiceImpl implements StatsResiWarnService {
@Autowired
private OperCustomizeOpenFeignClient operCustomizeOpenFeignClient;
+ @Resource
+ private IcResiUserDao icResiUserDao;
+
@Override
public List buildingwWarnList(String agencyID) {
List result = new ArrayList<>();
@@ -207,4 +212,59 @@ public class StatsResiWarnServiceImpl implements StatsResiWarnService {
icStatsResiWarnService.insertBatch(icStatsResiWarnEntities,500);
}
+
+ @Override
+ public void resiWarnByOne(String customerId, String userId) {
+ // 获取预警配置项
+ Result> warnResult = operCustomizeOpenFeignClient.resiCategoryWarnList();
+ if (!warnResult.success() || null == warnResult.getData()) {
+ throw new RenException("预警配置查询失败:"+ warnResult.getMsg());
+ }
+ List icResiCategoryWarnConfigDTOList = warnResult.getData();
+
+ IcResiUserEntity icResiUserEntity = icResiUserDao.selectById(userId);
+ if(null == icResiUserEntity){
+ return ;
+ }
+
+ //保存数据
+ for (IcResiCategoryWarnConfigDTO item : icResiCategoryWarnConfigDTOList) {
+ //查询这个用户信息
+
+ IcStatsResiWarnEntity icStatsResiWarn = icStatsResiWarnDao.selectOne(new QueryWrapper().lambda()
+ .eq(IcStatsResiWarnEntity::getConfigId,item.getId())
+ .eq(IcStatsResiWarnEntity::getAgencyId, icResiUserEntity.getAgencyId())
+ .eq(IcStatsResiWarnEntity::getGridId, icResiUserEntity.getGridId())
+ .eq(IcStatsResiWarnEntity::getNeighborHoodId, icResiUserEntity.getVillageId())
+ .eq(IcStatsResiWarnEntity::getBuildingId, icResiUserEntity.getBuildId()));
+
+ if(null == icStatsResiWarn){
+ //如果不存在,新增统计数量
+ icStatsResiWarn = new IcStatsResiWarnEntity();
+ icStatsResiWarn.setAgencyId(icResiUserEntity.getAgencyId());
+ icStatsResiWarn.setAgencyPids(icResiUserEntity.getPids());
+ icStatsResiWarn.setGridId(icResiUserEntity.getGridId());
+ icStatsResiWarn.setNeighborHoodId(icResiUserEntity.getVillageId());
+ icStatsResiWarn.setBuildingId(icResiUserEntity.getBuildId());
+ icStatsResiWarn.setConfigId(item.getId());
+ icStatsResiWarn.setCustomerId(customerId);
+ IcStatsResiWarnEntity resiWarnEntity = icStatsResiWarnDao.resiWarnById(item.getTableName(), item.getColumnName(),icStatsResiWarn);
+ if(null == resiWarnEntity){
+ continue;
+ }
+ icStatsResiWarn.setCount(resiWarnEntity.getCount());
+ icStatsResiWarnDao.insert(icStatsResiWarn);
+ }else{
+ //如果存在,更新统计数量
+ IcStatsResiWarnEntity resiWarnEntity = icStatsResiWarnDao.resiWarnById(item.getTableName(), item.getColumnName(),icStatsResiWarn);
+ icStatsResiWarn.setCount(resiWarnEntity.getCount());
+ icStatsResiWarn.setCustomerId(customerId);
+ icStatsResiWarnDao.updateById(icStatsResiWarn);
+ }
+
+
+ }
+ }
+
+
}
diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcStatsResiWarnDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcStatsResiWarnDao.xml
index 4416ac2f2e..79a5f7499b 100644
--- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcStatsResiWarnDao.xml
+++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcStatsResiWarnDao.xml
@@ -103,4 +103,26 @@
and DEL_FLAG = '0'
group by AGENCY_ID,GRID_ID,VILLAGE_ID,BUILD_ID
+
\ No newline at end of file