Browse Source

screenProjectQuantityOrgMonth

master
zxc 5 years ago
parent
commit
0ca8c61909
  1. 46
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/pingyin/result/ProjectOrgMonthlyResultDTO.java
  2. 14
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenProjectQuantityOrgMonthlyDTO.java
  3. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
  4. 20
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectQuantityOrgMonthlyDao.java
  5. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenProjectQuantityOrgMonthlyService.java
  6. 88
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectQuantityOrgMonthlyServiceImpl.java
  7. 31
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectQuantityOrgMonthlyDao.xml

46
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/pingyin/result/ProjectOrgMonthlyResultDTO.java

@ -0,0 +1,46 @@
package com.epmet.dto.pingyin.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2021/2/2 上午11:01
*/
@Data
public class ProjectOrgMonthlyResultDTO implements Serializable {
private static final long serialVersionUID = 4917301916897636586L;
/**
* 行政区域编码
*/
private String areaCode;
/**
* 本月新增的项目数量转项目日期在当前月份内
*/
private Integer projectIncr;
/**
* 累计项目总数
*/
private Integer projectTotal;
/**
* 累计未结项目总数
*/
private Integer unClosedTotal;
/**
* 累计已结项目
*/
private Integer closedTotal;
/**
* 本月新增结案项目数
*/
private Integer closedIncr;
}

14
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/ScreenProjectQuantityOrgMonthlyDTO.java

@ -17,6 +17,7 @@
package com.epmet.dto.screen;
import com.epmet.commons.tools.constant.NumConstant;
import lombok.Data;
import java.io.Serializable;
@ -124,4 +125,17 @@ public class ScreenProjectQuantityOrgMonthlyDTO implements Serializable {
*/
private Date updatedTime;
private String areaCode;
public ScreenProjectQuantityOrgMonthlyDTO() {
this.projectIncr = NumConstant.ZERO;
this.projectTotal = NumConstant.ZERO;
this.unClosedTotal = NumConstant.ZERO;
this.closedTotal = NumConstant.ZERO;
this.closedIncr = NumConstant.ZERO;
this.delFlag = NumConstant.ZERO_STR;
this.revision = NumConstant.ZERO;
this.createdBy = "APP_USER";
this.updatedBy = "APP_USER";
}
}

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

@ -39,6 +39,7 @@ import com.epmet.service.evaluationindex.indexcal.*;
import com.epmet.service.evaluationindex.screen.ScreenProjectGridDailyService;
import com.epmet.service.evaluationindex.screen.ScreenProjectOrgDailyService;
import com.epmet.service.evaluationindex.screen.ScreenProjectQuantityGridMonthlyService;
import com.epmet.service.evaluationindex.screen.ScreenProjectQuantityOrgMonthlyService;
import com.epmet.service.stats.DimAgencyService;
import com.epmet.service.stats.DimCustomerPartymemberService;
import lombok.extern.slf4j.Slf4j;
@ -756,6 +757,9 @@ public class DemoController {
@Autowired
private ScreenProjectOrgDailyService screenProjectOrgDailyService;
@Autowired
private ScreenProjectQuantityOrgMonthlyService screenProjectQuantityOrgMonthlyService;
@PostMapping("screenProjectGridDaily")
public Result screenProjectGridDaily(@RequestParam("customerId")String customerId,@RequestParam("dateId")String dateId){
screenProjectGridDailyService.extractionProjectGridDaily(customerId,dateId);
@ -773,4 +777,10 @@ public class DemoController {
screenProjectOrgDailyService.extractionProjectOrgDaily(customerId, dateId);
return new Result();
}
@PostMapping("screenProjectQuantityOrgMonthly")
public Result screenProjectQuantityOrgMonthly(@RequestParam("customerId")String customerId,@RequestParam("monthId")String monthId){
screenProjectQuantityOrgMonthlyService.extractionProjectOrgMonthly(customerId,monthId);
return new Result();
}
}

20
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectQuantityOrgMonthlyDao.java

@ -18,6 +18,7 @@
package com.epmet.dao.evaluationindex.screen;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.pingyin.result.ProjectOrgMonthlyResultDTO;
import com.epmet.dto.screen.ScreenProjectQuantityOrgMonthlyDTO;
import com.epmet.entity.evaluationindex.screen.ScreenProjectQuantityOrgMonthlyEntity;
import org.apache.ibatis.annotations.Mapper;
@ -39,5 +40,24 @@ public interface ScreenProjectQuantityOrgMonthlyDao extends BaseDao<ScreenProjec
int deleteByMonthIdAndCustomerId(@Param("customerId") String customerId, @Param("monthId") String monthId);
/**
* @Description 项目(事件)数量查询当月
* @Param agencyInfos
* @Param customerId
* @Param monthId
* @author zxc
* @date 2021/2/2 上午11:09
*/
List<ProjectOrgMonthlyResultDTO> selectQuantityOrgMonthly(@Param("agencyInfos") List<ScreenProjectQuantityOrgMonthlyDTO> agencyInfos, @Param("monthId") String monthId);
/**
* @Description 项目(事件)数量查询本月之前的累计
* @Param agencyInfos
* @Param monthId
* @author zxc
* @date 2021/2/2 下午3:03
*/
List<ProjectOrgMonthlyResultDTO> selectQuantityGrandOrgMonthly(@Param("agencyInfos") List<ScreenProjectQuantityOrgMonthlyDTO> agencyInfos, @Param("monthId") String monthId);
}

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

