| | |
| | | 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 = "设备工作日历表-配置", notes = "设备工作日历表-配置") |
| | | @PostMapping(value = "/add") |
| | | public Result add(@RequestBody EquipmentCalendarVo calendarVo) { |
| | | if (StringUtils.isBlank(calendarVo.getEquipmentId())) { |
| | | return Result.error("未选择设备"); |
| | | if (StringUtils.isBlank(calendarVo.getEquipmentId()) || calendarVo.getDateList().isEmpty() || StringUtils.isBlank(calendarVo.getShiftId())) { |
| | | return Result.error("请选择有效参数!"); |
| | | } |
| | | boolean result = mdcDeviceCalendarService.saveCalendar(calendarVo); |
| | | if(result){ |
| | | if (result) { |
| | | return Result.OK("保存成功"); |
| | | }else{ |
| | | } else { |
| | | return Result.error("未选择班次!"); |
| | | } |
| | | } |
| | |
| | | @ApiOperation(value = "设备工作日历表-通过id删除", notes = "设备工作日历表-通过id删除") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<?> delete(@RequestParam(name = "id", required = true) String id) { |
| | | mdcDeviceCalendarService.removeById(id); |
| | | return Result.OK("删除成功!"); |
| | | Date date = new Date(); |
| | | MdcDeviceCalendar mdcDeviceCalendar = mdcDeviceCalendarService.getById(id); |
| | | String todayDay = DateUtils.format(date, DateUtils.STRDATE); |
| | | String effectiveDate = mdcDeviceCalendar.getEffectiveDate(); |
| | | MdcSystemParameters mdcSystemParameters = mdcSystemParametersService.getOne(new LambdaQueryWrapper<MdcSystemParameters>().eq(MdcSystemParameters::getCode, "equip_log_statis_time")); |
| | | if (mdcSystemParameters != null) { |
| | | String time = mdcSystemParameters.getValue(); |
| | | Date keyDate = DateUtils.setTimeForDay(date, time); |
| | | // 20230920 20230910 20230922 |
| | | if (Integer.parseInt(todayDay) <= Integer.parseInt(effectiveDate)) { |
| | | mdcDeviceCalendarService.removeById(id); |
| | | return Result.OK("删除成功!"); |
| | | } else if ((Integer.parseInt(todayDay) - Integer.parseInt(effectiveDate)) == 1 && keyDate.after(date)) { |
| | | mdcDeviceCalendarService.removeById(id); |
| | | return Result.OK("删除成功!"); |
| | | } |
| | | } else { |
| | | if (Integer.parseInt(todayDay) > Integer.parseInt(effectiveDate)) { |
| | | return Result.error("删除失败!此配置已作为设备基础数据计算效率!"); |
| | | } |
| | | mdcDeviceCalendarService.removeById(id); |
| | | return Result.OK("删除成功!"); |
| | | } |
| | | return Result.error("删除失败!此配置已作为设备基础数据计算效率!"); |
| | | } |
| | | |
| | | /** |