master
zhaodw 5 months ago
parent c657b26bb0
commit 71a599ece4

Binary file not shown.

@ -10,6 +10,7 @@ import com.ruoyi.project.project.cases.domain.Case;
import com.ruoyi.project.project.cases.service.ICaseService;
import com.ruoyi.project.project.item.domain.Item;
import com.ruoyi.project.project.item.service.IItemService;
import com.ruoyi.project.project.util.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -32,6 +33,9 @@ public class CaseController extends BaseController
@Autowired
private ICaseService caseService;
@Autowired
private IItemService itemService;
@RequiresPermissions("system:case:view")
@GetMapping()
public String cases()
@ -70,6 +74,18 @@ public class CaseController extends BaseController
@ResponseBody
public AjaxResult addSave(Case cases)
{
int i = caseService.selectCaseByCaseNo(cases.getCaseNo());
if(i != 0){
return error("案件编号重复,请检查!!!!");
}
boolean phone = ValidatorUtils.isValidPhone(cases.getPhone());
if (!phone){
return error("手机号格式错误请检查,请检查!!!!");
}
boolean userNo = ValidatorUtils.isValidIdCard(cases.getUserNo());
if (!userNo){
return error("身份证号格式错误请检查,请检查!!!!");
}
return toAjax(caseService.insertCase(cases));
}
@ -93,10 +109,10 @@ public class CaseController extends BaseController
*
*/
@RequiresPermissions("system:case:edit")
@GetMapping("/edit/{caseNo}")
public String edit(@PathVariable("caseNo") String caseNo, ModelMap mmap)
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Integer id, ModelMap mmap)
{
mmap.put("case", caseService.selectCaseById(caseNo));
mmap.put("case", caseService.selectCaseById(id));
return prefix + "/edit";
}
@ -109,6 +125,14 @@ public class CaseController extends BaseController
@ResponseBody
public AjaxResult editSave(Case cases)
{
boolean phone = ValidatorUtils.isValidPhone(cases.getPhone());
if (!phone){
return error("手机号格式错误请检查,请检查!!!!");
}
boolean userNo = ValidatorUtils.isValidIdCard(cases.getUserNo());
if (!userNo){
return error("身份证号格式错误请检查,请检查!!!!");
}
return toAjax(caseService.updateCase(cases));
}
@ -121,6 +145,16 @@ public class CaseController extends BaseController
@ResponseBody
public AjaxResult remove(String ids)
{
//查询是否有物品信息
String[] idStr = ids.split(",");
for (String id : idStr) {
Case acase = caseService.selectCaseById(Integer.parseInt(id));
int i = itemService.selectItemByCaseId(id);
if (i != 0){
return error(acase.getCaseNo()+"案件中存在物品,请先删除物品!!!");
}
}
return toAjax(caseService.deleteCaseByIds(ids));
}

@ -19,6 +19,9 @@ public class Case extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Integer id;
/** 案件编号 */
private String caseNo;

@ -14,10 +14,10 @@ public interface CaseMapper
/**
*
*
* @param caseNo
* @param id
* @return
*/
public Case selectCaseById(String caseNo);
public Case selectCaseById(Integer id);
/**
*
@ -47,8 +47,10 @@ public interface CaseMapper
/**
*
*
* @param caseNos ID
* @param ids ID
* @return
*/
public int deleteCaseByIds(String[] caseNos);
public int deleteCaseByIds(Integer[] ids);
int selectCaseByCaseNo(String caseNo);
}

@ -24,13 +24,13 @@ public class CaseServiceImpl implements ICaseService
/**
*
*
* @param caseNo ID
* @param id ID
* @return
*/
@Override
public Case selectCaseById(String caseNo)
public Case selectCaseById(Integer id)
{
return caseMapper.selectCaseById(caseNo);
return caseMapper.selectCaseById(id);
}
/**
@ -80,6 +80,11 @@ public class CaseServiceImpl implements ICaseService
@Override
public int deleteCaseByIds(String ids)
{
return caseMapper.deleteCaseByIds(Convert.toStrArray(ids));
return caseMapper.deleteCaseByIds(Convert.toIntArray(ids));
}
@Override
public int selectCaseByCaseNo(String caseNo) {
return caseMapper.selectCaseByCaseNo(caseNo);
}
}

@ -14,10 +14,10 @@ public interface ICaseService
/**
*
*
* @param caseNo ID
* @param id ID
* @return
*/
public Case selectCaseById(String caseNo);
public Case selectCaseById(Integer id);
/**
*
@ -50,4 +50,6 @@ public interface ICaseService
* @return
*/
public int deleteCaseByIds(String ids);
int selectCaseByCaseNo(String caseNo);
}

