| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- package com.ktg.iscs.controller;
- import com.baomidou.mybatisplus.core.toolkit.Wrappers;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.ktg.common.annotation.Log;
- import com.ktg.common.core.controller.BaseController;
- import com.ktg.common.core.domain.entity.SysDictData;
- import com.ktg.common.enums.BusinessType;
- import com.ktg.common.pojo.CommonResult;
- import com.ktg.common.utils.DictUtils;
- import com.ktg.common.utils.poi.ExcelUtil;
- import com.ktg.iscs.domain.IsSop;
- import com.ktg.iscs.domain.dto.sop.AddSopDTO;
- import com.ktg.iscs.domain.dto.sop.PageSopDTO;
- import com.ktg.iscs.domain.vo.sop.SopDetailVO;
- import com.ktg.iscs.domain.vo.sop.SopPageVO;
- import com.ktg.iscs.service.IIsSopService;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.v3.oas.annotations.Parameter;
- import io.swagger.v3.oas.annotations.Parameters;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.security.access.prepost.PreAuthorize;
- import org.springframework.web.bind.annotation.*;
- import javax.servlet.http.HttpServletResponse;
- import java.util.ArrayList;
- import java.util.HashSet;
- import java.util.List;
- import java.util.Set;
- import java.util.stream.Collectors;
- /**
- * SOP信息Controller
- *
- * @author cgj
- * @date 2024-10-18
- */
- @Api(tags = "SOP信息")
- @RestController
- @RequestMapping("/iscs/sop")
- public class IsSopController extends BaseController {
- @Autowired
- private IIsSopService isSopService;
- /**
- * 查询SOP信息分页
- */
- @ApiOperation("查询SOP信息-分页")
- @Parameters({
- @Parameter(name = "page", description = "Page"),
- @Parameter(name = "dto", description = "实体参数")
- })
- @PreAuthorize("@ss.hasPermi('mes:sop:sopm:query')")
- @GetMapping("/getIsSopPage")
- public CommonResult<Page<SopPageVO>> getIsSopPage(Page<IsSop> page, PageSopDTO dto) {
- return CommonResult.success(isSopService.getIsSopPage(page, dto));
- }
- /**
- * 导出SOP信息列表
- */
- @ApiOperation("导出SOP信息列表")
- @Parameter(name = "isSop", description = "实体参数")
- @PreAuthorize("@ss.hasPermi('iscs:sop:export')")
- @Log(title = "SOP信息", businessType = BusinessType.EXPORT)
- @PostMapping("/exportIsSop")
- public void exportIsSop(HttpServletResponse response, IsSop isSop) {
- List<IsSop> list = isSopService.selectIsSopList(isSop);
- ExcelUtil<IsSop> util = new ExcelUtil<IsSop>(IsSop.class);
- util.exportExcel(response, list, "SOP信息数据");
- }
- /**
- * 获取SOP信息详细信息
- */
- @ApiOperation("获取SOP信息详细信息")
- @Parameter(name = "sopId", description = "sopId")
- // @PreAuthorize("@ss.hasPermi('iscs:sop:query')")
- @GetMapping(value = "/selectIsSopById")
- public CommonResult<SopDetailVO> selectIsSopById(Long sopId) {
- return CommonResult.success(isSopService.selectIsSopBySopId(sopId));
- }
- /**
- * 新增SOP信息
- */
- @ApiOperation("新增SOP信息")
- @PreAuthorize("@ss.hasPermi('mes:sop:sopm:add')")
- @Log(title = "SOP信息", businessType = BusinessType.INSERT)
- @PostMapping("/insertIsSop")
- public CommonResult<Boolean> insertIsSop(@RequestBody @Parameter(name = "dto", description = "新增数据类,放到body") AddSopDTO dto) {
- return CommonResult.success(isSopService.insertIsSop(dto));
- }
- /**
- * 修改SOP信息
- */
- @ApiOperation("修改SOP信息")
- @PreAuthorize("@ss.hasPermi('mes:sop:sopm:edit')")
- @Log(title = "SOP信息", businessType = BusinessType.UPDATE)
- @PostMapping("/updateIsSop")
- public CommonResult<Boolean> updateIsSop(@RequestBody @Parameter(name = "dto", description = "修改数据类,放到body") AddSopDTO dto) {
- return CommonResult.success(isSopService.updateIsSop(dto));
- }
- @ApiOperation("修改SOP信息排序")
- @Log(title = "SOP信息", businessType = BusinessType.UPDATE)
- @PostMapping("/updateIsSopIndex")
- public CommonResult<Boolean> updateIsSopIndex(@RequestBody @Parameter(name = "isSop", description = "修改数据类,放到body") IsSop isSop) {
- return CommonResult.success(isSopService.updateIsSopIndex(isSop));
- }
- /**
- * 删除SOP信息
- */
- @ApiOperation("删除SOP信息")
- // @PreAuthorize("@ss.hasPermi('iscs:sop:remove')")
- @Log(title = "SOP信息", businessType = BusinessType.DELETE)
- @PostMapping("/deleteIsSopBySopIds")
- public CommonResult<Boolean> deleteIsSopBySopIds(String sopIds) {
- return CommonResult.success(isSopService.deleteIsSopBySopIds(sopIds));
- }
- @ApiOperation("获取工艺下的sop类型集合")
- @Parameter(name = "sopId", description = "sopId")
- // @PreAuthorize("@ss.hasPermi('iscs:sop:query')")
- @GetMapping(value = "/selectSopTypeByMachineryId")
- public CommonResult<List<SysDictData>> selectSopTypeByMachineryId(Long machineryId) {
- ArrayList<SysDictData> sysDictDatas = new ArrayList<>();
- List<IsSop> list = isSopService.list(Wrappers.<IsSop>lambdaQuery().eq(IsSop::getMachineryId, machineryId));
- if (list.size() > 0) {
- List<String> collect = list.stream().map(IsSop::getSopType).collect(Collectors.toList());
- if (collect.size() > 0) {
- // 使用 HashSet 去重
- Set<String> set = new HashSet<>(collect);
- ArrayList<String> strings = new ArrayList<>(set);
- for (String s : strings) {
- String sopType = DictUtils.getDictLabel("sop_type", s);
- SysDictData sysDictData = new SysDictData();
- sysDictData.setDictLabel(sopType);
- sysDictData.setDictValue(s);
- sysDictData.setDictType("sop_type");
- sysDictDatas.add(sysDictData);
- }
- }
- }
- return CommonResult.success(sysDictDatas);
- }
- }
|