|
|
@@ -5,7 +5,9 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.zd.common.core.annotation.Log;
|
|
|
+import com.zd.common.core.annotation.PreAuthorize;
|
|
|
import com.zd.common.core.log.BusinessType;
|
|
|
+import com.zd.common.core.redis.RedisService;
|
|
|
import com.zd.common.core.utils.StringUtils;
|
|
|
import com.zd.common.core.web.controller.BaseController;
|
|
|
import com.zd.laboratory.api.entity.LabMessageContent;
|
|
|
@@ -17,13 +19,17 @@ import com.zd.laboratory.domain.vo.LabTimedExhaustVo;
|
|
|
import com.zd.laboratory.mapper.LabTimedExhaustJoinsubMapper;
|
|
|
import com.zd.laboratory.service.ILabMessageContentService;
|
|
|
import com.zd.laboratory.service.ILabTimedExhaustService;
|
|
|
+import com.zd.model.constant.BaseConstants;
|
|
|
import com.zd.model.domain.ResultData;
|
|
|
+import com.zd.model.domain.per.PerFun;
|
|
|
+import com.zd.model.domain.per.PerPrefix;
|
|
|
import com.zd.model.page.TableDataInfo;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
* 定时排风表Controller
|
|
|
@@ -44,6 +50,10 @@ public class LabTimedExhaustController extends BaseController {
|
|
|
@Autowired
|
|
|
private ILabMessageContentService labMessageContentService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RedisService redisService;
|
|
|
+
|
|
|
+ @PreAuthorize(hasPermi = PerPrefix.LABORATORY_EXHAUST + PerFun.LIST)
|
|
|
@ApiOperation(value = "定时排风列表")
|
|
|
@GetMapping("/list")
|
|
|
public TableDataInfo list(LabTimedExhaust labTimedExhaust) {
|
|
|
@@ -55,6 +65,7 @@ public class LabTimedExhaustController extends BaseController {
|
|
|
/**
|
|
|
* 新增定时排风
|
|
|
*/
|
|
|
+ @PreAuthorize(hasPermi = PerPrefix.LABORATORY_EXHAUST + PerFun.ADD)
|
|
|
@ApiOperation(value = "新增定时排风")
|
|
|
@Log(title = "新增定时排风", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
@@ -65,6 +76,7 @@ public class LabTimedExhaustController extends BaseController {
|
|
|
/**
|
|
|
* 修改定时排风
|
|
|
*/
|
|
|
+ @PreAuthorize(hasPermi = PerPrefix.LABORATORY_EXHAUST + PerFun.EDIT)
|
|
|
@ApiOperation(value = "修改定时排风")
|
|
|
@Log(title = "修改定时排风", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
@@ -75,6 +87,7 @@ public class LabTimedExhaustController extends BaseController {
|
|
|
/**
|
|
|
* 定时排风启用停用
|
|
|
*/
|
|
|
+ @PreAuthorize(hasPermi = PerPrefix.LABORATORY_EXHAUST + PerFun.EDIT)
|
|
|
@ApiOperation(value = "定时排风启用停用")
|
|
|
@Log(title = "定时排风启用停用", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping("/operateExhaust")
|
|
|
@@ -85,6 +98,7 @@ public class LabTimedExhaustController extends BaseController {
|
|
|
/**
|
|
|
* 获取定时排风详细信息
|
|
|
*/
|
|
|
+ @PreAuthorize(hasPermi = PerPrefix.LABORATORY_EXHAUST + PerFun.QUERY)
|
|
|
@ApiOperation(value = "获取定时排风详细信息")
|
|
|
@GetMapping(value = "/{id}")
|
|
|
public ResultData<LabTimedExhaustVo> getInfo(@PathVariable("id") Long id) {
|
|
|
@@ -117,6 +131,7 @@ public class LabTimedExhaustController extends BaseController {
|
|
|
/**
|
|
|
* 删除定时排风
|
|
|
*/
|
|
|
+ @PreAuthorize(hasPermi = PerPrefix.LABORATORY_EXHAUST + PerFun.REMOVE)
|
|
|
@ApiOperation(value = "删除定时排风")
|
|
|
@DeleteMapping("/{ids}")
|
|
|
public ResultData remove(@PathVariable Long[] ids) {
|
|
|
@@ -132,12 +147,18 @@ public class LabTimedExhaustController extends BaseController {
|
|
|
public ResultData<List<String>> getHoliday() {
|
|
|
List<String> arr = new ArrayList <>();
|
|
|
try{
|
|
|
- String str = HttpUtil.get("https://api.apihubs.cn/holiday/get?year=2023&holiday_recess=1&order_by=1&cn=1&size=100",2000);
|
|
|
- JSONArray jsonObject = JSON.parseObject(str).getJSONObject("data").getJSONArray("list");
|
|
|
- for (int i=0;i<jsonObject.size();i++) {
|
|
|
- JSONObject json = jsonObject.getJSONObject(i);
|
|
|
- arr.add(json.getString("date"));
|
|
|
-// System.out.println(""+json.getString("date"));
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ int yearInt = calendar.get(Calendar.YEAR);
|
|
|
+ if (redisService.getCacheObject(BaseConstants.HOLIDAY_TIME+""+ yearInt) == null) {
|
|
|
+ String str = HttpUtil.get("https://api.apihubs.cn/holiday/get?year="+yearInt+"&holiday_recess=1&order_by=1&cn=1&size=100",2000);
|
|
|
+ JSONArray jsonObject = JSON.parseObject(str).getJSONObject("data").getJSONArray("list");
|
|
|
+ for (int i=0;i<jsonObject.size();i++) {
|
|
|
+ JSONObject json = jsonObject.getJSONObject(i);
|
|
|
+ arr.add(json.getString("date"));
|
|
|
+ }
|
|
|
+ redisService.setCacheObject(BaseConstants.HOLIDAY_TIME+""+ yearInt,arr, 7L, TimeUnit.DAYS);
|
|
|
+ }else{
|
|
|
+ arr = redisService.getCacheObject(BaseConstants.HOLIDAY_TIME+""+ yearInt);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
return ResultData.success(new ArrayList <>());
|