浏览代码

新增工作区域管理、隔离点管理、sop新增修改

车车 1 年之前
父节点
当前提交
d293809623

+ 124 - 0
ktg-iscs/src/main/java/com/ktg/iscs/controller/IsIsolationPointController.java

@@ -0,0 +1,124 @@
+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.enums.BusinessType;
+import com.ktg.common.pojo.CommonResult;
+import com.ktg.common.utils.poi.ExcelUtil;
+import com.ktg.iscs.domain.IsIsolationPoint;
+import com.ktg.iscs.service.IIsIsolationPointService;
+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.List;
+
+/**
+ * 隔离点Controller
+ *
+ * @author cgj
+ * @date 2024-10-18
+ */
+@Api(tags = "隔离点")
+@RestController
+@RequestMapping("/iscs/point")
+public class IsIsolationPointController extends BaseController {
+    @Autowired
+    private IIsIsolationPointService isIsolationPointService;
+
+    /**
+     * 查询隔离点分页
+     */
+    @ApiOperation("查询隔离点-分页")
+    @Parameters({
+            @Parameter(name = "page", description = "Page"),
+            @Parameter(name = "sysTeam", description = "实体参数")
+    })
+    @PreAuthorize("@ss.hasPermi('iscs:point:page')")
+    @GetMapping("/getIsIsolationPointPage")
+    public CommonResult<Page<IsIsolationPoint>> getIsIsolationPointPage(Page<IsIsolationPoint> page, IsIsolationPoint isIsolationPoint) {
+        Page<IsIsolationPoint> result = isIsolationPointService.page(page, Wrappers.<IsIsolationPoint>lambdaQuery()
+                .orderByDesc(IsIsolationPoint::getPointId));
+        return CommonResult.success(result);
+    }
+
+    @ApiOperation("查询隔离点-列表")
+    @Parameters({
+            @Parameter(name = "workshopId", description = "所属车间ID"),
+            @Parameter(name = "workareaId", description = "所属区域ID")
+    })
+    @PreAuthorize("@ss.hasPermi('iscs:point:list')")
+    @GetMapping("/getIsIsolationPointList")
+    public CommonResult<List<IsIsolationPoint>> getIsIsolationPointList(Long workshopId, Long workareaId) {
+        List<IsIsolationPoint> result = isIsolationPointService.list(Wrappers.<IsIsolationPoint>lambdaQuery()
+                .eq(workshopId != null, IsIsolationPoint::getWorkshopId, workshopId)
+                .eq(workshopId != null, IsIsolationPoint::getWorkareaId, workareaId)
+                .orderByDesc(IsIsolationPoint::getPointId));
+        return CommonResult.success(result);
+    }
+
+    /**
+     * 导出隔离点列表
+     */
+    @ApiOperation("导出隔离点列表")
+    @Parameter(name = "isIsolationPoint", description = "实体参数")
+    @PreAuthorize("@ss.hasPermi('iscs:point:export')")
+    @Log(title = "隔离点", businessType = BusinessType.EXPORT)
+    @PostMapping("/exportIsIsolationPoint")
+    public void exportIsIsolationPoint(HttpServletResponse response, IsIsolationPoint isIsolationPoint) {
+        List<IsIsolationPoint> list = isIsolationPointService.selectIsIsolationPointList(isIsolationPoint);
+        ExcelUtil<IsIsolationPoint> util = new ExcelUtil<IsIsolationPoint>(IsIsolationPoint.class);
+        util.exportExcel(response, list, "隔离点数据");
+    }
+
+    /**
+     * 获取隔离点详细信息
+     */
+    @ApiOperation("获取隔离点详细信息")
+    @Parameter(name = "pointId", description = "pointId")
+    @PreAuthorize("@ss.hasPermi('iscs:point:query')")
+    @GetMapping(value = "/selectIsIsolationPointById")
+    public CommonResult<IsIsolationPoint> selectIsIsolationPointById(Long pointId) {
+        return CommonResult.success(isIsolationPointService.selectIsIsolationPointByPointId(pointId));
+    }
+
+    /**
+     * 新增隔离点
+     */
+    @ApiOperation("新增隔离点")
+    @PreAuthorize("@ss.hasPermi('iscs:point:add')")
+    @Log(title = "隔离点", businessType = BusinessType.INSERT)
+    @PostMapping("/insertIsIsolationPoint")
+    public CommonResult<Boolean> insertIsIsolationPoint(@RequestBody @Parameter(name = "isIsolationPoint", description = "新增数据类,放到body") IsIsolationPoint isIsolationPoint) {
+        return CommonResult.success(isIsolationPointService.insertIsIsolationPoint(isIsolationPoint) == 1);
+    }
+
+    /**
+     * 修改隔离点
+     */
+    @ApiOperation("修改隔离点")
+    @PreAuthorize("@ss.hasPermi('iscs:point:edit')")
+    @Log(title = "隔离点", businessType = BusinessType.UPDATE)
+    @PostMapping("/updateIsIsolationPoint")
+    public CommonResult<Boolean> updateIsIsolationPoint(@RequestBody @Parameter(name = "isIsolationPoint", description = "修改数据类,放到body") IsIsolationPoint isIsolationPoint) {
+        return CommonResult.success(isIsolationPointService.updateIsIsolationPoint(isIsolationPoint) == 1);
+    }
+
+    /**
+     * 删除隔离点
+     */
+    @ApiOperation("删除隔离点")
+    @PreAuthorize("@ss.hasPermi('iscs:point:remove')")
+    @Log(title = "隔离点", businessType = BusinessType.DELETE)
+    @PostMapping("/deleteIsIsolationPointByPointIds")
+    public CommonResult<Boolean> deleteIsIsolationPointByPointIds(String pointIds) {
+        return CommonResult.success(isIsolationPointService.deleteIsIsolationPointByPointIds(pointIds) != 0);
+    }
+}

