feat(停工停产): 新增基础项配置
parent
61ddf0460c
commit
7695debf57
@ -0,0 +1,63 @@
|
||||
package com.op.common.core.handler;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedJdbcTypes;
|
||||
import org.apache.ibatis.type.MappedTypes;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description: 数组类型读取写入mybatis转换
|
||||
*
|
||||
* @author : huangjinxian
|
||||
* @version : 1.0
|
||||
* @since : 2026/6/25
|
||||
*/
|
||||
@SuppressWarnings({"JavadocDeclaration", "unused", "SpellCheckingInspection"})
|
||||
@MappedTypes(List.class)
|
||||
@MappedJdbcTypes(JdbcType.VARCHAR)
|
||||
public class StringListTypeHandler extends BaseTypeHandler<List<String>> {
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int i, List<String> parameter, JdbcType jdbcType) throws SQLException {
|
||||
if (parameter == null || parameter.isEmpty()) {
|
||||
ps.setString(i, null);
|
||||
} else {
|
||||
// 将 List 转换为逗号分隔的字符串存储
|
||||
ps.setString(i, String.join(",", parameter));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||
String value = rs.getString(columnName);
|
||||
return parse(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
String value = rs.getString(columnIndex);
|
||||
return parse(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||
String value = cs.getString(columnIndex);
|
||||
return parse(value);
|
||||
}
|
||||
|
||||
// 解析数据库中的字符串为 List
|
||||
private List<String> parse(String value) {
|
||||
if (value == null || value.trim().isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Arrays.asList(value.split(","));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
package com.op.technology.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import com.op.common.core.web.domain.AjaxResult;
|
||||
import com.op.common.core.web.page.TableDataInfo;
|
||||
import com.op.common.core.web.controller.BaseController;
|
||||
import com.op.common.log.annotation.Log;
|
||||
import com.op.common.log.enums.BusinessType;
|
||||
import com.op.common.security.annotation.RequiresPermissions;
|
||||
import com.op.technology.domain.ProCheckItem;
|
||||
import com.op.technology.service.IProCheckItemService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 检查项目 Controller
|
||||
*
|
||||
* @author huangjinxian
|
||||
* @date 2026-06-25
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pro/checkItem")
|
||||
@RequiresPermissions("mes:pro:procheck:list")
|
||||
public class ProCheckItemController extends BaseController {
|
||||
@Resource
|
||||
private IProCheckItemService proCheckService;
|
||||
|
||||
/**
|
||||
* 查询检查项目列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(ProCheckItem proCheck) {
|
||||
startPage();
|
||||
List<ProCheckItem> list = proCheckService.selectProCheckItemList(proCheck);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取检查项目详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{itemId}")
|
||||
public AjaxResult getInfo(@PathVariable("itemId") String itemId) {
|
||||
return AjaxResult.success(proCheckService.selectProCheckItemByItemId(itemId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增检查项目
|
||||
*/
|
||||
@Log(title = "检查项目", businessType = BusinessType.INSERT)
|
||||
//@RequiresPermissions("mes:pro:procheck:add")
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ProCheckItem proCheck) {
|
||||
if (proCheckService.selectProCheckItemByItemId(proCheck.getItemId()) != null) {
|
||||
return AjaxResult.error("检查项目已存在!");
|
||||
}
|
||||
return toAjax(proCheckService.insertProCheckItem(proCheck));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改检查项目
|
||||
*/
|
||||
@Log(title = "检查项目", businessType = BusinessType.UPDATE)
|
||||
//@RequiresPermissions("mes:pro:procheck:edit")
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody ProCheckItem proCheckItem) {
|
||||
String itemId = proCheckItem.getItemId();
|
||||
ProCheckItem checkItem = proCheckService.selectProCheckItemByItemId(proCheckItem.getItemId());
|
||||
if (checkItem != null && !checkItem.getItemId().equals(itemId)) {
|
||||
return AjaxResult.error("检查项目已存在!");
|
||||
}
|
||||
return toAjax(proCheckService.updateProCheckItem(proCheckItem));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除检查项目
|
||||
*/
|
||||
@Log(title = "检查项目", businessType = BusinessType.DELETE)
|
||||
//@RequiresPermissions("mes:pro:procheck:remove")
|
||||
@DeleteMapping("/{itemIds}")
|
||||
public AjaxResult remove(@PathVariable String[] itemIds) {
|
||||
return toAjax(proCheckService.deleteProCheckItemByCheckIds(itemIds));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package com.op.technology.domain;
|
||||
|
||||
import com.op.common.core.annotation.Excel;
|
||||
import com.op.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 检查项目对象 pro_check_item
|
||||
*
|
||||
* @author huangjinxian
|
||||
* @date 2026-06-25
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class ProCheckItem extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 检查项目 ID
|
||||
*/
|
||||
private String itemId;
|
||||
//检查项目
|
||||
private String itemName;
|
||||
//检查对象
|
||||
private List<String> checkObject;
|
||||
//排序号
|
||||
private Integer sortOrder;
|
||||
//是否删除
|
||||
Boolean isDel;
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
package com.op.technology.mapper;
|
||||
|
||||
import com.op.technology.domain.ProCheckItem;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 检查项目 Mapper 接口
|
||||
*
|
||||
* @author huangjinxian
|
||||
* @date 2026-06-25
|
||||
*/
|
||||
@Mapper
|
||||
public interface ProCheckItemMapper {
|
||||
|
||||
/**
|
||||
* 根据检查 ID 查询
|
||||
* @param checkId 检查 ID
|
||||
* @return 检查项目
|
||||
*/
|
||||
ProCheckItem selectByItemId(@Param("itemId") String itemId);
|
||||
|
||||
/**
|
||||
* 查询检查项目列表
|
||||
* @param proCheck 检查项目
|
||||
* @return 检查项目集合
|
||||
*/
|
||||
List<ProCheckItem> selectList(ProCheckItem proCheck);
|
||||
|
||||
/**
|
||||
* 新增检查项目
|
||||
* @param proCheck 检查项目
|
||||
* @return 结果
|
||||
*/
|
||||
int insert(ProCheckItem proCheckItem);
|
||||
|
||||
/**
|
||||
* 修改检查项目
|
||||
* @param proCheck 检查项目
|
||||
* @return 结果
|
||||
*/
|
||||
int update(ProCheckItem proCheckItem);
|
||||
|
||||
/**
|
||||
* 根据检查 ID 删除
|
||||
* @param checkId 检查 ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteByItemId(@Param("itemId") String itemId);
|
||||
|
||||
/**
|
||||
* 批量删除检查项目
|
||||
* @param checkIds 需要删除的检查 ID 集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteByItemIds(@Param("itemIds") String[] itemIds);
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package com.op.technology.service;
|
||||
|
||||
import com.op.technology.domain.ProCheckItem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 检查项目 Service 接口
|
||||
*
|
||||
* @author huangjinxian
|
||||
* @date 2026-06-25
|
||||
*/
|
||||
public interface IProCheckItemService {
|
||||
/**
|
||||
* 查询检查项目
|
||||
*
|
||||
* @param checkId 检查项目主键
|
||||
* @return 检查项目
|
||||
*/
|
||||
ProCheckItem selectProCheckItemByItemId(String checkId);
|
||||
|
||||
/**
|
||||
* 查询检查项目列表
|
||||
*
|
||||
* @param proCheck 检查项目
|
||||
* @return 检查项目集合
|
||||
*/
|
||||
List<ProCheckItem> selectProCheckItemList(ProCheckItem proCheck);
|
||||
|
||||
/**
|
||||
* 新增检查项目
|
||||
*
|
||||
* @param proCheck 检查项目
|
||||
* @return 结果
|
||||
*/
|
||||
int insertProCheckItem(ProCheckItem proCheck);
|
||||
|
||||
/**
|
||||
* 修改检查项目
|
||||
*
|
||||
* @param proCheck 检查项目
|
||||
* @return 结果
|
||||
*/
|
||||
int updateProCheckItem(ProCheckItem proCheck);
|
||||
|
||||
/**
|
||||
* 批量删除检查项目
|
||||
*
|
||||
* @param checkIds 需要删除的检查项目主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteProCheckItemByCheckIds(String[] checkIds);
|
||||
|
||||
/**
|
||||
* 删除检查项目信息
|
||||
*
|
||||
* @param checkId 检查项目主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteProCheckItemByCheckId(String checkId);
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
package com.op.technology.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.op.technology.domain.ProCheckItem;
|
||||
import com.op.technology.mapper.ProCheckItemMapper;
|
||||
import com.op.technology.service.IProCheckItemService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 检查项目 Service 业务层处理
|
||||
*
|
||||
* @author huangjinxian
|
||||
* @date 2026-06-25
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ProCheckItemServiceImpl implements IProCheckItemService {
|
||||
final ProCheckItemMapper proCheckItemMapper;
|
||||
|
||||
/**
|
||||
* 查询检查项目
|
||||
*
|
||||
* @param itemId 检查项目主键
|
||||
* @return 检查项目
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public ProCheckItem selectProCheckItemByItemId(String itemId) {
|
||||
return proCheckItemMapper.selectByItemId(itemId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询检查项目列表
|
||||
*
|
||||
* @param proCheck 检查项目
|
||||
* @return 检查项目集合
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public List<ProCheckItem> selectProCheckItemList(ProCheckItem proCheck) {
|
||||
return proCheckItemMapper.selectList(proCheck);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增检查项目
|
||||
*
|
||||
* @param proCheck 检查项目
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public int insertProCheckItem(ProCheckItem proCheck) {
|
||||
return proCheckItemMapper.insert(proCheck);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改检查项目
|
||||
*
|
||||
* @param proCheck 检查项目
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public int updateProCheckItem(ProCheckItem proCheck) {
|
||||
if (proCheck.getItemId() == null) {
|
||||
return -1;
|
||||
}
|
||||
return proCheckItemMapper.update(proCheck);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除检查项目
|
||||
*
|
||||
* @param itemIds 需要删除的检查项目主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public int deleteProCheckItemByCheckIds(String[] itemIds) {
|
||||
return proCheckItemMapper.deleteByItemIds(itemIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除检查项目信息
|
||||
*
|
||||
* @param itemId 检查项目主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public int deleteProCheckItemByCheckId(String itemId) {
|
||||
return proCheckItemMapper.deleteByItemId(itemId);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,87 @@
|
||||
<?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="com.op.technology.mapper.ProCheckItemMapper">
|
||||
|
||||
<resultMap type="com.op.technology.domain.ProCheckItem" id="ProCheckResult">
|
||||
<result property="itemId" column="item_id"/>
|
||||
<result property="itemName" column="item_name"/>
|
||||
<result property="checkObject" column="check_object"/>
|
||||
<result property="sortOrder" column="sort_order"/>
|
||||
<result property="isDel" column="is_del"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectProCheckVo">
|
||||
select item_id, item_name, check_object, sort_order, is_del
|
||||
from pro_check_item
|
||||
</sql>
|
||||
|
||||
<select id="selectList" parameterType="com.op.technology.domain.ProCheckItem"
|
||||
resultMap="ProCheckResult">
|
||||
<include refid="selectProCheckVo"/>
|
||||
<where>
|
||||
<if test="itemName != null and itemName != ''">
|
||||
and item_name like concat('%', #{itemName}, '%')
|
||||
</if>
|
||||
<if test="sortOrder != null">
|
||||
and sort_order = #{sortOrder}
|
||||
</if>
|
||||
|
||||
<choose>
|
||||
<when test="isDel != null">
|
||||
and is_del = #{isDel}
|
||||
</when>
|
||||
<otherwise>
|
||||
and is_del = 0
|
||||
</otherwise>
|
||||
</choose>
|
||||
</where>
|
||||
order by sort_order desc
|
||||
</select>
|
||||
|
||||
<select id="selectByItemId"
|
||||
parameterType="String"
|
||||
resultMap="ProCheckResult">
|
||||
<include refid="selectProCheckVo"/>
|
||||
where item_id = #{itemId} AND is_del = 0
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.op.technology.domain.ProCheckItem">
|
||||
insert into pro_check_item
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="itemName != null and itemName != ''">item_name,</if>
|
||||
<if test="checkObject != null and !checkObject.isEmpty()">check_object,</if>
|
||||
<if test="sortOrder != null">sort_order,</if>
|
||||
<if test="isDel != null">is_del,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="itemName != null and itemName != ''">#{itemName},</if>
|
||||
<if test="checkObject != null and !checkObject.isEmpty()">#{checkObject},</if>
|
||||
<if test="sortOrder != null">#{sortOrder},</if>
|
||||
<if test="isDel != null">#{isDel},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="com.op.technology.domain.ProCheckItem">
|
||||
update pro_check_item
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="itemName != null and itemName != ''">item_name = #{itemName},</if>
|
||||
<if test="checkObject != null">check_object = #{checkObject},</if>
|
||||
<if test="sortOrder != null">sort_order = #{sortOrder},</if>
|
||||
<if test="isDel != null">is_del = #{isDel},</if>
|
||||
</trim>
|
||||
where item_id = #{itemId}
|
||||
</update>
|
||||
|
||||
<update id="deleteByItemId" parameterType="String">
|
||||
update pro_check_item set is_del = 1 where item_id = #{itemId}
|
||||
</update>
|
||||
|
||||
<update id="deleteByItemIds" parameterType="String">
|
||||
update pro_check_item set is_del = 1 where item_id in
|
||||
<foreach item="itemId" collection="itemIds" open="(" separator="," close=")">
|
||||
#{itemId}
|
||||
</foreach>
|
||||
</update>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue