Browse Source

统计居民预警类别

dev_shibei_match
lzh 4 years ago
parent
commit
88e40e7069
  1. 46
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StatsResiWarnCountFormDTO.java
  2. 9
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StatsResiWarnController.java
  3. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcStatsResiWarnDao.java
  4. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/StatsResiWarnService.java
  5. 60
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java
  6. 22
      epmet-user/epmet-user-server/src/main/resources/mapper/IcStatsResiWarnDao.xml

46
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StatsResiWarnCountFormDTO.java

@ -0,0 +1,46 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

9
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();
}
}

2
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcStatsResiWarnDao.java

@ -46,4 +46,6 @@ public interface IcStatsResiWarnDao extends BaseDao<IcStatsResiWarnEntity> {
@Param("level")String level);
List<IcStatsResiWarnEntity> resiWarn(@Param("tableName") String tableName,@Param("columnName") String columnName);
IcStatsResiWarnEntity resiWarnById(@Param("tableName") String tableName,@Param("columnName") String columnName,@Param("icStatsResiWarn") IcStatsResiWarnEntity icStatsResiWarn);
}

2
epmet-user/epmet-user-server/src/main/java/com/epmet/service/StatsResiWarnService.java

@ -38,4 +38,6 @@ public interface StatsResiWarnService{
List<IcStatsResiResultDTO> list(String id, String level);
void resiWarn(String customerId);
void resiWarnByOne(String customerId,String userId);
}

60
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<IcStatsResiWarnBuildingResultDTO> buildingwWarnList(String agencyID) {
List<IcStatsResiWarnBuildingResultDTO> 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<List<IcResiCategoryWarnConfigDTO>> warnResult = operCustomizeOpenFeignClient.resiCategoryWarnList();
if (!warnResult.success() || null == warnResult.getData()) {
throw new RenException("预警配置查询失败:"+ warnResult.getMsg());
}
List<IcResiCategoryWarnConfigDTO> icResiCategoryWarnConfigDTOList = warnResult.getData();
IcResiUserEntity icResiUserEntity = icResiUserDao.selectById(userId);
if(null == icResiUserEntity){
return ;
}
//保存数据
for (IcResiCategoryWarnConfigDTO item : icResiCategoryWarnConfigDTOList) {
//查询这个用户信息
IcStatsResiWarnEntity icStatsResiWarn = icStatsResiWarnDao.selectOne(new QueryWrapper<IcStatsResiWarnEntity>().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);
}
}
}
}

22
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
</select>
<select id="resiWarnById" resultType="com.epmet.entity.IcStatsResiWarnEntity">
SELECT
AGENCY_ID as agencyId,
PIDS as agencyPids,
GRID_ID as gridId,
VILLAGE_ID as neighborHoodId,
BUILD_ID as buildingId,
count(*) as count
from ic_resi_user
where 1=1
<if test="tableName=='ic_resi_user'">
and ${columnName} = '1'
</if>
<if test="tableName!='ic_resi_user'">
and ID in (
select IC_RESI_USER from ${tableName} where ${columnName} = '1' and DEL_FLAG = '0'
)
</if>
and DEL_FLAG = '0'
and AGENCY_ID = #{icStatsResiWarn.agencyId} and GRID_ID =#{icStatsResiWarn.gridId} and VILLAGE_ID=#{icStatsResiWarn.neighborHoodId} and BUILD_ID=#{icStatsResiWarn.buildingId}
group by AGENCY_ID,GRID_ID,VILLAGE_ID,BUILD_ID
</select>
</mapper>
Loading…
Cancel
Save