Browse Source

项目改造

dev_shibei_match
wangchao 5 years ago
parent
commit
0cc882cc5b
  1. 3
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java
  2. 114
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/project/ProjectOrgRelationDTO.java
  3. 2
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/project/result/ProjectOrgPeriodResultDTO.java
  4. 11
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
  5. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectOrgPeriodDailyDao.java
  6. 29
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/project/ProjectProcessDao.java
  7. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/ProjectExtractService.java
  8. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java
  9. 11
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/ProjectProcessService.java
  10. 110
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectProcessServiceImpl.java
  11. 109
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectProcessDao.xml
  12. 41
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/TimestampIntervalFormDTO.java
  13. 47
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/WorkMinuteFormDTO.java
  14. 16
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java
  15. 7
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java
  16. 29
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/constant/ProjectConstant.java
  17. 14
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/WorkDayController.java
  18. 12
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/WorkDayService.java
  19. 242
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/WorkDayServiceImpl.java
  20. 1
      epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/CalenderDao.xml
  21. 113
      epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/ProjectOrgRelationDTO.java
  22. 20
      epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/ProjectProcessDTO.java
  23. 20
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/constant/ProjectConstant.java
  24. 73
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/ProjectOrgRelationDao.java
  25. 19
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/ProjectStaffDao.java
  26. 83
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ProjectOrgRelationEntity.java
  27. 25
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ProjectProcessEntity.java
  28. 19
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ProjectStaffService.java
  29. 59
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectProcessServiceImpl.java
  30. 204
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java
  31. 25
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectStaffServiceImpl.java
  32. 106
      epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ProjectOrgRelationDao.xml
  33. 30
      epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ProjectStaffDao.xml

3
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java

@ -26,10 +26,11 @@ public interface NumConstant {
int TEN = 10;
int ELEVEN = 11;
int TWELVE = 12;
int SEVENTEEN = 17;
int FIFTEEN = 15;
int FOURTEEN=14;
int TWENTY = 20;
int TWENTY_FOUR = 24;
int THIRTY = 30;
int THIRTY_ONE = 31;
int FORTY = 40;

114
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/project/ProjectOrgRelationDTO.java

@ -0,0 +1,114 @@
/**
* 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.project;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 项目机关历时关系表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-10-19
*/
@Data
public class ProjectOrgRelationDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
private String id;
/**
* 关联PROJECT_STAFF由此ID可以关联出PROJECT_IDCUSTOMER_IDPROCESS_ID
*/
private String projectStaffId;
/**
* 流转到的日期 同CREATED_TIME
*/
private Date informedDate;
/**
* 流转走或结案的日期
*/
private Date handledDate;
/**
* 节点耗时从流转到自己到流转走共耗时单位分钟如果项目还没有结案且该项目在这个组织下一直滞留这一项为空
* 8*60的倍数
*/
private Integer totalPeriod;
/**
* 第一次响应时间
*/
private Date firstDealtDate;
/**
* 首次响应时长单位分钟
* 8*60的倍数
*/
private Integer firstReplyPeriod;
/**
* 来源动作return(回退)transfer(流转)closed(结案)response(响应)created(立项时第一个流转到的)
*/
private String sourceOperation;
/**
* 处理动作return(回退)transfer(流转)closed(结案)response(响应)
*/
private String operation;
/**
* 删除标识
*/
private String delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
*
*/
private Date createdTime;
/**
*
*/
private String createdBy;
/**
*
*/
private Date updatedTime;
/**
*
*/
private String updatedBy;
}

2
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/project/result/ProjectOrgPeriodResultDTO.java

@ -92,4 +92,6 @@ public class ProjectOrgPeriodResultDTO implements Serializable {
private String isResolved;
private String projectStaffId;
}

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

@ -21,6 +21,7 @@ import com.epmet.dto.AgencySubTreeDto;
import com.epmet.dto.extract.form.ExtractOriginFormDTO;
import com.epmet.dto.extract.form.ExtractScreenFormDTO;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.project.result.ProjectOrgPeriodResultDTO;
import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityGridMonthlyEntity;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityGridMonthlyEntity;
@ -36,6 +37,7 @@ import com.epmet.service.StatsDemoService;
import com.epmet.service.evaluationindex.extract.dataToIndex.*;
import com.epmet.service.evaluationindex.extract.todata.FactOriginProjectLogDailyService;
import com.epmet.service.evaluationindex.extract.todata.FactOriginTopicMainDailyService;
import com.epmet.service.evaluationindex.extract.todata.ProjectExtractService;
import com.epmet.service.evaluationindex.extract.toscreen.*;
import com.epmet.service.evaluationindex.indexcal.*;
import com.epmet.service.stats.DimAgencyService;
@ -742,4 +744,13 @@ public class DemoController {
return new Result();
}
@Autowired
ProjectExtractService projectExtractService;
@PostMapping("projectremould")
public Result<List<ProjectOrgPeriodResultDTO>> projectRemould(@RequestBody ExtractOriginFormDTO param){
return new Result<List<ProjectOrgPeriodResultDTO>>().ok(projectExtractService.test(param));
}
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectOrgPeriodDailyDao.java

@ -47,7 +47,7 @@ public interface FactOriginProjectOrgPeriodDailyDao extends BaseDao<FactOriginPr
/**
* @Description 在插入之前先删除所有与这个项目相关的历时信息
* @param list
* @param projectId
* @return
* @author wangc
* @date 2020.09.17 14:43

29
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/project/ProjectProcessDao.java

@ -20,6 +20,7 @@ package com.epmet.dao.project;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.project.FinishOrgDTO;
import com.epmet.dto.project.ProcessInfoDTO;
import com.epmet.dto.project.ProjectOrgRelationDTO;
import com.epmet.dto.project.result.ProjectLatestOperationResultDTO;
import com.epmet.dto.project.result.ProjectOrgPeriodResultDTO;
import com.epmet.dto.project.result.ProjectOrgRelationWhenResponseResultDTO;
@ -28,6 +29,7 @@ import com.epmet.entity.project.ProjectProcessEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
@ -106,6 +108,15 @@ public interface ProjectProcessDao extends BaseDao<ProjectProcessEntity> {
**/
List<ProjectOrgPeriodResultDTO> selectProjectOrgPeriod(@Param("customerId") String customerId,@Param("projectStatus")String projectStatus,@Param("dateId") String dateId);
/**
* @Description 根据项目业务改造在数据抽取时直接查询出项目节点的耗时
* @param
* @return java.util.List<com.epmet.dto.project.result.ProjectOrgPeriodResultDTO>
* @author wangc
* @date 2020.10.23 11:13
*/
List<ProjectOrgPeriodResultDTO> selectProjectOrgPeriodDirectly(@Param("customerId") String customerId,@Param("projectStatus")String projectStatus,@Param("dateId") String dateId);
/**
* @Description 查询项目-机关各个节点的响应列表
* @param projects
@ -115,6 +126,15 @@ public interface ProjectProcessDao extends BaseDao<ProjectProcessEntity> {
**/
List<ProjectOrgRelationWhenResponseResultDTO> selectResponseTrace(@Param("projects") List<String> projects);
/**
* @Description 查询项目的节点
* @param projects
* @return java.util.List<com.epmet.dto.project.result.ProjectOrgRelationWhenResponseResultDTO>
* @author wangc
* @date 2020.10.23 17:02
*/
List<ProjectOrgRelationWhenResponseResultDTO> selectProjectProcess(@Param("projects") List<String> projects);
/**
* 获取办结组织
* @author zhaoqifeng
@ -133,4 +153,13 @@ public interface ProjectProcessDao extends BaseDao<ProjectProcessEntity> {
* @date 2020.09.28 14:45
*/
List<ProjectLatestOperationResultDTO> selectLatestOperation(@Param("list") List<String> list);
/**
* @Description 批量插入节点耗时数据(数据补齐)
* @param list
* @return int
* @author wangc
* @date 2020.10.26 09:59
*/
int batchInsertProjectOrgRelation(@Param("list") List<ProjectOrgRelationDTO> list);
}

5
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/ProjectExtractService.java

@ -2,6 +2,9 @@ package com.epmet.service.evaluationindex.extract.todata;
import com.epmet.dto.extract.form.ExtractOriginFormDTO;
import com.epmet.dto.project.result.ProjectOrgPeriodResultDTO;
import java.util.List;
/**
* @author zhaoqifeng
@ -29,4 +32,6 @@ public interface ProjectExtractService {
* @date 2020.09.17 14:05
**/
void extractProjectPeriodData(ExtractOriginFormDTO param);
List<ProjectOrgPeriodResultDTO> test(ExtractOriginFormDTO param);
}

13
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java

