任务进度甘特图部分导入导出
This commit is contained in:
parent
e59b0fd066
commit
5f83c2696e
@ -1,5 +1,6 @@
|
|||||||
package com.zhgd.xmgl.modules.quality.entity.vo;
|
package com.zhgd.xmgl.modules.quality.entity.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ -7,17 +8,30 @@ public class QualityInspectionRecordTotalVo {
|
|||||||
|
|
||||||
private Integer verificationNum;
|
private Integer verificationNum;
|
||||||
private Double rectificationRatio;
|
private Double rectificationRatio;
|
||||||
|
@ApiModelProperty("已闭合")
|
||||||
private Integer closeNum;
|
private Integer closeNum;
|
||||||
private Integer reviewNum;
|
private Integer reviewNum;
|
||||||
private Integer investigateNum;
|
private Integer investigateNum;
|
||||||
|
@ApiModelProperty("超期未关闭")
|
||||||
private Integer overdueNotCloseNum;
|
private Integer overdueNotCloseNum;
|
||||||
private Integer rectificationNum;
|
private Integer rectificationNum;
|
||||||
private Integer ybUrgentLevelNum;
|
private Integer ybUrgentLevelNum;
|
||||||
private Integer yzUrgentLevelNum;
|
private Integer yzUrgentLevelNum;
|
||||||
|
@ApiModelProperty("总数")
|
||||||
private String totalNum;
|
private String totalNum;
|
||||||
private Double completeRatio;
|
private Double completeRatio;
|
||||||
private Integer jyUrgentLevelNum;
|
private Integer jyUrgentLevelNum;
|
||||||
private Integer overdueRectificationNum;
|
private Integer overdueRectificationNum;
|
||||||
|
@ApiModelProperty("未闭合")
|
||||||
private Integer notCloseNum;
|
private Integer notCloseNum;
|
||||||
|
@ApiModelProperty("今日较昨日总数")
|
||||||
|
private Integer totalNumDifferYesterday;
|
||||||
|
@ApiModelProperty("今日较昨日超期未关闭")
|
||||||
|
private Integer overdueNotCloseNumDifferYesterday;
|
||||||
|
@ApiModelProperty("今日较昨日已闭合")
|
||||||
|
private Integer closeNumDifferYesterday;
|
||||||
|
@ApiModelProperty("今日较昨日未闭合")
|
||||||
|
private Integer notCloseNumDifferYesterday;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.zhgd.xmgl.modules.quality.service.impl;
|
package com.zhgd.xmgl.modules.quality.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.core.util.NumberUtil;
|
import cn.hutool.core.util.NumberUtil;
|
||||||
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;
|
||||||
@ -22,6 +23,7 @@ import com.zhgd.xmgl.modules.quality.mapper.QualityInspectionRecordMapper;
|
|||||||
import com.zhgd.xmgl.modules.quality.mapper.QualityRectifyRecordMapper;
|
import com.zhgd.xmgl.modules.quality.mapper.QualityRectifyRecordMapper;
|
||||||
import com.zhgd.xmgl.modules.quality.mapper.QualityRegionMapper;
|
import com.zhgd.xmgl.modules.quality.mapper.QualityRegionMapper;
|
||||||
import com.zhgd.xmgl.modules.quality.service.IQualityInspectionRecordService;
|
import com.zhgd.xmgl.modules.quality.service.IQualityInspectionRecordService;
|
||||||
|
import com.zhgd.xmgl.util.DateUtil;
|
||||||
import com.zhgd.xmgl.util.JxlExcelUtils;
|
import com.zhgd.xmgl.util.JxlExcelUtils;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.collections.MapUtils;
|
import org.apache.commons.collections.MapUtils;
|
||||||
@ -112,6 +114,7 @@ public class QualityInspectionRecordServiceImpl extends ServiceImpl<QualityInspe
|
|||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
map.put("recordType", "1");
|
map.put("recordType", "1");
|
||||||
QualityInspectionRecordTotalVo total = qualityInspectionRecordMapper.selectQualityInspectionRecordPageTotal(map);
|
QualityInspectionRecordTotalVo total = qualityInspectionRecordMapper.selectQualityInspectionRecordPageTotal(map);
|
||||||
|
setDifferYesterday(map, total);
|
||||||
List<Map<String, Object>> monthList = qualityInspectionRecordMapper.selectQualityInspectionRecordCountByDay(map);
|
List<Map<String, Object>> monthList = qualityInspectionRecordMapper.selectQualityInspectionRecordCountByDay(map);
|
||||||
List<String> dayList = getDayList();
|
List<String> dayList = getDayList();
|
||||||
List<Map<String, Object>> list = new ArrayList<>();
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
@ -138,6 +141,23 @@ public class QualityInspectionRecordServiceImpl extends ServiceImpl<QualityInspe
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setDifferYesterday(Map<String, Object> map, QualityInspectionRecordTotalVo total) {
|
||||||
|
Date date = new Date();
|
||||||
|
map.put("inspectStartTime", DateUtil.today());
|
||||||
|
map.put("inspectEndTime", DateUtil.format(DateUtil.endOfDay(new Date()), "yyyy-MM-dd HH:mm:ss"));
|
||||||
|
QualityInspectionRecordTotalVo todayTotal = qualityInspectionRecordMapper.selectQualityInspectionRecordPageTotal(map);
|
||||||
|
DateTime d = DateUtil.offsetDay(date, -1);
|
||||||
|
map.put("inspectStartTime", DateUtil.format(d, "yyyy-MM-dd"));
|
||||||
|
map.put("inspectEndTime", DateUtil.format(DateUtil.endOfDay(d), "yyyy-MM-dd HH:mm:ss"));
|
||||||
|
QualityInspectionRecordTotalVo yesterdayTotal = qualityInspectionRecordMapper.selectQualityInspectionRecordPageTotal(map);
|
||||||
|
total.setTotalNumDifferYesterday(Integer.parseInt(todayTotal.getTotalNum()) - Integer.parseInt(yesterdayTotal.getTotalNum()));
|
||||||
|
total.setCloseNumDifferYesterday(todayTotal.getCloseNum() - yesterdayTotal.getCloseNum());
|
||||||
|
total.setNotCloseNumDifferYesterday(todayTotal.getNotCloseNum() - yesterdayTotal.getNotCloseNum());
|
||||||
|
total.setOverdueNotCloseNumDifferYesterday(todayTotal.getOverdueNotCloseNum() - yesterdayTotal.getOverdueNotCloseNum());
|
||||||
|
map.put("inspectStartTime", null);
|
||||||
|
map.put("inspectEndTime", null);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> selectDangerTypeQualityCount(Map<String, Object> map) {
|
public Map<String, Object> selectDangerTypeQualityCount(Map<String, Object> map) {
|
||||||
Map<String, Object> data = new HashMap<>(1);
|
Map<String, Object> data = new HashMap<>(1);
|
||||||
|
|||||||
@ -184,19 +184,20 @@ public class TaskProgressController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入mpp文件解析对应的数据(增量覆盖)
|
* 导入mpp文件解析对应的数据
|
||||||
*
|
*
|
||||||
* @param mppFile
|
* @param mppFile
|
||||||
* @return 删除结果
|
* @return 删除结果
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/importData")
|
@PostMapping(value = "/importData")
|
||||||
@ApiOperation(value = "导入mpp文件解析对应的数据(增量覆盖)")
|
@ApiOperation(value = "导入mpp文件解析对应的数据")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ApiImplicitParam(name = "mppUrl", value = "mpp甘特图文件路径", dataType = "string", dataTypeClass = String.class, required = true, paramType = "query"),
|
@ApiImplicitParam(name = "mppUrl", value = "mpp甘特图文件路径", dataType = "string", dataTypeClass = String.class, required = true, paramType = "query"),
|
||||||
@ApiImplicitParam(name = "projectSn", value = "项目sn", dataType = "string", dataTypeClass = String.class, required = true, paramType = "query"),
|
@ApiImplicitParam(name = "projectSn", value = "项目sn", dataType = "string", dataTypeClass = String.class, required = true, paramType = "query"),
|
||||||
|
@ApiImplicitParam(name = "type", value = "导入方式:1覆盖更新(复制)2根据名称替换更新", dataType = "integer", required = true, paramType = "query"),
|
||||||
})
|
})
|
||||||
public Result importData(@RequestParam(value = "mppFile") MultipartFile mppFile, String projectSn, Long createUserId) {
|
public Result importData(@RequestParam(value = "mppFile") MultipartFile mppFile, String projectSn, Integer type) {
|
||||||
taskProgressService.importData(mppFile, projectSn, createUserId);
|
taskProgressService.importData(mppFile, projectSn, type);
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,10 @@
|
|||||||
package com.zhgd.xmgl.modules.taskprogress.controller;
|
package com.zhgd.xmgl.modules.taskprogress.controller;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
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.zhgd.jeecg.common.api.vo.Result;
|
import com.zhgd.jeecg.common.api.vo.Result;
|
||||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||||
import com.zhgd.jeecg.common.util.oConvertUtils;
|
|
||||||
import com.zhgd.xmgl.modules.taskprogress.entity.TaskProgress;
|
import com.zhgd.xmgl.modules.taskprogress.entity.TaskProgress;
|
||||||
import com.zhgd.xmgl.modules.taskprogress.entity.TaskProgressMaterialRel;
|
import com.zhgd.xmgl.modules.taskprogress.entity.TaskProgressMaterialRel;
|
||||||
import com.zhgd.xmgl.modules.taskprogress.service.ITaskProgressMaterialRelService;
|
import com.zhgd.xmgl.modules.taskprogress.service.ITaskProgressMaterialRelService;
|
||||||
@ -16,18 +14,13 @@ import io.swagger.annotations.ApiImplicitParams;
|
|||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections.MapUtils;
|
import org.apache.commons.collections.MapUtils;
|
||||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
||||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
||||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import springfox.documentation.annotations.ApiIgnore;
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLDecoder;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -167,31 +160,28 @@ public class TaskProgressMaterialRelController {
|
|||||||
* @param request
|
* @param request
|
||||||
* @param response
|
* @param response
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "导出excel任务进度甘特图-材料类型-关联信息", notes = "导出excel任务进度甘特图-材料类型-关联信息", httpMethod = "POST")
|
@ApiOperation(value = "导出excel任务进度甘特图-计划材料工程", notes = "导出excel任务进度甘特图-计划材料工程", httpMethod = "POST")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "query", required = true, dataType = "String"),
|
||||||
|
@ApiImplicitParam(name = "type", value = "类型:1下载模板2导出", paramType = "query", required = true, dataType = "Integer"),
|
||||||
|
})
|
||||||
@RequestMapping(value = "/exportXls")
|
@RequestMapping(value = "/exportXls")
|
||||||
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
|
public void exportXls(HttpServletRequest request, @ApiIgnore @RequestBody HashMap<String, Object> paramMap, HttpServletResponse response) {
|
||||||
// Step.1 组装查询条件
|
taskProgressMaterialRelService.exportXls(request, paramMap, response);
|
||||||
QueryWrapper<TaskProgressMaterialRel> queryWrapper = null;
|
}
|
||||||
try {
|
|
||||||
String paramsStr = request.getParameter("paramsStr");
|
|
||||||
if (oConvertUtils.isNotEmpty(paramsStr)) {
|
|
||||||
String deString = URLDecoder.decode(paramsStr, "UTF-8");
|
|
||||||
TaskProgressMaterialRel taskProgressMaterialRel = JSON.parseObject(deString, TaskProgressMaterialRel.class);
|
|
||||||
queryWrapper = QueryGenerator.initQueryWrapper(taskProgressMaterialRel, request.getParameterMap());
|
|
||||||
}
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Step.2 AutoPoi 导出Excel
|
/**
|
||||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
* 通过excel导入数据
|
||||||
List<TaskProgressMaterialRel> pageList = taskProgressMaterialRelService.list(queryWrapper);
|
*
|
||||||
//导出文件名称
|
* @return
|
||||||
mv.addObject(NormalExcelConstants.FILE_NAME, "任务进度甘特图-材料类型-关联列表");
|
*/
|
||||||
mv.addObject(NormalExcelConstants.CLASS, TaskProgressMaterialRel.class);
|
@ApiOperation(value = "通过excel导入任务进度甘特图-计划材料工程", notes = "通过excel导入任务进度甘特图-计划材料工程", httpMethod = "POST")
|
||||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("任务进度甘特图-材料类型-关联列表数据", "导出人:Jeecg", "导出信息"));
|
@ApiImplicitParams({
|
||||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "query", required = true, dataType = "String"),
|
||||||
return mv;
|
})
|
||||||
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||||
|
public Result<?> importExcel(MultipartFile file, @ApiIgnore @RequestParam HashMap<String, Object> paramMap) {
|
||||||
|
return taskProgressMaterialRelService.importExcel(file, paramMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,13 +39,11 @@ public class TaskProgressMaterialRel implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* taskProgressMaterialTypeId
|
* taskProgressMaterialTypeId
|
||||||
*/
|
*/
|
||||||
@Excel(name = "taskProgressMaterialTypeId", width = 15)
|
|
||||||
@ApiModelProperty(value = "taskProgressMaterialTypeId")
|
@ApiModelProperty(value = "taskProgressMaterialTypeId")
|
||||||
private java.lang.Long taskProgressMaterialTypeId;
|
private java.lang.Long taskProgressMaterialTypeId;
|
||||||
/**
|
/**
|
||||||
* taskProgressContentId
|
* taskProgressContentId
|
||||||
*/
|
*/
|
||||||
@Excel(name = "taskProgressContentId", width = 15)
|
|
||||||
@ApiModelProperty(value = "taskProgressContentId")
|
@ApiModelProperty(value = "taskProgressContentId")
|
||||||
private java.lang.Long taskProgressContentId;
|
private java.lang.Long taskProgressContentId;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,10 +1,14 @@
|
|||||||
package com.zhgd.xmgl.modules.taskprogress.service;
|
package com.zhgd.xmgl.modules.taskprogress.service;
|
||||||
|
|
||||||
|
import com.zhgd.jeecg.common.api.vo.Result;
|
||||||
import com.zhgd.xmgl.modules.taskprogress.entity.TaskProgress;
|
import com.zhgd.xmgl.modules.taskprogress.entity.TaskProgress;
|
||||||
import com.zhgd.xmgl.modules.taskprogress.entity.TaskProgressMaterialRel;
|
import com.zhgd.xmgl.modules.taskprogress.entity.TaskProgressMaterialRel;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -19,4 +23,8 @@ public interface ITaskProgressMaterialRelService extends IService<TaskProgressMa
|
|||||||
List<TaskProgressMaterialRel> queryDetailList(HashMap<String, Object> paramMap);
|
List<TaskProgressMaterialRel> queryDetailList(HashMap<String, Object> paramMap);
|
||||||
|
|
||||||
List<TaskProgress> queryTreeList(HashMap<String, Object> paramMap);
|
List<TaskProgress> queryTreeList(HashMap<String, Object> paramMap);
|
||||||
|
|
||||||
|
void exportXls(HttpServletRequest request, HashMap<String, Object> paramMap, HttpServletResponse response);
|
||||||
|
|
||||||
|
Result<?> importExcel(MultipartFile file, HashMap<String, Object> paramMap);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,5 +22,5 @@ public interface ITaskProgressService extends IService<TaskProgress> {
|
|||||||
|
|
||||||
void delete(HashMap<String, Object> map);
|
void delete(HashMap<String, Object> map);
|
||||||
|
|
||||||
void importData(MultipartFile mppFile, String projectSn, Long createUserId);
|
void importData(MultipartFile mppFile, String projectSn, Integer createUserId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,21 +1,35 @@
|
|||||||
package com.zhgd.xmgl.modules.taskprogress.service.impl;
|
package com.zhgd.xmgl.modules.taskprogress.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.zhgd.jeecg.common.api.vo.Result;
|
||||||
|
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||||
import com.zhgd.xmgl.modules.taskprogress.entity.TaskProgress;
|
import com.zhgd.xmgl.modules.taskprogress.entity.TaskProgress;
|
||||||
import com.zhgd.xmgl.modules.taskprogress.entity.TaskProgressMaterialRel;
|
import com.zhgd.xmgl.modules.taskprogress.entity.TaskProgressMaterialRel;
|
||||||
|
import com.zhgd.xmgl.modules.taskprogress.entity.TaskProgressMaterialType;
|
||||||
import com.zhgd.xmgl.modules.taskprogress.mapper.TaskProgressMapper;
|
import com.zhgd.xmgl.modules.taskprogress.mapper.TaskProgressMapper;
|
||||||
import com.zhgd.xmgl.modules.taskprogress.mapper.TaskProgressMaterialRelMapper;
|
import com.zhgd.xmgl.modules.taskprogress.mapper.TaskProgressMaterialRelMapper;
|
||||||
|
import com.zhgd.xmgl.modules.taskprogress.mapper.TaskProgressMaterialTypeMapper;
|
||||||
import com.zhgd.xmgl.modules.taskprogress.service.ITaskProgressMaterialRelService;
|
import com.zhgd.xmgl.modules.taskprogress.service.ITaskProgressMaterialRelService;
|
||||||
import org.apache.commons.collections.MapUtils;
|
import org.apache.commons.collections.MapUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
import org.jeecgframework.poi.excel.ExcelExportUtil;
|
||||||
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||||
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||||
|
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||||
|
import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.util.Collections;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.HashMap;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,6 +47,8 @@ public class TaskProgressMaterialRelServiceImpl extends ServiceImpl<TaskProgress
|
|||||||
TaskProgressMapper taskProgressMapper;
|
TaskProgressMapper taskProgressMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
TaskProgressServiceImpl taskProgressService;
|
TaskProgressServiceImpl taskProgressService;
|
||||||
|
@Autowired
|
||||||
|
TaskProgressMaterialTypeMapper taskProgressMaterialTypeMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TaskProgressMaterialRel> queryDetailList(HashMap<String, Object> paramMap) {
|
public List<TaskProgressMaterialRel> queryDetailList(HashMap<String, Object> paramMap) {
|
||||||
@ -55,4 +71,140 @@ public class TaskProgressMaterialRelServiceImpl extends ServiceImpl<TaskProgress
|
|||||||
Map<Long, List<TaskProgress>> parentIdTaskListMap = progressTaskList.stream().collect(Collectors.groupingBy(TaskProgress::getParentId));
|
Map<Long, List<TaskProgress>> parentIdTaskListMap = progressTaskList.stream().collect(Collectors.groupingBy(TaskProgress::getParentId));
|
||||||
return taskProgressService.getChild(parentIdTaskListMap, 0L);
|
return taskProgressService.getChild(parentIdTaskListMap, 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exportXls(HttpServletRequest request, HashMap<String, Object> paramMap, HttpServletResponse response) {
|
||||||
|
String projectSn = MapUtils.getString(paramMap, "projectSn");
|
||||||
|
Integer type = MapUtils.getInteger(paramMap, "type");
|
||||||
|
List<TaskProgress> taskProgresses = queryTreeList(paramMap);
|
||||||
|
String plan = "计划情况";
|
||||||
|
String actual = "实际情况";
|
||||||
|
// 树形转为list
|
||||||
|
List<TaskProgress> result = new ArrayList<>();
|
||||||
|
for (TaskProgress taskProgress : taskProgresses) {
|
||||||
|
this.recursionTreeToList(result, taskProgress, null);
|
||||||
|
}
|
||||||
|
List<ExcelExportEntity> entityList = new ArrayList<>();
|
||||||
|
entityList.add(new ExcelExportEntity("id", "id"));
|
||||||
|
entityList.add(new ExcelExportEntity("父级id", "pid"));
|
||||||
|
entityList.add(new ExcelExportEntity("分部分项工程名称", "taskName"));
|
||||||
|
List<TaskProgressMaterialType> taskProgressMaterialRels = taskProgressMaterialTypeMapper.selectList(new LambdaQueryWrapper<TaskProgressMaterialType>()
|
||||||
|
.eq(TaskProgressMaterialType::getProjectSn, projectSn));
|
||||||
|
String p = "p";
|
||||||
|
String a = "a";
|
||||||
|
for (TaskProgressMaterialType rel : taskProgressMaterialRels) {
|
||||||
|
entityList.add(new ExcelExportEntity(rel.getName(), p + rel.getId() + "", true));
|
||||||
|
}
|
||||||
|
for (TaskProgressMaterialType rel : taskProgressMaterialRels) {
|
||||||
|
entityList.add(new ExcelExportEntity(rel.getName(), a + rel.getId() + "", true));
|
||||||
|
}
|
||||||
|
List<String> pids = taskProgressMaterialRels.stream().map(o -> p + o.getId() + "").collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isEmpty(pids)) {
|
||||||
|
throw new OpenAlertException("请先添加材料类型");
|
||||||
|
}
|
||||||
|
List<String> aids = taskProgressMaterialRels.stream().map(o -> p + o.getId() + "").collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isEmpty(aids)) {
|
||||||
|
throw new OpenAlertException("请先添加材料类型");
|
||||||
|
}
|
||||||
|
|
||||||
|
//合并表头
|
||||||
|
ExcelExportEntity e4 = new ExcelExportEntity(plan, "plan", true);
|
||||||
|
//还需要设置一个子表头key的集合
|
||||||
|
e4.setSubColumnList(pids);
|
||||||
|
entityList.add(e4);
|
||||||
|
ExcelExportEntity e5 = new ExcelExportEntity(actual, "actual", true);
|
||||||
|
//还需要设置一个子表头key的集合
|
||||||
|
e5.setSubColumnList(aids);
|
||||||
|
entityList.add(e5);
|
||||||
|
|
||||||
|
List<Map<Object, String>> list = new ArrayList<>();
|
||||||
|
Map<Object, String> map;
|
||||||
|
for (TaskProgress taskProgress : result) {
|
||||||
|
List<TaskProgressMaterialRel> relList = taskProgress.getRelList();
|
||||||
|
map = new HashMap<>();
|
||||||
|
map.put("id", String.valueOf(taskProgress.getId()));
|
||||||
|
map.put("pid", String.valueOf(taskProgress.getParentId()));
|
||||||
|
map.put("taskName", taskProgress.getTaskName());
|
||||||
|
if (CollUtil.isNotEmpty(relList) && Objects.equals(type, 2)) {
|
||||||
|
for (TaskProgressMaterialRel rel : relList) {
|
||||||
|
map.put(p + rel.getTaskProgressMaterialTypeId() + "", rel.getPlanUsage() + "");
|
||||||
|
map.put(a + rel.getTaskProgressMaterialTypeId() + "", rel.getActualUsage() + "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
list.add(map);
|
||||||
|
}
|
||||||
|
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), entityList, list);
|
||||||
|
try {
|
||||||
|
workbook.write(response.getOutputStream());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result importExcel(MultipartFile file, HashMap<String, Object> paramMap) {
|
||||||
|
String projectSn = MapUtils.getString(paramMap, "projectSn");
|
||||||
|
ImportParams params = new ImportParams();
|
||||||
|
params.setTitleRows(0);
|
||||||
|
params.setHeadRows(1);
|
||||||
|
try {
|
||||||
|
List<Map<String, String>> mapList = ExcelImportUtil.importExcel(file.getInputStream(), Map.class, params);
|
||||||
|
String plan = "计划情况_";
|
||||||
|
String actual = "实际情况_";
|
||||||
|
for (Map<String, String> m : mapList) {
|
||||||
|
Set<String> keys = m.keySet();
|
||||||
|
for (String key : keys) {
|
||||||
|
if (StringUtils.startsWith(key, plan)) {
|
||||||
|
String trueKey;
|
||||||
|
if (StringUtils.startsWith(key, plan)) {
|
||||||
|
trueKey = StringUtils.substringAfterLast(key, plan);
|
||||||
|
} else {
|
||||||
|
trueKey = StringUtils.substringAfterLast(actual, plan);
|
||||||
|
}
|
||||||
|
TaskProgressMaterialType type = taskProgressMaterialTypeMapper.selectOne(new LambdaQueryWrapper<TaskProgressMaterialType>()
|
||||||
|
.eq(TaskProgressMaterialType::getName, trueKey)
|
||||||
|
.eq(TaskProgressMaterialType::getProjectSn, projectSn));
|
||||||
|
if (type == null) {
|
||||||
|
throw new OpenAlertException("材料类型不存在");
|
||||||
|
}
|
||||||
|
TaskProgressMaterialRel rel = new TaskProgressMaterialRel();
|
||||||
|
rel.setTaskProgressId(MapUtils.getLong(m, "id"));
|
||||||
|
rel.setTaskProgressMaterialTypeId(type.getId());
|
||||||
|
rel.setPlanUsage(MapUtils.getDouble(m, plan + trueKey));
|
||||||
|
rel.setActualUsage(MapUtils.getDouble(m, actual + trueKey));
|
||||||
|
taskProgressMaterialRelMapper.insert(rel);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result.ok("文件导入成功!");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("err:" + e);
|
||||||
|
return Result.error("文件导入失败!");
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
file.getInputStream().close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归把传过来的tree转为list
|
||||||
|
*
|
||||||
|
* @param result 结果集
|
||||||
|
* @param root 当前对象
|
||||||
|
* @param parentNode 没有传Null
|
||||||
|
*/
|
||||||
|
private void recursionTreeToList(List<TaskProgress> result, TaskProgress root, TaskProgress parentNode) {
|
||||||
|
result.add(root);
|
||||||
|
if (CollectionUtils.isEmpty(root.getChildren())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (TaskProgress child : root.getChildren()) {
|
||||||
|
this.recursionTreeToList(result, child, root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -114,7 +114,7 @@ public class TaskProgressServiceImpl extends ServiceImpl<TaskProgressMapper, Tas
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void importData(MultipartFile mppFile, String projectSn, Long createUserId) {
|
public void importData(MultipartFile mppFile, String projectSn, Integer type) {
|
||||||
//log.info("用户id:{},执行上传mpp文件操作", createUserId);
|
//log.info("用户id:{},执行上传mpp文件操作", createUserId);
|
||||||
//List<TaskProgress> progressTasks = taskProgressMapper.selectList(Wrappers.lambdaQuery(TaskProgress.class).eq(TaskProgress::getProjectSn, projectSn));
|
//List<TaskProgress> progressTasks = taskProgressMapper.selectList(Wrappers.lambdaQuery(TaskProgress.class).eq(TaskProgress::getProjectSn, projectSn));
|
||||||
//log.info("原progressTasks:{}", JSON.toJSONString(progressTasks));
|
//log.info("原progressTasks:{}", JSON.toJSONString(progressTasks));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user