王兴琳
5 months ago
10 changed files with 897 additions and 0 deletions
@ -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<DcHolidays> 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<DcHolidays> list = dcHolidaysService.selectDcHolidaysList(dcHolidays); |
|||
ExcelUtil<DcHolidays> 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)); |
|||
} |
|||
} |
@ -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<DcHolidays> 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<String, Map<String, List<Map<String,String>>>> mapListOne = new HashMap<>(); |
|||
|
|||
Map<String, List<Map<String,String>>> map = new HashMap<>(); |
|||
Map<String, List<Map<String,String>>> map2 = new HashMap<>(); |
|||
for (int i1 = 0; i1 < date.length; i1++) { |
|||
List<Map<String,String>> mapList = dcGantryStatisticsDataService.realTimeTrafficFlow( date[i1],"1","4"); |
|||
List<Map<String,String>> 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<String,Object> contentMap = new HashMap<>(); |
|||
contentMap.put("content",name +"交通流数据预警提醒"); |
|||
contentMap.put("trafficFlowDataEarlyWarning",jsonString); |
|||
WebSocketService.broadcast("trafficFlowDataEarlyWarning", contentMap); |
|||
|
|||
// 打印JSON字符串
|
|||
System.out.println(jsonString.length()); |
|||
|
|||
} |
|||
} |
|||
} |
|||
} |
@ -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<DcHolidays> 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(); |
|||
} |
|||
} |
|||
} |
@ -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(); |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
@ -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(); |
|||
} |
|||
} |
@ -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<DcHolidays> 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); |
|||
} |
@ -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<DcHolidays> 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); |
|||
} |
@ -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<DcHolidays> 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); |
|||
} |
|||
} |
@ -0,0 +1,90 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<!DOCTYPE mapper |
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.zc.business.mapper.DcHolidaysMapper"> |
|||
|
|||
<resultMap type="com.zc.business.domain.DcHolidays" id="DcHolidaysResult"> |
|||
<result property="name" column="name" /> |
|||
<result property="vacation" column="vacation" /> |
|||
<result property="date" column="date" /> |
|||
<result property="createTime" column="create_time" /> |
|||
<result property="updateTime" column="update_time" /> |
|||
<result property="id" column="id" /> |
|||
</resultMap> |
|||
|
|||
<sql id="selectDcHolidaysVo"> |
|||
select name, vacation, date, create_time, update_time, id from dc_holidays |
|||
</sql> |
|||
|
|||
<select id="selectDcHolidaysList" parameterType="DcHolidays" resultMap="DcHolidaysResult"> |
|||
<include refid="selectDcHolidaysVo"/> |
|||
<where> |
|||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> |
|||
<if test="vacation != null and vacation != ''"> and vacation = #{vacation}</if> |
|||
<if test="date != null "> and date = #{date}</if> |
|||
</where> |
|||
</select> |
|||
|
|||
<select id="selectDcHolidaysById" parameterType="Long" resultMap="DcHolidaysResult"> |
|||
<include refid="selectDcHolidaysVo"/> |
|||
where id = #{id} |
|||
</select> |
|||
|
|||
<select id="selectDcHolidaysListNameByDate" resultMap="DcHolidaysResult"> |
|||
<include refid="selectDcHolidaysVo"/> |
|||
where date= #{date} and name =#{name} |
|||
</select> |
|||
|
|||
<insert id="insertDcHolidays" parameterType="DcHolidays" useGeneratedKeys="true" keyProperty="id"> |
|||
insert into dc_holidays |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="name != null">name,</if> |
|||
<if test="vacation != null">vacation,</if> |
|||
<if test="date != null">date,</if> |
|||
<if test="createTime != null">create_time,</if> |
|||
<if test="updateTime != null">update_time,</if> |
|||
</trim> |
|||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
|||
<if test="name != null">#{name},</if> |
|||
<if test="vacation != null">#{vacation},</if> |
|||
<if test="date != null">#{date},</if> |
|||
<if test="createTime != null">#{createTime},</if> |
|||
<if test="updateTime != null">#{updateTime},</if> |
|||
</trim> |
|||
</insert> |
|||
|
|||
<update id="updateDcHolidays" parameterType="DcHolidays"> |
|||
update dc_holidays |
|||
<trim prefix="SET" suffixOverrides=","> |
|||
<if test="name != null">name = #{name},</if> |
|||
<if test="vacation != null">vacation = #{vacation},</if> |
|||
<if test="date != null">date = #{date},</if> |
|||
<if test="createTime != null">create_time = #{createTime},</if> |
|||
<if test="updateTime != null">update_time = #{updateTime},</if> |
|||
</trim> |
|||
where id = #{id} |
|||
</update> |
|||
<update id="updateDcHoliday" parameterType="DcHolidays"> |
|||
update dc_holidays |
|||
<trim prefix="SET" suffixOverrides=","> |
|||
<if test="name != null">name = #{name},</if> |
|||
<if test="vacation != null">vacation = #{vacation},</if> |
|||
<if test="date != null">date = #{date},</if> |
|||
<if test="createTime != null">create_time = #{createTime},</if> |
|||
<if test="updateTime != null">update_time = #{updateTime},</if> |
|||
</trim> |
|||
where name = #{name} and date =#{date} |
|||
</update> |
|||
|
|||
<delete id="deleteDcHolidaysById" parameterType="Long"> |
|||
delete from dc_holidays where id = #{id} |
|||
</delete> |
|||
|
|||
<delete id="deleteDcHolidaysByIds" parameterType="String"> |
|||
delete from dc_holidays where id in |
|||
<foreach item="id" collection="array" open="(" separator="," close=")"> |
|||
#{id} |
|||
</foreach> |
|||
</delete> |
|||
</mapper> |
Loading…
Reference in new issue