@ -395,7 +395,7 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
param.setDateId(DateUtils.getBeforeNDay(NumConstant.ONE));
}
List<ProjectOrgPeriodResultDTO> extractData =
projectProcessService.getProjectPeriod(isFirst, param.getCustomerId(), param.getDateId());
projectProcessService.getProjectPeriodDirectly(isFirst, param.getCustomerId(), param.getDateId());
List<FactOriginProjectOrgPeriodDailyEntity> formattingData = new LinkedList<>();
extractData.forEach(original -> {
FactOriginProjectOrgPeriodDailyEntity dest
@ -444,6 +444,17 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
}
}
@Override
public List<ProjectOrgPeriodResultDTO> test(ExtractOriginFormDTO param) {
List<ProjectOrgPeriodResultDTO> extractData =
projectProcessService.getProjectPeriod(true, param.getCustomerId(), param.getDateId());
System.out.println("-------------EndPointHere----------------");
return extractData;
}
/**
* 工作日计算

11
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/ProjectProcessService.java

@ -104,6 +104,17 @@ public interface ProjectProcessService extends BaseService<ProjectProcessEntity>
**/
List<ProjectOrgPeriodResultDTO> getProjectPeriod(Boolean isFirst,String customerId,String date);
/**
* @Description 直接从项目业务改造获取项目节点耗时信息
* @param isFirst
* @param customerId
* @param date
* @return java.util.List<com.epmet.dto.project.result.ProjectOrgPeriodResultDTO>
* @author wangc
* @date 2020.10.23 09:10
*/
List<ProjectOrgPeriodResultDTO> getProjectPeriodDirectly(Boolean isFirst,String customerId, String date);
/**
* 获取办结组织
* @author zhaoqifeng

110
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectProcessServiceImpl.java

@ -106,18 +106,19 @@ public class ProjectProcessServiceImpl extends BaseServiceImpl<ProjectProcessDao
if(!CollectionUtils.isEmpty(projectNodePeriodPerOrgList)){
Map<String,List<ProjectOrgPeriodResultDTO>> processMap
= projectNodePeriodPerOrgList.stream().collect(Collectors.groupingBy(ProjectOrgPeriodResultDTO :: getProcessId));
Map<String,List<ProjectOrgPeriodResultDTO>> projectMap
= projectNodePeriodPerOrgList.stream().collect(Collectors.groupingBy(ProjectOrgPeriodResultDTO :: getProjectId));
List<String> projects =
projectNodePeriodPerOrgList.stream().map(ProjectOrgPeriodResultDTO::getProjectId).distinct().collect(Collectors.toList());
if(!projects.isEmpty()){
List<ProjectOrgRelationWhenResponseResultDTO> responseList = baseDao.selectResponseTrace(projects);
Map<String,List<ProjectOrgRelationWhenResponseResultDTO>> sorted =
responseList.stream().collect(Collectors.groupingBy(ProjectOrgRelationWhenResponseResultDTO::getProjectId));
skipLevelGrouping(processMap,sorted);
skipLevelGrouping(projectMap,sorted);
List<ProjectOrgPeriodResultDTO> result = new LinkedList<>();
processMap.values().forEach(list -> {list.forEach(obj -> {result.add(obj);});});
projectMap.values().forEach(list -> {list.forEach(obj -> {result.add(obj);});});
return result;
}
}
@ -125,6 +126,25 @@ public class ProjectProcessServiceImpl extends BaseServiceImpl<ProjectProcessDao
return new ArrayList<>();
}
/**
* @Description 直接从项目业务改造获取项目节点耗时信息
* @param isFirst
* @param customerId
* @param date
* @return java.util.List<com.epmet.dto.project.result.ProjectOrgPeriodResultDTO>
* @author wangc
* @date 2020.10.23 09:10
*/
@Override
public List<ProjectOrgPeriodResultDTO> getProjectPeriodDirectly(Boolean isFirst, String customerId, String date) {
if(isFirst){
return baseDao.selectProjectOrgPeriodDirectly(customerId,null,null);
}else{
return baseDao.selectProjectOrgPeriodDirectly(customerId,null,date);
}
}
@Override
public List<FinishOrgDTO> getFinishOrg(String customerId, String date) {
return baseDao.selectFinishOrg(customerId, date);
@ -151,7 +171,7 @@ public class ProjectProcessServiceImpl extends BaseServiceImpl<ProjectProcessDao
/**
* @Description 跨级分组 eg -> transfer ; response response transfer ; return ; response close.
* @param dest - Map<String,List<ProjectOrgPeriodResultDTO>> 需要填充的数据
* @param dest - Map<String,List<ProjectOrgPeriodResultDTO>> 需要填充的数据 projectMap
* @param fillFactor - Map<String,List<ProjectOrgRelationWhenResponseResultDTO>> 填充因子
* @return
* @author wangc
@ -159,53 +179,61 @@ public class ProjectProcessServiceImpl extends BaseServiceImpl<ProjectProcessDao
**/
private void skipLevelGrouping(Map<String,List<ProjectOrgPeriodResultDTO>> dest,Map<String,List<ProjectOrgRelationWhenResponseResultDTO>> fillFactor){
for(String projectId : fillFactor.keySet()){
//拿到同一个项目下的的节点记录(只有存在响应节点的项目)
List<ProjectOrgRelationWhenResponseResultDTO> projectTraceUnit = fillFactor.get(projectId);
if(!projectTraceUnit.isEmpty()){
Map<String,List<ProjectOrgRelationWhenResponseResultDTO>> staffResponseTrace =
// K : staffId
// V : 项目下对于某个员工(可能是在不同部门、网格、机关下)的所有节点顺时针操作,因为对于但项目单人来说,只能串行不能并行
Map<String,List<ProjectOrgRelationWhenResponseResultDTO>> staffResponseTrace =
projectTraceUnit.stream().collect(Collectors.groupingBy(ProjectOrgRelationWhenResponseResultDTO::getStaffId));
if(!CollectionUtils.isEmpty(staffResponseTrace)){
staffResponseTrace.keySet().forEach( staffId -> {
if(!CollectionUtils.isEmpty(staffResponseTrace.get(staffId))){
List<ProjectOrgRelationWhenResponseResultDTO> staffResponseTraceUnit
= staffResponseTrace.get(staffId);
int lastEndCount = NumConstant.ONE_NEG;
for(int index = NumConstant.ZERO; index < staffResponseTraceUnit.size(); index ++){
if(StringUtils.equalsAny(staffResponseTraceUnit.get(index).getOperation(),
"transfer","return","close")){
replaceFirstResponseDate(dest,index,staffResponseTraceUnit,true);
lastEndCount = index;
}else{
if(lastEndCount == NumConstant.ONE_NEG) continue;
if(index - NumConstant.ONE == lastEndCount){
replaceFirstResponseDate(dest,index,staffResponseTraceUnit,false);
}else{continue;}
}
}
}
});
List<ProjectOrgPeriodResultDTO> incompleteBody = dest.get(projectId);
if(!CollectionUtils.isEmpty(incompleteBody)) {
Map<String,List<ProjectOrgPeriodResultDTO>> incompleteBodyGroupByStaffMap =
incompleteBody.stream().collect(Collectors.groupingBy(ProjectOrgPeriodResultDTO::getStaffId));
if(!CollectionUtils.isEmpty(incompleteBodyGroupByStaffMap)) {
staffResponseTrace.keySet().forEach(staffId -> {
List<ProjectOrgRelationWhenResponseResultDTO> staffResponseTraceUnit
= staffResponseTrace.get(staffId);
List<ProjectOrgPeriodResultDTO> incompleteBodyUnit = incompleteBodyGroupByStaffMap.get(staffId);
if (!CollectionUtils.isEmpty(incompleteBodyUnit) && !CollectionUtils.isEmpty(staffResponseTraceUnit)) {
//int lastEndCount = NumConstant.ONE_NEG;
a:
for (int index = NumConstant.ZERO; index < staffResponseTraceUnit.size(); index++) {
if (StringUtils.equals("response", staffResponseTraceUnit.get(index).getOperation())) {
replaceFirstResponseDate(incompleteBodyUnit,staffResponseTraceUnit.get(index));
int cursor = index;
if (cursor == staffResponseTraceUnit.size() - NumConstant.ZERO) break;
while (StringUtils.equals("response", staffResponseTraceUnit.get(cursor++).getOperation())) {
if (cursor == staffResponseTraceUnit.size() - NumConstant.ZERO) break a;
}
if (cursor == staffResponseTraceUnit.size() - NumConstant.ZERO) break;
index = cursor;
} else {
replaceFirstResponseDate(incompleteBodyUnit,staffResponseTraceUnit.get(index));
}
}
}
});
}
}
}
}
}
}
private void replaceFirstResponseDate(Map<String,List<ProjectOrgPeriodResultDTO>> dest, int index, List<ProjectOrgRelationWhenResponseResultDTO> staffResponseTraceUnit, boolean ifResponsed){
List<ProjectOrgPeriodResultDTO> processSingleList =
dest.get(staffResponseTraceUnit.get(index).getProcessId());
if(!CollectionUtils.isEmpty(processSingleList)){
//ProjectOrgPeriodResultDTO element = processSingleList.get(NumConstant.ZERO);
ProjectOrgPeriodResultDTO element = processSingleList.stream().filter(node ->
StringUtils.equals(node.getStaffId(),staffResponseTraceUnit.get(index).getStaffId())).findFirst().get();
if(!ifResponsed && null == element.getHandledDate()){
log.warn("com.epmet.service.project.impl.ProjectProcessServiceImpl.skipLevelGrouping::已流出节点没有办结日期,节点ID{}",element.getProcessId() );
}
element.setPeriodTillReplyFirstly(ifResponsed ? staffResponseTraceUnit.get(index).getCreatedTime() :element.getHandledDate());
private void replaceFirstResponseDate(List<ProjectOrgPeriodResultDTO> dest,
ProjectOrgRelationWhenResponseResultDTO staffResponseTraceUnit){
// 传递过来的dest是已经按照projectId分好组之后再按照staff分组的集合
// dest key->staff
for(int cursor = 0; cursor < dest.size(); cursor++){
if(dest.get(cursor).getPeriodTillReplyFirstly() == null) continue;
dest.get(cursor).setPeriodTillReplyFirstly(staffResponseTraceUnit.getCreatedTime());
}
}

109
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectProcessDao.xml

@ -98,6 +98,7 @@
<!-- 查询项目-机关各个节点历时详情 -->
<select id="selectProjectOrgPeriod" resultType="com.epmet.dto.project.result.ProjectOrgPeriodResultDTO">
SELECT
staff.ID AS projectStaffId,
project.CUSTOMER_ID,
process.ID AS processId,
process.PROJECT_ID,
@ -107,7 +108,7 @@
staff.ORG_ID,
staff.DEPARTMENT_ID,
staff.GRID_ID,
staff.CREATED_BY AS staffId,
staff.STAFF_ID AS staffId,
staff.ORG_ID_PATH,
IF(staff.IS_HANDLE='handle',timestampdiff(MINUTE , staff.CREATED_TIME , staff.UPDATED_TIME),0) AS TOTAL_PERIOD,
@ -119,7 +120,9 @@
FROM PROJECT_STAFF staff
LEFT JOIN PROJECT project ON staff.PROJECT_ID = project.ID AND project.DEL_FLAG = '0'
LEFT JOIN PROJECT_PROCESS process ON staff.PROCESS_ID = process.ID AND process.DEL_FLAG = '0'
LEFT JOIN PROJECT_PROCESS selfAction ON staff.PROJECT_ID = selfAction.PROJECT_ID AND selfAction.DEL_FLAG = '0' AND staff.UPDATED_TIME = selfAction.CREATED_TIME AND staff.STAFF_ID = selfAction.STAFF_ID
LEFT JOIN PROJECT_PROCESS selfAction ON staff.PROJECT_ID = selfAction.PROJECT_ID AND selfAction.DEL_FLAG = '0'
AND ABS(TIMESTAMPDIFF(SECOND,staff.UPDATED_TIME,selfAction.CREATED_TIME)) <![CDATA[ <= ]]> 30
AND staff.STAFF_ID = selfAction.STAFF_ID
WHERE staff.DEL_FLAG = '0'
AND project.CUSTOMER_ID = #{customerId}
@ -137,6 +140,45 @@
ORDER BY process.PROJECT_ID,staff.CREATED_TIME ASC
</select>
<select id="selectProjectOrgPeriodDirectly" resultType="com.epmet.dto.project.result.ProjectOrgPeriodResultDTO">
SELECT
staff.CUSTOMER_ID,
staff.PROCESS_ID,
staff.PROJECT_ID,
relation.SOURCE_OPERATION AS lastAction,
relation.OPERATION,
staff.DEPARTMENT_NAME,
staff.ORG_ID,
staff.DEPARTMENT_ID,
staff.GRID_ID,
staff.ORG_ID_PATH,
staff.STAFF_ID,
relation.TOTAL_PERIOD,
relation.INFORMED_DATE,
IF(staff.IS_HANDLE='handle','resolved','unresolved') AS isResolved,
relation.HANDLED_DATE,
relation.FIRST_DEALT_DATE AS periodTillReplyFirstly
FROM PROJECT_STAFF staff
INNER JOIN PROJECT_ORG_RELATION relation ON staff.ID = relation.PROJECT_STAFF_ID AND relation.DEL_FLAG = '0'
WHERE staff.DEL_FLAG = '0'
AND staff.CUSTOMER_ID = #{customerId}
<if test='null != projectStatus and "" != projectStatus'>
AND project.STATUS = #{projectStatus}
</if>
<if test='null != dateId and "" != dateId'>
AND (
DATE_FORMAT(relation.UPDATED_TIME , '%Y%m%d') = #{dateId}
)
</if>
ORDER BY staff.PROJECT_ID,staff.CREATED_TIME ASC
</select>
<!-- 查询项目-机关各个节点的响应列表 -->
<select id="selectResponseTrace" resultType="com.epmet.dto.project.result.ProjectOrgRelationWhenResponseResultDTO">
SELECT
@ -159,8 +201,32 @@
SELECT * FROM PROJECT_PROCESS WHERE DEL_FLAG = '0' AND PROJECT_ID = process.PROJECT_ID AND OPERATION = 'response'
AND STAFF_ID = process.STAFF_ID AND DEPARTMENT_NAME = process.DEPARTMENT_NAME
)
ORDER BY process.STAFF_ID , process.CREATED_TIME ASC
ORDER BY process.PROJECT_ID , process.STAFF_ID , process.CREATED_TIME ASC
</select>
<!-- 查询项目的节点 -->
<select id="selectProjectProcess" resultType="com.epmet.dto.project.result.ProjectOrgRelationWhenResponseResultDTO">
SELECT
ID AS processId,
PROJECT_ID,
STAFF_ID,
OPERATION,
CREATED_TIME
FROM
PROJECT_PROCESS
WHERE
DEL_FLAG = '0'
AND
PROJECT_ID
IN(
SELECT DISTINCT ID
)
<foreach collection="projects" item="id" open="AND (" close=")" separator=" OR ">
PROJECT_ID = #{id}
</foreach>
ORDER BY PROJECT_ID,STAFF_ID,CREATED_TIME ASC
</select>
<select id="selectFinishOrg" resultType="com.epmet.dto.project.FinishOrgDTO">
SELECT
a.GRID_ID,
@ -239,4 +305,41 @@
AND DATE_FORMAT(pp.CREATED_TIME,'%Y%m%d') = #{date}
</if>
</select>
<insert id="batchInsertProjectOrgRelation" parameterType="java.util.List">
<!-- 批量插入 -->
INSERT INTO project_org_relation(
ID,
PROJECT_STAFF_ID,
INFORMED_DATE,
CREATED_TIME,
UPDATED_TIME,
SOURCE_OPERATION,
OPERATION,
TOTAL_PERIOD,
FIRST_DEALT_DATE,
FIRST_REPLY_PERIOD,
CREATED_BY,
UPDATED_BY
) values
<foreach collection="list" item="item" index="index" separator=",">
(
(SELECT REPLACE(UUID(),'-','') as id),
#{item.projectStaffId},
#{item.informedDate},
NOW(),
NOW(),
#{item.sourceOperation},
#{item.OPERATION},
#{item.totalPeriod},
#{item.firstDealtDate},
#{item.firstReplyPeriod},
'COMPENSATION_ROBOT',
'COMPENSATION_ROBOT'
)
</foreach>
</insert>
</mapper>

41
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/TimestampIntervalFormDTO.java

@ -0,0 +1,41 @@
package com.epmet.dto.form;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/**
* @Description 时间区间
* @ClassName TimestampIntervalFormDTO
* @Auth wangc
* @Date 2020-10-21 15:55
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TimestampIntervalFormDTO implements Serializable {
private static final long serialVersionUID = 8404199047657424778L;
/***
* 可以是任意的标志Id用来区分多组传参的返回值
*/
@NotNull(message = "时间区间标识Id不能为空",groups = WorkMinuteFormDTO.WorkTimeGroup.class)
private String id;
/**
* 区间左段点
*/
@NotNull(message = "开始时间不能为空",groups = WorkMinuteFormDTO.WorkTimeGroup.class)
private Date left;
/***
* 去边右段点
*/
private Date right;
}

47
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/WorkMinuteFormDTO.java

@ -0,0 +1,47 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.Valid;
import java.io.Serializable;
import java.util.List;
/**
* @Description 计算经历的多少分钟(只计算工作日)
* @ClassName WorkMinuteFromDTO
* @Auth wangc
* @Date 2020-10-21 15:48
*/
@Data
public class WorkMinuteFormDTO implements Serializable {
private static final long serialVersionUID = -7777345488803895645L;
public interface WorkTimeGroup extends CustomerClientShowGroup{}
/**
* 是否使用自定义起止时间 default - 24小时制计 custom - 使用自定义但是一定要传递起止时间(目前只支持在同一天)
*/
private String ifCustom;
/**
* 是否精准计算 默认不精准计算 Imprecise - 不精准 precise - 精准
*/
private String ifPrecise;
/***
* 每天的计算起始时间
* HH:mm:ss
*/
private String startTemplate;
/***
* 每天的计算截止时间
* HH:mm:ss
*/
private String endTemplate;
@Valid
private List<TimestampIntervalFormDTO> timeList;
}

16
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java

@ -6,6 +6,7 @@ import com.epmet.dto.form.CostDayFormDTO;
import com.epmet.dto.form.ExternalAppAuthFormDTO;
import com.epmet.dto.form.WorkDayFormDTO;
import com.epmet.dto.result.CostDayResultDTO;
import com.epmet.dto.form.WorkMinuteFormDTO;
import com.epmet.dto.result.ExternalAppAuthResultDTO;
import com.epmet.dto.result.WorkDayResultDTO;
import com.epmet.feign.fallback.EpmetCommonServiceOpenFeignClientFallback;
@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
import java.util.Map;
/**
* 本服务对外开放的API,其他服务通过引用此client调用该服务
@ -21,8 +23,8 @@ import java.util.List;
* @author yinzuomei@elink-cn.com
* @date 2020/6/4 10:28
*/
@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallback = EpmetCommonServiceOpenFeignClientFallback.class)
//@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallback = EpmetCommonServiceOpenFeignClientFallback.class, url = "http://localhost:8103")
//@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallback = EpmetCommonServiceOpenFeignClientFallback.class)
@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallback = EpmetCommonServiceOpenFeignClientFallback.class, url = "http://localhost:8103")
public interface EpmetCommonServiceOpenFeignClient {
/**
* @param formDTO
@ -75,4 +77,14 @@ public interface EpmetCommonServiceOpenFeignClient {
*/
@PostMapping("commonservice/workday/calendardays")
Result<List<CostDayResultDTO>> costCalendarDays(@RequestBody List<CostDayFormDTO> formDTO);
/**
* @Description 计算经历的多少分钟(只计算工作日)
* @param param
* @return com.epmet.commons.tools.utils.Result<java.util.Map<java.lang.String,java.lang.Integer>>
* @author wangc
* @date 2020.10.21 16:34
*/
@PostMapping("commonservice/workday/workminutes")
Result<Map<String,Integer>> workMinutes(@RequestBody WorkMinuteFormDTO param);
}

