Jelajahi Sumber

增加分选的检查指导项目

ezhizao 1 tahun lalu
induk
melakukan
048ca6977a

+ 138 - 0
src/main/java/cn/ezhizao/project/business/controller/BizInspectionInstructionController.java

@@ -0,0 +1,138 @@
+package cn.ezhizao.project.business.controller;
+
+import cn.ezhizao.framework.aspectj.lang.annotation.Log;
+import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
+import cn.ezhizao.framework.web.controller.BaseController;
+import cn.ezhizao.framework.web.domain.AjaxResult;
+import cn.ezhizao.framework.web.page.TableDataInfo;
+import cn.ezhizao.project.business.domain.BizInspectionCategory;
+import cn.ezhizao.project.business.domain.BizInspectionInstruction;
+import cn.ezhizao.project.business.service.IBizInspectionCategoryService;
+import cn.ezhizao.project.business.service.IBizInspectionInstructionService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * 检查指导书Controller
+ *
+ * @author ezhizao
+ * 日期 2023-11-14
+ */
+@RestController
+@RequestMapping("/business/inspectionInstruction")
+public class BizInspectionInstructionController extends BaseController {
+    @Resource
+    private IBizInspectionInstructionService iBizInspectionInstructionService;
+    @Resource
+    private IBizInspectionCategoryService iBizInspectionCategoryService;
+    @Resource
+    private HttpServletRequest request;
+
+    @PostMapping("/listCategory")
+    public TableDataInfo listCategory(@RequestBody Map<String, Object> data) throws NoSuchFieldException, IllegalAccessException {
+        String tenantId = request.getHeader("tenantId");
+        QueryWrapper<BizInspectionCategory> queryWrapper = new QueryWrapper<>();
+        if (tenantId != null && !"0".equals(tenantId)) {
+            queryWrapper.eq("tenant_id", Long.valueOf(tenantId));
+        }
+        if (data.get("type") != null && !"0".equals(data.get("type").toString())) {
+            int type = Integer.parseInt(data.get("type").toString());
+            queryWrapper.eq("type", type);
+        }
+
+        List<BizInspectionCategory> list = iBizInspectionCategoryService.list(queryWrapper);
+        List<BizInspectionCategory> resultList = iBizInspectionCategoryService.recursionList(list, 0);
+        return getDataTable(resultList);
+
+    }
+
+    /**
+     * 获取检查指导书类别详细信息
+     */
+    @GetMapping(value = "/getCategoryInfo/{id}")
+    public AjaxResult getCategoryInfo(@PathVariable("id") Long id) {
+        String tenantId = request.getHeader("tenantId");
+        Integer zero = 0;
+        QueryWrapper<BizInspectionCategory> queryWrapper = new QueryWrapper<>();
+        // 获取所有一级类别
+        queryWrapper.eq("tenant_id", Long.valueOf(tenantId))
+                    .eq("parent_id", zero);
+        List<BizInspectionCategory> categoryList = iBizInspectionCategoryService.list(queryWrapper);
+        BizInspectionCategory bizInspectionCategory = iBizInspectionCategoryService.getById(id);
+        Map<String, Object> map = new HashMap<>(3);
+        map.put("formData", bizInspectionCategory);
+        map.put("parentOptions", iBizInspectionCategoryService.getCategoryOptions(categoryList));
+        return success(map);
+    }
+
+    /**
+     * 新增检查指导书类别
+     */
+    @Log(title = "检查指导书类别", businessType = BusinessType.INSERT)
+    @PostMapping(value = "/saveCategory")
+    public AjaxResult saveCategory(@RequestBody BizInspectionCategory bizInspectionCategory) throws NoSuchFieldException, IllegalAccessException {
+        final String tenantId = request.getHeader("tenantId");
+        bizInspectionCategory.setTenantId(Long.valueOf(tenantId));
+        return toAjax(iBizInspectionCategoryService.saveOrUpdate(bizInspectionCategory));
+    }
+
+    /**
+     * 删除检查指导书类别
+     */
+    @Log(title = "检查指导书类别", businessType = BusinessType.DELETE)
+    @DeleteMapping("/removeCategory/{ids}")
+    public AjaxResult removeCategory(@PathVariable List<Long> ids) {
+        List<BizInspectionInstruction> instructions = iBizInspectionInstructionService.query().in("category_id", ids).list();
+        if (!instructions.isEmpty()) {
+            return AjaxResult.error("该类别下存在检查指导书,不能删除");
+        }
+        return toAjax(iBizInspectionCategoryService.removeBatchByIds(ids));
+    }
+
+    /************************************************ 检查指导书 ************************************************/
+    @PostMapping("/list")
+    public TableDataInfo list(@RequestBody Map<String, Object> data) throws NoSuchFieldException, IllegalAccessException, JsonProcessingException {
+        // 分页
+        startPage();
+        List<BizInspectionInstruction> list = iBizInspectionInstructionService.getList(data);
+        return getDataTable(list);
+    }
+
+    /**
+     * 获取检查指导书详细信息
+     */
+    @GetMapping(value = "/getInfo/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
+        return success(iBizInspectionInstructionService.getById(id));
+    }
+
+    /**
+     * 新增检查指导书
+     */
+    @Log(title = "检查指导书", businessType = BusinessType.INSERT)
+    @PostMapping(value = "/save")
+    public AjaxResult save(@RequestBody BizInspectionInstruction bizInspectionInstruction) throws NoSuchFieldException, IllegalAccessException {
+        final String tenantId = request.getHeader("tenantId");
+        bizInspectionInstruction.setTenantId(Long.valueOf(tenantId));
+        return toAjax(iBizInspectionInstructionService.saveOrUpdate(bizInspectionInstruction));
+    }
+
+    /**
+     * 删除检查指导书
+     */
+    @PreAuthorize("@ss.hasPermi('business:carrier:remove')")
+    @Log(title = "检查指导书", businessType = BusinessType.DELETE)
+    @DeleteMapping("/remove/{ids}")
+    public AjaxResult remove(@PathVariable List<Long> ids) {
+        return toAjax(iBizInspectionInstructionService.removeBatchByIds(ids));
+    }
+}

