IsSopController.java 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. package com.ktg.iscs.controller;
  2. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  3. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  4. import com.ktg.common.annotation.Log;
  5. import com.ktg.common.core.controller.BaseController;
  6. import com.ktg.common.core.domain.entity.SysDictData;
  7. import com.ktg.common.enums.BusinessType;
  8. import com.ktg.common.pojo.CommonResult;
  9. import com.ktg.common.utils.DictUtils;
  10. import com.ktg.common.utils.poi.ExcelUtil;
  11. import com.ktg.iscs.domain.IsSop;
  12. import com.ktg.iscs.domain.dto.sop.AddSopDTO;
  13. import com.ktg.iscs.domain.dto.sop.PageSopDTO;
  14. import com.ktg.iscs.domain.vo.sop.SopDetailVO;
  15. import com.ktg.iscs.domain.vo.sop.SopPageVO;
  16. import com.ktg.iscs.service.IIsSopService;
  17. import io.swagger.annotations.Api;
  18. import io.swagger.annotations.ApiOperation;
  19. import io.swagger.v3.oas.annotations.Parameter;
  20. import io.swagger.v3.oas.annotations.Parameters;
  21. import org.springframework.beans.factory.annotation.Autowired;
  22. import org.springframework.security.access.prepost.PreAuthorize;
  23. import org.springframework.web.bind.annotation.*;
  24. import javax.servlet.http.HttpServletResponse;
  25. import java.util.ArrayList;
  26. import java.util.HashSet;
  27. import java.util.List;
  28. import java.util.Set;
  29. import java.util.stream.Collectors;
  30. /**
  31. * SOP信息Controller
  32. *
  33. * @author cgj
  34. * @date 2024-10-18
  35. */
  36. @Api(tags = "SOP信息")
  37. @RestController
  38. @RequestMapping("/iscs/sop")
  39. public class IsSopController extends BaseController {
  40. @Autowired
  41. private IIsSopService isSopService;
  42. /**
  43. * 查询SOP信息分页
  44. */
  45. @ApiOperation("查询SOP信息-分页")
  46. @Parameters({
  47. @Parameter(name = "page", description = "Page"),
  48. @Parameter(name = "dto", description = "实体参数")
  49. })
  50. @PreAuthorize("@ss.hasPermi('mes:sop:sopm:query')")
  51. @GetMapping("/getIsSopPage")
  52. public CommonResult<Page<SopPageVO>> getIsSopPage(Page<IsSop> page, PageSopDTO dto) {
  53. return CommonResult.success(isSopService.getIsSopPage(page, dto));
  54. }
  55. /**
  56. * 导出SOP信息列表
  57. */
  58. @ApiOperation("导出SOP信息列表")
  59. @Parameter(name = "isSop", description = "实体参数")
  60. @PreAuthorize("@ss.hasPermi('iscs:sop:export')")
  61. @Log(title = "SOP信息", businessType = BusinessType.EXPORT)
  62. @PostMapping("/exportIsSop")
  63. public void exportIsSop(HttpServletResponse response, IsSop isSop) {
  64. List<IsSop> list = isSopService.selectIsSopList(isSop);
  65. ExcelUtil<IsSop> util = new ExcelUtil<IsSop>(IsSop.class);
  66. util.exportExcel(response, list, "SOP信息数据");
  67. }
  68. /**
  69. * 获取SOP信息详细信息
  70. */
  71. @ApiOperation("获取SOP信息详细信息")
  72. @Parameter(name = "sopId", description = "sopId")
  73. // @PreAuthorize("@ss.hasPermi('iscs:sop:query')")
  74. @GetMapping(value = "/selectIsSopById")
  75. public CommonResult<SopDetailVO> selectIsSopById(Long sopId) {
  76. return CommonResult.success(isSopService.selectIsSopBySopId(sopId));
  77. }
  78. /**
  79. * 新增SOP信息
  80. */
  81. @ApiOperation("新增SOP信息")
  82. @PreAuthorize("@ss.hasPermi('mes:sop:sopm:add')")
  83. @Log(title = "SOP信息", businessType = BusinessType.INSERT)
  84. @PostMapping("/insertIsSop")
  85. public CommonResult<Boolean> insertIsSop(@RequestBody @Parameter(name = "dto", description = "新增数据类,放到body") AddSopDTO dto) {
  86. return CommonResult.success(isSopService.insertIsSop(dto));
  87. }
  88. /**
  89. * 修改SOP信息
  90. */
  91. @ApiOperation("修改SOP信息")
  92. @PreAuthorize("@ss.hasPermi('mes:sop:sopm:edit')")
  93. @Log(title = "SOP信息", businessType = BusinessType.UPDATE)
  94. @PostMapping("/updateIsSop")
  95. public CommonResult<Boolean> updateIsSop(@RequestBody @Parameter(name = "dto", description = "修改数据类,放到body") AddSopDTO dto) {
  96. return CommonResult.success(isSopService.updateIsSop(dto));
  97. }
  98. @ApiOperation("修改SOP信息排序")
  99. @Log(title = "SOP信息", businessType = BusinessType.UPDATE)
  100. @PostMapping("/updateIsSopIndex")
  101. public CommonResult<Boolean> updateIsSopIndex(@RequestBody @Parameter(name = "isSop", description = "修改数据类,放到body") IsSop isSop) {
  102. return CommonResult.success(isSopService.updateIsSopIndex(isSop));
  103. }
  104. /**
  105. * 删除SOP信息
  106. */
  107. @ApiOperation("删除SOP信息")
  108. // @PreAuthorize("@ss.hasPermi('iscs:sop:remove')")
  109. @Log(title = "SOP信息", businessType = BusinessType.DELETE)
  110. @PostMapping("/deleteIsSopBySopIds")
  111. public CommonResult<Boolean> deleteIsSopBySopIds(String sopIds) {
  112. return CommonResult.success(isSopService.deleteIsSopBySopIds(sopIds));
  113. }
  114. @ApiOperation("获取工艺下的sop类型集合")
  115. @Parameter(name = "sopId", description = "sopId")
  116. // @PreAuthorize("@ss.hasPermi('iscs:sop:query')")
  117. @GetMapping(value = "/selectSopTypeByMachineryId")
  118. public CommonResult<List<SysDictData>> selectSopTypeByMachineryId(Long machineryId) {
  119. ArrayList<SysDictData> sysDictDatas = new ArrayList<>();
  120. List<IsSop> list = isSopService.list(Wrappers.<IsSop>lambdaQuery().eq(IsSop::getMachineryId, machineryId));
  121. if (list.size() > 0) {
  122. List<String> collect = list.stream().map(IsSop::getSopType).collect(Collectors.toList());
  123. if (collect.size() > 0) {
  124. // 使用 HashSet 去重
  125. Set<String> set = new HashSet<>(collect);
  126. ArrayList<String> strings = new ArrayList<>(set);
  127. for (String s : strings) {
  128. String sopType = DictUtils.getDictLabel("sop_type", s);
  129. SysDictData sysDictData = new SysDictData();
  130. sysDictData.setDictLabel(sopType);
  131. sysDictData.setDictValue(s);
  132. sysDictData.setDictType("sop_type");
  133. sysDictDatas.add(sysDictData);
  134. }
  135. }
  136. }
  137. return CommonResult.success(sysDictDatas);
  138. }
  139. }