7
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java

@ -6,6 +6,7 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.CostDayFormDTO;
import com.epmet.dto.form.ExternalAppAuthFormDTO;
import com.epmet.dto.form.WorkDayFormDTO;
import com.epmet.dto.form.WorkMinuteFormDTO;
import com.epmet.dto.result.CostDayResultDTO;
import com.epmet.dto.result.ExternalAppAuthResultDTO;
import com.epmet.dto.result.WorkDayResultDTO;
@ -13,6 +14,7 @@ import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
/**
* 本服务对外开放的API,其他服务通过引用此client调用该服务
@ -67,4 +69,9 @@ public class EpmetCommonServiceOpenFeignClientFallback implements EpmetCommonSer
public Result<List<CostDayResultDTO>> costCalendarDays(List<CostDayFormDTO> formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "costCalendarDays", formDTO);
}
@Override
public Result<Map<String, Integer>> workMinutes(WorkMinuteFormDTO param) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "workMinutes", param);
}
}

29
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/constant/ProjectConstant.java

@ -8,4 +8,33 @@ public interface ProjectConstant {
* 时间已存在
*/
/**
* 日期类型 工作日
*/
String DAY_TYPE_WORK = "1";
/**
* 日期类型 周末
*/
String DAY_TYPE_WEEKEND = "2";
/**
* 日期类型 假日
*/
String DAY_TYPE_HOLIDAY = "3";
/***
* 计算方式 使用自定应
*/
String CALCULATION_TYPE_CUSTOM = "custom";
/**
* 计算方式 使用默认24小时制
*/
String CALCULATION_TYPE_DEFAULT = "default";
/**
* 精准计算
*/
String PRECISE_CALCULATION = "precise";
}

14
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/WorkDayController.java

