| | |
| | | |
| | | import com.vci.constant.FrameWorkLangCodeConstant; |
| | | import com.vci.dto.OsAttributeDTO; |
| | | import com.vci.starter.web.annotation.controller.VciUnCheckRight; |
| | | import com.vci.starter.web.annotation.log.VciBusinessLog; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | | import com.vci.starter.web.pagemodel.BaseQueryObject; |
| | | import com.vci.starter.web.pagemodel.BaseResult; |
| | | import com.vci.pagemodel.OsAttributeVO; |
| | | import com.vci.starter.web.pagemodel.Tree; |
| | | import com.vci.starter.web.pagemodel.TreeQueryObject; |
| | | import com.vci.starter.web.util.ControllerUtil; |
| | | import com.vci.starter.web.util.LocalFileUtil; |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | | import com.vci.web.service.OsAttributeServiceI; |
| | | import com.vci.web.util.Func; |
| | | import com.vci.starter.web.util.Lcm.Func; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | private Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | /** |
| | | * 获取所有属性(树形结构) |
| | | * @return 查询结果 |
| | | */ |
| | | @GetMapping( "/getTreeAttributes") |
| | | @VciBusinessLog(operateName = "获取属性(树形结构)") |
| | | public BaseResult<List<Tree>> getTreeAttributesByBtmName(TreeQueryObject treeQueryObject){ |
| | | try { |
| | | List<Tree> trees = attributeService.getTreeAttributesByBtmName(treeQueryObject); |
| | | return BaseResult.dataList(trees); |
| | | // return BaseResult.tree(trees); |
| | | }catch (Throwable e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = "查询业务类型时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(exceptionMessage); |
| | | return BaseResult.fail(exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 属性列表 |
| | | * @param baseQueryObject 查询对象 |
| | | * @return 属性的显示对象 |
| | | */ |
| | | @GetMapping("/gridAttribute") |
| | | @VciUnCheckRight |
| | | @VciBusinessLog(operateName = "属性列表") |
| | | public BaseResult<OsAttributeVO> gridAttribute(BaseQueryObject baseQueryObject){ |
| | | try { |
| | | return BaseResult.dataGrid(attributeService.gridAttribute(baseQueryObject)); |
| | |
| | | /** |
| | | * 添加单条属性到属性池 |
| | | * @param osAttributeDTO |
| | | * @return 列表的内容 |
| | | * @return |
| | | */ |
| | | @PostMapping( "/addAttribute") |
| | | @VciBusinessLog(operateName = "添加属性") |
| | |
| | | */ |
| | | @PutMapping( "/updateAttribute") |
| | | @VciBusinessLog(operateName = "修改属性") |
| | | @VciUnCheckRight |
| | | public BaseResult updateAttribute(@RequestBody OsAttributeDTO osAttributeDTO) { |
| | | try { |
| | | return attributeService.updateAttribute(osAttributeDTO) ? BaseResult.success("属性修改成功!"):BaseResult.fail("属性修改失败!"); |
| | |
| | | @VciBusinessLog(operateName = "导出属性") |
| | | public void exportAttributes(String exportFileName,String attrNames, HttpServletResponse response){ |
| | | try { |
| | | String excelPath = attributeService.exportAttributes(exportFileName,attrNames); |
| | | String excelPath = attributeService.exportAttributes(exportFileName,attrNames,false); |
| | | ControllerUtil.writeFileToResponse(response,excelPath); |
| | | } catch (Exception e) { |
| | | String msg = "导出枚举时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | String msg = "导出属性时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | try { |
| | | //出错时 |
| | | e.printStackTrace(); |
| | |
| | | * @return |
| | | */ |
| | | @PostMapping("/importAttributes") |
| | | @VciUnCheckRight |
| | | @VciBusinessLog(operateName = "导入属性") |
| | | public BaseResult importAttributes(MultipartFile file){ |
| | | String excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + LocalFileUtil.getFileNameForIE(file.getOriginalFilename()); |
| | | File file1 = new File(excelFileName); |
| | | try { |
| | | file.transferTo(new File(excelFileName)); |
| | | if (file != null) { |
| | | return attributeService.importAttributes(file1); |
| | | return attributeService.importAttributes(file1,false); |
| | | } else { |
| | | return BaseResult.fail(FrameWorkLangCodeConstant.IMPORT_FAIL, new String[]{"无导入的文件"}); |
| | | } |