| | |
| | | package com.vci.ubcs.code.controller; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.vci.ubcs.code.dto.CodeDeleteBatchDTO; |
| | | import com.vci.ubcs.code.dto.CodeOrderDTO; |
| | | import com.vci.ubcs.code.dto.CodeOrderSecDTO; |
| | | import com.vci.ubcs.code.applyjtcodeservice.vo.BaseModelVO; |
| | | import com.vci.ubcs.code.dto.*; |
| | | import com.vci.ubcs.code.dto.datapush.BaseModelDTO; |
| | | import com.vci.ubcs.code.service.MdmEngineService; |
| | | import com.vci.ubcs.code.service.MdmIOService; |
| | | import com.vci.ubcs.code.vo.pagemodel.*; |
| | | import com.vci.ubcs.omd.vo.BtmTypeVO; |
| | | import com.vci.ubcs.flow.core.dto.FlowStatusDTO; |
| | | import com.vci.ubcs.starter.annotation.VciBusinessLog; |
| | | import com.vci.ubcs.starter.revision.model.BaseModel; |
| | | import com.vci.ubcs.starter.revision.model.TreeQueryObject; |
| | | import com.vci.ubcs.starter.util.LocalFileUtil; |
| | | import com.vci.ubcs.starter.util.SaveLogUtil; |
| | | import com.vci.ubcs.starter.web.pagemodel.*; |
| | | import com.vci.ubcs.starter.web.util.ControllerUtil; |
| | | import com.vci.ubcs.starter.web.util.LangBaseUtil; |
| | |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | //@AllArgsConstructor |
| | | @RequestMapping("/mdmEngineController") |
| | | @Api(value = "编码数据管理", tags = "编码数据管理") |
| | | public class MdmEngineController { |
| | | |
| | | // /** |
| | | // * 日志 |
| | | // */ |
| | | /** |
| | | * 日志 |
| | | */ |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | /** |
| | | * 主数据引擎服务 |
| | |
| | | */ |
| | | @Autowired |
| | | private MdmIOService mdmIOService; |
| | | /** |
| | | * 日志保存工具类 |
| | | */ |
| | | @Autowired |
| | | private SaveLogUtil saveLogUtil; |
| | | |
| | | /** |
| | | * 下载批量申请的导入模板 |
| | |
| | | ControllerUtil.writeDataToResponse(response,msg.getBytes(StandardCharsets.UTF_8),null); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 下载批量申请的导入模板 |
| | | * @param codeClassifyOid 分类的主键 |
| | | * @param response 响应对象 |
| | | * @throws IOException 抛出异常 |
| | | */ |
| | | @GetMapping("/downloadExcelBatchEdit") |
| | | @VciBusinessLog(operateName = "下载批量申请编码的导入模板") |
| | | public void downloadImportExcelBatchEdit(String codeClassifyOid, HttpServletResponse response) throws IOException{ |
| | | String excelName = mdmIOService.downloadImportExcelBatchEdit(codeClassifyOid); |
| | | try { |
| | | ControllerUtil.writeFileToResponse(response,excelName); |
| | | } catch (Throwable e) { |
| | | //如果出错,把错误信息写到text |
| | | String msg = LangBaseUtil.getErrorMsg(e); |
| | | if(StringUtils.isBlank(msg)){ |
| | | msg = "未知错误"; |
| | | } |
| | | ControllerUtil.writeDataToResponse(response,msg.getBytes(StandardCharsets.UTF_8),null); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 导入批量编辑数据 |
| | | * @param codeClassifyOid 分类的主键 |
| | | * @param classifyAttr 分类路径使用的属性 |
| | | * @param file 文件的内容 |
| | | */ |
| | | @VciBusinessLog(operateName = "导入批量编辑数据") |
| | | @PostMapping("/batchImportEdit") |
| | | public R batchImportEdit(String codeClassifyOid, String classifyAttr,MultipartFile file,HttpServletResponse response) throws Throwable { |
| | | String excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + file.getOriginalFilename(); |
| | | File file1 = new File(excelFileName); |
| | | try { |
| | | file.transferTo(new File(excelFileName)); |
| | | CodeImProtRusultVO codeImProtRusultVO =mdmIOService.batchImportEdit(codeClassifyOid, classifyAttr,file1); |
| | | if(StringUtils.isNotBlank(codeImProtRusultVO.getFilePath())||StringUtils.isNotBlank(codeImProtRusultVO.getRedisUuid())){ |
| | | //放到map里 |
| | | R result = R.fail("导入失败"); |
| | | if(StringUtils.isNotBlank(codeImProtRusultVO.getFilePath())) { |
| | | String filedUUid = ControllerUtil.putErrorFile(codeImProtRusultVO.getFilePath()); |
| | | codeImProtRusultVO.setFileOid(filedUUid); |
| | | } |
| | | result.setData(codeImProtRusultVO); |
| | | return result; |
| | | }else { |
| | | return R.success("操作成功!"); |
| | | } |
| | | }catch (Throwable e) { |
| | | logger.error("导入错误",e); |
| | | String errorFile = LocalFileUtil.getDefaultTempFolder() + File.separator + "错误.txt"; |
| | | LocalFileUtil.writeContentToFile(LangBaseUtil.getErrorMsg(e),errorFile); |
| | | String uuid=ControllerUtil.putErrorFile(errorFile); |
| | | CodeImProtRusultVO codeImProtRusultVO =new CodeImProtRusultVO(); |
| | | codeImProtRusultVO.setRedisUuid(""); |
| | | codeImProtRusultVO.setFileOid(uuid); |
| | | codeImProtRusultVO.setFilePath(errorFile); |
| | | R r = R.fail("导入失败"); |
| | | r.setData(codeImProtRusultVO); |
| | | return r; |
| | | }finally { |
| | | file1.delete(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 下载批量申请的导入模板 |
| | | * @param codeClassifyOid 分类的主键 |
| | |
| | | } |
| | | ControllerUtil.writeDataToResponse(response,msg.getBytes(StandardCharsets.UTF_8),null); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导出主题库的数据 |
| | | * @param exportAttrDTO 导出的相关配置 |
| | | */ |
| | | @VciBusinessLog(operateName = "导出主题库的数据") |
| | | @PostMapping("/exportCode") |
| | | public void exportCode(CodeExportAttrDTO exportAttrDTO, HttpServletResponse response) throws IOException { |
| | | try { |
| | | String excelName = mdmIOService.exportCode(exportAttrDTO); |
| | | ControllerUtil.writeFileToResponse(response,excelName); |
| | | } catch (Throwable e) { |
| | | //如果出错,把错误信息写到text |
| | | String msg = LangBaseUtil.getErrorMsg(e); |
| | | String errorFile = LocalFileUtil.getDefaultTempFolder() + File.separator + "错误.txt"; |
| | | LocalFileUtil.writeContentToFile(msg,errorFile); |
| | | ControllerUtil.writeFileToResponse(response,errorFile); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * 批量申请编码的信息 |
| | | * 批量申请编码的信息(当前分类上批量申请) |
| | | * @param secDTOList 申请编码的信息,必须包含码段和分类主键的信息 |
| | | * @param file 文件的内容 |
| | | */ |
| | |
| | | codeImProtRusultVO.setFilePath(errorFile); |
| | | R r = R.fail("导入失败"); |
| | | r.setData(codeImProtRusultVO); |
| | | |
| | | |
| | | return r; |
| | | }finally { |
| | | file1.delete(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 导入历史数据 |
| | | * 导入历史数据(从顶层分类导的) |
| | | * @param codeClassifyOid 分类的主键 |
| | | * @param classifyAttr 分类路径使用的属性 |
| | | * @param file 文件的内容 |
| | |
| | | R r = R.fail("导入失败"); |
| | | r.setData(codeImProtRusultVO); |
| | | |
| | | |
| | | return r; |
| | | }finally { |
| | | file1.delete(); |
| | |
| | | * @param baseModelDTO 数据传输对象 |
| | | * @return 执行结果 |
| | | */ |
| | | @PostMapping("changeStatus") |
| | | public R changeStatus(BaseModelDTO baseModelDTO) { |
| | | @PostMapping("/changeStatus") |
| | | public R changeStatus(@RequestBody BaseModelDTO baseModelDTO) { |
| | | engineService.changeStatus(baseModelDTO); |
| | | return R.success("操作成功!"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 申请编码保存 |
| | |
| | | @PostMapping("/addSaveCode") |
| | | @VciBusinessLog(operateName = "申请单个编码") |
| | | public R addSaveCode(@RequestBody CodeOrderDTO orderDTO) throws Exception { |
| | | return R.success(engineService.addSaveCode(orderDTO)); |
| | | String s = null; |
| | | try { |
| | | s = engineService.addSaveCode(orderDTO); |
| | | saveLogUtil.operateLog("编码申请",false,orderDTO.toString()); |
| | | }catch (Exception e){ |
| | | saveLogUtil.operateLog("编码申请",true,e.toString()); |
| | | throw e; |
| | | } |
| | | return R.success(s); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 使用模板的主键获取表单的定义 |
| | |
| | | return engineService.gridTableDataByClassifyOid(codeClassifyOid,templateOid,queryObject.getConditionMap(),queryObject.getPageHelper()); |
| | | } |
| | | |
| | | |
| | | /*** |
| | | /** |
| | | * 获取分类对象 |
| | | * @param redisOid |
| | | * @return |
| | |
| | | return R.data(codeImportTemplateVOs); |
| | | } |
| | | |
| | | /*** |
| | | /** |
| | | * 从redis缓存里获取到导入正确的数据 |
| | | * @param codeClassifyOid |
| | | * @param redisOid |
| | |
| | | return mdmIOService.gridDatas(codeClassifyOid,redisOid); |
| | | } |
| | | |
| | | /*** |
| | | /** |
| | | * 从redis缓存里获取到导入行相似项的数据 |
| | | * @param dataOid |
| | | * @param redisOid |
| | |
| | | return mdmIOService.gridRowResemble(dataOid,redisOid); |
| | | } |
| | | |
| | | /*** |
| | | /** |
| | | * 从redis缓存里获取到导入具有相似项的数据 |
| | | * @param codeClassifyOid |
| | | * @param redisOid |
| | |
| | | public DataGrid<Map<String,String>> gridResemble(String codeClassifyOid,String redisOid){ |
| | | return mdmIOService.gridDatas(codeClassifyOid,redisOid); |
| | | } |
| | | /*** |
| | | |
| | | /** |
| | | * 导入数据 |
| | | * @param codeImprotSaveDatVO//数据对象 |
| | | * @return |
| | | */ |
| | | @PostMapping("/batchImportData") |
| | | public R batchImportData(@RequestBody CodeImprotParmaDatVO codeImprotSaveDatVO){ |
| | | return mdmIOService.batchImportData(codeImprotSaveDatVO.getCodeImprotSaveDatVOList(),codeImprotSaveDatVO.getClassifyAttr(),codeImprotSaveDatVO.getImprot()); |
| | | return mdmIOService.batchImportData(codeImprotSaveDatVO.getCodeImprotSaveDatVOList(),codeImprotSaveDatVO.getClassifyAttr(),codeImprotSaveDatVO.getImprot()); |
| | | } |
| | | |
| | | /*** |
| | | *根据数据oid从缓存中移除数据 |
| | | /** |
| | | * 根据数据oid从缓存中移除数据 |
| | | * @param redisOid redisid |
| | | * @param codeClassifyOid 存储规则的oid |
| | | * @param dataOids 所需删除的数据 |
| | |
| | | public R deleteDatas(String redisOid,String codeClassifyOid,String dataOids){ |
| | | return mdmIOService.deleteDatas(redisOid,codeClassifyOid,dataOids); |
| | | } |
| | | |
| | | /** |
| | | * 批量保存流程执行页面修改的内容 |
| | | * @param orderDTOList 编码相关的信息,不需要码段的信息 |
| | |
| | | @PostMapping("/upSaveCode") |
| | | public R upSaveCode(@RequestBody CodeOrderDTO orderDTO){ |
| | | engineService.upSaveCode(orderDTO); |
| | | return R.success("操作成功!"); |
| | | return R.success("操作成功!"); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return 编码规则的内容 |
| | | */ |
| | | @GetMapping("/getCodeRuleByClassifyOid") |
| | | // @VciUnCheckRight |
| | | // @VciUnCheckRight |
| | | public R<CodeRuleVO> getCodeRuleByClassifyOid(String codeClassifyOid){ |
| | | return R.data(engineService.getCodeRuleByClassifyOid(codeClassifyOid)); |
| | | } |
| | |
| | | * @param idPath 编号的路径 |
| | | * @return UI相关的信息(仅包含表单) |
| | | */ |
| | | // @VciUnCheckRight |
| | | // @VciUnCheckRight |
| | | @GetMapping("/getFormDefineByClassifyIdPath") |
| | | public MdmUIInfoVO getFormDefineByClassifyIdPath(String idPath){ |
| | | return engineService.getFormDefineByClassifyIdPath(idPath); |
| | |
| | | return engineService.getUIInfoByClassifyOid(codeClassifyOid,functionId); |
| | | } |
| | | |
| | | /** |
| | | * 使用分类获取表格的定义 |
| | | * @param codeClassifyOid 分类主键 |
| | | * @param functionId 功能的编号 |
| | | * @return UI相关的信息(仅包含表格) |
| | | */ |
| | | @GetMapping("/getFlowdUIInfoByClassifyOid") |
| | | public MdmUIInfoVO getFlowUIInfoByClassifyOid(String codeClassifyOid,String functionId,String templateId,String taskId,String modelKey){ |
| | | return engineService.getFlowUIInfoByClassifyOid(codeClassifyOid,functionId,templateId,taskId,modelKey); |
| | | } |
| | | |
| | | @GetMapping("/thisistest") |
| | | @ResponseBody |
| | |
| | | * @param referConfigVO 参照的配置信息 |
| | | * @return 执行的结果 |
| | | */ |
| | | @GetMapping("/defaultReferDataGrid") |
| | | public IPage<BaseModel> defaultReferDataGrid(UIFormReferVO referConfigVO, BaseQueryObject baseQueryObject){ |
| | | @RequestMapping(value = "/defaultReferDataGrid",method = {RequestMethod.POST, RequestMethod.GET}) |
| | | public IPage<BaseModelVO> defaultReferDataGrid(UIFormReferVO referConfigVO, BaseQueryObject baseQueryObject){ |
| | | return engineService.referDataGrid(referConfigVO,baseQueryObject); |
| | | } |
| | | |
| | |
| | | return engineService.referTree(referConfigVO,queryObject); |
| | | } |
| | | |
| | | /** |
| | | * 流程中变更状态的简易接口 |
| | | * @param flowDTO 流程中携带的body |
| | | * @return |
| | | */ |
| | | @PostMapping("/processChangeStatus") |
| | | public R processChangeStatus(@RequestBody FlowStatusDTO flowDTO){ |
| | | return engineService.processChangeStatus(flowDTO); |
| | | } |
| | | |
| | | /** |
| | | * 标准申请和修订用 |
| | | * @param codeBZApplyDTO 编码申请相关的信息,需要有属性和码段相关的信息 |
| | | * @return 执行结果 |
| | | */ |
| | | @PostMapping("/addSaveBZ") |
| | | @VciBusinessLog(operateName = "申请单个编码") |
| | | public R addSaveBZ (@RequestBody CodeBZApplyDTO codeBZApplyDTO) throws Exception { |
| | | return R.success(engineService.addSaveBZ(codeBZApplyDTO)); |
| | | } |
| | | |
| | | /** |
| | | * 下载批量申请的导入模板 |
| | | * @param codeClassifyOid 分类的主键 |
| | | * @param response 响应对象 |
| | | * @throws IOException 抛出异常 |
| | | */ |
| | | @GetMapping("/exportGroupCodeExcel") |
| | | @VciBusinessLog(operateName = "导出集团码") |
| | | public void exportGroupCodeExcel(String codeClassifyOid, HttpServletResponse response) throws IOException { |
| | | try { |
| | | String excelName = mdmIOService.exportGroupCodeExcel(codeClassifyOid); |
| | | ControllerUtil.writeFileToResponse(response,excelName); |
| | | } catch (Throwable e) { |
| | | //如果出错,把错误信息写到text |
| | | String msg = LangBaseUtil.getErrorMsg(e); |
| | | if(StringUtils.isBlank(msg)){ |
| | | msg = "未知错误"; |
| | | } |
| | | String errorFile = LocalFileUtil.getDefaultTempFolder() + File.separator + "错误.txt"; |
| | | LocalFileUtil.writeContentToFile(msg,errorFile); |
| | | ControllerUtil.writeFileToResponse(response,errorFile); |
| | | // return R.fail(msg); |
| | | } |
| | | // return R.status(true); |
| | | } |
| | | |
| | | /** |
| | | * 集团码导入 |
| | | * @param codeClassifyOid |
| | | * @param file |
| | | * @param response |
| | | * @return |
| | | */ |
| | | @PostMapping("/importGroupCode") |
| | | public R importGroupCode(String codeClassifyOid,MultipartFile file,HttpServletResponse response){ |
| | | |
| | | String excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + file.getOriginalFilename(); |
| | | File file1 = new File(excelFileName); |
| | | try { |
| | | file.transferTo(new File(excelFileName)); |
| | | String excelName=mdmIOService.importGroupCode(codeClassifyOid,file1); |
| | | if(StringUtils.isNotBlank(excelName)) { |
| | | ControllerUtil.writeFileToResponse(response,excelName); |
| | | return R.fail("集团码导入出现问题,请查看文件"); |
| | | }else{ |
| | | return R.status(true); |
| | | } |
| | | }catch (Throwable e) { |
| | | logger.error("导入错误",e); |
| | | String errorFile = LocalFileUtil.getDefaultTempFolder() + File.separator + "错误.txt"; |
| | | LocalFileUtil.writeContentToFile(LangBaseUtil.getErrorMsg(e),errorFile); |
| | | String uuid=ControllerUtil.putErrorFile(errorFile); |
| | | CodeImProtRusultVO codeImProtRusultVO =new CodeImProtRusultVO(); |
| | | codeImProtRusultVO.setRedisUuid(""); |
| | | codeImProtRusultVO.setFileOid(uuid); |
| | | codeImProtRusultVO.setFilePath(errorFile); |
| | | R r = R.fail("集团码导入失败"); |
| | | r.setData(codeImProtRusultVO); |
| | | return r; |
| | | }finally { |
| | | file1.delete(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 获取统计分析数据 |
| | | * @param btmNames 业务类型 |
| | | * @return |
| | | */ |
| | | @GetMapping("/getStatisticAnalysis") |
| | | @VciBusinessLog(operateName = "获取统计分析数据") |
| | | public R getStatisticAnalysis(String btmNames) { |
| | | return engineService.getStatisticAnalysis(btmNames); |
| | | } |
| | | } |