diff --git a/ktg-mes/src/main/java/com/ktg/mes/cal/controller/CalHolidayController.java b/ktg-mes/src/main/java/com/ktg/mes/cal/controller/CalHolidayController.java new file mode 100644 index 0000000..3f82a3e --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/cal/controller/CalHolidayController.java @@ -0,0 +1,113 @@ +package com.ktg.mes.cal.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import cn.hutool.core.collection.CollUtil; +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.ktg.common.annotation.Log; +import com.ktg.common.core.controller.BaseController; +import com.ktg.common.core.domain.AjaxResult; +import com.ktg.common.enums.BusinessType; +import com.ktg.mes.cal.domain.CalHoliday; +import com.ktg.mes.cal.service.ICalHolidayService; +import com.ktg.common.utils.poi.ExcelUtil; +import com.ktg.common.core.page.TableDataInfo; + +/** + * 节假日设置Controller + * + * @author yinjinlu + * @date 2022-06-08 + */ +@RestController +@RequestMapping("/mes/cal/calholiday") +public class CalHolidayController extends BaseController +{ + @Autowired + private ICalHolidayService calHolidayService; + + /** + * 查询节假日设置列表 + */ + @PreAuthorize("@ss.hasPermi('mes:cal:calholiday:list')") + @GetMapping("/list") + public AjaxResult list(CalHoliday calHoliday) + { + List list = calHolidayService.selectCalHolidayList(calHoliday); + return AjaxResult.success(list); + } + + /** + * 导出节假日设置列表 + */ + @PreAuthorize("@ss.hasPermi('mes:cal:calholiday:export')") + @Log(title = "节假日设置", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, CalHoliday calHoliday) + { + List list = calHolidayService.selectCalHolidayList(calHoliday); + ExcelUtil util = new ExcelUtil(CalHoliday.class); + util.exportExcel(response, list, "节假日设置数据"); + } + + /** + * 获取节假日设置详细信息 + */ + @PreAuthorize("@ss.hasPermi('mes:cal:calholiday:query')") + @GetMapping(value = "/{holidayId}") + public AjaxResult getInfo(@PathVariable("holidayId") Long holidayId) + { + return AjaxResult.success(calHolidayService.selectCalHolidayByHolidayId(holidayId)); + } + + /** + * 新增节假日设置 + */ + @PreAuthorize("@ss.hasPermi('mes:cal:calholiday:add')") + @Log(title = "节假日设置", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody CalHoliday calHoliday) + { + CalHoliday param = new CalHoliday(); + param.setTheDay(calHoliday.getTheDay()); + List days = calHolidayService.selectCalHolidayList(param); + if(CollUtil.isNotEmpty(days)){ + calHoliday.setHolidayId(days.get(0).getHolidayId()); + return toAjax(calHolidayService.updateCalHoliday(calHoliday)); + }else{ + return toAjax(calHolidayService.insertCalHoliday(calHoliday)); + } + } + + /** + * 修改节假日设置 + */ + @PreAuthorize("@ss.hasPermi('mes:cal:calholiday:edit')") + @Log(title = "节假日设置", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody CalHoliday calHoliday) + { + return toAjax(calHolidayService.updateCalHoliday(calHoliday)); + } + + /** + * 删除节假日设置 + */ + @PreAuthorize("@ss.hasPermi('mes:cal:calholiday:remove')") + @Log(title = "节假日设置", businessType = BusinessType.DELETE) + @DeleteMapping("/{holidayIds}") + public AjaxResult remove(@PathVariable Long[] holidayIds) + { + return toAjax(calHolidayService.deleteCalHolidayByHolidayIds(holidayIds)); + } +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/cal/domain/CalHoliday.java b/ktg-mes/src/main/java/com/ktg/mes/cal/domain/CalHoliday.java new file mode 100644 index 0000000..1fbabc7 --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/cal/domain/CalHoliday.java @@ -0,0 +1,155 @@ +package com.ktg.mes.cal.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ktg.common.annotation.Excel; +import com.ktg.common.core.domain.BaseEntity; + +/** + * 节假日设置对象 cal_holiday + * + * @author yinjinlu + * @date 2022-06-08 + */ +public class CalHoliday extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 流水号 */ + private Long holidayId; + + /** 日期 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date theDay; + + /** 日期类型 */ + @Excel(name = "日期类型") + private String holidayType; + + /** 开始时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date startTime; + + /** 结束时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date endTime; + + /** 预留字段1 */ + private String attr1; + + /** 预留字段2 */ + private String attr2; + + /** 预留字段3 */ + private Long attr3; + + /** 预留字段4 */ + private Long attr4; + + public void setHolidayId(Long holidayId) + { + this.holidayId = holidayId; + } + + public Long getHolidayId() + { + return holidayId; + } + public void setTheDay(Date theDay) + { + this.theDay = theDay; + } + + public Date getTheDay() + { + return theDay; + } + public void setHolidayType(String holidayType) + { + this.holidayType = holidayType; + } + + public String getHolidayType() + { + return holidayType; + } + public void setStartTime(Date startTime) + { + this.startTime = startTime; + } + + public Date getStartTime() + { + return startTime; + } + public void setEndTime(Date endTime) + { + this.endTime = endTime; + } + + public Date getEndTime() + { + return endTime; + } + public void setAttr1(String attr1) + { + this.attr1 = attr1; + } + + public String getAttr1() + { + return attr1; + } + public void setAttr2(String attr2) + { + this.attr2 = attr2; + } + + public String getAttr2() + { + return attr2; + } + public void setAttr3(Long attr3) + { + this.attr3 = attr3; + } + + public Long getAttr3() + { + return attr3; + } + public void setAttr4(Long attr4) + { + this.attr4 = attr4; + } + + public Long getAttr4() + { + return attr4; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("holidayId", getHolidayId()) + .append("theDay", getTheDay()) + .append("holidayType", getHolidayType()) + .append("startTime", getStartTime()) + .append("endTime", getEndTime()) + .append("remark", getRemark()) + .append("attr1", getAttr1()) + .append("attr2", getAttr2()) + .append("attr3", getAttr3()) + .append("attr4", getAttr4()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/cal/mapper/CalHolidayMapper.java b/ktg-mes/src/main/java/com/ktg/mes/cal/mapper/CalHolidayMapper.java new file mode 100644 index 0000000..84d4910 --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/cal/mapper/CalHolidayMapper.java @@ -0,0 +1,61 @@ +package com.ktg.mes.cal.mapper; + +import java.util.List; +import com.ktg.mes.cal.domain.CalHoliday; + +/** + * 节假日设置Mapper接口 + * + * @author yinjinlu + * @date 2022-06-08 + */ +public interface CalHolidayMapper +{ + /** + * 查询节假日设置 + * + * @param holidayId 节假日设置主键 + * @return 节假日设置 + */ + public CalHoliday selectCalHolidayByHolidayId(Long holidayId); + + /** + * 查询节假日设置列表 + * + * @param calHoliday 节假日设置 + * @return 节假日设置集合 + */ + public List selectCalHolidayList(CalHoliday calHoliday); + + /** + * 新增节假日设置 + * + * @param calHoliday 节假日设置 + * @return 结果 + */ + public int insertCalHoliday(CalHoliday calHoliday); + + /** + * 修改节假日设置 + * + * @param calHoliday 节假日设置 + * @return 结果 + */ + public int updateCalHoliday(CalHoliday calHoliday); + + /** + * 删除节假日设置 + * + * @param holidayId 节假日设置主键 + * @return 结果 + */ + public int deleteCalHolidayByHolidayId(Long holidayId); + + /** + * 批量删除节假日设置 + * + * @param holidayIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteCalHolidayByHolidayIds(Long[] holidayIds); +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/cal/service/ICalHolidayService.java b/ktg-mes/src/main/java/com/ktg/mes/cal/service/ICalHolidayService.java new file mode 100644 index 0000000..e82cbe2 --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/cal/service/ICalHolidayService.java @@ -0,0 +1,61 @@ +package com.ktg.mes.cal.service; + +import java.util.List; +import com.ktg.mes.cal.domain.CalHoliday; + +/** + * 节假日设置Service接口 + * + * @author yinjinlu + * @date 2022-06-08 + */ +public interface ICalHolidayService +{ + /** + * 查询节假日设置 + * + * @param holidayId 节假日设置主键 + * @return 节假日设置 + */ + public CalHoliday selectCalHolidayByHolidayId(Long holidayId); + + /** + * 查询节假日设置列表 + * + * @param calHoliday 节假日设置 + * @return 节假日设置集合 + */ + public List selectCalHolidayList(CalHoliday calHoliday); + + /** + * 新增节假日设置 + * + * @param calHoliday 节假日设置 + * @return 结果 + */ + public int insertCalHoliday(CalHoliday calHoliday); + + /** + * 修改节假日设置 + * + * @param calHoliday 节假日设置 + * @return 结果 + */ + public int updateCalHoliday(CalHoliday calHoliday); + + /** + * 批量删除节假日设置 + * + * @param holidayIds 需要删除的节假日设置主键集合 + * @return 结果 + */ + public int deleteCalHolidayByHolidayIds(Long[] holidayIds); + + /** + * 删除节假日设置信息 + * + * @param holidayId 节假日设置主键 + * @return 结果 + */ + public int deleteCalHolidayByHolidayId(Long holidayId); +} diff --git a/ktg-mes/src/main/java/com/ktg/mes/cal/service/impl/CalHolidayServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/cal/service/impl/CalHolidayServiceImpl.java new file mode 100644 index 0000000..27399cb --- /dev/null +++ b/ktg-mes/src/main/java/com/ktg/mes/cal/service/impl/CalHolidayServiceImpl.java @@ -0,0 +1,96 @@ +package com.ktg.mes.cal.service.impl; + +import java.util.List; +import com.ktg.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ktg.mes.cal.mapper.CalHolidayMapper; +import com.ktg.mes.cal.domain.CalHoliday; +import com.ktg.mes.cal.service.ICalHolidayService; + +/** + * 节假日设置Service业务层处理 + * + * @author yinjinlu + * @date 2022-06-08 + */ +@Service +public class CalHolidayServiceImpl implements ICalHolidayService +{ + @Autowired + private CalHolidayMapper calHolidayMapper; + + /** + * 查询节假日设置 + * + * @param holidayId 节假日设置主键 + * @return 节假日设置 + */ + @Override + public CalHoliday selectCalHolidayByHolidayId(Long holidayId) + { + return calHolidayMapper.selectCalHolidayByHolidayId(holidayId); + } + + /** + * 查询节假日设置列表 + * + * @param calHoliday 节假日设置 + * @return 节假日设置 + */ + @Override + public List selectCalHolidayList(CalHoliday calHoliday) + { + return calHolidayMapper.selectCalHolidayList(calHoliday); + } + + /** + * 新增节假日设置 + * + * @param calHoliday 节假日设置 + * @return 结果 + */ + @Override + public int insertCalHoliday(CalHoliday calHoliday) + { + calHoliday.setCreateTime(DateUtils.getNowDate()); + return calHolidayMapper.insertCalHoliday(calHoliday); + } + + /** + * 修改节假日设置 + * + * @param calHoliday 节假日设置 + * @return 结果 + */ + @Override + public int updateCalHoliday(CalHoliday calHoliday) + { + calHoliday.setUpdateTime(DateUtils.getNowDate()); + return calHolidayMapper.updateCalHoliday(calHoliday); + } + + /** + * 批量删除节假日设置 + * + * @param holidayIds 需要删除的节假日设置主键 + * @return 结果 + */ + @Override + public int deleteCalHolidayByHolidayIds(Long[] holidayIds) + { + return calHolidayMapper.deleteCalHolidayByHolidayIds(holidayIds); + } + + /** + * 删除节假日设置信息 + * + * @param holidayId 节假日设置主键 + * @return 结果 + */ + @Override + public int deleteCalHolidayByHolidayId(Long holidayId) + { + return calHolidayMapper.deleteCalHolidayByHolidayId(holidayId); + } +} diff --git a/ktg-mes/src/main/resources/mapper/cal/CalHolidayMapper.xml b/ktg-mes/src/main/resources/mapper/cal/CalHolidayMapper.xml new file mode 100644 index 0000000..cfea6a7 --- /dev/null +++ b/ktg-mes/src/main/resources/mapper/cal/CalHolidayMapper.xml @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + + + + + + + + + select holiday_id, the_day, holiday_type, start_time, end_time, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from cal_holiday + + + + + + + + insert into cal_holiday + + the_day, + holiday_type, + start_time, + end_time, + remark, + attr1, + attr2, + attr3, + attr4, + create_by, + create_time, + update_by, + update_time, + + + #{theDay}, + #{holidayType}, + #{startTime}, + #{endTime}, + #{remark}, + #{attr1}, + #{attr2}, + #{attr3}, + #{attr4}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update cal_holiday + + the_day = #{theDay}, + holiday_type = #{holidayType}, + start_time = #{startTime}, + end_time = #{endTime}, + remark = #{remark}, + attr1 = #{attr1}, + attr2 = #{attr2}, + attr3 = #{attr3}, + attr4 = #{attr4}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where holiday_id = #{holidayId} + + + + delete from cal_holiday where holiday_id = #{holidayId} + + + + delete from cal_holiday where holiday_id in + + #{holidayId} + + + \ No newline at end of file