@ -4,6 +4,7 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.CostDayFormDTO;
import com.epmet.dto.form.WorkDayFormDTO;
import com.epmet.dto.result.CostDayResultDTO;
import com.epmet.dto.form.WorkMinuteFormDTO;
import com.epmet.dto.result.WorkDayResultDTO;
import com.epmet.service.WorkDayService;
import org.springframework.beans.factory.annotation.Autowired;
@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
* @Description 工作日计算
@ -66,5 +68,17 @@ public class WorkDayController {
return new Result<List<CostDayResultDTO>>().ok(list);
}
/**
* @Description 计算经历的多少分钟(只计算工作日)
* @param param
* @return com.epmet.commons.tools.utils.Result<java.util.Map<java.lang.String,java.lang.Integer>>
* @author wangc
* @date 2020.10.21 16:34
*/
@PostMapping("workminutes")
public Result<Map<String,Integer>> workMinutes(@RequestBody WorkMinuteFormDTO param){
return new Result<Map<String,Integer>>().ok(workDayService.workMinutes(param));
}
}

12
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/WorkDayService.java

@ -3,9 +3,12 @@ package com.epmet.service;
import com.epmet.dto.form.CostDayFormDTO;
import com.epmet.dto.form.WorkDayFormDTO;
import com.epmet.dto.result.CostDayResultDTO;
import com.epmet.dto.form.WorkMinuteFormDTO;
import com.epmet.dto.result.WorkDayResultDTO;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
@ -33,4 +36,13 @@ public interface WorkDayService {
* @return java.util.List<com.epmet.dto.result.CostDayResultDTO>
*/
List<CostDayResultDTO> costCalendarDays(List<CostDayFormDTO> formDTO);
/**
* @Description 计算经历的多少分钟(只计算工作日)
* @param param
* @return java.util.Map<java.lang.String,java.lang.Integer>
* @author wangc
* @date 2020.10.21 16:14
*/
Map<String,Integer> workMinutes(WorkMinuteFormDTO param);
}

242
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/WorkDayServiceImpl.java

