From 6ab1565a1a86623af925719935d605e875d98af4 Mon Sep 17 00:00:00 2001
From: 吴羡 <16976746+Xian-TT3@user.noreply.gitee.com>
Date: 星期五, 23 十月 2026 18:08:56 +0800
Subject: [PATCH] 设备核查计划:设备档案变更即时登记计划明细,提前核查复用待核查明细并回写档案,已完成记录不可覆盖;新增附件字段、明细固定排序与删除保护;人员查询新增包含admin的类型;检验保存/提交按页面模板校验,复核驳回按检验室删除复核人
---
cnas-device/src/main/java/com/ruoyi/device/service/DeviceExaminePlanService.java | 26 ++++
cnas-device/src/main/java/com/ruoyi/device/service/impl/DeviceServiceImpl.java | 8 +
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserServiceImpl.java | 2
cnas-device/src/main/java/com/ruoyi/device/controller/DeviceExaminePlanController.java | 16 ++
cnas-device/src/main/resources/mapper/DeviceExaminePlanDetailsMapper.xml | 4
ruoyi-system/src/main/resources/mapper/system/UserMapper.xml | 28 ++++
ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserMapper.java | 7 +
cnas-device/src/main/java/com/ruoyi/device/pojo/DeviceExaminePlanDetails.java | 6 +
cnas-device/src/main/java/com/ruoyi/device/service/impl/DeviceExaminePlanServiceImpl.java | 156 +++++++++++++++++++++++--
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java | 80 +++++++++++--
10 files changed, 300 insertions(+), 33 deletions(-)
diff --git a/cnas-device/src/main/java/com/ruoyi/device/controller/DeviceExaminePlanController.java b/cnas-device/src/main/java/com/ruoyi/device/controller/DeviceExaminePlanController.java
index b2aa097..208271a 100644
--- a/cnas-device/src/main/java/com/ruoyi/device/controller/DeviceExaminePlanController.java
+++ b/cnas-device/src/main/java/com/ruoyi/device/controller/DeviceExaminePlanController.java
@@ -168,17 +168,27 @@
@Operation(summary = "淇敼璁惧鏍告煡璁″垝璇︽儏")
@PostMapping("/updateDeviceExaminePlanDetail")
public Result updateDeviceExaminePlanDetail(@RequestBody DeviceExaminePlanDetails deviceExaminePlanDetail){
- return Result.success(deviceExaminePlanDetailsService.updateById(deviceExaminePlanDetail));
+ return Result.success(deviceExaminePlanService.updateExaminePlanDetail(deviceExaminePlanDetail));
}
/**
- * 鍒犻櫎璁惧鏍告煡璁″垝璇︽儏
+ * 鍒犻櫎璁惧鏍告煡璁″垝璇︽儏锛堝凡鏈夋牳鏌ヨ褰曠殑涓嶅厑璁稿垹闄わ級
* @return
*/
@Operation(summary = "鍒犻櫎璁惧鏍告煡璁″垝璇︽儏")
@DeleteMapping("/delDeviceExaminePlanDetail")
public Result delDeviceExaminePlanDetail(Integer planDetailsId){
- return Result.success(deviceExaminePlanDetailsService.removeById(planDetailsId));
+ return Result.success(deviceExaminePlanService.removeExaminePlanDetail(planDetailsId));
+ }
+
+ /**
+ * 涓烘寚瀹氳澶囨壘涓�鏉″彲褰曞叆鏍告煡璁板綍鐨勮鍒掓槑缁嗭紝娌℃湁鍒欐柊澧炴湰杞槑缁�
+ * @return
+ */
+ @Operation(summary = "鎸夎澶囪幏鍙栨湰杞牳鏌ヨ鍒掓槑缁�")
+ @GetMapping("/resolveExaminePlanDetail")
+ public Result<DeviceExaminePlanDetails> resolveExaminePlanDetail(Integer deviceId, String checkTime){
+ return Result.success(deviceExaminePlanService.resolveExaminePlanDetail(deviceId, checkTime));
}
/**
diff --git a/cnas-device/src/main/java/com/ruoyi/device/pojo/DeviceExaminePlanDetails.java b/cnas-device/src/main/java/com/ruoyi/device/pojo/DeviceExaminePlanDetails.java
index bc8c1c3..6a3bcf6 100644
--- a/cnas-device/src/main/java/com/ruoyi/device/pojo/DeviceExaminePlanDetails.java
+++ b/cnas-device/src/main/java/com/ruoyi/device/pojo/DeviceExaminePlanDetails.java
@@ -57,6 +57,12 @@
@Schema(description = "澶囨敞")
private String remark;
+ @Schema(description = "闄勪欢鍚嶇О")
+ private String fileName;
+
+ @Schema(description = "闄勪欢璺緞")
+ private String fileUrl;
+
@Schema(description = "鍒涘缓浜�")
@TableField(fill = FieldFill.INSERT)
private Integer createUser;
diff --git a/cnas-device/src/main/java/com/ruoyi/device/service/DeviceExaminePlanService.java b/cnas-device/src/main/java/com/ruoyi/device/service/DeviceExaminePlanService.java
index 69c5aa3..50cb2ad 100644
--- a/cnas-device/src/main/java/com/ruoyi/device/service/DeviceExaminePlanService.java
+++ b/cnas-device/src/main/java/com/ruoyi/device/service/DeviceExaminePlanService.java
@@ -96,14 +96,36 @@
DeviceExaminePlanDto getOrCreatePlanByYear(String planYear);
/**
- * 璁惧妗f鍙樻洿鍚庯紝鎶婅澶囧悓姝ュ埌瀵瑰簲骞翠唤鐨勮澶囨牳鏌ヨ鍒掓槑缁嗭紙浠呭綋宸茶繘鍏ユ彁閱掓湡/宸茶繃鏈熸椂鐢熸垚锛�
+ * 璁惧妗f鍙樻洿鍚庯紝绔嬪嵆鎶婅澶囩櫥璁板埌涓嬫鏍告煡鏃ユ湡鎵�鍦ㄥ勾浠界殑璁惧鏍告煡璁″垝鏄庣粏
* @param device 璁惧
*/
void syncDeviceExamineDetail(Device device);
/**
- * 鏍告煡璁板綍澶嶆牳閫氳繃鍚庯紝婊氬姩璁惧妗f鐨勬渶杩�/涓嬫鏍告煡鏃ユ湡
+ * 鏍告煡璁板綍澶嶆牳閫氳繃鍚庯紝婊氬姩璁惧妗f鐨勬渶杩�/涓嬫鏍告煡鏃ユ湡锛屽苟鐧昏涓嬩竴杞鍒�
* @param planDetailsId 璁″垝鏄庣粏id
*/
void updateDeviceExamineDate(Integer planDetailsId);
+
+ /**
+ * 涓烘寚瀹氳澶囨壘涓�鏉″彲褰曞叆鏍告煡璁板綍鐨勮鍒掓槑缁嗭紝娌℃湁鍒欐柊澧炴湰杞槑缁�
+ * @param deviceId 璁惧id
+ * @param checkTime 鏍告煡鏈堜唤锛坹yyy-MM锛夛紝鍐冲畾鏄庣粏鎵�灞炵殑璁″垝骞翠唤
+ * @return 璁″垝鏄庣粏
+ */
+ DeviceExaminePlanDetails resolveExaminePlanDetail(Integer deviceId, String checkTime);
+
+ /**
+ * 淇敼璁″垝鏄庣粏锛堟牳鏌ユ湀浠借法骞存椂褰掑埌瀵瑰簲骞翠唤鐨勮鍒掞級
+ * @param detail 璁″垝鏄庣粏
+ * @return 鏄惁淇敼鎴愬姛
+ */
+ boolean updateExaminePlanDetail(DeviceExaminePlanDetails detail);
+
+ /**
+ * 鍒犻櫎璁″垝鏄庣粏锛堝凡鏈夋牳鏌ヨ褰曠殑涓嶅厑璁稿垹闄わ級
+ * @param planDetailsId 璁″垝鏄庣粏id
+ * @return 鏄惁鍒犻櫎鎴愬姛
+ */
+ boolean removeExaminePlanDetail(Integer planDetailsId);
}
diff --git a/cnas-device/src/main/java/com/ruoyi/device/service/impl/DeviceExaminePlanServiceImpl.java b/cnas-device/src/main/java/com/ruoyi/device/service/impl/DeviceExaminePlanServiceImpl.java
index 7ef252c..a8b3ace 100644
--- a/cnas-device/src/main/java/com/ruoyi/device/service/impl/DeviceExaminePlanServiceImpl.java
+++ b/cnas-device/src/main/java/com/ruoyi/device/service/impl/DeviceExaminePlanServiceImpl.java
@@ -22,10 +22,14 @@
import com.ruoyi.device.excel.upload.DeviceExaminePlanUpload;
import com.ruoyi.device.mapper.DeviceExaminePlanDetailsMapper;
import com.ruoyi.device.mapper.DeviceExaminePlanMapper;
+import com.ruoyi.device.mapper.DeviceExamineRecordContrastMapper;
+import com.ruoyi.device.mapper.DeviceExamineRecordMapper;
import com.ruoyi.device.mapper.DeviceMapper;
import com.ruoyi.device.pojo.Device;
import com.ruoyi.device.pojo.DeviceExaminePlan;
import com.ruoyi.device.pojo.DeviceExaminePlanDetails;
+import com.ruoyi.device.pojo.DeviceExamineRecord;
+import com.ruoyi.device.pojo.DeviceExamineRecordContrast;
import com.ruoyi.device.service.DeviceExaminePlanDetailsService;
import com.ruoyi.device.service.DeviceExaminePlanService;
import com.ruoyi.framework.exception.ErrorException;
@@ -49,6 +53,7 @@
import java.time.LocalDateTime;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -77,6 +82,10 @@
private DeviceMapper deviceMapper;
@Resource
private UserMapper userMapper;
+ @Resource
+ private DeviceExamineRecordMapper deviceExamineRecordMapper;
+ @Resource
+ private DeviceExamineRecordContrastMapper deviceExamineRecordContrastMapper;
/**
* 鏂板璁惧鏍告煡璁″垝
@@ -381,15 +390,15 @@
}
/**
- * 璁惧妗f鍙樻洿鍚庯紝鎶婅澶囧悓姝ュ埌瀵瑰簲骞翠唤鐨勮澶囨牳鏌ヨ鍒掓槑缁�
+ * 璁惧妗f鍙樻洿鍚庯紝绔嬪嵆鎶婅澶囩櫥璁板埌涓嬫鏍告煡鏃ユ湡鎵�鍦ㄥ勾浠界殑璁惧鏍告煡璁″垝鏄庣粏
*/
@Override
public void syncDeviceExamineDetail(Device device) {
- LocalDate remind = calcExamineRemindDate(device);
- if (remind == null || remind.isAfter(LocalDate.now())) {
+ LocalDate due = calcExamineDueDate(device);
+ if (due == null) {
return;
}
- DeviceExaminePlan plan = getOrCreatePlanEntity(String.valueOf(remind.getYear()));
+ DeviceExaminePlan plan = getOrCreatePlanEntity(String.valueOf(due.getYear()));
fillExamineDetailIfAbsent(plan, device);
}
@@ -406,6 +415,7 @@
if (device == null) {
return;
}
+ // 鎻愬墠鏍告煡鏃惰鍒掓湀浠藉彲鑳借繕娌″埌锛屽彇瀹為檯瀹屾垚褰撳ぉ锛涘惁鍒欐寜鏈疆璁″垝鏍告煡鏈堜唤
LocalDate checkDate = parseCheckDate(detail.getCheckTime());
if (checkDate.isAfter(LocalDate.now())) {
checkDate = LocalDate.now();
@@ -423,6 +433,8 @@
}
}
deviceMapper.updateById(device);
+ // 鏈疆鏍告煡瀹屾垚鍚庣珛鍗崇櫥璁颁笅涓�杞紝鍘嗗彶鏄庣粏鍜岃褰曚繚鎸佷笉鍔�
+ syncDeviceExamineDetail(device);
}
/**
@@ -445,7 +457,7 @@
}
/**
- * 鎵弿鎵�鏈夎澶囷紝鎶婂凡鍒扮偣锛堜笅娆℃牳鏌ユ棩鏈熷墠1涓湀璧凤紝鍚凡杩囨湡锛夌殑璁惧琛ヨ繘鏈勾搴﹁鍒�
+ * 鎵弿鎵�鏈夎澶囷紝鎶婃湰骞村害鍙婂線骞撮�炬湡鏈牳鏌ョ殑璁惧琛ヨ繘璁″垝
*/
private void ensureExamineDetails(DeviceExaminePlan plan) {
List<Device> devices = deviceMapper.selectList(null);
@@ -455,9 +467,9 @@
}
/**
- * 璁惧鎻愰啋璧风偣锛氫笅娆℃牳鏌ユ棩鏈熷墠1涓湀锛堟病濉笅娆℃棩鏈熸椂鐢ㄦ渶杩戞棩鏈�+鏍告煡鍛ㄦ湡鍏滃簳锛�
+ * 璁惧鏈疆搴旀牳鏌ユ棩鏈燂紙娌″~涓嬫鏃ユ湡鏃剁敤鏈�杩戞棩鏈�+鏍告煡鍛ㄦ湡鍏滃簳锛�
*/
- private LocalDate calcExamineRemindDate(Device device) {
+ private LocalDate calcExamineDueDate(Device device) {
LocalDateTime base = device.getNextExamineDate();
if (base == null && device.getLastExamineDate() != null && StringUtils.isNotBlank(device.getExamineCycle())) {
try {
@@ -465,21 +477,21 @@
} catch (NumberFormatException ignored) {
}
}
- return base == null ? null : base.toLocalDate().minusMonths(1);
+ return base == null ? null : base.toLocalDate();
}
/**
- * 宸插埌鐐逛笖璁″垝涓皻鏃犺璁惧鏈疆鏄庣粏鏃惰嚜鍔ㄨˉ涓�鏉�
+ * 璁″垝涓皻鏃犺璁惧鏈疆鏄庣粏鏃惰嚜鍔ㄨˉ涓�鏉★紱鏍告煡鏃堕棿鍙栧簲鏍告煡鏈堜唤
*/
private void fillExamineDetailIfAbsent(DeviceExaminePlan plan, Device device) {
- LocalDate remind = calcExamineRemindDate(device);
- if (remind == null || remind.isAfter(LocalDate.now())) {
+ LocalDate due = calcExamineDueDate(device);
+ if (due == null) {
return;
}
- if (plan.getPlanYear() != null && String.valueOf(remind.getYear()).compareTo(plan.getPlanYear()) > 0) {
+ if (plan.getPlanYear() != null && String.valueOf(due.getYear()).compareTo(plan.getPlanYear()) > 0) {
return;
}
- String checkTime = remind.format(DateTimeFormatter.ofPattern("yyyy-MM"));
+ String checkTime = due.format(DateTimeFormatter.ofPattern("yyyy-MM"));
Long exist = deviceExaminePlanDetailsMapper.selectCount(Wrappers.<DeviceExaminePlanDetails>lambdaQuery()
.eq(DeviceExaminePlanDetails::getPlanId, plan.getPlanId())
.eq(DeviceExaminePlanDetails::getDeviceId, device.getId())
@@ -515,4 +527,122 @@
}
return LocalDate.now();
}
+
+ /**
+ * 涓烘寚瀹氳澶囨壘涓�鏉″彲褰曞叆鏍告煡璁板綍鐨勮鍒掓槑缁嗭紱娌℃湁鍙敤鏄庣粏鏃跺湪褰撳墠骞村害璁″垝鏂板鏈疆鏄庣粏
+ */
+ @Override
+ public DeviceExaminePlanDetails resolveExaminePlanDetail(Integer deviceId, String checkTime) {
+ if (deviceId == null) {
+ throw new ErrorException("璇烽�夋嫨鏍告煡璁惧");
+ }
+ Device device = deviceMapper.selectById(deviceId);
+ if (device == null) {
+ throw new ErrorException("鏍告煡璁惧涓嶅瓨鍦�");
+ }
+ String checkMonth = normalizeCheckMonth(checkTime);
+ DeviceExaminePlan plan = getOrCreatePlanEntity(checkMonth.substring(0, 4));
+ List<DeviceExaminePlanDetails> details = deviceExaminePlanDetailsMapper.selectList(
+ Wrappers.<DeviceExaminePlanDetails>lambdaQuery()
+ .eq(DeviceExaminePlanDetails::getDeviceId, deviceId)
+ .orderByAsc(DeviceExaminePlanDetails::getCheckTime));
+ DeviceExaminePlanDetails nearest = null;
+ long nearestDistance = Long.MAX_VALUE;
+ for (DeviceExaminePlanDetails detail : details) {
+ // 宸叉湁鏍告煡璁板綍鐨勬槑缁嗕唬琛ㄥ凡瀹屾垚鐨勪竴杞紝鍚庣画鏍告煡姘歌繙涓嶅鐢ㄣ�佷笉瑕嗙洊
+ Long recordCount = deviceExamineRecordMapper.selectCount(Wrappers.<DeviceExamineRecord>lambdaQuery()
+ .eq(DeviceExamineRecord::getPlanDetailsId, detail.getPlanDetailsId()));
+ if (recordCount != null && recordCount > 0) {
+ continue;
+ }
+ if (detail.getPlanId() != null && detail.getPlanId().equals(plan.getPlanId())) {
+ return detail;
+ }
+ long distance = monthDistance(detail.getCheckTime(), checkMonth);
+ if (distance < nearestDistance) {
+ nearest = detail;
+ nearestDistance = distance;
+ }
+ }
+ // 鎻愬墠鏍告煡鏃朵紭鍏堝鐢ㄧ郴缁熺櫥璁般�佸皻鏈牳鏌ョ殑杩欎竴杞紙鍙兘鍦ㄥ埆鐨勫勾浠借鍒掗噷锛�
+ if (nearest != null) {
+ return nearest;
+ }
+ DeviceExaminePlanDetails detail = new DeviceExaminePlanDetails();
+ detail.setPlanId(plan.getPlanId());
+ detail.setDeviceId(device.getId());
+ String deviceName = device.getDeviceName() == null ? "" : device.getDeviceName();
+ if (StringUtils.isNotBlank(device.getSpecificationModel())) {
+ deviceName = deviceName + " " + device.getSpecificationModel();
+ }
+ detail.setDeviceName(deviceName);
+ detail.setDeviceNumber(device.getManagementNumber());
+ detail.setCheckTime(checkMonth);
+ deviceExaminePlanDetailsMapper.insert(detail);
+ return detail;
+ }
+
+ /**
+ * 瑙勮寖鏍告煡鏈堜唤涓� yyyy-MM锛岄潪娉曟垨涓虹┖鏃跺彇褰撳墠鏈堜唤
+ */
+ private String normalizeCheckMonth(String checkTime) {
+ if (StringUtils.isNotBlank(checkTime)) {
+ String normalized = checkTime.trim().replace('.', '-').replace('/', '-');
+ if (normalized.length() >= 7) {
+ try {
+ return YearMonth.parse(normalized.substring(0, 7)).toString();
+ } catch (Exception ignored) {
+ }
+ }
+ }
+ return LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM"));
+ }
+
+ /**
+ * 涓や釜鏈堜唤涔嬮棿鐩稿樊鐨勬湀鏁�
+ */
+ private long monthDistance(String fromCheckTime, String targetMonth) {
+ try {
+ YearMonth from = YearMonth.parse(normalizeCheckMonth(fromCheckTime));
+ YearMonth target = YearMonth.parse(targetMonth);
+ return Math.abs(ChronoUnit.MONTHS.between(from, target));
+ } catch (Exception e) {
+ return Long.MAX_VALUE;
+ }
+ }
+
+ /**
+ * 淇敼璁″垝鏄庣粏锛涙牳鏌ユ湀浠借法骞存椂锛屾妸鏄庣粏褰掑埌鏍告煡鏈堜唤鎵�灞炲勾浠界殑璁″垝涓�
+ */
+ @Override
+ public boolean updateExaminePlanDetail(DeviceExaminePlanDetails detail) {
+ if (detail == null || detail.getPlanDetailsId() == null) {
+ throw new ErrorException("缂哄皯璁惧鏍告煡璁″垝鏄庣粏id");
+ }
+ if (StringUtils.isNotBlank(detail.getCheckTime())) {
+ String checkMonth = normalizeCheckMonth(detail.getCheckTime());
+ detail.setCheckTime(checkMonth);
+ DeviceExaminePlan plan = getOrCreatePlanEntity(checkMonth.substring(0, 4));
+ detail.setPlanId(plan.getPlanId());
+ }
+ return deviceExaminePlanDetailsMapper.updateById(detail) > 0;
+ }
+
+ /**
+ * 鍒犻櫎璁″垝鏄庣粏锛涘凡鏈夋牳鏌�/姣斿璁板綍鐨勪笉鍏佽鍒犻櫎锛屼繚璇佸巻鍙茬暀妗�
+ */
+ @Override
+ public boolean removeExaminePlanDetail(Integer planDetailsId) {
+ if (planDetailsId == null) {
+ throw new ErrorException("缂哄皯璁惧鏍告煡璁″垝鏄庣粏id");
+ }
+ Long recordCount = deviceExamineRecordMapper.selectCount(Wrappers.<DeviceExamineRecord>lambdaQuery()
+ .eq(DeviceExamineRecord::getPlanDetailsId, planDetailsId));
+ Long contrastCount = deviceExamineRecordContrastMapper.selectCount(Wrappers.<DeviceExamineRecordContrast>lambdaQuery()
+ .eq(DeviceExamineRecordContrast::getPlanDetailsId, planDetailsId));
+ if ((recordCount != null && recordCount > 0) || (contrastCount != null && contrastCount > 0)) {
+ throw new ErrorException("璇ヨ鍒掑凡瀛樺湪鏍告煡璁板綍锛屼负淇濈暀鍘嗗彶璁板綍涓嶅厑璁稿垹闄�");
+ }
+ return deviceExaminePlanDetailsService.removeById(planDetailsId);
+ }
}
diff --git a/cnas-device/src/main/java/com/ruoyi/device/service/impl/DeviceServiceImpl.java b/cnas-device/src/main/java/com/ruoyi/device/service/impl/DeviceServiceImpl.java
index a0cc9d1..70671c3 100644
--- a/cnas-device/src/main/java/com/ruoyi/device/service/impl/DeviceServiceImpl.java
+++ b/cnas-device/src/main/java/com/ruoyi/device/service/impl/DeviceServiceImpl.java
@@ -102,7 +102,13 @@
@Override
public int addDeviceParameter(Device itemParameter) {
- return deviceMapper.insert(itemParameter);
+ int rows = deviceMapper.insert(itemParameter);
+ Device device = deviceMapper.selectById(itemParameter.getId());
+ if (device != null && (device.getNextExamineDate() != null
+ || (device.getLastExamineDate() != null && StringUtils.isNotBlank(device.getExamineCycle())))) {
+ deviceExaminePlanService.syncDeviceExamineDetail(device);
+ }
+ return rows;
}
@Override
diff --git a/cnas-device/src/main/resources/mapper/DeviceExaminePlanDetailsMapper.xml b/cnas-device/src/main/resources/mapper/DeviceExaminePlanDetailsMapper.xml
index 56597c1..cd28058 100644
--- a/cnas-device/src/main/resources/mapper/DeviceExaminePlanDetailsMapper.xml
+++ b/cnas-device/src/main/resources/mapper/DeviceExaminePlanDetailsMapper.xml
@@ -20,6 +20,8 @@
CASE WHEN d.check_charger_user='' or d.check_charger_user is null THEN u.name
ELSE d.check_charger_user END AS check_charger_user,
d.remark,
+ d.file_name,
+ d.file_url,
d.create_user,
d.create_time,
d.update_user,
@@ -43,11 +45,11 @@
left join device_examine_record dc on d.plan_details_id = dc.plan_details_id
left join device_examine_record_contrast dd on dd.plan_details_id = d.plan_details_id
left join device dev on dev.id = d.device_id
- order by check_time asc
) a
<if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
${ew.customSqlSegment}
</if>
+ order by device_number asc, check_time desc
</select>
</mapper>
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
index dcd6d1e..9e1e3c2 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
@@ -365,7 +365,7 @@
}
}
map.put("errorMsg", collect);
- map.put("missingExportItems", getMissingTemplateExportValues(orderId));
+ map.put("missingExportItems", getMissingTemplateExportValues(orderId, laboratory));
map.put("unInsOrderCount", 0L);
return map;
}
@@ -649,10 +649,11 @@
JSONObject values = JSON.parseObject(JSON.toJSONString(dto.getValues() == null
? Collections.emptyMap() : dto.getValues()));
- // 妫�楠屾湡闂撮〉闈㈠睍绀虹殑鏄爣鍑嗙淮鎶や腑鐨勬渶鏂版ā鏉匡紝淇濆瓨鏍¢獙蹇呴』浣跨敤鍚屼竴浠芥ā鏉匡紝
- // 閬垮厤妯℃澘鏂板鈥滃鍑哄�尖�濇壒娉ㄥ悗浠嶆寜涓嬪崟鏃剁殑鏃у揩鐓ц鎶ユ湭閰嶇疆銆�
- String currentTemplateThing = getCurrentTemplateThing(snapshot);
- List<String> exportValueCoordinates = getExportValueCoordinates(currentTemplateThing).values().stream()
+ // 淇濆瓨鏃跺繀椤讳娇鐢ㄩ〉闈㈠綋鍓嶅睍绀虹殑妯℃澘锛氬緟妫�銆佸湪妫�闃舵灞曠ず鏍囧噯缁存姢涓殑瀹炴椂妯℃澘锛�
+ // 澶嶆牳銆侀┏鍥為樁娈靛睍绀鸿鍗曞揩鐓э紱鍚﹀垯妯℃澘鍦ㄦ楠岄�斾腑琚慨鏀瑰悗浼氬彇閿欏鍑哄�煎崟鍏冩牸銆�
+ boolean useSnapshot = useSnapshotTemplate(dto.getOrderId(), getCurrentUserLaboratory(dto.getOrderId()));
+ String pageTemplateThing = getPageTemplateThing(snapshot, useSnapshot);
+ List<String> exportValueCoordinates = getExportValueCoordinates(pageTemplateThing).values().stream()
.flatMap(Collection::stream)
.distinct()
.collect(Collectors.toList());
@@ -889,8 +890,8 @@
}
/**
- * 妫�楠屼繚瀛樸�佹彁浜ゆ牎楠岃鍙栨爣鍑嗙淮鎶や腑鐨勫疄鏃舵ā鏉匡紱妯℃澘宸茶鍒犻櫎鎴栧唴瀹逛负绌烘椂鎵嶅洖閫�璁㈠崟蹇収銆�
- * 妫�楠屽畬鎴愬悗鐨勫睍绀哄拰鎶ュ憡浠嶇敱璁㈠崟蹇収璐熻矗锛屼笉浼氶殢鏍囧噯妯℃澘鍚庣画淇敼鑰屽彉鍖栥��
+ * 璇诲彇鏍囧噯缁存姢涓殑瀹炴椂妯℃澘锛涙ā鏉垮凡琚垹闄ゆ垨鍐呭涓虹┖鏃舵墠鍥為��璁㈠崟蹇収銆�
+ * 浠呯敤浜庢楠屽浠嶅浜庡緟妫�銆佸湪妫�闃舵锛堥〉闈㈠睍绀哄疄鏃舵ā鏉匡級鐨勪繚瀛樹笌鏍¢獙銆�
*/
private String getCurrentTemplateThing(InsOrderStandardTemplate snapshot) {
if (snapshot != null && snapshot.getTemplateId() != null) {
@@ -903,9 +904,53 @@
}
/**
+ * 妫�楠屽崟椤甸潰鍦ㄦ楠屽杩涘叆澶嶆牳鍙婁箣鍚庣姸鎬佹椂灞曠ず璁㈠崟蹇収锛屽鍑哄�肩殑淇濆瓨鍜屾彁浜ゆ牎楠屽繀椤讳笌椤甸潰
+ * 浣跨敤鍚屼竴浠芥ā鏉匡紱鍚﹀垯鏍囧噯妯℃澘鍦ㄦ楠岄�斾腑琚慨鏀瑰悗锛屽巻鍙插崟鎹細鎸夋柊鍧愭爣璇诲彇蹇収鏁版嵁鑰岃鎶ヤ负绌恒��
+ */
+ private String getPageTemplateThing(InsOrderStandardTemplate snapshot, boolean useSnapshot) {
+ if (useSnapshot && snapshot != null && StrUtil.isNotBlank(snapshot.getThing())) {
+ return snapshot.getThing();
+ }
+ return getCurrentTemplateThing(snapshot);
+ }
+
+ /**
+ * 涓庢楠屽崟椤甸潰 getTemplateThing 鐨勫垽瀹氫繚鎸佷竴鑷达細妫�楠屽鐘舵�佽繘鍏ュ鏍革紙2锛夊強涔嬪悗鏃朵娇鐢ㄨ鍗曞揩鐓с��
+ * 鎸囨淳璁板綍閲岀殑瀹為獙瀹ゅ悕绉板彲鑳藉拰鐘舵�佽涓嶄竴鑷达紙濡傗�滃叏閮ㄢ�濓級锛屾鏃堕��鍥炴寜璁㈠崟鏁翠綋鐘舵�佸垽瀹氥��
+ */
+ private boolean useSnapshotTemplate(Integer orderId, String laboratory) {
+ if (StringUtils.isNotBlank(laboratory)) {
+ InsOrderState state = insOrderStateMapper.selectOne(Wrappers.<InsOrderState>lambdaQuery()
+ .eq(InsOrderState::getInsOrderId, orderId)
+ .eq(InsOrderState::getLaboratory, laboratory)
+ .last("limit 1"));
+ if (state != null) {
+ return state.getInsState() != null && state.getInsState() >= 2;
+ }
+ }
+ return insOrderStateMapper.selectList(Wrappers.<InsOrderState>lambdaQuery()
+ .eq(InsOrderState::getInsOrderId, orderId))
+ .stream()
+ .anyMatch(state -> state.getInsState() != null && state.getInsState() >= 2);
+ }
+
+ /**
+ * 鍙栧綋鍓嶇櫥褰曚汉鍦ㄨ璁㈠崟涓婃渶杩戜竴鏉℃寚娲捐褰曟墍灞炵殑妫�楠屽锛涙湭鎸囨淳璐﹀彿杩斿洖 null锛岀敱鐘舵�佸垽瀹氬厹搴曘��
+ */
+ private String getCurrentUserLaboratory(Integer orderId) {
+ Integer userId = SecurityUtils.getUserId().intValue();
+ InsSampleUser sampleUser = insSampleUserMapper.selectOne(Wrappers.<InsSampleUser>lambdaQuery()
+ .eq(InsSampleUser::getInsSampleId, orderId)
+ .eq(InsSampleUser::getUserId, userId)
+ .orderByDesc(InsSampleUser::getId)
+ .last("limit 1"));
+ return sampleUser == null ? null : sampleUser.getSonLaboratory();
+ }
+
+ /**
* 鐩寸粦妯℃澘璁㈠崟鍙牎楠屾瘡涓�滃鍑哄�尖�濇壒娉ㄦ墍鍦ㄥ尯鍩熷彸渚х揣閭诲崟鍏冩牸锛屼笉浣跨敤妫�楠岄」鐘舵�佹垨 last_value 鍒ゅ畾銆�
*/
- private List<String> getMissingTemplateExportValues(Integer orderId) {
+ private List<String> getMissingTemplateExportValues(Integer orderId, String laboratory) {
List<InsOrderStandardTemplate> snapshots = insOrderStandardTemplateService.list(
Wrappers.<InsOrderStandardTemplate>lambdaQuery()
.eq(InsOrderStandardTemplate::getInsOrderId, orderId)
@@ -915,9 +960,10 @@
missing.add("褰撳墠璁㈠崟鏈壘鍒板師濮嬭褰曟ā鏉垮揩鐓�");
return missing;
}
+ boolean useSnapshot = useSnapshotTemplate(orderId, laboratory);
for (InsOrderStandardTemplate snapshot : snapshots) {
Integer templateId = snapshot.getTemplateId();
- List<String> coordinates = getExportValueCoordinates(getCurrentTemplateThing(snapshot)).values().stream()
+ List<String> coordinates = getExportValueCoordinates(getPageTemplateThing(snapshot, useSnapshot)).values().stream()
.flatMap(Collection::stream)
.distinct()
.collect(Collectors.toList());
@@ -1273,7 +1319,7 @@
boolean directTemplateOrder = isDirectTemplateOrder(orderId);
List<InsProduct> insProducts;
if (directTemplateOrder) {
- List<String> missingExportValues = getMissingTemplateExportValues(orderId);
+ List<String> missingExportValues = getMissingTemplateExportValues(orderId, laboratory);
if (!missingExportValues.isEmpty()) {
throw new ErrorException("妯℃澘涓殑瀵煎嚭鍊间笉鑳戒负绌猴細\n" + String.join("\n", missingExportValues));
}
@@ -1882,9 +1928,17 @@
} else {
- //澶嶆牳涓嶉�氳繃灏嗘妸澶嶆牳鐨勮礋璐d汉鍘绘帀
- Integer id = insSampleUserMapper.selectOne(Wrappers.<InsSampleUser>lambdaQuery().eq(InsSampleUser::getInsSampleId, orderId).orderByDesc(InsSampleUser::getId).last("limit 1")).getId();
- insSampleUserMapper.deleteById(id);
+ // 澶嶆牳涓嶉�氳繃鍙幓鎺夋湰妫�楠屽鏈鎻愪氦鐨勫鏍歌礋璐d汉锛涙寜澶嶆牳浜虹姸鎬佸拰妫�楠屽瀹氫綅锛�
+ // 閬垮厤璇垹鍏朵粬妫�楠屽鐨勮褰曟垨妫�楠屼汉鍛樿褰曘��
+ InsSampleUser reviewerRow = insSampleUserMapper.selectOne(Wrappers.<InsSampleUser>lambdaQuery()
+ .eq(InsSampleUser::getInsSampleId, orderId)
+ .eq(InsSampleUser::getState, 1)
+ .eq(InsSampleUser::getSonLaboratory, laboratory)
+ .orderByDesc(InsSampleUser::getId)
+ .last("limit 1"));
+ if (reviewerRow != null) {
+ insSampleUserMapper.deleteById(reviewerRow.getId());
+ }
// 褰撳墠瀹℃牳浜�
Integer currentUserId = SecurityUtils.getUserId().intValue();
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserMapper.java
index 1aa062e..3528749 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserMapper.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserMapper.java
@@ -26,6 +26,13 @@
List<User> selectUserCondition(@Param("ew") QueryWrapper<User> ew, @Param("type") String type);
/**
+ * 鏍规嵁鏉′欢鑾峰彇鐢ㄦ埛鍒楄〃锛堝寘鍚秴绾х鐞嗗憳锛�
+ * @param ew
+ * @return
+ */
+ List<User> selectUserConditionWithAdmin(@Param("ew") QueryWrapper<User> ew);
+
+ /**
* 鑾峰彇鐢ㄦ埛閮ㄩ棬
* @param userId
* @return
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserServiceImpl.java
index c4fb604..c362f0a 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserServiceImpl.java
@@ -43,6 +43,8 @@
return baseMapper.selectDepartmentLimsUserList(SecurityUtils.getUserId().intValue());
case "3":
return baseMapper.selectInspectorUserList();
+ case "4":
+ return baseMapper.selectUserConditionWithAdmin(QueryWrappers.queryWrappers(user));
}
}
diff --git a/ruoyi-system/src/main/resources/mapper/system/UserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/UserMapper.xml
index 7075623..933ae03 100644
--- a/ruoyi-system/src/main/resources/mapper/system/UserMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/UserMapper.xml
@@ -31,6 +31,34 @@
</if>
</select>
+ <!--鏍规嵁鏉′欢鑾峰彇鐢ㄦ埛鍒楄〃锛堝寘鍚秴绾х鐞嗗憳锛�-->
+ <select id="selectUserConditionWithAdmin" resultType="com.ruoyi.common.core.domain.entity.User">
+ select * from (select id,
+ dept_id,
+ account,
+ name,
+ name_en,
+ user_type,
+ email,
+ phone,
+ sex,
+ age,
+ signature_url,
+ picture_url,
+ status,
+ del_flag,
+ login_ip,
+ login_date,
+ depart_lims_id,
+ company,
+ is_custom
+ from user
+ where del_flag = '0') a
+ <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
+ ${ew.customSqlSegment}
+ </if>
+ </select>
+
<!-- 鑾峰彇鐢ㄦ埛閮ㄩ棬 -->
<select id="selectUserDepartmentLimsName" resultType="java.lang.String">
select dl.name
--
Gitblit v1.9.3