Browse Source

Merge branch 'develop' of http://git.elinkit.com.cn:7070/r/epmet-cloud into release_temp

dev
jianjun 4 years ago
parent
commit
6936af1596
  1. 102
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenProjectCategoryDTO.java
  2. 74
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/GridAndOrgCategoryCountResultDTO.java
  3. 6
      epmet-module/data-statistical/data-statistical-server/pom.xml
  4. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/ProjectConstant.java
  5. 33
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
  6. 12
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java
  7. 36
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectCategoryDao.java
  8. 28
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectDataDao.java
  9. 68
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenProjectCategoryEntity.java
  10. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java
  11. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java
  12. 34
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectCategoryGridAndOrgDailyService.java
  13. 105
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectCategoryService.java
  14. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectDataService.java
  15. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java
  16. 195
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryGridAndOrgDailyServiceImpl.java
  17. 119
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryServiceImpl.java
  18. 90
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java
  19. 36
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml
  20. 30
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectCategoryDao.xml
  21. 116
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectDataDao.xml
  22. 22
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java
  23. 16
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java
  24. 22
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java
  25. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java
  26. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java
  27. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java
  28. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java
  29. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java
  30. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/NeighborHoodService.java
  31. 19
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java
  32. 21
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java
  33. 28
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java
  34. 8
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml
  35. 4
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml
  36. 4
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml
  37. 2
      epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/CustomerFormResultDTO.java
  38. 2
      epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormGroupDTO.java
  39. 2
      epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormItemResult.java
  40. 2
      epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormItemResult2.java
  41. 2
      epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java
  42. 2
      epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java
  43. 6
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcFormController.java
  44. 8
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcFormDao.java
  45. 6
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/IcFormService.java
  46. 27
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormServiceImpl.java
  47. 8
      epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcFormDao.xml
  48. 46
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/StatsResiWarnCountFormDTO.java
  49. 205
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java
  50. 9
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StatsResiWarnController.java
  51. 4
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java
  52. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcStatsResiWarnDao.java
  53. 7
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java
  54. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/StatsResiWarnService.java
  55. 23
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java
  56. 19
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java
  57. 60
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsResiWarnServiceImpl.java
  58. 3
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsStaffPatrolRecordDailyServiceImpl.java
  59. 2
      epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml
  60. 22
      epmet-user/epmet-user-server/src/main/resources/mapper/IcStatsResiWarnDao.xml
  61. 6
      epmet-user/epmet-user-server/src/test/java/com/epmet/epmetuser/test/IcResiUserControllerTest.java

102
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenProjectCategoryDTO.java

@ -0,0 +1,102 @@
/**
* 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.screen;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 项目所属分类表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-11-10
*/
@Data
public class ScreenProjectCategoryDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private String id;
/**
* 客户id
*/
private String customerId;
/**
* 项目id
*/
private String projectId;
/**
* 分类编码
*/
private String categoryCode;
/**
* 所属父类分类编码
*/
private String parentCategoryCode;
/**
* 原始分类编码
*/
private String originCategoryCode;
/**
* 分类等级12....产品目前只有2级分类
*/
private Integer level;
/**
* 删除标识 0未删除1已删除
*/
private String delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

74
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/GridAndOrgCategoryCountResultDTO.java

@ -0,0 +1,74 @@
package com.epmet.dto.screen.result;
import com.epmet.commons.tools.constant.NumConstant;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2021/11/10 10:36 上午
* @DESC
*/
@Data
public class GridAndOrgCategoryCountResultDTO implements Serializable {
private static final long serialVersionUID = -5167964547464983118L;
/**
* 组织ID
*/
private String orgId;
/**
* 组织类型
*/
private String orgType;
/**
* 网格ID
*/
private String gridId;
/**
* 上级组织ID
*/
private String pid;
/**
* 所有上级组织ID
*/
private String pids;
private String dateId;
private String customerId;
/**
* 分类CODE
*/
private String categoryCode;
/**
* 分类CODE级别
*/
private Integer level;
/**
* 项目总数
*/
private Integer projectTotal;
/**
* 关闭结案项目总数
*/
private Integer closedProjectTotal;
public GridAndOrgCategoryCountResultDTO() {
this.orgId = "";
this.categoryCode = "";
this.level = NumConstant.ZERO;
this.projectTotal = NumConstant.ZERO;
this.closedProjectTotal = NumConstant.ZERO;
}
}

6
epmet-module/data-statistical/data-statistical-server/pom.xml

@ -142,6 +142,12 @@
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>oper-crm-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/ProjectConstant.java

@ -90,4 +90,7 @@ public interface ProjectConstant {
* 上报
*/
String PROJECT_REPORT="02";
String PROJECT_STATUS_CLOSED = "closed";
String PROJECT_STATUS_ALL = "all";
}

33
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java

@ -62,7 +62,6 @@ import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
@ -136,6 +135,8 @@ public class DemoController {
private FactGridMemberStatisticsDailyService factGridMemberStatisticsDailyService;
@Autowired
private DimCustomerService dimCustomerService;
@Autowired
private ScreenProjectDataService screenProjectDataService;
@GetMapping("testAlarm")
public void testAlarm() {
@ -1068,4 +1069,34 @@ public class DemoController {
customerAgencyService.sysAgencyInfo(formDTO.getFromCustomerId(), formDTO.getToCustomerId());
return new Result();
}
@PostMapping("extractCategory")
public Result extractCategory(@RequestBody StatsFormDTO formDTO) {
screenProjectDataService.extractCategory(formDTO.getCustomerId());
return new Result();
}
@Autowired
private ScreenProjectCategoryGridAndOrgDailyService screenProjectCategoryGridAndOrgDailyService;
@PostMapping("gridandorgdailynew")
public Result<String> gridAndDaily(@RequestParam("customerId")String customerId,@RequestParam("dateId")String dateId,
@RequestParam(name = "startDate",required = false)String startDate,
@RequestParam(name = "endDate",required = false)String endDate
){
long start = System.currentTimeMillis();
if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)){
List<String> daysBetween = DateUtils.getDaysBetween(startDate, endDate);
daysBetween.forEach(d -> {
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,d);
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,d);
});
}else {
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,dateId);
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,dateId);
}
long end = System.currentTimeMillis();
long l = (end - start) / 1000;
return new Result<String>().ok("gridAndOrgDaily耗时" + l+ "s");
}
}

12
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java

@ -28,6 +28,7 @@ import com.epmet.dto.extract.result.OrgNameResultDTO;
import com.epmet.dto.indexcal.AgencyAndParentResultDTO;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
import com.epmet.dto.screen.ScreenProjectOrgDailyDTO;
import com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO;
import com.epmet.dto.screen.result.TreeResultDTO;
import com.epmet.dto.screencoll.form.CustomerAgencyFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity;
@ -244,4 +245,15 @@ public interface ScreenCustomerAgencyDao extends BaseDao<ScreenCustomerAgencyEnt
*/
List<CustomerAgencyDTO> selectByCustomerId(@Param("customerId") String customerId);
/**
* @Description 查询父子客户的组织平阴
* @param customerIds 平阴榆山锦水的客户ID
* @param customerId 孔村的客户ID🤬
* @author zxc
* @date 2021/11/10 2:52 下午
*/
List<GridAndOrgCategoryCountResultDTO> selectParentSonAgency(@Param("customerIds") List<String> customerIds ,@Param("customerId") String customerId);
String getParentAgencyId(@Param("agencyId") String agencyId);
}

36
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectCategoryDao.java

@ -0,0 +1,36 @@
/**
* 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.dao.evaluationindex.screen;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 项目所属分类表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-11-10
*/
@Mapper
public interface ScreenProjectCategoryDao extends BaseDao<ScreenProjectCategoryEntity> {
void deleteByProjectIds(@Param("customerId") String customerId, @Param("projectIds") List<String> projectIds);
}

28
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectDataDao.java

@ -19,6 +19,7 @@ package com.epmet.dao.evaluationindex.screen;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.screen.ScreenProjectDataDTO;
import com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO;
import com.epmet.entity.evaluationindex.screen.ScreenProjectDataEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -68,4 +69,31 @@ public interface ScreenProjectDataDao extends BaseDao<ScreenProjectDataEntity> {
int updateProjectSatisfactionScore(@Param("projectId")String projectId, @Param("score")BigDecimal score);
List<ScreenProjectDataDTO> selectProjectList(@Param("customerId") String customerId, @Param("projectId") String projectId);
/**
* @Description 查询网格下的项目分类
* @param customerIds 父子客户的customerId
* @param dateId 日期ID
* @param status 所有项目all已结案项目closed
* @param customerId 父级客户ID
* @param subCount 分类截取位数
* @author zxc
* @date 2021/11/10 3:12 下午
*/
List<GridAndOrgCategoryCountResultDTO> selectGridCategoryProjectCount(@Param("customerIds") List<String> customerIds,@Param("dateId") String dateId,
@Param("status")String status,@Param("customerId") String customerId,
@Param("subCount")Integer subCount);
/**
* @Description 查询组织下的项目分类
* @param dateId 日期ID
* @param status 所有项目all已结案项目closed
* @param customerId 父级客户ID
* @param subCount 分类截取位数
* @author zxc
* @date 2021/11/10 3:14 下午
*/
List<GridAndOrgCategoryCountResultDTO> selectOrgCategoryProjectCount(@Param("dateId") String dateId, @Param("status")String status,
@Param("customerId") String customerId, @Param("subCount")Integer subCount,
@Param("allAgencies") List<GridAndOrgCategoryCountResultDTO> allAgencies);
}

68
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenProjectCategoryEntity.java

@ -0,0 +1,68 @@
/**
* 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.entity.evaluationindex.screen;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 项目所属分类表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-11-10
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("screen_project_category")
public class ScreenProjectCategoryEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户id
*/
private String customerId;
/**
* 项目id
*/
private String projectId;
/**
* 分类编码
*/
private String categoryCode;
/**
* 所属父类分类编码
*/
private String parentCategoryCode;
/**
* 原始分类编码
*/
private String originCategoryCode;
/**
* 分类等级12....产品目前只有2级分类
*/
private Integer level;
}

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java

@ -84,6 +84,8 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
private FactAgencyGovernDailyService factAgencyGovernDailyService;
@Autowired
private FactGridMemberStatisticsDailyService factGridMemberStatisticsDailyService;
@Autowired
private ScreenProjectCategoryGridAndOrgDailyService screenProjectCategoryGridAndOrgDailyService;
/**
* @param extractOriginFormDTO
@ -243,14 +245,14 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
//按天统计:网格内各个分类下的项目总数
try {
projectCategoryGridDailyService.extractProjectCategoryData(customerId, dateId);
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId, dateId);
} catch (Exception e) {
log.error("按天统计:网格内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e);
}
// 按天统计:组织内各个分类下的项目总数
try {
projectCategoryOrgDailyService.extractProjectCategoryOrgData(customerId, dateId);
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId, dateId);
} catch (Exception e) {
log.error("按天统计:组织内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e);
}

9
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java

@ -155,4 +155,13 @@ public interface ScreenCustomerAgencyService extends BaseService<ScreenCustomerA
*/
Map<String, ScreenCustomerAgencyEntity> getAgencyList(String customerId);
/**
* @Description 获取父级组织ID外部客户
* @Param agencyId
* @Return {@link String}
* @Author zhaoqifeng
* @Date 2021/11/10 17:00
*/
String getParentAgencyId(String agencyId);
}

34
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectCategoryGridAndOrgDailyService.java

@ -0,0 +1,34 @@
package com.epmet.service.evaluationindex.screen;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.screen.ScreenProjectCategoryOrgDailyDTO;
import com.epmet.dto.screencoll.ScreenCollFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryOrgDailyEntity;
import java.util.List;
import java.util.Map;
/**
* 项目(事件)分类按 网格组织按天统计
*/
public interface ScreenProjectCategoryGridAndOrgDailyService {
/**
* @Description 分类下的项目数grid
* @param customerId
* @param dateId
* @author zxc
* @date 2021/11/10 10:23 上午
*/
void extractCategoryProjectGridData(String customerId, String dateId);
/**
* @Description 分类下的项目数org
* @param customerId
* @param dateId
* @author zxc
* @date 2021/11/10 10:23 上午
*/
void extractCategoryProjectOrgData(String customerId, String dateId);
}

105
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectCategoryService.java

