| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.google.protobuf.ServiceException; |
| | | import com.vci.ubcs.code.applyjtcodeservice.feign.IMdmInterJtClient; |
| | |
| | | import com.vci.ubcs.omd.feign.IBtmTypeClient; |
| | | import com.vci.ubcs.omd.feign.IWebSecretClient; |
| | | import com.vci.ubcs.omd.vo.BtmTypeVO; |
| | | import com.vci.ubcs.omd.vo.RevisionRuleVO; |
| | | import com.vci.ubcs.starter.bo.WriteExcelData; |
| | | import com.vci.ubcs.starter.exception.VciBaseException; |
| | | import com.vci.ubcs.starter.poi.bo.ReadExcelOption; |
| | |
| | | import org.apache.poi.ss.usermodel.Font; |
| | | import org.apache.poi.ss.usermodel.RichTextString; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.aspectj.apache.bcel.classfile.Code; |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.beans.BeanInfo; |
| | | import java.beans.Introspector; |
| | | import java.beans.PropertyDescriptor; |
| | |
| | | import java.util.concurrent.CopyOnWriteArraySet; |
| | | import java.util.concurrent.ForkJoinPool; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.alibaba.druid.util.FnvHash.Constants.LIMIT; |
| | |
| | | engineService.batchSaveSelectChar(templateVO, dataCBOIdList); |
| | | } |
| | | } |
| | | //long end = System.currentTimeMillis(); |
| | | //log.info("=============for执行时间================="+String.valueOf((end-start)/1000)); |
| | | String excelFileName=""; |
| | | if(isExport&&!CollectionUtils.isEmpty(shetNameMap)) { |
| | | excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + "错误信息.xls"; |
| | |
| | | throw new VciBaseException(LangBaseUtil.getErrorMsg(e)); |
| | | } |
| | | ExcelUtil.writeDataToFile(excelFileName, eo); |
| | | saveLogUtil.operateLog("历史数据导入",true, StringUtil.format("错误信息:{}",JSON.toJSONString(shetNameMap))); |
| | | }else{ |
| | | // 历史数据导入时出现了相似项返回结果时不算导入成功 |
| | | if(shetNameMap.isEmpty() || !isCreateUUid){ |
| | | saveLogUtil.operateLog("历史数据导入",false, StringUtil.format("导入到分类{}中,导入成功总数为:{}", JSON.toJSONString(classifyFullInfo), Func.isEmpty(importCount) ? 0:importCount.get(0))); |
| | | } |
| | | } |
| | | CodeImProtRusultVO codeImProtRusultVO=new CodeImProtRusultVO(); |
| | | if(StringUtils.isNotBlank(excelFileName)) { |
| | | codeImProtRusultVO.setFilePath(excelFileName); |
| | | codeImProtRusultVO.setFileOid(""); |
| | | saveLogUtil.operateLog("历史数据导入",true, StringUtil.format("错误信息:{}",JSON.toJSONString(shetNameMap))); |
| | | }else{ |
| | | saveLogUtil.operateLog("历史数据导入",false, StringUtil.format("导入到分类{}中,导入成功总数为:{}", JSON.toJSONString(classifyFullInfo),importCount.get(0))); |
| | | } |
| | | if(isCreateUUid){ |
| | | codeImProtRusultVO.setRedisUuid(uuid); |
| | |
| | | ExcelUtil.writeDataToFile(excelName, excelOption); |
| | | } |
| | | |
| | | /** |
| | | * 相似项查询出来之后再点击确认时调用的 |
| | | * @param codeImprotSaveDatVOList |
| | | * @param classifyAttr |
| | | * @param isImprot |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R batchImportData(List<CodeImprotSaveDatVO> codeImprotSaveDatVOList, String classifyAttr, boolean isImprot) { |
| | | WriteExcelOption eo = new WriteExcelOption(); |
| | | AtomicBoolean success= new AtomicBoolean(true); |
| | | AtomicReference<CodeClassifyTemplateVO> codeClassifyTemplateVO = new AtomicReference<>(); |
| | | codeImprotSaveDatVOList.stream().forEach(codeImprotSaveDatVO -> { |
| | | List<SheetRowData> rowDataList = new ArrayList<>(); |
| | | List<ClientBusinessObject>cboList=new ArrayList<>(); |
| | |
| | | log.info("分类:"+classifyFullInfo.getCurrentClassifyVO().getName()+"数据:"+codeImprotSaveDatVO.getDataList().size()); |
| | | |
| | | // CodeClassifyTemplateVO codeClassifyTemplateVO= engineService.getUsedTemplateByClassifyOid(orderDTO.getCodeClassifyOid()); |
| | | CodeClassifyTemplateVO codeClassifyTemplateVO= templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid()); |
| | | codeClassifyTemplateVO.set(templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid())); |
| | | //规则的主键需要去获取 |
| | | CodeRuleVO ruleVO = engineService.getCodeRuleByClassifyFullInfo(classifyFullInfo); |
| | | //除去默认的属性.还有只有表单显示的字段才导入 |
| | | List<CodeClassifyTemplateAttrVO> attrVOS = codeClassifyTemplateVO.getAttributes().stream().filter(s -> |
| | | List<CodeClassifyTemplateAttrVO> attrVOS = codeClassifyTemplateVO.get().getAttributes().stream().filter(s -> |
| | | !DEFAULT_ATTR_LIST.contains(s.getId()) && |
| | | ((Func.isNotEmpty(s.getClassifyInvokeAttr()) || Func.isNotEmpty(s.getClassifyInvokeAttrName())) || VciBaseUtil.getBoolean(s.getFormDisplayFlag())) |
| | | ).collect(Collectors.toList()); |
| | | String fullPath = getFullPath(classifyFullInfo); |
| | | excelToCbo(classifyFullInfo,fieldIndexMap,rowDataList, codeClassifyTemplateVO,cboList,fullPath,!isImprot); |
| | | excelToCbo(classifyFullInfo,fieldIndexMap,rowDataList, codeClassifyTemplateVO.get(),cboList,fullPath,!isImprot); |
| | | Map<String,String> errorMap=new ConcurrentHashMap<>(); |
| | | Map<String/**路径**/, CodeClassifyVO> pathMap=new HashMap<>() ; |
| | | //校验编码规则和码段是否正确 |
| | |
| | | //最后弄组合规则 |
| | | batchSwitchComponentAttrOnOrder(attrVOS,cboList); |
| | | //3.判断关键属性 |
| | | CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, codeClassifyTemplateVO, cboList,false,errorMap); |
| | | CodeImportResultVO keyResultVO = batchCheckKeyAttrOnOrder(classifyFullInfo, codeClassifyTemplateVO.get(), cboList,false,errorMap); |
| | | Set<String> selfRepeatRowIndexList = keyResultVO.getSelfRepeatRowIndexList(); |
| | | Set<String> keyAttrRepeatRowIndexList = keyResultVO.getKeyAttrRepeatRowIndexList(); |
| | | if(!CollectionUtils.isEmpty(keyAttrRepeatRowIndexList)){ |
| | |
| | | dataCBOList.add(baseModel); |
| | | }); |
| | | try { |
| | | productCodeService.productCodeAndSaveData(classifyFullInfo, codeClassifyTemplateVO, finalRuleVOMap.get(ruleOid), null, dataCBOList, user); |
| | | productCodeService.productCodeAndSaveData(classifyFullInfo, codeClassifyTemplateVO.get(), finalRuleVOMap.get(ruleOid), null, dataCBOList, user); |
| | | } catch (Throwable e) { |
| | | //success=false; |
| | | log.error("批量产生编码的时候出错了", e); |
| | |
| | | }); |
| | | } |
| | | } |
| | | engineService.batchSaveSelectChar(codeClassifyTemplateVO, dataCBOList); |
| | | engineService.batchSaveSelectChar(codeClassifyTemplateVO.get(), dataCBOList); |
| | | }); |
| | | }else { |
| | | final BladeUser user = AuthUtil.getUser(); |
| | |
| | | dataCBOList.add(baseModel); |
| | | }); |
| | | try { |
| | | productCodeService.productCodeAndSaveData(classifyFullInfo, codeClassifyTemplateVO, ruleVO, orderDTO.getSecDTOList(), dataCBOList,user); |
| | | productCodeService.productCodeAndSaveData(classifyFullInfo, codeClassifyTemplateVO.get(), ruleVO, orderDTO.getSecDTOList(), dataCBOList,user); |
| | | } catch (Exception e) { |
| | | log.error("批量产生编码的时候出错了", e); |
| | | needSaveCboList.stream().forEach(cbo -> { |
| | |
| | | }); |
| | | } |
| | | //如果是编码生成失败,则直接就失败了,其他的判断出来有错误的我们都统一返回到excel里面 |
| | | engineService.batchSaveSelectChar(codeClassifyTemplateVO, dataCBOList); |
| | | engineService.batchSaveSelectChar(codeClassifyTemplateVO.get(), dataCBOList); |
| | | } |
| | | } |
| | | if(errorMap.size()>0) { |
| | |
| | | errorMap.forEach((key,v)->{ |
| | | excelDataList.add(new WriteExcelData(index[0]++, 0, "第"+(Integer.parseInt(key)+1)+"行数据:"+v)); |
| | | }); |
| | | eo.addSheetDataList(codeClassifyTemplateVO.getName() + "导入模板", excelDataList); |
| | | eo.addSheetDataList(codeClassifyTemplateVO.get().getName() + "导入模板", excelDataList); |
| | | } |
| | | }); |
| | | if(!success.get()){ |
| | | String excelName = LocalFileUtil.getDefaultTempFolder() + File.separator + (isImprot?"批量历史错误信息.xls":"批量申请错误信息.xls"); |
| | | ExcelUtil.writeDataToFile(excelName,eo); |
| | | return R.fail(excelName); |
| | | saveLogUtil.operateLog("历史数据导入",true, StringUtil.format("错误信息:{}",JSON.toJSONString(eo.getWriteDataMap()))); |
| | | return R.fail(excelName); |
| | | }else { |
| | | saveLogUtil.operateLog("历史数据导入",false, StringUtil.format("导入到分类{}中,导入成功总数为:{}", JSON.toJSONString(codeClassifyTemplateVO), Func.isEmpty(codeImprotSaveDatVOList.get(0).getDataList().size()))); |
| | | return R.success(isImprot ? "批量历史导入成功" : "批量申请成功"); |
| | | } |
| | | } |