Przeglądaj źródła

工作区域分页修改

车车 1 rok temu
rodzic
commit
e72900d23e

+ 3 - 9
ktg-iscs/src/main/java/com/ktg/iscs/controller/IsWorkareaController.java

@@ -8,12 +8,12 @@ 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.domain.vo.workarea.PageWorkareaVO;
 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.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
@@ -44,14 +44,8 @@ public class IsWorkareaController extends BaseController {
     })
     @PreAuthorize("@ss.hasPermi('iscs:workarea:page')")
     @GetMapping("/getIsWorkareaPage")
-    public CommonResult<Page<IsWorkarea>> getIsWorkareaPage(Page page, IsWorkarea dto) {
-        Page<IsWorkarea> result = isWorkareaService.page(page, Wrappers.<IsWorkarea>lambdaQuery()
-                .like(StringUtils.isNotBlank(dto.getWorkareaCode()), IsWorkarea::getWorkareaCode, dto.getWorkareaCode())
-                .like(StringUtils.isNotBlank(dto.getWorkareaName()), IsWorkarea::getWorkareaName, dto.getWorkareaName())
-                .eq(StringUtils.isNotBlank(dto.getWorkareaType()), IsWorkarea::getWorkareaType, dto.getWorkareaType())
-                .eq(dto.getWorkshopId() != null, IsWorkarea::getWorkshopId, dto.getWorkshopId())
-                .orderByDesc(IsWorkarea::getWorkareaId));
-        return CommonResult.success(result);
+    public CommonResult<Page<PageWorkareaVO>> getIsWorkareaPage(Page page, IsWorkarea dto) {
+        return CommonResult.success(isWorkareaService.getIsWorkareaPage(page, dto));
     }
 
     @ApiOperation("查询工作区域-列表")

+ 59 - 0
ktg-iscs/src/main/java/com/ktg/iscs/domain/vo/workarea/PageWorkareaVO.java

@@ -0,0 +1,59 @@
+package com.ktg.iscs.domain.vo.workarea;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.ktg.common.annotation.Excel;
+import com.ktg.common.core.domain.model.BaseBean;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 工作区域对象 is_workarea
+ *
+ * @author cgj
+ * @date 2024-10-18
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class PageWorkareaVO extends BaseBean
+{
+    private static final long serialVersionUID = 1L;
+
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "区域ID")
+    private Long workareaId;
+
+    @ApiModelProperty(value = "区域编号")
+    @Excel(name = "区域编号")
+    private String workareaCode;
+
+    @ApiModelProperty(value = "区域名称")
+    @Excel(name = "区域名称")
+    private String workareaName;
+
+    /** 区域类型 */
+    @ApiModelProperty(value = "区域类型")
+    @Excel(name = "区域类型")
+    private String workareaType;
+
+    /** 所属车间ID */
+    @ApiModelProperty(value = "所属车间ID")
+    @Excel(name = "所属车间ID")
+    private Long workshopId;
+
+    @ApiModelProperty(value = "所属车间Name")
+    @Excel(name = "所属车间Name")
+    private String workshopName;
+
+    /** 地图 */
+    @ApiModelProperty(value = "地图")
+    @Excel(name = "地图")
+    private String map;
+
+    /** 删除标志(0代表存在 2代表删除) */
+    @ApiModelProperty(value = "删除标志(0代表存在 2代表删除)")
+    private String delFlag;
+
+
+}

+ 5 - 0
ktg-iscs/src/main/java/com/ktg/iscs/mapper/IsWorkareaMapper.java

@@ -1,8 +1,11 @@
 package com.ktg.iscs.mapper;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ktg.common.mapper.BaseMapperX;
 import com.ktg.iscs.domain.IsWorkarea;
+import com.ktg.iscs.domain.vo.workarea.PageWorkareaVO;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -62,4 +65,6 @@ public interface IsWorkareaMapper extends BaseMapperX<IsWorkarea>
      * @return 结果
      */
     int deleteIsWorkareaByWorkareaIds(Long[] workareaIds);
+
+    Page<PageWorkareaVO> getIsWorkareaPage(Page page, @Param(value = "dto") IsWorkarea dto);
 }

+ 4 - 0
ktg-iscs/src/main/java/com/ktg/iscs/service/IIsWorkareaService.java

@@ -1,7 +1,9 @@
 package com.ktg.iscs.service;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ktg.iscs.domain.IsWorkarea;
+import com.ktg.iscs.domain.vo.workarea.PageWorkareaVO;
 
 import java.util.List;
 
@@ -60,4 +62,6 @@ public interface IIsWorkareaService extends IService<IsWorkarea>
      * @return 结果
      */
     int deleteIsWorkareaByWorkareaId(Long workareaId);
+
+    Page<PageWorkareaVO> getIsWorkareaPage(Page page, IsWorkarea dto);
 }

+ 1 - 0
ktg-iscs/src/main/java/com/ktg/iscs/service/impl/IsJobTicketServiceImpl.java

