| | |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.poi.xwpf.usermodel.XWPFDocument; |
| | | import org.apache.poi.xwpf.usermodel.XWPFParagraph; |
| | | import org.apache.poi.xwpf.usermodel.XWPFTable; |
| | | import org.apache.poi.xwpf.usermodel.XWPFTableRow; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.exception.JeecgBootException; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.common.util.FileUtil; |
| | | import org.jeecg.common.util.SimpleVersionGenerateUtil; |
| | | import org.jeecg.modules.system.entity.BaseFactory; |
| | | import org.jeecg.modules.system.entity.BaseFactoryUser; |
| | | import org.jeecg.modules.system.service.IBaseFactoryService; |
| | | import org.jeecg.modules.system.service.IBaseFactoryUserService; |
| | | import org.jeecg.modules.eam.constant.BusinessCodeConst; |
| | | import org.jeecg.modules.eam.constant.TechnicalStatusEvaluationCheckCategoryEnum; |
| | | import org.jeecg.modules.eam.constant.TechnicalStatusEvaluationStandardEnum; |
| | | import org.jeecg.modules.eam.entity.EamEquipment; |
| | | import org.jeecg.modules.eam.entity.EamTechnicalStatusEvaluationStandard; |
| | | import org.jeecg.modules.eam.entity.EamTechnicalStatusEvaluationStandardDetail; |
| | | import org.jeecg.modules.eam.mapper.EamTechnicalStatusEvaluationStandardMapper; |
| | | import org.jeecg.modules.eam.request.EamTechnicalStatusEvaluationStandardRequest; |
| | | import org.jeecg.modules.eam.request.ImportException; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentService; |
| | | import org.jeecg.modules.eam.service.IEamTechnicalStatusEvaluationStandardDetailService; |
| | | import org.jeecg.modules.eam.service.IEamTechnicalStatusEvaluationStandardService; |
| | | import org.jeecg.modules.system.entity.BaseFactory; |
| | | import org.jeecg.modules.system.entity.BaseFactoryUser; |
| | | import org.jeecg.modules.system.service.IBaseFactoryService; |
| | | import org.jeecg.modules.system.service.IBaseFactoryUserService; |
| | | import org.jeecg.modules.system.service.ISysBusinessCodeRuleService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class EamTechnicalStatusEvaluationStandardServiceImpl extends ServiceImpl<EamTechnicalStatusEvaluationStandardMapper, EamTechnicalStatusEvaluationStandard> implements IEamTechnicalStatusEvaluationStandardService { |
| | | |
| | | @Autowired |
| | |
| | | private IBaseFactoryService baseFactoryService; |
| | | @Autowired |
| | | private IEamTechnicalStatusEvaluationStandardDetailService standardDetailService; |
| | | @Autowired |
| | | private IEamEquipmentService equipmentService; |
| | | @Autowired |
| | | private ISysBusinessCodeRuleService businessCodeRuleService; |
| | | |
| | | @Override |
| | | public IPage<EamTechnicalStatusEvaluationStandard> queryPageList(Page<EamTechnicalStatusEvaluationStandard> page, EamTechnicalStatusEvaluationStandard query) { |
| | |
| | | List<BaseFactoryUser> baseFactoryUserList = baseFactoryUserService. |
| | | list(new LambdaQueryWrapper<BaseFactoryUser>().eq(BaseFactoryUser::getUserId, sysUser.getId())); |
| | | if (!CollectionUtils.isEmpty(baseFactoryUserList)) { |
| | | List<String> factoryIds = baseFactoryUserList.stream().map(BaseFactoryUser::getFactoryId).collect(Collectors.toList()); |
| | | List<String> factoryCode = baseFactoryService.listByIds(factoryIds).stream().map(BaseFactory::getFactoryCode).collect(Collectors.toList()); |
| | | queryWrapper.in("e.factory_org_code", factoryCode); |
| | | Set<String> factoryIds = baseFactoryUserList.stream().map(BaseFactoryUser::getFactoryId).collect(Collectors.toSet()); |
| | | Set<String> factoryCodeList = baseFactoryService.listByIds(factoryIds).stream().map(BaseFactory::getOrgCode).collect(Collectors.toSet()); |
| | | queryWrapper.in("e.factory_org_code", factoryCodeList); |
| | | } else { |
| | | return page; |
| | | } |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean addEamTechnicalStatusEvaluationStandard(EamTechnicalStatusEvaluationStandardRequest request) { |
| | | if(!CommonConstant.STATUS_1.equals(request.getHasOtherCheck()) && !CommonConstant.STATUS_1.equals(request.getHasSafetyEquipmentCheck()) && !CommonConstant.STATUS_1.equals(request.getHasPrecisionCheck())) { |
| | | if (!CommonConstant.STATUS_1.equals(request.getHasOtherCheck()) && !CommonConstant.STATUS_1.equals(request.getHasSafetyEquipmentCheck()) && !CommonConstant.STATUS_1.equals(request.getHasPrecisionCheck())) { |
| | | //å¿
é¡»è¦éæ©ä¸ä¸ªæ£æ¥åç±» |
| | | throw new JeecgBootException("å¿
é¡»è¦éæ©ä¸ä¸ªæ£æ¥åç±»ï¼"); |
| | | } |
| | |
| | | entity.setDelFlag(CommonConstant.DEL_FLAG_0); |
| | | //é夿§æ ¡éª |
| | | EamTechnicalStatusEvaluationStandard exist = checkDuplicate(entity.getEquipmentId(), null); |
| | | if(exist != null){ |
| | | if (exist != null) { |
| | | throw new JeecgBootException("è§èå·²åå¨ï¼ä¸è½é夿·»å ï¼"); |
| | | } |
| | | this.getBaseMapper().insert(entity); |
| | | //å¤çæç»æ°æ® |
| | | if(CollectionUtil.isNotEmpty(request.getTableDetailList())) { |
| | | if (CollectionUtil.isNotEmpty(request.getTableDetailList())) { |
| | | request.getTableDetailList().forEach(tableDetail -> { |
| | | tableDetail.setStandardId(entity.getId()); |
| | | }); |
| | | //æ ¹æ®åç±»å¤ææ¯å¦ä¿å |
| | | if(CommonConstant.STATUS_1.equals(entity.getHasOtherCheck())) { |
| | | if (CommonConstant.STATUS_1.equals(entity.getHasOtherCheck())) { |
| | | //ä¿åå
¶ä»åç±» |
| | | List<EamTechnicalStatusEvaluationStandardDetail> collect = request.getTableDetailList().stream().filter(item -> TechnicalStatusEvaluationCheckCategoryEnum.OTHER_CHECK.name().equals(item.getCheckCategory())).collect(Collectors.toList()); |
| | | if(CollectionUtils.isEmpty(collect)) { |
| | | if (CollectionUtils.isEmpty(collect)) { |
| | | throw new JeecgBootException("å
¶ä»æ£æ¥æç»ä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | standardDetailService.saveBatch(collect); |
| | | } |
| | | if(CommonConstant.STATUS_1.equals(entity.getHasSafetyEquipmentCheck())) { |
| | | if (CommonConstant.STATUS_1.equals(entity.getHasSafetyEquipmentCheck())) { |
| | | //ä¿åå®å
¨è£
ç½®åç±» |
| | | List<EamTechnicalStatusEvaluationStandardDetail> collect = request.getTableDetailList().stream().filter(item -> TechnicalStatusEvaluationCheckCategoryEnum.SAFETY_EQUIPMENT_CHECK.name().equals(item.getCheckCategory())).collect(Collectors.toList()); |
| | | if(CollectionUtils.isEmpty(collect)) { |
| | | if (CollectionUtils.isEmpty(collect)) { |
| | | throw new JeecgBootException("å®å
¨è£
ç½®æ£æ¥æç»ä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | standardDetailService.saveBatch(collect); |
| | | } |
| | | if(CommonConstant.STATUS_1.equals(entity.getHasPrecisionCheck())) { |
| | | if (CommonConstant.STATUS_1.equals(entity.getHasPrecisionCheck())) { |
| | | //ä¿å精度æ£éªåç±» |
| | | List<EamTechnicalStatusEvaluationStandardDetail> collect = request.getTableDetailList().stream().filter(item -> TechnicalStatusEvaluationCheckCategoryEnum.PRECISION_CHECK.name().equals(item.getCheckCategory())).collect(Collectors.toList()); |
| | | if(CollectionUtils.isEmpty(collect)) { |
| | | if (CollectionUtils.isEmpty(collect)) { |
| | | throw new JeecgBootException("ç²¾åº¦æ£æ¥æç»ä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | standardDetailService.saveBatch(collect); |
| | |
| | | //å¾
æäº¤ãå¯ç¨ç¶æ |
| | | queryWrapper.in(EamTechnicalStatusEvaluationStandard::getStandardStatus, Arrays.asList(TechnicalStatusEvaluationStandardEnum.ENABLE.name(), TechnicalStatusEvaluationStandardEnum.WAIT_SUBMIT.name())); |
| | | queryWrapper.orderByDesc(EamTechnicalStatusEvaluationStandard::getStandardVersion); |
| | | if(StringUtils.isNotBlank(id)){ |
| | | if (StringUtils.isNotBlank(id)) { |
| | | queryWrapper.ne(EamTechnicalStatusEvaluationStandard::getId, id); |
| | | } |
| | | List<EamTechnicalStatusEvaluationStandard> list = this.getBaseMapper().selectList(queryWrapper); |
| | | if(CollectionUtil.isEmpty(list)) { |
| | | if (CollectionUtil.isEmpty(list)) { |
| | | return null; |
| | | } |
| | | return list.get(0); |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean editEamTechnicalStatusEvaluationStandard(EamTechnicalStatusEvaluationStandardRequest request) { |
| | | if(!CommonConstant.STATUS_1.equals(request.getHasOtherCheck()) && !CommonConstant.STATUS_1.equals(request.getHasSafetyEquipmentCheck()) && !CommonConstant.STATUS_1.equals(request.getHasPrecisionCheck())) { |
| | | if (!CommonConstant.STATUS_1.equals(request.getHasOtherCheck()) && !CommonConstant.STATUS_1.equals(request.getHasSafetyEquipmentCheck()) && !CommonConstant.STATUS_1.equals(request.getHasPrecisionCheck())) { |
| | | //å¿
é¡»è¦éæ©ä¸ä¸ªæ£æ¥åç±» |
| | | throw new JeecgBootException("å¿
é¡»è¦éæ©ä¸ä¸ªæ£æ¥åç±»ï¼"); |
| | | } |
| | | EamTechnicalStatusEvaluationStandard entity = this.getBaseMapper().selectById(request.getId()); |
| | | if(entity == null){ |
| | | if (entity == null) { |
| | | throw new JeecgBootException("ç¼è¾çæ°æ®å·²å é¤ï¼è¯·å·æ°éè¯ï¼"); |
| | | } |
| | | entity.setStandardName(request.getStandardName()); |
| | |
| | | entity.setRemark(request.getRemark()); |
| | | this.getBaseMapper().updateById(entity); |
| | | //å¤ç详æ
|
| | | if(CollectionUtil.isNotEmpty(request.getTableDetailList())) { |
| | | if (CollectionUtil.isNotEmpty(request.getTableDetailList())) { |
| | | //å
å 餿£æ¥é¡¹ |
| | | standardDetailService.removeByStandardId(entity.getId()); |
| | | request.getTableDetailList().forEach(tableDetail -> { |
| | | tableDetail.setStandardId(entity.getId()); |
| | | }); |
| | | //æ ¹æ®åç±»å¤ææ¯å¦ä¿å |
| | | if(CommonConstant.STATUS_1.equals(entity.getHasOtherCheck())) { |
| | | if (CommonConstant.STATUS_1.equals(entity.getHasOtherCheck())) { |
| | | //ä¿åå
¶ä»åç±» |
| | | List<EamTechnicalStatusEvaluationStandardDetail> collect = request.getTableDetailList().stream().filter(item -> TechnicalStatusEvaluationCheckCategoryEnum.OTHER_CHECK.name().equals(item.getCheckCategory())).collect(Collectors.toList()); |
| | | if(CollectionUtils.isEmpty(collect)) { |
| | | if (CollectionUtils.isEmpty(collect)) { |
| | | throw new JeecgBootException("å
¶ä»æ£æ¥æç»ä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | standardDetailService.saveBatch(collect); |
| | | } |
| | | if(CommonConstant.STATUS_1.equals(entity.getHasSafetyEquipmentCheck())) { |
| | | if (CommonConstant.STATUS_1.equals(entity.getHasSafetyEquipmentCheck())) { |
| | | //ä¿åå®å
¨è£
ç½®åç±» |
| | | List<EamTechnicalStatusEvaluationStandardDetail> collect = request.getTableDetailList().stream().filter(item -> TechnicalStatusEvaluationCheckCategoryEnum.SAFETY_EQUIPMENT_CHECK.name().equals(item.getCheckCategory())).collect(Collectors.toList()); |
| | | if(CollectionUtils.isEmpty(collect)) { |
| | | if (CollectionUtils.isEmpty(collect)) { |
| | | throw new JeecgBootException("å®å
¨è£
ç½®æ£æ¥æç»ä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | standardDetailService.saveBatch(collect); |
| | | } |
| | | if(CommonConstant.STATUS_1.equals(entity.getHasPrecisionCheck())) { |
| | | if (CommonConstant.STATUS_1.equals(entity.getHasPrecisionCheck())) { |
| | | //ä¿å精度æ£éªåç±» |
| | | List<EamTechnicalStatusEvaluationStandardDetail> collect = request.getTableDetailList().stream().filter(item -> TechnicalStatusEvaluationCheckCategoryEnum.PRECISION_CHECK.name().equals(item.getCheckCategory())).collect(Collectors.toList()); |
| | | if(CollectionUtils.isEmpty(collect)) { |
| | | if (CollectionUtils.isEmpty(collect)) { |
| | | throw new JeecgBootException("ç²¾åº¦æ£æ¥æç»ä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | standardDetailService.saveBatch(collect); |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean upgrade(EamTechnicalStatusEvaluationStandardRequest request) { |
| | | if(!CommonConstant.STATUS_1.equals(request.getHasOtherCheck()) && !CommonConstant.STATUS_1.equals(request.getHasSafetyEquipmentCheck()) && !CommonConstant.STATUS_1.equals(request.getHasPrecisionCheck())) { |
| | | if (!CommonConstant.STATUS_1.equals(request.getHasOtherCheck()) && !CommonConstant.STATUS_1.equals(request.getHasSafetyEquipmentCheck()) && !CommonConstant.STATUS_1.equals(request.getHasPrecisionCheck())) { |
| | | //å¿
é¡»è¦éæ©ä¸ä¸ªæ£æ¥åç±» |
| | | throw new JeecgBootException("å¿
é¡»è¦éæ©ä¸ä¸ªæ£æ¥åç±»ï¼"); |
| | | } |
| | | EamTechnicalStatusEvaluationStandard entity = this.getBaseMapper().selectById(request.getId()); |
| | | if(entity == null){ |
| | | if (entity == null) { |
| | | throw new JeecgBootException("åççæ°æ®å·²å é¤ï¼è¯·å·æ°éè¯ï¼"); |
| | | } |
| | | |
| | |
| | | newEntity.setRemark(request.getRemark()); |
| | | //é夿§æ ¡éª |
| | | EamTechnicalStatusEvaluationStandard exist = checkDuplicate(newEntity.getEquipmentId(), entity.getId()); |
| | | if(exist != null){ |
| | | if (exist != null) { |
| | | throw new JeecgBootException("é´å®è§èå·²åå¨ï¼ä¸è½é夿·»å ï¼"); |
| | | } |
| | | this.getBaseMapper().insert(newEntity); |
| | | //å¤çæç»æ°æ® |
| | | if(CollectionUtil.isNotEmpty(request.getTableDetailList())) { |
| | | if (CollectionUtil.isNotEmpty(request.getTableDetailList())) { |
| | | request.getTableDetailList().forEach(tableDetail -> { |
| | | tableDetail.setId(null); |
| | | tableDetail.setCreateBy(null); |
| | |
| | | tableDetail.setStandardId(newEntity.getId()); |
| | | }); |
| | | //æ ¹æ®åç±»å¤ææ¯å¦ä¿å |
| | | if(CommonConstant.STATUS_1.equals(entity.getHasOtherCheck())) { |
| | | if (CommonConstant.STATUS_1.equals(entity.getHasOtherCheck())) { |
| | | //ä¿åå
¶ä»åç±» |
| | | List<EamTechnicalStatusEvaluationStandardDetail> collect = request.getTableDetailList().stream().filter(item -> TechnicalStatusEvaluationCheckCategoryEnum.OTHER_CHECK.name().equals(item.getCheckCategory())).collect(Collectors.toList()); |
| | | if(CollectionUtils.isEmpty(collect)) { |
| | | if (CollectionUtils.isEmpty(collect)) { |
| | | throw new JeecgBootException("å
¶ä»æ£æ¥æç»ä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | standardDetailService.saveBatch(collect); |
| | | } |
| | | if(CommonConstant.STATUS_1.equals(entity.getHasSafetyEquipmentCheck())) { |
| | | if (CommonConstant.STATUS_1.equals(entity.getHasSafetyEquipmentCheck())) { |
| | | //ä¿åå®å
¨è£
ç½®åç±» |
| | | List<EamTechnicalStatusEvaluationStandardDetail> collect = request.getTableDetailList().stream().filter(item -> TechnicalStatusEvaluationCheckCategoryEnum.SAFETY_EQUIPMENT_CHECK.name().equals(item.getCheckCategory())).collect(Collectors.toList()); |
| | | if(CollectionUtils.isEmpty(collect)) { |
| | | if (CollectionUtils.isEmpty(collect)) { |
| | | throw new JeecgBootException("å®å
¨è£
ç½®æ£æ¥æç»ä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | standardDetailService.saveBatch(collect); |
| | | } |
| | | if(CommonConstant.STATUS_1.equals(entity.getHasPrecisionCheck())) { |
| | | if (CommonConstant.STATUS_1.equals(entity.getHasPrecisionCheck())) { |
| | | //ä¿å精度æ£éªåç±» |
| | | List<EamTechnicalStatusEvaluationStandardDetail> collect = request.getTableDetailList().stream().filter(item -> TechnicalStatusEvaluationCheckCategoryEnum.PRECISION_CHECK.name().equals(item.getCheckCategory())).collect(Collectors.toList()); |
| | | if(CollectionUtils.isEmpty(collect)) { |
| | | if (CollectionUtils.isEmpty(collect)) { |
| | | throw new JeecgBootException("ç²¾åº¦æ£æ¥æç»ä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | standardDetailService.saveBatch(collect); |
| | |
| | | this.getBaseMapper().updateById(entity); |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Result<?> importSafetyEquipmentCheck(MultipartFile file) { |
| | | String fileName = file.getOriginalFilename(); |
| | | if (StringUtils.isBlank(fileName)) { |
| | | return Result.error(fileName + ":æä»¶æ ¼å¼é误,æ æ³è§£æï¼"); |
| | | } |
| | | String fileSuffix = FileUtil.getFileSuffix(fileName); |
| | | //åªæ¯æ .docx çwordææ¡£ |
| | | if ("docx".equals(fileSuffix)) { |
| | | try (XWPFDocument doc = new XWPFDocument(file.getInputStream())) { |
| | | List<XWPFParagraph> paragraphs = doc.getParagraphs(); |
| | | List<XWPFTable> tables = doc.getTables(); |
| | | if (CollectionUtil.isEmpty(paragraphs) || CollectionUtil.isEmpty(tables)) { |
| | | return Result.error(fileName + ":æ¤æä»¶ä¸ç¬¦åå®å
¨è£
ç½®æ£æ¥æ¨¡æ¿è§èï¼è¯·æ£æ¥ï¼"); |
| | | } |
| | | //è·åæä»¶æ é¢ |
| | | StringBuilder builder = new StringBuilder(); |
| | | paragraphs.forEach(paragraph -> { |
| | | if (StringUtils.isNotBlank(paragraph.getText())) { |
| | | builder.append(paragraph.getText().trim()); |
| | | } |
| | | }); |
| | | if (!checkImportCategory(builder.toString(), TechnicalStatusEvaluationCheckCategoryEnum.SAFETY_EQUIPMENT_CHECK)) { |
| | | return Result.error(fileName + ":æ¤æä»¶ä¸ç¬¦åå®å
¨è£
ç½®æ£æ¥æ¨¡æ¿è§èï¼è¯·æ£æ¥ï¼"); |
| | | } |
| | | //è·å设å¤ä¿¡æ¯ |
| | | EamEquipment equipment = extractEquipmentInfo(tables.get(0)); |
| | | //æ¥çæ¯å¦ææ¤è®¾å¤å¯ç¨çè§èä¿¡æ¯ |
| | | EamTechnicalStatusEvaluationStandard originalStandard = checkDuplicate(equipment.getId(), null); |
| | | if (originalStandard != null && TechnicalStatusEvaluationStandardEnum.ENABLE.name().equals(originalStandard.getStandardStatus())) { |
| | | return Result.error(fileName + ":æ¤è®¾å¤çå®å
¨è£
ç½®æ£æ¥é¡¹å·²æ·»å ï¼è¯·è¿è¡ç¼è¾æåçï¼"); |
| | | } |
| | | //è·åæ£æ¥é¡¹ä¿¡æ¯ |
| | | List<EamTechnicalStatusEvaluationStandardDetail> detailList = extractSafetyEquipmentCheckItems(tables); |
| | | if(CollectionUtil.isEmpty(detailList)){ |
| | | return Result.error(fileName + ":æªè§£æå°æ£æ¥é¡¹å
容ï¼è¯·æ£æ¥ï¼"); |
| | | } |
| | | if(originalStandard != null) { |
| | | //å·²å卿æ¯ç¶æé´å®è§è,ä¸è§èç¶æä¸ºå·²æäº¤ |
| | | originalStandard.setHasSafetyEquipmentCheck(CommonConstant.STATUS_1); |
| | | originalStandard.setStandardStatus(TechnicalStatusEvaluationStandardEnum.WAIT_SUBMIT.name()); |
| | | super.getBaseMapper().updateById(originalStandard); |
| | | detailList.forEach(standardDetail -> { |
| | | standardDetail.setStandardId(originalStandard.getId()); |
| | | }); |
| | | standardDetailService.saveBatch(detailList); |
| | | }else { |
| | | String codeSeq = businessCodeRuleService.generateBusinessCodeSeq(BusinessCodeConst.TECHNICAL_STATUS_EVALUATION_STANDARD_CODE_RULE); |
| | | //æ°å¢ææ¯ç¶æé´å®è§è |
| | | EamTechnicalStatusEvaluationStandardRequest request = new EamTechnicalStatusEvaluationStandardRequest(); |
| | | request.setEquipmentId(equipment.getId()); |
| | | request.setHasSafetyEquipmentCheck(CommonConstant.STATUS_1); |
| | | request.setHasOtherCheck(CommonConstant.STATUS_0); |
| | | request.setHasPrecisionCheck(CommonConstant.STATUS_0); |
| | | request.setStandardCode(codeSeq); |
| | | request.setStandardName(equipment.getEquipmentName() + "ææ¯ç¶æé´å®è§è"); |
| | | request.setTableDetailList(detailList); |
| | | this.addEamTechnicalStatusEvaluationStandard(request); |
| | | } |
| | | } catch (ImportException e) { |
| | | log.error(e.getMessage(), e); |
| | | return Result.error(fileName + ":" + e.getMessage() + "ï¼"); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | return Result.error(fileName + ":ç³»ç»é误-" + e.getMessage() + "ï¼"); |
| | | } |
| | | } else { |
| | | return Result.error(fileName + ":æä»¶æ ¼å¼é误,æ æ³è§£æï¼"); |
| | | } |
| | | |
| | | return Result.OK(fileName + ":导å
¥æåï¼"); |
| | | } |
| | | |
| | | private boolean checkImportCategory(String title, TechnicalStatusEvaluationCheckCategoryEnum category) { |
| | | switch (category) { |
| | | case SAFETY_EQUIPMENT_CHECK: |
| | | return title.contains("å®å
¨è£
ç½®æ£æ¥"); |
| | | case PRECISION_CHECK: |
| | | return title.contains("ç²¾åº¦æ£æ¥å"); |
| | | case OTHER_CHECK: |
| | | return title.contains("å
¶ä»æ£æ¥"); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æå设å¤åºæ¬ä¿¡æ¯ |
| | | */ |
| | | private EamEquipment extractEquipmentInfo(XWPFTable table) { |
| | | if (table.getNumberOfRows() < 4) { |
| | | //妿 table å°äº4è¡ ä»£è¡¨ä¸ç¬¦å模æ¿è§èï¼å¯¼å
¥å¤±è´¥ |
| | | throw new JeecgBootException("æ¤æä»¶ä¸ç¬¦åå®å
¨è£
ç½®æ£æ¥æ¨¡æ¿è§èï¼è¯·æ£æ¥"); |
| | | } |
| | | // æå第äºè¡æ°æ® |
| | | Map<String, String> row2Data = extractHeadRowData(table.getRow(1)); |
| | | //è·å设å¤ç»ä¸ç¼ç |
| | | String equipmentCode = row2Data.get("ç»ä¸ç¼å·") == null ? null : row2Data.get("ç»ä¸ç¼å·").trim(); |
| | | EamEquipment eamEquipment = equipmentService.selectByEquipmentCode(equipmentCode); |
| | | if (eamEquipment == null) { |
| | | throw new JeecgBootException("æªæ¾å°è®¾å¤ä¿¡æ¯ï¼è¯·æ¥ç设å¤å°è´¦æ¯å¦ææ¤è®¾å¤"); |
| | | } |
| | | return eamEquipment; |
| | | } |
| | | |
| | | /** |
| | | * è¡¨æ ¼è¡¨å¤´æ°æ®è§£æ |
| | | */ |
| | | private Map<String, String> extractHeadRowData(XWPFTableRow row) { |
| | | Map<String, String> data = new HashMap<>(); |
| | | if(CollectionUtil.isEmpty(row.getTableCells()) || row.getTableCells().size() != 4) { |
| | | throw new JeecgBootException("æ¤æä»¶ä¸ç¬¦åå®å
¨è£
ç½®æ£æ¥æ¨¡æ¿è§èï¼è¯·æ£æ¥"); |
| | | } |
| | | int cellCount = row.getTableCells().size(); |
| | | for (int i = 0; i < cellCount; i += 2) { |
| | | String key = row.getCell(i).getText().trim(); |
| | | String value = row.getCell(i + 1).getText().trim(); |
| | | if (StringUtils.isNotBlank(key) && StringUtils.isNotBlank(value)) { |
| | | data.put(key, value); |
| | | } |
| | | } |
| | | return data; |
| | | } |
| | | |
| | | /** |
| | | * æåå®å
¨è£
ç½®æ£æ¥æç» |
| | | */ |
| | | private List<EamTechnicalStatusEvaluationStandardDetail> extractSafetyEquipmentCheckItems(List<XWPFTable> tableList) { |
| | | |
| | | List<EamTechnicalStatusEvaluationStandardDetail> items = new ArrayList<>(); |
| | | EamTechnicalStatusEvaluationStandardDetail item = null; |
| | | //è§£æç¬¬ä¸ä¸ªè¡¨æ ¼ï¼å¸¦è®¾å¤ä¿¡æ¯ |
| | | XWPFTable table = tableList.get(0); |
| | | for (int i = 0; i < table.getNumberOfRows(); i++) { |
| | | XWPFTableRow row = table.getRow(i); |
| | | if (row == null || CollectionUtil.isEmpty(row.getTableCells()) || row.getTableCells().size() < 2) { |
| | | //读åå°ç©ºrowå¼ |
| | | continue; |
| | | } |
| | | //æ£æ¥æ¯å¦å°æ£æ¥é¡¹åºå· |
| | | String firstCell = row.getCell(0).getText().trim(); |
| | | Integer itemCode = null; |
| | | try { |
| | | itemCode = Integer.parseInt(firstCell); |
| | | } catch (NumberFormatException e) { |
| | | //䏿¯æ£æ¥é¡¹å
容ï¼è·³è¿æ¤è¡ |
| | | continue; |
| | | } |
| | | //è·å第äºä¸ªåå
æ ¼ |
| | | String secondCell = row.getCell(1).getText().trim(); |
| | | //妿è¿ä¸è¡ä¸ºåºå·åè§£ææ´è¡ |
| | | if (StringUtils.isNotBlank(secondCell)) { |
| | | item = new EamTechnicalStatusEvaluationStandardDetail(); |
| | | item.setItemCode(itemCode); |
| | | item.setItemName(secondCell); |
| | | item.setCheckCategory(TechnicalStatusEvaluationCheckCategoryEnum.SAFETY_EQUIPMENT_CHECK.name()); |
| | | items.add(item); |
| | | } |
| | | } |
| | | return items; |
| | | } |
| | | } |