diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/SyncOrgInfoFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/SyncOrgInfoFormDTO.java new file mode 100644 index 0000000000..bd1e2034f9 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/SyncOrgInfoFormDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.extract.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 描述一下 + * + * @author yinzuomei@elink-cn.com + * @date 2021/7/6 16:37 + */ +@Data +public class SyncOrgInfoFormDTO implements Serializable { + private static final long serialVersionUID = -3533276226280926966L; + @NotBlank(message = "孔村or榆山or锦水客户id不能为空") + private String fromCustomerId; + @NotBlank(message = "平阴客户id不能为空") + private String toCustomerId; +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java index a5317f5ba2..bfb8bdc42d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java @@ -6,6 +6,7 @@ import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.constant.DataSourceConstant; import com.epmet.constant.IndexCalConstant; import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityGridMonthlyDao; @@ -22,6 +23,7 @@ import com.epmet.dto.StatsFormDTO; import com.epmet.dto.extract.form.ExtractFactGridGovernDailyFromDTO; import com.epmet.dto.extract.form.ExtractOriginFormDTO; import com.epmet.dto.extract.form.ExtractScreenFormDTO; +import com.epmet.dto.extract.form.SyncOrgInfoFormDTO; import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.dto.screen.form.ScreenCentralZoneDataFormDTO; import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; @@ -42,6 +44,8 @@ import com.epmet.service.evaluationindex.extract.todata.*; import com.epmet.service.evaluationindex.extract.toscreen.*; import com.epmet.service.evaluationindex.indexcal.*; import com.epmet.service.evaluationindex.screen.*; +import com.epmet.service.org.CustomerAgencyService; +import com.epmet.service.org.CustomerGridService; import com.epmet.service.stats.DimAgencyService; import com.epmet.service.stats.DimCustomerPartymemberService; import lombok.extern.slf4j.Slf4j; @@ -936,4 +940,22 @@ public class DemoController { return new Result(); } + @Autowired + private CustomerAgencyService customerAgencyService; + @Autowired + private CustomerGridService customerGridService; + + + /** + * 将孔村、榆山、锦水3个街道的网格、组织插入到gov-org库的customer_grid、customer_agency + * + * @param formDTO + * @return Result + */ + @PostMapping("syncorginfo") + public Result syncOrgInfo(@RequestBody SyncOrgInfoFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + customerAgencyService.sysAgencyInfo(formDTO.getFromCustomerId(), formDTO.getToCustomerId()); + return new Result(); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java index b0dedb0db5..ebe3ff3783 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java @@ -34,7 +34,6 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; -import java.util.Map; /** * 组织机构信息 @@ -231,4 +230,10 @@ public interface ScreenCustomerAgencyDao extends BaseDao selectByPid(@Param("customerId") String customerId, @Param("parentAgencyId")String parentAgencyId); + + List selectKcCommunity(String customerId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerGridDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerGridDao.java index 6aa2aacc1c..90875a233a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerGridDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerGridDao.java @@ -216,4 +216,6 @@ public interface ScreenCustomerGridDao extends BaseDao * @date 2021/6/10 10:45 上午 */ List selectGridInfoList(@Param("customerId") String customerId, @Param("pids") String pids); + + List selectEntityByAgencyId(@Param("customerId") String customerId, @Param("parentAgencyId") String parentAgencyId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java index fc575d3024..5745ff7cca 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java @@ -69,4 +69,6 @@ public interface StatsCustomerAgencyDao extends BaseDao { * @return com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity */ CustomerAgencyEntity selectByDeptId(String deptId); + + CustomerAgencyEntity selecByAreaCode(@Param("customerId")String customerId, @Param("areaCode")String areaCode); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/org/CustomerAgencyEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/org/CustomerAgencyEntity.java index 4fbb9bfb83..f521f0aa60 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/org/CustomerAgencyEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/org/CustomerAgencyEntity.java @@ -108,4 +108,9 @@ public class CustomerAgencyEntity extends BaseEpmetEntity { * 社区 */ private String community; + + /** + * 是否同步到统计库和指标库,1同步。0不同步 + */ + private String syncFlag; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/org/CustomerGridEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/org/CustomerGridEntity.java index 6c01df7df8..dc760a4b5e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/org/CustomerGridEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/org/CustomerGridEntity.java @@ -79,4 +79,9 @@ public class CustomerGridEntity extends BaseEpmetEntity { * 所有上级组织ID */ private String pids; + + /** + * 是否同步到统计库和指标库,1同步。0不同步 + */ + private String syncFlag; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java index 86fbe9e336..5c303466aa 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java @@ -21,13 +21,11 @@ import com.epmet.dto.extract.form.PartyBaseInfoFormDTO; import com.epmet.dto.extract.form.ScreenPartyBranchDataFormDTO; import com.epmet.dto.extract.form.ScreenPartyLinkMassesDataFormDTO; import com.epmet.dto.extract.result.CustomerAgencyInfoResultDTO; - -import java.util.List; - import com.epmet.dto.extract.result.OrgNameResultDTO; import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity; import com.epmet.entity.org.CustomerAgencyEntity; +import java.util.List; import java.util.Map; /** @@ -114,4 +112,23 @@ public interface ScreenCustomerAgencyService{ * @date 2021/5/24 9:42 上午 */ ScreenCustomerAgencyEntity selectTopAgency(String customerId); + + /** + * 获取当前客户下的跟组织 + * + * @param customerId + * @return com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity + */ + ScreenCustomerAgencyEntity getRootAgency(String customerId); + + List getByPid(String customerId, String parentAgencyId); + + /** + * 查询出孔村的社区 + * + * @param customerId + * @return com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity + */ + List selectKcCommunity(String customerId); + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java index f2a40b11c0..358b102ea6 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java @@ -109,4 +109,6 @@ public interface ScreenCustomerGridService extends BaseService selectGridInfoByCustomerId(String customerId); List selectGridInfoList(String customerId, String pids); + + List selectEntityByAgencyId(String customerId, String parentAgencyId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java index 96019615ea..17b22866c6 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java @@ -267,5 +267,32 @@ public class ScreenCustomerAgencyServiceImpl implements ScreenCustomerAgencyServ return screenCustomerAgencyDao.selectTopAgency(customerId); } + /** + * 获取当前客户下的跟组织 + * + * @param customerId + * @return com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity + */ + @Override + public ScreenCustomerAgencyEntity getRootAgency(String customerId) { + return screenCustomerAgencyDao.selectRootAgency(customerId); + } + + @Override + public List getByPid(String customerId, String parentAgencyId) { + return screenCustomerAgencyDao.selectByPid(customerId,parentAgencyId); + } + + /** + * 查询出孔村的社区 + * + * @param customerId + * @return com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity + */ + @Override + public List selectKcCommunity(String customerId) { + return screenCustomerAgencyDao.selectKcCommunity(customerId); + } + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java index b012accfe0..11aa43e27b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java @@ -210,4 +210,9 @@ public class ScreenCustomerGridServiceImpl extends BaseServiceImpl selectGridInfoList(String customerId, String pids) { return baseDao.selectGridInfoList(customerId,pids); } + + @Override + public List selectEntityByAgencyId(String customerId, String parentAgencyId) { + return baseDao.selectEntityByAgencyId(customerId,parentAgencyId); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java index 0eb247471e..60991b69bf 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java @@ -48,4 +48,14 @@ public interface CustomerAgencyService { * @return com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity */ CustomerAgencyEntity getAgencyByDeptId(String deptId); + + /** + * 将孔村、榆山、锦水3个街道的组织插入到gov-org库的customer_agency + * + * @param fromCustomerId + * @param toCustomerId + * @return Result + */ + void sysAgencyInfo(String fromCustomerId, String toCustomerId); + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java index 2cdee8ccad..7ba6178809 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java @@ -1,5 +1,6 @@ package com.epmet.service.org; +import com.epmet.commons.mybatis.service.BaseService; import com.epmet.dto.group.AgencyDTO; import com.epmet.dto.group.result.AgencyGridTotalCountResultDTO; import com.epmet.dto.group.result.GridIdListByCustomerResultDTO; @@ -9,7 +10,7 @@ import com.epmet.entity.org.CustomerGridEntity; import java.util.Date; import java.util.List; -public interface CustomerGridService { +public interface CustomerGridService extends BaseService { /** * 根据创建时间,截取时间段内的网格 * @param start diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java index d603b6781c..a917038b1c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java @@ -1,15 +1,24 @@ package com.epmet.service.org.impl; import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.constant.StrConstant; import com.epmet.constant.DataSourceConstant; import com.epmet.dao.org.StatsCustomerAgencyDao; import com.epmet.dto.org.result.CustomerAreaCodeResultDTO; import com.epmet.dto.org.result.OrgStaffDTO; +import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity; +import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity; import com.epmet.entity.org.CustomerAgencyEntity; +import com.epmet.entity.org.CustomerGridEntity; +import com.epmet.service.evaluationindex.screen.ScreenCustomerAgencyService; +import com.epmet.service.evaluationindex.screen.ScreenCustomerGridService; import com.epmet.service.org.CustomerAgencyService; +import com.epmet.service.org.CustomerGridService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; import java.util.ArrayList; import java.util.Date; @@ -21,6 +30,12 @@ public class CustomerAgencyServiceImpl implements CustomerAgencyService { @Autowired private StatsCustomerAgencyDao customerAgencyDao; + @Autowired + private ScreenCustomerAgencyService screenCustomerAgencyService; + @Autowired + private ScreenCustomerGridService screenCustomerGridService; + @Autowired + private CustomerGridService customerGridService; @Override public List listAgenciesByCreateTime(Date statsStartTime, Date statsEndTime) { @@ -103,4 +118,145 @@ public class CustomerAgencyServiceImpl implements CustomerAgencyService { public CustomerAgencyEntity getAgencyByDeptId(String deptId) { return customerAgencyDao.selectByDeptId(deptId); } + + /** + * 将孔村、榆山、锦水3个街道的组织插入到gov-org库的customer_agency + * + * @param fromCustomerId + * @param toCustomerId + * @return Result + */ + @Override + public void sysAgencyInfo(String fromCustomerId, String toCustomerId) { + // 1、查询出平阴县组织信息 + CustomerAgencyEntity pingYin = customerAgencyDao.selecByAreaCode(toCustomerId, "370124"); + // 2、查询出街道 + ScreenCustomerAgencyEntity street = screenCustomerAgencyService.getRootAgency(fromCustomerId); + CustomerAgencyEntity insertStreetEntity = new CustomerAgencyEntity(); + insertStreetEntity.setCustomerId(pingYin.getCustomerId()); + insertStreetEntity.setPid(pingYin.getId()); + if(!StringUtils.isEmpty(pingYin.getPids())){ + insertStreetEntity.setPids(pingYin.getPids().concat(StrConstant.COLON).concat(pingYin.getId())); + }else{ + insertStreetEntity.setPids(pingYin.getId()); + } + insertStreetEntity.setAllParentName(pingYin.getOrganizationName()); + insertStreetEntity.setOrganizationName(street.getAgencyName()); + insertStreetEntity.setLevel("street"); + insertStreetEntity.setAreaCode(street.getAreaCode()); + insertStreetEntity.setSyncFlag("0"); + insertStreetEntity.setTotalUser(0); + insertStreetEntity.setProvince("山东省"); + insertStreetEntity.setCity("济南市"); + insertStreetEntity.setDistrict(pingYin.getOrganizationName()); + insertStreetEntity.setStreet(street.getAgencyName()); + insertStreetEntity.setCommunity(StrConstant.EPMETY_STR); + insertStreetEntity.setParentAreaCode(pingYin.getAreaCode()); + insertStreetEntity.setId(street.getAgencyId()); + // 3、插入街道 + if (null == customerAgencyDao.selectById(insertStreetEntity.getId())) { + customerAgencyDao.insert(insertStreetEntity); + } else { + customerAgencyDao.updateById(insertStreetEntity); + } + // 3.1、街道的直属网格 + this.insertCustomerGrid(street.getCustomerId(),street.getAgencyId(),insertStreetEntity); + + if ("2fe0065f70ca0e23ce4c26fca5f1d933".equals(fromCustomerId)) { + List kcCommunityList = screenCustomerAgencyService.selectKcCommunity(fromCustomerId); + for(ScreenCustomerAgencyEntity kcCommunity:kcCommunityList){ + CustomerAgencyEntity insertCommunityEntity = new CustomerAgencyEntity(); + insertCommunityEntity.setCustomerId(pingYin.getCustomerId()); + insertCommunityEntity.setPid(insertStreetEntity.getId()); + insertCommunityEntity.setPids(insertStreetEntity.getPids().concat(StrConstant.COLON).concat(insertStreetEntity.getId())); + insertCommunityEntity.setAllParentName(insertStreetEntity.getAllParentName().concat(StrConstant.HYPHEN).concat(insertStreetEntity.getOrganizationName())); + insertCommunityEntity.setOrganizationName(kcCommunity.getAgencyName()); + insertCommunityEntity.setLevel("community"); + insertCommunityEntity.setAreaCode(kcCommunity.getAreaCode()); + insertCommunityEntity.setSyncFlag(NumConstant.ZERO_STR); + insertCommunityEntity.setTotalUser(NumConstant.ZERO); + insertCommunityEntity.setProvince("山东省"); + insertCommunityEntity.setCity("济南市"); + insertCommunityEntity.setDistrict(pingYin.getOrganizationName()); + insertCommunityEntity.setStreet(insertStreetEntity.getOrganizationName()); + insertCommunityEntity.setCommunity(kcCommunity.getAgencyName()); + insertCommunityEntity.setParentAreaCode(insertStreetEntity.getAreaCode()); + insertCommunityEntity.setId(kcCommunity.getAgencyId()); + CustomerAgencyEntity customerAgencyEntity=customerAgencyDao.selectById(insertCommunityEntity.getId()); + if(null==customerAgencyEntity){ + // 4、插入社区 + customerAgencyDao.insert(insertCommunityEntity); + }else{ + customerAgencyDao.updateById(insertCommunityEntity); + } + // 4.1插入社区下的直属网格 + this.insertCustomerGrid(kcCommunity.getCustomerId(),kcCommunity.getAgencyId(),insertCommunityEntity); + } + } else { + // 4、查询出社区 + List communityList = screenCustomerAgencyService.getByPid(fromCustomerId,street.getAgencyId()); + for(ScreenCustomerAgencyEntity community:communityList){ + CustomerAgencyEntity insertCommunityEntity = new CustomerAgencyEntity(); + insertCommunityEntity.setCustomerId(pingYin.getCustomerId()); + insertCommunityEntity.setPid(insertStreetEntity.getId()); + insertCommunityEntity.setPids(insertStreetEntity.getPids().concat(StrConstant.COLON).concat(insertStreetEntity.getId())); + insertCommunityEntity.setAllParentName(insertStreetEntity.getAllParentName().concat(StrConstant.HYPHEN).concat(insertStreetEntity.getOrganizationName())); + insertCommunityEntity.setOrganizationName(community.getAgencyName()); + insertCommunityEntity.setLevel("community"); + insertCommunityEntity.setAreaCode(community.getAreaCode()); + insertCommunityEntity.setSyncFlag(NumConstant.ZERO_STR); + insertCommunityEntity.setTotalUser(NumConstant.ZERO); + insertCommunityEntity.setProvince("山东省"); + insertCommunityEntity.setCity("济南市"); + insertCommunityEntity.setDistrict(pingYin.getOrganizationName()); + insertCommunityEntity.setStreet(insertStreetEntity.getOrganizationName()); + insertCommunityEntity.setCommunity(community.getAgencyName()); + insertCommunityEntity.setParentAreaCode(insertStreetEntity.getAreaCode()); + insertCommunityEntity.setId(community.getAgencyId()); + CustomerAgencyEntity customerAgencyEntity=customerAgencyDao.selectById(insertCommunityEntity.getId()); + if(null==customerAgencyEntity){ + customerAgencyDao.insert(insertCommunityEntity); + }else{ + customerAgencyDao.updateById(insertCommunityEntity); + } + // 4.1插入社区下的直属网格 + this.insertCustomerGrid(community.getCustomerId(),community.getAgencyId(),insertCommunityEntity); + } + + } + } + + /** + * @return void + * @param customerId 孔村、榆山、锦水的客户id + * @param agencyId 孔村、榆山、锦水的组织id + * @param parentCustomerEntity 在平阴客户里,网格所属组织信息 + * @author yinzuomei + * @description 将3个街道的网格,插入到gov-org.customer_grid库 + * @Date 2021/7/7 9:54 + **/ + private void insertCustomerGrid(String customerId, String agencyId, CustomerAgencyEntity parentCustomerEntity) { + List gridEntityList = screenCustomerGridService.selectEntityByAgencyId(customerId, agencyId); + for (ScreenCustomerGridEntity gridEntity : gridEntityList) { + CustomerGridEntity insertGrid = new CustomerGridEntity(); + insertGrid.setId(gridEntity.getGridId()); + insertGrid.setCustomerId(parentCustomerEntity.getCustomerId()); + insertGrid.setGridName(gridEntity.getGridName()); + insertGrid.setAreaCode(gridEntity.getAreaCode()); + insertGrid.setSyncFlag(NumConstant.ZERO_STR); + insertGrid.setManageDistrict(gridEntity.getGridName()); + insertGrid.setTotalUser(NumConstant.ZERO); + insertGrid.setPid(gridEntity.getParentAgencyId()); + if(StringUtils.isEmpty(parentCustomerEntity.getPids())){ + insertGrid.setPids(insertGrid.getPid()); + }else{ + insertGrid.setPids(parentCustomerEntity.getPids().concat(StrConstant.COLON).concat(insertGrid.getPid())); + } + if (null == customerGridService.selectById(insertGrid.getId())) { + customerGridService.insert(insertGrid); + } else { + customerGridService.updateById(insertGrid); + } + } + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java index fa8018e1e1..70e321f702 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java @@ -1,6 +1,7 @@ package com.epmet.service.org.impl; import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.constant.DataSourceConstant; import com.epmet.dao.org.CustomerGridDao; import com.epmet.dto.group.AgencyDTO; @@ -9,7 +10,6 @@ import com.epmet.dto.group.result.GridIdListByCustomerResultDTO; import com.epmet.dto.org.GridInfoDTO; import com.epmet.entity.org.CustomerGridEntity; import com.epmet.service.org.CustomerGridService; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; @@ -17,14 +17,11 @@ import java.util.List; @Service @DataSource(DataSourceConstant.GOV_ORG) -public class CustomerGridServiceImpl implements CustomerGridService { - - @Autowired - private CustomerGridDao customerGridDao; +public class CustomerGridServiceImpl extends BaseServiceImpl implements CustomerGridService { @Override public List listGridsByCreateTime(Date start, Date end) { - return customerGridDao.listGridsByCreateTime(start, end); + return baseDao.listGridsByCreateTime(start, end); } /** @@ -34,7 +31,7 @@ public class CustomerGridServiceImpl implements CustomerGridService { */ @Override public List selectAgencyGridTotalCount(List community, String dateId) { - return customerGridDao.selectAgencyGridTotalCount(community,dateId); + return baseDao.selectAgencyGridTotalCount(community,dateId); } /** @@ -45,12 +42,12 @@ public class CustomerGridServiceImpl implements CustomerGridService { */ @Override public List getCustomerGridIdList(String customerId, String dateId) { - return customerGridDao.getCustomerGridIdList(customerId, dateId); + return baseDao.getCustomerGridIdList(customerId, dateId); } @Override public List listUpdatedGridsByUpdateTime(Date lastInitTime, Date now) { - return customerGridDao.listUpdatedGridsByUpdateTime(lastInitTime, now); + return baseDao.listUpdatedGridsByUpdateTime(lastInitTime, now); } /** @@ -62,6 +59,6 @@ public class CustomerGridServiceImpl implements CustomerGridService { **/ @Override public List queryGridInfoList(String customerId) { - return customerGridDao.selectListGridInfo(customerId); + return baseDao.selectListGridInfo(customerId); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml index b60f152f95..4640aeebe6 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml @@ -452,4 +452,37 @@ DEL_FLAG = 0 AND CUSTOMER_ID = #{customerId} + + + + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerGridDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerGridDao.xml index 0fca6febf5..3838261c45 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerGridDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerGridDao.xml @@ -386,4 +386,19 @@ AND cg.ALL_PARENT_IDS like concat(#{pids},'%') + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml index 7aa2bf3422..a35631c893 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml @@ -9,6 +9,7 @@ FROM customer_grid DEL_FLAG = 0 + AND SYNC_FLAG='1' AND CREATED_TIME >= #{start} @@ -65,7 +66,8 @@ pid, pids FROM customer_grid - WHERE UPDATED_TIME >= #{startTime} + WHERE SYNC_FLAG='1' + AND UPDATED_TIME >= #{startTime} AND UPDATED_TIME #{endTime} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml index cf3ce06acc..c0209242e6 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml @@ -16,6 +16,7 @@ FROM customer_agency DEL_FLAG = 0 + AND SYNC_FLAG='1' AND CREATED_TIME >= #{statsStartTime} @@ -97,7 +98,8 @@ district, PARENT_AREA_CODE as parentAreaCode from customer_agency - where UPDATED_TIME >= #{startTime} + where SYNC_FLAG='1' + AND UPDATED_TIME >= #{startTime} and UPDATED_TIME #{endTime} @@ -191,4 +193,15 @@ AND cd.DEL_FLAG = '0' ) + +