|
|
@ -1,15 +1,29 @@ |
|
|
|
package com.hnac.hzims.ticket.twoTicket.service.impl; |
|
|
|
package com.hnac.hzims.ticket.twoTicket.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.main.constant.HomePageConstant; |
|
|
|
|
|
|
|
import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketInfoEntity; |
|
|
|
|
|
|
|
import com.hnac.hzims.ticket.standardTicket.service.IStandardTicketInfoService; |
|
|
|
import com.hnac.hzims.ticket.standardTicket.vo.CensParamVo; |
|
|
|
import com.hnac.hzims.ticket.standardTicket.vo.CensParamVo; |
|
|
|
import com.hnac.hzims.ticket.standardTicket.vo.CensVo; |
|
|
|
import com.hnac.hzims.ticket.standardTicket.vo.CensVo; |
|
|
|
import com.hnac.hzims.ticket.standardTicket.vo.CensYearParamVo; |
|
|
|
import com.hnac.hzims.ticket.standardTicket.vo.CensYearParamVo; |
|
|
|
import com.hnac.hzims.ticket.standardTicket.vo.CensYearVo; |
|
|
|
import com.hnac.hzims.ticket.standardTicket.vo.CensYearVo; |
|
|
|
import com.hnac.hzims.ticket.twoTicket.service.CensService; |
|
|
|
import com.hnac.hzims.ticket.twoTicket.service.CensService; |
|
|
|
|
|
|
|
import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; |
|
|
|
|
|
|
|
import com.hnac.hzims.ticket.workTicket.service.IWorkTicketInfoService; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
|
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
|
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
|
|
|
|
import org.springblade.system.entity.Dept; |
|
|
|
|
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -20,14 +34,147 @@ import java.util.List; |
|
|
|
@RequiredArgsConstructor |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class CensServiceImpl implements CensService { |
|
|
|
public class CensServiceImpl implements CensService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IStandardTicketInfoService operateTicketService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IWorkTicketInfoService workTicketInfoService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final ISysClient sysClient; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<CensVo> cens(CensParamVo param) { |
|
|
|
public List<CensVo> cens(CensParamVo param) { |
|
|
|
return null; |
|
|
|
if(StringUtil.isEmpty(param.getStartTime())){ |
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
calendar.setTime(new Date()); |
|
|
|
|
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,-calendar.get(Calendar.DAY_OF_MONTH)); |
|
|
|
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY)); |
|
|
|
|
|
|
|
calendar.add(Calendar.MINUTE,-calendar.get(Calendar.MINUTE)); |
|
|
|
|
|
|
|
calendar.add(Calendar.SECOND,-calendar.get(Calendar.SECOND)); |
|
|
|
|
|
|
|
param.setStartTime(DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(StringUtil.isEmpty(param.getEndTime())){ |
|
|
|
|
|
|
|
param.setStartTime(DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(!StringUtil.isEmpty(param.getState()) && param.getState().equals(1)){ |
|
|
|
|
|
|
|
param.setFlowTaskName("结束"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取权限区域机构
|
|
|
|
|
|
|
|
List<Dept> depts = this.authArea(); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(depts)){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 操作票查询
|
|
|
|
|
|
|
|
LambdaQueryWrapper operateWrapper = Wrappers.<StandardTicketInfoEntity>lambdaQuery() |
|
|
|
|
|
|
|
.between(StandardTicketInfoEntity::getCreateTime,param.getStartTime(),param.getEndTime()) |
|
|
|
|
|
|
|
.in(StandardTicketInfoEntity::getCreateDept,depts); |
|
|
|
|
|
|
|
if(!StringUtil.isEmpty(param.getFlowTaskName())){ |
|
|
|
|
|
|
|
operateWrapper.eq("FLOW_TASK_NAME",param.getFlowTaskName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<StandardTicketInfoEntity> operates = operateTicketService.list(operateWrapper); |
|
|
|
|
|
|
|
// 工作票查询
|
|
|
|
|
|
|
|
LambdaQueryWrapper workWrapper = Wrappers.<StandardTicketInfoEntity>lambdaQuery() |
|
|
|
|
|
|
|
.between(StandardTicketInfoEntity::getCreateTime,param.getStartTime(),param.getEndTime()) |
|
|
|
|
|
|
|
.in(StandardTicketInfoEntity::getCreateDept,depts); |
|
|
|
|
|
|
|
if(!StringUtil.isEmpty(param.getFlowTaskName())){ |
|
|
|
|
|
|
|
workWrapper.eq("FLOW_TASK_NAME",param.getFlowTaskName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<WorkTicketInfoEntity> works = workTicketInfoService.list(workWrapper); |
|
|
|
|
|
|
|
// 工作任务单
|
|
|
|
|
|
|
|
return depts.stream().map(dept->{ |
|
|
|
|
|
|
|
CensVo cens = new CensVo(); |
|
|
|
|
|
|
|
cens.setDeptId(dept.getId()); |
|
|
|
|
|
|
|
cens.setDeptName(dept.getDeptName()); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(operates)){ |
|
|
|
|
|
|
|
cens.setOperateCount(0L); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
cens.setOperateCount(operates.stream().filter(operate->operate.getCreateDept().equals(dept.getId())).count()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(works)){ |
|
|
|
|
|
|
|
cens.setWorkCount(0L); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
cens.setOperateCount(works.stream().filter(work->work.getCreateDept().equals(dept.getId())).count()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
cens.setWorkTaskCount((long)new Random().nextInt(10)); |
|
|
|
|
|
|
|
return cens; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取权限区域机构 |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<Dept> authArea() { |
|
|
|
|
|
|
|
R<List<Dept>> resut = sysClient.getDeptByCurrentUser(); |
|
|
|
|
|
|
|
if(!resut.isSuccess() || CollectionUtil.isEmpty(resut.getData())){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return resut.getData().stream().filter(dept->dept.getDeptCategory().equals(HomePageConstant.AREA)).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<CensYearVo> censYear(CensYearParamVo param) { |
|
|
|
public List<CensYearVo> censYear(CensYearParamVo param) { |
|
|
|
return null; |
|
|
|
if(StringUtil.isEmpty(param.getYear())){ |
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
calendar.add(Calendar.MONTH,-calendar.get(Calendar.MONTH)); |
|
|
|
|
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,-calendar.get(Calendar.DAY_OF_MONTH)); |
|
|
|
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY)); |
|
|
|
|
|
|
|
calendar.add(Calendar.MINUTE,-calendar.get(Calendar.MINUTE)); |
|
|
|
|
|
|
|
calendar.add(Calendar.SECOND,-calendar.get(Calendar.SECOND)); |
|
|
|
|
|
|
|
param.setStartTime(DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME)); |
|
|
|
|
|
|
|
param.setEndTime(DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME)); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
param.setStartTime(param.getYear() + "-01-01 00:00:00"); |
|
|
|
|
|
|
|
param.setEndTime(param.getYear() + "-12-31 23:59:59"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!StringUtil.isEmpty(param.getState()) && param.getState().equals(1)){ |
|
|
|
|
|
|
|
param.setFlowTaskName("结束"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取权限区域机构
|
|
|
|
|
|
|
|
List<Dept> depts = this.authArea(); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(depts)){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 操作票查询
|
|
|
|
|
|
|
|
LambdaQueryWrapper operateWrapper = Wrappers.<StandardTicketInfoEntity>lambdaQuery() |
|
|
|
|
|
|
|
.between(StandardTicketInfoEntity::getCreateTime,param.getStartTime(),param.getEndTime()) |
|
|
|
|
|
|
|
.in(StandardTicketInfoEntity::getCreateDept,depts); |
|
|
|
|
|
|
|
if(!StringUtil.isEmpty(param.getFlowTaskName())){ |
|
|
|
|
|
|
|
operateWrapper.eq("FLOW_TASK_NAME",param.getFlowTaskName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<StandardTicketInfoEntity> operates = operateTicketService.list(operateWrapper); |
|
|
|
|
|
|
|
// 工作票查询
|
|
|
|
|
|
|
|
LambdaQueryWrapper workWrapper = Wrappers.<StandardTicketInfoEntity>lambdaQuery() |
|
|
|
|
|
|
|
.between(StandardTicketInfoEntity::getCreateTime,param.getStartTime(),param.getEndTime()) |
|
|
|
|
|
|
|
.in(StandardTicketInfoEntity::getCreateDept,depts); |
|
|
|
|
|
|
|
if(!StringUtil.isEmpty(param.getFlowTaskName())){ |
|
|
|
|
|
|
|
workWrapper.eq("FLOW_TASK_NAME",param.getFlowTaskName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<WorkTicketInfoEntity> works = workTicketInfoService.list(workWrapper); |
|
|
|
|
|
|
|
return depts.stream().map(dept -> { |
|
|
|
|
|
|
|
CensYearVo censYear = new CensYearVo(); |
|
|
|
|
|
|
|
censYear.setDeptId(dept.getId()); |
|
|
|
|
|
|
|
censYear.setDeptName(dept.getDeptName()); |
|
|
|
|
|
|
|
for(int mon = 1 ; mon <= 12 ;mon++){ |
|
|
|
|
|
|
|
String strMon = param.getYear() + "-" + (mon > 9 ? mon : "0" + mon); |
|
|
|
|
|
|
|
CensVo cens = new CensVo(); |
|
|
|
|
|
|
|
cens.setMon(mon); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(operates)){ |
|
|
|
|
|
|
|
cens.setOperateCount(0L); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
cens.setOperateCount(operates.stream().filter(operate->operate.getCreateDept().equals(dept.getId()) && DateUtil.format(operate.getCreateTime(),"yyyy-MM").equals(strMon)).count()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(works)){ |
|
|
|
|
|
|
|
cens.setWorkCount(0L); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
cens.setOperateCount(works.stream().filter(work->work.getCreateDept().equals(dept.getId()) && DateUtil.format(work.getCreateTime(),"yyyy-MM").equals(strMon)).count()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
cens.setWorkTaskCount((long)new Random().nextInt(10)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return censYear; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |