diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenProjectOrgDailyDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenProjectOrgDailyDao.xml index f050e5dd1b..27d91a7f2a 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenProjectOrgDailyDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenProjectOrgDailyDao.xml @@ -43,7 +43,7 @@ INNER JOIN screen_customer_agency a ON ( m.ORG_ID = a.AGENCY_ID AND a.DEL_FLAG = '0' ) WHERE m.DEL_FLAG = '0' - AND a.AREA_CODE LIKE concat( #{areaCode}, '%') + AND a.PARENT_AREA_CODE=#{areaCode} AND M.DATE_ID=( select t1.DATE_ID from screen_project_org_daily t1 where t1.DEL_FLAG='0' 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 4d9a22030a..1dd85ba74a 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 @@ -790,8 +790,8 @@ public class DemoController { @RequestParam("dateId") String dateId, @RequestParam("monthId") String monthId) { screenProjectGridDailyService.extractionProjectGridDaily(customerId, dateId); - screenProjectOrgDailyService.extractionProjectOrgDaily(customerId, dateId); screenProjectQuantityGridMonthlyService.extractionProjectGridMonthly(customerId, monthId); + screenProjectOrgDailyService.extractionProjectOrgDaily(customerId, dateId); screenProjectQuantityOrgMonthlyService.extractionProjectOrgMonthly(customerId, monthId); return new Result(); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerRelationDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerRelationDao.java index 87a8db63bf..fabee946e7 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerRelationDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerRelationDao.java @@ -23,6 +23,8 @@ import com.epmet.entity.crm.CustomerRelationEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * 客户关系表(01.14 add) * @@ -39,4 +41,6 @@ public interface CustomerRelationDao extends BaseDao { * @Date 2021/1/21 11:27 **/ CustomerSubInfoDTO selectCustomerSubInfo(@Param("customerId")String customerId); + + List selectListByPids(String customerId); } \ No newline at end of file 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 de96e0abd3..f61e21f2ad 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 @@ -192,4 +192,6 @@ public interface ScreenCustomerAgencyDao extends BaseDao selectAgencyByCustomer(@Param("customerId")String customerId); + + List selectAgencyByAreaCode(String areaCode); } 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 9c1217bd02..05a85d3d7c 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 @@ -31,4 +31,6 @@ public interface StatsCustomerAgencyDao extends BaseDao { * @date 2021/1/14 上午11:07 */ List selectCustomerAreaCodeById(@Param("customerIds") List customerIds); + + CustomerAgencyEntity getRootAgencyInfo(String customerId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerRelationService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerRelationService.java index 25e3272436..7d9a9f8aca 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerRelationService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerRelationService.java @@ -41,4 +41,6 @@ public interface CustomerRelationService extends BaseService getCustomerInfoMap(List customerIds); + + boolean haveSubCustomer(String customerId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerRelationServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerRelationServiceImpl.java index 440491f8a5..ac09dc001a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerRelationServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerRelationServiceImpl.java @@ -73,4 +73,13 @@ public class CustomerRelationServiceImpl extends BaseServiceImpl customer)); } + + @Override + public boolean haveSubCustomer(String customerId) { + List list=baseDao.selectListByPids(customerId); + if(null==list||list.isEmpty()){ + return false; + } + return true; + } } \ 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/ScreenProjectOrgDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectOrgDailyServiceImpl.java index 3f69596cd3..b5c71b558b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectOrgDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectOrgDailyServiceImpl.java @@ -23,7 +23,6 @@ import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; -import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.constant.DataSourceConstant; @@ -34,7 +33,10 @@ import com.epmet.dto.pingyin.result.ProjectOrgDailyResultDTO; import com.epmet.dto.screen.ScreenProjectOrgDailyDTO; import com.epmet.dto.screencoll.ScreenCollFormDTO; import com.epmet.entity.evaluationindex.screen.ScreenProjectOrgDailyEntity; +import com.epmet.entity.org.CustomerAgencyEntity; +import com.epmet.service.crm.CustomerRelationService; import com.epmet.service.evaluationindex.screen.ScreenProjectOrgDailyService; +import com.epmet.service.org.CustomerAgencyService; import com.google.common.collect.Lists; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.ListUtils; @@ -45,6 +47,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -62,6 +65,10 @@ public class ScreenProjectOrgDailyServiceImpl extends BaseServiceImpl page(Map params) { @@ -148,9 +155,18 @@ public class ScreenProjectOrgDailyServiceImpl extends BaseServiceImpl agencyInfos = agencyDao.selectAgencyByCustomer(customerId); + List agencyInfos = new ArrayList<>(); + //如果有子客户要按照跟组织的area_code查询组织列表 + if(customerRelationService.haveSubCustomer(customerId)){ + // + CustomerAgencyEntity rootAgency=customerAgencyService.getRootAgencyInfo(customerId); + agencyInfos=agencyDao.selectAgencyByAreaCode(rootAgency.getAreaCode()); + }else{ + agencyInfos=agencyDao.selectAgencyByCustomer(customerId); + } if (CollectionUtils.isEmpty(agencyInfos)){ - throw new RenException(String.format(PingYinConstants.AGENCY_INFO_IS_ZERO,customerId)); + log.warn(String.format(PingYinConstants.AGENCY_INFO_IS_ZERO,customerId)); + return; } List projectOrgDaily = baseDao.selectOrgProject(agencyInfos, dateId); if (CollectionUtils.isEmpty(projectOrgDaily)){ diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectQuantityOrgMonthlyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectQuantityOrgMonthlyServiceImpl.java index 15b8a46201..960f863d95 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectQuantityOrgMonthlyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectQuantityOrgMonthlyServiceImpl.java @@ -23,7 +23,6 @@ import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; -import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.constant.DataSourceConstant; @@ -35,7 +34,10 @@ import com.epmet.dto.screen.ScreenProjectOrgDailyDTO; import com.epmet.dto.screen.ScreenProjectQuantityOrgMonthlyDTO; import com.epmet.dto.screencoll.ScreenCollFormDTO; import com.epmet.entity.evaluationindex.screen.ScreenProjectQuantityOrgMonthlyEntity; +import com.epmet.entity.org.CustomerAgencyEntity; +import com.epmet.service.crm.CustomerRelationService; import com.epmet.service.evaluationindex.screen.ScreenProjectQuantityOrgMonthlyService; +import com.epmet.service.org.CustomerAgencyService; import com.google.common.collect.Lists; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.ListUtils; @@ -45,6 +47,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -62,7 +65,10 @@ public class ScreenProjectQuantityOrgMonthlyServiceImpl extends BaseServiceImpl< @Autowired private ScreenCustomerAgencyDao agencyDao; - + @Autowired + private CustomerRelationService customerRelationService; + @Autowired + private CustomerAgencyService customerAgencyService; @Override public PageData page(Map params) { IPage page = baseDao.selectPage( @@ -147,10 +153,20 @@ public class ScreenProjectQuantityOrgMonthlyServiceImpl extends BaseServiceImpl< */ @Override public void extractionProjectOrgMonthly(String customerId, String monthId) { - List screenProjectOrgDailyDTOS = agencyDao.selectAgencyByCustomer(customerId); + List screenProjectOrgDailyDTOS = new ArrayList<>(); + //如果有子客户要按照跟组织的area_code查询组织列表 + if(customerRelationService.haveSubCustomer(customerId)){ + // + CustomerAgencyEntity rootAgency=customerAgencyService.getRootAgencyInfo(customerId); + screenProjectOrgDailyDTOS=agencyDao.selectAgencyByAreaCode(rootAgency.getAreaCode()); + }else{ + screenProjectOrgDailyDTOS=agencyDao.selectAgencyByCustomer(customerId); + } if (CollectionUtils.isEmpty(screenProjectOrgDailyDTOS)){ - throw new RenException(String.format(PingYinConstants.AGENCY_INFO_IS_ZERO,customerId)); + log.warn(String.format(PingYinConstants.AGENCY_INFO_IS_ZERO,customerId)); + return; } + List agencyInfos = ConvertUtils.sourceToTarget(screenProjectOrgDailyDTOS, ScreenProjectQuantityOrgMonthlyDTO.class); List projectOrg = baseDao.selectQuantityOrgMonthly(agencyInfos, monthId); if (!CollectionUtils.isEmpty(projectOrg)){ @@ -174,6 +190,7 @@ public class ScreenProjectQuantityOrgMonthlyServiceImpl extends BaseServiceImpl< if (a.getAreaCode().equals(p.getAreaCode())){ a.setClosedIncr(p.getClosedIncr()); a.setProjectIncr(p.getProjectIncr()); + a.setProjectIncr(p.getProjectIncr()); } }); } @@ -183,6 +200,7 @@ public class ScreenProjectQuantityOrgMonthlyServiceImpl extends BaseServiceImpl< a.setClosedTotal(p.getClosedTotal()); a.setProjectTotal(p.getProjectTotal()); a.setUnClosedTotal(p.getUnClosedTotal()); + a.setProjectIncr(p.getProjectIncr()); } }); } 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 b93c4563ec..b3aa943ada 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 @@ -18,4 +18,6 @@ public interface CustomerAgencyService { * @date 2021/1/14 上午11:07 */ List selectCustomerAreaCodeById(List customerIds); + + CustomerAgencyEntity getRootAgencyInfo(String customerId); } 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 702da0930d..8a8fae83b8 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 @@ -45,4 +45,9 @@ public class CustomerAgencyServiceImpl implements CustomerAgencyService { } return new ArrayList<>(); } + + @Override + public CustomerAgencyEntity getRootAgencyInfo(String customerId) { + return customerAgencyDao.getRootAgencyInfo(customerId); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerRelationDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerRelationDao.xml index a92c55e9f9..88c12c8deb 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerRelationDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerRelationDao.xml @@ -22,4 +22,16 @@ AND cr.`STATUS` = 'open' AND cr.PARENT_CUSTOMER_ID =#{customerId} + + \ No newline at end of file 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 31d45d2e3c..dbc3146388 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 @@ -377,4 +377,17 @@ WHERE DEL_FLAG = 0 AND CUSTOMER_ID = #{customerId} + + 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 945b47260e..d5ead92c47 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 @@ -118,4 +118,11 @@ ) + \ No newline at end of file