@@ -205,6 +205,7 @@ public class IsJobTicketServiceImpl extends ServiceImpl<IsJobTicketMapper, IsJob
      * @param ticketIds 需要删除的作业票主键
      * @return 结果
      */
+    @Transactional
     @Override
     public Boolean deleteIsJobTicketByTicketIds(String ticketIds)
     {

+ 8 - 1
ktg-iscs/src/main/java/com/ktg/iscs/service/impl/IsWorkareaServiceImpl.java

@@ -2,10 +2,12 @@ package com.ktg.iscs.service.impl;
 
 import cn.hutool.core.lang.Assert;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ktg.common.core.text.Convert;
 import com.ktg.iscs.domain.IsSopPoints;
 import com.ktg.iscs.domain.IsWorkarea;
+import com.ktg.iscs.domain.vo.workarea.PageWorkareaVO;
 import com.ktg.iscs.mapper.IsWorkareaMapper;
 import com.ktg.iscs.service.IIsSopPointsService;
 import com.ktg.iscs.service.IIsWorkareaService;
@@ -89,7 +91,7 @@ public class IsWorkareaServiceImpl extends ServiceImpl<IsWorkareaMapper, IsWorka
         Assert.notNull(isWorkarea.getWorkshopId(), "所属车间不可为空!");
         List<IsWorkarea> list = list(Wrappers.<IsWorkarea>lambdaQuery()
                 .eq(IsWorkarea::getWorkareaCode, isWorkarea.getWorkareaCode())
-                .ne(IsWorkarea::getWorkshopId, isWorkarea.getWorkshopId()));
+                .ne(IsWorkarea::getWorkareaId, isWorkarea.getWorkareaId()));
         Assert.isTrue(list.isEmpty(), "该区域编号已被使用!");
         isWorkarea.setUpdateTime(new Date());
         return isWorkareaMapper.updateIsWorkarea(isWorkarea);
@@ -129,4 +131,9 @@ public class IsWorkareaServiceImpl extends ServiceImpl<IsWorkareaMapper, IsWorka
     {
         return isWorkareaMapper.deleteIsWorkareaByWorkareaId(workareaId);
     }
+
+    @Override
+    public Page<PageWorkareaVO> getIsWorkareaPage(Page page, IsWorkarea dto) {
+        return isWorkareaMapper.getIsWorkareaPage(page, dto);
+    }
 }

+ 31 - 6
ktg-iscs/src/main/resources/mapper/IsWorkareaMapper.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.IsWorkareaMapper">
-    
+
     <resultMap type="IsWorkarea" id="IsWorkareaResult">
         <result property="workareaId"    column="workarea_id"    />
         <result property="workareaCode"    column="workarea_code"    />
@@ -24,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectIsWorkareaList" parameterType="IsWorkarea" resultMap="IsWorkareaResult">
         <include refid="selectIsWorkareaVo"/>
-        <where>  
+        <where>
             <if test="workareaCode != null  and workareaCode != ''"> and workarea_code = #{workareaCode}</if>
             <if test="workareaName != null  and workareaName != ''"> and workarea_name like concat('%', #{workareaName}, '%')</if>
             <if test="workareaType != null  and workareaType != ''"> and workarea_type = #{workareaType}</if>
@@ -32,12 +32,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="map != null  and map != ''"> and map = #{map}</if>
         </where>
     </select>
-    
+
     <select id="selectIsWorkareaByWorkareaId" parameterType="Long" resultMap="IsWorkareaResult">
         <include refid="selectIsWorkareaVo"/>
         where workarea_id = #{workareaId}
     </select>
-        
+
     <insert id="insertIsWorkarea" parameterType="IsWorkarea" useGeneratedKeys="true" keyProperty="workareaId">
         insert into is_workarea
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -88,9 +88,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteIsWorkareaByWorkareaIds" parameterType="String">
-        delete from is_workarea where workarea_id in 
+        delete from is_workarea where workarea_id in
         <foreach item="workareaId" collection="array" open="(" separator="," close=")">
             #{workareaId}
         </foreach>
     </delete>
-</mapper>
+
+    <select id="getIsWorkareaPage" resultType="com.ktg.iscs.domain.vo.workarea.PageWorkareaVO">
+        SELECT
+            w.*,
+            s.workshop_name
+        FROM
+            is_workarea w
+            LEFT JOIN md_workshop s ON s.workshop_id = w.workshop_id
+        <where>
+            <if test="dto.workareaCode != null and dto.workareaCode.trim != ''">
+                and w.workarea_code like concat('%',#{dto.workareaCode},'%')
+            </if>
+            <if test="dto.workareaName != null and dto.workareaName.trim != ''">
+                and w.workarea_name like concat('%',#{dto.workareaName},'%')
+            </if>
+            <if test="dto.workareaType != null and dto.workareaType.trim != ''">
+                and w.workarea_type = #{dto.workareaType}
+            </if>
+            <if test="dto.workshopId != null">
+                and w.workshop_id = #{dto.workshopId}
+            </if>
+        </where>
+            order by workarea_id desc
+    </select>
+
+</mapper>