| | |
| | | package org.jeecg.modules.mdc.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.models.auth.In; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.mdc.entity.MdcDeviceCalendar; |
| | | import org.jeecg.modules.mdc.entity.MdcSystemParameters; |
| | | import org.jeecg.modules.mdc.service.IMdcDeviceCalendarService; |
| | | import org.jeecg.modules.mdc.service.IMdcSystemParametersService; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.jeecg.modules.mdc.vo.EquipmentCalendarVo; |
| | | import org.jeecg.modules.mdc.vo.MdcDeviceCalendarQueryVo; |
| | | import org.jeecg.modules.mdc.vo.MdcDeviceCalendarVo; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @Description: 设备工作日历表 |
| | |
| | | |
| | | @Resource |
| | | private IMdcDeviceCalendarService mdcDeviceCalendarService; |
| | | @Resource |
| | | private IMdcSystemParametersService mdcSystemParametersService; |
| | | |
| | | /** |
| | | * 分页列表查询 |
| | |
| | | @ApiOperation(value = "设备工作日历表-通过id删除", notes = "设备工作日历表-通过id删除") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<?> delete(@RequestParam(name = "id", required = true) String id) { |
| | | mdcDeviceCalendarService.removeById(id); |
| | | return Result.OK("删除成功!"); |
| | | MdcDeviceCalendar mdcDeviceCalendar = mdcDeviceCalendarService.getById(id); |
| | | String todayDay = DateUtils.format(new Date(), DateUtils.STRDATE); |
| | | String effectiveDate = mdcDeviceCalendar.getEffectiveDate(); |
| | | MdcSystemParameters mdcSystemParameters = mdcSystemParametersService.getOne(new LambdaQueryWrapper<MdcSystemParameters>().eq(MdcSystemParameters::getCode, "equip_log_statis_time")); |
| | | boolean b = Integer.parseInt(todayDay) > Integer.parseInt(effectiveDate); |
| | | if (mdcSystemParameters != null) { |
| | | String time = mdcSystemParameters.getValue(); |
| | | Date keyDate = DateUtils.setTimeForDay(new Date(), time); |
| | | // 20230920 20230910 20230922 |
| | | if (Integer.parseInt(todayDay) <= Integer.parseInt(effectiveDate)) { |
| | | mdcDeviceCalendarService.removeById(id); |
| | | return Result.OK("删除成功!"); |
| | | } else if (b && keyDate.before(new Date())) { |
| | | mdcDeviceCalendarService.removeById(id); |
| | | return Result.OK("删除成功!"); |
| | | } |
| | | } else { |
| | | if (b) { |
| | | return Result.error("删除失败!"); |
| | | } |
| | | mdcDeviceCalendarService.removeById(id); |
| | | return Result.OK("删除成功!"); |
| | | } |
| | | return Result.error("删除失败!"); |
| | | } |
| | | |
| | | /** |