@@ -1,6 +1,5 @@ | |||
package com.hz.pm.api.dashboard.manage; | |||
import cn.hutool.core.collection.CollUtil; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.google.common.collect.Lists; | |||
import com.hz.pm.api.common.model.entity.DataDTO; | |||
@@ -10,15 +9,15 @@ import com.hz.pm.api.meeting.entity.domain.Meeting; | |||
import com.hz.pm.api.meeting.entity.domain.MeetingExpert; | |||
import com.hz.pm.api.meeting.service.IMeetingExpertService; | |||
import com.hz.pm.api.meeting.service.IMeetingService; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.stereotype.Component; | |||
import java.math.BigDecimal; | |||
import java.math.RoundingMode; | |||
import java.time.LocalDateTime; | |||
import java.util.List; | |||
import java.util.Objects; | |||
import java.time.LocalDate; | |||
import java.util.*; | |||
import java.util.stream.Collectors; | |||
/** | |||
@@ -36,22 +35,31 @@ public class ProjectCostStatisticsManage { | |||
private final IMeetingService meetingService; | |||
List<Integer> thisTwoYears = Lists.newArrayList(LocalDateTime.now().getYear() - 1 | |||
,LocalDateTime.now().getYear()); | |||
//评审费 每人500 (0.05万) | |||
private static final BigDecimal REVIEW_AMOUNT_EXPERT = DashboardConstant.Expert.REVIEW_AOUMT_EXPERT; | |||
private List<Integer> getRecentTwoYears() { | |||
int currYear = LocalDate.now().getYear(); | |||
return Arrays.asList(currYear - 1, currYear); | |||
} | |||
public CostStatisticsVO statistics() { | |||
CostStatisticsVO res = new CostStatisticsVO(); | |||
List<Meeting> meetings = meetingService.list(Wrappers.lambdaQuery(Meeting.class)); | |||
List<Long> meetingIds = meetings.stream().map(Meeting::getId) | |||
.collect(Collectors.toList()); | |||
List<Meeting> meetings = meetingService.list(Wrappers.lambdaQuery(Meeting.class) | |||
.select(Meeting::getStartTime, Meeting::getId)); | |||
//算出所有的 同意的专家 | |||
List<MeetingExpert> meetingExperts = meetingExpertService.listAgreedExperts(meetingIds); | |||
List<MeetingExpert> meetingExperts; | |||
//评审费 每人500 (0.05万) | |||
BigDecimal reviewAoumtExpert = DashboardConstant.Expert.REVIEW_AOUMT_EXPERT; | |||
if (meetings.isEmpty()) { | |||
meetingExperts = Collections.emptyList(); | |||
} else { | |||
List<Long> meetingIds = CollUtils.fieldList(meetings, Meeting::getId); | |||
meetingExperts = meetingExpertService.listAgreedExperts(meetingIds); | |||
} | |||
//计算累积 | |||
res.setReviewAmount(reviewAoumtExpert.multiply(BigDecimal.valueOf(meetingExperts.size()))); | |||
res.setReviewAmount(REVIEW_AMOUNT_EXPERT.multiply(BigDecimal.valueOf(meetingExperts.size()))); | |||
res.setPricingAmount(BigDecimal.ZERO); | |||
//近两年 | |||
@@ -64,30 +72,27 @@ public class ProjectCostStatisticsManage { | |||
DataDTO pricingAvg = new DataDTO(); | |||
pricingAvg.setName("核价费"); | |||
BigDecimal reviewTwoYearTotal = BigDecimal.ZERO; | |||
for(Integer thisYear : thisTwoYears){ | |||
Map<Integer, List<Meeting>> meetingMapYear = CollUtils.group(meetings, w -> w.getStartTime().getYear()); | |||
Map<Long, List<MeetingExpert>> expertMapMeetingId = CollUtils.group(meetingExperts, MeetingExpert::getMeetingId); | |||
for (Integer thisYear : getRecentTwoYears()) { | |||
//查出 年份的 会议数据 | |||
List<Meeting> yearMeetings = meetings.stream().filter(m -> { | |||
if(Objects.nonNull(m.getStartTime()) && | |||
( thisYear.equals(m.getStartTime().getYear()))){ | |||
return Boolean.TRUE; | |||
} | |||
return Boolean.FALSE; | |||
}).collect(Collectors.toList()); | |||
List<Long> yearMeetingIds = yearMeetings.stream().map(Meeting::getId) | |||
List<Meeting> yearMeetings = meetingMapYear.getOrDefault(thisYear, Collections.emptyList()); | |||
List<MeetingExpert> yearMeetingExperts = yearMeetings.stream() | |||
.map(w -> expertMapMeetingId.get(w.getId())) | |||
.filter(Objects::nonNull) | |||
.flatMap(Collection::stream) | |||
.collect(Collectors.toList()); | |||
//算出所有的 同意的专家 | |||
List<MeetingExpert> yearMeetingExperts = Lists.newArrayList(); | |||
if(CollUtil.isNotEmpty(yearMeetingIds)){ | |||
yearMeetingExperts = meetingExpertService.listAgreedExperts(yearMeetingIds); | |||
} | |||
twoYearsReviews.add(DataDTO.of(thisYear.toString(),reviewAoumtExpert.multiply(BigDecimal | |||
.valueOf(yearMeetingExperts.size())))); | |||
twoYearsPricing.add(DataDTO.of(thisYear.toString(),BigDecimal.ZERO)); | |||
reviewTwoYearTotal = reviewTwoYearTotal.add(reviewAoumtExpert.multiply(BigDecimal | |||
.valueOf(yearMeetingExperts.size()))); | |||
BigDecimal yearExpertCnt = BigDecimal.valueOf(yearMeetingExperts.size()); | |||
BigDecimal yearExpertAmount = REVIEW_AMOUNT_EXPERT.multiply(yearExpertCnt); | |||
twoYearsReviews.add(DataDTO.of(thisYear.toString(), yearExpertAmount)); | |||
twoYearsPricing.add(DataDTO.of(thisYear.toString(), BigDecimal.ZERO)); | |||
reviewTwoYearTotal = reviewTwoYearTotal.add(yearExpertAmount); | |||
} | |||
reviewAvg.setAmount(reviewTwoYearTotal.divide(BigDecimal.valueOf(2),BigDecimal.ROUND_CEILING, | |||
reviewAvg.setAmount(reviewTwoYearTotal.divide(BigDecimal.valueOf(2), BigDecimal.ROUND_CEILING, | |||
RoundingMode.HALF_UP)); | |||
twoYearsAvg.add(reviewAvg); | |||
twoYearsAvg.add(pricingAvg); | |||
@@ -40,8 +40,6 @@ public class DeclaredProjectController { | |||
private final ProjectAdjustmentManage projectAdjustmentManage; | |||
private final GovProjectCollectionManage collectionManage; | |||
@ApiOperation(value = "申报项目已申报列表", notes = "申报项目已申报列表") | |||
@GetMapping("/list") | |||
public PageVo<ProjectLibListItemVO> list(@ModelAttribute ProjectListReq req) { | |||
@@ -31,6 +31,7 @@ import com.hz.pm.api.sys.manage.NoticeManage; | |||
import com.hz.pm.api.todocenter.constant.TodoCenterConst; | |||
import com.hz.pm.api.todocenter.constant.WorkNoticeConstant; | |||
import com.hz.pm.api.user.security.model.UserFullInfoDTO; | |||
import com.hz.pm.api.user.security.model.UserInfoDetails; | |||
import com.hz.pm.api.user.util.LoginUserUtil; | |||
import com.ningdatech.basic.function.VUtils; | |||
import com.ningdatech.basic.model.PageVo; | |||
@@ -97,7 +98,7 @@ public class PrequalificationDeclaredProjectManage { | |||
*/ | |||
@Transactional(rollbackFor = Exception.class) | |||
public String startTheProcess(DefaultDeclaredDTO dto) { | |||
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId()); | |||
UserInfoDetails user = LoginUserUtil.loginUserDetail(); | |||
ProjectDTO projectDto = dto.getProjectInfo(); | |||
VUtils.isTrue(Objects.isNull(projectDto.getId())).throwMessage("提交失败 缺少项目ID!"); | |||
Project projectInfo = projectService.getNewProject(projectDto.getId()); | |||
@@ -120,7 +121,7 @@ public class PrequalificationDeclaredProjectManage { | |||
projectInfo.setHigherLineSuperOrgReviewComments(projectDto.getHigherLineSuperOrgReviewComments()); | |||
} | |||
stateMachineUtil.pass(projectInfo); | |||
String instanceId = null; | |||
String instanceId; | |||
//如果是省级部门 需要联审的(申报金额大于1000万 并且是市级项目) | |||
if (ProjectStatusEnum.JOINT_REVIEW_BY_PROVINCIAL_DEPARTMENTS | |||
.getCode().equals(projectInfo.getStatus())) { | |||
@@ -52,4 +52,10 @@ public interface IUserRoleService extends IService<UserRole> { | |||
return list(eq); | |||
} | |||
default void removeByUserId(Long userId){ | |||
LambdaQueryWrapper<UserRole> query = Wrappers.lambdaQuery(UserRole.class) | |||
.eq(UserRole::getUserId, userId); | |||
remove(query); | |||
} | |||
} |
@@ -103,7 +103,7 @@ public class UserInfoManage { | |||
} | |||
List<Long> roleIds = CollUtils.fieldList(userRoles, UserRoleVO::getId); | |||
LambdaQueryWrapper<UserRole> urQuery = Wrappers.lambdaQuery(UserRole.class) | |||
.select(UserRole::getUserId).in(UserRole::getRoleId,roleIds); | |||
.select(UserRole::getUserId).in(UserRole::getRoleId, roleIds); | |||
return userRoleService.listUserIdByRoleIds(roleIds); | |||
} | |||
@@ -203,40 +203,29 @@ public class UserInfoManage { | |||
} | |||
@Transactional(rollbackFor = Exception.class) | |||
public void userInfoDetailEdit(ReqUserDetailEditPO reqUserDetailEditPO) { | |||
Long userId = reqUserDetailEditPO.getUserId(); | |||
if (Objects.isNull(userId)) { | |||
String employeeCode = reqUserDetailEditPO.getEmployeeCode(); | |||
if (StringUtils.isBlank(employeeCode)) { | |||
throw new IllegalArgumentException("employeeCode can't be null"); | |||
} | |||
userId = generateUserId(employeeCode); | |||
} | |||
public void userInfoDetailEdit(ReqUserDetailEditPO req) { | |||
Long userId = req.getUserId(); | |||
UserInfo userInfo = userInfoService.getById(userId); | |||
String oldUserStatus = userInfo.getAvailable(); | |||
// 绑定用户手机号 | |||
bandUserMobile(userInfo, reqUserDetailEditPO); | |||
userInfo.setAvailable(reqUserDetailEditPO.getStatus()); | |||
String oldStatus = userInfo.getAvailable(); | |||
userInfo.setAvailable(req.getStatus()); | |||
userInfo.setUpdateOn(LocalDateTime.now()); | |||
userInfo.setUpdateBy(LoginUserUtil.getUserId()); | |||
userInfoService.updateById(userInfo); | |||
List<UserRoleVO> userRoleInfoList = reqUserDetailEditPO.getUserRoleInfoList(); | |||
userRoleService.remove(Wrappers.lambdaQuery(UserRole.class).eq(UserRole::getUserId, userId)); | |||
if (CollUtil.isNotEmpty(userRoleInfoList)) { | |||
Long finalUserId = userId; | |||
List<UserRole> userRoleList = userRoleInfoList.stream().map(r -> { | |||
List<UserRoleVO> userRoles = req.getUserRoleInfoList(); | |||
userRoleService.removeByUserId(userId); | |||
if (CollUtil.isNotEmpty(userRoles)) { | |||
List<UserRole> userRoleList = userRoles.stream().map(r -> { | |||
UserRole saveRecord = new UserRole(); | |||
saveRecord.setRoleId(r.getId()); | |||
saveRecord.setUserId(finalUserId); | |||
saveRecord.setUserId(userId); | |||
return saveRecord; | |||
}).collect(Collectors.toList()); | |||
userRoleService.saveBatch(userRoleList); | |||
} | |||
// 刷新用户权限 仅原状态为正常才需要刷新session | |||
if ("ENABLE".equals(oldUserStatus)) { | |||
if (oldUserStatus.equals(userInfo.getAvailable())) { | |||
if ("ENABLE".equals(oldStatus)) { | |||
if (oldStatus.equals(userInfo.getAvailable())) { | |||
userAuthManage.refreshSession(userId); | |||
} else { | |||
userAuthManage.kickOff(userId); | |||
@@ -244,36 +233,6 @@ public class UserInfoManage { | |||
} | |||
} | |||
/** | |||
* 绑定用户手机号 | |||
* | |||
* @param userInfo | |||
* @param reqUserDetailEditPO | |||
*/ | |||
@Transactional(rollbackFor = Exception.class) | |||
public void bandUserMobile(UserInfo userInfo, ReqUserDetailEditPO reqUserDetailEditPO) { | |||
String employeeCode = reqUserDetailEditPO.getEmployeeCode(); | |||
Long userId = userInfo.getId(); | |||
// 校验手机号是否重复 | |||
UserInfo repeatMobileUserInfo = userInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) | |||
.eq(UserInfo::getMobile, reqUserDetailEditPO.getPhoneNo()).ne(UserInfo::getId, userId)); | |||
if (Objects.nonNull(repeatMobileUserInfo)) { | |||
throw new BizException("该手机号码已被绑定,请问重复绑定"); | |||
} | |||
String phoneNo = reqUserDetailEditPO.getPhoneNo(); | |||
userInfo.setMobile(phoneNo); | |||
// 更新浙政钉相关数据 | |||
if (StringUtils.isNotBlank(phoneNo)) { | |||
dingEmployeeInfoService | |||
.update(Wrappers.lambdaUpdate(DingEmployeeInfo.class) | |||
.eq(DingEmployeeInfo::getMainJob, "true") | |||
.eq(DingEmployeeInfo::getEmployeeCode, employeeCode) | |||
.set(DingEmployeeInfo::getBindUserMobile, phoneNo)); | |||
userInfoService.updateById(userInfo); | |||
} | |||
} | |||
@Transactional(rollbackFor = Exception.class) | |||
public Long generateUserId(String employeeCode) { | |||
UserInfo userInfo = userInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) | |||
@@ -21,9 +21,6 @@ public class ReqUserDetailEditPO { | |||
@ApiModelProperty("userId") | |||
private Long userId; | |||
@ApiModelProperty("浙政钉 用户编码") | |||
private String employeeCode; | |||
@NotBlank(message = "用户手机号不能为空") | |||
@ApiModelProperty("手机号") | |||
private String phoneNo; | |||
@@ -136,6 +136,7 @@ flowable: | |||
enabled: false | |||
app: | |||
enabled: false | |||
database-schema: HZ_PROJECT_MANAGEMENT | |||
wflow: | |||
file: | |||