|
|
@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.easy.admin.auth.model.SysUser; |
|
|
|
import com.easy.admin.common.core.exception.EasyException; |
|
|
|
import com.easy.admin.modules.huzhou.vo.HuzhouProjectinfoOV; |
|
|
|
import com.easy.admin.util.ShiroUtil; |
|
|
|
import org.activiti.engine.RuntimeService; |
|
|
|
import org.activiti.engine.runtime.ProcessInstance; |
|
|
@ -40,108 +41,80 @@ import java.util.*; |
|
|
|
public class HuzhouPlanController { |
|
|
|
@Autowired |
|
|
|
private IHuzhouPlaninfoService planinfoService; |
|
|
|
@Autowired |
|
|
|
private IWorkflowService workflowService; |
|
|
|
@Autowired |
|
|
|
private IHuzhouProcessinfoService processinfoService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IHuzhouProjectinfoService projectinfoService; |
|
|
|
@Autowired |
|
|
|
private IHuzhouPlaninfoHistoryService planinfoHistoryService; |
|
|
|
@Autowired |
|
|
|
private RuntimeService runtimeService; |
|
|
|
|
|
|
|
@Value(value = "${jeecg.path.upload}") |
|
|
|
private String uploadpath; |
|
|
|
/** |
|
|
|
* 项目计划列表信息 |
|
|
|
* @param projectinfo 查询条件 |
|
|
|
* @param pageNo 页码 |
|
|
|
* @param pageSize 每页条数 |
|
|
|
* @return 返回值 |
|
|
|
*/ |
|
|
|
@GetMapping("/projectPlanPageList") |
|
|
|
public Result<IPage<HuzhouProjectinfoOV>> projectPlanPageList(HuzhouProjectinfo projectinfo, |
|
|
|
@RequestParam(name="current", defaultValue="1") Integer pageNo, |
|
|
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize){ |
|
|
|
IPage<HuzhouProjectinfoOV> infoPageList =planinfoService.projectPlanPageList(projectinfo, pageNo, pageSize); |
|
|
|
return Result.OK(infoPageList); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 上传计划信息 |
|
|
|
* @param multipartFile |
|
|
|
* @param projectid |
|
|
|
* @return |
|
|
|
* 上传计划信息(创建审批流程) |
|
|
|
* @param multipartFile 模板文件 |
|
|
|
* @param projectid 项目id |
|
|
|
* @return 返回值 |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
@PostMapping("/submitplaninfoUploadFile") |
|
|
|
public Result<?> submitPlaninfoUploadFile(@RequestParam(value = "file",required = false) MultipartFile multipartFile, |
|
|
|
@RequestParam String projectid) throws Exception { |
|
|
|
HashMap<String, Object> hashMap = planinfoService.getPlanInfoListFromFile(multipartFile, projectid); |
|
|
|
boolean res = (boolean) hashMap.get("res"); |
|
|
|
if(!res){ |
|
|
|
throw new EasyException((String)hashMap.get("msg")); |
|
|
|
} |
|
|
|
ArrayList<HuzhouPlaninfo> huzhouPlaninfoArrayList = (ArrayList<HuzhouPlaninfo>) hashMap.get("arr"); |
|
|
|
|
|
|
|
planinfoService.saveBatch(huzhouPlaninfoArrayList); |
|
|
|
|
|
|
|
WorkFlow workFlow = workflowService.createFlow("createPlaninfo",projectid); |
|
|
|
projectinfoService.modifyStageById(projectid,"4"); |
|
|
|
planinfoService.submitPlaninfoUploadFile(multipartFile,projectid); |
|
|
|
return Result.ok("成功"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 审批项目计划 |
|
|
|
* @param file 重新提交要啊传文件 |
|
|
|
* @param taskId 流程任务id |
|
|
|
* @param flag 审批标志 |
|
|
|
* @param projectid 项目id |
|
|
|
* @param comment 审批意见 |
|
|
|
* @return 返回值 |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
@PostMapping("/approvePlaninfo") |
|
|
|
public Result<?> approvePlaninfo(@RequestParam(value = "file",required = false) MultipartFile file, |
|
|
|
@RequestParam String taskId, |
|
|
|
@RequestParam String flag, |
|
|
|
@RequestParam String projectid, |
|
|
|
@RequestParam String comment) throws Exception { |
|
|
|
SysUser currentUser = ShiroUtil.getCurrentUser(); |
|
|
|
String userId = currentUser.getId(); |
|
|
|
if(file!=null&&"1".equals(flag)){ |
|
|
|
|
|
|
|
//发生了修改
|
|
|
|
HashMap<String, Object> hashMap = planinfoService.getPlanInfoListFromFile(file, projectid); |
|
|
|
boolean res = (boolean) hashMap.get("res"); |
|
|
|
if(!res){ |
|
|
|
throw new EasyException((String)hashMap.get("msg")); |
|
|
|
} |
|
|
|
ArrayList<HuzhouPlaninfo> huzhouPlaninfoArrayList = (ArrayList<HuzhouPlaninfo>) hashMap.get("arr"); |
|
|
|
String isAllow = planinfoService.IsAllowModifyPlaninfo(projectid,huzhouPlaninfoArrayList); |
|
|
|
if(!"1".equals(isAllow)){ |
|
|
|
throw new EasyException(isAllow); |
|
|
|
} |
|
|
|
//保存历史记录
|
|
|
|
planinfoHistoryService.savePlanInfoToHistory(projectid); |
|
|
|
//删除原纪录
|
|
|
|
planinfoService.removeByProjectId(projectid); |
|
|
|
planinfoService.saveBatch(huzhouPlaninfoArrayList); |
|
|
|
} |
|
|
|
WorkFlow workFlow = workflowService.approveProjectInfo(taskId, flag, comment); |
|
|
|
if("3".equals(flag)){ |
|
|
|
projectinfoService.modifyStageById(projectid,"0"); |
|
|
|
processinfoService.modifyStatusByProjectId(projectid,"0","createPlaninfo"); |
|
|
|
return Result.ok("作废成功!"); |
|
|
|
} |
|
|
|
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(workFlow.getProcessInstanceId()).singleResult(); |
|
|
|
if(processInstance==null&&"1".equals(flag)){ |
|
|
|
projectinfoService.modifyStageById(projectid,"5"); |
|
|
|
processinfoService.modifyStatusByProjectId(projectid,"2","createPlaninfo"); |
|
|
|
} |
|
|
|
planinfoService.approvePlaninfo(file,taskId,flag,projectid,comment); |
|
|
|
return Result.ok("审批成功"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改项目计划 |
|
|
|
* @param multipartFile 需要解析的文件 |
|
|
|
* @param projectid 项目id |
|
|
|
* @return 返回值 |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
@PostMapping("/modifyPlaninfo") |
|
|
|
public Result<?> modifyPlaninfo(@RequestParam(value = "file",required = false) MultipartFile multipartFile, |
|
|
|
@RequestParam String projectid) throws Exception { |
|
|
|
HashMap<String, Object> hashMap = planinfoService.getPlanInfoListFromFile(multipartFile, projectid); |
|
|
|
boolean res = (boolean) hashMap.get("res"); |
|
|
|
if(!res){ |
|
|
|
throw new EasyException((String)hashMap.get("msg")); |
|
|
|
} |
|
|
|
ArrayList<HuzhouPlaninfo> huzhouPlaninfoArrayList = (ArrayList<HuzhouPlaninfo>) hashMap.get("arr"); |
|
|
|
String isAllow = planinfoService.IsAllowModifyPlaninfo(projectid,huzhouPlaninfoArrayList); |
|
|
|
if(!"1".equals(isAllow)){ |
|
|
|
throw new EasyException(isAllow); |
|
|
|
} |
|
|
|
WorkFlow workFlow = workflowService.createFlow("createPlaninfo",projectid); |
|
|
|
projectinfoService.modifyStageById(projectid,"4"); |
|
|
|
planinfoHistoryService.savePlanInfoToHistory(projectid); |
|
|
|
planinfoService.removeByProjectId(projectid); |
|
|
|
LambdaUpdateWrapper<HuzhouPlaninfo> wrapper = new LambdaUpdateWrapper<>(); |
|
|
|
wrapper.eq(HuzhouPlaninfo::getProjectId,projectid); |
|
|
|
wrapper.set(HuzhouPlaninfo::getGroupId,huzhouPlaninfoArrayList.get(0).getGroupId()); |
|
|
|
planinfoService.update(null,wrapper); |
|
|
|
planinfoService.saveBatch(huzhouPlaninfoArrayList); |
|
|
|
planinfoService.modifyPlaninfo(multipartFile,projectid); |
|
|
|
|
|
|
|
return Result.ok("修改计划成功"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取项目计划的树形结构List |
|
|
|
* @param projectid 项目id |
|
|
|
* @param isArchive 是否已归档 |
|
|
|
* @param pageNo 页码 |
|
|
|
* @param pageSize 页数 |
|
|
|
* @return 返回值 |
|
|
|
*/ |
|
|
|
@GetMapping("/queryPlanInfoMainTimeline") |
|
|
|
public Result<?> queryPlanInfoMainTimeline(String projectid,String isArchive,@RequestParam(name="current", defaultValue="1") Integer pageNo, |
|
|
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize){ |
|
|
@ -152,6 +125,12 @@ public class HuzhouPlanController { |
|
|
|
ArrayList<HuzhouPlaninfoOV> planInfoMainTimelineList = planinfoService.getPlanInfoMainTimelineList(projectid); |
|
|
|
return Result.ok(planInfoMainTimelineList); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据计划id获取当前计划阶段的数据 |
|
|
|
* @param planinfoid 计划id |
|
|
|
* @return 返回值 |
|
|
|
*/ |
|
|
|
@GetMapping("/qetplaninfoByid") |
|
|
|
public Result<?> getplaninfoByid(String planinfoid){ |
|
|
|
HuzhouPlaninfo planinfo = planinfoService.getById(planinfoid); |
|
|
@ -159,6 +138,14 @@ public class HuzhouPlanController { |
|
|
|
huzhouPlaninfos.add(planinfo); |
|
|
|
return Result.OK(huzhouPlaninfos); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 项目计划汇总展示 |
|
|
|
* @param projectinfo 项目计划信息 |
|
|
|
* @param pageNo 页码 |
|
|
|
* @param pageSize 页数 |
|
|
|
* @return 返回值 |
|
|
|
*/ |
|
|
|
@GetMapping("/getplanSummary") |
|
|
|
public Result<?> getplanSummary(HuzhouProjectinfo projectinfo, |
|
|
|
@RequestParam(name="current", defaultValue="1") Integer pageNo, |
|
|
@ -166,57 +153,15 @@ public class HuzhouPlanController { |
|
|
|
Page<Map> mapPage = planinfoService.getplanSummary(projectinfo, pageNo, pageSize); |
|
|
|
return Result.OK(mapPage); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据项目id下载项目计划内容 |
|
|
|
* @param response 返回内容 |
|
|
|
* @param projectid 项目id |
|
|
|
*/ |
|
|
|
@GetMapping("/downloadPlanInfo") |
|
|
|
public void downloadPlanInfo(HttpServletResponse response, String projectid){ |
|
|
|
LambdaQueryWrapper<HuzhouPlaninfo> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
queryWrapper.eq(HuzhouPlaninfo::getProjectId,projectid); |
|
|
|
List<HuzhouPlaninfo> list = planinfoService.list(queryWrapper); |
|
|
|
try (Workbook workbook = new XSSFWorkbook()) { |
|
|
|
Sheet sheet = workbook.createSheet("项目计划内容"); |
|
|
|
Row headerRow0 = sheet.createRow(0); |
|
|
|
headerRow0.createCell(0).setCellValue("taskLevel"); |
|
|
|
headerRow0.createCell(1).setCellValue("taskName"); |
|
|
|
headerRow0.createCell(2).setCellValue("scheduledStartTime"); |
|
|
|
headerRow0.createCell(3).setCellValue("scheduledEndTime"); |
|
|
|
headerRow0.createCell(4).setCellValue("taskFile"); |
|
|
|
headerRow0.setZeroHeight(true);//隐藏当前行
|
|
|
|
// 创建标题行
|
|
|
|
Row headerRow1 = sheet.createRow(1); |
|
|
|
headerRow1.createCell(0).setCellValue("阶段序号"); |
|
|
|
headerRow1.createCell(1).setCellValue("阶段名称"); |
|
|
|
headerRow1.createCell(2).setCellValue("开始时间"); |
|
|
|
headerRow1.createCell(3).setCellValue("结束时间"); |
|
|
|
headerRow1.createCell(4).setCellValue("所需文件"); |
|
|
|
CellStyle dateCellStyle = workbook.createCellStyle(); |
|
|
|
CreationHelper createHelper = workbook.getCreationHelper(); |
|
|
|
dateCellStyle.setDataFormat(createHelper.createDataFormat().getFormat("yyyy-MM-dd")); |
|
|
|
// 填充数据行
|
|
|
|
int rowNum = 2; |
|
|
|
for (HuzhouPlaninfo planinfo : list) { |
|
|
|
Row row = sheet.createRow(rowNum++); |
|
|
|
row.createCell(0).setCellValue(planinfo.getTaskLevel()); |
|
|
|
row.createCell(1).setCellValue(planinfo.getTaskName()); |
|
|
|
Cell cell2 = row.createCell(2); |
|
|
|
cell2.setCellValue(planinfo.getScheduledStartTime()); |
|
|
|
cell2.setCellStyle(dateCellStyle); |
|
|
|
Cell cell3 = row.createCell(3); |
|
|
|
cell3.setCellValue(planinfo.getScheduledEndTime()); |
|
|
|
cell3.setCellStyle(dateCellStyle); |
|
|
|
row.createCell(4).setCellValue(planinfo.getTaskFile()); |
|
|
|
} |
|
|
|
// 自动调整列宽以适应内容
|
|
|
|
for (int i = 0; i < 5; i++) { |
|
|
|
sheet.autoSizeColumn(i); // 使用Apache POI的autoSizeColumn方法
|
|
|
|
} |
|
|
|
// 设置响应头
|
|
|
|
response.setCharacterEncoding("utf-8"); |
|
|
|
response.setContentType("application/octet-stream"); |
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=项目计划.xlsx"); |
|
|
|
// 将Excel内容写入响应
|
|
|
|
workbook.write(response.getOutputStream()); |
|
|
|
} catch (IOException e) { |
|
|
|
throw new RuntimeException("导出失败!"); |
|
|
|
} |
|
|
|
// planinfoService.downloadPlanInfo(response,projectinfoid);
|
|
|
|
planinfoService.downloadPlanInfo(response,projectid); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|