| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.poi.ss.usermodel.*; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.api.dto.message.MessageDTO; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.system.api.ISysBaseAPI; |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import org.jeecg.modules.eam.entity.DailyInspectionStandard; |
| | | import org.jeecg.modules.eam.entity.DailyInspectionStandardDetail; |
| | | import org.jeecg.modules.eam.service.IDailyInspectionStandardDetailService; |
| | | import org.jeecg.modules.eam.service.IDailyInspectionStandardService; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentService; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.common.util.ImportExcelUtil; |
| | | import org.jeecg.modules.eam.entity.*; |
| | | import org.jeecg.modules.eam.service.*; |
| | | import org.jeecg.modules.eam.vo.InspectionStandardImportVo; |
| | | import org.jeecg.modules.system.entity.*; |
| | | import org.jeecg.modules.system.service.*; |
| | | import org.jeecgframework.poi.excel.entity.ImportParams; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.springframework.web.multipart.MultipartHttpServletRequest; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.math.BigDecimal; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @Description: mom_eam_inspection_project |
| | |
| | | |
| | | @Autowired |
| | | private IDailyInspectionStandardDetailService dailyInspectionStandardDetailService; |
| | | |
| | | @Autowired |
| | | private IdentityService identityService; |
| | | |
| | | @Autowired |
| | | private IInspectionProjectService inspectionProjectService; |
| | | |
| | | @Autowired |
| | | private IInspectionCycleService inspectionCycleService; |
| | | |
| | | @Autowired |
| | | private ISysBaseAPI sysBaseApi; |
| | | @Autowired |
| | | private ISysUserService sysUserService; |
| | | @Resource |
| | | private ISysRoleService sysRoleService; |
| | | @Resource |
| | | private ISysDictService sysDictService; |
| | | @Resource |
| | | private ISysDictItemService sysDictItemService; |
| | | @Resource |
| | | private ISysUserRoleService sysUserRoleService; |
| | | /** |
| | | * 分页列表查询 |
| | | * |
| | |
| | | */ |
| | | @GetMapping("findInspectionStandardList") |
| | | public Result<?> findInspectionStandardList(@RequestParam("pageNo") Integer pageNo, |
| | | @RequestParam("pageSize") Integer pageSize, |
| | | @RequestParam Map<String, Object> params) { |
| | | @RequestParam("pageSize") Integer pageSize, |
| | | @RequestParam Map<String, Object> params) { |
| | | IPage<Map<String, Object>> inspectionStandardList = dailyInspectionStandardService.findInspectionStandardList(pageNo, pageSize, params); |
| | | return Result.ok(inspectionStandardList); |
| | | } |
| | |
| | | @PostMapping(value = "/add") |
| | | @Transactional(rollbackFor = { Exception.class }) |
| | | public Result<String> add(@RequestBody DailyInspectionStandard dailyInspectionStandard) { |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | dailyInspectionStandard.setWritePerson(sysUser.getRealname()); |
| | | dailyInspectionStandard.setAssignMode("1"); |
| | | dailyInspectionStandardService.save(dailyInspectionStandard); |
| | | List<DailyInspectionStandardDetail> dailyInspectionStandardDetaillist = dailyInspectionStandard.getDailyInspectionStandardDetaillist(); |
| | | DailyInspectionStandardDetail isd = null; |
| | |
| | | isd.setInspectionCycleId(dailyInspectionStandardDetail.getInspectionCycleId()); |
| | | dailyInspectionStandardDetailService.save(isd); |
| | | } |
| | | //消息提醒 |
| | | this.inspectionStandardAlert(dailyInspectionStandard.getApprovalStatus(),dailyInspectionStandard.getNum()); |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | |
| | |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) |
| | | @Transactional(rollbackFor = { Exception.class }) |
| | | public Result<String> edit(@RequestBody DailyInspectionStandard dailyInspectionStandard) { |
| | | dailyInspectionStandard.setApprovalStatus("1"); |
| | | dailyInspectionStandardService.updateById(dailyInspectionStandard); |
| | | //1.删除原点检项目 |
| | | List<DailyInspectionStandardDetail> dailyInspectionStandardDetails = dailyInspectionStandardDetailService.lambdaQuery() |
| | |
| | | isd.setInspectionCycleId(dailyInspectionStandardDetail.getInspectionCycleId()); |
| | | dailyInspectionStandardDetailService.save(isd); |
| | | } |
| | | //消息提醒 |
| | | this.inspectionStandardAlert(dailyInspectionStandard.getApprovalStatus(),dailyInspectionStandard.getNum()); |
| | | return Result.OK("编辑成功!"); |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | return super.importExcel(request, response, DailyInspectionStandard.class); |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) throws IOException { |
| | | MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; |
| | | LoginUser user= (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); |
| | | // 错误信息 |
| | | List<String> errorMessage = new ArrayList<>(); |
| | | int successLines = 0, errorLines = 0; |
| | | //a = 1开始读取点检项目;b = 1开始读取周保养项目;c = 1该设备导入信息存在错误;projectColumnIndex点检项目所在列;maintenanceColumnIndex周保养项目所在列 |
| | | int a = 0,b = 0,c = 0,projectColumnIndex = -1,maintenanceColumnIndex = 0; |
| | | //表头标题 |
| | | String title = ""; |
| | | String dailyInspectionStandardId = null; |
| | | String equipmentNum = null; |
| | | DailyInspectionStandard dailyInspectionStandard = null; |
| | | List<DailyInspectionStandardDetail> dailyInspectionStandardDetailList = new ArrayList<>(); |
| | | for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { |
| | | MultipartFile file = entity.getValue(); |
| | | ImportParams params = new ImportParams(); |
| | | params.setNeedSave(true); |
| | | try { |
| | | InputStream fis = file.getInputStream(); |
| | | Workbook workbook = new XSSFWorkbook(fis); |
| | | int sheets = workbook.getNumberOfSheets(); |
| | | //判断点检周期是否存在 |
| | | InspectionCycle dayInspectionCycle = inspectionCycleService.lambdaQuery().eq(InspectionCycle::getName,"1日").eq(InspectionCycle::getVersionStatus,"2").one(); |
| | | InspectionCycle weekInspectionCycle = inspectionCycleService.lambdaQuery().eq(InspectionCycle::getName,"1周").eq(InspectionCycle::getVersionStatus,"2").one(); |
| | | if(dayInspectionCycle == null || weekInspectionCycle == null){ |
| | | c = 1; |
| | | errorMessage.add("点检周期不存在,请先维护点检周期"); |
| | | errorLines++; |
| | | }else{ |
| | | for(int i = 0;i < sheets;i++){ |
| | | Sheet sheet = workbook.getSheetAt(i); |
| | | for (Row row : sheet) { |
| | | // 遍历每一个单元格 |
| | | // for (Cell cell : row) { |
| | | for(int j = 0;j < 5;j++){ |
| | | // 处理单元格数据,例如输出单元格的值 |
| | | Cell cell = row.getCell(j); |
| | | // if("STRING".equals(cell.getCellType().toString())|| "BLANK".equals(cell.getCellType().toString())){ |
| | | if("STRING".equals(cell.getCellType().toString())|| "BLANK".equals(cell.getCellType().toString())){ |
| | | //点检周期存在,判断设备统一编码是否存在 |
| | | String strCell = cell.getStringCellValue(); |
| | | if(strCell.contains("生产设备自主维护点检表")){ |
| | | title = strCell.trim().substring(11).trim(); |
| | | } |
| | | if(strCell.contains("设备名称:")){ |
| | | String[] tybh1 = strCell.split("统一编号:"); |
| | | String[] tybh2 = tybh1[1].split("年"); |
| | | // equipmentNum = tybh2[0].trim().substring(0,tybh2[0].trim().length()-4).trim(); |
| | | equipmentNum = tybh2[0].trim(); |
| | | /*String year = tybh2[0].trim().substring(tybh2[0].trim().length()-4,tybh2[0].trim().length()).trim(); |
| | | String[] month1 = tybh2[1].split("月"); |
| | | String month = month1[0].trim(); |
| | | String[] unit1 = strCell.split("单位:"); |
| | | String unit = unit1[1].trim();*/ |
| | | Equipment equipment = equipmentService.lambdaQuery().eq(Equipment::getNum,equipmentNum).eq(Equipment::getDelFlag, CommonConstant.DEL_FLAG_0).one(); |
| | | if(equipment == null){ |
| | | c = 1; |
| | | errorMessage.add("sheet页为"+sheet.getSheetName()+",设备统一编码为"+ equipmentNum + "的数据导入失败,原因:设备不存在,请先维护设备台账!"); |
| | | errorLines++; |
| | | }else { |
| | | List<DailyInspectionStandard> dailyInspectionStandardList = dailyInspectionStandardService.lambdaQuery().eq(DailyInspectionStandard::getEquipmentId,equipment.getId()) |
| | | .eq(DailyInspectionStandard::getVersionStatus,"2").eq(DailyInspectionStandard::getDelFlag,CommonConstant.DEL_FLAG_0).list(); |
| | | if(CollectionUtils.isNotEmpty(dailyInspectionStandardList)){ |
| | | c = 1; |
| | | errorMessage.add("sheet页为"+sheet.getSheetName()+",设备统一编码为"+ equipmentNum + "的数据导入失败,原因:该设备已经存在点检标准!"); |
| | | errorLines++; |
| | | }else { |
| | | c = 0; |
| | | String num = identityService.getNumByTypeAndLength("DailylnspectionStandard", 4); |
| | | dailyInspectionStandard = new DailyInspectionStandard(); |
| | | dailyInspectionStandard.setNum(num); |
| | | dailyInspectionStandard.setVersionStatus("2"); |
| | | dailyInspectionStandard.setVersion("1.0"); |
| | | dailyInspectionStandard.setAssignMode("1"); |
| | | dailyInspectionStandard.setEquipmentId(equipment.getId()); |
| | | dailyInspectionStandard.setApprovalStatus("5"); |
| | | dailyInspectionStandard.setDisUda1(title); |
| | | //dailyInspectionStandardService.save(dailyInspectionStandard); |
| | | //dailyInspectionStandardId = dailyInspectionStandard.getId(); |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | //设备统一编码存在,判断点检项目是否存在 |
| | | if(c == 0){ |
| | | System.out.print(strCell + "\t"); |
| | | if(strCell.contains("点检项目")){ |
| | | a = 1; |
| | | projectColumnIndex = cell.getColumnIndex(); |
| | | break; |
| | | } |
| | | if(strCell.contains("维护责任人签字")){ |
| | | a = 0; |
| | | } |
| | | if(projectColumnIndex == cell.getColumnIndex() && a == 1){ |
| | | DailyInspectionStandardDetail dailyInspectionStandardDetail = new DailyInspectionStandardDetail(); |
| | | dailyInspectionStandardDetail.setDailyInspectionStandardId(dailyInspectionStandardId); |
| | | String dayInspectionProjectName = row.getCell(projectColumnIndex).toString(); |
| | | String standard = row.getCell(projectColumnIndex+3).toString(); |
| | | //查询点检项目,如果没有新增点检项目 |
| | | if(StringUtils.isNotBlank(dayInspectionProjectName)){ |
| | | List<InspectionProject> inspectionProjectList = inspectionProjectService.lambdaQuery().eq(InspectionProject::getName,dayInspectionProjectName) |
| | | .eq(InspectionProject::getDetectionStandard,standard).eq(InspectionProject::getDelFlag,CommonConstant.DEL_FLAG_0).list(); |
| | | if(CollectionUtils.isEmpty(inspectionProjectList)){ |
| | | InspectionProject inspectionProject = new InspectionProject(); |
| | | inspectionProject.setNum(identityService.getNumByTypeAndLength("InspectionProject",4)); |
| | | inspectionProject.setName(dayInspectionProjectName); |
| | | inspectionProject.setDetectionStandard(standard); |
| | | inspectionProjectService.save(inspectionProject); |
| | | dailyInspectionStandardDetail.setInspectionProjectId(inspectionProject.getId()); |
| | | dailyInspectionStandardDetail.setInspectionCycleId(dayInspectionCycle.getId()); |
| | | dailyInspectionStandardDetailList.add(dailyInspectionStandardDetail); |
| | | // c = 1; |
| | | // errorMessage.add("sheet页为"+sheet.getSheetName()+",设备统一编码为"+ equipmentNum + "的数据导入失败,原因:点检项目不存在,请先维护点检项目!"); |
| | | // errorLines++; |
| | | }else { |
| | | dailyInspectionStandardDetail.setInspectionProjectId(inspectionProjectList.get(0).getId()); |
| | | dailyInspectionStandardDetail.setInspectionCycleId(dayInspectionCycle.getId()); |
| | | dailyInspectionStandardDetailList.add(dailyInspectionStandardDetail); |
| | | //dailyInspectionStandardDetailService.save(dailyInspectionStandardDetail); |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | |
| | | if(strCell.contains("周保养项目")){ |
| | | b = 1; |
| | | maintenanceColumnIndex = cell.getColumnIndex(); |
| | | break; |
| | | } |
| | | if(strCell.contains("周保养操作者执行")){ |
| | | b = 0; |
| | | dailyInspectionStandardService.save(dailyInspectionStandard); |
| | | for(DailyInspectionStandardDetail dailyInspectionStandardDetail : dailyInspectionStandardDetailList){ |
| | | dailyInspectionStandardDetail.setDailyInspectionStandardId(dailyInspectionStandard.getId()); |
| | | } |
| | | dailyInspectionStandardDetailService.saveBatch(dailyInspectionStandardDetailList); |
| | | successLines++; |
| | | dailyInspectionStandard = null; |
| | | dailyInspectionStandardDetailList.clear(); |
| | | } |
| | | if(b == 1 && c == 0 && maintenanceColumnIndex == cell.getColumnIndex()){ |
| | | DailyInspectionStandardDetail dailyInspectionStandardDetail = new DailyInspectionStandardDetail(); |
| | | dailyInspectionStandardDetail.setDailyInspectionStandardId(dailyInspectionStandardId); |
| | | String weekInspectionProjectName = row.getCell(maintenanceColumnIndex).toString(); |
| | | String inspectionStandardName = row.getCell(maintenanceColumnIndex+3).toString(); |
| | | if(StringUtils.isNotBlank(weekInspectionProjectName)){ |
| | | List<InspectionProject> inspectionProjectList = inspectionProjectService.lambdaQuery().eq(InspectionProject::getName,weekInspectionProjectName) |
| | | .eq(InspectionProject::getDetectionStandard,inspectionStandardName).eq(InspectionProject::getDelFlag,CommonConstant.DEL_FLAG_0).list(); |
| | | if(CollectionUtils.isEmpty(inspectionProjectList)){ |
| | | InspectionProject inspectionProject = new InspectionProject(); |
| | | inspectionProject.setNum(identityService.getNumByTypeAndLength("InspectionProject",4)); |
| | | inspectionProject.setName(weekInspectionProjectName); |
| | | inspectionProject.setDetectionStandard(inspectionStandardName); |
| | | inspectionProjectService.save(inspectionProject); |
| | | dailyInspectionStandardDetail.setInspectionProjectId(inspectionProject.getId()); |
| | | dailyInspectionStandardDetail.setInspectionCycleId(weekInspectionCycle.getId()); |
| | | dailyInspectionStandardDetailList.add(dailyInspectionStandardDetail); |
| | | // c = 1; |
| | | // errorMessage.add("sheet页为"+sheet.getSheetName()+",行数为:"+row.getRowNum()+",设备统一编码为"+ equipmentNum + "的数据导入失败,原因:点检项目不存在,请先维护点检项目!"); |
| | | // errorLines++; |
| | | }else { |
| | | |
| | | dailyInspectionStandardDetail.setInspectionProjectId(inspectionProjectList.get(0).getId()); |
| | | dailyInspectionStandardDetail.setInspectionCycleId(weekInspectionCycle.getId()); |
| | | dailyInspectionStandardDetailList.add(dailyInspectionStandardDetail); |
| | | //dailyInspectionStandardDetailService.save(dailyInspectionStandardDetail); |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | }/*else if("NUMERIC".equals(cell.getCellType().toString())){ |
| | | System.out.print(cell.getNumericCellValue() + "\t"); |
| | | } |
| | | */ |
| | | } |
| | | System.out.println(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return ImportExcelUtil.imporReturnRes(errorLines, successLines, errorMessage); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @GetMapping("getDepartByEquipment") |
| | | public Result<?> getDepartByEquipment(@RequestParam("pageNo") Integer pageNo, |
| | | @RequestParam("pageSize") Integer pageSize, |
| | | @RequestParam Map<String, Object> params) { |
| | | @RequestParam("pageSize") Integer pageSize, |
| | | @RequestParam Map<String, Object> params) { |
| | | IPage<Map<String, Object>> departByEquipment = dailyInspectionStandardService.getDepartByEquipment(pageNo, pageSize, params); |
| | | return Result.ok(departByEquipment); |
| | | } |
| | |
| | | @PostMapping(value = "/revise") |
| | | @Transactional(rollbackFor = { Exception.class }) |
| | | public Result<String> revise(@RequestBody DailyInspectionStandard dailyInspectionStandard) { |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | dailyInspectionStandard.setWritePerson(sysUser.getRealname()); |
| | | dailyInspectionStandard.setId(""); |
| | | dailyInspectionStandard.setAssignMode("1"); |
| | | dailyInspectionStandard.setApprovalStatus("1"); |
| | | dailyInspectionStandard.setCreateTime(new Date()); |
| | | dailyInspectionStandard.setTakeEffectTime(null); |
| | | dailyInspectionStandard.setLoseEfficacyTime(null); |
| | | dailyInspectionStandard.setApprovalFeedback(null); |
| | | dailyInspectionStandard.setAuditFeedback(null); |
| | | dailyInspectionStandard.setAuditPerson(null); |
| | | dailyInspectionStandard.setApprovalPerson(null); |
| | | dailyInspectionStandardService.save(dailyInspectionStandard); |
| | | List<DailyInspectionStandardDetail> dailyInspectionStandardDetaillist = dailyInspectionStandard.getDailyInspectionStandardDetaillist(); |
| | | DailyInspectionStandardDetail isd = null; |
| | |
| | | @Transactional(rollbackFor = { Exception.class }) |
| | | public Result<String> versionTakeEffect(@RequestBody DailyInspectionStandard dailyInspectionStandard) { |
| | | |
| | | List<DailyInspectionStandard> dailyInspectionStandards = dailyInspectionStandardService.lambdaQuery() |
| | | .eq(DailyInspectionStandard::getNum, dailyInspectionStandard.getNum()) |
| | | .eq(DailyInspectionStandard::getVersionStatus, "2").list(); |
| | | for (DailyInspectionStandard standard : dailyInspectionStandards) { |
| | | standard.setVersionStatus("3"); |
| | | dailyInspectionStandardService.updateById(standard); |
| | | } |
| | | // List<DailyInspectionStandard> dailyInspectionStandards = dailyInspectionStandardService.lambdaQuery() |
| | | // .eq(DailyInspectionStandard::getNum, dailyInspectionStandard.getNum()) |
| | | // .eq(DailyInspectionStandard::getVersionStatus, "2").list(); |
| | | // for (DailyInspectionStandard standard : dailyInspectionStandards) { |
| | | // standard.setVersionStatus("3"); |
| | | // standard.setLoseEfficacyTime(new Date()); |
| | | // dailyInspectionStandardService.updateById(standard); |
| | | // } |
| | | // dailyInspectionStandard.setTakeEffectTime(new Date()); |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | dailyInspectionStandard.setLoseEfficacyPerson(sysUser.getRealname()); |
| | | dailyInspectionStandard.setLoseEfficacyTime(new Date()); |
| | | boolean b = dailyInspectionStandardService.updateById(dailyInspectionStandard); |
| | | if (b){ |
| | | return Result.OK("编辑成功!"); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 签审流程 |
| | | * qsw 2023-11-16 |
| | | */ |
| | | @RequestMapping(value = "/auditApproval", method = {RequestMethod.PUT,RequestMethod.POST}) |
| | | @Transactional(rollbackFor = { Exception.class }) |
| | | public Result<String> auditApproval(@RequestBody DailyInspectionStandard dailyInspectionStandard) { |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String approvalStatus = dailyInspectionStandard.getApprovalStatus(); |
| | | if("5".equals(approvalStatus)){//审核通过后,版本生效 |
| | | List<DailyInspectionStandard> dailyInspectionStandards = dailyInspectionStandardService.lambdaQuery() |
| | | .eq(DailyInspectionStandard::getNum, dailyInspectionStandard.getNum()) |
| | | .eq(DailyInspectionStandard::getVersionStatus, "2").list(); |
| | | for (DailyInspectionStandard standard : dailyInspectionStandards) { |
| | | standard.setVersionStatus("3"); |
| | | standard.setLoseEfficacyTime(new Date()); |
| | | standard.setLoseEfficacyPerson(sysUser.getRealname()); |
| | | dailyInspectionStandardService.updateById(standard); |
| | | } |
| | | dailyInspectionStandard.setApprovalPerson(sysUser.getRealname()); |
| | | dailyInspectionStandard.setVersionStatus("2"); |
| | | dailyInspectionStandard.setTakeEffectTime(new Date()); |
| | | }else if("3".equals(approvalStatus)){ |
| | | dailyInspectionStandard.setAuditPerson(sysUser.getRealname()); |
| | | } |
| | | boolean b = dailyInspectionStandardService.updateById(dailyInspectionStandard); |
| | | if (b){ |
| | | if(!"5".equals(approvalStatus)){//已编制 |
| | | this.inspectionStandardAlert(approvalStatus,dailyInspectionStandard.getNum()); |
| | | } |
| | | |
| | | return Result.OK("审核成功!"); |
| | | }else{ |
| | | return Result.error("审核失败!"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | *点检标准签审流程消息提醒 |
| | | * qsw 2024-3-11 |
| | | */ |
| | | void inspectionStandardAlert(String approvalStatus,String standardNum){ |
| | | |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | SysDict sysDict = sysDictService.getOne(new QueryWrapper<SysDict>().eq("dict_code","info_type"),false); |
| | | SysDictItem sysDictItem = null; |
| | | String roleDictItem = ""; |
| | | if("1".equals(approvalStatus)){//已编制 |
| | | roleDictItem = "点检标准审核"; |
| | | sysDictItem = sysDictItemService.getOne(new QueryWrapper<SysDictItem>() |
| | | .eq("item_text","点检标准审核") |
| | | .eq("dict_id",sysDict.getId()),false); |
| | | }else if("2".equals(approvalStatus)){//驳回编制 |
| | | roleDictItem = "点检标准编制"; |
| | | sysDictItem = sysDictItemService.getOne(new QueryWrapper<SysDictItem>() |
| | | .eq("item_text","点检标准编制") |
| | | .eq("dict_id",sysDict.getId()),false); |
| | | }else if("3".equals(approvalStatus)){//已审核 |
| | | roleDictItem = "点检标准审批"; |
| | | sysDictItem = sysDictItemService.getOne(new QueryWrapper<SysDictItem>() |
| | | .eq("item_text","点检标准审批") |
| | | .eq("dict_id",sysDict.getId()),false); |
| | | }else if("4".equals(approvalStatus)){//驳回审核 |
| | | roleDictItem = "点检标准审核"; |
| | | sysDictItem = sysDictItemService.getOne(new QueryWrapper<SysDictItem>() |
| | | .eq("item_text","点检标准审核") |
| | | .eq("dict_id",sysDict.getId()),false); |
| | | } |
| | | // else if("5".equals(approvalStatus)){//通过 |
| | | // roleDictItem = "点检标准审批"; |
| | | // sysDictItem = sysDictItemService.getOne(new QueryWrapper<SysDictItem>() |
| | | // .eq("item_text","点检标准审批") |
| | | // .eq("dict_id",sysDict.getId()),false); |
| | | // } |
| | | String roleCode = sysDictItem.getItemValue(); |
| | | SysRole sysRole = sysRoleService.getOne(new QueryWrapper<SysRole>().eq("role_code",roleCode),false); |
| | | List<SysUserRole> sysUserRoles = sysUserRoleService.list(new QueryWrapper<SysUserRole>().eq("role_id",sysRole.getId())); |
| | | for(SysUserRole sysUserRole:sysUserRoles){ |
| | | SysUser user = sysUserService.getById(sysUserRole.getUserId()); |
| | | String msg = ""; |
| | | if("1".equals(approvalStatus)){ |
| | | msg = "【"+sysUser.getRealname()+"】"+"将【"+standardNum+"】的自主维护点检标准编制成功,请到自主维护点检标准页面审核!"; |
| | | }else if("2".equals(approvalStatus)){ |
| | | msg = "【"+sysUser.getRealname()+"】"+"将【"+standardNum+"】的自主维护点检标准已驳回,请到自主维护点检标准页面查看!"; |
| | | }else if("3".equals(approvalStatus)){ |
| | | msg = "【"+sysUser.getRealname()+"】"+"将【"+standardNum+"】的自主维护点检标准审核通过,请到自主维护点检标准页面审批!"; |
| | | }else if("4".equals(approvalStatus)){ |
| | | msg = "【"+sysUser.getRealname()+"】"+"将【"+standardNum+"】的自主维护点检标准已驳回,请到自主维护点检标准页面查看!"; |
| | | } |
| | | // else if("5".equals(approvalStatus)){ |
| | | // msg = "【"+sysUser.getRealname()+"】"+"将二级保养工单号【"+standardNum+"】的完工移交单确认通过,请到二级保养页面查看!"; |
| | | // } |
| | | MessageDTO messageDTO = new MessageDTO(); |
| | | messageDTO.setTitle("自主维护点检标准签审消息提醒!"); |
| | | messageDTO.setContent(msg); |
| | | messageDTO.setCategory(roleDictItem); |
| | | messageDTO.setFromUser("自主维护点检标准签审消息提醒提醒小助手"); |
| | | if(user != null){ |
| | | messageDTO.setToUser(user.getUsername()); |
| | | } |
| | | sysBaseApi.sendSysAnnouncement(messageDTO); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 批量 签审流程 |
| | | * qsw 2023-12-12 |
| | | */ |
| | | @RequestMapping(value = "/auditApprovalBatch", method = {RequestMethod.PUT,RequestMethod.POST}) |
| | | @Transactional(rollbackFor = { Exception.class }) |
| | | public Result<String> auditApprovalBatch(@RequestBody DailyInspectionStandard dailyInspectionStandard) { |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | |
| | | List<DailyInspectionStandard> dailyInspectionStandardlist = dailyInspectionStandard.getDailyInspectionStandardlist(); |
| | | for (DailyInspectionStandard inspectionStandard : dailyInspectionStandardlist) { |
| | | String approvalStatus = inspectionStandard.getApprovalStatus(); |
| | | if("5".equals(approvalStatus)){//审核通过后,版本生效 |
| | | List<DailyInspectionStandard> dailyInspectionStandards = dailyInspectionStandardService.lambdaQuery() |
| | | .eq(DailyInspectionStandard::getNum, inspectionStandard.getNum()) |
| | | .eq(DailyInspectionStandard::getVersionStatus, "2").list(); |
| | | for (DailyInspectionStandard standard : dailyInspectionStandards) { |
| | | standard.setVersionStatus("3"); |
| | | standard.setLoseEfficacyTime(new Date()); |
| | | standard.setLoseEfficacyPerson(sysUser.getRealname()); |
| | | dailyInspectionStandardService.updateById(standard); |
| | | } |
| | | inspectionStandard.setApprovalPerson(sysUser.getRealname()); |
| | | inspectionStandard.setVersionStatus("2"); |
| | | inspectionStandard.setTakeEffectTime(new Date()); |
| | | }else if("3".equals(approvalStatus)){ |
| | | inspectionStandard.setAuditPerson(sysUser.getRealname()); |
| | | } |
| | | boolean b = dailyInspectionStandardService.updateById(inspectionStandard); |
| | | if (!b){ |
| | | return Result.error("审核失败!"); |
| | | } |
| | | } |
| | | return Result.OK("审核成功!"); |
| | | } |
| | | } |