24 changed files with 1162 additions and 14 deletions
@ -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; |
|||
|
|||
/** |
|||
* 分类等级:1、2....;产品目前只有2级分类 |
|||
*/ |
|||
private Integer level; |
|||
|
|||
/** |
|||
* 删除标识 0未删除;1已删除 |
|||
*/ |
|||
private String delFlag; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新人 |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
} |
@ -0,0 +1,76 @@ |
|||
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; |
|||
|
|||
private String categoryOriginCustomerId; |
|||
|
|||
/** |
|||
* 分类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; |
|||
} |
|||
} |
@ -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); |
|||
} |
@ -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; |
|||
|
|||
/** |
|||
* 分类等级:1、2....;产品目前只有2级分类 |
|||
*/ |
|||
private Integer level; |
|||
|
|||
} |
@ -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); |
|||
} |
@ -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); |
|||
} |
@ -0,0 +1,203 @@ |
|||
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> oneLevelList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.FOUR, allAgencies); |
|||
List<GridAndOrgCategoryCountResultDTO> oneLevelClosedList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.FOUR, allAgencies); |
|||
oneLevelList.forEach(a -> oneLevelClosedList.stream().filter(c -> a.getOrgId().equals(c.getOrgId()) && a.getCategoryCode().equals(c.getCategoryCode())).forEach(c -> a.setClosedProjectTotal(c.getClosedProjectTotal()))); |
|||
result.addAll(oneLevelList); |
|||
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> oneLevelList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.FOUR, allAgencies); |
|||
List<GridAndOrgCategoryCountResultDTO> oneLevelClosedList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.FOUR, allAgencies); |
|||
oneLevelList.forEach(a -> oneLevelClosedList.stream().filter(c -> a.getOrgId().equals(c.getOrgId()) && a.getCategoryCode().equals(c.getCategoryCode())).forEach(c -> a.setClosedProjectTotal(c.getClosedProjectTotal()))); |
|||
allOrgList.addAll(oneLevelList); |
|||
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)); |
|||
}); |
|||
} |
|||
} |
@ -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); |
|||
} |
|||
|
|||
} |
@ -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> |
Loading…
Reference in new issue