@ -74,6 +74,10 @@ public class ItemController extends BaseController
@ResponseBody
public AjaxResult addSave(Item item)
{
int i = itemService.selectItemByItemNo(item);
if (i != 0){
return error("物品编号重复,请检查!!!");
}
return toAjax(itemService.insertItem(item));
}
@ -95,10 +99,10 @@ public class ItemController extends BaseController
*
*/
@RequiresPermissions("system:case:edit")
@GetMapping("/edit/{itemNo}")
public String edit(@PathVariable("itemNo") String itemNo, ModelMap mmap)
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Integer id, ModelMap mmap)
{
mmap.put("item", itemService.selectItemById(itemNo));
mmap.put("item", itemService.selectItemById(id));
return prefix + "/edit";
}
@ -111,6 +115,10 @@ public class ItemController extends BaseController
@ResponseBody
public AjaxResult editSave(Item item)
{
int i = itemService.selectItemByItemNo(item);
if (i != 0){
return error("物品编号重复,请检查!!!");
}
return toAjax(itemService.updateItem(item));
}

@ -19,6 +19,9 @@ public class Item extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Integer id;
/** 案件编号 */
private String caseNo;

@ -14,10 +14,10 @@ public interface ItemMapper
/**
*
*
* @param itemNo
* @param id
* @return
*/
public Item selectItemById(String itemNo);
public Item selectItemById(Integer id);
/**
*
@ -49,8 +49,17 @@ public interface ItemMapper
/**
*
*
* @param itemNos ID
* @param ids ID
* @return
*/
public int deleteItemByIds(String[] itemNos);
public int deleteItemByIds(String[] ids);
/**
*
* @param id
* @return
*/
public int selectItemByCaseId(String id);
int selectItemByItemNo(Item item);
}

@ -14,10 +14,10 @@ public interface IItemService
/**
*
*
* @param itemNo ID
* @param id ID
* @return
*/
public Item selectItemById(String itemNo);
public Item selectItemById(Integer id);
/**
*
@ -52,4 +52,20 @@ public interface IItemService
* @return
*/
public int deleteItemByIds(String ids);
/**
*
* @param id
* @return
*/
public int selectItemByCaseId(String id);
/**
*
* @param item
* @return
*/
int selectItemByItemNo(Item item);
}

@ -22,13 +22,13 @@ public class ItemServiceImpl implements IItemService
/**
*
*
* @param itemNo ID
* @param id ID
* @return
*/
@Override
public Item selectItemById(String itemNo)
public Item selectItemById(Integer id)
{
return itemMapper.selectItemById(itemNo);
return itemMapper.selectItemById(id);
}
/**
@ -85,4 +85,14 @@ public class ItemServiceImpl implements IItemService
{
return itemMapper.deleteItemByIds(Convert.toStrArray(ids));
}
@Override
public int selectItemByCaseId(String id) {
return itemMapper.selectItemByCaseId(id);
}
@Override
public int selectItemByItemNo(Item item) {
return itemMapper.selectItemByItemNo(item);
}
}

@ -0,0 +1,72 @@
package com.ruoyi.project.project.util;
import java.util.regex.Pattern;
/**
* ClassName: ValidatorUtils
* Package: com.ruoyi.project.project.util
* Description:
*
* @Author zhaodw
* @Create 2025/7/11 17:08
* @Version 1.0
*/
public class ValidatorUtils {
// 手机号正则(中国大陆)
private static final Pattern PHONE_PATTERN = Pattern.compile(
"^1[3-9]\\d{9}$"
);
// 18位身份证号正则包含校验码验证
private static final Pattern ID_CARD_PATTERN = Pattern.compile(
"^[1-9]\\d{5}(18|19|20)\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])\\d{3}[0-9Xx]$"
);
// 身份证号校验码权重因子
private static final int[] WEIGHTS = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
// 身份证号校验码对应表
private static final char[] CHECK_CODES = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};
/**
*
* @param phone
* @return
*/
public static boolean isValidPhone(String phone) {
if (phone == null || phone.isEmpty()) {
return false;
}
return PHONE_PATTERN.matcher(phone).matches();
}
/**
*
* @param idCard
* @return
*/
public static boolean isValidIdCard(String idCard) {
if (idCard == null || idCard.isEmpty()) {
return false;
}
// 长度校验
if (idCard.length() != 18) {
return false;
}
// 格式校验
if (!ID_CARD_PATTERN.matcher(idCard).matches()) {
return false;
}
// 校验码验证
char[] chars = idCard.toUpperCase().toCharArray();
int sum = 0;
for (int i = 0; i < 17; i++) {
sum += (chars[i] - '0') * WEIGHTS[i];
}
int mod = sum % 11;
return chars[17] == CHECK_CODES[mod];
}
}