+ 44 - 0
src/main/java/cn/ezhizao/project/business/domain/BizInspectionCategory.java

@@ -0,0 +1,44 @@
+package cn.ezhizao.project.business.domain;
+
+import cn.ezhizao.framework.web.domain.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 企业租户对象 biz_carrier_category
+ *
+ * @author ezhizao
+ * @date 2024-03-18
+ */
+@Data
+@TableName(value = "biz_inspection_category")
+public class BizInspectionCategory extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "租户id")
+    private Long tenantId;
+
+    @ApiModelProperty(value = "1:分选标准;2:检查指导书;")
+    private Integer type;
+
+    @ApiModelProperty(value = "父级类别id")
+    private Long parentId;
+
+    @ApiModelProperty(value = "类别名称")
+    private String name;
+
+    @ApiModelProperty(value = "类别排序")
+    private Integer sort;
+
+    /* ********************************************* 虚字段 ********************************************* */
+
+    /** 子类别 */
+    @TableField(exist = false)
+    private List<BizInspectionCategory> children;
+
+}

+ 38 - 0
src/main/java/cn/ezhizao/project/business/domain/BizInspectionInstruction.java

@@ -0,0 +1,38 @@
+package cn.ezhizao.project.business.domain;
+
+import cn.ezhizao.framework.web.domain.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 企业租户对象 biz_carrier_category
+ *
+ * @author ezhizao
+ * @date 2024-03-18
+ */
+@Data
+@TableName(value = "biz_inspection_instruction")
+public class BizInspectionInstruction extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "租户id")
+    private Long tenantId;
+
+    @ApiModelProperty(value = "1:分选标准;2:检查指导书;")
+    private Integer type;
+
+    @ApiModelProperty(value = "类别id")
+    private Long categoryId;
+
+    @ApiModelProperty(value = "检查标准")
+    private String standard;
+
+    @ApiModelProperty(value = "检查仪器设备(用于检查指导书)")
+    private String equipment;
+
+    @ApiModelProperty(value = "排序")
+    private Integer sort;
+
+}

+ 24 - 0
src/main/java/cn/ezhizao/project/business/domain/InspectionCategoryOptions.java

@@ -0,0 +1,24 @@
+package cn.ezhizao.project.business.domain;
+
+import lombok.Data;
+
+import java.util.List;
+
+
+/**
+ * 设备类别对象 biz_carrier_category
+ *
+ * @author ezhizao
+ * @date 2023-11-14
+ */
+@Data
+public class InspectionCategoryOptions {
+    /** 文本 */
+    private String label;
+
+    /** 值 */
+    private String value;
+
+    /** 子类别 */
+    private List<InspectionCategoryOptions> children;
+}

+ 21 - 0
src/main/java/cn/ezhizao/project/business/mapper/BizInspectionCategoryMapper.java

@@ -0,0 +1,21 @@
+package cn.ezhizao.project.business.mapper;
+
+import cn.ezhizao.project.business.domain.BizInspectionCategory;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 检查指导书类别Mapper接口
+ *
+ * @author zhuangdezheng
+ * @date 2024-04-22
+ */
+public interface BizInspectionCategoryMapper extends BaseMapper<BizInspectionCategory> {
+
+    /**
+     * 物理删除
+     * @param bizInspectionCategory 待删除的数据
+     * @return 删除结果
+     */
+    public int physicalDelete(BizInspectionCategory bizInspectionCategory);
+
+}