@ -1,20 +1,30 @@
package com.epmet.service.impl;
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.DateUtils;
import com.epmet.constant.ProjectConstant;
import com.epmet.dao.CalenderDao;
import com.epmet.dto.form.CostDayFormDTO;
import com.epmet.dto.form.TimestampIntervalFormDTO;
import com.epmet.dto.form.WorkDayFormDTO;
import com.epmet.dto.result.CostDayResultDTO;
import com.epmet.dto.form.WorkMinuteFormDTO;
import com.epmet.dto.result.WorkDayResultDTO;
import com.epmet.entity.CalenderEntity;
import com.epmet.service.WorkDayService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.*;
/**
@ -28,6 +38,8 @@ public class WorkDayServiceImpl implements WorkDayService {
@Autowired
private CalenderDao calenderDao;
private static SimpleDateFormat format = new SimpleDateFormat(DateUtils.DATE_PATTERN);
private static SimpleDateFormat formatMinute = new SimpleDateFormat(DateUtils.DATE_TIME_PATTERN);
@Override
public List<WorkDayResultDTO> detentionDays(List<WorkDayFormDTO> workDayFormDTO) {
List<WorkDayResultDTO> list = new ArrayList<>();
@ -97,6 +109,45 @@ public class WorkDayServiceImpl implements WorkDayService {
return list;
}
/**
* @Description 计算经历的多少分钟(只计算工作日)
* @param param
* @return java.util.Map<java.lang.String,java.lang.Integer>
* @author wangc
* @date 2020.10.21 16:14
*/
@Override
public Map<String,Integer> workMinutes(WorkMinuteFormDTO param) {
List<TimestampIntervalFormDTO> params = param.getTimeList();
if(CollectionUtils.isEmpty(params)) return null;
Map<String,Integer> result = new LinkedHashMap<>();
//默认非精准计算
if(StringUtils.isBlank(param.getIfPrecise()) || !StringUtils.equals(ProjectConstant.PRECISE_CALCULATION,param.getIfPrecise())){
params.forEach(local -> {
result.put(local.getId(),calculateImpreciseDetentionMinutes(local.getLeft(),local.getRight()));
});
return result;
}
//精准计算
if(StringUtils.isBlank(param.getIfCustom()) || !StringUtils.equals(ProjectConstant.CALCULATION_TYPE_CUSTOM,param.getIfCustom())){
//默认
params.forEach(local -> {
result.put(local.getId(),calculateDetentionMinutes(local.getLeft(),local.getRight()));
});
}else{
//自定义
params.forEach(local -> {
try {
result.put(local.getId(), calculateDetentionMinutesWithStartEnd(local.getLeft(), local.getRight(), param.getStartTemplate(), param.getEndTemplate()));
}catch (Exception e){
throw new RenException(e.getMessage());
}
});
}
return result;
}
//公式: 当前日期 - 被吹日期 - 期间的节假日
private String caculateDetentionDays(String startDateStr, String endDateStr) {
if (startDateStr.equals(endDateStr)) {
@ -130,6 +181,197 @@ public class WorkDayServiceImpl implements WorkDayService {
return "-1";
}
/***
* @Description 计算两个日期之间的非准确时间差(只包括工作日)单位分钟 不足一天按照一天计算
* @param left
* @param right
* @return java.lang.Integer
* @author wangc
* @date 2020.10.21 17:09
*/
private Integer calculateImpreciseDetentionMinutes(Date left, Date right){
if(null == left){ logger.error("计算工作日,传入的开始日期为空!");return null;}
//给右区间赋值,默认当前时间
if(null == right || right.compareTo(left) < NumConstant.ZERO) right = new Date();
List<CalenderEntity> list = calenderDao.selectByStartAndEnd(format.format(left),format.format(right));
if(!CollectionUtils.isEmpty(list)){
//集合中只有一个元素,说明两个时间在同一天
if(list.size() == NumConstant.ONE){
return NumConstant.EIGHT * NumConstant.SIXTY;
}
//集合中有两个元素,说明两个时间是相连的
//集合中有两个元素以上,说明两个时间存在跨度
else{
int costMin = NumConstant.ZERO;
if(NumConstant.TWO == list.size()) return costMin;
for(int index = NumConstant.ZERO ; index < list.size() ; index++)
if(StringUtils.equals(ProjectConstant.DAY_TYPE_WORK,list.get(index).getType()))
costMin += NumConstant.TWENTY_FOUR * NumConstant.SIXTY;
return costMin;
}
}
logger.warn("计算工作日,没有找到开始日期和结束日期,可能数据库中没有存储对应时段的数据,开始时间:{},结束时间:{}",left,right);
return null;
}
/**
* @Description 计算两个日期之间的时间差(只包括工作日)单位分钟
* @param left
* @param right
* @return java.lang.Integer
* @author wangc
* @date 2020.10.21 14:00
*/
private Integer calculateDetentionMinutes(Date left ,Date right){
if(null == left){ logger.error("计算工作日,传入的开始日期为空!");return null;}
//给右区间赋值,默认当前时间
if(null == right || right.compareTo(left) < NumConstant.ZERO) right = new Date();
List<CalenderEntity> list = calenderDao.selectByStartAndEnd(format.format(left),format.format(right));
if(!CollectionUtils.isEmpty(list)){
//集合中只有一个元素,说明两个时间在同一天
if(list.size() == NumConstant.ONE){
if(ProjectConstant.DAY_TYPE_WORK.equals(list.get(NumConstant.ZERO).getType()))
return (int)((right.getTime() - left.getTime())/NumConstant.ONE_THOUSAND/NumConstant.SIXTY);
else {
logger.warn("计算工作日,传入的起始时间都在同一天且是在节假日,开始时间:{},结束时间:{},节日类型:{}(1工作日、2周末、3、节假日)",left,right);
return NumConstant.ZERO;
}
}
//集合中有两个元素,说明两个时间是相连的
//集合中有两个元素以上,说明两个时间存在跨度
else{
String leftType = list.get(NumConstant.ZERO).getType();
String rightType = list.get(list.size() - NumConstant.ONE).getType();
int costMin = NumConstant.ZERO;
if(ProjectConstant.DAY_TYPE_WORK.equals(leftType)){
LocalDateTime localDateTime = LocalDateTime.ofInstant(left.toInstant(), ZoneId.systemDefault());
//获取第第二天零点时刻的实例
LocalDateTime tomorrowTime = LocalDateTime.ofInstant(left.toInstant(), ZoneId.systemDefault())
.plusDays(NumConstant.ONE).withHour(NumConstant.ZERO).withMinute(NumConstant.ZERO).withSecond(NumConstant.ZERO).withNano(NumConstant.ZERO);
//ChronoUnit日期枚举类,between方法计算两个时间对象之间的时间量
costMin += ChronoUnit.SECONDS.between(localDateTime, tomorrowTime)/NumConstant.SIXTY;
}
if(ProjectConstant.DAY_TYPE_WORK.equals(rightType)){
LocalDateTime localDateTime = LocalDateTime.ofInstant(right.toInstant(), ZoneId.systemDefault());
//获取第第二天零点时刻的实例
LocalDateTime initialTime = LocalDateTime.ofInstant(right.toInstant(), ZoneId.systemDefault())
.withHour(NumConstant.ZERO).withMinute(NumConstant.ZERO).withSecond(NumConstant.ZERO).withNano(NumConstant.ZERO);
//ChronoUnit日期枚举类,between方法计算两个时间对象之间的时间量
costMin += ChronoUnit.SECONDS.between(localDateTime, initialTime)/NumConstant.SIXTY;
}
if(NumConstant.TWO == list.size()) return costMin;
for(int index = NumConstant.ONE ; index < list.size() - NumConstant.ONE ; index++)
if(StringUtils.equals(ProjectConstant.DAY_TYPE_WORK,list.get(index).getType()))
costMin += NumConstant.TWENTY_FOUR * NumConstant.SIXTY;
return costMin;
}
}
logger.warn("计算工作日,没有找到开始日期和结束日期,可能数据库中没有存储对应时段的数据,开始时间:{},结束时间:{}",left,right);
return null;
}
/***
* @Description 根据可配置的工作起始时间计算两个日期之间的差
* @param left
* @param right
* @param start 格式为 HH:mm:ss
* @param end 格式为 HH:mm:ss
* @return java.lang.Integer
* @author wangc
* @date 2020.10.20 18:05
*/
private Integer calculateDetentionMinutesWithStartEnd(Date left ,Date right, String start, String end)throws Exception{
if(null == left){ logger.error("计算工作日,传入的开始日期为空!");return null;}
if(null == start || null == end){start = "9:00:00"; end = "17:00:00";}
//给右区间赋值,默认当前时间
if(null == right || right.compareTo(left) < NumConstant.ZERO) right = new Date();
//自定义起始时间
String standardStartDateStr = format.format(left).concat(" ").concat(start);
//自定义截至时间
String standardEndDateStr = format.format(right).concat(" ").concat(end);
Date standardStartDate = formatMinute.parse(standardStartDateStr);
Date standardEndDate = formatMinute.parse(standardEndDateStr);
if(standardEndDate.compareTo(standardStartDate) < NumConstant.ZERO){ logger.error("计算工作日,自定义截止日期小于自定义起始日期!");return null;}
//单位时间内规定起止时间的时间差
Integer delta_T = (int)(standardEndDate.getTime() - formatMinute.parse(format.format(right).concat(" ").concat(start)).getTime())/NumConstant.ONE_THOUSAND/NumConstant.SIXTY;
List<CalenderEntity> list = calenderDao.selectByStartAndEnd(format.format(left),format.format(right));
if(!CollectionUtils.isEmpty(list)){
//集合中只有一个元素,说明两个时间在同一天
if(list.size() == NumConstant.ONE){
if(ProjectConstant.DAY_TYPE_WORK.equals(list.get(NumConstant.ZERO).getType())){
//开始时间早于当天规定开始时间
if(left.before(standardStartDate)){
if(right.before(standardStartDate)){
//结束时间早于当天规定开始时间
logger.warn("计算工作日,开始时间与结数时间均早于当天规定的起止计算时间,开始时间:{},结束时间:{},当天开始时间:{}",left,right,standardStartDate);
return NumConstant.ZERO;
}else if(right.before(standardEndDate)){
return (int)(right.getTime() - standardStartDate.getTime())/NumConstant.ONE_THOUSAND/NumConstant.SIXTY;
}else{
//结束时间晚于当天规定截止时间
return delta_T;
}
}else if(left.before(standardEndDate)){
//开始时间在当天规定起止时间之间
if(right.before(standardEndDate)){
return (int)(right.getTime() - left.getTime())/NumConstant.ONE_THOUSAND/NumConstant.SIXTY;
}else{
return (int)(standardEndDate.getTime() - left.getTime())/NumConstant.ONE_THOUSAND/NumConstant.SIXTY;
}
}else{
logger.warn("计算工作日,开始时间与结数时间晚于当天规定的截止计算时间,开始时间:{},结束时间:{},当天截止时间:{}",left,right,standardEndDate);
return NumConstant.ZERO;
}
}else {
logger.warn("计算工作日,传入的起始时间都在同一天且是在节假日,开始时间:{},结束时间:{},节日类型:{}(1工作日、2周末、3、节假日)",left,right);
return NumConstant.ZERO;
}
}
//集合中有两个元素,说明两个时间是相连的
//集合中有两个元素以上,说明两个时间存在跨度
else{
String leftType = list.get(NumConstant.ZERO).getType();
String rightType = list.get(list.size() - NumConstant.ONE).getType();
int costMin = NumConstant.ZERO;
if(ProjectConstant.DAY_TYPE_WORK.equals(leftType)){
if(left.before(standardStartDate)){
costMin += delta_T;
}else if(left.before(standardEndDate)){
costMin += (formatMinute.parse(format.format(left).concat(" ").concat(end)).getTime() - left.getTime())/NumConstant.ONE_THOUSAND/NumConstant.SIXTY;
}else{
}
}
if(ProjectConstant.DAY_TYPE_WORK.equals(rightType)){
Date leftStandardStartDate = formatMinute.parse(format.format(right).concat(" ").concat(end));
if(right.before(leftStandardStartDate)){
}else if(right.before(standardEndDate)){
costMin += (left.getTime() - leftStandardStartDate.getTime())/NumConstant.ONE_THOUSAND/NumConstant.SIXTY;
}else{
costMin += delta_T;
}
}
if(NumConstant.TWO == list.size()) return costMin;
for(int index = NumConstant.ONE ; index < list.size() - NumConstant.ONE ; index++)
if(StringUtils.equals(ProjectConstant.DAY_TYPE_WORK,list.get(index).getType()))
costMin += delta_T * NumConstant.SIXTY;
return costMin;
}
}
logger.warn("计算工作日,没有找到开始日期和结束日期,可能数据库中没有存储对应时段的数据,开始时间:{},结束时间:{}",left,right);
return null;
}
private Integer getWorkDays(Date start, Date end) {
String startDateStr = DateUtils.format(start, DateUtils.DATE_PATTERN_YYYYMMDD);

1
epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/CalenderDao.xml

@ -61,4 +61,5 @@
AND QUERY_DATE BETWEEN #{begin}
AND #{end}
</select>
</mapper>

113
epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/ProjectOrgRelationDTO.java

@ -0,0 +1,113 @@
/**
* 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;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 项目机关历时关系表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-10-19
*/
@Data
public class ProjectOrgRelationDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
private String id;
/**
* 关联PROJECT_STAFF由此ID可以关联出PROJECT_IDCUSTOMER_IDPROCESS_ID
*/
private String projectStaffId;
/**
* 流转到的日期 同CREATED_TIME
*/
private Date informedDate;
/**
* 流转走或结案的日期
*/
private Date handledDate;
/**
* 节点耗时从流转到自己到流转走共耗时单位分钟如果项目还没有结案且该项目在这个组织下一直滞留这一项为空
* 8*60的倍数
*/
private Integer totalPeriod;
/**
* 第一次响应时间
*/
private Date firstDealtDate;
/**
* 首次响应时长单位分钟
* 8*60的倍数
*/
private Integer firstReplyPeriod;
/**
* 来源动作return(回退)transfer(流转)closed(结案)response(响应)created(立项时第一个流转到的)
*/
private String sourceOperation;
/**
* 处理动作return(回退)transfer(流转)closed(结案)response(响应)
*/
private String operation;
/**
* 删除标识
*/
private String delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
*
*/
private Date createdTime;
/**
*
*/
private String createdBy;
/**
*
*/
private Date updatedTime;
/**
*
*/
private String updatedBy;
}

20
epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/ProjectProcessDTO.java

@ -114,4 +114,24 @@ public class ProjectProcessDTO implements Serializable {
*/
private Date updatedTime;
/**
* 节点发起人所属机关Id
*/
private String agencyId;
/**
* 节点发起人所属部门Id 可空
*/
private String departmentId;
/**
* 节点发起人所属网格Id 可空
*/
private String gridId;
/**
* 节点发起人所属机关全路径
*/
private String orgIdPath;
}

20
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/constant/ProjectConstant.java

@ -128,4 +128,24 @@ public interface ProjectConstant {
String SAVE_PROJECT_EXCEPTION = "已存在项目数据,不能重复转项目";
String REVIEW_PROJECT = "项目评论失败,评论内容为:%s";
/***
* 计算方式 使用自定应
*/
String CALCULATION_TYPE_CUSTOM = "custom";
/**
* 计算方式 使用默认24小时制
*/
String CALCULATION_TYPE_DEFAULT = "default";
/**
* 精准计算
*/
String PRECISE_CALCULATION = "precise";
/**
* 非精准计算
*/
String IMPRECISE_CALCULATION = "imprecise";
}

73
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/ProjectOrgRelationDao.java

@ -0,0 +1,73 @@
/**
* 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;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.ProjectOrgRelationEntity;
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 2020-10-19
*/
@Mapper
public interface ProjectOrgRelationDao extends BaseDao<ProjectOrgRelationEntity> {
/***
* @Description
* @param entity
* @return int
* @author wangc
* @date 2020.10.20 14:18
*/
int maintainTimePropertyConsistency(ProjectOrgRelationEntity entity);
/***
* @Description 批量插入
* @param list
* @return void
* @author wangc
* @date 2020.10.20 09:57
*/
void insertBatch(@Param("list") List<ProjectOrgRelationEntity> list);
/***
* @Description 根据projectStaffId查找项目机关关联的数据
* @param projectStaffId
* @return com.epmet.entity.ProjectOrgRelationEntity
* @author wangc
* @date 2020.10.21 15:37
*/
ProjectOrgRelationEntity selectByProjectStaffId(@Param("projectStaffId") String projectStaffId);
/***
* @Description 查询出所有未处理的节点耗时记录 - 结案时使用
* @param projectId
* @return java.util.List<com.epmet.entity.ProjectOrgRelationEntity>
* @author wangc
* @date 2020.10.22 13:37
*/
List<ProjectOrgRelationEntity> selectAllUnhandledProcess(@Param("projectId")String projectId);
}

19
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/ProjectStaffDao.java

@ -89,4 +89,23 @@ public interface ProjectStaffDao extends BaseDao<ProjectStaffEntity> {
* @return java.util.List<com.epmet.dto.result.StaffUnHandledDTO>
*/
List<StaffUnHandledDTO> getStaffUnHandledList(@Param("customerId") String customerId);
/***
* @Description 根据项目ID查询项目-人员表的ID
* @param projectId
* @return java.util.List<java.lang.String>
* @author wangc
* @date 2020.10.19 18:00
*/
List<String> selectIdByProjectId(@Param("projectId") String projectId);
/**
* @Description 根据项目Id和工作人员Id查找最新的project_staff表的ID
* @param projectId
* @param staffId
* @return com.epmet.dto.ProjectStaffDTO
* @author wangc
* @date 2020.10.21 15:07
*/
ProjectStaffDTO selectLatestByProjectIdAndStaffId(@Param("projectId") String projectId,@Param("staffId") String staffId);
}

83
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ProjectOrgRelationEntity.java

@ -0,0 +1,83 @@
/**
* 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;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 项目机关历时关系表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-10-19
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("project_org_relation")
public class ProjectOrgRelationEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 关联PROJECT_STAFF由此ID可以关联出PROJECT_IDCUSTOMER_IDPROCESS_ID
*/
private String projectStaffId;
/**
* 流转到的日期 同CREATED_TIME
*/
private Date informedDate;
/**
* 流转走或结案的日期
*/
private Date handledDate;
/**
* 节点耗时从流转到自己到流转走共耗时单位分钟如果项目还没有结案且该项目在这个组织下一直滞留这一项为空
* 8*60的倍数
*/
private Integer totalPeriod;
/**
* 第一次响应时间
*/
private Date firstDealtDate;
/**
* 首次响应时长单位分钟
* 8*60的倍数
*/
private Integer firstReplyPeriod;
/**
* 来源动作return(回退)transfer(流转)closed(结案)response(响应)created(立项时第一个流转到的)
*/
private String sourceOperation;
/**
* 处理动作return(回退)transfer(流转)closed(结案)response(响应)
*/
private String operation;
}

25
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ProjectProcessEntity.java

@ -43,6 +43,11 @@ public class ProjectProcessEntity extends BaseEpmetEntity {
*/
private String projectId;
/**
* 项目改造新增字段客户Id
*/
private String customerId;
/**
* 部门名
*/
@ -83,4 +88,24 @@ public class ProjectProcessEntity extends BaseEpmetEntity {
*/
private String costWorkdays;
/**
* 节点发起人所属机关Id
*/
private String agencyId;
/**
* 节点发起人所属部门Id 可空
*/
private String departmentId;
/**
* 节点发起人所属网格Id 可空
*/
private String gridId;
/**
* 节点发起人所属机关全路径
*/
private String orgIdPath;
}

19
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ProjectStaffService.java

@ -150,4 +150,23 @@ public interface ProjectStaffService extends BaseService<ProjectStaffEntity> {
* @return java.util.List<com.epmet.dto.result.StaffUnHandledDTO>
*/
List<StaffUnHandledDTO> getStaffUnHandledList(String customerId);
/***
* @Description 根据项目ID查询项目-人员表的ID
* @param projectId
* @return java.util.List<java.lang.String>
* @author wangc
* @date 2020.10.19 18:00
*/
List<String> getIdByProjectId(String projectId);
/**
* @Description 根据项目Id和工作人员Id查找最新的project_staff表的ID
* @param projectId
* @param staffId
* @return com.epmet.dto.ProjectStaffDTO
* @author wangc
* @date 2020.10.21 15:07
*/
ProjectStaffDTO getLatestIdByProjectIdAndStaffId(String projectId,String staffId);
}

59
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectProcessServiceImpl.java

@ -17,6 +17,7 @@
package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
@ -35,25 +36,30 @@ import com.epmet.commons.tools.utils.ScanContentUtils;
import com.epmet.constant.ProjectConstant;
import com.epmet.constant.ReadFlagConstant;
import com.epmet.constant.UserMessageConstant;
import com.epmet.dao.ProjectOrgRelationDao;
import com.epmet.dao.ProjectProcessDao;
import com.epmet.dao.ProjectStaffDao;
import com.epmet.dto.ProjectProcessDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.entity.ProjectEntity;
import com.epmet.entity.ProjectOrgRelationEntity;
import com.epmet.entity.ProjectProcessEntity;
import com.epmet.entity.ProjectStaffEntity;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.feign.EpmetUserFeignClient;
import com.epmet.feign.GovOrgFeignClient;
import com.epmet.redis.ProjectProcessRedis;
import com.epmet.service.ProjectProcessService;
import com.epmet.service.ProjectService;
import com.epmet.service.ProjectStaffService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
@ -65,6 +71,7 @@ import java.util.stream.Collectors;
* @since v1.0.0 2020-05-11
*/
@Service
@Slf4j
public class ProjectProcessServiceImpl extends BaseServiceImpl<ProjectProcessDao, ProjectProcessEntity> implements ProjectProcessService {
@Autowired
@ -83,6 +90,10 @@ public class ProjectProcessServiceImpl extends BaseServiceImpl<ProjectProcessDao
private ProjectStaffService projectStaffService;
@Autowired
private com.epmet.feign.MessageFeignClient messageFeignClient;
@Autowired
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
@Autowired
private ProjectOrgRelationDao relationDao;
@Value("${openapi.scan.server.url}")
private String scanApiUrl;
@Value("${openapi.scan.method.textSyncScan}")
@ -215,12 +226,18 @@ public class ProjectProcessServiceImpl extends BaseServiceImpl<ProjectProcessDao
if (projectStaffDao.updateById(staffEntity) < NumConstant.ONE) {
throw new RenException(ProjectConstant.UPDATE_PROJECTSTAFF_EXCEPTION);
}
//2:项目处理进展列表新增数据
ProjectProcessEntity processEntity = ConvertUtils.sourceToTarget(formDTO, ProjectProcessEntity.class);
processEntity.setCustomerId(staffEntity.getCustomerId());
processEntity.setDepartmentName(staffEntity.getDepartmentName());
processEntity.setStaffId(staffEntity.getStaffId());
processEntity.setOperation(ProjectConstant.OPERATION_TRANSFER);
processEntity.setOperationName(ProjectConstant.OPERATION_TRANSFER_NAME);
processEntity.setAgencyId(staffEntity.getOrgId());
processEntity.setDepartmentId(staffEntity.getDepartmentId());
processEntity.setGridId(staffEntity.getGridId());
processEntity.setOrgIdPath(staffEntity.getOrgIdPath());
projectProcessDao.insert(processEntity);
//3:项目人员关联表新增部门流转数据
List<TickStaffFormDTO> staffList = formDTO.getStaffList();
@ -276,6 +293,48 @@ public class ProjectProcessServiceImpl extends BaseServiceImpl<ProjectProcessDao
});
projectStaffService.insertBatch(entityList);
//3.3 项目机关历时关系 project_org_relation 更新原来的
ProjectOrgRelationEntity orientRelation = relationDao.selectByProjectStaffId(staffEntity.getId());
if(null == orientRelation){
log.error("com.epmet.service.impl.ProjectProcessServiceImpl.transfer,找不到项目节点机关历时记录,参数:{}",JSON.toJSONString(formDTO));
}
Date current = new Date();
WorkMinuteFormDTO timeParam = new WorkMinuteFormDTO();
timeParam.setIfPrecise(ProjectConstant.IMPRECISE_CALCULATION);
timeParam.setIfCustom(ProjectConstant.CALCULATION_TYPE_DEFAULT);
TimestampIntervalFormDTO interval = new TimestampIntervalFormDTO(orientRelation.getProjectStaffId(),orientRelation.getInformedDate(),current);
List<TimestampIntervalFormDTO> intervalList = new LinkedList<>();intervalList.add(interval);
timeParam.setTimeList(intervalList);
Result<Map<String,Integer>> timeResult = epmetCommonServiceOpenFeignClient.workMinutes(timeParam);
if(timeResult.success() && !CollectionUtils.isEmpty(timeResult.getData()) && null != timeResult.getData().get(staffEntity.getId())){
ProjectOrgRelationEntity relationDto = new ProjectOrgRelationEntity();
relationDto.setProjectStaffId(orientRelation.getProjectStaffId());
relationDto.setHandledDate(current);
relationDto.setTotalPeriod(timeResult.getData().get(staffEntity.getId()));
relationDto.setOperation(ProjectConstant.OPERATION_TRANSFER);
if(null == orientRelation.getFirstDealtDate()){
relationDto.setFirstDealtDate(current);
relationDto.setFirstReplyPeriod(relationDto.getTotalPeriod());
}
relationDao.maintainTimePropertyConsistency(relationDto);
}else{
log.error("com.epmet.service.impl.ProjectProcessServiceImpl.transfer,计算节点耗时失败,参数:{}", JSON.toJSONString(timeParam));
throw new RenException("计算节点耗时失败");
}
//3.4 项目机关历时关系 project_org_relation 插入新增的
List<ProjectOrgRelationEntity> relationList = new LinkedList<>();
entityList.forEach(staff -> {
ProjectOrgRelationEntity relation = new ProjectOrgRelationEntity();
relation.setProjectStaffId(staff.getId());
relation.setInformedDate(current);
relation.setSourceOperation(ProjectConstant.OPERATION_TRANSFER);
relationList.add(relation);
});
relationDao.insertBatch(relationList);
//4:调用epmet-message服务,给项目流转过程中的工作人员发送消息
if (!transferMessage(formDTO).success()) {
throw new RenException(ProjectConstant.SAVE_MSG_EXCEPTION);

204
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java

@ -17,6 +17,7 @@
package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
@ -28,30 +29,29 @@ import com.epmet.commons.tools.scan.param.TextScanParamDTO;
import com.epmet.commons.tools.scan.param.TextTaskDTO;
import com.epmet.commons.tools.scan.result.SyncScanResult;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.ScanContentUtils;
import com.epmet.constant.ParameterKeyConstant;
import com.epmet.constant.ProjectConstant;
import com.epmet.constant.UserMessageConstant;
import com.epmet.dao.ProjectDao;
import com.epmet.dao.ProjectOrgRelationDao;
import com.epmet.dto.*;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.entity.ProjectEntity;
import com.epmet.entity.ProjectProcessEntity;
import com.epmet.entity.ProjectRelatedPersonnelEntity;
import com.epmet.entity.ProjectStaffEntity;
import com.epmet.entity.*;
import com.epmet.feign.*;
import com.epmet.redis.ProjectRedis;
import com.epmet.service.*;
import org.apache.commons.collections4.CollectionUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@ -63,6 +63,7 @@ import java.util.stream.Collectors;
* @since v1.0.0 2020-05-11
*/
@Service
@Slf4j
public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntity> implements ProjectService {
@Autowired
@ -89,6 +90,8 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
private String scanApiUrl;
@Value("${openapi.scan.method.textSyncScan}")
private String textSyncScanMethod;
@Autowired
private ProjectOrgRelationDao relationDao;
private final static String ONE_DAY = "<1";
@ -357,6 +360,8 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
if (ProjectConstant.CLOSED.equals(projectEntity.getStatus())) {
throw new RenException(EpmetErrorCode.PROJECT_IS_CLOSED.getCode());
}
Date current = new Date();
projectEntity.setStatus(ProjectConstant.CLOSED);
projectEntity.setClosedStatus(fromDTO.getClosedStatus());
baseDao.updateById(projectEntity);
@ -366,19 +371,66 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
projectStaffEntity.setIsHandle(ProjectConstant.HANDLE);
projectStaffService.updateById(projectStaffEntity);
//查询结案人员的信息
ProjectStaffEntity operatorProjectReference = projectStaffService.selectById(fromDTO.getProjectStaffId());
if(null == operatorProjectReference){
log.error("com.epmet.service.impl.ProjectServiceImpl.closed,找不到结案工作人员的相关记录,参数:{}",JSON.toJSONString(fromDTO));
throw new RenException("找不到结案工作人员的相关记录");
}
//结案记录加入项目进展表
ProjectProcessEntity projectProcessEntity = new ProjectProcessEntity();
projectProcessEntity.setProjectId(fromDTO.getProjectId());
projectProcessEntity.setCustomerId(operatorProjectReference.getCustomerId());
projectProcessEntity.setDepartmentName(fromDTO.getDepartmentName());
projectProcessEntity.setAgencyId(operatorProjectReference.getOrgId());
projectProcessEntity.setGridId(operatorProjectReference.getGridId());
projectProcessEntity.setDepartmentId(operatorProjectReference.getDepartmentId());
projectProcessEntity.setOrgIdPath(operatorProjectReference.getOrgIdPath());
projectProcessEntity.setEndTime(new Date());
projectProcessEntity.setOperation(ProjectConstant.OPERATION_CLOSE);
projectProcessEntity.setOperationName(ProjectConstant.OPERATION_CLOSE_NAME);
projectProcessEntity.setPublicReply(fromDTO.getPublicReply());
projectProcessEntity.setInternalRemark(fromDTO.getInternalRemark());
projectProcessEntity.setStaffId(fromDTO.getUserId());
projectProcessEntity.setCostWorkdays(getDetentionDays(ConvertUtils.sourceToTarget(projectEntity, ProjectDTO.class)));
ProjectDTO projectDto = ConvertUtils.sourceToTarget(projectEntity, ProjectDTO.class);
projectDto.setUpdatedTime(projectDto.getCreatedTime());
projectProcessEntity.setCostWorkdays(getDetentionDays(projectDto));
projectProcessService.insert(projectProcessEntity);
//对项目节点耗时记录进行更新,更新全部未处理节点以及结案人的节点耗时
//List<ProjectOrgRelationEntity> periodsToUpdate = relationDao.selectAllUnhandledProcess(fromDTO.getProjectId());
//if(CollectionUtils.isEmpty(periodsToUpdate)){
// log.error("com.epmet.service.impl.ProjectServiceImpl.closed,至少存在一条处理时间为空的项目节点耗时记录,但是没有找到,参数:{}",JSON.toJSONString(fromDTO));
// throw new RenException("至少存在一条处理时间为空的项目节点耗时记录,但是没有找到");
//}
//List<TimestampIntervalFormDTO> intervalList = new LinkedList<>();
//periodsToUpdate.forEach(local -> {
// TimestampIntervalFormDTO obj = new TimestampIntervalFormDTO();
// obj.setId(local.getProjectStaffId());
// obj.setLeft(local.getInformedDate());
// obj.setRight(current);
// intervalList.add(obj);
//});
ProjectOrgRelationEntity orientRelation = relationDao.selectByProjectStaffId(operatorProjectReference.getId());
if(null == orientRelation){
log.error("com.epmet.service.impl.ProjectServiceImpl.closed,找不到结案工作人员的节点耗时相关记录,参数:{}",JSON.toJSONString(fromDTO));
throw new RenException("找不到结案工作人员的节点耗时相关记录");
}
Integer delta_t = calculateDelta_T(ProjectConstant.IMPRECISE_CALCULATION,
ProjectConstant.CALCULATION_TYPE_DEFAULT, operatorProjectReference.getId(),orientRelation.getInformedDate(),current);
ProjectOrgRelationEntity carrier = new ProjectOrgRelationEntity();
carrier.setProjectStaffId(operatorProjectReference.getId());
carrier.setOperation(ProjectConstant.OPERATION_CLOSE);
carrier.setHandledDate(current);
carrier.setFirstReplyPeriod(delta_t);
relationDao.maintainTimePropertyConsistency(carrier);
//通知
List<UserMessageFormDTO> msgList = new ArrayList<>();
//通知项目相关人员
@ -436,16 +488,30 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
throw new RenException(EpmetErrorCode.PROJECT_IS_CLOSED.getCode());
}
Date current = new Date();
//更新项目关联表
ProjectStaffEntity projectStaffEntity = new ProjectStaffEntity();
projectStaffEntity.setId(fromDTO.getProjectStaffId());
projectStaffEntity.setIsHandle(ProjectConstant.HANDLE);
projectStaffService.updateById(projectStaffEntity);
//查找对应的project_staff的信息,为了取出机关的信息,给即将要生成的“退回”节点赋值
ProjectStaffEntity sourceProjectStaff = projectStaffService.selectById(fromDTO.getProjectStaffId());
if(null == sourceProjectStaff){
log.error("com.epmet.service.impl.ProjectServiceImpl.projectReturn,找不到发起退回的项目相关人员的记录,参数:{}",JSON.toJSONString(fromDTO));
throw new RenException("找不到发起退回的项目相关人员的记录");
}
//结案记录加入项目进展表
ProjectProcessEntity projectProcessEntity = new ProjectProcessEntity();
projectProcessEntity.setProjectId(fromDTO.getProjectId());
projectProcessEntity.setCustomerId(sourceProjectStaff.getCustomerId());
projectProcessEntity.setDepartmentName(fromDTO.getDepartmentName());
projectProcessEntity.setOrgIdPath(sourceProjectStaff.getOrgIdPath());
projectProcessEntity.setGridId(sourceProjectStaff.getGridId());
projectProcessEntity.setDepartmentId(sourceProjectStaff.getDepartmentId());
projectProcessEntity.setAgencyId(sourceProjectStaff.getOrgId());
projectProcessEntity.setOperation(ProjectConstant.OPERATION_RETURN);
projectProcessEntity.setOperationName(ProjectConstant.OPERATION_RETURN_NAME);
projectProcessEntity.setPublicReply(fromDTO.getPublicReply());
@ -458,12 +524,41 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
ProjectStaffEntity projectStaff = ConvertUtils.sourceToTarget(projectStaffDTO, ProjectStaffEntity.class);
projectStaff.setId(null);
//防止将被退回的项目相关人员节点的创建时间赋值给新增的相关人员节点的创建时间,否则数据统计将出现误差
projectStaff.setCreatedTime(null);
projectStaff.setUpdatedTime(null);
projectStaff.setCreatedTime(current);
projectStaff.setUpdatedTime(current);
projectStaff.setProcessId(projectProcessEntity.getId());
projectStaff.setIsHandle(ProjectConstant.UNHANDLED);
projectStaffService.insert(projectStaff);
//更新退回发起人的节点耗时记录
ProjectOrgRelationEntity orientRelation = relationDao.selectByProjectStaffId(fromDTO.getProjectStaffId());
if(null == orientRelation){
log.error("com.epmet.service.impl.ProjectServiceImpl.projectReturn,找不到发起退回的项目相关人员的节点耗时记录,参数:{}",JSON.toJSONString(fromDTO));
throw new RenException("找不到发起退回的项目相关人员的节点耗时记录");
}
ProjectOrgRelationEntity relationDto = new ProjectOrgRelationEntity();
relationDto.setProjectStaffId(orientRelation.getProjectStaffId());
relationDto.setHandledDate(current);
Integer costTime = calculateDelta_T(ProjectConstant.IMPRECISE_CALCULATION,
ProjectConstant.CALCULATION_TYPE_DEFAULT,
orientRelation.getProjectStaffId(),
orientRelation.getInformedDate(),
current);
relationDto.setTotalPeriod(costTime);
relationDto.setOperation(ProjectConstant.OPERATION_RETURN);
if(null == orientRelation.getFirstDealtDate()){
relationDto.setFirstDealtDate(current);
relationDto.setFirstReplyPeriod(costTime);
}
relationDao.maintainTimePropertyConsistency(relationDto);
//初始化被退回人的节点耗时记录
ProjectOrgRelationEntity newRelation = new ProjectOrgRelationEntity();
newRelation.setProjectStaffId(projectStaff.getId());
newRelation.setSourceOperation(ProjectConstant.OPERATION_RETURN);
newRelation.setInformedDate(current);
relationDao.insert(newRelation);
//通知
List<UserMessageFormDTO> msgList = new ArrayList<>();
UserMessageFormDTO messageFormDTO = new UserMessageFormDTO();
@ -592,6 +687,7 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
//3:项目处理进展表新增数据
ProjectProcessEntity processEntity = new ProjectProcessEntity();
processEntity.setProjectId(projectEntity.getId());
processEntity.setCustomerId(issueDTO.getCustomerId());
processEntity.setStaffId(formDTO.getStaffId());
processEntity.setOperation(ProjectConstant.OPERATION_CREATED);
processEntity.setOperationName(ProjectConstant.OPERATION_CREATED_NAME);
@ -600,11 +696,18 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
agencyDeptGrid.getAgencyList().forEach(agency -> {
if (issueDTO.getOrgId().equals(agency.getId())) {
processEntity.setDepartmentName(agency.getOrganizationName());
processEntity.setAgencyId(agency.getId());
if(StringUtils.isBlank(agency.getPids()) || StringUtils.equals(NumConstant.ZERO_STR,agency.getPids().trim()) || "".equals(agency.getPids().trim())){
processEntity.setOrgIdPath(agency.getId());
}else{
processEntity.setOrgIdPath(agency.getPids().concat(":").concat(agency.getId()));
}
}
});
agencyDeptGrid.getGridList().forEach(grid -> {
if (issueDTO.getGridId().equals(grid.getId())) {
processEntity.setDepartmentName(processEntity.getDepartmentName() + "-" + grid.getGridName());
processEntity.setGridId(grid.getId());
}
});
projectProcessService.insert(processEntity);
@ -642,6 +745,24 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
});
projectStaffService.insertBatch(entityList);
//7:初始化机关-项目时间关联数据
Date current = new Date();
List<String> projectStaffIds = entityList.stream().map(ProjectStaffEntity::getId).distinct().collect(Collectors.toList());
if(!CollectionUtils.isEmpty(projectStaffIds)){
List<ProjectOrgRelationEntity> container = new LinkedList<>();
projectStaffIds.forEach(o -> {
ProjectOrgRelationEntity period = new ProjectOrgRelationEntity();
period.setProjectStaffId(o);
period.setInformedDate(current);
//created
period.setSourceOperation(ProjectConstant.OPERATION_CREATED);
period.setCreatedBy(formDTO.getStaffId());
container.add(period);
});
relationDao.insertBatch(container);
}
//5:项目相关人员表初始数据
List<ProjectRelatedPersonnelEntity> list = new ArrayList<>();
ProjectRelatedPersonnelEntity entity1 = new ProjectRelatedPersonnelEntity();
@ -659,6 +780,8 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
issueProjectResultDTO.setProjectId(projectEntity.getId());
issueProjectResultDTO.setOrgName(processEntity.getDepartmentName());
issueProjectResultDTO.setShiftedTime(projectEntity.getCreatedTime());
return issueProjectResultDTO;
}
@ -670,7 +793,6 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
**/
@Override
public List<LatestListResultDTO> getClosedProjectList(LatestListFormDTO formDTO) {
return baseDao.selectClosedProjectList(formDTO);
}
@ -698,17 +820,81 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
if (ProjectConstant.CLOSED.equals(projectEntity.getStatus())) {
throw new RenException(EpmetErrorCode.PROJECT_IS_CLOSED.getCode());
}
ProjectStaffDTO projectStaff = projectStaffService.getLatestIdByProjectIdAndStaffId(formDTO.getProjectId(),formDTO.getUserId());
if(null == projectStaff){
log.error("com.epmet.service.impl.ProjectServiceImpl.response,project_staff表中没有与之对应的数据,传参:{}", JSON.toJSONString(formDTO));
throw new RenException("未找到项目相关人员记录");
}
if(StringUtils.isBlank(formDTO.getProjectStaffId())){
formDTO.setProjectStaffId(projectStaff.getId());
}
//处理响应记录加入项目进展表
ProjectProcessEntity projectProcessEntity = new ProjectProcessEntity();
projectProcessEntity.setProjectId(formDTO.getProjectId());
projectEntity.setCustomerId(projectStaff.getCustomerId());
projectProcessEntity.setDepartmentName(formDTO.getDepartmentName());
projectProcessEntity.setOrgIdPath(projectStaff.getOrgIdPath());
projectProcessEntity.setGridId(projectStaff.getGridId());
projectProcessEntity.setDepartmentId(projectStaff.getDepartmentId());
projectProcessEntity.setAgencyId(projectStaff.getOrgId());
projectProcessEntity.setOperation(ProjectConstant.OPERATION_RESPONSES);
projectProcessEntity.setOperationName(ProjectConstant.OPERATION_RESPONSES_NAME);
projectProcessEntity.setPublicReply(formDTO.getPublicReply());
projectProcessEntity.setInternalRemark(formDTO.getInternalRemark());
projectProcessEntity.setStaffId(formDTO.getUserId());
projectProcessService.insert(projectProcessEntity);
//项目节点历时
ProjectOrgRelationEntity relationEntity = relationDao.selectByProjectStaffId(formDTO.getProjectStaffId());
if(null != relationEntity){
ProjectOrgRelationEntity relationDto = new ProjectOrgRelationEntity();
relationDto.setProjectStaffId(relationEntity.getProjectStaffId());
if(null == relationEntity.getFirstDealtDate()){
Date current = new Date();
relationDto.setFirstDealtDate(current);
relationDto.setFirstReplyPeriod(calculateDelta_T(ProjectConstant.IMPRECISE_CALCULATION,
ProjectConstant.CALCULATION_TYPE_DEFAULT,projectStaff.getId(),
relationEntity.getInformedDate(),current));
relationDto.setOperation(ProjectConstant.OPERATION_RESPONSES);
relationDao.maintainTimePropertyConsistency(relationDto);
}
}else{
log.error("com.epmet.service.impl.ProjectServiceImpl#response,没有找到相关的节点耗时记录,参数:{}",JSON.toJSONString(formDTO));
throw new RenException("没有找到相关的节点耗时记录");
}
}
private Integer calculateDelta_T(String ifPrecise,String ifCustom,String identity,Date left,Date right){
WorkMinuteFormDTO timeParam = new WorkMinuteFormDTO();
timeParam.setIfPrecise(ifPrecise);
timeParam.setIfCustom(ifCustom);
TimestampIntervalFormDTO interval = new TimestampIntervalFormDTO(identity,left,right);
List<TimestampIntervalFormDTO> intervalList = new LinkedList<>();intervalList.add(interval);
timeParam.setTimeList(intervalList);
Result<Map<String,Integer>> timeResult = epmetCommonServiceOpenFeignClient.workMinutes(timeParam);
if(timeResult.success() && !org.springframework.util.CollectionUtils.isEmpty(timeResult.getData()) && null != timeResult.getData().get(identity)){
return timeResult.getData().get(identity);
}else{
log.error("com.epmet.service.impl.ProjectServiceImpl.response,计算首次响应时间失败");
throw new RenException("计算首次响应时间失败");
}
}
private Map<String,Integer> batchCalculateDelta_T(String ifPrecise,String ifCustom,List<TimestampIntervalFormDTO> intervalList){
WorkMinuteFormDTO timeParam = new WorkMinuteFormDTO();
timeParam.setIfPrecise(ifPrecise);
timeParam.setIfCustom(ifCustom);
timeParam.setTimeList(intervalList);
Result<Map<String,Integer>> timeResult = epmetCommonServiceOpenFeignClient.workMinutes(timeParam);
if(timeResult.success() && !org.springframework.util.CollectionUtils.isEmpty(timeResult.getData())){
return timeResult.getData();
}else{
log.error("com.epmet.service.impl.ProjectServiceImpl.response,计算首次响应时间失败");
throw new RenException("计算首次响应时间失败");
}
}
/**

25
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectStaffServiceImpl.java

@ -169,4 +169,29 @@ public class ProjectStaffServiceImpl extends BaseServiceImpl<ProjectStaffDao, Pr
return baseDao.getStaffUnHandledList(customerId);
}
/***
* @Description 根据项目ID查询项目-人员表的ID
* @param projectId
* @return java.util.List<java.lang.String>
* @author wangc
* @date 2020.10.19 18:00
*/
@Override
public List<String> getIdByProjectId(String projectId) {
return baseDao.selectIdByProjectId(projectId);
}
/**
* @Description 根据项目Id和工作人员Id查找最新的project_staff表的ID
* @param projectId
* @param staffId
* @return com.epmet.dto.ProjectStaffDTO
* @author wangc
* @date 2020.10.21 15:07
*/
@Override
public ProjectStaffDTO getLatestIdByProjectIdAndStaffId(String projectId, String staffId) {
return baseDao.selectLatestByProjectIdAndStaffId(projectId,staffId);
}
}

