包头bug修复
This commit is contained in:
parent
f90f70585e
commit
725f2ed0ad
@ -1,6 +1,8 @@
|
||||
package com.zhgd.xmgl.modules.baotou.plan.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@ -8,12 +10,15 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.annotation.OperLog;
|
||||
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.vo.PlanRecordCurve;
|
||||
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.impl.PlanRecordServiceImpl;
|
||||
import com.zhgd.xmgl.util.ExcelUtils;
|
||||
import com.zhgd.xmgl.util.MapBuilder;
|
||||
import com.zhgd.xmgl.util.MessageUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
@ -23,7 +28,9 @@ import org.apache.commons.collections.MapUtils;
|
||||
import org.simpleframework.xml.core.Validate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@ -540,72 +547,146 @@ public class PlanRecordController {
|
||||
// }
|
||||
|
||||
|
||||
// /**
|
||||
// *录入数据-作业0427
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// @PostMapping(value = "/importWorker")
|
||||
// public Result importWorker(@RequestParam("file") MultipartFile file) {
|
||||
// List<Map<String, String>> list = null;
|
||||
// try {
|
||||
// list = ExcelUtils.jxlExlToList(file.getInputStream(), 0);
|
||||
// if (list == null || list.size() == 0) {
|
||||
// throw new OpenAlertException(MessageUtil.get("excelNotDataErr"));
|
||||
// }
|
||||
// Integer sort = 1;
|
||||
// Map<String, PlanRecord> codeNameMap = planRecordService.list(new LambdaQueryWrapper<PlanRecord>()
|
||||
// .eq(PlanRecord::getPbsId,1899717371193204738L)).stream().collect(Collectors.toMap(planRecord -> planRecord.getCode()+":"+planRecord.getJobName(), Function.identity(), (o1, o2) -> o1));
|
||||
// List<PlanRecord> addList = new ArrayList<>();
|
||||
// List<PlanRecord> updateList = new ArrayList<>();
|
||||
// for (Map<String, String> map : list) {
|
||||
// String zyCodeName = null;
|
||||
// //专业编号 作业编号 作业名称 作业开始时间 作业结束时间 作业权重
|
||||
// if (StrUtil.isNotBlank(zyCodeName = StrUtil.trim(map.get("专业编号")) + ":" + StrUtil.trim(map.get("专业名称")))) {
|
||||
// sort++;
|
||||
// PlanRecord record = new PlanRecord();
|
||||
// record.setProjectSn("5B8B3DB047214AE188F2C7916DD08203");
|
||||
// record.setCode(StrUtil.trim(map.get("作业编号")));
|
||||
// record.setJobName(StrUtil.trim(map.get("作业名称")));
|
||||
// record.setPlannedStart(DateUtil.parseDate(StrUtil.trim(map.get("作业开始时间"))));
|
||||
// record.setPlannedFinish(DateUtil.parseDate(StrUtil.trim(map.get("作业结束时间"))));
|
||||
// record.setActualStart(record.getPlannedStart());
|
||||
// record.setActualFinish(record.getPlannedFinish());
|
||||
// record.setExpectedFinish(record.getPlannedFinish());
|
||||
// record.setWeightRate(NumberUtil.mul(Convert.toBigDecimal(StrUtil.trim(map.get("作业权重"))), new BigDecimal("100")));
|
||||
// record.setCtlLevel(1);
|
||||
// record.setWorkType(1);
|
||||
// PlanRecord parent = codeNameMap.get(zyCodeName);
|
||||
// if (parent == null) {
|
||||
// throw new OpenAlertException(zyCodeName + "不存在");
|
||||
// }
|
||||
// record.setParentId(parent.getId());
|
||||
// record.setAncestors(parent.getAncestors() + "," + parent.getId());
|
||||
// record.setPbsId(1899717371193204738L);
|
||||
// record.setSort(sort);
|
||||
// codeNameMap.compute(record.getCode(), (key, val) -> {
|
||||
// if (val == null) {
|
||||
// addList.add(record);
|
||||
// } else {
|
||||
// record.setId(val.getId());
|
||||
// updateList.add(record);
|
||||
// }
|
||||
// return record;
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// if (CollUtil.isNotEmpty(addList)) {
|
||||
// planRecordService.saveBatch(addList);
|
||||
// }
|
||||
// if (CollUtil.isNotEmpty(updateList)) {
|
||||
// planRecordService.updateBatchById(updateList);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// throw new OpenAlertException();
|
||||
// }
|
||||
// return Result.ok();
|
||||
// }
|
||||
/**
|
||||
* 录入作业数据-作业0427
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@PostMapping(value = "/importWork")
|
||||
public Result importWork(@RequestParam("file") MultipartFile file, @RequestParam HashMap<String, Object> param) {
|
||||
List<Map<String, String>> list = null;
|
||||
String zyCodeName = null;
|
||||
try {
|
||||
list = ExcelUtils.jxlExlToList(file.getInputStream(), 0);
|
||||
if (list == null || list.size() == 0) {
|
||||
throw new OpenAlertException(MessageUtil.get("excelNotDataErr"));
|
||||
}
|
||||
long pbsId = MapUtils.getLong(param, "pbsId");
|
||||
String projectSn = "5B8B3DB047214AE188F2C7916DD08203";
|
||||
Map<String, PlanRecord> codeNameMap = planRecordService.list(new LambdaQueryWrapper<PlanRecord>()
|
||||
.eq(PlanRecord::getPbsId, pbsId)).stream().collect(Collectors.toMap(planRecord -> planRecord.getCode() + ":" + planRecord.getJobName(), Function.identity(), (o1, o2) -> o1));
|
||||
Integer sort = codeNameMap.values().stream().map(PlanRecord::getSort).filter(Objects::nonNull).max(Comparator.comparing(Integer::intValue)).orElse(1);
|
||||
List<PlanRecord> addList = new ArrayList<>();
|
||||
List<PlanRecord> updateList = new ArrayList<>();
|
||||
for (Map<String, String> map : list) {
|
||||
//专业编号 作业编号 作业名称 作业开始时间 作业结束时间 作业权重
|
||||
if (StrUtil.isNotBlank(zyCodeName = StrUtil.trim(map.get("专业编号")) + ":" + StrUtil.trim(map.get("专业名称")))) {
|
||||
sort++;
|
||||
PlanRecord record = new PlanRecord();
|
||||
record.setProjectSn(projectSn);
|
||||
record.setCode(StrUtil.trim(map.get("作业编号")));
|
||||
record.setJobName(StrUtil.trim(map.get("作业名称")));
|
||||
record.setPlannedStart(DateUtil.parseDate(StrUtil.trim(map.get("作业开始时间"))));
|
||||
record.setPlannedFinish(DateUtil.parseDate(StrUtil.trim(map.get("作业结束时间"))));
|
||||
record.setActualStart(record.getPlannedStart());
|
||||
record.setActualFinish(record.getPlannedFinish());
|
||||
record.setExpectedFinish(record.getPlannedFinish());
|
||||
record.setWeightRate(NumberUtil.mul(Convert.toBigDecimal(StrUtil.trim(map.get("作业权重"))), new BigDecimal("100")));
|
||||
record.setCtlLevel(1);
|
||||
record.setWorkType(1);
|
||||
PlanRecord parent = codeNameMap.get(zyCodeName);
|
||||
if (parent == null) {
|
||||
throw new OpenAlertException(zyCodeName + "不存在");
|
||||
}
|
||||
record.setParentId(parent.getId());
|
||||
record.setAncestors(parent.getAncestors() + "," + parent.getId());
|
||||
record.setPbsId(pbsId);
|
||||
record.setSort(sort);
|
||||
codeNameMap.compute(record.getCode() + ":" + record.getJobName(), (key, val) -> {
|
||||
if (val == null) {
|
||||
addList.add(record);
|
||||
} else {
|
||||
record.setId(val.getId());
|
||||
updateList.add(record);
|
||||
}
|
||||
return record;
|
||||
});
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(addList)) {
|
||||
planRecordService.saveBatch(addList);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(updateList)) {
|
||||
planRecordService.updateBatchById(updateList);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error(zyCodeName + e.getMessage());
|
||||
}
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 录入专业-0429
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@PostMapping(value = "/importProfession")
|
||||
public Result importProfession(@RequestParam("file") MultipartFile file, @RequestParam HashMap<String, Object> param) {
|
||||
List<Map<String, String>> list = null;
|
||||
try {
|
||||
list = ExcelUtils.jxlExlToList(file.getInputStream(), 0);
|
||||
if (list == null || list.size() == 0) {
|
||||
throw new OpenAlertException(MessageUtil.get("excelNotDataErr"));
|
||||
}
|
||||
long pbsId = MapUtils.getLong(param, "pbsId");
|
||||
String projectSn = "5B8B3DB047214AE188F2C7916DD08203";
|
||||
Map<String, PlanRecord> codeMap = planRecordService.list(new LambdaQueryWrapper<PlanRecord>()
|
||||
.eq(PlanRecord::getPbsId, pbsId)).stream().collect(Collectors.toMap(planRecord -> planRecord.getCode(), Function.identity(), (o1, o2) -> o1));
|
||||
Integer sort = codeMap.values().stream().map(PlanRecord::getSort).filter(Objects::nonNull).max(Comparator.comparing(Integer::intValue)).orElse(1);
|
||||
List<PlanRecord> addList = new ArrayList<>();
|
||||
List<PlanRecord> updateList = new ArrayList<>();
|
||||
for (Map<String, String> map : list) {
|
||||
String zyCode = null;
|
||||
//上级WBS编号 编号 名称 计划开始 计划完成 权重(%)
|
||||
if (StrUtil.isNotBlank(zyCode = StrUtil.trim(map.get("上级WBS编号")))) {
|
||||
sort++;
|
||||
PlanRecord record = new PlanRecord();
|
||||
record.setProjectSn(projectSn);
|
||||
record.setCode(StrUtil.trim(map.get("编号")));
|
||||
record.setJobName(StrUtil.trim(map.get("名称")));
|
||||
record.setPlannedStart(DateUtil.parseDate(StrUtil.trim(map.get("计划开始"))));
|
||||
record.setPlannedFinish(DateUtil.parseDate(StrUtil.trim(map.get("计划完成"))));
|
||||
record.setActualStart(record.getPlannedStart());
|
||||
record.setActualFinish(record.getPlannedFinish());
|
||||
record.setExpectedFinish(record.getPlannedFinish());
|
||||
record.setWeightRate(NumberUtil.mul(Convert.toBigDecimal(StrUtil.trim(map.get("权重(%)"))), new BigDecimal("100")));
|
||||
record.setCtlLevel(1);
|
||||
record.setWorkType(2);
|
||||
PlanRecord parent = codeMap.get(zyCode);
|
||||
if (parent == null) {
|
||||
throw new OpenAlertException(zyCode + "不存在");
|
||||
}
|
||||
record.setParentId(parent.getId());
|
||||
record.setAncestors(parent.getAncestors() + "," + parent.getId());
|
||||
record.setPbsId(pbsId);
|
||||
record.setSort(sort);
|
||||
codeMap.compute(record.getCode(), (key, val) -> {
|
||||
if (val == null) {
|
||||
addList.add(record);
|
||||
} else {
|
||||
record.setId(val.getId());
|
||||
updateList.add(record);
|
||||
}
|
||||
return record;
|
||||
});
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(addList)) {
|
||||
planRecordService.saveBatch(addList);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(updateList)) {
|
||||
planRecordService.updateBatchById(updateList);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new OpenAlertException();
|
||||
}
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -72,7 +72,11 @@ public class PlanMilestoneVal implements Serializable {
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "计划完成日期 yyyy-MM-dd")
|
||||
private java.util.Date planCompleteDate;
|
||||
|
||||
/**
|
||||
* 1选择百分比2选择日期
|
||||
*/
|
||||
@ApiModelProperty(value = "1选择百分比2选择日期")
|
||||
private java.lang.Integer selectType;
|
||||
@TableField(exist = false)
|
||||
private String milestoneName;
|
||||
@TableField(exist = false)
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package com.zhgd.xmgl.modules.baotou.plan.service.impl;
|
||||
import java.util.Date;
|
||||
|
||||
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
@ -27,6 +29,7 @@ import com.zhgd.xmgl.util.*;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -301,7 +304,6 @@ public class PlanRecordServiceImpl extends ServiceImpl<PlanRecordMapper, PlanRec
|
||||
return entity;
|
||||
}
|
||||
|
||||
// @Cacheable(value = "planRecord", key = "#param['pbsId']")
|
||||
@Override
|
||||
public IPage<PlanRecord> queryTreePage(HashMap<String, Object> param) {
|
||||
List<PlanRecord> list = this.queryList(param);
|
||||
|
||||
@ -24,13 +24,19 @@ public class FlowUtil {
|
||||
* @return
|
||||
*/
|
||||
public static String getFileUrl(Map map, String key) {
|
||||
if (isEmpty(map.get(key))) {
|
||||
return null;
|
||||
}
|
||||
return Optional.ofNullable(map.get(key)).map(o -> {
|
||||
if ("".equals(o)) {
|
||||
return null;
|
||||
} else if (o instanceof String) {
|
||||
return ((Map) (JSON.parseArray(o.toString())).get(0)).get("url").toString();
|
||||
if (o instanceof String) {
|
||||
JSONArray jsonArray = JSON.parseArray(o.toString());
|
||||
if (jsonArray.size() == 0) {
|
||||
return null;
|
||||
} else {
|
||||
return Optional.ofNullable((Map) jsonArray.get(0)).map(m -> m.get("url").toString()).orElse(null);
|
||||
}
|
||||
} else {
|
||||
return ((Map) getFirstFromListNotNull(o)).get("url").toString();
|
||||
return Optional.ofNullable((Map) getFirstFromListNotNull(o)).map(m -> m.get("url").toString()).orElse(null);
|
||||
}
|
||||
}).orElse(null);
|
||||
}
|
||||
@ -54,17 +60,6 @@ public class FlowUtil {
|
||||
return StrUtil.join(",", collect);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件url完整链接
|
||||
*
|
||||
* @param map
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static String getFileUrlWithHost(Map map, String key) {
|
||||
return Optional.ofNullable(map.get(key)).map(o -> "".equals(o) ? null : PathUtil.getDomain() + ((Map) getFirstFromListNotNull(o)).get("url").toString()).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件原来的名称
|
||||
*
|
||||
@ -73,7 +68,10 @@ public class FlowUtil {
|
||||
* @return
|
||||
*/
|
||||
public static String getFileOriginFileName(Map map, String key) {
|
||||
return Optional.ofNullable(map.get(key)).map(o -> "".equals(o) ? null : ((Map) getFirstFromListNotNull(o)).get("name").toString()).orElse(null);
|
||||
if (isEmpty(map.get(key))) {
|
||||
return null;
|
||||
}
|
||||
return Optional.ofNullable((Map) getFirstFromListNotNull(map.get(key))).map(m -> m.get("name").toString()).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user