@ -103,4 +103,13 @@ public interface ScreenProjectQuantityOrgMonthlyService extends BaseService<Scre
* @date 2021.01.28 09:33
*/
void collect(String customerId, ScreenCollFormDTO<ScreenProjectQuantityOrgMonthlyDTO> data);
/**
* @Description 数据抽取组织-
* @Param customerId
* @Param monthId
* @author zxc
* @date 2021/2/2 上午10:43
*/
void extractionProjectOrgMonthly(String customerId,String monthId);
}

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

@ -22,17 +22,28 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
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;
import com.epmet.constant.PingYinConstants;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao;
import com.epmet.dao.evaluationindex.screen.ScreenProjectQuantityOrgMonthlyDao;
import com.epmet.dto.pingyin.result.ProjectOrgMonthlyResultDTO;
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.service.evaluationindex.screen.ScreenCustomerAgencyService;
import com.epmet.service.evaluationindex.screen.ScreenProjectQuantityOrgMonthlyService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.Arrays;
import java.util.List;
@ -45,8 +56,13 @@ import java.util.Map;
* @since v1.0.0 2021-01-27
*/
@Service
@Slf4j
@DataSource(DataSourceConstant.EVALUATION_INDEX)
public class ScreenProjectQuantityOrgMonthlyServiceImpl extends BaseServiceImpl<ScreenProjectQuantityOrgMonthlyDao, ScreenProjectQuantityOrgMonthlyEntity> implements ScreenProjectQuantityOrgMonthlyService {
@Autowired
private ScreenCustomerAgencyDao agencyDao;
@Override
public PageData<ScreenProjectQuantityOrgMonthlyDTO> page(Map<String, Object> params) {
IPage<ScreenProjectQuantityOrgMonthlyEntity> page = baseDao.selectPage(
@ -120,4 +136,76 @@ public class ScreenProjectQuantityOrgMonthlyServiceImpl extends BaseServiceImpl<
baseDao.insertBatch(data.getDataList(),customerId,"APP_USER",data.getMonthId());
}
/**
* @Description 数据抽取组织-
* @Param customerId
* @Param monthId
* @author zxc
* @date 2021/2/2 上午10:43
*/
@Override
public void extractionProjectOrgMonthly(String customerId, String monthId) {
List<ScreenProjectOrgDailyDTO> screenProjectOrgDailyDTOS = agencyDao.selectAgencyByCustomer(customerId);
if (CollectionUtils.isEmpty(screenProjectOrgDailyDTOS)){
throw new RenException(String.format(PingYinConstants.AGENCY_INFO_IS_ZERO,customerId));
}
List<ScreenProjectQuantityOrgMonthlyDTO> agencyInfos = ConvertUtils.sourceToTarget(screenProjectOrgDailyDTOS, ScreenProjectQuantityOrgMonthlyDTO.class);
List<ProjectOrgMonthlyResultDTO> projectOrg = baseDao.selectQuantityOrgMonthly(agencyInfos, monthId);
if (!CollectionUtils.isEmpty(projectOrg)){
projectOrg.forEach(p -> {
p.setClosedIncr(null == p.getClosedIncr() ? NumConstant.ZERO : p.getClosedIncr());
p.setProjectIncr(null == p.getProjectIncr() ? NumConstant.ZERO : p.getProjectIncr());
});
}
List<ProjectOrgMonthlyResultDTO> projectGrandOrg = baseDao.selectQuantityGrandOrgMonthly(agencyInfos, monthId);
if (!CollectionUtils.isEmpty(projectGrandOrg)){
projectGrandOrg.forEach(p -> {
p.setClosedTotal(null == p.getClosedTotal() ? NumConstant.ZERO : p.getClosedTotal());
p.setProjectTotal(null == p.getProjectTotal() ? NumConstant.ZERO : p.getProjectTotal());
p.setUnClosedTotal(null == p.getUnClosedTotal() ? NumConstant.ZERO : p.getUnClosedTotal());
});
}
agencyInfos.forEach(a -> {
a.setMonthId(monthId);
if (!CollectionUtils.isEmpty(projectOrg)){
projectOrg.forEach(p -> {
if (a.getAreaCode().equals(p.getAreaCode())){
a.setClosedIncr(p.getClosedIncr());
a.setProjectIncr(p.getProjectIncr());
}
});
}
if (!CollectionUtils.isEmpty(projectGrandOrg)){
projectGrandOrg.forEach(p -> {
if (a.getAreaCode().equals(p.getAreaCode())){
a.setClosedTotal(p.getClosedTotal());
a.setProjectTotal(p.getProjectTotal());
a.setUnClosedTotal(p.getUnClosedTotal());
}
});
}
});
log.info(agencyInfos.toString());
del(customerId, monthId);
insert(agencyInfos,customerId,monthId);
}
@Transactional(rollbackFor = Exception.class)
public void del(String customerId,String monthId){
Integer flag;
do {
flag = baseDao.deleteByMonthIdAndCustomerId(customerId, monthId);
}while (flag > NumConstant.ZERO && flag == NumConstant.ONE_THOUSAND);
}
@Transactional(rollbackFor = Exception.class)
public void insert(List<ScreenProjectQuantityOrgMonthlyDTO> agencyInfos,String customerId,String monthId){
if (!CollectionUtils.isEmpty(agencyInfos)){
List<List<ScreenProjectQuantityOrgMonthlyDTO>> partition = ListUtils.partition(agencyInfos, NumConstant.ONE_HUNDRED);
partition.forEach(p -> {
baseDao.insertBatch(p,customerId,PingYinConstants.CREATED_BY,monthId);
});
}
}
}

31
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectQuantityOrgMonthlyDao.xml

@ -96,5 +96,36 @@
limit 1000
</delete>
<!-- 项目(事件)数量查询【当月】 -->
<select id="selectQuantityOrgMonthly" resultType="com.epmet.dto.pingyin.result.ProjectOrgMonthlyResultDTO">
<foreach collection="agencyInfos" item="a" separator=" UNION ">
SELECT
#{a.areaCode} AS areaCode,
SUM(g.PROJECT_INCR) AS projectIncr,
SUM(g.CLOSED_INCR) AS closedIncr
FROM screen_project_quantity_grid_monthly g
LEFT JOIN screen_customer_grid cg ON cg.GRID_ID = g.GRID_ID
WHERE g.DEL_FLAG = 0
AND cg.AREA_CODE LIKE CONCAT(#{a.areaCode},'%')
AND g.MONTH_ID = #{monthId}
</foreach>
</select>
<!-- 项目(事件)数量查询【本月之前的累计 -->
<select id="selectQuantityGrandOrgMonthly" resultType="com.epmet.dto.pingyin.result.ProjectOrgMonthlyResultDTO">
<foreach collection="agencyInfos" item="a" separator=" UNION ">
SELECT
#{a.areaCode} AS areaCode,
SUM(g.PROJECT_TOTAL) AS projectTotal,
SUM(g.UN_CLOSED_TOTAL) AS unClosedTotal,
SUM(g.CLOSED_TOTAL) AS closedTotal
FROM screen_project_quantity_grid_monthly g
LEFT JOIN screen_customer_grid cg ON cg.GRID_ID = g.GRID_ID
WHERE g.DEL_FLAG = 0
AND cg.AREA_CODE LIKE CONCAT(#{a.areaCode},'%')
AND g.MONTH_ID <![CDATA[ <= ]]> #{monthId}
</foreach>
</select>
</mapper>
Loading…
Cancel
Save