From 5e113d775e0143f3ad86e8122aac8015b5d78f1e Mon Sep 17 00:00:00 2001
From: qushaowei <qushaowei@163.com>
Date: 星期六, 28 十月 2023 18:21:48 +0800
Subject: [PATCH] 三保 授权 二保 移交单修改
---
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcDeviceCalendarController.java | 40 +++++++++++++++++++++++++++++++++++-----
1 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcDeviceCalendarController.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcDeviceCalendarController.java
index a55e9bb..f0d7903 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcDeviceCalendarController.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcDeviceCalendarController.java
@@ -1,8 +1,10 @@
package org.jeecg.modules.mdc.controller;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
+import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
@@ -11,7 +13,10 @@
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.mdc.entity.MdcDeviceCalendar;
+import org.jeecg.modules.mdc.entity.MdcSystemParameters;
import org.jeecg.modules.mdc.service.IMdcDeviceCalendarService;
+import org.jeecg.modules.mdc.service.IMdcSystemParametersService;
+import org.jeecg.modules.mdc.util.DateUtils;
import org.jeecg.modules.mdc.vo.EquipmentCalendarVo;
import org.jeecg.modules.mdc.vo.MdcDeviceCalendarQueryVo;
import org.jeecg.modules.mdc.vo.MdcDeviceCalendarVo;
@@ -22,6 +27,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
+import java.util.Date;
/**
* @Description: 璁惧宸ヤ綔鏃ュ巻琛�
@@ -37,6 +43,8 @@
@Resource
private IMdcDeviceCalendarService mdcDeviceCalendarService;
+ @Resource
+ private IMdcSystemParametersService mdcSystemParametersService;
/**
* 鍒嗛〉鍒楄〃鏌ヨ
@@ -70,13 +78,13 @@
@ApiOperation(value = "璁惧宸ヤ綔鏃ュ巻琛�-閰嶇疆", notes = "璁惧宸ヤ綔鏃ュ巻琛�-閰嶇疆")
@PostMapping(value = "/add")
public Result add(@RequestBody EquipmentCalendarVo calendarVo) {
- if (StringUtils.isBlank(calendarVo.getEquipmentId()) || calendarVo.getDateList().isEmpty()) {
+ if (StringUtils.isBlank(calendarVo.getEquipmentId()) || calendarVo.getDateList().isEmpty() || StringUtils.isBlank(calendarVo.getShiftId())) {
return Result.error("璇烽�夋嫨鏈夋晥鍙傛暟锛�");
}
boolean result = mdcDeviceCalendarService.saveCalendar(calendarVo);
- if(result){
+ if (result) {
return Result.OK("淇濆瓨鎴愬姛");
- }else{
+ } else {
return Result.error("鏈�夋嫨鐝锛�");
}
}
@@ -105,8 +113,30 @@
@ApiOperation(value = "璁惧宸ヤ綔鏃ュ巻琛�-閫氳繃id鍒犻櫎", notes = "璁惧宸ヤ綔鏃ュ巻琛�-閫氳繃id鍒犻櫎")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
- mdcDeviceCalendarService.removeById(id);
- return Result.OK("鍒犻櫎鎴愬姛!");
+ Date date = new Date();
+ MdcDeviceCalendar mdcDeviceCalendar = mdcDeviceCalendarService.getById(id);
+ String todayDay = DateUtils.format(date, DateUtils.STRDATE);
+ String effectiveDate = mdcDeviceCalendar.getEffectiveDate();
+ MdcSystemParameters mdcSystemParameters = mdcSystemParametersService.getOne(new LambdaQueryWrapper<MdcSystemParameters>().eq(MdcSystemParameters::getCode, "equip_log_statis_time"));
+ if (mdcSystemParameters != null) {
+ String time = mdcSystemParameters.getValue();
+ Date keyDate = DateUtils.setTimeForDay(date, time);
+ // 20230920 20230910 20230922
+ if (Integer.parseInt(todayDay) <= Integer.parseInt(effectiveDate)) {
+ mdcDeviceCalendarService.removeById(id);
+ return Result.OK("鍒犻櫎鎴愬姛!");
+ } else if ((Integer.parseInt(todayDay) - Integer.parseInt(effectiveDate)) == 1 && keyDate.after(date)) {
+ mdcDeviceCalendarService.removeById(id);
+ return Result.OK("鍒犻櫎鎴愬姛!");
+ }
+ } else {
+ if (Integer.parseInt(todayDay) > Integer.parseInt(effectiveDate)) {
+ return Result.error("鍒犻櫎澶辫触!姝ら厤缃凡浣滀负璁惧鍩虹鏁版嵁璁$畻鏁堢巼锛�");
+ }
+ mdcDeviceCalendarService.removeById(id);
+ return Result.OK("鍒犻櫎鎴愬姛!");
+ }
+ return Result.error("鍒犻櫎澶辫触!姝ら厤缃凡浣滀负璁惧鍩虹鏁版嵁璁$畻鏁堢巼锛�");
}
/**
--
Gitblit v1.9.3