106
epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ProjectOrgRelationDao.xml

@ -0,0 +1,106 @@
<?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.ProjectOrgRelationDao">
<resultMap type="com.epmet.entity.ProjectOrgRelationEntity" id="projectOrgRelationMap">
<result property="id" column="ID"/>
<result property="projectStaffId" column="PROJECT_STAFF_ID"/>
<result property="informedDate" column="INFORMED_DATE"/>
<result property="handledDate" column="HANDLED_DATE"/>
<result property="totalPeriod" column="TOTAL_PERIOD"/>
<result property="firstDealtDate" column="FIRST_DEALT_DATE"/>
<result property="firstReplyPeriod" column="FIRST_REPLY_PERIOD"/>
<result property="operation" column="OPERATION"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
</resultMap>
<!-- 维护时间属性的一致性 -->
<update id="maintainTimePropertyConsistency" parameterType="com.epmet.entity.ProjectOrgRelationEntity">
UPDATE
project_org_relation
<set>
<if test="null != firstDealtDate">
FIRST_DEALT_DATE = #{firstDealtDate},
UPDATED_TIME = #{firstDealtDate},
FIRST_REPLY_PERIOD = #{firstReplyPeriod},
</if>
<if test="null != handledDate">
HANDLED_DATE = #{handledDate},
UPDATED_TIME = #{handledDate},
TOTAL_PERIOD = #{totalPeriod},
</if>
OPERATION = #{operation}
</set>
<where>
DEL_FLAG = '0'
AND PROJECT_STAFF_ID = #{projectStaffId}
<if test="null != firstDealtDate">
AND FIRST_DEALT_DATE IS NULL
</if>
</where>
</update>
<!-- 批量插入 -->
<insert id="insertBatch" parameterType="java.util.List">
INSERT INTO project_org_relation(
ID,
PROJECT_STAFF_ID,
INFORMED_DATE,
CREATED_TIME,
UPDATED_TIME,
SOURCE_OPERATION,
CREATED_BY,
UPDATED_BY
) values
<foreach collection="list" item="item" index="index" separator=",">
(
(SELECT REPLACE(UUID(),'-','') as id),
#{item.projectStaffId},
<choose>
<when test="null == item.informedDate">
NOW(),
NOW(),
NOW(),
</when>
<otherwise>
#{item.informedDate},
#{item.informedDate},
#{item.informedDate},
</otherwise>
</choose>
#{item.sourceOperation},
#{item.createdBy},
#{item.createdBy}
)
</foreach>
</insert>
<select id="selectByProjectStaffId" resultType="com.epmet.entity.ProjectOrgRelationEntity">
SELECT
*
FROM
project_org_relation
WHERE
PROJECT_STAFF_ID = #{projectStaffId}
</select>
<select id="selectAllUnhandledProcess" resultType="com.epmet.entity.ProjectOrgRelationEntity">
SELECT
period.*
FROM
project_org_relation period
INNER JOIN project_staff staff ON period.PROJECT_STAFF_ID = staff.ID AND staff.DEL_FLAG = '0' AND staff.PROJECT_ID = #{projectId}
WHERE
period.DEL_FLAG = '0'
AND
HANDLED_DATE IS NULL
</select>
</mapper>

30
epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ProjectStaffDao.xml

@ -110,4 +110,34 @@
AND ps.CUSTOMER_ID = #{customerId}
</select>
<!-- 根据项目ID查询项目-人员表的ID -->
<select id="selectIdByProjectId" resultType="java.lang.String">
SELECT
ID
FROM
project_staff
WHERE
DEL_FLAG = '0'
AND
PROJECT_ID = #{projectId}
</select>
<!-- 根据项目Id和工作人员Id查找最新的project_staff表的ID -->
<select id="selectLatestByProjectIdAndStaffId" resultType="com.epmet.dto.ProjectStaffDTO">
SELECT
*
FROM
project_staff
WHERE
DEL_FLAG = '0'
AND
PROJECT_ID = #{projectId}
AND
STAFF_ID = #{staffId}
AND
IS_HANDLE = 'unhandled'
ORDER BY UPDATED_TIME DESC
LIMIT 1
</select>
</mapper>
Loading…
Cancel
Save