From 699b5fadc595f0b92a435c95a6f583aa2cfcf7f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E7=90=B3?= <1911390090@qq.com> Date: Wed, 19 Jun 2024 16:43:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=A4=E9=80=9A=E6=B5=81=E9=A2=84=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zc-business/pom.xml | 6 + .../controller/DcHolidaysController.java | 113 ++++++++++++++++ .../controller/DcTrafficFlowWarning.java | 111 ++++++++++++++++ .../controller/DcTrafficFlowWarningDate.java | 98 ++++++++++++++ .../zc/business/controller/FTPDeletion.java | 112 ++++++++++++++++ .../com/zc/business/domain/DcHolidays.java | 82 ++++++++++++ .../zc/business/mapper/DcHolidaysMapper.java | 81 ++++++++++++ .../business/service/IDcHolidaysService.java | 81 ++++++++++++ .../service/impl/DcHolidaysServiceImpl.java | 123 ++++++++++++++++++ .../mapper/business/DcHolidaysMapper.xml | 90 +++++++++++++ 10 files changed, 897 insertions(+) create mode 100644 zc-business/src/main/java/com/zc/business/controller/DcHolidaysController.java create mode 100644 zc-business/src/main/java/com/zc/business/controller/DcTrafficFlowWarning.java create mode 100644 zc-business/src/main/java/com/zc/business/controller/DcTrafficFlowWarningDate.java create mode 100644 zc-business/src/main/java/com/zc/business/controller/FTPDeletion.java create mode 100644 zc-business/src/main/java/com/zc/business/domain/DcHolidays.java create mode 100644 zc-business/src/main/java/com/zc/business/mapper/DcHolidaysMapper.java create mode 100644 zc-business/src/main/java/com/zc/business/service/IDcHolidaysService.java create mode 100644 zc-business/src/main/java/com/zc/business/service/impl/DcHolidaysServiceImpl.java create mode 100644 zc-business/src/main/resources/mapper/business/DcHolidaysMapper.xml diff --git a/zc-business/pom.xml b/zc-business/pom.xml index b185377e..d612ab2e 100644 --- a/zc-business/pom.xml +++ b/zc-business/pom.xml @@ -21,6 +21,12 @@ org.eclipse.paho.client.mqttv3 1.2.2 + + + commons-net + commons-net + 3.8.0 + org.json json diff --git a/zc-business/src/main/java/com/zc/business/controller/DcHolidaysController.java b/zc-business/src/main/java/com/zc/business/controller/DcHolidaysController.java new file mode 100644 index 00000000..7c878c5c --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/controller/DcHolidaysController.java @@ -0,0 +1,113 @@ +package com.zc.business.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.common.enums.BusinessType; +import com.zc.business.domain.DcHolidays; +import com.zc.business.service.IDcHolidaysService; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; + +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 节假日 基础数据 +Controller + * + * @author ruoyi + * @date 2024-06-18 + */ +@RestController +@RequestMapping("/system/holidays") +public class DcHolidaysController extends BaseController +{ + @Autowired + private IDcHolidaysService dcHolidaysService; + + /** + * 查询节假日 基础数据 +列表 + */ + @PreAuthorize("@ss.hasPermi('system:holidays:list')") + @GetMapping("/list") + public TableDataInfo list(DcHolidays dcHolidays) + { + startPage(); + List list = dcHolidaysService.selectDcHolidaysList(dcHolidays); + return getDataTable(list); + } + + /** + * 导出节假日 基础数据 +列表 + */ + @PreAuthorize("@ss.hasPermi('system:holidays:export')") + @Log(title = "节假日 基础数据 ", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, DcHolidays dcHolidays) + { + List list = dcHolidaysService.selectDcHolidaysList(dcHolidays); + ExcelUtil util = new ExcelUtil<>(DcHolidays.class); + util.exportExcel(response, list, "节假日 基础数据数据"); + } + + /** + * 获取节假日 基础数据 +详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:holidays:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(dcHolidaysService.selectDcHolidaysById(id)); + } + + /** + * 新增节假日 基础数据 + + */ + @PreAuthorize("@ss.hasPermi('system:holidays:add')") + @Log(title = "节假日 基础数据 ", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody DcHolidays dcHolidays) + { + return toAjax(dcHolidaysService.insertDcHolidays(dcHolidays)); + } + + /** + * 修改节假日 基础数据 + + */ + @PreAuthorize("@ss.hasPermi('system:holidays:edit')") + @Log(title = "节假日 基础数据 ", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody DcHolidays dcHolidays) + { + return toAjax(dcHolidaysService.updateDcHolidays(dcHolidays)); + } + + /** + * 删除节假日 基础数据 + + */ + @PreAuthorize("@ss.hasPermi('system:holidays:remove')") + @Log(title = "节假日 基础数据 ", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(dcHolidaysService.deleteDcHolidaysByIds(ids)); + } +} diff --git a/zc-business/src/main/java/com/zc/business/controller/DcTrafficFlowWarning.java b/zc-business/src/main/java/com/zc/business/controller/DcTrafficFlowWarning.java new file mode 100644 index 00000000..ac4f9484 --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/controller/DcTrafficFlowWarning.java @@ -0,0 +1,111 @@ +package com.zc.business.controller; + +import com.google.gson.Gson; +import com.ruoyi.common.utils.uuid.IdUtils; +import com.ruoyi.common.utils.uuid.UUID; +import com.zc.business.domain.DcHolidays; +import com.zc.business.domain.DcNoStakeWarningTable; +import com.zc.business.service.IDcGantryStatisticsDataService; +import com.zc.business.service.IDcHolidaysService; +import com.zc.business.service.impl.DcNoStakeWarningTableServiceImpl; +import com.zc.common.core.websocket.WebSocketService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.*; + +/** + * + */ + + +@Component +public class DcTrafficFlowWarning { + @Resource + private DcNoStakeWarningTableServiceImpl dcNoStakeWarningTableService; + @Autowired + private IDcHolidaysService dcHolidaysService; + @Autowired + private IDcGantryStatisticsDataService dcGantryStatisticsDataService; + // @Scheduled(cron = "0/10 * * * * ?") + //@Scheduled(cron = "0 0/5 * * * ?") + public void DcTrafficFlow() { + System.out.println("每隔10秒执行一次:" + new Date()); + + // 获取当前日期 + LocalDate currentDate = LocalDate.now(); + // 获取当前年份 + int currentYear = currentDate.getYear(); + DcHolidays dcHolidays = new DcHolidays(); + dcHolidays.setDate(currentYear); + //查询当前年份假期 + List dcHolidaysList = dcHolidaysService.selectDcHolidaysList(dcHolidays); + // 计算当前日期加上七天的日期 + LocalDate dateAfterSevenDays = currentDate.plusDays(7); + // 格式化日期输出(可选) + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + String formattedDate = dateAfterSevenDays.format(formatter); + // String formattedDate ="2024-05-01"; + + for (DcHolidays holidays : dcHolidaysList) { + String vacation = holidays.getVacation(); + String[] dates = vacation.split("\\|"); + //判断当前日期+ 7天 与 日期 数据对比 + if (formattedDate.equals(dates[0])) { + //当前假期名称 + String name = holidays.getName(); + dcHolidays.setDate(currentYear-1); + + DcHolidays dcHolidaysLast = dcHolidaysService.selectDcHolidaysListNameByDate(currentYear-1,name); + String vacation1 = dcHolidaysLast.getVacation(); + + + String[] date = vacation1.split("\\|"); + Map>>> mapListOne = new HashMap<>(); + + Map>> map = new HashMap<>(); + Map>> map2 = new HashMap<>(); + for (int i1 = 0; i1 < date.length; i1++) { + List> mapList = dcGantryStatisticsDataService.realTimeTrafficFlow( date[i1],"1","4"); + List> mapList2 = dcGantryStatisticsDataService.realTimeTrafficFlow(date[i1],"3","4"); + // 计算当前日期加上七天后的日期 + LocalDate dateAfterSevenDay = currentDate.plusDays(7+i1); + DateTimeFormatter formattedDateLst = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + String formatted = dateAfterSevenDay.format(formattedDateLst); + map.put(formatted,mapList); + map2.put(formatted,mapList2); + + } + + mapListOne.put("1",map); + mapListOne.put("3",map2); + + // 创建Gson对象 + Gson gson = new Gson(); + // 将Map转换为JSON字符串 + String jsonString = gson.toJson(mapListOne); + DcNoStakeWarningTable dcNoStakeWarningTable = new DcNoStakeWarningTable(); + + dcNoStakeWarningTable.setWarningDescription(name +"交通流数据预警提醒"); + dcNoStakeWarningTable.setWarningType("1"); + dcNoStakeWarningTable.setOtherConfig(jsonString); + dcNoStakeWarningTable.setWarningTime(new Date()); + + dcNoStakeWarningTableService.addDcNoStakeWarningTable(dcNoStakeWarningTable); + + Map contentMap = new HashMap<>(); + contentMap.put("content",name +"交通流数据预警提醒"); + contentMap.put("trafficFlowDataEarlyWarning",jsonString); + WebSocketService.broadcast("trafficFlowDataEarlyWarning", contentMap); + + // 打印JSON字符串 + System.out.println(jsonString.length()); + + } + } + } +} diff --git a/zc-business/src/main/java/com/zc/business/controller/DcTrafficFlowWarningDate.java b/zc-business/src/main/java/com/zc/business/controller/DcTrafficFlowWarningDate.java new file mode 100644 index 00000000..3ee0c3e3 --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/controller/DcTrafficFlowWarningDate.java @@ -0,0 +1,98 @@ +package com.zc.business.controller; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.zc.business.domain.DcHolidays; +import com.zc.business.service.IDcHolidaysService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.time.LocalDate; +import java.util.List; + +/** + * + */ +@Component +public class DcTrafficFlowWarningDate { + + @Autowired + private IDcHolidaysService dcHolidaysService; + + //@Scheduled(cron = "0/10 * * * * ?") + public void yearPriorToAcquisition() { + + try { + String apiKey = "00b26cbc2cb242283452ac5c842e81d1"; // 替换为你的API密钥 + // 获取当前日期 + LocalDate currentDate = LocalDate.now(); + // 获取前一年 年份 + int currentYear = currentDate.getYear(); + String urlString = "https://apis.tianapi.com/jiejiari/index?key=" + apiKey + "&date=" + currentYear + "&type=1"; + URL url = new URL(urlString); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + + connection.setRequestMethod("GET"); + connection.setRequestProperty("Accept", "application/json"); + + if (connection.getResponseCode() != 200) { + throw new RuntimeException("HTTP错误码:" + connection.getResponseCode()); + } + BufferedReader br = new BufferedReader(new InputStreamReader((connection.getInputStream()))); + String output; + StringBuilder response = new StringBuilder(); + while ((output = br.readLine()) != null) { + response.append(output); + } + connection.disconnect(); + JSONObject jsonResponse = JSONObject.parseObject(response.toString()); + // 检查响应状态是否成功 + if (jsonResponse.getInteger("code") == 200) { + // 获取result对象 + JSONObject resultObj = jsonResponse.getJSONObject("result"); + + // 获取节假日列表JSONArray + JSONArray listArray = resultObj.getJSONArray("list"); + DcHolidays dcHolidays = new DcHolidays(); + dcHolidays.setDate(currentYear); + List dcHolidays1 = dcHolidaysService.selectDcHolidaysList(dcHolidays); + + if (dcHolidays1.size() <=0){ + // 遍历节假日列表 添加数据 + for (int i = 0; i < listArray.size(); i++) { + JSONObject holidayObj = listArray.getJSONObject(i); + String vacation = holidayObj.getString("vacation"); + String name = holidayObj.getString("name"); + dcHolidays.setName(name); + dcHolidays.setVacation(vacation); + // 年份 + dcHolidays.setDate(currentYear); + int i1 = dcHolidaysService.insertDcHolidays(dcHolidays); + } + }else { + // 遍历节假日列表 修改数据 + for (int i = 0; i < listArray.size(); i++) { + JSONObject holidayObj = listArray.getJSONObject(i); + String vacation = holidayObj.getString("vacation"); + String name = holidayObj.getString("name"); + DcHolidays dcHoliday = new DcHolidays(); + dcHoliday.setName(name); + dcHoliday.setVacation(vacation); + // 年份 + dcHoliday.setDate(currentYear); + dcHolidaysService.updateDcHoliday(dcHoliday); + } + + } + +} + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/zc-business/src/main/java/com/zc/business/controller/FTPDeletion.java b/zc-business/src/main/java/com/zc/business/controller/FTPDeletion.java new file mode 100644 index 00000000..b828ba4a --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/controller/FTPDeletion.java @@ -0,0 +1,112 @@ +package com.zc.business.controller; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import org.apache.commons.net.ftp.FTPClient; +import org.apache.commons.net.ftp.FTPFile; + +/** + * + */ + +@Component("FTPDeletion") +@Slf4j +public class FTPDeletion { + + private static int retentionDays = 60; // 默认保存天数为60天 + public void deleteEventFile() { + log.info("定时任务执行,当前保存天气设置天数:"+retentionDays+"当前时间:"+java.time.LocalTime.now()); + new FTPDeletion().remoteFileDeletion(); + } + //修改当前保存天数 + public void deleteEventFile(int days) { + this.retentionDays = days; + } + + //获取当前保存天数 + public int getRetentionDays() { + return retentionDays; + } + // 递归方法来处理文件和目录的删除 + private void deleteDirectoryRecursively(FTPClient ftpClient, String parentDirPath) throws IOException { + + ftpClient.setControlEncoding("GBK"); + + FTPFile[] files = ftpClient.listFiles(parentDirPath); + //选择要保留的天数 + Instant thirtyDaysAgo = Instant.now().minus(retentionDays, ChronoUnit.DAYS); + log.info("当前设置的文件保存天数为:"+FTPDeletion.retentionDays+"当前时间:"+java.time.LocalTime.now()); + for (FTPFile file : files) { + String filePath = parentDirPath + "/" + file.getName(); + + if (file.isDirectory()) { + // 如果是目录,则递归调用 + deleteDirectoryRecursively(ftpClient, filePath); + } else { + // 排除包含特定关键词的文件名 + if (!file.getName().contains("事故")) { + // 删除30天前的文件 + Instant lastModifiedTime = file.getTimestamp().toInstant(); + if (lastModifiedTime.isBefore(thirtyDaysAgo)) { + boolean deleted = ftpClient.deleteFile(filePath); + if (deleted) { + log.info("已删除文件:"+filePath); + + } else { + log.info("无法删除文件:"+filePath); + + } + } + } else { + log.info("文件名包含关键词'事故',跳过删除: :"+file.getName()); + } + } + } + + // 检查并删除空目录(但不删除根目录) + if (!parentDirPath.equals("/")) { + FTPFile[] remainingFiles = ftpClient.listFiles(parentDirPath); + if (remainingFiles.length == 0) { + boolean removed = ftpClient.removeDirectory(parentDirPath); + if (removed) { + log.info("已删除目录:"+parentDirPath); + + } else { + log.info("无法删除目录:"+parentDirPath); + } + } + } + } + + public void remoteFileDeletion() { + String server = "192.168.3.1"; + int port = 21; + String user = "1911390090@qq.com"; + String password = "989878wxl"; + + try { + FTPClient ftpClient = new FTPClient(); + ftpClient.setControlEncoding("GBK"); + ftpClient.connect(server, port); + ftpClient.login(user, password); + ftpClient.enterLocalPassiveMode(); + ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); + + // 指定远程根目录 + String remoteDirPath = "/"; + // 从根目录开始递归删除 + deleteDirectoryRecursively(ftpClient, remoteDirPath); + + ftpClient.logout(); + ftpClient.disconnect(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + +} \ No newline at end of file diff --git a/zc-business/src/main/java/com/zc/business/domain/DcHolidays.java b/zc-business/src/main/java/com/zc/business/domain/DcHolidays.java new file mode 100644 index 00000000..f9f99e85 --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/domain/DcHolidays.java @@ -0,0 +1,82 @@ +package com.zc.business.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 节假日 基础数据 +对象 dc_holidays + * + * @author ruoyi + * @date 2024-06-18 + */ +public class DcHolidays extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 节假日名称 */ + @Excel(name = "节假日名称") + private String name; + + /** 节假日假期 */ + @Excel(name = "节假日假期 ") + private String vacation; + + /** 日期 年份 */ + @Excel(name = "日期 年份") + private Integer date; + + /** $column.columnComment */ + private Long id; + + public void setName(String name) + { + this.name = name; + } + + public String getName() + { + return name; + } + public void setVacation(String vacation) + { + this.vacation = vacation; + } + + public String getVacation() + { + return vacation; + } + public void setDate(Integer date) + { + this.date = date; + } + + public Integer getDate() + { + return date; + } + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("name", getName()) + .append("vacation", getVacation()) + .append("date", getDate()) + .append("createTime", getCreateTime()) + .append("updateTime", getUpdateTime()) + .append("id", getId()) + .toString(); + } +} diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcHolidaysMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcHolidaysMapper.java new file mode 100644 index 00000000..b7752e58 --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/mapper/DcHolidaysMapper.java @@ -0,0 +1,81 @@ +package com.zc.business.mapper; + +import com.zc.business.domain.DcHolidays; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 节假日 基础数据 +Mapper接口 + * + * @author ruoyi + * @date 2024-06-18 + */ +public interface DcHolidaysMapper +{ + /** + * 查询节假日 基础数据 + + * + * @param id 节假日 基础数据 +主键 + * @return 节假日 基础数据 + + */ + public DcHolidays selectDcHolidaysById(Long id); + + /** + * 查询节假日 基础数据 +列表 + * + * @param dcHolidays 节假日 基础数据 + + * @return 节假日 基础数据 +集合 + */ + List selectDcHolidaysList(DcHolidays dcHolidays); + + /** + * 新增节假日 基础数据 + + * + * @param dcHolidays 节假日 基础数据 + + * @return 结果 + */ + int insertDcHolidays(DcHolidays dcHolidays); + + /** + * 修改节假日 基础数据 + + * + * @param dcHolidays 节假日 基础数据 + + * @return 结果 + */ + int updateDcHolidays(DcHolidays dcHolidays); + + /** + * 删除节假日 基础数据 + + * + * @param id 节假日 基础数据 +主键 + * @return 结果 + */ + int deleteDcHolidaysById(Long id); + + /** + * 批量删除节假日 基础数据 + + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + int deleteDcHolidaysByIds(Long[] ids); + + int updateDcHoliday(DcHolidays dcHolidays); + + DcHolidays selectDcHolidaysListNameByDate(@Param("date") int date, @Param("name") String name); +} diff --git a/zc-business/src/main/java/com/zc/business/service/IDcHolidaysService.java b/zc-business/src/main/java/com/zc/business/service/IDcHolidaysService.java new file mode 100644 index 00000000..ba8fb9ed --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/service/IDcHolidaysService.java @@ -0,0 +1,81 @@ +package com.zc.business.service; + +import com.zc.business.domain.DcHolidays; + +import java.util.List; + +/** + * 节假日 基础数据 +Service接口 + * + * @author ruoyi + * @date 2024-06-18 + */ +public interface IDcHolidaysService +{ + /** + * 查询节假日 基础数据 + + * + * @param id 节假日 基础数据 +主键 + * @return 节假日 基础数据 + + */ + public DcHolidays selectDcHolidaysById(Long id); + + /** + * 查询节假日 基础数据 +列表 + * + * @param dcHolidays 节假日 基础数据 + + * @return 节假日 基础数据 +集合 + */ + List selectDcHolidaysList(DcHolidays dcHolidays); + + /** + * 新增节假日 基础数据 + + * + * @param dcHolidays 节假日 基础数据 + + * @return 结果 + */ + int insertDcHolidays(DcHolidays dcHolidays); + + /** + * 修改节假日 基础数据 + + * + * @param dcHolidays 节假日 基础数据 + + * @return 结果 + */ + int updateDcHolidays(DcHolidays dcHolidays); + + /** + * 批量删除节假日 基础数据 + + * + * @param ids 需要删除的节假日 基础数据 +主键集合 + * @return 结果 + */ + int deleteDcHolidaysByIds(Long[] ids); + + /** + * 删除节假日 基础数据 +信息 + * + * @param id 节假日 基础数据 +主键 + * @return 结果 + */ + int deleteDcHolidaysById(Long id); + + int updateDcHoliday(DcHolidays dcHolidays); + + DcHolidays selectDcHolidaysListNameByDate(int date, String name); +} diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcHolidaysServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcHolidaysServiceImpl.java new file mode 100644 index 00000000..b91cd863 --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcHolidaysServiceImpl.java @@ -0,0 +1,123 @@ +package com.zc.business.service.impl; + +import java.util.List; +import com.ruoyi.common.utils.DateUtils; +import com.zc.business.domain.DcHolidays; +import com.zc.business.mapper.DcHolidaysMapper; +import com.zc.business.service.IDcHolidaysService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + + +/** + * 节假日 基础数据 +Service业务层处理 + * + * @author ruoyi + * @date 2024-06-18 + */ +@Service +public class DcHolidaysServiceImpl implements IDcHolidaysService +{ + @Autowired + private DcHolidaysMapper dcHolidaysMapper; + + /** + * 查询节假日 基础数据 + + * + * @param id 节假日 基础数据 +主键 + * @return 节假日 基础数据 + + */ + @Override + public DcHolidays selectDcHolidaysById(Long id) + { + return dcHolidaysMapper.selectDcHolidaysById(id); + } + + /** + * 查询节假日 基础数据 +列表 + * + * @param dcHolidays 节假日 基础数据 + + * @return 节假日 基础数据 + + */ + @Override + public List selectDcHolidaysList(DcHolidays dcHolidays) + { + return dcHolidaysMapper.selectDcHolidaysList(dcHolidays); + } + + /** + * 新增节假日 基础数据 + + * + * @param dcHolidays 节假日 基础数据 + + * @return 结果 + */ + @Override + public int insertDcHolidays(DcHolidays dcHolidays) + { + dcHolidays.setCreateTime(DateUtils.getNowDate()); + return dcHolidaysMapper.insertDcHolidays(dcHolidays); + } + + /** + * 修改节假日 基础数据 + + * + * @param dcHolidays 节假日 基础数据 + + * @return 结果 + */ + @Override + public int updateDcHolidays(DcHolidays dcHolidays) + { + dcHolidays.setUpdateTime(DateUtils.getNowDate()); + return dcHolidaysMapper.updateDcHolidays(dcHolidays); + } + + /** + * 批量删除节假日 基础数据 + + * + * @param ids 需要删除的节假日 基础数据 +主键 + * @return 结果 + */ + @Override + public int deleteDcHolidaysByIds(Long[] ids) + { + return dcHolidaysMapper.deleteDcHolidaysByIds(ids); + } + + /** + * 删除节假日 基础数据 +信息 + * + * @param id 节假日 基础数据 +主键 + * @return 结果 + */ + @Override + public int deleteDcHolidaysById(Long id) + { + return dcHolidaysMapper.deleteDcHolidaysById(id); + } + + @Override + public int updateDcHoliday(DcHolidays dcHolidays) { + dcHolidays.setUpdateTime(DateUtils.getNowDate()); + return dcHolidaysMapper.updateDcHoliday(dcHolidays); + } + + @Override + public DcHolidays selectDcHolidaysListNameByDate(int date, String name) { + return dcHolidaysMapper.selectDcHolidaysListNameByDate(date,name); + } +} diff --git a/zc-business/src/main/resources/mapper/business/DcHolidaysMapper.xml b/zc-business/src/main/resources/mapper/business/DcHolidaysMapper.xml new file mode 100644 index 00000000..faf1e111 --- /dev/null +++ b/zc-business/src/main/resources/mapper/business/DcHolidaysMapper.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + select name, vacation, date, create_time, update_time, id from dc_holidays + + + + + + + + + + insert into dc_holidays + + name, + vacation, + date, + create_time, + update_time, + + + #{name}, + #{vacation}, + #{date}, + #{createTime}, + #{updateTime}, + + + + + update dc_holidays + + name = #{name}, + vacation = #{vacation}, + date = #{date}, + create_time = #{createTime}, + update_time = #{updateTime}, + + where id = #{id} + + + update dc_holidays + + name = #{name}, + vacation = #{vacation}, + date = #{date}, + create_time = #{createTime}, + update_time = #{updateTime}, + + where name = #{name} and date =#{date} + + + + delete from dc_holidays where id = #{id} + + + + delete from dc_holidays where id in + + #{id} + + + \ No newline at end of file