+ 120 - 0
ktg-iscs/src/main/java/com/ktg/iscs/controller/IsSopController.java

@@ -0,0 +1,120 @@
+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.enums.BusinessType;
+import com.ktg.common.pojo.CommonResult;
+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.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.apache.commons.lang3.StringUtils;
+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.List;
+
+/**
+ * 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('iscs:sop:list')")
+    @GetMapping("/getIsSopPage")
+    public CommonResult<Page<IsSop>> getIsSopPage(Page<IsSop> page, PageSopDTO dto) {
+        Page<IsSop> result = isSopService.page(page, Wrappers.<IsSop>lambdaQuery()
+                .like(StringUtils.isNotBlank(dto.getSopCode()), IsSop::getSopCode, dto.getSopCode())
+                .like(StringUtils.isNotBlank(dto.getSopName()), IsSop::getSopName, dto.getSopName())
+                .eq(StringUtils.isNotBlank(dto.getSopStatus()), IsSop::getSopStatus, dto.getSopStatus())
+                .eq(dto.getWorkshopId() != null, IsSop::getWorkshopId, dto.getWorkshopId())
+                .eq(dto.getWorkareaId() != null, IsSop::getWorkareaId, dto.getWorkareaId())
+                .eq(StringUtils.isNotBlank(dto.getSopType()), IsSop::getSopType, dto.getSopType())
+                .ge(StringUtils.isNotBlank(dto.getStartTime()), IsSop::getCreateTime, dto.getStartTime())
+                .le(StringUtils.isNotBlank(dto.getEndTime()), IsSop::getCreateTime, dto.getEndTime())
+                .orderByDesc(IsSop::getSopId));
+        return CommonResult.success(result);
+    }
+
+    /**
+     * 导出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<IsSop> selectIsSopById(Long sopId) {
+        return CommonResult.success(isSopService.selectIsSopBySopId(sopId));
+    }
+
+    /**
+     * 新增SOP信息
+     */
+    @ApiOperation("新增SOP信息")
+    @PreAuthorize("@ss.hasPermi('iscs:sop: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('iscs:sop: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));
+    }
+
+    /**
+     * 删除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) != 0);
+    }
+}

+ 130 - 0
ktg-iscs/src/main/java/com/ktg/iscs/controller/IsWorkareaController.java

@@ -0,0 +1,130 @@
+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.enums.BusinessType;
+import com.ktg.common.pojo.CommonResult;
+import com.ktg.common.utils.poi.ExcelUtil;
+import com.ktg.iscs.domain.IsWorkarea;
+import com.ktg.iscs.service.IIsWorkareaService;
+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.List;
+
+/**
+ * 工作区域Controller
+ *
+ * @author cgj
+ * @date 2024-10-18
+ */
+@Api(tags = "工作区域")
+@RestController
+@RequestMapping("/iscs/workarea")
+public class IsWorkareaController extends BaseController
+{
+    @Autowired
+    private IIsWorkareaService isWorkareaService;
+
+    /**
+     * 查询工作区域分页
+     */
+    @ApiOperation("查询工作区域-分页")
+    @Parameters({
+            @Parameter(name = "page", description = "Page"),
+            @Parameter(name = "isWorkarea", description = "实体参数")
+    })
+    @PreAuthorize("@ss.hasPermi('iscs:workarea:page')")
+    @GetMapping("/getIsWorkareaPage")
+    public CommonResult<Page<IsWorkarea>> getIsWorkareaPage(Page page, IsWorkarea isWorkarea)
+    {
+        Page<IsWorkarea> result = isWorkareaService.page(page, Wrappers.<IsWorkarea>lambdaQuery()
+                .orderByDesc(IsWorkarea::getWorkareaId));
+        return CommonResult.success(result);
+    }
+
+    @ApiOperation("查询工作区域-列表")
+    @Parameters({
+            @Parameter(name = "workshopId", description = "所属车间ID")
+    })
+    @PreAuthorize("@ss.hasPermi('iscs:workarea:list')")
+    @GetMapping("/getIsWorkareaList")
+    public CommonResult<List<IsWorkarea>> getIsWorkareaList(Long workshopId)
+    {
+        List<IsWorkarea> result = isWorkareaService.list(Wrappers.<IsWorkarea>lambdaQuery()
+                        .eq(IsWorkarea::getWorkshopId, workshopId)
+                .orderByDesc(IsWorkarea::getWorkareaId));
+        return CommonResult.success(result);
+    }
+
+    /**
+     * 导出工作区域列表
+     */
+    @ApiOperation("导出工作区域列表")
+    @Parameter(name = "isWorkarea", description = "实体参数")
+    @PreAuthorize("@ss.hasPermi('iscs:workarea:export')")
+    @Log(title = "工作区域", businessType = BusinessType.EXPORT)
+    @PostMapping("/exportIsWorkarea")
+    public void exportIsWorkarea(HttpServletResponse response, IsWorkarea isWorkarea)
+    {
+        List<IsWorkarea> list = isWorkareaService.selectIsWorkareaList(isWorkarea);
+        ExcelUtil<IsWorkarea> util = new ExcelUtil<IsWorkarea>(IsWorkarea.class);
+        util.exportExcel(response, list, "工作区域数据");
+    }
+
+    /**
+     * 获取工作区域详细信息
+     */
+    @ApiOperation("获取工作区域详细信息")
+    @Parameter(name = "workareaId", description = "workareaId")
+    @PreAuthorize("@ss.hasPermi('iscs:workarea:query')")
+    @GetMapping(value = "/selectIsWorkareaById")
+    public CommonResult<IsWorkarea> selectIsWorkareaById(Long workareaId)
+    {
+        return CommonResult.success(isWorkareaService.selectIsWorkareaByWorkareaId(workareaId));
+    }
+
+    /**
+     * 新增工作区域
+     */
+    @ApiOperation("新增工作区域")
+    @PreAuthorize("@ss.hasPermi('iscs:workarea:add')")
+    @Log(title = "工作区域", businessType = BusinessType.INSERT)
+    @PostMapping("/insertIsWorkarea")
+    public CommonResult<Boolean> insertIsWorkarea(@RequestBody @Parameter(name = "isWorkarea", description = "新增数据类,放到body") IsWorkarea isWorkarea)
+    {
+        return CommonResult.success(isWorkareaService.insertIsWorkarea(isWorkarea) == 1);
+    }
+
+    /**
+     * 修改工作区域
+     */
+    @ApiOperation("修改工作区域")
+    @PreAuthorize("@ss.hasPermi('iscs:workarea:edit')")
+    @Log(title = "工作区域", businessType = BusinessType.UPDATE)
+    @PostMapping("/updateIsWorkarea")
+    public CommonResult<Boolean> updateIsWorkarea(@RequestBody @Parameter(name = "isWorkarea", description = "修改数据类,放到body") IsWorkarea isWorkarea)
+    {
+        return CommonResult.success(isWorkareaService.updateIsWorkarea(isWorkarea) == 1);
+    }
+
+    /**
+     * 删除工作区域
+     */
+    @ApiOperation("删除工作区域")
+    @PreAuthorize("@ss.hasPermi('iscs:workarea:remove')")
+    @Log(title = "工作区域", businessType = BusinessType.DELETE)
+	@PostMapping("/deleteIsWorkareaByWorkareaIds")
+    public CommonResult<Boolean> deleteIsWorkareaByWorkareaIds(String workareaIds)
+    {
+        return CommonResult.success(isWorkareaService.deleteIsWorkareaByWorkareaIds(workareaIds) != 0);
+    }
+}

