包头bug修改

This commit is contained in:
guoshengxiong 2025-03-19 18:31:24 +08:00
parent 5ad9c7ff8f
commit 074b5434d7
17 changed files with 256 additions and 89 deletions

View File

@ -304,7 +304,7 @@ public class WorkerAdmissionController {
throw new OpenAlertException("" + StrUtil.join(",", existNums) + "】编号已存在"); throw new OpenAlertException("" + StrUtil.join(",", existNums) + "】编号已存在");
} }
} }
Map<Long, DictionariesRecord> allCeNameMap = dictionariesRecordService.list().stream().collect(Collectors.toMap(DictionariesRecord::getId, Function.identity(), (o1, o2) -> o1)); Map<String, DictionariesRecord> allCeNameMap = dictionariesRecordService.list().stream().collect(Collectors.toMap(DictionariesRecord::getDictionaryValue, Function.identity(), (o1, o2) -> o1));
if (CollUtil.isNotEmpty(tableList)) { if (CollUtil.isNotEmpty(tableList)) {
List<String> errs = new ArrayList<>(); List<String> errs = new ArrayList<>();
Map<Long, PostWorkType> typeMap = postWorkTypeService.list(new LambdaQueryWrapper<PostWorkType>() Map<Long, PostWorkType> typeMap = postWorkTypeService.list(new LambdaQueryWrapper<PostWorkType>()
@ -315,7 +315,7 @@ public class WorkerAdmissionController {
Long type = jo.getJSONArray("field3008722075250").getLong(0); Long type = jo.getJSONArray("field3008722075250").getLong(0);
List<String> hasCeList = new ArrayList(); List<String> hasCeList = new ArrayList();
Map<Long, DictionariesRecord> hasCeMap = new HashMap<>(); Map<Long, DictionariesRecord> hasCeMap = new HashMap<>();
Long ce = jo.getJSONArray("field9312043914427").getLong(0); String ce = jo.getJSONArray("field9312043914427").getString(0);
hasCeList.add(allCeNameMap.get(ce).getDictionaryName()); hasCeList.add(allCeNameMap.get(ce).getDictionaryName());
if (typeMap.containsKey(type)) { if (typeMap.containsKey(type)) {
String typeName = typeMap.get(type).getPostWorkTypeName(); String typeName = typeMap.get(type).getPostWorkTypeName();

View File

@ -7,8 +7,6 @@ import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhgd.annotation.DataScope; import com.zhgd.annotation.DataScope;
import com.zhgd.xmgl.modules.baotou.entity.ProjectGroup; import com.zhgd.xmgl.modules.baotou.entity.ProjectGroup;
import com.zhgd.xmgl.modules.baotou.entity.vo.CountEnterpriseVo;
import com.zhgd.xmgl.modules.baotou.entity.vo.EnterpriseListVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -25,8 +23,8 @@ import java.util.List;
@DataScope @DataScope
public interface ProjectGroupMapper extends BaseMapper<ProjectGroup> { public interface ProjectGroupMapper extends BaseMapper<ProjectGroup> {
IPage<ProjectGroup> queryList(Page<ProjectGroup> page, @Param(Constants.WRAPPER) QueryWrapper<ProjectGroup> queryWrapper); IPage<ProjectGroup> queryList(Page<ProjectGroup> page, @Param(Constants.WRAPPER) QueryWrapper<ProjectGroup> queryWrapper, @Param("param") HashMap<String, Object> param);
List<ProjectGroup> queryList(@Param(Constants.WRAPPER) QueryWrapper<ProjectGroup> queryWrapper); List<ProjectGroup> queryList(@Param(Constants.WRAPPER) QueryWrapper<ProjectGroup> queryWrapper, @Param("param") HashMap<String, Object> param);
} }

View File

@ -1,7 +1,6 @@
package com.zhgd.xmgl.modules.baotou.plan.controller; package com.zhgd.xmgl.modules.baotou.plan.controller;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
@ -10,12 +9,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhgd.annotation.OperLog; import com.zhgd.annotation.OperLog;
import com.zhgd.jeecg.common.api.vo.Result; import com.zhgd.jeecg.common.api.vo.Result;
import com.zhgd.jeecg.common.execption.OpenAlertException;
import com.zhgd.xmgl.modules.baotou.plan.entity.*; import com.zhgd.xmgl.modules.baotou.plan.entity.*;
import com.zhgd.xmgl.modules.baotou.plan.entity.vo.PlanRecordCurve;
import com.zhgd.xmgl.modules.baotou.plan.mapper.PlanRecordMapper; import com.zhgd.xmgl.modules.baotou.plan.mapper.PlanRecordMapper;
import com.zhgd.xmgl.modules.baotou.plan.service.*; import com.zhgd.xmgl.modules.baotou.plan.service.*;
import com.zhgd.xmgl.util.ExcelUtils;
import com.zhgd.xmgl.util.MessageUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
@ -25,14 +22,11 @@ import org.apache.commons.collections.MapUtils;
import org.simpleframework.xml.core.Validate; import org.simpleframework.xml.core.Validate;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -197,8 +191,8 @@ public class PlanRecordController {
@OperLog(operModul = "进度计划编制管理", operType = "", operDesc = "查询进度曲线") @OperLog(operModul = "进度计划编制管理", operType = "", operDesc = "查询进度曲线")
@ApiOperation(value = "查询进度曲线", notes = "查询进度曲线", httpMethod = "GET") @ApiOperation(value = "查询进度曲线", notes = "查询进度曲线", httpMethod = "GET")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "recordId", value = "计划编制id", paramType = "query", required = true, dataType = "String"),
@ApiImplicitParam(name = "pbsId", value = "进度PBSID计划编制id和进度PBSID必传其中之一都传以计划编制id为准", paramType = "query", required = true, dataType = "String"), @ApiImplicitParam(name = "pbsId", value = "进度PBSID计划编制id和进度PBSID必传其中之一都传以计划编制id为准", paramType = "query", required = true, dataType = "String"),
@ApiImplicitParam(name = "recordId", value = "计划编制id", paramType = "query", required = false, dataType = "String"),
@ApiImplicitParam(name = "beginDate", value = "开始日期", paramType = "query", required = false, dataType = "String"), @ApiImplicitParam(name = "beginDate", value = "开始日期", paramType = "query", required = false, dataType = "String"),
@ApiImplicitParam(name = "endDate", value = "结束日期", paramType = "query", required = false, dataType = "String"), @ApiImplicitParam(name = "endDate", value = "结束日期", paramType = "query", required = false, dataType = "String"),
@ApiImplicitParam(name = "year", value = "年份", paramType = "query", required = false, dataType = "String") @ApiImplicitParam(name = "year", value = "年份", paramType = "query", required = false, dataType = "String")
@ -214,29 +208,30 @@ public class PlanRecordController {
String recordId = MapUtils.getString(param, "recordId"); String recordId = MapUtils.getString(param, "recordId");
String projectSn = MapUtils.getString(param, "projectSn"); String projectSn = MapUtils.getString(param, "projectSn");
if (StrUtil.isNotBlank(recordId)) { if (StrUtil.isNotBlank(recordId)) {
PlanRecord record = planRecordService.getById(recordId); //查询某个计划编制的曲线
PlanPeriod planPeriod = planPeriodService.getOne(new LambdaQueryWrapper<PlanPeriod>().eq(PlanPeriod::getProjectSn, projectSn));
return Result.success(planRecordService.getPlanCurve(param)); return Result.success(planRecordService.getPlanCurve(param));
} else { } else {
//查询某个pbs的曲线
Long pbsId = MapUtils.getLong(param, "pbsId"); Long pbsId = MapUtils.getLong(param, "pbsId");
PlanPbs topPbs = planPbsService.getById(pbsId);
List<PlanPbs> planPbs = planPbsService.getChildren(pbsId); List<PlanPbs> planPbs = planPbsService.getChildren(pbsId);
// planPbs.add(topPbs);
// calByRecursionPbs(topPbs, planPbs);
PlanPeriod planPeriod = planPeriodService.getOne(new LambdaQueryWrapper<PlanPeriod>().eq(PlanPeriod::getProjectSn, projectSn)); PlanPeriod planPeriod = planPeriodService.getOne(new LambdaQueryWrapper<PlanPeriod>().eq(PlanPeriod::getProjectSn, projectSn));
List<Long> pbsIds = planPbs.stream().map(PlanPbs::getId).collect(Collectors.toList()); List<Long> pbsIds = planPbs.stream().map(PlanPbs::getId).collect(Collectors.toList());
pbsIds.add(pbsId); pbsIds.add(pbsId);
List<Map<String, Object>> rtList = new ArrayList<>(); List<Map<String, Object>> rtList = new ArrayList<>();
List<PlanRecord> records = planRecordService.list(new LambdaQueryWrapper<PlanRecord>() List<PlanRecord> topRecords = planRecordService.list(new LambdaQueryWrapper<PlanRecord>()
.in(PlanRecord::getPbsId, pbsIds) .in(PlanRecord::getPbsId, pbsIds)
.eq(PlanRecord::getParentId, 0) .eq(PlanRecord::getParentId, 0)
); );
Map<Date, List<PlanFeedbackPeriod>> dateMap = new HashMap<>(); Map<Date, List<PlanFeedbackPeriod>> dateMap = new HashMap<>();
List<PlanMilestone> milestones = planMilestoneService.list(new LambdaQueryWrapper<PlanMilestone>().eq(PlanMilestone::getProjectSn, projectSn)); List<PlanMilestone> milestones = planMilestoneService.list(new LambdaQueryWrapper<PlanMilestone>().eq(PlanMilestone::getProjectSn, projectSn));
List<PlanRecord> allPlanRecords = planRecordMapper.selectList(new LambdaQueryWrapper<PlanRecord>().eq(PlanRecord::getProjectSn, projectSn)); List<PlanRecord> allPlanRecords = planRecordMapper.selectList(new LambdaQueryWrapper<PlanRecord>().eq(PlanRecord::getProjectSn, projectSn));
Map<Long, List<PlanRecord>> childrenMap = new HashMap<>(); for (PlanRecord topRecord : topRecords) {
for (PlanRecord record : records) { topRecord.setChildren(planRecordService.getPlanRecordChildren(topRecord, allPlanRecords));
childrenMap.put(record.getId(), this.getChildren(record, allPlanRecords)); List<PlanFeedbackPeriod> periods = planRecordService.getPlanSharesForCurve(param, topRecord, milestones, planPeriod, allPlanRecords, planPeriod);
}
for (PlanRecord record : records) {
List<PlanFeedbackPeriod> periods = planRecordService.getPlanSharesForCurve(param, record, milestones, planPeriod, allPlanRecords, childrenMap.get(record.getId()), planPeriod);
for (PlanFeedbackPeriod period : periods) { for (PlanFeedbackPeriod period : periods) {
List<PlanFeedbackPeriod> periodList = dateMap.get(period.getPeriodStart()); List<PlanFeedbackPeriod> periodList = dateMap.get(period.getPeriodStart());
if (periodList == null) { if (periodList == null) {
@ -283,11 +278,23 @@ public class PlanRecordController {
} }
} }
private List<PlanRecord> getChildren(PlanRecord st, List<PlanRecord> allList) { /**
return allList.stream() * 递归pbs计算曲线
.filter(m -> Objects.equals(m.getParentId(), st.getId())) *
.peek(m -> m.setChildren(getChildren(m, allList))) * @param topPbs
* @param planPbs
*/
private Map<String, PlanRecordCurve> calByRecursionPbs(PlanPbs topPbs, List<PlanPbs> planPbs) {
List<PlanPbs> children = planPbs.stream()
.filter(m -> Objects.equals(m.getParentId(), topPbs.getId()))
.collect(Collectors.toList()); .collect(Collectors.toList());
if (CollUtil.isNotEmpty(children)) {
for (PlanPbs child : children) {
calByRecursionPbs(child, planPbs);
}
} else {
}
} }
@OperLog(operModul = "进度计划编制管理", operType = "", operDesc = "查询项目里程碑") @OperLog(operModul = "进度计划编制管理", operType = "", operDesc = "查询项目里程碑")

View File

@ -154,7 +154,7 @@ public class PlanFeedback implements Serializable {
private java.lang.Integer status; private java.lang.Integer status;
@TableField(exist = false) @TableField(exist = false)
private java.lang.String key; private java.lang.String k;
} }

View File

@ -0,0 +1,15 @@
package com.zhgd.xmgl.modules.baotou.plan.entity.vo;
import lombok.Data;
/**
* 计划编制的曲线
*/
@Data
public class PlanRecordCurve {
private String time;
private String plan;
private String actual;
private String planTotal;
private String actualTotal;
}

View File

@ -75,9 +75,10 @@ public interface IPlanFeedbackApprovalService extends IService<PlanFeedbackAppro
/** /**
* 查询最新的一条审批 * 查询最新的一条审批
* *
* @param feedbackType
* @return * @return
*/ */
PlanFeedbackApproval queryNewestApproval(); PlanFeedbackApproval queryNewestApproval(Integer feedbackType);
void deleteByApprovalAndRecordId(HashMap<String, Object> map); void deleteByApprovalAndRecordId(HashMap<String, Object> map);
} }

View File

@ -7,7 +7,6 @@ import com.zhgd.xmgl.modules.baotou.plan.entity.PlanMilestone;
import com.zhgd.xmgl.modules.baotou.plan.entity.PlanPeriod; import com.zhgd.xmgl.modules.baotou.plan.entity.PlanPeriod;
import com.zhgd.xmgl.modules.baotou.plan.entity.PlanRecord; import com.zhgd.xmgl.modules.baotou.plan.entity.PlanRecord;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -75,9 +74,19 @@ public interface IPlanRecordService extends IService<PlanRecord> {
List<PlanFeedbackPeriod> getPlanShares(Map<String, Object> param); List<PlanFeedbackPeriod> getPlanShares(Map<String, Object> param);
List<PlanFeedbackPeriod> getPlanSharesForCurve(Map<String, Object> param, PlanRecord record, List<PlanMilestone> milestones, PlanPeriod planPeriod, List<PlanRecord> planRecords, List<PlanRecord> children, PlanPeriod period); List<PlanFeedbackPeriod> getPlanSharesForCurve(Map<String, Object> param, PlanRecord record, List<PlanMilestone> milestones, PlanPeriod planPeriod, List<PlanRecord> planRecords, PlanPeriod period);
List<Map<String, Object>> getPlanCurve(Map<String, Object> param); List<Map<String, Object>> getPlanCurve(Map<String, Object> param);
HashMap<String, Object> getProjectMilestone(HashMap<String, Object> param); HashMap<String, Object> getProjectMilestone(HashMap<String, Object> param);
/**
* 获取children的计划编制
*
* @param topRecord
* @param allPlanRecords
* @return
*/
List<PlanRecord> getPlanRecordChildren(PlanRecord topRecord, List<PlanRecord> allPlanRecords);
} }

View File

@ -240,7 +240,7 @@ public class PlanFeedbackApprovalServiceImpl extends ServiceImpl<PlanFeedbackApp
}).stream().filter(Objects::nonNull).collect(Collectors.toList()); }).stream().filter(Objects::nonNull).collect(Collectors.toList());
UserInfo user = SecurityUtils.getUser(); UserInfo user = SecurityUtils.getUser();
Long userId = user.getUserId(); Long userId = user.getUserId();
PlanFeedbackApproval approval = this.queryNewestApproval(); PlanFeedbackApproval approval = this.queryNewestApproval(feedbackType);
Map<Long, PlanFeedback> ridFeedBackMap = new HashMap<>(); Map<Long, PlanFeedback> ridFeedBackMap = new HashMap<>();
if (CollUtil.isNotEmpty(recordIdList)) { if (CollUtil.isNotEmpty(recordIdList)) {
ridFeedBackMap = planFeedbackService.getNewestOneByRecordIdList(recordIdList).stream().collect(Collectors.toMap(PlanFeedback::getRecordId, Function.identity(), (planFeedback, planFeedback2) -> planFeedback)); ridFeedBackMap = planFeedbackService.getNewestOneByRecordIdList(recordIdList).stream().collect(Collectors.toMap(PlanFeedback::getRecordId, Function.identity(), (planFeedback, planFeedback2) -> planFeedback));
@ -303,23 +303,24 @@ public class PlanFeedbackApprovalServiceImpl extends ServiceImpl<PlanFeedbackApp
PlanFeedbackApprovalWork faw = new PlanFeedbackApprovalWork(); PlanFeedbackApprovalWork faw = new PlanFeedbackApprovalWork();
faw.setApprovalId(approval.getId()); faw.setApprovalId(approval.getId());
faw.setRecordId(rid); faw.setRecordId(rid);
PlanFeedback feedback = ridFeedBackMap.get(rid); // PlanFeedback feedback = ridFeedBackMap.get(rid);
if (feedback == null || feedback.getApprovalStatus() != 1) { // if (feedback == null || feedback.getApprovalStatus() != 1) {
feedback = planFeedbackService.getNewest(String.valueOf(rid), feedback.getFeedbackType()); // feedback = planFeedbackService.getNewest(String.valueOf(rid), feedback.getFeedbackType());
feedback.setRecordId(rid); // feedback.setRecordId(rid);
} // }
feedback.setProjectSn(approval.getProjectSn()); // feedback.setProjectSn(approval.getProjectSn());
planFeedbackService.saveInfo(feedback); // planFeedbackService.saveInfo(feedback);
// faw.setFeedbackId(feedback.getId()); // faw.setFeedbackId(feedback.getId());
planFeedbackApprovalWorkService.add(faw); planFeedbackApprovalWorkService.add(faw);
} }
} }
@Override @Override
public PlanFeedbackApproval queryNewestApproval() { public PlanFeedbackApproval queryNewestApproval(Integer feedbackType) {
Long userId = SecurityUtils.getUser().getUserId(); Long userId = SecurityUtils.getUser().getUserId();
return planFeedbackApprovalMapper.selectOne(new LambdaQueryWrapper<PlanFeedbackApproval>() return planFeedbackApprovalMapper.selectOne(new LambdaQueryWrapper<PlanFeedbackApproval>()
.eq(PlanFeedbackApproval::getInputWorkerId, userId) .eq(PlanFeedbackApproval::getInputWorkerId, userId)
.eq(PlanFeedbackApproval::getFeedbackType, feedbackType)
.last("order by create_time desc limit 1") .last("order by create_time desc limit 1")
); );
} }

View File

@ -19,6 +19,7 @@ import com.zhgd.xmgl.modules.baotou.plan.mapper.PlanFeedbackMapper;
import com.zhgd.xmgl.modules.baotou.plan.service.*; import com.zhgd.xmgl.modules.baotou.plan.service.*;
import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService; import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
import com.zhgd.xmgl.security.util.SecurityUtils; import com.zhgd.xmgl.security.util.SecurityUtils;
import com.zhgd.xmgl.util.MapBuilder;
import com.zhgd.xmgl.util.PageUtil; import com.zhgd.xmgl.util.PageUtil;
import com.zhgd.xmgl.util.RefUtil; import com.zhgd.xmgl.util.RefUtil;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
@ -383,6 +384,20 @@ public class PlanFeedbackServiceImpl extends ServiceImpl<PlanFeedbackMapper, Pla
baseMapper.insert(feedback); baseMapper.insert(feedback);
this.addFeedbackPeriodAndVal(feedback); this.addFeedbackPeriodAndVal(feedback);
} }
//保存到批量反馈
//{
// "recordIdList": [
// "1901822089696657410"
// ],
// "projectSn": "5B8B3DB047214AE188F2C7916DD08203",
// "feedbackType": 2
//}
planFeedbackApprovalService.saveInfo(new MapBuilder<String, Object>()
.put("recordIdList", Collections.singletonList(feedback.getRecordId()))
.put("projectSn", feedback.getProjectSn())
.put("feedbackType", feedback.getFeedbackType())
.build());
} }
@Override @Override
@ -441,7 +456,7 @@ public class PlanFeedbackServiceImpl extends ServiceImpl<PlanFeedbackMapper, Pla
for (PlanFeedbackPeriod period : periods) { for (PlanFeedbackPeriod period : periods) {
period.setFeedbackId(feedback.getId()); period.setFeedbackId(feedback.getId());
planFeedbackPeriodService.updateById(period); planFeedbackPeriodService.updateById(period);
List<PlanMilestoneVal> milestoneVals = period.getPlanMilestoneVals(); List<PlanMilestoneVal> milestoneVals = period.getMilestoneVals();
if (CollUtil.isNotEmpty(milestoneVals)) { if (CollUtil.isNotEmpty(milestoneVals)) {
for (PlanMilestoneVal val : milestoneVals) { for (PlanMilestoneVal val : milestoneVals) {
val.setFeedbackPeriodId(period.getId()); val.setFeedbackPeriodId(period.getId());
@ -454,6 +469,6 @@ public class PlanFeedbackServiceImpl extends ServiceImpl<PlanFeedbackMapper, Pla
@Override @Override
public Map<String, PlanFeedback> queryManyNewestFeedbackMap(HashMap<String, Object> param) { public Map<String, PlanFeedback> queryManyNewestFeedbackMap(HashMap<String, Object> param) {
return baseMapper.queryManyNewestFeedbackMap(param).stream().collect(Collectors.toMap(PlanFeedback::getKey, Function.identity(), (o1, o2) -> o1)); return baseMapper.queryManyNewestFeedbackMap(param).stream().collect(Collectors.toMap(PlanFeedback::getK, Function.identity(), (o1, o2) -> o1));
} }
} }

View File

@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -213,11 +214,13 @@ public class PlanRecordServiceImpl extends ServiceImpl<PlanRecordMapper, PlanRec
} }
} }
baseMapper.updateAncestors(oldPlanRecord.getAncestors(), planRecord.getAncestors(), planRecord.getProjectSn(), planRecord.getId()); baseMapper.updateAncestors(oldPlanRecord.getAncestors(), planRecord.getAncestors(), planRecord.getProjectSn(), planRecord.getId());
baseMapper.updateById(planRecord);
} else { } else {
planRecord.setAncestors(null); planRecord.setAncestors(null);
baseMapper.updateById(planRecord);
} }
planRecordService.update(null, new LambdaUpdateWrapper<PlanRecord>()
.set(PlanRecord::getWeightRate, planRecord.getWeightRate())
.eq(PlanRecord::getId, planRecord.getId()));
baseMapper.updateById(planRecord);
return this.queryById(String.valueOf(planRecord.getId())); return this.queryById(String.valueOf(planRecord.getId()));
} }
@ -304,23 +307,22 @@ public class PlanRecordServiceImpl extends ServiceImpl<PlanRecordMapper, PlanRec
List<PlanMilestoneVal> allVals = new ArrayList(); List<PlanMilestoneVal> allVals = new ArrayList();
if (CollUtil.isNotEmpty(fbIds)) { if (CollUtil.isNotEmpty(fbIds)) {
List<Long> pfbpIds = planFeedbackPeriodService.list(new LambdaQueryWrapper<PlanFeedbackPeriod>() List<Long> pfbpIds = planFeedbackPeriodService.list(new LambdaQueryWrapper<PlanFeedbackPeriod>()
.eq(PlanFeedbackPeriod::getFeedbackId, fbIds)).stream().map(PlanFeedbackPeriod::getId).collect(Collectors.toList()); .in(PlanFeedbackPeriod::getFeedbackId, fbIds)).stream().map(PlanFeedbackPeriod::getId).collect(Collectors.toList());
if (CollUtil.isNotEmpty(pfbpIds)) { if (CollUtil.isNotEmpty(pfbpIds)) {
allVals = planMilestoneValService.list(new LambdaQueryWrapper<PlanMilestoneVal>() allVals = planMilestoneValService.list(new LambdaQueryWrapper<PlanMilestoneVal>()
.eq(PlanMilestoneVal::getFeedbackPeriodId, pfbpIds)); .in(PlanMilestoneVal::getFeedbackPeriodId, pfbpIds));
} }
fbPeriods = planFeedbackPeriodService.list(new LambdaQueryWrapper<PlanFeedbackPeriod>().in(PlanFeedbackPeriod::getFeedbackId, fbIds)); fbPeriods = planFeedbackPeriodService.list(new LambdaQueryWrapper<PlanFeedbackPeriod>().in(PlanFeedbackPeriod::getFeedbackId, fbIds));
} }
if (record.getWorkType() == 1) { if (record.getWorkType() == 1) {
feedbackPeriods = this.getPeriodMilestonesForWork(record, planPeriod, milestones, recordIdMap, fbPeriods, allVals); feedbackPeriods = this.getPeriodMilestonesForWork(record, planPeriod, milestones, recordIdMap, fbPeriods, allVals);
} else if (record.getWorkType() == 2) { } else if (record.getWorkType() == 2) {
List<PlanRecord> planRecords = planRecordMapper.selectList(new LambdaQueryWrapper<PlanRecord>().eq(PlanRecord::getProjectSn, projectSn));
//判断是否最后一级wbs是的话需要显示里程碑 //判断是否最后一级wbs是的话需要显示里程碑
List<PlanRecord> children = planRecordMapper.getChildren(recordId); List<PlanRecord> records = planRecordMapper.getChildren(recordId);
children = ObjectUtil.cloneByStream(children); records = ObjectUtil.cloneByStream(records);
children.add(record); records.add(record);
List<PlanRecord> trees = BeanUtil.copyToList(ListUtils.listToTree(JSONArray.parseArray(JSON.toJSONString(children)), "id", "parentId", "children"), PlanRecord.class); List<PlanRecord> trees = BeanUtil.copyToList(ListUtils.listToTree(JSONArray.parseArray(JSON.toJSONString(records)), "id", "parentId", "children"), PlanRecord.class);
Map<Date, PlanFeedbackPeriod> map = this.getChildFeedbackPeriodMap(trees.get(0), planRecords, milestones, planPeriod, recordIdMap, fbPeriods, allVals); Map<Date, PlanFeedbackPeriod> map = this.getChildFeedbackPeriodMap(trees.get(0), milestones, planPeriod, recordIdMap, fbPeriods, allVals);
feedbackPeriods = new ArrayList<>(map.values()); feedbackPeriods = new ArrayList<>(map.values());
} else { } else {
throw new OpenAlertException("不存在的类型"); throw new OpenAlertException("不存在的类型");
@ -369,7 +371,7 @@ public class PlanRecordServiceImpl extends ServiceImpl<PlanRecordMapper, PlanRec
} }
@Override @Override
public List<PlanFeedbackPeriod> getPlanSharesForCurve(Map<String, Object> param, PlanRecord record, List<PlanMilestone> milestones, PlanPeriod planPeriod, List<PlanRecord> planRecords, List<PlanRecord> children, PlanPeriod period) { public List<PlanFeedbackPeriod> getPlanSharesForCurve(Map<String, Object> param, PlanRecord record, List<PlanMilestone> milestones, PlanPeriod planPeriod, List<PlanRecord> planRecords, PlanPeriod period) {
String beginDate = MapUtils.getString(param, "periodStart"); String beginDate = MapUtils.getString(param, "periodStart");
String endDate = MapUtils.getString(param, "periodEnd"); String endDate = MapUtils.getString(param, "periodEnd");
String projectSn = MapUtils.getString(param, "projectSn"); String projectSn = MapUtils.getString(param, "projectSn");
@ -382,19 +384,16 @@ public class PlanRecordServiceImpl extends ServiceImpl<PlanRecordMapper, PlanRec
List<PlanMilestoneVal> allVals = new ArrayList(); List<PlanMilestoneVal> allVals = new ArrayList();
if (CollUtil.isNotEmpty(fbIds)) { if (CollUtil.isNotEmpty(fbIds)) {
List<Long> pfbpIds = planFeedbackPeriodService.list(new LambdaQueryWrapper<PlanFeedbackPeriod>() List<Long> pfbpIds = planFeedbackPeriodService.list(new LambdaQueryWrapper<PlanFeedbackPeriod>()
.eq(PlanFeedbackPeriod::getFeedbackId, fbIds)).stream().map(PlanFeedbackPeriod::getId).collect(Collectors.toList()); .in(PlanFeedbackPeriod::getFeedbackId, fbIds)).stream().map(PlanFeedbackPeriod::getId).collect(Collectors.toList());
if (CollUtil.isNotEmpty(pfbpIds)) { if (CollUtil.isNotEmpty(pfbpIds)) {
allVals = planMilestoneValService.list(new LambdaQueryWrapper<PlanMilestoneVal>() allVals = planMilestoneValService.list(new LambdaQueryWrapper<PlanMilestoneVal>()
.eq(PlanMilestoneVal::getFeedbackPeriodId, pfbpIds)); .in(PlanMilestoneVal::getFeedbackPeriodId, pfbpIds));
} }
fbPeriods = planFeedbackPeriodService.list(new LambdaQueryWrapper<PlanFeedbackPeriod>().in(PlanFeedbackPeriod::getFeedbackId, fbIds)); fbPeriods = planFeedbackPeriodService.list(new LambdaQueryWrapper<PlanFeedbackPeriod>().in(PlanFeedbackPeriod::getFeedbackId, fbIds));
} }
List<PlanFeedbackPeriod> feedbackPeriods; List<PlanFeedbackPeriod> feedbackPeriods;
//判断是否最后一级wbs是的话需要显示里程碑 //判断是否最后一级wbs是的话需要显示里程碑
children = ObjectUtil.cloneByStream(children); Map<Date, PlanFeedbackPeriod> map = this.getChildFeedbackPeriodMap(record, milestones, planPeriod, recordIdMap, fbPeriods, allVals);
children.add(record);
List<PlanRecord> trees = BeanUtil.copyToList(ListUtils.listToTree(JSONArray.parseArray(JSON.toJSONString(children)), "id", "parentId", "children"), PlanRecord.class);
Map<Date, PlanFeedbackPeriod> map = this.getChildFeedbackPeriodMap(trees.get(0), planRecords, milestones, planPeriod, recordIdMap, fbPeriods, allVals);
feedbackPeriods = new ArrayList<>(map.values()); feedbackPeriods = new ArrayList<>(map.values());
if (CollUtil.isNotEmpty(feedbackPeriods)) { if (CollUtil.isNotEmpty(feedbackPeriods)) {
if (StrUtil.isNotBlank(beginDate)) { if (StrUtil.isNotBlank(beginDate)) {
@ -505,10 +504,10 @@ public class PlanRecordServiceImpl extends ServiceImpl<PlanRecordMapper, PlanRec
List<PlanMilestoneVal> allVals = new ArrayList(); List<PlanMilestoneVal> allVals = new ArrayList();
if (CollUtil.isNotEmpty(fbIds)) { if (CollUtil.isNotEmpty(fbIds)) {
List<Long> pfbpIds = planFeedbackPeriodService.list(new LambdaQueryWrapper<PlanFeedbackPeriod>() List<Long> pfbpIds = planFeedbackPeriodService.list(new LambdaQueryWrapper<PlanFeedbackPeriod>()
.eq(PlanFeedbackPeriod::getFeedbackId, fbIds)).stream().map(PlanFeedbackPeriod::getId).collect(Collectors.toList()); .in(PlanFeedbackPeriod::getFeedbackId, fbIds)).stream().map(PlanFeedbackPeriod::getId).collect(Collectors.toList());
if (CollUtil.isNotEmpty(pfbpIds)) { if (CollUtil.isNotEmpty(pfbpIds)) {
allVals = planMilestoneValService.list(new LambdaQueryWrapper<PlanMilestoneVal>() allVals = planMilestoneValService.list(new LambdaQueryWrapper<PlanMilestoneVal>()
.eq(PlanMilestoneVal::getFeedbackPeriodId, pfbpIds)); .in(PlanMilestoneVal::getFeedbackPeriodId, pfbpIds));
} }
fbPeriods = planFeedbackPeriodService.list(new LambdaQueryWrapper<PlanFeedbackPeriod>().in(PlanFeedbackPeriod::getFeedbackId, fbIds)); fbPeriods = planFeedbackPeriodService.list(new LambdaQueryWrapper<PlanFeedbackPeriod>().in(PlanFeedbackPeriod::getFeedbackId, fbIds));
} }
@ -678,6 +677,14 @@ public class PlanRecordServiceImpl extends ServiceImpl<PlanRecordMapper, PlanRec
return rtMap; return rtMap;
} }
@Override
public List<PlanRecord> getPlanRecordChildren(PlanRecord topRecord, List<PlanRecord> allPlanRecords) {
return allPlanRecords.stream()
.filter(m -> Objects.equals(m.getParentId(), topRecord.getId()))
.peek(m -> m.setChildren(getPlanRecordChildren(m, allPlanRecords)))
.collect(Collectors.toList());
}
/** /**
* 获取任务作业的区间数据 * 获取任务作业的区间数据
* *
@ -725,13 +732,22 @@ public class PlanRecordServiceImpl extends ServiceImpl<PlanRecordMapper, PlanRec
BigDecimal weight = Optional.ofNullable(milestoneMap.get(val.getMilestoneId())).map(planMilestone -> { BigDecimal weight = Optional.ofNullable(milestoneMap.get(val.getMilestoneId())).map(planMilestone -> {
return NumberUtil.div(planMilestone.getWeight(), new BigDecimal("100"), 2); return NumberUtil.div(planMilestone.getWeight(), new BigDecimal("100"), 2);
}).orElse(null); }).orElse(null);
pp = NumberUtil.add(pp, NumberUtil.mul(val.getPlanVal(), weight)); if (val.getPlanVal() != null) {
ap = NumberUtil.add(ap, NumberUtil.mul(val.getActualVal(), weight)); pp = NumberUtil.add(pp, NumberUtil.mul(NumberUtil.div(val.getPlanVal(), new BigDecimal("100"), 2), weight));
}
if (val.getActualVal() != null) {
ap = NumberUtil.add(ap, NumberUtil.mul(NumberUtil.div(val.getActualVal(), new BigDecimal("100"), 2), weight));
}
} }
period.setPlanYdz(record.getWeightRate()); period.setPlanPer(NumberUtil.mul(pp, new BigDecimal("100")));
period.setActualYdz(record.getWeightRate()); period.setActualPer(NumberUtil.mul(ap, new BigDecimal("100")));
period.setPlanPer((record.getWeightRate() == null || NumberUtil.equals(record.getWeightRate(), BigDecimal.ZERO)) ? BigDecimal.ZERO : NumberUtil.div(period.getPlanYdz(), record.getWeightRate(), 2)); BigDecimal weight = record.getWeightRate() != null ? NumberUtil.div(record.getWeightRate(), new BigDecimal("100")) : null;
period.setActualPer((record.getWeightRate() == null || NumberUtil.equals(record.getWeightRate(), BigDecimal.ZERO)) ? BigDecimal.ZERO : NumberUtil.div(period.getActualYdz(), record.getWeightRate(), 2)); period.setPlanYdz(weight == null ? BigDecimal.ZERO : NumberUtil.mul(pp, weight));
period.setActualYdz(weight == null ? BigDecimal.ZERO : NumberUtil.mul(ap, weight));
// period.setPlanPer((record.getWeightRate() == null || NumberUtil.equals(record.getWeightRate(), BigDecimal.ZERO)) ? BigDecimal.ZERO : NumberUtil.div(period.getPlanYdz(), record.getWeightRate(), 2));
// period.setActualPer((record.getWeightRate() == null || NumberUtil.equals(record.getWeightRate(), BigDecimal.ZERO)) ? BigDecimal.ZERO : NumberUtil.div(period.getActualYdz(), record.getWeightRate(), 2));
// period.setPlanYdz(record.getWeightRate());
// period.setActualYdz(record.getWeightRate());
} }
/** /**
@ -800,8 +816,7 @@ public class PlanRecordServiceImpl extends ServiceImpl<PlanRecordMapper, PlanRec
/** /**
* 获取反馈周期的map递归计算赢得值key是周期开始时间 * 获取反馈周期的map递归计算赢得值key是周期开始时间
* *
* @param record * @param record tree的记录的最顶级
* @param planRecords
* @param milestones * @param milestones
* @param planPeriod * @param planPeriod
* @param recordIdMap * @param recordIdMap
@ -809,20 +824,20 @@ public class PlanRecordServiceImpl extends ServiceImpl<PlanRecordMapper, PlanRec
* @param allVals * @param allVals
* @return * @return
*/ */
private Map<Date, PlanFeedbackPeriod> getChildFeedbackPeriodMap(PlanRecord record, List<PlanRecord> planRecords, List<PlanMilestone> milestones, PlanPeriod planPeriod, Map<String, PlanFeedback> recordIdMap, List<PlanFeedbackPeriod> fbPeriods, List<PlanMilestoneVal> allVals) { private Map<Date, PlanFeedbackPeriod> getChildFeedbackPeriodMap(PlanRecord record, List<PlanMilestone> milestones, PlanPeriod planPeriod, Map<String, PlanFeedback> recordIdMap, List<PlanFeedbackPeriod> fbPeriods, List<PlanMilestoneVal> allVals) {
List<PlanRecord> children = record.getChildren(); List<PlanRecord> children = record.getChildren();
Map<Date, PlanFeedbackPeriod> startMap = new HashMap<>(); Map<Date, PlanFeedbackPeriod> startMap = new HashMap<>();
for (PlanRecord child : children) { for (PlanRecord child : children) {
Map<Date, PlanFeedbackPeriod> startMap1; Map<Date, PlanFeedbackPeriod> startMap1;
BigDecimal weight = record.getWeightRate() != null ? NumberUtil.div(record.getWeightRate(), new BigDecimal("100")) : null;
if (Objects.equals(child.getWorkType(), 1)) { if (Objects.equals(child.getWorkType(), 1)) {
PlanRecord planRecord = planRecords.stream().filter(o -> Objects.equals(o.getId(), child.getId())).findFirst().get(); List<PlanFeedbackPeriod> feedbackPeriods1 = this.getPeriodMilestonesForWork(child, planPeriod, milestones, recordIdMap, fbPeriods, allVals);
List<PlanFeedbackPeriod> feedbackPeriods1 = this.getPeriodMilestonesForWork(planRecord, planPeriod, milestones, recordIdMap, fbPeriods, allVals);
startMap1 = feedbackPeriods1.stream().collect(Collectors.toMap(PlanFeedbackPeriod::getPeriodStart, Function.identity(), (planFeedbackPeriod, planFeedbackPeriod2) -> planFeedbackPeriod)); startMap1 = feedbackPeriods1.stream().collect(Collectors.toMap(PlanFeedbackPeriod::getPeriodStart, Function.identity(), (planFeedbackPeriod, planFeedbackPeriod2) -> planFeedbackPeriod));
//按权重求和 //按权重求和
for (Map.Entry<Date, PlanFeedbackPeriod> entry : startMap1.entrySet()) { for (Map.Entry<Date, PlanFeedbackPeriod> entry : startMap1.entrySet()) {
PlanFeedbackPeriod fp = entry.getValue(); PlanFeedbackPeriod fp = entry.getValue();
BigDecimal pydz = NumberUtil.mul(fp.getPlanYdz(), record.getWeightRate()); BigDecimal pydz = NumberUtil.mul(fp.getPlanYdz(), weight);
BigDecimal aydz = NumberUtil.mul(fp.getActualYdz(), record.getWeightRate()); BigDecimal aydz = NumberUtil.mul(fp.getActualYdz(), weight);
PlanFeedbackPeriod p = startMap.get(fp.getPeriodStart()); PlanFeedbackPeriod p = startMap.get(fp.getPeriodStart());
if (p == null) { if (p == null) {
p = ObjectUtil.cloneByStream(fp); p = ObjectUtil.cloneByStream(fp);
@ -835,11 +850,11 @@ public class PlanRecordServiceImpl extends ServiceImpl<PlanRecordMapper, PlanRec
} }
} }
} else { } else {
startMap1 = this.getChildFeedbackPeriodMap(child, planRecords, milestones, planPeriod, recordIdMap, fbPeriods, allVals); startMap1 = this.getChildFeedbackPeriodMap(child, milestones, planPeriod, recordIdMap, fbPeriods, allVals);
for (Map.Entry<Date, PlanFeedbackPeriod> entry : startMap1.entrySet()) { for (Map.Entry<Date, PlanFeedbackPeriod> entry : startMap1.entrySet()) {
PlanFeedbackPeriod fp = entry.getValue(); PlanFeedbackPeriod fp = entry.getValue();
BigDecimal pydz = NumberUtil.mul(fp.getPlanYdz(), record.getWeightRate()); BigDecimal pydz = NumberUtil.mul(fp.getPlanYdz(), weight);
BigDecimal aydz = NumberUtil.mul(fp.getActualYdz(), record.getWeightRate()); BigDecimal aydz = NumberUtil.mul(fp.getActualYdz(), weight);
PlanFeedbackPeriod p = startMap.get(fp.getPeriodStart()); PlanFeedbackPeriod p = startMap.get(fp.getPeriodStart());
if (p == null) { if (p == null) {
p = ObjectUtil.cloneByStream(fp); p = ObjectUtil.cloneByStream(fp);
@ -855,9 +870,9 @@ public class PlanRecordServiceImpl extends ServiceImpl<PlanRecordMapper, PlanRec
//计算百分比 //计算百分比
for (Map.Entry<Date, PlanFeedbackPeriod> entry : startMap.entrySet()) { for (Map.Entry<Date, PlanFeedbackPeriod> entry : startMap.entrySet()) {
PlanFeedbackPeriod period = entry.getValue(); PlanFeedbackPeriod period = entry.getValue();
if (record.getWeightRate() != null && BigDecimal.ZERO.compareTo(record.getWeightRate()) != 0) { if (weight != null && BigDecimal.ZERO.compareTo(weight) != 0) {
period.setPlanPer(NumberUtil.div(period.getPlanYdz(), record.getWeightRate(), 2)); period.setPlanPer(NumberUtil.div(period.getPlanYdz(), weight, 12));
period.setActualPer(NumberUtil.div(period.getActualYdz(), record.getWeightRate(), 2)); period.setActualPer(NumberUtil.div(period.getActualYdz(), weight, 12));
} }
} }
} }

View File

@ -62,7 +62,7 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
public IPage<ProjectGroup> queryPageList(HashMap<String, Object> param) { public IPage<ProjectGroup> queryPageList(HashMap<String, Object> param) {
QueryWrapper<ProjectGroup> queryWrapper = this.getQueryWrapper(param); QueryWrapper<ProjectGroup> queryWrapper = this.getQueryWrapper(param);
Page<ProjectGroup> page = PageUtil.getPage(param); Page<ProjectGroup> page = PageUtil.getPage(param);
IPage<ProjectGroup> pageList = baseMapper.queryList(page, queryWrapper); IPage<ProjectGroup> pageList = baseMapper.queryList(page, queryWrapper, param);
pageList.setRecords(this.dealList(pageList.getRecords())); pageList.setRecords(this.dealList(pageList.getRecords()));
return pageList; return pageList;
} }
@ -70,7 +70,7 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
@Override @Override
public List<ProjectGroup> queryList(HashMap<String, Object> param) { public List<ProjectGroup> queryList(HashMap<String, Object> param) {
QueryWrapper<ProjectGroup> queryWrapper = getQueryWrapper(param); QueryWrapper<ProjectGroup> queryWrapper = getQueryWrapper(param);
return dealList(baseMapper.queryList(queryWrapper)); return dealList(baseMapper.queryList(queryWrapper, param));
} }
private QueryWrapper<ProjectGroup> getQueryWrapper(HashMap<String, Object> param) { private QueryWrapper<ProjectGroup> getQueryWrapper(HashMap<String, Object> param) {

View File

@ -427,6 +427,7 @@ public class WorkerAdmissionServiceImpl extends ServiceImpl<WorkerAdmissionMappe
.build()); .build());
List<ProjectGroup> groupList = projectGroupService.queryList(new MapBuilder<String, Object>() List<ProjectGroup> groupList = projectGroupService.queryList(new MapBuilder<String, Object>()
.put("projectSn", projectSn) .put("projectSn", projectSn)
.put("ignoreDataScope", 1)
.build()); .build());
List<PartyConstructionOrganization> organizations = partyConstructionOrganizationService.list(new LambdaQueryWrapper<PartyConstructionOrganization>() List<PartyConstructionOrganization> organizations = partyConstructionOrganizationService.list(new LambdaQueryWrapper<PartyConstructionOrganization>()
.eq(PartyConstructionOrganization::getProjectSn, projectSn)); .eq(PartyConstructionOrganization::getProjectSn, projectSn));

View File

@ -15,6 +15,7 @@ import com.zhgd.annotation.OperLog;
import com.zhgd.jeecg.common.api.vo.Result; import com.zhgd.jeecg.common.api.vo.Result;
import com.zhgd.jeecg.common.execption.OpenAlertException; import com.zhgd.jeecg.common.execption.OpenAlertException;
import com.zhgd.xmgl.modules.baotou.entity.UserDevGroup; import com.zhgd.xmgl.modules.baotou.entity.UserDevGroup;
import com.zhgd.xmgl.modules.baotou.plan.entity.PlanRecord;
import com.zhgd.xmgl.modules.baotou.service.IProjectGroupService; import com.zhgd.xmgl.modules.baotou.service.IProjectGroupService;
import com.zhgd.xmgl.modules.baotou.service.IUserDevGroupService; import com.zhgd.xmgl.modules.baotou.service.IUserDevGroupService;
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser; import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
@ -207,6 +208,7 @@ public class SystemUserController {
@ApiImplicitParam(name = "isSupervisingRoleName", required = false, value = "1监理角色名称的人", paramType = "body"), @ApiImplicitParam(name = "isSupervisingRoleName", required = false, value = "1监理角色名称的人", paramType = "body"),
@ApiImplicitParam(name = "roleName", required = false, value = "角色名称", paramType = "body"), @ApiImplicitParam(name = "roleName", required = false, value = "角色名称", paramType = "body"),
@ApiImplicitParam(name = "notI", required = false, value = "1不查自己", paramType = "body"), @ApiImplicitParam(name = "notI", required = false, value = "1不查自己", paramType = "body"),
@ApiImplicitParam(name = "createUserId", required = false, value = "创建用户id", paramType = "body"),
}) })
@PostMapping(value = "/getProjectChilderSystemUserList") @PostMapping(value = "/getProjectChilderSystemUserList")
public Result<List<SystemUser>> getProjectChilderSystemUserList(@RequestBody Map<String, Object> map) { public Result<List<SystemUser>> getProjectChilderSystemUserList(@RequestBody Map<String, Object> map) {
@ -505,4 +507,28 @@ public class SystemUserController {
.eq(SystemUser::getUserId, userId)); .eq(SystemUser::getUserId, userId));
return Result.ok(); return Result.ok();
} }
@ApiOperation(value = "更新所有ancestor", notes = "更新所有ancestor", httpMethod = "GET")
@GetMapping(value = "/updateAncestor")
public Result updateAncestor(@ApiIgnore @RequestParam HashMap<String, Object> param) {
List<SystemUser> list = systemUserService.list();
Map<Long, List<SystemUser>> pbsMap = list.stream().collect(Collectors.groupingBy(SystemUser::getUserId));
for (Map.Entry<Long, List<SystemUser>> entry : pbsMap.entrySet()) {
List<SystemUser> value = entry.getValue();
value.stream().filter(o -> o.getCreateUserId().equals(0L)).forEach(o -> {
o.setCreateUserAncestor("0");
systemUserService.updateById(o);
setAncestor(o, list);
});
}
return Result.ok();
}
private void setAncestor(SystemUser planRecord, List<SystemUser> all) {
all.stream().filter(o -> o.getCreateUserId().equals(planRecord.getId())).forEach(o -> {
o.setCreateUserAncestor(planRecord.getCreateUserAncestor() + "," + planRecord.getId());
systemUserService.updateById(o);
setAncestor(o, all);
});
}
} }

View File

@ -245,8 +245,22 @@ public interface SystemUserMapper extends BaseMapper<SystemUser> {
/** /**
* 更新子账号名称 * 更新子账号名称
*
* @param workerId * @param workerId
* @param workerName * @param workerName
*/ */
void updateRealNameFromWorker(@Param("workerId") Long workerId, @Param("workerName") String workerName); void updateRealNameFromWorker(@Param("workerId") Long workerId, @Param("workerName") String workerName);
List<SystemUser> getChildren(Long id);
/**
* 更新祖级列表
*
* @param oldAncestor
* @param newAncestor
* @param projectSn
* @param id
*/
void updateAncestors(@Param("oldAncestor") String oldAncestor, @Param("newAncestor") String newAncestor, @Param("projectSn") String projectSn, @Param("id") Long id);
} }

View File

@ -68,6 +68,9 @@
qrte.quality_region_id = #{param.qualityRegionId} qrte.quality_region_id = #{param.qualityRegionId}
</if> </if>
<where> <where>
<if test="param.createUserId != null and param.createUserId != '' or param.createUserId == '0'.toString()">
and t.create_user_id = #{param.createUserId}
</if>
and t.sn = #{param.projectSn} and t.sn = #{param.projectSn}
and t.account_type = 6 and t.account_type = 6
<if test="param.userType != null and param.userType != ''"> <if test="param.userType != null and param.userType != ''">
@ -361,4 +364,15 @@
<update id="updateRealNameFromWorker"> <update id="updateRealNameFromWorker">
update system_user set real_name=#{workerName} where worker_id = #{workerId} update system_user set real_name=#{workerName} where worker_id = #{workerId}
</update> </update>
<select id="getChildren" resultMap="zjwjUserPage">
select * from system_user
where find_in_set(#{id}, create_user_ancestor)
</select>
<update id="updateAncestors">
UPDATE system_user
SET create_user_ancestor=REPLACE(create_user_ancestor, #{oldAncestor}, #{newAncestor})
WHERE create_user_ancestor LIKE N'${oldAncestor},${id}%' and sn = #{projectSn} and account_type = 6
</update>
</mapper> </mapper>

View File

@ -1021,12 +1021,25 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
systemUser.setRealName(workerInfo.getWorkerName()); systemUser.setRealName(workerInfo.getWorkerName());
} }
} }
//设置创建用户字段 //设置创建用户字段
Long userId = SecurityUtils.getUser().getUserId(); if (Objects.equals(systemUser.getAccountType(), 6)) {
SystemUser parentUser = this.getById(userId); UserInfo tokenUser = SecurityUtils.getUser();
String createUserAncestor = parentUser.getCreateUserAncestor() + "," + userId; if (Objects.equals(tokenUser.getAccountType(), 6)) {
systemUser.setCreateUserId(userId); systemUser.setCreateUserId(tokenUser.getUserId());
systemUser.setCreateUserAncestor(createUserAncestor); }
boolean top = systemUser.getCreateUserId() == null || systemUser.getCreateUserId() == 0;
if (top) {
systemUser.setCreateUserId(0L);
systemUser.setCreateUserAncestor("0");
} else {
SystemUser pOrg = baseMapper.selectOne(new LambdaQueryWrapper<SystemUser>()
.eq(SystemUser::getId, systemUser.getCreateUserId()));
if (pOrg != null) {
systemUser.setCreateUserAncestor(pOrg.getCreateUserAncestor() + "," + pOrg.getId());
}
}
}
systemUserMapper.insert(systemUser); systemUserMapper.insert(systemUser);
addBaseRoleUsers(systemUser); addBaseRoleUsers(systemUser);
} }
@ -1044,8 +1057,8 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
@Override @Override
public void editProjectUser(SystemUser systemUser) { public void editProjectUser(SystemUser systemUser) {
SystemUser systemUser1 = systemUserMapper.selectById(systemUser.getUserId()); SystemUser oldUser = systemUserMapper.selectById(systemUser.getUserId());
if (!Objects.equals(systemUser1.getXzProjectOrgId(), systemUser.getXzProjectOrgId())) { if (!Objects.equals(oldUser.getXzProjectOrgId(), systemUser.getXzProjectOrgId())) {
// 判断是否存在工作流的流程中 // 判断是否存在工作流的流程中
List<HistoricProcessInstance> list = historyService.createHistoricProcessInstanceQuery().unfinished().list(); List<HistoricProcessInstance> list = historyService.createHistoricProcessInstanceQuery().unfinished().list();
if (list.size() > 0) { if (list.size() > 0) {
@ -1096,6 +1109,37 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
} }
} }
systemUser.setPwUpdateTime(new Date()); systemUser.setPwUpdateTime(new Date());
//项目子账号设置createUserAncestor
if (Objects.equals(systemUser.getAccountType(), 6)) {
if (!Objects.equals(oldUser.getCreateUserId(), systemUser.getCreateUserId())) {
if (Objects.equals(systemUser.getId(), systemUser.getCreateUserId())) {
throw new OpenAlertException("不能将用户移动到其自身");
}
List<SystemUser> children = baseMapper.getChildren(systemUser.getId());
for (SystemUser child : children) {
if (child.getId().equals(systemUser.getCreateUserId())) {
throw new OpenAlertException("不能将用户移动到其自身下级");
}
}
SystemUser pOrg = baseMapper.selectById(systemUser.getCreateUserId());
// 修改子部门
boolean top = systemUser.getCreateUserId() == null || systemUser.getCreateUserId() == 0;
if (top) {
systemUser.setCreateUserId(0L);
systemUser.setCreateUserAncestor("0");
} else {
if (pOrg == null) {
throw new OpenAlertException("上级用户不存在");
}
systemUser.setCreateUserAncestor(pOrg.getCreateUserAncestor() + "," + pOrg.getId());
}
baseMapper.updateAncestors(oldUser.getCreateUserAncestor(), systemUser.getCreateUserAncestor(), systemUser.getProjectSn(), systemUser.getId());
} else {
systemUser.setCreateUserAncestor(null);
}
}
systemUserMapper.updateById(systemUser); systemUserMapper.updateById(systemUser);
QueryWrapper<BaseRoleUser> queryWrapper1 = new QueryWrapper<>(); QueryWrapper<BaseRoleUser> queryWrapper1 = new QueryWrapper<>();
queryWrapper1.lambda().eq(BaseRoleUser::getUserId, systemUser.getUserId()); queryWrapper1.lambda().eq(BaseRoleUser::getUserId, systemUser.getUserId());
@ -1529,6 +1573,10 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
if (systemUser == null) { if (systemUser == null) {
throw new OpenAlertException(MessageUtil.get("notFindErr")); throw new OpenAlertException(MessageUtil.get("notFindErr"));
} }
List<SystemUser> children = systemUserMapper.getChildren(Long.valueOf(id));
if (CollUtil.isNotEmpty(children)) {
throw new OpenAlertException("请先删除下级账号");
}
if (Objects.equals(systemUser.getAccountType(), SystemUserAccountTypeEnum.NEW_USER.getValue())) { if (Objects.equals(systemUser.getAccountType(), SystemUserAccountTypeEnum.NEW_USER.getValue())) {
//新用户 //新用户
deleteTenantOrSupplier(id, projectSn); deleteTenantOrSupplier(id, projectSn);

View File

@ -728,6 +728,9 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
//同步海康 //同步海康
deleteWorkerForHikvision(String.valueOf(workerInfo.getId()), workerInfo); deleteWorkerForHikvision(String.valueOf(workerInfo.getId()), workerInfo);
partyConstructionMemberService.deleteMember(workerInfo); partyConstructionMemberService.deleteMember(workerInfo);
workerBlacklistService.remove(new LambdaQueryWrapper<WorkerBlacklist>()
.eq(WorkerBlacklist::getWorkerId, id));
} }
private void checkExistAccount(String id) { private void checkExistAccount(String id) {