@ -5,6 +5,7 @@
<mapper namespace="com.ruoyi.project.project.cases.mapper.CaseMapper">
<resultMap type="Case" id="CaseResult">
<result property="id" column="id" />
<result property="caseNo" column="case_no" />
<result property="name" column="name" />
<result property="userNo" column="user_no" />
@ -19,13 +20,13 @@
</resultMap>
<sql id="selectCaseVo">
select case_no, name, user_no, sex, age, position, department, rank, phone, filing_time, creat_time
select id,case_no, name, user_no, sex, age, position, department, rank, phone, filing_time, creat_time
from cases
</sql>
<select id="selectCaseById" parameterType="String" resultMap="CaseResult">
<select id="selectCaseById" parameterType="integer" resultMap="CaseResult">
<include refid="selectCaseVo"/>
where case_no = #{caseNo}
where id = #{id}
</select>
<select id="selectCaseList" parameterType="Case" resultMap="CaseResult">
@ -38,6 +39,7 @@
AND name like '%'||#{name}||'%' <!-- concat('%', #{createBy}, '%') -->
</if>
</where>
order by id desc
</select>
<insert id="insertCase" parameterType="Case">
@ -71,6 +73,7 @@
<update id="updateCase" parameterType="Case">
update cases
<set>
<if test="caseNo != null and name != ''">case_No = #{caseNo}, </if>
<if test="name != null and name != ''">name = #{name}, </if>
<if test="userNo != null and userNo != ''">user_no = #{userNo}, </if>
<if test="sex != null">sex = #{sex}, </if>
@ -81,14 +84,17 @@
<if test="phone != null and phone != ''">phone = #{phone},</if>
<if test="filingTime != null and filingTime != ''">filing_time = #{filingTime}</if>
</set>
where case_no = #{caseNo}
where id = #{id}
</update>
<delete id="deleteCaseByIds" parameterType="String">
delete from cases where case_no in
<foreach item="caseNo" collection="array" open="(" separator="," close=")">
#{caseNo}
delete from cases where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectCaseByCaseNo" parameterType="string" resultType="integer">
select count(*) from cases where case_no = #{caseNo}
</select>
</mapper>

@ -5,6 +5,7 @@
<mapper namespace="com.ruoyi.project.project.item.mapper.ItemMapper">
<resultMap type="Item" id="ItemResult">
<result property="id" column="id" />
<result property="caseNo" column="case_no" />
<result property="itemNo" column="item_no" />
<result property="itemType" column="item_type" />
@ -16,13 +17,13 @@
</resultMap>
<sql id="selectItemVo">
select case_no, item_no, item_type, brand, number, price, source, creat_time
select id,case_no, item_no, item_type, brand, number, price, source, creat_time
from item
</sql>
<select id="selectItemById" parameterType="String" resultMap="ItemResult">
<select id="selectItemById" parameterType="Integer" resultMap="ItemResult">
<include refid="selectItemVo"/>
where item_no = #{itemNo}
where id = #{id}
</select>
<select id="selectItemByCaseNo" parameterType="String" resultMap="ItemResult">
@ -64,20 +65,27 @@
<update id="updateItem" parameterType="Item">
update item
<set>
<if test="itemNo != null and itemNo != ''">item_no = #{itemNo}, </if>
<if test="itemType != null and itemType != ''">item_type = #{itemType}, </if>
<if test="brand != null and brand != ''">brand = #{brand}, </if>
<if test="number != null">number = #{number}, </if>
<if test="price != null and price != ''">price = #{price}, </if>
<if test="source != null and source != ''">source = #{source}</if>
</set>
where item_no = #{itemNo}
where id = #{id}
</update>
<delete id="deleteItemByIds" parameterType="String">
delete from item where item_no in
<foreach item="itemNo" collection="array" open="(" separator="," close=")">
#{itemNo}
delete from item where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectItemByCaseId" parameterType="String" resultType="integer">
select COUNT(*) from item where case_no = (SELECT case_no FROM cases where id = #{id})
</select>
<select id="selectItemByItemNo" parameterType="Item" resultType="integer">
select count(*) from item where item_no = #{itemNo} and case_No = #{caseNo}
</select>
</mapper>

@ -63,6 +63,11 @@
modalName: "案件管理",
columns: [{
checkbox: true
},
{
field: 'id',
title: '主键',
visible: false
},
{
field: 'caseNo',
@ -114,8 +119,8 @@
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-info btn-xs ' + listFlag + '" href="javascript:void(0)" onclick="detail(\'' + row.caseNo + '\')"><i class="fa fa-list-ul"></i>物品登记</a> ');
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.caseNo + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.caseNo + '\')"><i class="fa fa-remove"></i>删除</a>');
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
}]

@ -7,10 +7,11 @@
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content" id="app">
<form class="form-horizontal m" id="form-network-add" th:object="${case}">
<input name="id" type="hidden" th:field="*{id}" />
<div class="form-group">
<label class="col-sm-3 control-label is-required">案件编号:</label>
<div class="col-sm-8">
<input name="caseNo" required class="form-control" type="text" th:field="*{caseNo}">
<input name="caseNo" required class="form-control" type="text" readonly="readonly" th:field="*{caseNo}">
</div>
</div>
<div class="form-group">

@ -7,6 +7,7 @@
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content" id="app">
<form class="form-horizontal m" id="form-network-add" th:object="${item}">
<input name="id" type="hidden" th:field="*{id}" />
<div class="form-group">
<label class="col-sm-3 control-label is-required">案件编号:</label>
<div class="col-sm-8">

@ -70,6 +70,11 @@
modalName: "案件管理",
columns: [{
checkbox: true
},
{
field: 'id',
title: '主键',
visible: false
},
{
field: 'caseNo',
@ -107,8 +112,8 @@
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.itemNo + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.itemNo + '\')"><i class="fa fa-remove"></i>删除</a>');
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
}]

Loading…
Cancel
Save