+ 42 - 0
ktg-iscs/src/main/java/com/ktg/iscs/domain/dto/sop/AddSopDTO.java

@@ -0,0 +1,42 @@
+package com.ktg.iscs.domain.dto.sop;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * SOP信息对象 is_sop
+ *
+ * @author cgj
+ * @date 2024-10-18
+ */
+@Data
+public class AddSopDTO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @Schema(description = "SOP ID")
+    private Long sopId;
+
+    @Schema(description = "SOP编号")
+    private String sopCode;
+
+    @Schema(description = "SOP名称")
+    private String sopName;
+
+    @Schema(description = "SOP类型")
+    private String sopType;
+
+    @Schema(description = "所属车间ID")
+    private Long workshopId;
+
+    @Schema(description = "所属区域ID")
+    private Long workareaId;
+
+    @Schema(description = "SOP内容")
+    private String sopContent;
+
+    @Schema(description = "隔离点id, 多个用逗号分隔")
+    private String pointIds;
+
+}

+ 42 - 0
ktg-iscs/src/main/java/com/ktg/iscs/domain/dto/sop/PageSopDTO.java

@@ -0,0 +1,42 @@
+package com.ktg.iscs.domain.dto.sop;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * SOP信息对象 is_sop
+ *
+ * @author cgj
+ * @date 2024-10-18
+ */
+@Data
+public class PageSopDTO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @Schema(description = "SOP编号")
+    private String sopCode;
+
+    @Schema(description = "SOP名称")
+    private String sopName;
+
+    @Schema(description = "SOP状态")
+    private String sopStatus;
+
+    @Schema(description = "SOP类型")
+    private String sopType;
+
+    @Schema(description = "所属车间ID")
+    private Long workshopId;
+
+    @Schema(description = "所属区域ID")
+    private Long workareaId;
+
+    @Schema(description = "开始时间")
+    private String startTime;
+
+    @Schema(description = "结束时间")
+    private String endTime;
+
+}

+ 5 - 4
ktg-iscs/src/main/java/com/ktg/iscs/service/IIsSopService.java

@@ -2,6 +2,7 @@ package com.ktg.iscs.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ktg.iscs.domain.IsSop;
+import com.ktg.iscs.domain.dto.sop.AddSopDTO;
 
 import java.util.List;
 
@@ -32,18 +33,18 @@ public interface IIsSopService extends IService<IsSop>
     /**
      * 新增SOP信息
      *
-     * @param isSop SOP信息
+     * @param dto SOP信息
      * @return 结果
      */
-    int insertIsSop(IsSop isSop);
+    Boolean insertIsSop(AddSopDTO dto);
 
     /**
      * 修改SOP信息
      *
-     * @param isSop SOP信息
+     * @param dto SOP信息
      * @return 结果
      */
-    int updateIsSop(IsSop isSop);
+    Boolean updateIsSop(AddSopDTO dto);
 
     /**
      * 批量删除SOP信息

+ 20 - 1
ktg-iscs/src/main/java/com/ktg/iscs/service/impl/IsIsolationPointServiceImpl.java

@@ -1,12 +1,14 @@
 package com.ktg.iscs.service.impl;
 
 import cn.hutool.core.lang.Assert;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ktg.common.core.text.Convert;
 import com.ktg.common.utils.DateUtils;
 import com.ktg.iscs.domain.IsIsolationPoint;
 import com.ktg.iscs.mapper.IsIsolationPointMapper;
 import com.ktg.iscs.service.IIsIsolationPointService;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -57,7 +59,14 @@ public class IsIsolationPointServiceImpl extends ServiceImpl<IsIsolationPointMap
     @Override
     public int insertIsIsolationPoint(IsIsolationPoint isIsolationPoint)
     {
-        isIsolationPoint.setCreateTime(DateUtils.getNowDate());
+        // 断言校验
+        Assert.isTrue(StringUtils.isNotBlank(isIsolationPoint.getPointName()), "隔离点名称不可为空!");
+        Assert.isTrue(StringUtils.isNotBlank(isIsolationPoint.getPointCode()), "隔离点编号名称不可为空!");
+        Assert.notNull(isIsolationPoint.getWorkshopId(), "所属车间不可为空!");
+        Assert.notNull(isIsolationPoint.getWorkareaId(), "所属区域不可为空!");
+        List<IsIsolationPoint> list = list(Wrappers.<IsIsolationPoint>lambdaQuery()
+                .eq(IsIsolationPoint::getPointCode, isIsolationPoint.getPointCode()));
+        Assert.isTrue(list.isEmpty(), "该隔离点编号已被使用!");
         return isIsolationPointMapper.insertIsIsolationPoint(isIsolationPoint);
     }
 
@@ -70,6 +79,16 @@ public class IsIsolationPointServiceImpl extends ServiceImpl<IsIsolationPointMap
     @Override
     public int updateIsIsolationPoint(IsIsolationPoint isIsolationPoint)
     {
+        // 断言校验
+        Assert.notNull(isIsolationPoint.getPointId(), "隔离点ID不可为空!");
+        Assert.isTrue(StringUtils.isNotBlank(isIsolationPoint.getPointName()), "隔离点名称不可为空!");
+        Assert.isTrue(StringUtils.isNotBlank(isIsolationPoint.getPointCode()), "隔离点编号名称不可为空!");
+        Assert.notNull(isIsolationPoint.getWorkshopId(), "所属车间不可为空!");
+        Assert.notNull(isIsolationPoint.getWorkareaId(), "所属区域不可为空!");
+        List<IsIsolationPoint> list = list(Wrappers.<IsIsolationPoint>lambdaQuery()
+                .eq(IsIsolationPoint::getPointCode, isIsolationPoint.getPointCode())
+                .ne(IsIsolationPoint::getPointId, isIsolationPoint.getPointId()));
+        Assert.isTrue(list.isEmpty(), "该隔离点编号已被使用!");
         isIsolationPoint.setUpdateTime(DateUtils.getNowDate());
         return isIsolationPointMapper.updateIsIsolationPoint(isIsolationPoint);
     }

+ 77 - 21
ktg-iscs/src/main/java/com/ktg/iscs/service/impl/IsSopServiceImpl.java

@@ -1,14 +1,20 @@
 package com.ktg.iscs.service.impl;
 
 import cn.hutool.core.lang.Assert;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ktg.common.core.text.Convert;
-import com.ktg.common.utils.DateUtils;
+import com.ktg.common.utils.bean.BeanUtils;
 import com.ktg.iscs.domain.IsSop;
+import com.ktg.iscs.domain.IsSopPoints;
+import com.ktg.iscs.domain.dto.sop.AddSopDTO;
 import com.ktg.iscs.mapper.IsSopMapper;
+import com.ktg.iscs.service.IIsSopPointsService;
 import com.ktg.iscs.service.IIsSopService;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 
@@ -19,10 +25,11 @@ import java.util.List;
  * @date 2024-10-18
  */
 @Service
