| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.api.dto.message.MessageDTO; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.system.api.ISysBaseAPI; |
| | | import org.jeecg.common.system.base.entity.SysUpload; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.eam.entity.*; |
| | | import org.jeecg.modules.eam.model.DepartVo; |
| | | import org.jeecg.modules.eam.service.*; |
| | |
| | | |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | |
| | | import org.jeecgframework.poi.excel.ExcelImportUtil; |
| | | import org.jeecgframework.poi.excel.entity.ImportParams; |
| | | 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 org.springframework.web.multipart.MultipartHttpServletRequest; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | @Autowired |
| | | private IProcessParametersTemplateService processParametersTemplateService; |
| | | |
| | | // @Autowired |
| | | // private IUploadRelaService uploadRelaService; |
| | | |
| | | |
| | | @Autowired |
| | | private ISysBaseAPI sysBaseApi; |
| | |
| | | |
| | | @Autowired |
| | | private ICalibrationOrderReportService calibrationOrderReportService; |
| | | |
| | | @Autowired |
| | | private IEquipmentCategoryService equipmentCategoryService; |
| | | /** |
| | | * 分页列表查询 |
| | | * |
| | |
| | | if(StringUtils.isNotBlank(equipment.getTechnologyStatus())){ |
| | | queryWrapper.eq("technology_status",equipment.getTechnologyStatus()); |
| | | } |
| | | if(StringUtils.isNotBlank(equipment.getEquipmentCategoryId())){ |
| | | queryWrapper.eq("equipment_category_id",equipment.getEquipmentCategoryId()); |
| | | } |
| | | |
| | | queryWrapper.eq("status","1"); |
| | | queryWrapper.eq("del_flag",0); |
| | | queryWrapper.orderByDesc("create_time"); |
| | | |
| | | Page<Equipment> page = new Page<Equipment>(pageNo, pageSize); |
| | | IPage<Equipment> pageList = equipmentService.page(page, queryWrapper); |
| | |
| | | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | QueryWrapper<Equipment> queryWrapper = QueryGenerator.initQueryWrapper(equipment, req.getParameterMap()); |
| | | queryWrapper.eq("status","1"); |
| | | queryWrapper.eq("del_flag",0); |
| | | Page<Equipment> page = new Page<Equipment>(pageNo, pageSize); |
| | | IPage<Equipment> pageList = equipmentService.page(page, queryWrapper); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | |
| | | @GetMapping(value = "/pageEquipment") |
| | | public Result<IPage<Equipment>> pageEquipment(@RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize, @RequestParam Map<String, Object> params) { |
| | | IPage<Equipment> pageList = equipmentService.pageEquipment(pageNo, pageSize, params); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | |
| | | } |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 编辑 |
| | | * |
| | |
| | | } |
| | | return Result.OK("编辑成功!"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 通过id删除 |
| | | * |
| | |
| | | equipmentService.updateById(equipment); |
| | | return Result.OK("删除成功!"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * |
| | |
| | | // this.equipmentService.removeByIds(Arrays.asList(ids.split(","))); |
| | | return Result.OK("批量删除成功!"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 通过id查询 |
| | | * |
| | |
| | | //@RequiresPermissions("org.jeecg.modules.demo:mom_eam_equipment:exportXls") |
| | | @RequestMapping(value = "/exportXls") |
| | | public ModelAndView exportXls(HttpServletRequest request, Equipment equipment) { |
| | | return super.exportXls(request, equipment, Equipment.class, "mom_eam_equipment"); |
| | | return super.exportXls(request, equipment, Equipment.class, "设备台账导出"); |
| | | } |
| | | |
| | | /** |
| | | * 通过excel导入数据 |
| | | * |
| | | * @param request |
| | | * @param response |
| | | * @return |
| | | */ |
| | | //@RequiresPermissions("mom_eam_equipment:importExcel") |
| | | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | return super.importExcel(request, response, Equipment.class); |
| | | } |
| | | // /** |
| | | // * 通过excel导入数据 |
| | | // * |
| | | // * @param request |
| | | // * @param response |
| | | // * @return |
| | | // */ |
| | | // //@RequiresPermissions("mom_eam_equipment:importExcel") |
| | | // @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
| | | // public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | // return super.importExcel(request, response, Equipment.class); |
| | | // } |
| | | |
| | | |
| | | /** |
| | |
| | | @GetMapping(value = "/getResumeInspectionRecordList") |
| | | public Result<?> getResumeInspectionRecordList(@RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize, @RequestParam Map<String, Object> params) { |
| | | IPage<Map<String, Object>> resumeInspectionRecordList = equipmentService.getResumeInspectionRecordList(pageNo, pageSize, params); |
| | | LoginUser user= (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | for (Map<String, Object> record : resumeInspectionRecordList.getRecords()) { |
| | | String id = (String)record.get("id"); |
| | | String inspectionType = (String)record.get("inspectionType"); |
| | |
| | | queryWrapper.in("equipment_status",statusList); |
| | | IPage<Equipment> pageList = equipmentService.page(page, queryWrapper); |
| | | return Result.OK(pageList); |
| | | }/** |
| | | * 导入 |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; |
| | | LoginUser user= (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); |
| | | String exceptionInfo = ""; |
| | | int exceptionNum = 0; |
| | | for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { |
| | | MultipartFile file = entity.getValue(); |
| | | ImportParams params = new ImportParams(); |
| | | params.setNeedSave(true); |
| | | try { |
| | | List<EquipmentImportVo> list = ExcelImportUtil.importExcel(file.getInputStream(), EquipmentImportVo.class, params); |
| | | for(int i = 0;i<list.size();i++){ |
| | | EquipmentImportVo equipmentImportVo = list.get(i); |
| | | EquipmentCategory equipmentCategory = equipmentCategoryService.getOne(new QueryWrapper<EquipmentCategory>().eq("name",equipmentImportVo.getEquipmentCategoryName()),false); |
| | | if(StringUtils.isBlank(equipmentImportVo.getNum())){ |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:统一编码缺失,请填写必填项后再导入;"; |
| | | exceptionNum++; |
| | | } |
| | | else if(StringUtils.isBlank(equipmentImportVo.getName())){ |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:设备名称缺失,请填写必填项后再导入;"; |
| | | exceptionNum++; |
| | | } |
| | | else if(StringUtils.isBlank(equipmentImportVo.getUseId())){ |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:使用部门缺失,请填写必填项后再导入;"; |
| | | exceptionNum++; |
| | | } |
| | | // else if(StringUtils.isBlank(equipmentImportVo.getEquipmentUda1())){ |
| | | // exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:工区缺失,请填写必填项后再导入;"; |
| | | // exceptionNum++; |
| | | // } |
| | | else if(StringUtils.isBlank(equipmentImportVo.getManageId())){ |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:维护部门缺失,请填写必填项后再导入;"; |
| | | exceptionNum++; |
| | | } |
| | | else if(StringUtils.isBlank(equipmentImportVo.getTeamId())){ |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:维修班组缺失,请填写必填项后再导入;"; |
| | | exceptionNum++; |
| | | } |
| | | else if(StringUtils.isBlank(equipmentImportVo.getEquipmentImportanceId())){ |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:ABC标识缺失,请填写必填项后再导入;"; |
| | | exceptionNum++; |
| | | } |
| | | else if(StringUtils.isBlank(equipmentImportVo.getEquipmentCategoryName())){ |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:设备分类缺失,请填写必填项后再导入;"; |
| | | exceptionNum++; |
| | | } |
| | | else if(StringUtils.isBlank(equipmentImportVo.getEquipmentStatus())){ |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:设备状态缺失,请填写必填项后再导入;"; |
| | | exceptionNum++; |
| | | } |
| | | else if(StringUtils.isBlank(equipmentImportVo.getTechnologyStatus())){ |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:设备技术缺失,请填写必填项后再导入;"; |
| | | exceptionNum++; |
| | | } |
| | | else if(StringUtils.isBlank(equipmentImportVo.getFactoryModelId())){ |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:车间缺失,请填写必填项后再导入;"; |
| | | exceptionNum++; |
| | | } |
| | | else if(StringUtils.isBlank(equipmentImportVo.getWorkCenterId())){ |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:产线缺失,请填写必填项后再导入;"; |
| | | exceptionNum++; |
| | | } |
| | | else if(ObjectUtils.isNotNull(equipmentImportVo.getWarrantyStart())){ |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:质保开始日期缺失,请填写必填项后再导入;"; |
| | | exceptionNum++; |
| | | } |
| | | else if(StringUtils.isBlank(equipmentImportVo.getPropertyStatus())){ |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:资产状态缺失,请填写必填项后再导入;"; |
| | | exceptionNum++; |
| | | } |
| | | //非必填项 |
| | | // else if(StringUtils.isBlank(equipmentImportVo.getEquipmentUda5())){ |
| | | // exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:功能位置缺失,请填写必填项后再导入;"; |
| | | // exceptionNum++; |
| | | // } |
| | | // else if(StringUtils.isBlank(equipmentImportVo.getLocation())){ |
| | | // exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:安装位置缺失,请填写必填项后再导入;"; |
| | | // exceptionNum++; |
| | | // } |
| | | // else if(StringUtils.isBlank(equipmentImportVo.getLeaveFactoryDate())){ |
| | | // exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:出厂日期缺失,请填写必填项后再导入;"; |
| | | // exceptionNum++; |
| | | // } |
| | | // else if(StringUtils.isBlank(equipmentImportVo.getProjectApprovalNo())){ |
| | | // exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:立项卡号缺失,请填写必填项后再导入;"; |
| | | // exceptionNum++; |
| | | // } |
| | | // else if(StringUtils.isBlank(equipmentImportVo.getFundSource())){ |
| | | // exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:资金来源缺失,请填写必填项后再导入;"; |
| | | // exceptionNum++; |
| | | // } |
| | | // else if(StringUtils.isBlank(equipmentImportVo.getAcceptanceCheckDate())){ |
| | | // exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:验收日期缺失,请填写必填项后再导入;"; |
| | | // exceptionNum++; |
| | | // } |
| | | // else if(StringUtils.isBlank(equipmentImportVo.getLeaveFactoryDate())){ |
| | | // exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:出厂日期缺失,请填写必填项后再导入;"; |
| | | // exceptionNum++; |
| | | // } |
| | | // else if(StringUtils.isBlank(equipmentImportVo.getFactoryNo())){ |
| | | // exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:出厂编号缺失,请填写必填项后再导入;"; |
| | | // exceptionNum++; |
| | | // } |
| | | // else if( StringUtils.isBlank(equipmentImportVo.getConstructorId())){ |
| | | // exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:资产制造商缺失,请填写必填项后再导入;"; |
| | | // exceptionNum++; |
| | | // } |
| | | else if(StringUtils.isBlank(equipmentImportVo.getModel())){ |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:设备型号缺失,请填写必填项后再导入;"; |
| | | exceptionNum++; |
| | | } |
| | | else if(StringUtils.isBlank(equipmentImportVo.getSpecification())){ |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:设备规格缺失,请填写必填项后再导入;"; |
| | | exceptionNum++; |
| | | } |
| | | // else if(StringUtils.isBlank(equipmentImportVo.getGpo())){ |
| | | // exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:设备功率缺失,请填写必填项后再导入;"; |
| | | // exceptionNum++; |
| | | // } |
| | | else if(ObjectUtils.isNull(equipmentCategory)) |
| | | { |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:该设备所属类别不存在,请先维护设备类别;"; |
| | | exceptionNum++; |
| | | } |
| | | else{ |
| | | if(equipmentImportVo.getPropertyStatus().equals("warranty")){ |
| | | if( |
| | | ObjectUtils.isNull(equipmentImportVo.getWarrantyStart()) |
| | | ||ObjectUtils.isNull(equipmentImportVo.getWarrantyEnd()) |
| | | ){ |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:该设备处于质保期,质保信息缺失,请先维护质保开始时间或结束时间;"; |
| | | exceptionNum++; |
| | | } |
| | | |
| | | }else{ |
| | | Equipment oriEquipment = equipmentService.getOne(new QueryWrapper<Equipment>().eq("num",equipmentImportVo.getNum()),false); |
| | | if(ObjectUtils.isNull(oriEquipment)){ |
| | | Equipment equipment = new Equipment(); |
| | | equipment.setNum(equipmentImportVo.getNum()) |
| | | .setName(equipmentImportVo.getName()) |
| | | .setUseId(equipmentImportVo.getUseId()) |
| | | .setEquipmentUda1(equipmentImportVo.getEquipmentUda1()) |
| | | .setManageId(equipmentImportVo.getManageId()) |
| | | .setTeamId(equipmentImportVo.getTeamId()) |
| | | .setTechnologyStatus(equipmentImportVo.getTechnologyStatus()) |
| | | .setEquipmentImportanceId(equipmentImportVo.getEquipmentImportanceId()) |
| | | .setEquipmentCategoryId(equipmentCategory.getId()) |
| | | .setSpecificEquipment(equipmentImportVo.getKeyEquipmentIdentification()) |
| | | .setSecurityConfiguration(equipmentImportVo.getSecurityConfiguration()) |
| | | .setCoolingSystem(equipmentImportVo.getCoolingSystem()) |
| | | .setFireExtinguisher(equipmentImportVo.getFireExtinguisher()) |
| | | .setFireExtinguisherValidityPeriod(equipmentImportVo.getFireExtinguisherValidityPeriod()) |
| | | .setOperatingSystem(equipmentImportVo.getOperatingSystem()) |
| | | .setSystem(equipmentImportVo.getSystem()) |
| | | .setPort(equipmentImportVo.getPort()) |
| | | .setCoordinateNum(equipmentImportVo.getCoordinateNum()) |
| | | .setEquipmentStatus(equipmentImportVo.getEquipmentStatus()) |
| | | .setEquipmentUda3(equipmentImportVo.getEquipmentUda3()) |
| | | .setEquipmentUda4(equipmentImportVo.getEquipmentUda4()) |
| | | .setEquipmentUda5(equipmentImportVo.getEquipmentUda5()) |
| | | .setLocation(equipmentImportVo.getLocation()) |
| | | .setLastVerificationDate(equipmentImportVo.getLeaveFactoryDate()) |
| | | .setProjectApprovalNo(equipmentImportVo.getProjectApprovalNo()) |
| | | .setFundSource(equipmentImportVo.getFundSource()) |
| | | .setAcceptanceCheckDate(equipmentImportVo.getAcceptanceCheckDate()) |
| | | .setFactoryNumber(equipmentImportVo.getFactoryNumber()) |
| | | .setConstructorId(equipmentImportVo.getConstructorId()) |
| | | .setSourceCountry(equipmentImportVo.getSourceCountry()) |
| | | .setModel(equipmentImportVo.getModel()) |
| | | .setSpecification(equipmentImportVo.getSpecification()) |
| | | .setFactoryModelId(equipmentImportVo.getFactoryModelId()) |
| | | .setWorkCenterId(equipmentImportVo.getWorkCenterId()) |
| | | .setPropertyStatus(equipmentImportVo.getPropertyStatus()) |
| | | .setWarrantyStart(equipmentImportVo.getWarrantyStart()) |
| | | .setWarrantyEnd(equipmentImportVo.getWarrantyEnd()) |
| | | .setGpo(equipmentImportVo.getGpo()); |
| | | equipmentService.save(equipment); |
| | | }else { |
| | | exceptionInfo = exceptionInfo+"第"+(i+2)+"行导入失败,原因:统一编码已存在,数据重复导入;"; |
| | | exceptionNum++; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | if(exceptionNum!=0){ |
| | | String headInfo = "小导提醒您!设备台账:导入成功"+(list.size()-exceptionNum)+"条,失败"+exceptionNum+"条"; |
| | | MessageDTO messageDTO = new MessageDTO(); |
| | | messageDTO.setTitle(headInfo); |
| | | messageDTO.setFromUser("数据导入小助手-小导"); |
| | | messageDTO.setCategory("导入操作附加信息"); |
| | | messageDTO.setContent(exceptionInfo); |
| | | messageDTO.setToUser(user.getUsername()); |
| | | sysBaseApi.sendSysAnnouncement(messageDTO); |
| | | return Result.OK(headInfo+",可在-系统消息-查看导入详情"); |
| | | } |
| | | return Result.OK("导入成功,已导入全部数据。"); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | return Result.error("文件导入失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | return Result.error("文件导入失败!"); |
| | | } |
| | | |
| | | |
| | | } |