+ 32 - 0
src/main/java/cn/ezhizao/project/business/mapper/BizInspectionInstructionMapper.java

@@ -0,0 +1,32 @@
+package cn.ezhizao.project.business.mapper;
+
+import cn.ezhizao.project.business.domain.BizInspectionInstruction;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 检查指导书Mapper接口
+ *
+ * @author zhuangdezheng
+ * @date 2024-04-22
+ */
+public interface BizInspectionInstructionMapper extends BaseMapper<BizInspectionInstruction> {
+
+    /**
+     * 查询企业租户列表
+     *
+     * @param data 企业租户
+     * @return 企业租户集合
+     */
+    public List<BizInspectionInstruction> getList(Map<String, Object> data);
+
+    /**
+     * 物理删除
+     *
+     * @param bizInspectionInstruction 载具信息
+     * @return 删除结果
+     */
+    public int physicalDelete(BizInspectionInstruction bizInspectionInstruction);
+}

+ 30 - 0
src/main/java/cn/ezhizao/project/business/service/IBizInspectionCategoryService.java

@@ -0,0 +1,30 @@
+package cn.ezhizao.project.business.service;
+
+import cn.ezhizao.project.business.domain.BizInspectionCategory;
+import cn.ezhizao.project.business.domain.InspectionCategoryOptions;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+ * 检查指导书类别Service接口
+ *
+ * @author zhuangdezheng
+ * @date 2024-04-22
+ */
+public interface IBizInspectionCategoryService extends IService<BizInspectionCategory> {
+    /**
+     * 物理删除
+     *
+     * @param bizInspectionCategory 待删除
+     * @return 删除结果
+     */
+    int physicalDelete(BizInspectionCategory bizInspectionCategory);
+    List<InspectionCategoryOptions> getCategoryOptions(List<BizInspectionCategory> list);
+
+    /**
+     * 获取子类别
+     * @param list 类别列表
+     */
+    List<BizInspectionCategory> recursionList(List<BizInspectionCategory> list, long parentId);
+}

+ 31 - 0
src/main/java/cn/ezhizao/project/business/service/IBizInspectionInstructionService.java

@@ -0,0 +1,31 @@
+package cn.ezhizao.project.business.service;
+
+import cn.ezhizao.project.business.domain.BizInspectionInstruction;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 检查指导书Service接口
+ *
+ * @author zhuangdezheng
+ * @date 2024-04-22
+ */
+public interface IBizInspectionInstructionService extends IService<BizInspectionInstruction> {
+    /**
+     * 查询检测指导书列表
+     *
+     * @param data 查询条件
+     * @return 检测指导书集合
+     */
+    List<BizInspectionInstruction> getList(Map<String, Object> data);
+
+    /**
+     * 物理删除
+     *
+     * @param bizInspectionInstruction 待删除
+     * @return 删除结果
+     */
+    int physicalDelete(BizInspectionInstruction bizInspectionInstruction);
+}

+ 93 - 0
src/main/java/cn/ezhizao/project/business/service/impl/BizInspectionCategoryServiceImpl.java

@@ -0,0 +1,93 @@
+package cn.ezhizao.project.business.service.impl;
+
+import cn.ezhizao.project.business.domain.BizInspectionCategory;
+import cn.ezhizao.project.business.domain.InspectionCategoryOptions;
+import cn.ezhizao.project.business.mapper.BizInspectionCategoryMapper;
+import cn.ezhizao.project.business.mapper.BizInspectionInstructionMapper;
+import cn.ezhizao.project.business.service.IBizInspectionCategoryService;
+import cn.ezhizao.project.business.service.IBizInspectionInstructionService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 检查指导书类别Service业务层处理
+ *
+ * @author zhuangdezheng
+ * @date 2024-04-22
+ */
+@Service
+public class BizInspectionCategoryServiceImpl extends ServiceImpl<BizInspectionCategoryMapper, BizInspectionCategory> implements IBizInspectionCategoryService {
+    @Resource
+    private BizInspectionCategoryMapper bizInspectionCategoryMapper;
+
+    /**
+     * 物理删除
+     *
+     * @return 删除结果
+     */
+    @Override
+    public int physicalDelete(BizInspectionCategory bizInspectionCategory) {
+        return bizInspectionCategoryMapper.physicalDelete(bizInspectionCategory);
+    }
+
+
+    /**
+     * 返回类别的选项
+     * @param list 类别列表
+     * @return 选项集合
+     */
+    @Override
+    public List<InspectionCategoryOptions> getCategoryOptions(List<BizInspectionCategory> list) {
+        List<InspectionCategoryOptions> options = new ArrayList<>();
+        // 循环List
+        for (BizInspectionCategory item : list) {
+            InspectionCategoryOptions option = new InspectionCategoryOptions();
+            option.setLabel(item.getName());
+            option.setValue(item.getId().toString());
+
+            QueryWrapper<BizInspectionCategory> queryWrapper = new QueryWrapper<>();
+            // 获取所有一级类别
+            queryWrapper.eq("deleted", 0)
+                    .eq("parent_id", item.getId());
+            // 获取子类别
+            List<BizInspectionCategory> childrenCategories = bizInspectionCategoryMapper.selectList(queryWrapper);
+            if (!childrenCategories.isEmpty()) {
+                option.setChildren(getCategoryOptions(childrenCategories));
+            }
+            options.add(option);
+        }
+
+        return options;
+    }
+
+    /**
+     * 递归获取子类别
+     */
+    @Override
+    public List<BizInspectionCategory> recursionList(List<BizInspectionCategory> list, long parentId) {
+        List<BizInspectionCategory> resultList = list.stream()
+                .filter(item -> item.getParentId().equals(parentId))
+                .sorted(Comparator.comparing(BizInspectionCategory::getSort))
+                .collect(Collectors.toList());
+
+        for (BizInspectionCategory item : resultList) {
+            QueryWrapper<BizInspectionCategory> queryWrapper = new QueryWrapper<>();
+            // 获取所有一级类别
+            queryWrapper.eq("parent_id", item.getId());
+            // 获取子类别
+            List<BizInspectionCategory> children = recursionList(list, item.getId());
+            if (!children.isEmpty()) {
+                item.setChildren(children);
+            }
+        }
+
+        return resultList;
+    }
+}

