From 44f2a0a32c096bdb05d4cc0ac162cdc1eb14c3ed Mon Sep 17 00:00:00 2001
From: Administrator <1144154118@qq.com>
Date: 星期四, 10 八月 2023 13:14:29 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ard-work/src/main/java/com/ruoyi/app/patrolplan/service/impl/ArdAppPatrolpointRecordServiceImpl.java | 138 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 138 insertions(+), 0 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/app/patrolplan/service/impl/ArdAppPatrolpointRecordServiceImpl.java b/ard-work/src/main/java/com/ruoyi/app/patrolplan/service/impl/ArdAppPatrolpointRecordServiceImpl.java
index 887f965..c09b1fd 100644
--- a/ard-work/src/main/java/com/ruoyi/app/patrolplan/service/impl/ArdAppPatrolpointRecordServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/app/patrolplan/service/impl/ArdAppPatrolpointRecordServiceImpl.java
@@ -1,8 +1,22 @@
package com.ruoyi.app.patrolplan.service.impl;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
import java.util.List;
+import java.util.Map;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.ruoyi.app.patrolplan.domain.ArdAppPatrolplan;
+import com.ruoyi.app.patrolplan.domain.ArdAppPatrolpointRecordImg;
+import com.ruoyi.app.patrolplan.domain.param.ArdAppPatrolpointRecordParam;
+import com.ruoyi.app.patrolplan.mapper.ArdAppPatrolplanMapper;
+import com.ruoyi.app.patrolplan.mapper.ArdAppPatrolpointRecordImgMapper;
import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.uuid.IdUtils;
+import com.ruoyi.utils.result.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.app.patrolplan.mapper.ArdAppPatrolpointRecordMapper;
@@ -10,6 +24,7 @@
import com.ruoyi.app.patrolplan.service.IArdAppPatrolpointRecordService;
import javax.annotation.Resource;
+import javax.xml.crypto.Data;
/**
* app宸℃璁″垝璁板綍Service涓氬姟灞傚鐞�
@@ -21,6 +36,12 @@
public class ArdAppPatrolpointRecordServiceImpl implements IArdAppPatrolpointRecordService {
@Resource
private ArdAppPatrolpointRecordMapper ardAppPatrolpointRecordMapper;
+
+ @Resource
+ private ArdAppPatrolpointRecordImgMapper recordImgMapper;
+
+ @Resource
+ private ArdAppPatrolplanMapper patrolplanMapper;
/**
* 鏌ヨapp宸℃璁″垝璁板綍
@@ -88,4 +109,121 @@
public int deleteArdAppPatrolpointRecordById(String id) {
return ardAppPatrolpointRecordMapper.deleteArdAppPatrolpointRecordById(id);
}
+
+ @Override
+ public Results record(ArdAppPatrolpointRecord ardAppPatrolpointRecord) {
+ String id = IdUtils.simpleUUID();
+ ardAppPatrolpointRecord.setId(id);
+ int num = ardAppPatrolpointRecordMapper.insert(ardAppPatrolpointRecord);
+ List<String> list = ardAppPatrolpointRecord.getImg();
+ for (int i = 0; i < list.size(); i++) {
+ ArdAppPatrolpointRecordImg recordImg = new ArdAppPatrolpointRecordImg();
+ String imgId = IdUtils.simpleUUID();
+ recordImg.setId(imgId);
+ recordImg.setAppPatrolponitRecordId(id);
+ recordImg.setImg(list.get(i));
+ recordImgMapper.insert(recordImg);
+ }
+ if(num>0){
+ return Results.succeed("鎵撳崱鎴愬姛锛�");
+ }else {
+ return Results.error("鎵撳紑澶辫触锛�");
+ }
+ }
+
+ @Override
+ public Results recordMonth(ArdAppPatrolpointRecordParam ardAppPatrolpointRecordParam) throws ParseException {
+ //鑾峰彇鍓嶇鍙傛暟
+ String begin = ardAppPatrolpointRecordParam.getBegin();
+ String end = ardAppPatrolpointRecordParam.getEnd();
+ String planId = ardAppPatrolpointRecordParam.getPlanId();
+ //鏌ヨ璁″垝琛�
+ ArdAppPatrolplan ardAppPatrolplan = patrolplanMapper.selectById(planId);
+ //鏌ヨ鍑烘湁鏁堟墦鍗℃暟鎹�
+ QueryWrapper<ArdAppPatrolpointRecord> queryWrapper = new QueryWrapper<>();
+ queryWrapper.between("record_time",begin,end).eq("plan_id",planId);
+ List<ArdAppPatrolpointRecord> list = ardAppPatrolpointRecordMapper.selectList(queryWrapper);
+ //鏃堕棿鎷嗗垎
+ String[] parts = end.split("[-\\s:]");
+ int year = Integer.parseInt(parts[0]);
+ int month = Integer.parseInt(parts[1]);
+ int day = Integer.parseInt(parts[2]);
+ String monthZero;
+ if(month<10){
+ monthZero = String.format("%02d", month);
+ }else {
+ monthZero = String.valueOf(month);
+ }
+ JSONArray jsonArray = new JSONArray();
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ for (int i = 1; i <= day; i++) {
+ String di;
+ if(i<10){
+ di = String.format("%02d", i);
+ }else {
+ di = String.valueOf(i);
+ }
+ JSONObject jsonObject = new JSONObject();
+ Boolean planBoolean = false;
+ //寰幆姣忎竴澶�
+ String ymd = year+"-"+monthZero+"-"+di;
+ Date ymdDate = dateFormat.parse(ymd);
+ //鍖归厤璁″垝鏃堕棿
+ String cycle = ardAppPatrolplan.getCycle();
+ if(cycle.equals("day")){
+ String createTime = ardAppPatrolplan.getCreateTime();
+ Date beginCreateDate = dateFormat.parse(createTime);
+ int d = ymdDate.compareTo(beginCreateDate);
+ if(d>=0){
+ planBoolean = true;
+ }
+ }else if(cycle.equals("once")){
+ String onceBegin = ardAppPatrolplan.getPatroBeginTime();
+ Date onceBeginDate = dateFormat.parse(onceBegin);
+ String onceEnd = ardAppPatrolplan.getPatroEndTime();
+ Date onceEndDate = dateFormat.parse(onceEnd);
+ int bd = ymdDate.compareTo(onceBeginDate);
+ int ed = ymdDate.compareTo(onceEndDate);
+ if(bd>=0 && ed<=0){
+ planBoolean = true;
+ }
+ }
+ //鍖归厤鎵撳崱鏃堕棿
+ Boolean or = false;
+ if(planBoolean){
+ for (int j = 0; j < list.size(); j++) {
+ //鎵撳崱鏃堕棿鎷嗗垎
+ String recordTime = list.get(j).getRecordTime();
+ String[] part = recordTime.split("[-\\s:]");
+ int recordYear = Integer.parseInt(part[0]);
+ int recordMonth = Integer.parseInt(part[1]);
+ String recordMonthZero;
+ if(i<10){
+ recordMonthZero = String.format("%02d", recordMonth);
+ }else {
+ recordMonthZero = String.valueOf(recordMonth);
+ }
+ int recordDay = Integer.parseInt(part[2]);
+ String recordDayZero;
+ if(i<10){
+ recordDayZero = String.format("%02d", recordDay);
+ }else {
+ recordDayZero = String.valueOf(recordDay);
+ }
+ String recordDate = recordYear+"-"+recordMonthZero+"-"+recordDayZero;
+ //濡傛灉鐩哥瓑璇存槑杩欏ぉ鏈夋墦鍗¤褰曡褰�
+ if(ymd.equals(recordDate)){
+ or = true;
+ break;
+ }
+ }
+ }
+ jsonObject.put("toDay",ymd );
+ jsonObject.put("plan",planBoolean);
+ jsonObject.put("record",or);
+ jsonArray.add(jsonObject);
+ }
+ return Results.succeed(jsonArray);
+ }
+
}
--
Gitblit v1.9.3