@ -0,0 +1,105 @@
/**
* 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.service.evaluationindex.screen;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.screen.ScreenProjectCategoryDTO;
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryEntity;
import java.util.List;
import java.util.Map;
/**
* 项目所属分类表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-11-10
*/
public interface ScreenProjectCategoryService extends BaseService<ScreenProjectCategoryEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<ScreenProjectCategoryDTO>
* @author generator
* @date 2021-11-10
*/
PageData<ScreenProjectCategoryDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<ScreenProjectCategoryDTO>
* @author generator
* @date 2021-11-10
*/
List<ScreenProjectCategoryDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return ScreenProjectCategoryDTO
* @author generator
* @date 2021-11-10
*/
ScreenProjectCategoryDTO get(String id);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2021-11-10
*/
void save(ScreenProjectCategoryDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author generator
* @date 2021-11-10
*/
void update(ScreenProjectCategoryDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author generator
* @date 2021-11-10
*/
void delete(String[] ids);
/**
* 删除项目分类
* @Param customerId
* @Param projectIds
* @Return
* @Author zhaoqifeng
* @Date 2021/11/10 11:06
*/
void deleteByProjectId(String customerId, List<String> projectIds);
}

9
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectDataService.java

@ -148,4 +148,13 @@ public interface ScreenProjectDataService extends BaseService<ScreenProjectDataE
*/
void sendProjectChangeMq(DisputeProcessMQMsg msg);
/**
* @Description 提取项目分类
* @Param customerId
* @Return
* @Author zhaoqifeng
* @Date 2021/11/10 10:24
*/
void extractCategory(String customerId);
}

13
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java

@ -342,4 +342,17 @@ public class ScreenCustomerAgencyServiceImpl extends BaseServiceImpl<ScreenCusto
return list.stream().collect(Collectors.toMap(ScreenCustomerAgencyEntity::getAgencyId, Function.identity()));
}
/**
* @param agencyId
* @Description 获取父级组织ID外部客户
* @Param agencyId
* @Return {@link String}
* @Author zhaoqifeng
* @Date 2021/11/10 17:00
*/
@Override
public String getParentAgencyId(String agencyId) {
return baseDao.getParentAgencyId(agencyId);
}
}

195
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryGridAndOrgDailyServiceImpl.java

@ -0,0 +1,195 @@
package com.epmet.service.evaluationindex.screen.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.PingYinConstant;
import com.epmet.constant.ProjectConstant;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao;
import com.epmet.dao.evaluationindex.screen.ScreenProjectCategoryGridDailyDao;
import com.epmet.dao.evaluationindex.screen.ScreenProjectCategoryOrgDailyDao;
import com.epmet.dao.evaluationindex.screen.ScreenProjectDataDao;
import com.epmet.dto.screen.ScreenProjectOrgDailyDTO;
import com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO;
import com.epmet.entity.crm.CustomerRelationEntity;
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryGridDailyEntity;
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryOrgDailyEntity;
import com.epmet.service.crm.CustomerRelationService;
import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryGridAndOrgDailyService;
import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryGridDailyService;
import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryOrgDailyService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author zxc
* @DateTime 2021/11/10 10:25 上午
* @DESC
*/
@Service
@DataSource(DataSourceConstant.EVALUATION_INDEX)
@Slf4j
public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenProjectCategoryGridAndOrgDailyService{
@Autowired
private ScreenProjectDataDao screenProjectDataDao;
@Autowired
private CustomerRelationService relationService;
@Autowired
private ScreenProjectCategoryGridDailyDao gridDailyDao;
@Autowired
private ScreenProjectCategoryGridDailyService gridDailyService;
@Autowired
private ScreenProjectCategoryOrgDailyService orgDailyService;
@Autowired
private ScreenProjectCategoryOrgDailyDao orgDailyDao;
@Autowired
private ScreenCustomerAgencyDao screenCustomerAgencyDao;
/**
* @Description 分类下的项目数grid
* @param customerId
* @param dateId
* @author zxc
* @date 2021/11/10 10:23 上午
*/
@Override
public void extractCategoryProjectGridData(String customerId, String dateId) {
List<CustomerRelationEntity> relationInfo = relationService.selectSubCustomer(customerId);
List<String> customerIds = new ArrayList<>();
customerIds.add(customerId);
List<GridAndOrgCategoryCountResultDTO> allList = new ArrayList<>();
List<GridAndOrgCategoryCountResultDTO> closedList = new ArrayList<>();
if (CollectionUtils.isEmpty(relationInfo)){
// 单客户
allList = screenProjectDataDao.selectGridCategoryProjectCount(customerIds, dateId, ProjectConstant.PROJECT_STATUS_ALL,customerId, NumConstant.FOUR);
closedList = screenProjectDataDao.selectGridCategoryProjectCount(customerIds, dateId, ProjectConstant.PROJECT_STATUS_CLOSED,customerId, NumConstant.FOUR);
}else {
// 多客户
List<String> subCustomerIds = relationInfo.stream().map(CustomerRelationEntity::getCustomerId).collect(Collectors.toList());
customerIds.addAll(subCustomerIds);
allList = screenProjectDataDao.selectGridCategoryProjectCount(customerIds, dateId, ProjectConstant.PROJECT_STATUS_ALL,customerId, NumConstant.TWO);
closedList = screenProjectDataDao.selectGridCategoryProjectCount(customerIds, dateId, ProjectConstant.PROJECT_STATUS_CLOSED,customerId, NumConstant.TWO);
}
List<GridAndOrgCategoryCountResultDTO> finalClosedList = closedList;
allList.forEach(a -> finalClosedList.stream().filter(c -> c.getGridId().equals(a.getGridId()) && c.getCategoryCode().equals(a.getCategoryCode())).forEach(c -> a.setClosedProjectTotal(c.getClosedProjectTotal())));
gridDel(customerId,dateId);
gridInsert(allList);
}
/**
* @Description 项目分类网格删除
* @param customerId
* @param dateId
* @author zxc
* @date 2021/11/10 1:55 下午
*/
@Transactional(rollbackFor = Exception.class)
public void gridDel(String customerId,String dateId){
Integer num = NumConstant.ZERO;
do {
num = gridDailyDao.deleteByDateIdAndCustomerId(customerId, dateId);
}while (num > NumConstant.ZERO && num == NumConstant.ONE_THOUSAND);
}
/**
* @Description 项目分类网格添加
* @param needInsert
* @author zxc
* @date 2021/11/10 1:55 下午
*/
@Transactional(rollbackFor = Exception.class)
public void gridInsert(List<GridAndOrgCategoryCountResultDTO> needInsert){
List<List<GridAndOrgCategoryCountResultDTO>> partition = ListUtils.partition(needInsert, NumConstant.ONE_HUNDRED);
partition.forEach(p -> {
gridDailyService.insertBatch(ConvertUtils.sourceToTarget(p,ScreenProjectCategoryGridDailyEntity.class));
log.info("插入的网格项目分类为" + JSON.toJSONString(p));
});
}
/**
* @Description 分类下的项目数org
* 项目分类来源
* 本级直接立项 + 下级 + 直属网格
* @param customerId
* @param dateId
* @author zxc
* @date 2021/11/10 10:23 上午
*/
@Override
public void extractCategoryProjectOrgData(String customerId, String dateId) {
List<CustomerRelationEntity> relationInfo = relationService.selectSubCustomer(customerId);
List<String> customerIds = new ArrayList<>();
customerIds.add(customerId);
List<GridAndOrgCategoryCountResultDTO> result = new ArrayList<>();
if (CollectionUtils.isEmpty(relationInfo)){
// one customer
List<ScreenProjectOrgDailyDTO> agencies = screenCustomerAgencyDao.selectAgencyByCustomer(customerId);
List<GridAndOrgCategoryCountResultDTO> allAgencies = ConvertUtils.sourceToTarget(agencies, GridAndOrgCategoryCountResultDTO.class);
result = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.FOUR, allAgencies);
List<GridAndOrgCategoryCountResultDTO> closedList = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.FOUR, allAgencies);
result.forEach(r -> closedList.stream().filter(c -> r.getOrgId().equals(c.getOrgId()) && r.getCategoryCode().equals(c.getCategoryCode())).forEach(c -> r.setClosedProjectTotal(c.getClosedProjectTotal())));
}else {
// more customers
// 去除孔村的客户ID,孔村镇的单独查😡
List<String> subCustomerIds = relationInfo.stream().map(CustomerRelationEntity::getCustomerId).collect(Collectors.toList());
for (int i = NumConstant.ZERO; i < subCustomerIds.size(); i++) {
if (subCustomerIds.get(i).equals(PingYinConstant.KONG_CUN_CUSTOMER_ID)){
customerIds.remove(i);
continue;
}
}
List<GridAndOrgCategoryCountResultDTO> allAgencies = screenCustomerAgencyDao.selectParentSonAgency(subCustomerIds, PingYinConstant.KONG_CUN_CUSTOMER_ID);
List<List<GridAndOrgCategoryCountResultDTO>> partition = ListUtils.partition(allAgencies, NumConstant.FIFTY);
List<GridAndOrgCategoryCountResultDTO> allOrgCategoryList = result;
partition.forEach(p -> {
List<GridAndOrgCategoryCountResultDTO> allOrgList = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.TWO, p);
List<GridAndOrgCategoryCountResultDTO> closedOrgList = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.TWO, p);
allOrgList.forEach(a -> closedOrgList.stream().filter(c -> a.getOrgId().equals(c.getOrgId()) && a.getCategoryCode().equals(c.getCategoryCode())).forEach(c -> a.setClosedProjectTotal(c.getClosedProjectTotal())));
allOrgCategoryList.addAll(allOrgList);
});
}
orgDel(customerId,dateId);
orgInsert(result);
}
/**
* @Description 项目分类组织删除
* @param customerId
* @param dateId
* @author zxc
* @date 2021/11/10 4:58 下午
*/
@Transactional(rollbackFor = Exception.class)
public void orgDel(String customerId,String dateId){
Integer num = NumConstant.ZERO;
do {
num = orgDailyDao.deleteByDateIdAndCustomerId(customerId, dateId);
}while (num > NumConstant.ZERO && num == NumConstant.ONE_THOUSAND);
}
/**
* @Description 项目分类组织插入
* @param needInsert
* @author zxc
* @date 2021/11/10 5:03 下午
*/
@Transactional(rollbackFor = Exception.class)
public void orgInsert(List<GridAndOrgCategoryCountResultDTO> needInsert){
List<List<GridAndOrgCategoryCountResultDTO>> partition = ListUtils.partition(needInsert, NumConstant.ONE_HUNDRED);
partition.forEach(p -> {
orgDailyService.insertBatch(ConvertUtils.sourceToTarget(p, ScreenProjectCategoryOrgDailyEntity.class));
log.info("插入的组织项目分类为" + JSON.toJSONString(p));
});
}
}

119
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryServiceImpl.java