-public class IsSopServiceImpl extends ServiceImpl<IsSopMapper, IsSop> implements IIsSopService
-{
+public class IsSopServiceImpl extends ServiceImpl<IsSopMapper, IsSop> implements IIsSopService {
     @Autowired
     private IsSopMapper isSopMapper;
+    @Autowired
+    private IIsSopPointsService iIsSopPointsService;
 
     /**
      * 查询SOP信息
@@ -31,8 +38,7 @@ public class IsSopServiceImpl extends ServiceImpl<IsSopMapper, IsSop> implements
      * @return SOP信息
      */
     @Override
-    public IsSop selectIsSopBySopId(Long sopId)
-    {
+    public IsSop selectIsSopBySopId(Long sopId) {
         return isSopMapper.selectIsSopBySopId(sopId);
     }
 
@@ -43,35 +49,86 @@ public class IsSopServiceImpl extends ServiceImpl<IsSopMapper, IsSop> implements
      * @return SOP信息
      */
     @Override
-    public List<IsSop> selectIsSopList(IsSop isSop)
-    {
+    public List<IsSop> selectIsSopList(IsSop isSop) {
         return isSopMapper.selectIsSopList(isSop);
     }
 
     /**
      * 新增SOP信息
      *
-     * @param isSop SOP信息
+     * @param dto SOP信息
      * @return 结果
      */
+    @Transactional
     @Override
-    public int insertIsSop(IsSop isSop)
-    {
-        isSop.setCreateTime(DateUtils.getNowDate());
-        return isSopMapper.insertIsSop(isSop);
+    public Boolean insertIsSop(AddSopDTO dto) {
+        // 断言校验
+        Assert.notNull(dto.getWorkshopId(), "所属车间不可为空!");
+        Assert.isTrue(StringUtils.isNotBlank(dto.getSopName()), "SOP名称不可为空!");
+        Assert.isTrue(StringUtils.isNotBlank(dto.getSopCode()), "SOP编号名称不可为空!");
+        List<IsSop> list = list(Wrappers.<IsSop>lambdaQuery().eq(IsSop::getSopCode, dto.getSopCode()));
+        Assert.isTrue(list.isEmpty(), "该SOP编号已被使用!");
+        // 1.判断隔离点必选
+        Assert.isTrue(StringUtils.isNotBlank(dto.getPointIds()), "隔离点id不可为空!");
+        // 2.开始新增sop数据
+        IsSop isSop = BeanUtils.toBean(dto, IsSop.class);
+        save(isSop);
+        // 3.新增车间、区域、隔离点和sop的关联关系
+        // TODO 批量新增
+        Long[] pointIds = Convert.toLongArray(dto.getPointIds());
+        for (Long pointId : pointIds) {
+            IsSopPoints isSopPoints = new IsSopPoints();
+            isSopPoints.setSopId(isSop.getSopId());
+            isSopPoints.setWorkshopId(dto.getWorkshopId());
+            isSopPoints.setWorkareaId(dto.getWorkareaId());
+            isSopPoints.setPointId(pointId);
+            iIsSopPointsService.save(isSopPoints);
+        }
+        return true;
     }
 
     /**
      * 修改SOP信息
      *
-     * @param isSop SOP信息
+     * @param dto SOP信息
      * @return 结果
      */
+    @Transactional
     @Override
-    public int updateIsSop(IsSop isSop)
-    {
-        isSop.setUpdateTime(DateUtils.getNowDate());
-        return isSopMapper.updateIsSop(isSop);
+    public Boolean updateIsSop(AddSopDTO dto) {
+        // 断言校验
+        Assert.notNull(dto.getSopId(), "sopId不可为空!");
+        Assert.notNull(dto.getWorkshopId(), "所属车间不可为空!");
+        Assert.isTrue(StringUtils.isNotBlank(dto.getSopName()), "SOP名称不可为空!");
+        Assert.isTrue(StringUtils.isNotBlank(dto.getSopCode()), "SOP编号名称不可为空!");
+        List<IsSop> list = list(Wrappers.<IsSop>lambdaQuery()
+                .eq(IsSop::getSopCode, dto.getSopCode())
+                .ne(IsSop::getSopId, dto.getSopId()));
+        Assert.isTrue(list.isEmpty(), "该SOP编号已被使用!");
+        // 1.判断隔离点必选
+        Assert.isTrue(StringUtils.isNotBlank(dto.getPointIds()), "隔离点id不可为空!");
+        // 2.开始检查隔离点有没有变更
+        Long[] pointIds = Convert.toLongArray(dto.getPointIds());
+        List<IsSopPoints> isSopPoints = iIsSopPointsService.list(Wrappers.<IsSopPoints>lambdaQuery()
+                .eq(IsSopPoints::getSopId, dto.getSopId())
+                .in(IsSopPoints::getPointId, pointIds));
+        // 2.1如果查出来变更了,开始执行删除,重新增加一轮
+        if (pointIds.length != isSopPoints.size()) {
+            iIsSopPointsService.remove(Wrappers.<IsSopPoints>lambdaQuery().eq(IsSopPoints::getSopId, dto.getSopId()));
+            // TODO 批量新增
+            for (Long pointId : pointIds) {
+                IsSopPoints newSopPoints = new IsSopPoints();
+                newSopPoints.setSopId(dto.getSopId());
+                newSopPoints.setWorkshopId(dto.getWorkshopId());
+                newSopPoints.setWorkareaId(dto.getWorkareaId());
+                newSopPoints.setPointId(pointId);
+                iIsSopPointsService.save(newSopPoints);
+            }
+        }
+        // 3.开始执行更新操作
+        IsSop isSop = BeanUtils.toBean(dto, IsSop.class);
+        isSopMapper.updateById(isSop);
+        return true;
     }
 
     /**
@@ -81,8 +138,7 @@ public class IsSopServiceImpl extends ServiceImpl<IsSopMapper, IsSop> implements
      * @return 结果
      */
     @Override
-    public int deleteIsSopBySopIds(String sopIds)
-    {
+    public int deleteIsSopBySopIds(String sopIds) {
         Assert.notBlank(sopIds, "请选择需要删除的数据!");
         Long[] longIds = Convert.toLongArray(sopIds);
         return isSopMapper.deleteIsSopBySopIds(longIds);
@@ -95,8 +151,8 @@ public class IsSopServiceImpl extends ServiceImpl<IsSopMapper, IsSop> implements
      * @return 结果
      */
     @Override
-    public int deleteIsSopBySopId(Long sopId)
-    {
+    public int deleteIsSopBySopId(Long sopId) {
         return isSopMapper.deleteIsSopBySopId(sopId);
     }
+
 }

+ 33 - 3
ktg-iscs/src/main/java/com/ktg/iscs/service/impl/IsWorkareaServiceImpl.java

@@ -1,15 +1,19 @@
 package com.ktg.iscs.service.impl;
 
 import cn.hutool.core.lang.Assert;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ktg.common.core.text.Convert;
-import com.ktg.common.utils.DateUtils;
+import com.ktg.iscs.domain.IsSopPoints;
 import com.ktg.iscs.domain.IsWorkarea;
 import com.ktg.iscs.mapper.IsWorkareaMapper;
+import com.ktg.iscs.service.IIsSopPointsService;
 import com.ktg.iscs.service.IIsWorkareaService;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -23,6 +27,8 @@ public class IsWorkareaServiceImpl extends ServiceImpl<IsWorkareaMapper, IsWorka
 {
     @Autowired
     private IsWorkareaMapper isWorkareaMapper;
+    @Autowired
+    private IIsSopPointsService iIsSopPointsService;
 
     /**
      * 查询工作区域
@@ -57,7 +63,13 @@ public class IsWorkareaServiceImpl extends ServiceImpl<IsWorkareaMapper, IsWorka
     @Override
     public int insertIsWorkarea(IsWorkarea isWorkarea)
     {
-        isWorkarea.setCreateTime(DateUtils.getNowDate());
+        // 断言校验
+        Assert.isTrue(StringUtils.isNotBlank(isWorkarea.getWorkareaName()), "区域名称不可为空!");
+        Assert.isTrue(StringUtils.isNotBlank(isWorkarea.getWorkareaCode()), "区域编号名称不可为空!");
+        Assert.notNull(isWorkarea.getWorkshopId(), "所属车间不可为空!");
+        List<IsWorkarea> list = list(Wrappers.<IsWorkarea>lambdaQuery()
+                .eq(IsWorkarea::getWorkareaCode, isWorkarea.getWorkareaCode()));
+        Assert.isTrue(list.isEmpty(), "该区域编号已被使用!");
         return isWorkareaMapper.insertIsWorkarea(isWorkarea);
     }
 
@@ -70,7 +82,16 @@ public class IsWorkareaServiceImpl extends ServiceImpl<IsWorkareaMapper, IsWorka
     @Override
     public int updateIsWorkarea(IsWorkarea isWorkarea)
     {
-        isWorkarea.setUpdateTime(DateUtils.getNowDate());
+        // 断言校验
+        Assert.notNull(isWorkarea.getWorkareaId(), "区域ID不可为空!");
+        Assert.isTrue(StringUtils.isNotBlank(isWorkarea.getWorkareaName()), "区域名称不可为空!");
+        Assert.isTrue(StringUtils.isNotBlank(isWorkarea.getWorkareaCode()), "区域编号名称不可为空!");
+        Assert.notNull(isWorkarea.getWorkshopId(), "所属车间不可为空!");
+        List<IsWorkarea> list = list(Wrappers.<IsWorkarea>lambdaQuery()
+                .eq(IsWorkarea::getWorkareaCode, isWorkarea.getWorkareaCode())
+                .ne(IsWorkarea::getWorkshopId, isWorkarea.getWorkshopId()));
+        Assert.isTrue(list.isEmpty(), "该区域编号已被使用!");
+        isWorkarea.setUpdateTime(new Date());
         return isWorkareaMapper.updateIsWorkarea(isWorkarea);
     }
 
@@ -85,6 +106,15 @@ public class IsWorkareaServiceImpl extends ServiceImpl<IsWorkareaMapper, IsWorka
     {
         Assert.notBlank(workareaIds, "请选择需要删除的数据!");
         Long[] longIds = Convert.toLongArray(workareaIds);
+        // 1.判断下面有没有隔离点信息
+        for (Long longId : longIds) {
+            List<IsSopPoints> list = iIsSopPointsService.list(Wrappers.<IsSopPoints>lambdaQuery()
+                    .eq(IsSopPoints::getWorkareaId, longId));
+            if (!list.isEmpty()) {
+                IsWorkarea byId = getById(longId);
+                Assert.isTrue(false, byId.getWorkareaName() + "下有隔离点,暂不可删除!");
+            }
+        }
         return isWorkareaMapper.deleteIsWorkareaByWorkareaIds(longIds);
     }
 

+ 6 - 6
ktg-iscs/src/main/resources/mapper/IsSopMapper.xml

@@ -3,7 +3,7 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ktg.iscs.mapper.IsSopMapper">
-    
+
     <resultMap type="IsSop" id="IsSopResult">
         <result property="sopId"    column="sop_id"    />
         <result property="sopCode"    column="sop_code"    />
@@ -26,7 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectIsSopList" parameterType="IsSop" resultMap="IsSopResult">
         <include refid="selectIsSopVo"/>
-        <where>  
+        <where>
             <if test="sopCode != null  and sopCode != ''"> and sop_code = #{sopCode}</if>
             <if test="sopName != null  and sopName != ''"> and sop_name like concat('%', #{sopName}, '%')</if>
             <if test="sopType != null  and sopType != ''"> and sop_type = #{sopType}</if>
@@ -36,12 +36,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="sopStatus != null  and sopStatus != ''"> and sop_status = #{sopStatus}</if>
         </where>
     </select>
-    
+
     <select id="selectIsSopBySopId" parameterType="Long" resultMap="IsSopResult">
         <include refid="selectIsSopVo"/>
         where sop_id = #{sopId}
     </select>
-        
+
     <insert id="insertIsSop" parameterType="IsSop" useGeneratedKeys="true" keyProperty="sopId">
         insert into is_sop
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -98,9 +98,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteIsSopBySopIds" parameterType="String">
-        delete from is_sop where sop_id in 
+        delete from is_sop where sop_id in
         <foreach item="sopId" collection="array" open="(" separator="," close=")">
             #{sopId}
         </foreach>
     </delete>
-</mapper>
+</mapper>