|
@@ -1,23 +1,27 @@
|
|
|
package com.ruoyi.project.production.controller;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
-import com.ruoyi.common.utils.StringUtils;
|
|
|
+import com.ruoyi.common.utils.file.ExcelUtils;
|
|
|
+import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
+import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
|
|
+import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
|
|
import com.ruoyi.framework.interceptor.annotation.RepeatSubmit;
|
|
|
-import com.ruoyi.project.apply.domain.TApplyLock;
|
|
|
-import com.ruoyi.project.apply.domain.TApplyOfflinevalve;
|
|
|
-import com.ruoyi.project.apply.domain.TApplySafetychange;
|
|
|
+import com.ruoyi.framework.web.controller.BaseController;
|
|
|
+import com.ruoyi.framework.web.domain.AjaxResult;
|
|
|
+import com.ruoyi.framework.web.page.TableDataInfo;
|
|
|
import com.ruoyi.project.approve.damain.DevTask;
|
|
|
-import com.ruoyi.project.listener.apply.change.ChangeEndFailListener;
|
|
|
-import com.ruoyi.project.listener.apply.change.ChangeEndSuccessListener;
|
|
|
-import com.ruoyi.project.listener.apply.change.ChangeFlowListener;
|
|
|
-import com.ruoyi.project.listener.apply.change.ChangeNextTaskListener;
|
|
|
-import com.ruoyi.project.plant.domain.TStaffmgr;
|
|
|
+import com.ruoyi.project.process.domain.TMoc;
|
|
|
+import com.ruoyi.project.production.controller.vo.SaiApplyExportVO;
|
|
|
+import com.ruoyi.project.production.domain.TSaiApply;
|
|
|
+import com.ruoyi.project.production.service.ITSaiApplyService;
|
|
|
+import com.ruoyi.project.system.domain.SysDept;
|
|
|
+import com.ruoyi.project.system.domain.SysDictData;
|
|
|
import com.ruoyi.project.system.domain.SysUser;
|
|
|
+import com.ruoyi.project.system.mapper.SysDeptMapper;
|
|
|
+import com.ruoyi.project.system.mapper.SysUserMapper;
|
|
|
+import com.ruoyi.project.system.service.ISysDeptService;
|
|
|
+import com.ruoyi.project.system.service.ISysDictTypeService;
|
|
|
import com.ruoyi.project.system.service.ISysUserService;
|
|
|
import org.activiti.engine.ProcessEngine;
|
|
|
import org.activiti.engine.ProcessEngines;
|
|
@@ -26,25 +30,18 @@ import org.activiti.engine.TaskService;
|
|
|
import org.activiti.engine.impl.identity.Authentication;
|
|
|
import org.activiti.engine.runtime.ProcessInstance;
|
|
|
import org.activiti.engine.task.Task;
|
|
|
-import org.activiti.engine.task.TaskQuery;
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.apache.poi.ss.usermodel.Cell;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.PutMapping;
|
|
|
-import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
|
|
-import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
|
|
-import com.ruoyi.project.production.domain.TSaiApply;
|
|
|
-import com.ruoyi.project.production.service.ITSaiApplyService;
|
|
|
-import com.ruoyi.framework.web.controller.BaseController;
|
|
|
-import com.ruoyi.framework.web.domain.AjaxResult;
|
|
|
-import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
-import com.ruoyi.framework.web.page.TableDataInfo;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* SAI开项管理Controller
|
|
@@ -65,9 +62,15 @@ public class TSaiApplyController extends BaseController
|
|
|
@Autowired
|
|
|
private ISysUserService userService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysDeptService deptService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private TaskService taskService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysDictTypeService iSysDictTypeService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询SAI开项管理列表
|
|
|
*/
|
|
@@ -80,6 +83,140 @@ public class TSaiApplyController extends BaseController
|
|
|
return getDataTable(list);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 批量导入SAI开项管理列表
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('production:apply:add')")
|
|
|
+ @PostMapping("/importData")
|
|
|
+ public AjaxResult importData(@RequestParam("file") MultipartFile file) throws IOException
|
|
|
+ {
|
|
|
+ //获取操作人员ID
|
|
|
+ Long userId = getUserId();
|
|
|
+ //报错行数统计
|
|
|
+ List<Integer> failRow =new ArrayList<Integer>();
|
|
|
+ Workbook workbook = ExcelUtils.getWorkBook(file);
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ List<TSaiApply> list = new ArrayList<TSaiApply>();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ // 字典查询
|
|
|
+ List<SysDictData> saiApplyStatusDict = iSysDictTypeService.selectDictDataByType("SAI_APPLY_STATUS");
|
|
|
+ List<SysDictData> teamDivideDict = iSysDictTypeService.selectDictDataByType("TEAM_DIVIDE");
|
|
|
+ // 部门列表
|
|
|
+ List<SysDept> deptList = deptService.selectDeptList(new SysDept());
|
|
|
+ // 用户列表
|
|
|
+ List<SysUser> userList = userService.selectUserList(new SysUser());
|
|
|
+ int rowNum = sheet.getPhysicalNumberOfRows();
|
|
|
+ int failNumber = 0;
|
|
|
+ for (int i = 2; i <= rowNum; i++) {
|
|
|
+ try {
|
|
|
+ logger.info("读取行数:" + i);
|
|
|
+ Row row = sheet.getRow(i);
|
|
|
+ int cellNum = row.getPhysicalNumberOfCells();
|
|
|
+ TSaiApply entity = new TSaiApply();
|
|
|
+ entity.setCreateTime(new Date());
|
|
|
+ entity.setCreateBy(userId.toString());
|
|
|
+ entity.setDeptId(103L);
|
|
|
+ for (int j = 0; j < cellNum; j++) {
|
|
|
+ Cell cell = row.getCell(j);
|
|
|
+ // cell.setCellType(CellType.STRING);
|
|
|
+ String cellValue = ExcelUtils.getCellValue(cell);
|
|
|
+ String applicantName = "";
|
|
|
+ String handlerName = "";
|
|
|
+ String executorName = "";
|
|
|
+ logger.info("cellValue:" + cellValue);
|
|
|
+ if (j == 0) {
|
|
|
+ entity.setDescription(cellValue);
|
|
|
+ } else if (j == 1) {
|
|
|
+ for (SysDictData sysDictData : saiApplyStatusDict) {
|
|
|
+ if (sysDictData.getDictLabel().equals(cellValue.trim())) {
|
|
|
+ entity.setApplyStatus(Long.valueOf(sysDictData.getDictValue()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (j == 2) {
|
|
|
+ if (cellValue != "" && cellValue != null) {
|
|
|
+ for (SysDept sysDept : deptList) {
|
|
|
+ if (cellValue.equals(sysDept.getDeptName())) {
|
|
|
+ entity.setApplicantDept(sysDept.getDeptId().toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (j == 3) {
|
|
|
+ for (SysDictData sysDictData : teamDivideDict) {
|
|
|
+ if (sysDictData.getDictLabel().equals(cellValue.trim())) {
|
|
|
+ entity.setApplicantTeam(sysDictData.getDictValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (j == 4) {
|
|
|
+ applicantName = cellValue;
|
|
|
+ } else if (j == 5) {
|
|
|
+ handlerName = cellValue;
|
|
|
+ } else if (j == 6) {
|
|
|
+ executorName = cellValue;
|
|
|
+ } else if (j == 7) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setApplyDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ } else if (j == 8) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setEstimateFinishDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ } else if (j == 9) {
|
|
|
+ if (cellValue.length() > 3) {
|
|
|
+ entity.setActualFinishDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
|
|
|
+ }
|
|
|
+ } else if (j == 10) {
|
|
|
+ if (cellValue != "" && cellValue != null) {
|
|
|
+ entity.setIsRecorded(cellValue == "是" ? 1L : 0L);
|
|
|
+ }
|
|
|
+ } else if (j == 11) {
|
|
|
+ entity.setRecordNo(cellValue);
|
|
|
+ }
|
|
|
+ for (SysUser sysUser : userList) {
|
|
|
+ if (applicantName != "" && applicantName != null) {
|
|
|
+ if (applicantName.equals(sysUser.getNickName())) {
|
|
|
+ entity.setApplicant(sysUser.getUserId().toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (handlerName != "" && handlerName != null) {
|
|
|
+ if (handlerName.equals(sysUser.getNickName())) {
|
|
|
+ entity.setHandler(sysUser.getUserId().toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (executorName != "" && executorName != null) {
|
|
|
+ if (executorName.equals(sysUser.getNickName())) {
|
|
|
+ entity.setExecutor(sysUser.getUserId().toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logger.info("entity:" + entity);
|
|
|
+ list.add(entity);
|
|
|
+ }catch (Exception e){
|
|
|
+ failNumber++;
|
|
|
+ failRow.add(i+1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int successNumber = 0;
|
|
|
+ int failNum = 0;
|
|
|
+ for (TSaiApply t : list
|
|
|
+ ) {
|
|
|
+ failNum++;
|
|
|
+ try {
|
|
|
+ tSaiApplyService.insertTSaiApply(t);
|
|
|
+ successNumber++;
|
|
|
+ }catch (Exception e){
|
|
|
+ failNumber++;
|
|
|
+ logger.info("e:" + e);
|
|
|
+ failRow.add(failNum+1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logger.info("list:" + JSON.toJSONString(list));
|
|
|
+ logger.info("successNumber:" +String.valueOf(successNumber));
|
|
|
+ logger.info("failNumber:" +String.valueOf(failNumber));
|
|
|
+ logger.info("failRow:" +String.valueOf(failRow));
|
|
|
+ return AjaxResult.success(String.valueOf(successNumber), failRow);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 导出SAI开项管理列表
|
|
|
*/
|
|
@@ -88,9 +225,43 @@ public class TSaiApplyController extends BaseController
|
|
|
@GetMapping("/export")
|
|
|
public AjaxResult export(TSaiApply tSaiApply)
|
|
|
{
|
|
|
+ // 实体类集合
|
|
|
List<TSaiApply> list = tSaiApplyService.selectTSaiApplyList(tSaiApply);
|
|
|
- ExcelUtil<TSaiApply> util = new ExcelUtil<TSaiApply>(TSaiApply.class);
|
|
|
- return util.exportExcel(list, "apply");
|
|
|
+ // 导出VO集合
|
|
|
+ List<SaiApplyExportVO> exportVOList = new ArrayList<>();
|
|
|
+ // 字典查询
|
|
|
+ List<SysDictData> saiApplyStatusDict = iSysDictTypeService.selectDictDataByType("SAI_APPLY_STATUS");
|
|
|
+ List<SysDictData> teamDivideDict = iSysDictTypeService.selectDictDataByType("TEAM_DIVIDE");
|
|
|
+ for (TSaiApply entity : list) {
|
|
|
+ // 复制属性
|
|
|
+ SaiApplyExportVO vo = new SaiApplyExportVO();
|
|
|
+ vo.setDescription(entity.getDescription());
|
|
|
+ for (SysDictData sysDictData : saiApplyStatusDict) {
|
|
|
+ if (sysDictData.getDictValue().equals(entity.getApplyStatus() + "")) {
|
|
|
+ vo.setApplyStatus(sysDictData.getDictLabel());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ vo.setApplicantDept(entity.getApplicantDeptName());
|
|
|
+ for (SysDictData sysDictData : teamDivideDict) {
|
|
|
+ if (sysDictData.getDictValue().equals(entity.getApplicantTeam())) {
|
|
|
+ vo.setApplicantTeam(sysDictData.getDictLabel());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ vo.setApplicant(entity.getApplicantName());
|
|
|
+ vo.setHandler(entity.getHandlerName());
|
|
|
+ vo.setExecutor(entity.getExecutorName());
|
|
|
+ vo.setApplyDate(entity.getApplyDate());
|
|
|
+ vo.setEstimateFinishDate(entity.getEstimateFinishDate());
|
|
|
+ vo.setActualFinishDate(entity.getActualFinishDate());
|
|
|
+ Long isRecorded = entity.getIsRecorded();
|
|
|
+ if (isRecorded != null) {
|
|
|
+ vo.setIsRecorded(isRecorded == 1L ? "是" : "否");
|
|
|
+ }
|
|
|
+ vo.setRecordNo(entity.getRecordNo());
|
|
|
+ exportVOList.add(vo);
|
|
|
+ }
|
|
|
+ ExcelUtil<SaiApplyExportVO> util = new ExcelUtil<SaiApplyExportVO>(SaiApplyExportVO.class);
|
|
|
+ return util.exportExcel(exportVOList, "SAI开项管理数据");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -230,6 +401,7 @@ public class TSaiApplyController extends BaseController
|
|
|
case "验收":
|
|
|
if ("1".equals(condition)) {
|
|
|
form.setApplyStatus(4);
|
|
|
+ form.setActualFinishDate(new Date());
|
|
|
form.setTaskId(null);
|
|
|
form.setTaskName(null);
|
|
|
nextHandler = null;
|