@ -0,0 +1,119 @@
/**
* 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.service.evaluationindex.screen.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.dao.evaluationindex.screen.ScreenProjectCategoryDao;
import com.epmet.dto.screen.ScreenProjectCategoryDTO;
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryEntity;
import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 项目所属分类表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-11-10
*/
@Service
public class ScreenProjectCategoryServiceImpl extends BaseServiceImpl<ScreenProjectCategoryDao, ScreenProjectCategoryEntity> implements ScreenProjectCategoryService {
@Override
public PageData<ScreenProjectCategoryDTO> page(Map<String, Object> params) {
IPage<ScreenProjectCategoryEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, ScreenProjectCategoryDTO.class);
}
@Override
public List<ScreenProjectCategoryDTO> list(Map<String, Object> params) {
List<ScreenProjectCategoryEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, ScreenProjectCategoryDTO.class);
}
private QueryWrapper<ScreenProjectCategoryEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<ScreenProjectCategoryEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public ScreenProjectCategoryDTO get(String id) {
ScreenProjectCategoryEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, ScreenProjectCategoryDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(ScreenProjectCategoryDTO dto) {
ScreenProjectCategoryEntity entity = ConvertUtils.sourceToTarget(dto, ScreenProjectCategoryEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(ScreenProjectCategoryDTO dto) {
ScreenProjectCategoryEntity entity = ConvertUtils.sourceToTarget(dto, ScreenProjectCategoryEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
/**
* 删除项目分类
*
* @param customerId
* @param projectIds
* @Param customerId
* @Param projectIds
* @Return
* @Author zhaoqifeng
* @Date 2021/11/10 11:06
*/
@Override
public void deleteByProjectId(String customerId, List<String> projectIds) {
if (CollectionUtils.isEmpty(projectIds)) {
return;
}
baseDao.deleteByProjectIds(customerId, projectIds);
}
}

90
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java

@ -17,6 +17,7 @@
package com.epmet.service.evaluationindex.screen.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
@ -24,19 +25,27 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.rocketmq.messages.DisputeProcessMQMsg;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.DataSourceConstant;
import com.epmet.dao.evaluationindex.screen.ScreenProjectDataDao;
import com.epmet.dao.evaluationindex.screen.ScreenProjectImgDataDao;
import com.epmet.dto.screen.ScreenProjectDataDTO;
import com.epmet.dto.screen.form.ScreenProjectDataInfoFormDTO;
import com.epmet.dto.screencoll.ScreenCollFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryEntity;
import com.epmet.entity.evaluationindex.screen.ScreenProjectDataEntity;
import com.epmet.entity.evaluationindex.screen.ScreenProjectImgDataEntity;
import com.epmet.entity.stats.CustomerProjectCategoryDictEntity;
import com.epmet.feign.EpmetMessageOpenFeignClient;
import com.epmet.feign.OperCrmOpenFeignClient;
import com.epmet.send.SendMqMsgUtil;
import com.epmet.service.evaluationindex.screen.ScreenCustomerAgencyService;
import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryService;
import com.epmet.service.evaluationindex.screen.ScreenProjectDataService;
import com.epmet.service.stats.CustomerProjectCategoryDictService;
import com.github.pagehelper.PageHelper;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.ArrayUtils;
@ -48,10 +57,8 @@ import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
* 中央区-项目数据
@ -67,6 +74,14 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl<ScreenProjectD
private ScreenProjectImgDataDao screenProjectImgDataDao;
@Resource
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient;
@Resource
private ScreenProjectCategoryService screenProjectCategoryService;
@Resource
private CustomerProjectCategoryDictService customerProjectCategoryDictService;
@Resource
private OperCrmOpenFeignClient operCrmOpenFeignClient;
@Resource
private ScreenCustomerAgencyService screenCustomerAgencyService;
@Override
public PageData<ScreenProjectDataDTO> page(Map<String, Object> params) {
@ -132,6 +147,7 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl<ScreenProjectD
}*/
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date today = new Date();
List<ScreenProjectDataEntity> projectList = new ArrayList<>();
param.getDataList().forEach(item -> {
String projectStatusCode = item.getProjectStatusCode();
@ -195,7 +211,12 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl<ScreenProjectD
ScreenProjectDataEntity screenProjectDataEntity = ConvertUtils.sourceToTarget(item, ScreenProjectDataEntity.class);
screenProjectDataEntity.setCustomerId(param.getCustomerId());
screenProjectDataEntity.setDataEndTime(param.getDateId());
String agencyId = screenCustomerAgencyService.getParentAgencyId(screenProjectDataEntity.getAllParentIds().split(StrConstant.COMMA)[0]);
if(StringUtils.isNotBlank(agencyId)) {
screenProjectDataEntity.setAllParentIds(agencyId.concat(StrConstant.COMMA).concat(screenProjectDataEntity.getAllParentIds()));
}
baseDao.insert(screenProjectDataEntity);
projectList.add(screenProjectDataEntity);
//插入图片表
String[] projectImgUrl = item.getProjectImgUrl();
if (ArrayUtils.isNotEmpty(projectImgUrl)) {
@ -209,6 +230,8 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl<ScreenProjectD
}
}
});
saveCategory(param.getCustomerId(), projectList);
}
@ -262,13 +285,17 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl<ScreenProjectD
partition.forEach(part -> {
List<ScreenProjectDataEntity> list = ConvertUtils.sourceToTarget(part, ScreenProjectDataEntity.class);
insertBatch(list);
saveCategory(customerId, list);
});
}
if(!CollectionUtils.isEmpty(orient)){
List<List<ScreenProjectDataDTO>> partition = ListUtils.partition(orient, NumConstant.ONE_HUNDRED);
partition.forEach(part -> baseDao.updateBatch(part,dateId));
partition.forEach(part -> {
baseDao.updateBatch(part,dateId);
saveCategory(customerId, ConvertUtils.sourceToTarget(part, ScreenProjectDataEntity.class));
});
}
}
@ -306,4 +333,57 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl<ScreenProjectD
SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendProjectMqMsg(msg);
}
/**
* @param customerId
* @Description 提取项目分类
* @Param customerId
* @Return
* @Author zhaoqifeng
* @Date 2021/11/10 10:24
*/
@Override
public void extractCategory(String customerId) {
LambdaQueryWrapper<ScreenProjectDataEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(customerId), ScreenProjectDataEntity::getCustomerId, customerId);
List<ScreenProjectDataEntity> projectList = baseDao.selectList(wrapper);
saveCategory(customerId, projectList);
}
private void saveCategory(String customerId, List<ScreenProjectDataEntity> projectList) {
Result<String> parentCustomer = operCrmOpenFeignClient.getExternalAndParentCustomerId(customerId);
//删除旧分类
List<String> projectIds = projectList.stream().map(ScreenProjectDataEntity::getProjectId).collect(Collectors.toList());
screenProjectCategoryService.deleteByProjectId(customerId, projectIds);
//提取分类信息
List<ScreenProjectCategoryEntity> projectCategoryList = new ArrayList<>();
projectList.forEach(project -> {
//分类为空不作处理
if (StringUtils.isNotBlank(project.getCategoryCode())) {
List<String> categoryList = Arrays.asList(project.getCategoryCode().split(StrConstant.COMMA));
categoryList.forEach(category -> {
ScreenProjectCategoryEntity entity = new ScreenProjectCategoryEntity();
entity.setCustomerId(customerId);
entity.setProjectId(project.getProjectId());
entity.setOriginCategoryCode(category);
CustomerProjectCategoryDictEntity categoryEntity = customerProjectCategoryDictService.getByCategoryCode(customerId, category);
if (null != categoryEntity) {
//
if ("external".equals(categoryEntity.getCustomerType())) {
entity.setCategoryCode(categoryEntity.getEpmetCategoryCode());
CustomerProjectCategoryDictEntity parent = customerProjectCategoryDictService.getByCategoryCode(parentCustomer.getData(), categoryEntity.getEpmetCategoryCode());
entity.setParentCategoryCode(parent.getParentCategoryCode());
} else {
entity.setCategoryCode(categoryEntity.getCategoryCode());
entity.setParentCategoryCode(categoryEntity.getParentCategoryCode());
}
entity.setLevel(categoryEntity.getLevel());
}
projectCategoryList.add(entity);
});
}
});
screenProjectCategoryService.insertBatch(projectCategoryList);
}
}

36
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml

@ -505,5 +505,41 @@
del_flag = 0
AND customer_id = #{customerId}
</select>
<select id="getParentAgencyId" resultType="java.lang.String">
SELECT
a.AGENCY_ID
FROM
screen_customer_agency a
INNER JOIN screen_customer_agency b ON a.AREA_CODE = b.PARENT_AREA_CODE
AND b.DEL_FLAG = '0'
AND b.AGENCY_ID = #{agencyId}
WHERE
a.DEL_FLAG = '0'
</select>
<!-- 查询父子客户的组织【平阴】 -->
<select id="selectParentSonAgency" resultType="com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO">
SELECT
AGENCY_ID AS orgId,
PID,
REPLACE(PIDS,',',':') AS pids,
`LEVEL` AS orgType
FROM screen_customer_agency
WHERE DEL_FLAG = '0'
AND CUSTOMER_ID IN
<foreach collection="customerIds" item="c" separator="," open="(" close=")">
#{c}
</foreach>
UNION ALL
SELECT
AGENCY_ID AS orgId,
PID,
REPLACE(PIDS,',',':') AS pids,
CASE WHEN `LEVEL` = 'district' THEN 'street' ELSE `LEVEL` END AS orgType
FROM screen_customer_agency
WHERE DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND `LEVEL` != 'street'
</select>
</mapper>

30
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectCategoryDao.xml

@ -0,0 +1,30 @@
<?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.epmet.dao.evaluationindex.screen.ScreenProjectCategoryDao">
<resultMap type="com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryEntity" id="screenProjectCategoryMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="projectId" column="PROJECT_ID"/>
<result property="categoryCode" column="CATEGORY_CODE"/>
<result property="parentCategoryCode" column="PARENT_CATEGORY_CODE"/>
<result property="originCategoryCode" column="ORIGIN_CATEGORY_CODE"/>
<result property="level" column="LEVEL"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<delete id="deleteByProjectIds">
delete from screen_project_category
where CUSTOMER_ID = #{customerId}
<foreach collection="projectIds" item="projectId" open="AND (" close=" )" separator=" OR ">
PROJECT_ID = #{projectId}
</foreach>
</delete>
</mapper>

116
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectDataDao.xml