+ 45 - 0
src/main/java/cn/ezhizao/project/business/service/impl/BizInspectionInstructionServiceImpl.java

@@ -0,0 +1,45 @@
+package cn.ezhizao.project.business.service.impl;
+
+import cn.ezhizao.project.business.domain.BizInspectionInstruction;
+import cn.ezhizao.project.business.mapper.BizInspectionInstructionMapper;
+import cn.ezhizao.project.business.service.IBizInspectionInstructionService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 检查指导书Service业务层处理
+ *
+ * @author zhuangdezheng
+ * @date 2024-04-22
+ */
+@Service
+public class BizInspectionInstructionServiceImpl extends ServiceImpl<BizInspectionInstructionMapper, BizInspectionInstruction> implements IBizInspectionInstructionService {
+    @Resource
+    private BizInspectionInstructionMapper bizInspectionInstructionMapper;
+
+    /**
+     * 查询检测指导书列表
+     *
+     * @param data 查询条件
+     * @return 检测指导书集合
+     */
+    @Override
+    public List<BizInspectionInstruction> getList(Map<String, Object> data)
+    {
+        return bizInspectionInstructionMapper.getList(data);
+    }
+
+    /**
+     * 物理删除
+     *
+     * @return 删除结果
+     */
+    @Override
+    public int physicalDelete(BizInspectionInstruction bizInspectionInstruction) {
+        return bizInspectionInstructionMapper.physicalDelete(bizInspectionInstruction);
+    }
+}

+ 19 - 0
src/main/resources/mybatis/business/BizInspectionCategoryMapper.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.ezhizao.project.business.mapper.BizInspectionCategoryMapper">
+
+    <resultMap type="cn.ezhizao.project.business.domain.BizInspectionCategory" id="BizInspectionCategoryResult">
+        <id column="id" property="id"/>
+    </resultMap>
+
+    <delete id="physicalDelete">
+        DELETE FROM biz_inspection_category
+        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
+            <if test="id != null">
+                id = #{id} AND
+            </if>
+        </trim>
+    </delete>
+</mapper>

+ 30 - 0
src/main/resources/mybatis/business/BizInspectionInstructionMapper.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.ezhizao.project.business.mapper.BizInspectionInstructionMapper">
+
+    <resultMap type="cn.ezhizao.project.business.domain.BizInspectionInstruction" id="BizInspectionInstructionResult">
+        <id column="id" property="id"/>
+    </resultMap>
+
+    <select id="getList" resultMap="BizInspectionInstructionResult" parameterType="cn.ezhizao.project.business.domain.BizInspectionInstruction">
+        SELECT t1.*
+        FROM biz_inspection_instruction t1
+        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
+            deleted = 0
+            <if test="type != null and type != 0"> AND type = #{type}</if>
+            <if test="categoryId != null and categoryId != '0'"> AND category_id = #{categoryId}</if>
+            <if test="keywords != null and keywords != ''"> AND standard LIKE CONCAT('%', #{keywords}, '%')</if>
+
+        </trim>
+
+    </select>
+
+    <delete id="physicalDelete">
+        DELETE FROM biz_inspection_instruction WHERE deleted = 0
+        <if test="id != null">
+            AND id = #{id}
+        </if>
+    </delete>
+</mapper>