From a4f1e1a9b97f7606347ba1b6a5c5957c3fc28a59 Mon Sep 17 00:00:00 2001
From: heheng <475597332@qq.com>
Date: 星期三, 15 十月 2025 13:28:37 +0800
Subject: [PATCH] 功能改造
---
gkhy-system/src/main/java/com/gkhy/system/domain/DailySafetyInspectionDept.java | 41 ++++++++++
gkhy-system/src/main/resources/mapper/system/DailySafetyInspectionMapper.xml | 119 ++++++++++++++++++-----------
gkhy-system/src/main/java/com/gkhy/system/service/impl/DailySafetyInspectionServiceImpl.java | 34 ++++++--
gkhy-system/src/main/java/com/gkhy/system/domain/DailySafetyInspection.java | 7 +
gkhy-system/src/main/java/com/gkhy/system/mapper/DailySafetyInspectionDeptMapper.java | 20 +++++
gkhy-system/src/main/resources/mapper/system/DailySafetyInspectionDeptMapper.xml | 5 +
gkhy-admin/src/main/java/com/gkhy/web/controller/system/SysProfileController.java | 2
7 files changed, 173 insertions(+), 55 deletions(-)
diff --git a/gkhy-admin/src/main/java/com/gkhy/web/controller/system/SysProfileController.java b/gkhy-admin/src/main/java/com/gkhy/web/controller/system/SysProfileController.java
index 09c8767..1275395 100644
--- a/gkhy-admin/src/main/java/com/gkhy/web/controller/system/SysProfileController.java
+++ b/gkhy-admin/src/main/java/com/gkhy/web/controller/system/SysProfileController.java
@@ -86,7 +86,7 @@
* 重置密码
*/
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
- @PutMapping("/updatePwd")
+ @PostMapping("/updatePwd")
public AjaxResult updatePwd(@RequestBody Map<String, String> params)
{
String oldPassword = params.get("oldPassword");
diff --git a/gkhy-system/src/main/java/com/gkhy/system/domain/DailySafetyInspection.java b/gkhy-system/src/main/java/com/gkhy/system/domain/DailySafetyInspection.java
index b88ad23..c69d484 100644
--- a/gkhy-system/src/main/java/com/gkhy/system/domain/DailySafetyInspection.java
+++ b/gkhy-system/src/main/java/com/gkhy/system/domain/DailySafetyInspection.java
@@ -56,11 +56,10 @@
@ApiModelProperty(value = "被检查部门/研究组",required = true)
@TableField("research_group")
- @NotNull(message = "被检查部门/研究组不能为空")
private Long researchGroup;
@TableField(exist = false)
- @ApiModelProperty("被检查部门/研究组名称")
+ @ApiModelProperty(value = "被检查部门/研究组名称",hidden = true)
private String researchGroupName;
@@ -153,4 +152,8 @@
@ApiModelProperty(value = "是否存在隐患 0否1是")
@TableField(exist = false)
private Integer haveMainHazard;
+
+ @ApiModelProperty(value = "部门信息")
+ @TableField(exist = false)
+ private List<DailySafetyInspectionDept> dailySafetyInspectionDepts;
}
diff --git a/gkhy-system/src/main/java/com/gkhy/system/domain/DailySafetyInspectionDept.java b/gkhy-system/src/main/java/com/gkhy/system/domain/DailySafetyInspectionDept.java
new file mode 100644
index 0000000..28a7b7c
--- /dev/null
+++ b/gkhy-system/src/main/java/com/gkhy/system/domain/DailySafetyInspectionDept.java
@@ -0,0 +1,41 @@
+package com.gkhy.system.domain;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 日常检查人员表
+ * </p>
+ *
+ * @author hh
+ * @since 2025-09-08 10:36:52
+ */
+@Getter
+@Setter
+@TableName("daily_safety_inspection_dept")
+@ApiModel(value = "DailySafetyInspectionDept对象", description = "日常检查部门表")
+public class DailySafetyInspectionDept implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("主表id")
+ @TableId("daily_safety_inspection_id")
+ private Long dailySafetyInspectionId;
+
+ @ApiModelProperty("部门id")
+ @TableField("dept_id")
+ private Long deptId;
+
+ @TableField("dept_name")
+ private String deptName;
+
+
+}
diff --git a/gkhy-system/src/main/java/com/gkhy/system/mapper/DailySafetyInspectionDeptMapper.java b/gkhy-system/src/main/java/com/gkhy/system/mapper/DailySafetyInspectionDeptMapper.java
new file mode 100644
index 0000000..c929e16
--- /dev/null
+++ b/gkhy-system/src/main/java/com/gkhy/system/mapper/DailySafetyInspectionDeptMapper.java
@@ -0,0 +1,20 @@
+package com.gkhy.system.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gkhy.system.domain.DailySafetyInspectionDept;
+import com.gkhy.system.domain.DailySafetyInspectionUser;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ * 日常检查人员表 Mapper 接口
+ * </p>
+ *
+ * @author hh
+ * @since 2025-09-08 10:36:52
+ */
+@Mapper
+public interface DailySafetyInspectionDeptMapper extends BaseMapper<DailySafetyInspectionDept> {
+
+}
diff --git a/gkhy-system/src/main/java/com/gkhy/system/service/impl/DailySafetyInspectionServiceImpl.java b/gkhy-system/src/main/java/com/gkhy/system/service/impl/DailySafetyInspectionServiceImpl.java
index 83444ce..42cf000 100644
--- a/gkhy-system/src/main/java/com/gkhy/system/service/impl/DailySafetyInspectionServiceImpl.java
+++ b/gkhy-system/src/main/java/com/gkhy/system/service/impl/DailySafetyInspectionServiceImpl.java
@@ -9,7 +9,9 @@
import com.gkhy.common.exception.ServiceException;
import com.gkhy.common.utils.SecurityUtils;
import com.gkhy.system.domain.DailySafetyInspection;
+import com.gkhy.system.domain.DailySafetyInspectionDept;
import com.gkhy.system.domain.DailySafetyInspectionUser;
+import com.gkhy.system.mapper.DailySafetyInspectionDeptMapper;
import com.gkhy.system.mapper.DailySafetyInspectionMapper;
import com.gkhy.system.mapper.DailySafetyInspectionUserMapper;
import com.gkhy.system.mapper.SysDeptMapper;
@@ -40,6 +42,9 @@
private DailySafetyInspectionUserMapper dailySafetyInspectionUserMapper;
@Autowired
+ private DailySafetyInspectionDeptMapper dailySafetyInspectionDeptMapper;
+
+ @Autowired
private SysDeptMapper sysDeptMapper;
@Override
@@ -54,14 +59,14 @@
// if (ObjectUtil.isEmpty(dailySafetyInspectionUsers)) {
// throw new ServiceException("参检人员不能为空");
// }
- Long researchGroup = inspection.getResearchGroup();
- SysDept sysDept = sysDeptMapper.selectDeptById(researchGroup);
- if (sysDept == null) {
- throw new ServiceException("部门不存在");
- }
- if (!"1".equals(sysDept.getSafety())){
- throw new ServiceException("所选部门未开启安全检查");
- }
+// Long researchGroup = inspection.getResearchGroup();
+// SysDept sysDept = sysDeptMapper.selectDeptById(researchGroup);
+// if (sysDept == null) {
+// throw new ServiceException("部门不存在");
+// }
+// if (!"1".equals(sysDept.getSafety())){
+// throw new ServiceException("所选部门未开启安全检查");
+// }
int i = 0;
if (inspection.getId() == null) {
@@ -72,6 +77,9 @@
inspection.setUpdateTime(LocalDateTime.now());
inspection.setUpdateBy(SecurityUtils.getUsername());
i = dailySafetyInspectionMapper.updateById(inspection);
+ }
+ if (i > 0){
+ saveDailySafetyInspectionDept(inspection.getDailySafetyInspectionDepts(),inspection.getId());
}
// if (i > 0) {
// saveDailySafetyInspectionUser(dailySafetyInspectionUsers, inspection.getId());
@@ -90,7 +98,17 @@
});
}
+ private void saveDailySafetyInspectionDept(List<DailySafetyInspectionDept> dailySafetyInspectionDepts, Long id) {
+ DailySafetyInspectionDept dept = new DailySafetyInspectionDept();
+ dept.setDailySafetyInspectionId(id);
+ dailySafetyInspectionDeptMapper.deleteById(dept);
+ dailySafetyInspectionDepts.forEach(dept1 -> {
+ dept1.setDailySafetyInspectionId(id);
+ dailySafetyInspectionDeptMapper.insert(dept1);
+ });
+
+ }
@Override
public int deleteDailySafetyInspection(Long id) {
diff --git a/gkhy-system/src/main/resources/mapper/system/DailySafetyInspectionDeptMapper.xml b/gkhy-system/src/main/resources/mapper/system/DailySafetyInspectionDeptMapper.xml
new file mode 100644
index 0000000..b6493c5
--- /dev/null
+++ b/gkhy-system/src/main/resources/mapper/system/DailySafetyInspectionDeptMapper.xml
@@ -0,0 +1,5 @@
+<?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.gkhy.system.mapper.DailySafetyInspectionDeptMapper">
+
+</mapper>
diff --git a/gkhy-system/src/main/resources/mapper/system/DailySafetyInspectionMapper.xml b/gkhy-system/src/main/resources/mapper/system/DailySafetyInspectionMapper.xml
index d525dbe..818dce4 100644
--- a/gkhy-system/src/main/resources/mapper/system/DailySafetyInspectionMapper.xml
+++ b/gkhy-system/src/main/resources/mapper/system/DailySafetyInspectionMapper.xml
@@ -1,43 +1,59 @@
<?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.gkhy.system.mapper.DailySafetyInspectionMapper">
-
-
<resultMap id="BaseResultMap" type="com.gkhy.system.domain.DailySafetyInspection">
- <id column="id" property="id" />
- <result column="check_date" property="checkDate" />
- <result column="check_place" property="checkPlace" />
- <result column="check_room" property="checkRoom" />
- <result column="research_group" property="researchGroup" />
- <result column="research_group_name" property="researchGroupName" />
- <result column="check_content" property="checkContent" />
- <result column="main_hazard" property="mainHazard" />
- <result column="rectification_measures" property="rectificationMeasures" />
- <result column="examination_results" property="examinationResults" />
- <result column="re_check_user_id" property="reCheckUserId" />
- <result column="check_user" property="checkUser" />
- <result column="re_check_user" property="reCheckUser" />
- <result column="re_check_date" property="reCheckDate" />
- <result column="remark" property="remark" />
- <result column="del_flag" property="delFlag" />
- <result column="create_by" property="createBy" />
- <result column="create_time" property="createTime" />
- <result column="update_by" property="updateBy" />
- <result column="update_time" property="updateTime" />
- <result column="check_type" property="checkType" />
+ <id column="id" property="id"/>
+ <result column="check_date" property="checkDate"/>
+ <result column="check_place" property="checkPlace"/>
+ <result column="check_room" property="checkRoom"/>
+ <result column="research_group" property="researchGroup"/>
+ <result column="research_group_name" property="researchGroupName"/>
+ <result column="check_content" property="checkContent"/>
+ <result column="main_hazard" property="mainHazard"/>
+ <result column="rectification_measures" property="rectificationMeasures"/>
+ <result column="examination_results" property="examinationResults"/>
+ <result column="re_check_user_id" property="reCheckUserId"/>
+ <result column="check_user" property="checkUser"/>
+ <result column="re_check_user" property="reCheckUser"/>
+ <result column="re_check_date" property="reCheckDate"/>
+ <result column="remark" property="remark"/>
+ <result column="del_flag" property="delFlag"/>
+ <result column="create_by" property="createBy"/>
+ <result column="create_time" property="createTime"/>
+ <result column="update_by" property="updateBy"/>
+ <result column="update_time" property="updateTime"/>
+ <result column="check_type" property="checkType"/>
-<!-- <collection property="dailySafetyInspectionUsers" ofType="com.gkhy.system.domain.DailySafetyInspectionUser" column="id = id" select="selectDailySafetyInspectionUsers" />-->
-
+ <!-- <collection property="dailySafetyInspectionUsers" ofType="com.gkhy.system.domain.DailySafetyInspectionUser" column="id = id" select="selectDailySafetyInspectionUsers" />-->
+ <collection property="dailySafetyInspectionDepts" ofType="com.gkhy.system.domain.DailySafetyInspectionDept"
+ column="id = id" select="selectDailySafetyInspectionDepts"/>
</resultMap>
<resultMap id="dailySafetyInspectionUsers" type="com.gkhy.system.domain.DailySafetyInspectionUser">
- <result column="daily_safety_inspection_id" property="dailySafetyInspectionId" />
- <result column="check_user_id" property="checkUserId" />
- <result column="check_user" property="checkUser" />
+ <result column="daily_safety_inspection_id" property="dailySafetyInspectionId"/>
+ <result column="check_user_id" property="checkUserId"/>
+ <result column="check_user" property="checkUser"/>
</resultMap>
+ <resultMap id="dailySafetyInspectionDepts" type="com.gkhy.system.domain.DailySafetyInspectionDept">
+ <result column="daily_safety_inspection_id" property="dailySafetyInspectionId"/>
+ <result column="dept_id" property="deptId"/>
+ <result column="dept_name" property="deptName"/>
+ </resultMap>
+
+
+ <select id="selectDailySafetyInspectionDepts" resultMap="dailySafetyInspectionDepts">
+ select a.daily_safety_inspection_id, a.dept_id, b.dept_name
+ from daily_safety_inspection_dept a
+ left join sys_dept b on a.dept_id = b.dept_id
+ where a.daily_safety_inspection_id = #{id}
+ </select>
+
+
<select id="selectDailySafetyInspectionUsers" resultMap="dailySafetyInspectionUsers">
- select * from daily_safety_inspection_user where daily_safety_inspection_id = #{id}
+ select *
+ from daily_safety_inspection_user
+ where daily_safety_inspection_id = #{id}
</select>
@@ -46,17 +62,19 @@
select a.*,b.dept_name as research_group_name from
daily_safety_inspection a
left join sys_dept b on a.research_group = b.dept_id
- where a.del_flag = '0'
- <if test="researchGroup != null ">
- and a.research_group = #{researchGroup}
- </if>
+ where a.del_flag = 0
+<!-- <if test="researchGroup != null ">-->
+<!-- and a.research_group = #{researchGroup}-->
+<!-- </if>-->
<if test="checkType != null ">
and a.check_type = #{checkType}
</if>
- <if test="checkBeginDate != null "><!-- 开始时间检索 -->
+ <if test="checkBeginDate != null ">
+ <!-- 开始时间检索 -->
AND date_format(a.check_date,'%Y%m%d') >= date_format(#{checkBeginDate},'%Y%m%d')
</if>
- <if test="checkEndDate != null "><!-- 结束时间检索 -->
+ <if test="checkEndDate != null ">
+ <!-- 结束时间检索 -->
AND date_format(a.check_date,'%Y%m%d') <= date_format(#{checkEndDate},'%Y%m%d')
</if>
<if test="haveMainHazard != null and haveMainHazard == 0 ">
@@ -68,19 +86,32 @@
<if test="checkUser != null and checkUser != ''">
and a.check_user like concat('%',#{checkUser},'%')
</if>
-<!-- <if test="searchCheckUserIds != null and !searchCheckUserIds.isEmpty()">-->
-<!-- and a.id in (-->
-<!-- select distinct daily_safety_inspection_id from daily_safety_inspection_user-->
-<!-- where check_user_id in <foreach collection="searchCheckUserIds" item="group" open="(" separator="," close=")">-->
-<!-- #{group}-->
-<!-- </foreach>-->
-<!-- )-->
-<!-- </if>-->
+
+ <if test="researchGroup != null ">
+ and a.id in (
+ select distinct daily_safety_inspection_id from daily_safety_inspection_dept
+ where dept_id = #{researchGroup}
+ )
+ </if>
+
+ <!-- <if test="searchCheckUserIds != null and !searchCheckUserIds.isEmpty()">-->
+ <!-- and a.id in (-->
+ <!-- select distinct daily_safety_inspection_id from daily_safety_inspection_user-->
+ <!-- where check_user_id in <foreach collection="searchCheckUserIds" item="group" open="(" separator="," close=")">-->
+ <!-- #{group}-->
+ <!-- </foreach>-->
+ <!-- )-->
+ <!-- </if>-->
order by a.create_time desc
</select>
<select id="getCheckCount" parameterType="long" resultType="int">
- select count(*) from daily_safety_inspection where del_flag = 0 and research_group = #{deptId} and date_format(check_date,'%Y%m') = date_format(now(),'%Y%m')
+ select count(*)
+ from daily_safety_inspection_dept a
+ inner join daily_safety_inspection b on a.daily_safety_inspection_id = b.id
+ where b.del_flag = 0
+ and a.dept_id = #{deptId}
+ and date_format(b.check_date, '%Y%m') = date_format(now(), '%Y%m')
</select>
</mapper>
--
Gitblit v1.9.2