@ -269,4 +269,120 @@
ORDER BY
a.CREATED_TIME ASC
</select>
<!-- 查询网格下的项目分类 -->
<select id="selectGridCategoryProjectCount" resultType="com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO">
SELECT
#{dateId} AS dateId,
#{customerId} AS customerId,
pc.CATEGORY_CODE,
pd.ORG_ID AS gridId,
pd.PARENT_ID AS pid,
pd.ALL_PARENT_IDS AS pids,
pc.`LEVEL`,
<if test=' status == "closed" '>
COUNT(DISTINCT pc.PROJECT_ID) AS closedProjectTotal
</if>
<if test=' status == "all" '>
COUNT(DISTINCT pc.PROJECT_ID) AS projectTotal
</if>
FROM screen_project_data pd
LEFT JOIN screen_project_category pc ON (pc.PROJECT_ID = pd.PROJECT_ID AND pc.DEL_FLAG = '0')
WHERE pd.DEL_FLAG = '0'
AND pd.CUSTOMER_ID IN
<foreach collection="customerIds" item="c" separator="," open="(" close=")">
#{c}
</foreach>
AND DATE_FORMAT(pd.PROJECT_CREATE_TIME,'%Y%m%d') <![CDATA[ <= ]]> #{dateId}
AND pd.ORG_TYPE = 'grid'
AND pc.level = 2
<if test=' status == "closed" '>
AND pd.PROJECT_STATUS_CODE IN ('closed','closed_case')
</if>
GROUP BY pd.ORG_ID,pc.CATEGORY_CODE
UNION ALL
SELECT
#{dateId} AS dateId,
#{customerId} AS customerId,
left(pc.CATEGORY_CODE, #{subCount}) AS categoryCode,
pd.ORG_ID AS gridId,
pd.PARENT_ID AS pid,
pd.ALL_PARENT_IDS AS pids,
1 AS level,
<if test=' status == "closed" '>
COUNT(DISTINCT pc.PROJECT_ID) AS closedProjectTotal
</if>
<if test=' status == "all" '>
COUNT(DISTINCT pc.PROJECT_ID) AS projectTotal
</if>
FROM screen_project_data pd
INNER JOIN screen_project_category pc ON (pc.PROJECT_ID = pd.PROJECT_ID AND pc.DEL_FLAG = '0')
WHERE pd.DEL_FLAG = '0'
AND pd.CUSTOMER_ID IN
<foreach collection="customerIds" item="c" separator="," open="(" close=")">
#{c}
</foreach>
AND DATE_FORMAT(pd.PROJECT_CREATE_TIME,'%Y%m%d') <![CDATA[ <= ]]> #{dateId}
AND pd.ORG_TYPE = 'grid'
<if test=' status == "closed" '>
AND pd.PROJECT_STATUS_CODE IN ('closed','closed_case')
</if>
GROUP BY pd.ORG_ID,categoryCode
</select>
<!-- 查询组织下的项目分类 -->
<select id="selectOrgCategoryProjectCount" resultType="com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO">
<foreach collection="allAgencies" item="a" separator=" UNION ALL ">
SELECT
#{dateId} AS dateId,
#{customerId} AS customerId,
pc.CATEGORY_CODE,
#{a.orgId} AS orgId,
#{a.pid} AS pid,
#{a.pids} AS pids,
#{a.orgType} AS orgType,
pc.`LEVEL`,
<if test=' status == "closed" '>
COUNT(DISTINCT pc.PROJECT_ID) AS closedProjectTotal
</if>
<if test=' status == "all" '>
COUNT(DISTINCT pc.PROJECT_ID) AS projectTotal
</if>
FROM screen_project_data pd
LEFT JOIN screen_project_category pc ON (pc.PROJECT_ID = pd.PROJECT_ID AND pc.DEL_FLAG = '0')
WHERE pd.DEL_FLAG = '0'
AND pc.level = 2
AND DATE_FORMAT(pd.PROJECT_CREATE_TIME,'%Y%m%d') <![CDATA[ <= ]]> #{dateId}
AND ALL_PARENT_IDS LIKE #{a.orgId}
<if test=' status == "closed" '>
AND pd.PROJECT_STATUS_CODE IN ('closed','closed_case')
</if>
GROUP BY pc.CATEGORY_CODE
UNION ALL
SELECT
#{dateId} AS dateId,
#{customerId} AS customerId,
left(pc.CATEGORY_CODE, #{subCount}) AS categoryCode,
#{a.orgId} AS orgId,
#{a.pid} AS pid,
#{a.pids} AS pids,
#{a.orgType} AS orgType,
pc.`LEVEL`,
<if test=' status == "closed" '>
COUNT(DISTINCT pc.PROJECT_ID) AS closedProjectTotal
</if>
<if test=' status == "all" '>
COUNT(DISTINCT pc.PROJECT_ID) AS projectTotal
</if>
FROM screen_project_data pd
INNER JOIN screen_project_category pc ON (pc.PROJECT_ID = pd.PROJECT_ID AND pc.DEL_FLAG = '0')
WHERE pd.DEL_FLAG = '0'
AND DATE_FORMAT(pd.PROJECT_CREATE_TIME,'%Y%m%d') <![CDATA[ <= ]]> #{dateId}
AND ALL_PARENT_IDS LIKE #{a.orgId}
<if test=' status == "closed" '>
AND pd.PROJECT_STATUS_CODE IN ('closed','closed_case')
</if>
GROUP BY categoryCode
</foreach>
</select>
</mapper>

22
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java

@ -23,6 +23,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
@ -47,10 +48,8 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -180,15 +179,24 @@ public class BuildingController {
List<IcBuildingExcel> failList = importResult.getFailList();
//存放错误数据行号
List<Integer> numList = new ArrayList<>();
if(!CollectionUtils.isEmpty(failList)){
for ( IcBuildingExcel entity : failList) {
log.error("第{}行,{}",entity.getRowNum(),entity.getErrorMsg());//打印失败的行 和失败的信息
numList.add(entity.getRowNum());
}
return new Result().error(8001,failList.get(0).getErrorMsg());
//return new Result().error(8001,failList.get(0).getErrorMsg());
}
List<IcBuildingExcel> result =importResult.getList();
return new Result().ok(buildingService.importExcel(customerId,result,tokenDTO.getUserId()));
List<Integer> resultList = buildingService.importExcel(customerId,result,tokenDTO.getUserId(),numList);
String str = String.format("共%s条,成功导入%s条。",numList.size()+result.size(),numList.size()+result.size()-resultList.size());
if(resultList.size()> NumConstant.ZERO){
Collections.sort(resultList);
String subList = resultList.stream().map(String::valueOf).collect(Collectors.joining("、"));
return new Result().error(9999, str+"第"+subList+"行未成功!");
}
return new Result().ok(str);
}
/**

16
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java

@ -21,6 +21,7 @@ import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
@ -42,6 +43,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -145,15 +147,25 @@ public class HouseController {
List<IcHouseExcel> failList = importResult.getFailList();
//存放错误数据行号
List<Integer> numList = new ArrayList<>();
if(!CollectionUtils.isEmpty(failList)){
for ( IcHouseExcel entity : failList) {
log.error("第{}行,{}",entity.getRowNum(),entity.getErrorMsg());//打印失败的行 和失败的信息
numList.add(entity.getRowNum());
}
return new Result().error(8001,failList.get(0).getErrorMsg());
//return new Result().error(8001,failList.get(0).getErrorMsg());
}
List<IcHouseExcel> result =importResult.getList();
return new Result().ok(houseService.importExcel(customerId,result,tokenDTO.getUserId()));
List<Integer> resultList = houseService.importExcel(customerId,result,tokenDTO.getUserId(),numList);
String str = String.format("共%s条,成功导入%s条。",numList.size()+result.size(),numList.size()+result.size()-resultList.size());
if(resultList.size()> NumConstant.ZERO){
Collections.sort(resultList);
String subList = resultList.stream().map(String::valueOf).collect(Collectors.joining("、"));
return new Result().error(9999, str+"第"+subList+"行未成功!");
}
return new Result().ok(str);
}
@PostMapping( "queryListHouseInfo")

22
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java

@ -22,6 +22,7 @@ import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
@ -45,10 +46,8 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -207,16 +206,25 @@ public class NeighborHoodController {
// List<IcNeighborHoodExcel> result = ExcelPoiUtils.importExcel(file, 0, 1, IcNeighborHoodExcel.class);
List<IcNeighborHoodExcel> failList = importResult.getFailList();
//存放错误数据行号
List<Integer> numList = new ArrayList<>();
if(!CollectionUtils.isEmpty(failList)){
for ( IcNeighborHoodExcel entity : failList) {
log.error("第{}行,{}",entity.getRowNum(),entity.getErrorMsg());//打印失败的行 和失败的信息
numList.add(entity.getRowNum());
}
return new Result().error(8001,failList.get(0).getErrorMsg());
//return new Result().error(8001,failList.get(0).getErrorMsg());
}
List<IcNeighborHoodExcel> result =importResult.getList();
// log.info(JSON.toJSONString(result));
neighborHoodService.importExcel(customerId,result,tokenDTO.getUserId());
return new Result();
List<Integer> resultList = neighborHoodService.importExcel(customerId,result,tokenDTO.getUserId(),numList);
String str = String.format("共%s条,成功导入%s条。",numList.size()+result.size(),numList.size()+result.size()-resultList.size());
if(resultList.size()> NumConstant.ZERO){
Collections.sort(resultList);
String subList = resultList.stream().map(String::valueOf).collect(Collectors.joining("、"));
return new Result().error(9999, str+"第"+subList+"行未成功!");
}
return new Result().ok(str);
}

6
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java

@ -336,4 +336,10 @@ public interface CustomerGridDao extends BaseDao<CustomerGridEntity> {
* @Date 2021/10/25 16:04
*/
List<UnitDTO> selectUnitList(@Param("buildingId") String buildingId);
/**
* @Author sun
* @Description 查询组织下直属网格列表
**/
List<CustomerGridEntity> selectByPid(@Param("pid") String pid);
}

3
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcBuildingDao.java

@ -56,7 +56,8 @@ public interface IcBuildingDao extends BaseDao<IcBuildingEntity> {
List<CustomerAgencyEntity> selectAgencyChildrenList(@Param("agencyId") String agencyId);
List<Map<String, Object>> selectListByName(@Param("neighborNameList")ArrayList<String> strings,
List<Map<String, Object>> selectListByName(@Param("customerId") String customerId,
@Param("neighborNameList")ArrayList<String> strings,
@Param("buildingNameList") ArrayList<String> strings1,
@Param("buildingUnitList") ArrayList<Integer> integers);

3
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java

@ -43,7 +43,8 @@ public interface IcNeighborHoodDao extends BaseDao<IcNeighborHoodEntity> {
// List<IcNeighborHoodExcel> searchAllNeighborhood(@Param(Constants.WRAPPER) QueryWrapper<IcNeighborHoodEntity> neighborHoodEntityQueryWrapper);
List<IcNeighborHoodExcel> searchAllNeighborhood(@Param("neighbor") IcNeighborHoodEntity neighbor, @Param("house")IcHouseEntity house);
List<IcNeighborHoodEntity> selectListByName(@Param("neighborNameList")List<String> neighborNameList,
List<IcNeighborHoodEntity> selectListByName(@Param("customerId") String customerId,
@Param("neighborNameList")List<String> neighborNameList,
@Param("agencyNameList") List<String> agencyNameList,
@Param("gridNameList") List<String> gridNameList);

3
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java

@ -17,7 +17,6 @@
package com.epmet.service;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.BuildingTreeLevelDTO;
import com.epmet.dto.form.IcBulidingFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
@ -53,7 +52,7 @@ public interface BuildingService {
List<BuildingTreeLevelDTO> treeList(String customerId);
Result importExcel(String customerId, List<IcBuildingExcel> list, String staffId);
List<Integer> importExcel(String customerId, List<IcBuildingExcel> list, String staffId, List<Integer> numList);
IcNeighborHoodResultDTO listBuilding(ListIcNeighborHoodFormDTO formDTO);

3
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java

@ -17,7 +17,6 @@
package com.epmet.service;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.IcHouseFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
import com.epmet.dto.result.HouseInfoDTO;
@ -48,7 +47,7 @@ public interface HouseService {
void delHouse(String houseId);
Result importExcel(String customerId, List<IcHouseExcel> list, String staffId);
List<Integer> importExcel(String customerId, List<IcHouseExcel> list, String staffId, List<Integer> numList);
IcNeighborHoodResultDTO listNeighborhood(ListIcNeighborHoodFormDTO formDTO);

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/NeighborHoodService.java

@ -52,5 +52,5 @@ public interface NeighborHoodService{
*/
void exportNeighborhoodinfo(ListIcNeighborHoodFormDTO formDTO, HttpServletResponse response) throws Exception ;
void importExcel(String customerId,List<IcNeighborHoodExcel> list,String staffId);
List<Integer> importExcel(String customerId, List<IcNeighborHoodExcel> list, String staffId, List<Integer> numList);
}

19
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java

@ -9,7 +9,6 @@ import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.*;
import com.epmet.dto.BuildingTreeLevelDTO;
import com.epmet.dto.CustomerStaffAgencyDTO;
@ -210,7 +209,7 @@ public class BuildingServiceImpl implements BuildingService {
@Override
@Transactional(rollbackFor = Exception.class)
public Result importExcel(String customerId, List<IcBuildingExcel> list, String staffId) {
public List<Integer> importExcel(String customerId, List<IcBuildingExcel> list, String staffId, List<Integer> numList) {
//2021.11.9 需求变更 当前工作人员只能导致自己所属组织下数据,网格名对应不上的数据舍弃【注:需求就这样】 sun
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(customerId, staffId);
//组织名称不一样的数据舍弃
@ -218,15 +217,16 @@ public class BuildingServiceImpl implements BuildingService {
while (iterator.hasNext()) {
IcBuildingExcel obj = iterator.next();
if (!obj.getAgencyName().trim().equals(staffInfoCache.getAgencyName())) {
numList.add(obj.getRowNum());
iterator.remove();
}
}
//用于存储匹配不上的数据给前端的提示 如南宁社区不存在
StringBuffer str = new StringBuffer("");
//StringBuffer str = new StringBuffer("");
//end sun
//导入
if(CollectionUtils.isEmpty(list)){
return new Result();
return numList;
}
//查询所有组织和网格根据名字
@ -236,7 +236,7 @@ public class BuildingServiceImpl implements BuildingService {
Set<String> neighborNameList = list.stream().map(item -> item.getNeighborHoodName()).collect(Collectors.toSet());
Set<String> agencyNameList = list.stream().map(item -> item.getAgencyName()).collect(Collectors.toSet());
Set<String> gridNameList = list.stream().map(item -> item.getGridName()).collect(Collectors.toSet());
List<IcNeighborHoodEntity> neighborHoodList = icNeighborHoodDao.selectListByName(new ArrayList<String>(neighborNameList),new ArrayList<String>(agencyNameList),new ArrayList<String>(gridNameList));
List<IcNeighborHoodEntity> neighborHoodList = icNeighborHoodDao.selectListByName(customerId, new ArrayList<String>(neighborNameList),new ArrayList<String>(agencyNameList),new ArrayList<String>(gridNameList));
// List<IcNeighborHoodEntity> neighborHoodList = icNeighborHoodDao.selectList(new QueryWrapper<IcNeighborHoodEntity>().lambda().in(IcNeighborHoodEntity::getNeighborHoodName, neighborNameList));
Map<String,IcNeighborHoodEntity> neighborHoodMap = neighborHoodList.stream().collect(Collectors.toMap(IcNeighborHoodEntity::getNeighborHoodName, Function.identity(),(key1, key2)->key1));
@ -252,7 +252,8 @@ public class BuildingServiceImpl implements BuildingService {
entity.setCustomerId(customerId);
entity.setNeighborHoodId(Optional.ofNullable(neighborHoodMap.get(icBuildingExcel.getNeighborHoodName())).map(u->u.getId()).orElse(""));//neighborHoodMap.get(icBuildingExcel.getNeighborHoodName()).getId()
if ("".equals(entity.getNeighborHoodId())) {
str.append("".equals(str) ? icBuildingExcel.getNeighborHoodName() : str.append("、").append(icBuildingExcel.getNeighborHoodName()));
//str.append("".equals(str) ? icBuildingExcel.getNeighborHoodName() : str.append("、").append(icBuildingExcel.getNeighborHoodName()));
numList.add(icBuildingExcel.getRowNum());
continue;
}
entity.setBuildingName(icBuildingExcel.getBuildingName());
@ -286,10 +287,10 @@ public class BuildingServiceImpl implements BuildingService {
icBuildingService.insertBatch(buildingEntityList);
icBuildingUnitService.insertBatch(icBuildingUnitEntityList);
if(!"".equals(str)){
/* if(!"".equals(str)){
return new Result().error(9999, str.append("不存在").toString());
}
return new Result();
}*/
return numList;
}
@Override

21
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java

@ -8,7 +8,6 @@ import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.IcBuildingDao;
import com.epmet.dao.IcBuildingUnitDao;
import com.epmet.dao.IcHouseDao;
@ -24,7 +23,6 @@ import com.epmet.entity.IcHouseEntity;
import com.epmet.enums.HousePurposeEnums;
import com.epmet.enums.HouseRentFlagEnums;
import com.epmet.enums.HouseTypeEnums;
import com.epmet.excel.IcBuildingExcel;
import com.epmet.excel.IcHouseExcel;
import com.epmet.service.HouseService;
import com.epmet.service.IcBuildingService;
@ -123,7 +121,8 @@ public class HouseServiceImpl implements HouseService {
}
@Override
public Result importExcel(String customerId, List<IcHouseExcel> list, String staffId) {
@Transactional(rollbackFor = Exception.class)
public List<Integer> importExcel(String customerId, List<IcHouseExcel> list, String staffId, List<Integer> numList) {
//2021.11.10 需求变更 当前工作人员只能导致自己所属组织下数据,对应不上的数据舍弃【注:需求就这样】 sun
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(customerId, staffId);
//组织名称不一样的数据舍弃
@ -131,15 +130,16 @@ public class HouseServiceImpl implements HouseService {
while (iterator.hasNext()) {
IcHouseExcel obj = iterator.next();
if (!obj.getAgencyName().trim().equals(staffInfoCache.getAgencyName())) {
numList.add(obj.getRowNum());
iterator.remove();
}
}
//用于存储匹配不上的数据给前端的提示 如南宁社区不存在
StringBuffer str = new StringBuffer("");
//StringBuffer str = new StringBuffer("");
//end sun
//导入
if(CollectionUtils.isEmpty(list)){
return new Result();
return numList;
}
//获取所有小区 list
// List<String> neighborNameList = list.stream().map(item -> item.getNeighborHoodName()).collect(Collectors.toList());
@ -153,7 +153,7 @@ public class HouseServiceImpl implements HouseService {
Set<String> neighborNameList = list.stream().map(item -> item.getNeighborHoodName()).collect(Collectors.toSet());
Set<String> buildingNameList = list.stream().map(item -> item.getBuildingName()).collect(Collectors.toSet());
Set<Integer> buildingUnitList = list.stream().map(item -> item.getBuildingUnit()).collect(Collectors.toSet());
List<Map<String,Object>> buildMapList = icBuildingDao.selectListByName(new ArrayList<String>(neighborNameList),new ArrayList<String>(buildingNameList),new ArrayList<Integer>(buildingUnitList));
List<Map<String,Object>> buildMapList = icBuildingDao.selectListByName(customerId, new ArrayList<String>(neighborNameList),new ArrayList<String>(buildingNameList),new ArrayList<Integer>(buildingUnitList));
//转Map
Map<String,Map<String,Object>> buildMap = new HashMap<>();
buildMapList.forEach(item->{
@ -173,7 +173,8 @@ public class HouseServiceImpl implements HouseService {
entity.setBuildingUnitId(String.valueOf(Optional.ofNullable(item).map(u->u.get("buildingUnitId")).orElse("")));
entity.setHouseName(icHouseExcel.getBuildingName()+"-"+icHouseExcel.getBuildingUnit()+"-"+icHouseExcel.getDoorName());
if ("".equals(entity.getNeighborHoodId()) || "".equals(entity.getBuildingId()) || "".equals(entity.getBuildingUnitId())) {
str.append("".equals(str) ? icHouseExcel.getBuildingName() + icHouseExcel.getBuildingUnit() : str.append("、").append(icHouseExcel.getBuildingName() + icHouseExcel.getBuildingUnit()));
//str.append("".equals(str) ? icHouseExcel.getBuildingName() + icHouseExcel.getBuildingUnit() : str.append("、").append(icHouseExcel.getBuildingName() + icHouseExcel.getBuildingUnit()));
numList.add(icHouseExcel.getRowNum());
continue;
}
entity.setDoorName(icHouseExcel.getDoorName());
@ -193,10 +194,10 @@ public class HouseServiceImpl implements HouseService {
//3.保存
icHouseService.insertBatch(houseEntityList);
if(!"".equals(str)){
/*if(!"".equals(str)){
return new Result().error(9999, str.append("不存在").toString());
}
return new Result();
}*/
return numList;
}

28
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java

@ -36,6 +36,7 @@ import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -240,32 +241,49 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
@Override
@Transactional(rollbackFor = Exception.class)
public void importExcel(String customerId,List<IcNeighborHoodExcel> list,String staffId) {
public List<Integer> importExcel(String customerId,List<IcNeighborHoodExcel> list,String staffId, List<Integer> numList) {
//2021.11.9 需求变更 当前工作人员只能导致自己所属组织下数据,网格名对应不上的数据舍弃【注:需求就这样】 sun
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(customerId, staffId);
//查询当前组织下网格列表
List<CustomerGridEntity> customerGridList = customerGridDao.selectByPid(staffInfoCache.getAgencyId());
//组织名称不一样的数据舍弃
Iterator<IcNeighborHoodExcel> iterator = list.iterator();
while (iterator.hasNext()) {
IcNeighborHoodExcel obj = iterator.next();
if (!obj.getAgencyName().trim().equals(staffInfoCache.getAgencyName())) {
numList.add(obj.getRowNum());
iterator.remove();
}
//当前组织下网格名不存在的也不允许导入
AtomicBoolean br = new AtomicBoolean(true);
customerGridList.forEach(g->{
if(obj.getGridName().trim().equals(g.getGridName())){
br.set(false);
}
});
if(br.get()){
numList.add(obj.getRowNum());
iterator.remove();
}
}
//end sun
//导入
if(CollectionUtils.isEmpty(list)){
return ;
return numList;
}
//获取所有组织 list
List<String> agencyNameList = list.stream().map(item -> item.getAgencyName()).collect(Collectors.toList());
agencyNameList = agencyNameList.stream().distinct().collect(Collectors.toList());
//获取所有网格 list
List<String> gridNameList = list.stream().map(item->item.getGridName()).collect(Collectors.toList());
//List<String> gridNameList = list.stream().map(item->item.getGridName()).collect(Collectors.toList());
//获取所有物业 list
List<String> propertyNameList = list.stream().map(item->item.getPropertyName()).collect(Collectors.toList());
propertyNameList = propertyNameList.stream().distinct().collect(Collectors.toList());
//查询对应的id
List<CustomerAgencyEntity> customerAgencyList = customerAgencyDao.selectList(new QueryWrapper<CustomerAgencyEntity>().lambda().in(CustomerAgencyEntity::getOrganizationName, agencyNameList));
List<CustomerGridEntity> customerGridList = customerGridDao.selectList(new QueryWrapper<CustomerGridEntity>().lambda().in(CustomerGridEntity::getGridName, gridNameList));
//List<CustomerGridEntity> customerGridList = customerGridDao.selectList(new QueryWrapper<CustomerGridEntity>().lambda().in(CustomerGridEntity::getGridName, gridNameList));
List<IcPropertyManagementEntity> icPropertyManagementList = icPropertyManagementDao.selectList(new QueryWrapper<IcPropertyManagementEntity>().lambda().in(IcPropertyManagementEntity::getName, propertyNameList));
Map<String,CustomerAgencyEntity> agencyMap = customerAgencyList.stream().collect(Collectors.toMap(CustomerAgencyEntity::getOrganizationName, Function.identity(),(key1, key2)->key1));
@ -294,6 +312,7 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
entity.setGridId(Optional.ofNullable(gridMap.get(icNeighborHoodExcel.getGridName().trim())).map(u->u.getId()).orElse(""));//gridMap.get(icNeighborHoodExcel.getGridName()).getId()
//网格名对应不上的数据舍弃
if ("".equals(entity.getGridId())) {
numList.add(icNeighborHoodExcel.getRowNum());
continue;
}
entity.setAddress(icNeighborHoodExcel.getAddress());
@ -312,6 +331,7 @@ public class NeighborHoodServiceImpl implements NeighborHoodService {
icNeighborHoodService.insertBatch(neighborHoodEntityList);
icNeighborHoodPropertyService.insertBatch(icNeighborHoodPropertyEntityList);
return numList;
}

8
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml

@ -680,5 +680,13 @@
DEL_FLAG = '0'
AND BUILDING_ID = #{buildingId}
</select>
<select id="selectByPid" resultType="com.epmet.entity.CustomerGridEntity">
SELECT
*
FROM customer_grid
WHERE
del_flag = '0'
AND pid = #{pid}
</select>
</mapper>

4
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcBuildingDao.xml

@ -283,7 +283,9 @@
<foreach collection="buildingUnitList" open="(" separator="," close=")" item="val">
#{val}
</foreach>
WHERE a.DEL_FLAG = '0' and a.NEIGHBOR_HOOD_NAME in
WHERE a.DEL_FLAG = '0'
AND a.CUSTOMER_ID = #{customerId}
and a.NEIGHBOR_HOOD_NAME in
<foreach collection="neighborNameList" open="(" separator="," close=")" item="val">
#{val}
</foreach>

4
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml

@ -193,7 +193,9 @@
<foreach collection="gridNameList" open="(" separator="," close=")" item="val">
#{val}
</foreach>
where a.DEL_FLAG= '0'and a.NEIGHBOR_HOOD_NAME in
where a.DEL_FLAG= '0'
AND a.CUSTOMER_ID = #{customerId}
and a.NEIGHBOR_HOOD_NAME in
<foreach collection="neighborNameList" open="(" separator="," close=")" item="val">
#{val}
</foreach>

2
epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/CustomerFormResultDTO.java

@ -27,7 +27,7 @@ public class CustomerFormResultDTO implements Serializable {
/**
* 表单项
*/
private List<FormItem> itemList;
private List<FormItemResult> itemList;
/**
* 表单分组

2
epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormGroupDTO.java

@ -42,6 +42,6 @@ public class FormGroupDTO implements Serializable {
/**
* 分组里面的组件
*/
private List<FormItem2> itemList;
private List<FormItemResult2> itemList;
}

2
epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormItem.java → epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormItemResult.java

@ -12,7 +12,7 @@ import java.util.List;
* @Date 2021/10/26 2:15 下午
*/
@Data
public class FormItem implements Serializable {
public class FormItemResult implements Serializable {
private static final long serialVersionUID = 7443085469505238040L;
/**

2
epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormItem2.java → epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/dto/result/FormItemResult2.java

@ -12,7 +12,7 @@ import java.util.List;
* @Date 2021/10/26 4:29 下午
*/
@Data
public class FormItem2 implements Serializable {
public class FormItemResult2 implements Serializable {
private static final long serialVersionUID = -7571266621687396261L;
/**
* 父项ID

2
epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/OperCustomizeOpenFeignClient.java

@ -91,7 +91,7 @@ public interface OperCustomizeOpenFeignClient {
* @date 2021.10.28 15:19:59
*/
@PostMapping("/oper/customize/icform/items")
Result<List<FormItem>> listItems(@RequestBody CustomerFormQueryDTO formDto);
Result<List<FormItemResult>> listItems(@RequestBody CustomerFormQueryDTO formDto);
/**
* @Author sun

2
epmet-module/oper-customize/oper-customize-client/src/main/java/com/epmet/feign/fallback/OperCustomizeOpenFeignClientFallback.java

@ -73,7 +73,7 @@ public class OperCustomizeOpenFeignClientFallback implements OperCustomizeOpenFe
}
@Override
public Result<List<FormItem>> listItems(CustomerFormQueryDTO formDto) {
public Result<List<FormItemResult>> listItems(CustomerFormQueryDTO formDto) {
return ModuleUtils.feignConError(ServiceConstant.OPER_CUSTOMIZE_SERVER, "listItems", formDto);
}

6
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/IcFormController.java

@ -187,9 +187,9 @@ public class IcFormController {
* @date 2021.10.28 15:19:59
*/
@PostMapping("items")
public Result<List<FormItem>> listItems(@LoginUser TokenDto tokenDto, @RequestBody CustomerFormQueryDTO formDto) {
public Result<List<FormItemResult>> listItems(@LoginUser TokenDto tokenDto, @RequestBody CustomerFormQueryDTO formDto) {
ValidatorUtils.validateEntity(formDto, CustomerFormQueryDTO.GetFormInfoGroup.class);
List<FormItem> rst = icFormService.listItems(tokenDto.getCustomerId(), formDto.getFormCode());
return new Result<List<FormItem>>().ok(rst);
List<FormItemResult> rst = icFormService.listItems(tokenDto.getCustomerId(), formDto.getFormCode());
return new Result<List<FormItemResult>>().ok(rst);
}
}

8
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/dao/IcFormDao.java

@ -20,7 +20,7 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.result.CustomerFormResultDTO;
import com.epmet.dto.result.FormGroupDTO;
import com.epmet.dto.result.FormItem;
import com.epmet.dto.result.FormItemResult;
import com.epmet.dto.result.OptionDTO;
import com.epmet.entity.IcFormEntity;
import org.apache.ibatis.annotations.Mapper;
@ -47,9 +47,9 @@ public interface IcFormDao extends BaseDao<IcFormEntity> {
*/
CustomerFormResultDTO selectByCode(@Param("customerId") String customerId, @Param("formCode") String formCode);
List<FormItem> selectItemList(String formId, Boolean dynamic);
List<FormItemResult> selectItemList(String formId, Boolean dynamic);
List<FormItem> selectItemListByGroupId(String groupId);
List<FormItemResult> selectItemListByGroupId(String groupId);
List<OptionDTO> selectListOption(String itemId);
List<FormGroupDTO> selectListGroup(String formId);
@ -64,5 +64,5 @@ public interface IcFormDao extends BaseDao<IcFormEntity> {
* @author wxz
* @date 2021.10.28 16:43:00
*/
List<FormItem> listItems(@Param("formId") String formId);
List<FormItemResult> listItems(@Param("formId") String formId);
}

6
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/IcFormService.java

@ -22,7 +22,7 @@ import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.IcFormDTO;
import com.epmet.dto.form.CustomerFormQueryDTO;
import com.epmet.dto.result.CustomerFormResultDTO;
import com.epmet.dto.result.FormItem;
import com.epmet.dto.result.FormItemResult;
import com.epmet.entity.IcFormEntity;
import java.util.List;
@ -115,5 +115,5 @@ public interface IcFormService extends BaseService<IcFormEntity> {
* @author wxz
* @date 2021.10.27 17:41:59
*/
List<FormItem> listItems(String customerId, String formCode);
}
List<FormItemResult> listItems(String customerId, String formCode);
}

27
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcFormServiceImpl.java

@ -17,9 +17,7 @@
package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
@ -35,21 +33,18 @@ import com.epmet.dto.IcFormDTO;
import com.epmet.dto.form.CustomerFormQueryDTO;
import com.epmet.dto.result.CustomerFormResultDTO;
import com.epmet.dto.result.FormGroupDTO;
import com.epmet.dto.result.FormItem;
import com.epmet.dto.result.FormItemResult;
import com.epmet.entity.IcFormEntity;
import com.epmet.redis.CustomerFootBarRedis;
import com.epmet.service.IcFormService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* 配置表单
@ -61,7 +56,7 @@ import java.util.Optional;
public class IcFormServiceImpl extends BaseServiceImpl<IcFormDao, IcFormEntity> implements IcFormService {
@Autowired
private CustomerFootBarRedis customerFootBarRedis;
@Autowired
private RedisUtils redisUtils;
@ -135,7 +130,7 @@ public class IcFormServiceImpl extends BaseServiceImpl<IcFormDao, IcFormEntity>
if (null == resultDTO) {
throw new RenException(EpmetErrorCode.CUSTOMER_FORM_NOT_EXITS.getCode(),EpmetErrorCode.CUSTOMER_FORM_NOT_EXITS.getMsg());
}
List<FormItem> itemList=baseDao.selectItemList(resultDTO.getFormId(),formDto.getDynamic());
List<FormItemResult> itemList=baseDao.selectItemList(resultDTO.getFormId(),formDto.getDynamic());
List<FormGroupDTO> groupList=baseDao.selectListGroup(resultDTO.getFormId());
resultDTO.setItemList(itemList);
resultDTO.setGroupList(groupList);
@ -144,13 +139,13 @@ public class IcFormServiceImpl extends BaseServiceImpl<IcFormDao, IcFormEntity>
}
@Override
public List<FormItem> listItems(String customerId, String formCode) {
public List<FormItemResult> listItems(String customerId, String formCode) {
// 从redis取
String icFormItemsKey = RedisKeys.getIcFormItemsKey(customerId, formCode);
Object objValue = redisUtils.get(icFormItemsKey);
if (objValue != null) {
return ((JSONArray) objValue).toJavaList(FormItem.class);
return ((JSONArray) objValue).toJavaList(FormItemResult.class);
//return JSON.parseObject((String) objValue, type);
}
@ -160,14 +155,14 @@ public class IcFormServiceImpl extends BaseServiceImpl<IcFormDao, IcFormEntity>
throw new RenException(EpmetErrorCode.CUSTOMER_FORM_NOT_EXITS.getCode(),EpmetErrorCode.CUSTOMER_FORM_NOT_EXITS.getMsg());
}
List<FormItem> formItems = baseDao.listItems(formResultDto.getFormId());
formItems.forEach(i -> {
List<FormItemResult> formItemResults = baseDao.listItems(formResultDto.getFormId());
formItemResults.forEach(i -> {
i.setOptions(baseDao.selectListOption(i.getItemId()));
});
// 缓存
redisUtils.set(icFormItemsKey, formItems);
redisUtils.set(icFormItemsKey, formItemResults);
return formItems;
return formItemResults;
}
}

8
epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/IcFormDao.xml

@ -17,7 +17,7 @@
</select>
<resultMap id="FormItemMap1" type="com.epmet.dto.result.FormItem">
<resultMap id="FormItemMap1" type="com.epmet.dto.result.FormItemResult">
<id property="itemId" column="item_id" ></id>
<result property="tableName" column="table_name"/>
<result property="parentItemId" column="PARENT_ITEM_ID"/>
@ -123,13 +123,13 @@
<result property="sort" column="sort"/>
<result property="supportAdd" column="SUPPORT_ADD"/>
<result property="tableName" column="TABLE_NAME"/>
<collection property="itemList" ofType="com.epmet.dto.result.FormItem2"
<collection property="itemList" ofType="com.epmet.dto.result.FormItemResult2"
column="group_id" select="com.epmet.dao.IcFormDao.selectItemListByGroupId">
</collection>
</resultMap>
<resultMap id="FormItemMap2" type="com.epmet.dto.result.FormItem2">
<resultMap id="FormItemMap2" type="com.epmet.dto.result.FormItemResult2">
<id property="itemId" column="item_id" ></id>
<result property="tableName" column="table_name"/>
<result property="parentItemId" column="PARENT_ITEM_ID"/>
@ -210,7 +210,7 @@
g.SORT ASC
</select>
<select id="listItems" resultType="com.epmet.dto.result.FormItem">
<select id="listItems" resultType="com.epmet.dto.result.FormItemResult">
SELECT fi.ID AS item_id,
case
when g.TABLE_NAME is null or g.TABLE_NAME = '' then 'ic_resi_user'

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;
}

205
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java

@ -29,10 +29,12 @@ import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
@ -178,58 +180,21 @@ public class IcResiUserController {
* @throws Exception
*/
@RequestMapping(value = "/exportExcel2")
public void exportExcel(@RequestHeader String customerId, @RequestBody IcResiUserPageFormDTO pageFormDTO, HttpServletResponse response) throws Exception {
public void exportExcel(@RequestHeader String customerId,@LoginUser TokenDto tokenDto, @RequestBody IcResiUserPageFormDTO pageFormDTO, HttpServletResponse response) throws Exception {
CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(customerId, tokenDto.getUserId());
String staffOrgPath = null;
if (StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds()) && !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())) {
staffOrgPath = staffInfoCacheResult.getAgencyPIds().concat(":").concat(staffInfoCacheResult.getAgencyId());
}else{
staffOrgPath=staffInfoCacheResult.getAgencyId();
}
pageFormDTO.setCustomerId(customerId);
pageFormDTO.setPageFlag(false);
CustomerFormResultDTO resiFormItems = getResiFormItems(pageFormDTO.getCustomerId());
Map<String, Map<String, FormItem>> otherSheetItems = new HashMap<>();
CustomerFormResultDTO resiFormItems = getResiFormAddItems(pageFormDTO.getCustomerId());
//主表的
for (FormItem formItem : resiFormItems.getItemList()) {
if (StringUtils.isBlank(formItem.getColumnName())) {
continue;
}
Map<String, FormItem> itemMap = otherSheetItems.getOrDefault(formItem.getTableName(), new HashMap<>());
otherSheetItems.putIfAbsent(formItem.getTableName(), itemMap);
if (formItem.getItemType().equals("checkbox") || formItem.getItemType().equals("select") || formItem.getItemType().equals("radio")) {
itemMap.put(formItem.getColumnName().concat(formItem.getColumnNum() == 0 ? "" : formItem.getColumnNum().toString()), formItem);
}
if (formItem.getChildGroup() != null) {
itemMap = otherSheetItems.getOrDefault(formItem.getChildGroup().getTableName(), new HashMap<>());
otherSheetItems.putIfAbsent(formItem.getChildGroup().getTableName(), itemMap);
for (FormItem2 item2 : formItem.getChildGroup().getItemList()) {
if (StringUtils.isBlank(item2.getColumnName())) {
continue;
}
if ("checkbox".equals(item2.getItemType()) || "select".equals(item2.getItemType()) || "radio".equals(item2.getItemType())) {
itemMap.put(item2.getColumnName().concat(item2.getColumnNum() == 0 ? "" : item2.getColumnNum().toString()), ConvertUtils.sourceToTarget(item2, FormItem.class));
}
}
}
}
//其他sheet
for (FormGroupDTO groupItem : resiFormItems.getGroupList()) {
if (groupItem.getItemList() == null) {
continue;
}
Map<String, FormItem> itemMap = otherSheetItems.getOrDefault(groupItem.getTableName(), new HashMap<>());
otherSheetItems.putIfAbsent(groupItem.getTableName(), itemMap);
for (FormItem2 formItem2 : groupItem.getItemList()) {
if (StringUtils.isBlank(formItem2.getColumnName())) {
continue;
}
if ("checkbox".equals(formItem2.getItemType()) || "select".equals(formItem2.getItemType()) || "radio".equals(formItem2.getItemType())) {
itemMap.put(formItem2.getColumnName().concat(formItem2.getColumnNum() == 0 ? "" : formItem2.getColumnNum().toString()), ConvertUtils.sourceToTarget(formItem2, FormItem.class));
}
}
}
Map<String, Map<String, FormItemResult>> otherSheetItems = buildItemMap(resiFormItems);
Map<String, Map<String, Object>> resiMainList = icResiUserService.getDataForExport(otherSheetItems.get(BASE_TABLE_NAME),new HashMap<>(), pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), BASE_TABLE_NAME, pageFormDTO.getConditions());
Map<String, Map<String, Object>> resiMainList = icResiUserService.getDataForExport(otherSheetItems.get(BASE_TABLE_NAME),new HashMap<>(), pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), BASE_TABLE_NAME, pageFormDTO.getConditions(),staffInfoCacheResult.getAgencyId(),staffOrgPath);
//resiMainList = (List<Map<String, Object>>)JSON.parse("[{\"IS_BDHJ\":\"1\",\"IS_SPECIAL\":\"1\",\"IS_XFRY\":\"0\",\"REMARKS\":\"beizhu\",\"IS_PARTY\":\"1\",\"icResiUserId\":\"yzmtest2\",\"HOME_ID\":\"中海国际社区一里城1号楼1单元101\",\"HOUSE_TYPE\":\"平房\",\"UNIT_NAME\":\"1单元\",\"GRID_ID\":\"市北区-市北区第三网格3\",\"IS_DB\":\"0\",\"GENDER\":\"男\",\"BIRTHDAY\":\"2021-10-04\",\"IS_VETERANS\":\"0\",\"IS_MB\":\"0\",\"IS_UNEMPLOYED\":\"0\",\"DEMAND_NAME\":null,\"IS_KC\":\"0\",\"IS_ENSURE_HOUSE\":\"0\",\"IS_SD\":\"0\",\"NAME\":\"尹作梅\",\"RDSJ\":null,\"IS_VOLUNTEER\":\"1\",\"GRID_ID_VALUE\":\"e74829ffc43d5470eba6b5e060c11e63\",\"IS_SZ\":\"0\",\"IS_CJ\":\"0\",\"HOME_ID_VALUE\":\"200\",\"DEMAND_CATEGORY_IDS\":null,\"VILLAGE_NAME\":\"中海国际社区一里城\",\"IS_DBH\":\"0\",\"IS_SN\":\"0\",\"BUILD_NAME\":\"1号楼\",\"IS_YLFN\":\"0\",\"IS_UNITED_FRONT\":\"0\",\"ID_CARD\":\"371325199310260529\",\"MOBILE\":\"15764229697\",\"IS_OLD_PEOPLE\":\"0\",\"DOOR_NAME\":\"101\"},{\"IS_SPECIAL\":\"1\",\"IS_XFRY\":\"0\",\"REMARKS\":\"beizhu\",\"IS_PARTY\":\"1\",\"icResiUserId\":\"yzmtest\",\"HOME_ID\":\"中海国际社区一里城1号楼1单元101\",\"HOUSE_TYPE\":\"平房\",\"UNIT_NAME\":\"1单元\",\"GRID_ID\":\"市北区-市北区第三网格3\",\"IS_DB\":\"0\",\"GENDER\":\"男\",\"BIRTHDAY\":\"2021-10-04\",\"IS_VETERANS\":\"0\",\"IS_MB\":\"0\",\"IS_UNEMPLOYED\":\"0\",\"DEMAND_NAME\":\"心理咨询\",\"IS_KC\":\"0\",\"IS_ENSURE_HOUSE\":\"0\",\"IS_SD\":\"0\",\"NAME\":\"尹作梅\",\"RDSJ\":\"2021-10-28 00:00:00\",\"IS_VOLUNTEER\":\"1\",\"GRID_ID_VALUE\":\"e74829ffc43d5470eba6b5e060c11e63\",\"IS_SZ\":\"0\",\"IS_CJ\":\"0\",\"HOME_ID_VALUE\":\"200\",\"DEMAND_CATEGORY_IDS\":\"10180002\",\"VILLAGE_NAME\":\"中海国际社区一里城\",\"IS_DBH\":\"0\",\"IS_SN\":\"0\",\"BUILD_NAME\":\"1号楼\",\"IS_YLFN\":\"0\",\"IS_UNITED_FRONT\":\"0\",\"ID_CARD\":\"371325199310260529\",\"MOBILE\":\"15764229697\",\"IS_OLD_PEOPLE\":\"0\",\"DOOR_NAME\":\"101\"}]");
log.info("resiMainList:{}", JSON.toJSONString(resiMainList));
String templatePath = "excel/ic_resi_info_cid.xls";
@ -241,12 +206,12 @@ public class IcResiUserController {
System.out.println("===resiMainList==="+" "+JSON.toJSONString(resiMainList.values()));
sheetMap.put(0, mapData);
AtomicInteger n = new AtomicInteger();
for (FormItem item : resiFormItems.getItemList()) {
for (FormItemResult item : resiFormItems.getItemList()) {
if (item.getChildGroup() != null) {
if (!item.getChildGroup().getTableName().equals(BASE_TABLE_NAME)) {
Map<String, FormItem> itemMap1 = otherSheetItems.get(item.getChildGroup().getTableName());
Map<String, Map<String, Object>> resiChildMap = icResiUserService.getDataForExport(itemMap1,resiMainList, pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), item.getChildGroup().getTableName(), pageFormDTO.getConditions());
Map<String, FormItemResult> itemMap1 = otherSheetItems.get(item.getChildGroup().getTableName());
Map<String, Map<String, Object>> resiChildMap = icResiUserService.getDataForExport(itemMap1,resiMainList, pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), item.getChildGroup().getTableName(), pageFormDTO.getConditions(),staffInfoCacheResult.getAgencyId(),staffOrgPath);
//resiChildMap.forEach((key, value) -> value.putAll(resiMainList.get(key)));
Map<String, Object> mapData2 = new HashMap<>();
@ -263,58 +228,25 @@ public class IcResiUserController {
}
@RequestMapping(value = "/exportExcel")
public void exportExcelByEasyExcel(@RequestHeader String customerId, @RequestBody IcResiUserPageFormDTO pageFormDTO, HttpServletResponse response) throws Exception {
public void exportExcelByEasyExcel(@RequestHeader String customerId,@LoginUser TokenDto tokenDto, @RequestBody IcResiUserPageFormDTO pageFormDTO, HttpServletResponse response) throws Exception {
//tokenDto.setUserId("9e37adcce6472152e6508a19d3683e02");
CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(customerId, tokenDto.getUserId());
String staffOrgPath = null;
if (StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds()) && !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())) {
staffOrgPath = staffInfoCacheResult.getAgencyPIds().concat(":").concat(staffInfoCacheResult.getAgencyId());
}else{
staffOrgPath=staffInfoCacheResult.getAgencyId();
}
pageFormDTO.setCustomerId(customerId);
pageFormDTO.setPageFlag(false);
CustomerFormResultDTO resiFormItems = getResiFormItems(pageFormDTO.getCustomerId());
CustomerFormResultDTO resiFormItems = getResiFormAddItems(pageFormDTO.getCustomerId());
Map<String, Map<String, FormItemResult>> otherSheetItems = buildItemMap(resiFormItems);
Map<String, Map<String, FormItem>> otherSheetItems = new HashMap<>();
/*List<FormItemResult> resiFormAllItems = getResiFormAllItems(pageFormDTO.getCustomerId());
resiFormAllItems.stream().collect(Collectors.groupingBy(e ->e.get));*/
//主表的
for (FormItem formItem : resiFormItems.getItemList()) {
if (StringUtils.isBlank(formItem.getColumnName())) {
continue;
}
Map<String, FormItem> itemMap = otherSheetItems.getOrDefault(formItem.getTableName(), new HashMap<>());
otherSheetItems.putIfAbsent(formItem.getTableName(), itemMap);
if (formItem.getItemType().equals("checkbox") || formItem.getItemType().equals("select") || formItem.getItemType().equals("radio")) {
itemMap.put(formItem.getColumnName().concat(formItem.getColumnNum() == 0 ? "" : formItem.getColumnNum().toString()), formItem);
}
if (formItem.getChildGroup() != null) {
itemMap = otherSheetItems.getOrDefault(formItem.getChildGroup().getTableName(), new HashMap<>());
otherSheetItems.putIfAbsent(formItem.getChildGroup().getTableName(), itemMap);
for (FormItem2 item2 : formItem.getChildGroup().getItemList()) {
if (StringUtils.isBlank(item2.getColumnName())) {
continue;
}
if ("checkbox".equals(item2.getItemType()) || "select".equals(item2.getItemType()) || "radio".equals(item2.getItemType())) {
itemMap.put(item2.getColumnName().concat(item2.getColumnNum() == 0 ? "" : item2.getColumnNum().toString()), ConvertUtils.sourceToTarget(item2, FormItem.class));
}
}
}
}
//其他sheet
for (FormGroupDTO groupItem : resiFormItems.getGroupList()) {
if (groupItem.getItemList() == null) {
continue;
}
Map<String, FormItem> itemMap = otherSheetItems.getOrDefault(groupItem.getTableName(), new HashMap<>());
otherSheetItems.putIfAbsent(groupItem.getTableName(), itemMap);
for (FormItem2 formItem2 : groupItem.getItemList()) {
if (StringUtils.isBlank(formItem2.getColumnName())) {
continue;
}
if ("checkbox".equals(formItem2.getItemType()) || "select".equals(formItem2.getItemType()) || "radio".equals(formItem2.getItemType())) {
itemMap.put(formItem2.getColumnName().concat(formItem2.getColumnNum() == 0 ? "" : formItem2.getColumnNum().toString()), ConvertUtils.sourceToTarget(formItem2, FormItem.class));
}
}
}
Map<String, Map<String, Object>> resiMainList = icResiUserService.getDataForExport(otherSheetItems.get(BASE_TABLE_NAME),new HashMap<>(), pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), BASE_TABLE_NAME, pageFormDTO.getConditions());
Map<String, Map<String, Object>> resiMainList = icResiUserService.getDataForExport(otherSheetItems.get(BASE_TABLE_NAME),new HashMap<>(), pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), BASE_TABLE_NAME, pageFormDTO.getConditions(),staffInfoCacheResult.getAgencyId(),staffOrgPath);
//=========================================
String templatePath = "excel/ic_resi_info_cid_for_easy_excel.xlsx";
@ -329,12 +261,12 @@ public class IcResiUserController {
//=======================================
AtomicInteger n = new AtomicInteger();
for (FormItem item : resiFormItems.getItemList()) {
for (FormItemResult item : resiFormItems.getItemList()) {
if (item.getChildGroup() != null) {
if (!item.getChildGroup().getTableName().equals(BASE_TABLE_NAME)) {
Map<String, FormItem> itemMap1 = otherSheetItems.get(item.getChildGroup().getTableName());
Map<String, Map<String, Object>> resiChildMap = icResiUserService.getDataForExport(itemMap1,resiMainList, pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), item.getChildGroup().getTableName(), pageFormDTO.getConditions());
Map<String, FormItemResult> itemMap1 = otherSheetItems.get(item.getChildGroup().getTableName());
Map<String, Map<String, Object>> resiChildMap = icResiUserService.getDataForExport(itemMap1,resiMainList, pageFormDTO.getCustomerId(), pageFormDTO.getFormCode(), item.getChildGroup().getTableName(), pageFormDTO.getConditions(),staffInfoCacheResult.getAgencyId(),staffOrgPath);
//resiChildMap.forEach((key, value) -> value.putAll(resiMainList.get(key)));
int sheetNo = n.incrementAndGet();
@ -348,6 +280,57 @@ public class IcResiUserController {
excelWriter.finish();
}
@NotNull
private Map<String, Map<String, FormItemResult>> buildItemMap(CustomerFormResultDTO resiFormItems) {
Map<String, Map<String, FormItemResult>> otherSheetItems = new HashMap<>();
//主表的
for (FormItemResult formItemResult : resiFormItems.getItemList()) {
if (StringUtils.isBlank(formItemResult.getColumnName())) {
continue;
}
Map<String, FormItemResult> itemMap = otherSheetItems.getOrDefault(formItemResult.getTableName(), new HashMap<>());
otherSheetItems.putIfAbsent(formItemResult.getTableName(), itemMap);
if (formItemResult.getItemType().equals("checkbox") || formItemResult.getItemType().equals("select") || formItemResult.getItemType().equals("radio")) {
itemMap.put(formItemResult.getColumnName().concat(formItemResult.getColumnNum() == 0 ? "" : formItemResult.getColumnNum().toString()), formItemResult);
}
if (formItemResult.getChildGroup() != null) {
itemMap = otherSheetItems.getOrDefault(formItemResult.getChildGroup().getTableName(), new HashMap<>());
otherSheetItems.putIfAbsent(formItemResult.getChildGroup().getTableName(), itemMap);
for (FormItemResult2 item2 : formItemResult.getChildGroup().getItemList()) {
if (StringUtils.isBlank(item2.getColumnName())) {
continue;
}
if ("checkbox".equals(item2.getItemType()) || "select".equals(item2.getItemType()) || "radio".equals(item2.getItemType())) {
itemMap.put(item2.getColumnName().concat(item2.getColumnNum() == 0 ? "" : item2.getColumnNum().toString()), ConvertUtils.sourceToTarget(item2, FormItemResult.class));
}
}
}
}
//其他sheet
for (FormGroupDTO groupItem : resiFormItems.getGroupList()) {
if (groupItem.getItemList() == null) {
continue;
}
Map<String, FormItemResult> itemMap = otherSheetItems.getOrDefault(groupItem.getTableName(), new HashMap<>());
otherSheetItems.putIfAbsent(groupItem.getTableName(), itemMap);
for (FormItemResult2 formItemResult2 : groupItem.getItemList()) {
if (StringUtils.isBlank(formItemResult2.getColumnName())) {
continue;
}
if ("checkbox".equals(formItemResult2.getItemType()) || "select".equals(formItemResult2.getItemType()) || "radio".equals(formItemResult2.getItemType())) {
itemMap.put(formItemResult2.getColumnName().concat(formItemResult2.getColumnNum() == 0 ? "" : formItemResult2.getColumnNum().toString()), ConvertUtils.sourceToTarget(formItemResult2, FormItemResult.class));
}
}
}
return otherSheetItems;
}
private static OutputStream getOutputStream(String fileName, HttpServletResponse response) throws Exception {
fileName = URLEncoder.encode(fileName, "UTF-8");
response.setContentType("application/vnd.ms-excel");
@ -397,13 +380,14 @@ public class IcResiUserController {
}
@PostMapping("test")
public Result<List<Map<String, Object>>> test(@RequestBody DynamicQueryFormDTO formDTO) {
public Result<List<Map<String, Object>>> test(@LoginUser TokenDto tokenDto,@RequestBody DynamicQueryFormDTO formDTO) {
formDTO.setCustomerId("45687aa479955f9d06204d415238f7cc");
//formDTO.setCustomerId(tokenDto.getCustomerId());
return new Result<List<Map<String, Object>>>().ok(icResiUserService.dynamicQuery(formDTO.getCustomerId(),
formDTO.getFormCode(),
formDTO.getResultTableName(),
formDTO.getConditions()));
formDTO.getConditions(),
tokenDto.getUserId(),null));
}
/**
@ -431,7 +415,7 @@ public class IcResiUserController {
}
@NotNull
private CustomerFormResultDTO getResiFormItems(String customerId) {
private CustomerFormResultDTO getResiFormAddItems(String customerId) {
CustomerFormQueryDTO queryDTO = new CustomerFormQueryDTO();
queryDTO.setFormCode("resi_base_info");
queryDTO.setCustomerId(customerId);
@ -443,6 +427,19 @@ public class IcResiUserController {
return resultForm.getData();
}
@NotNull
private List<FormItemResult> getResiFormAllItems(String customerId) {
CustomerFormQueryDTO queryDTO = new CustomerFormQueryDTO();
queryDTO.setFormCode("resi_base_info");
queryDTO.setCustomerId(customerId);
Result<List<FormItemResult>> resultForm = operCustomizeOpenFeignClient.listItems(queryDTO);
if (resultForm == null || !resultForm.success() || resultForm.getData() == null) {
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
}
System.out.println(JSON.toJSONString(resultForm.getData()));
return resultForm.getData();
}
/**
* @Description 个人信息-家庭关系
* @Param formDTO

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

4
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java

@ -100,7 +100,9 @@ public interface IcResiUserDao extends BaseDao<IcResiUserEntity> {
List<Map<String,Object>> dynamicQuery(@Param("customerId")String customerId,
@Param("resultTableName")String resultTableName,
@Param("conditions") List<ResiUserQueryValueDTO> conditions,
@Param("subTables") List<String> subTables);
@Param("subTables") List<String> subTables,
@Param("currentStaffAgencyId")String currentStaffAgencyId,
@Param("staffOrgPath")String staffOrgPath);
/**
* @Description 查询个人信息

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

7
epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java

@ -80,7 +80,9 @@ public interface IcResiUserService extends BaseService<IcResiUserEntity> {
List<Map<String,Object>> dynamicQuery(String customerId,
String formCode,
String resultTableName,
List<ResiUserQueryValueDTO> conditions);
List<ResiUserQueryValueDTO> conditions,
String currentStaffAgencyId,
String staffOrgPath);
/**
* @Description 查询个人数据
@ -111,7 +113,8 @@ public interface IcResiUserService extends BaseService<IcResiUserEntity> {
* @param conditions
* @return
*/
Map<String, Map<String, Object>> getDataForExport(Map<String, FormItem> itemList, Map<String, Map<String, Object>> resiMainList, String customerId, String formCode, String baseTableName, List<ResiUserQueryValueDTO> conditions);
Map<String, Map<String, Object>> getDataForExport(Map<String, FormItemResult> itemList, Map<String, Map<String, Object>> resiMainList, String customerId, String formCode, String baseTableName, List<ResiUserQueryValueDTO> conditions,String currentStaffAgencyId,
String staffOrgPath);
/**
* @Description 家庭关系

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

23
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java

@ -5,7 +5,6 @@ import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.EasyExcelFactory;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.dto.result.OptionResultDTO;
@ -21,7 +20,7 @@ import com.epmet.dto.form.AgencyIdFormDTO;
import com.epmet.dto.form.CustomerFormQueryDTO;
import com.epmet.dto.form.HouseFormDTO;
import com.epmet.dto.form.LoginUserDetailsFormDTO;
import com.epmet.dto.result.FormItem;
import com.epmet.dto.result.FormItemResult;
import com.epmet.dto.result.LoginUserDetailsResultDTO;
import com.epmet.dto.result.OptionDTO;
import com.epmet.entity.IcResiUserEntity;
@ -262,7 +261,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
Map<Integer, List<String>> headers = mergeHead(headList);
// 查询form相关信息
List<FormItem> customerItems = listFormItems(IMPORT_IC_RESI_FORM_CODE);
List<FormItemResult> customerItems = listFormItems(IMPORT_IC_RESI_FORM_CODE);
// 清洗表头数据
Map<Integer, String> abandonedHeaders = washHeaders(headers, customerItems);
@ -271,7 +270,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
HashMap<String, List<Integer>> combinedHeaders = combineHeaders(headers);
// 得到客户配置item数据
Map<String, FormItem> formItemMap = customerItems.stream().collect(
Map<String, FormItemResult> formItemMap = customerItems.stream().collect(
Collectors.toMap(formItem -> {
String groupLabel = formItem.getGroupLabel();
String label = formItem.getLabel();
@ -311,7 +310,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
Map<Integer, List<String>> headers = mergeHead(headList);
// 查询form相关信息
List<FormItem> customerItems = listFormItems(IMPORT_IC_RESI_FORM_CODE);
List<FormItemResult> customerItems = listFormItems(IMPORT_IC_RESI_FORM_CODE);
// 清洗表头数据
Map<Integer, String> abandonedHeaders = washHeaders(headers, customerItems);
@ -320,7 +319,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
HashMap<String, List<Integer>> combinedHeaders = combineHeaders(headers);
// 得到客户配置item数据
Map<String, FormItem> formItemMap = customerItems.stream().collect(
Map<String, FormItemResult> formItemMap = customerItems.stream().collect(
Collectors.toMap(formItem -> {
String groupLabel = formItem.getGroupLabel();
String label = formItem.getLabel();
@ -461,7 +460,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
// skipedRow.setInfo("信息已存在,跳过导入");
// skipedRow.setTableName(targetTableName);
// skipedRows.get().get(targetTableName).add(skipedRow);
//
//
// continue;
//}
@ -603,10 +602,10 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
* @param formCode
* @return
*/
private List<FormItem> listFormItems(String formCode) {
private List<FormItemResult> listFormItems(String formCode) {
CustomerFormQueryDTO form = new CustomerFormQueryDTO();
form.setFormCode(formCode);
Result<List<FormItem>> result = operCustomizeOpenFeignClient.listItems(form);
Result<List<FormItemResult>> result = operCustomizeOpenFeignClient.listItems(form);
return getResultDataOrThrowsException(result, ServiceConstant.OPER_CUSTOMIZE_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【居民信息excel导入】查询表单相关信息失败");
}
@ -643,7 +642,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
* @author wxz
* @date 2021.10.28 21:07:12
*/
private Map<Integer, String> washHeaders(Map<Integer, List<String>> headers, List<FormItem> items) {
private Map<Integer, String> washHeaders(Map<Integer, List<String>> headers, List<FormItemResult> items) {
List<String> itemLabels = items.stream().map(i -> i.getLabel()).collect(Collectors.toList());
Map<Integer, String> abandonedHeaders = new HashMap<>();
for (Map.Entry<Integer, List<String>> entry:headers.entrySet()) {
@ -675,7 +674,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
* @param abandonedHeaders
* @return
*/
private Map<String, ColumnWrapper> convertExcelHeaders2DBColumnWrappers(Map<String, FormItem> formItemMap, Map<String, List<Integer>> combinedHeaders,
private Map<String, ColumnWrapper> convertExcelHeaders2DBColumnWrappers(Map<String, FormItemResult> formItemMap, Map<String, List<Integer>> combinedHeaders,
List<Map<Integer, String>> datas, Map<Integer, String> abandonedHeaders) {
// HashMap<String, List<ColumnWrapper>> tables = new HashMap<>();
@ -684,7 +683,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
for (Map.Entry<String, List<Integer>> entry : combinedHeaders.entrySet()) {
String combinedHeader = entry.getKey();
FormItem item = formItemMap.get(combinedHeader);
FormItemResult item = formItemMap.get(combinedHeader);
if (item == null) {
// 如果数据库中没有该项,可能是用户自己定义的项,忽略

19
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java

@ -290,6 +290,8 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
String staffOrgPath=StrConstant.EPMETY_STR;
if(StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds())&& !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())){
staffOrgPath=staffInfoCacheResult.getAgencyPIds().concat(":").concat(staffInfoCacheResult.getAgencyId());
}else{
staffOrgPath=staffInfoCacheResult.getAgencyId();
}
// 查询列表展示项,如果没有,直接返回
@ -467,16 +469,19 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
public List<Map<String,Object>> dynamicQuery(String customerId,
String formCode,
String resultTableName,
List<ResiUserQueryValueDTO> conditions){
List<ResiUserQueryValueDTO> conditions,
String currentStaffAgencyId,
String staffOrgPath){
CustomerFormQueryDTO queryDTO=new CustomerFormQueryDTO();
queryDTO.setCustomerId(customerId);
queryDTO.setFormCode(formCode);
//所有的子表
Result<List<String>> subTablesRes=operCustomizeOpenFeignClient.querySubTables(queryDTO);
List<String> subTables=new ArrayList<>();
if(subTablesRes.success()&&CollectionUtils.isNotEmpty(subTablesRes.getData())){
subTables =subTablesRes.getData();
}
return baseDao.dynamicQuery(customerId,resultTableName,conditions,subTables);
return baseDao.dynamicQuery(customerId,resultTableName,conditions,subTables,currentStaffAgencyId,staffOrgPath);
}
/**
@ -616,8 +621,10 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
* @return
*/
@Override
public Map<String, Map<String, Object>> getDataForExport(Map<String, FormItem> formItemMap, Map<String, Map<String, Object>> resiMainList, String customerId, String formCode, String baseTableName, List<ResiUserQueryValueDTO> conditions) {
List<Map<String, Object>> mapList = this.dynamicQuery(customerId, formCode, baseTableName, conditions);
public Map<String, Map<String, Object>> getDataForExport(Map<String, FormItemResult> formItemMap, Map<String, Map<String, Object>> resiMainList, String customerId, String formCode, String baseTableName, List<ResiUserQueryValueDTO> conditions,
String currentStaffAgencyId,
String staffOrgPath) {
List<Map<String, Object>> mapList = this.dynamicQuery(customerId, formCode, baseTableName, conditions,currentStaffAgencyId,staffOrgPath);
Map<String, Map<String, Object>> result = new LinkedHashMap<>();
mapList.stream().filter(Objects::nonNull).forEach(map -> {
map.forEach((k,o) -> {
@ -640,9 +647,9 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
return;
}
result.put(resiId, map);
for (Map.Entry<String, FormItem> e : formItemMap.entrySet()) {
for (Map.Entry<String, FormItemResult> e : formItemMap.entrySet()) {
String k = e.getKey();
FormItem v = e.getValue();
FormItemResult v = e.getValue();
Object temp = map.get(k);
String vauleStr = temp == null ? "" : temp.toString();

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

3
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StatsStaffPatrolRecordDailyServiceImpl.java

@ -47,6 +47,9 @@ public class StatsStaffPatrolRecordDailyServiceImpl extends BaseServiceImpl<Stat
return result;
}
public static void main(String[] args) {
System.out.println(DateUtils.getBeforeNDay(NumConstant.ZERO));
}
/**
* @Description 查询巡查次数和时长
* @Param agencyId

2
epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

@ -143,7 +143,7 @@
</if>
<where>
<include refid="listWhere"></include>
<include refid="listWhereForPage"></include>
</where>
group by IC_RESI_USER.id
order by ic_resi_user.CREATED_TIME desc

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>

6
epmet-user/epmet-user-server/src/test/java/com/epmet/epmetuser/test/IcResiUserControllerTest.java

@ -11,7 +11,7 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.CustomerFormQueryDTO;
import com.epmet.dto.result.CustomerFormResultDTO;
import com.epmet.dto.result.FormGroupDTO;
import com.epmet.dto.result.FormItem;
import com.epmet.dto.result.FormItemResult;
import com.epmet.feign.OperCustomizeOpenFeignClient;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@ -75,7 +75,7 @@ public class IcResiUserControllerTest {
private Map<String,List<ExcelExportEntity>> buildHeaderByItem(CustomerFormResultDTO resultForm) {
//form中的itemlist 为一级表头 但是要排除每个item中含有childGroup的
List<FormItem> itemList = resultForm.getItemList();
List<FormItemResult> itemList = resultForm.getItemList();
List<FormGroupDTO> groupList = resultForm.getGroupList();
Map<String,List<ExcelExportEntity>> everySheetHeaderMap = new LinkedHashMap<>();
@ -155,7 +155,7 @@ public class IcResiUserControllerTest {
return everySheetHeaderMap;
}
private void buildHeader(Map<String, List<ExcelExportEntity>> everySheetHeaderMap, FormItem item, ExcelExportEntity header) {
private void buildHeader(Map<String, List<ExcelExportEntity>> everySheetHeaderMap, FormItemResult item, ExcelExportEntity header) {
List<ExcelExportEntity> firstSheetHeaderList = new ArrayList<>();
List<ExcelExportEntity> secondHeaderList = new ArrayList<>();
item.getChildGroup().getItemList().forEach(item2->{

Loading…
Cancel
Save