| | |
| | | package org.jeecg.modules.eam.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.util.DateUtils; |
| | | import org.jeecg.modules.eam.entity.EamEquipment; |
| | | import org.jeecg.modules.eam.entity.EamEquipmentExtend; |
| | | import org.jeecg.modules.eam.entity.EamThirdMaintenanceWorkPlanSheet; |
| | | import org.jeecg.modules.eam.mapper.EamEquipmentExtendMapper; |
| | | import org.jeecg.modules.eam.mapper.EamEquipmentMapper; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentExtendService; |
| | | import org.jeecg.modules.eam.service.IEamThirdMaintenanceWorkPlanSheetService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDate; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @Description: 设备台账扩展表 |
| | |
| | | |
| | | @Resource |
| | | private EamEquipmentExtendMapper eamEquipmentExtendMapper; |
| | | |
| | | @Autowired |
| | | private IEamThirdMaintenanceWorkPlanSheetService eamThirdMaintenanceWorkPlanSheetService; |
| | | |
| | | @Resource |
| | | private EamEquipmentMapper eamEquipmentMapper; |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | eamEquipmentExtendMapper.updateById(entity); |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updateTechnologyParam(String equipmentId, String status, Date evaluationDate, String technologyGenerateFlag) { |
| | | if (StringUtils.isBlank(status) && StringUtils.isBlank(technologyGenerateFlag) && evaluationDate == null) { |
| | | return false; |
| | | } |
| | | EamEquipmentExtend entity = this.getBaseMapper().selectById(equipmentId); |
| | | UpdateWrapper<EamEquipmentExtend> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("id", equipmentId); |
| | | if (StringUtils.isNotBlank(status)) { |
| | | entity.setTechnologyStatus(status); |
| | | } |
| | | if (StringUtils.isNotBlank(technologyGenerateFlag)) { |
| | | entity.setTechnologyGenerateFlag(technologyGenerateFlag); |
| | | } |
| | | if (evaluationDate != null) { |
| | | entity.setLatestTechnologyCheck(evaluationDate); |
| | | if (entity.getTechnologyCheckPeriod() != null) { |
| | | entity.setNextTechnologyCheck(DateUtils.addYear(entity.getLatestTechnologyCheck(), entity.getTechnologyCheckPeriod())); |
| | | } |
| | | } |
| | | return this.getBaseMapper().updateById(entity) > 0; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updateThirdMaintenanceParam(String equipmentId, String status, Date evaluationDate, String thirdMaintenanceGenerateFlag) { |
| | | if (StringUtils.isBlank(status) && StringUtils.isBlank(thirdMaintenanceGenerateFlag) && evaluationDate == null) { |
| | | return false; |
| | | } |
| | | EamEquipmentExtend entity = this.getBaseMapper().selectById(equipmentId); |
| | | UpdateWrapper<EamEquipmentExtend> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("id", equipmentId); |
| | | if (StringUtils.isNotBlank(status)) { |
| | | entity.setMaintenanceStatus(status); |
| | | } |
| | | if (StringUtils.isNotBlank(thirdMaintenanceGenerateFlag)) { |
| | | entity.setThirdMaintenanceGenerateFlag(thirdMaintenanceGenerateFlag); |
| | | } |
| | | if (evaluationDate != null) { |
| | | entity.setLatestThirdMaintenance(evaluationDate); |
| | | if (entity.getThirdMaintenancePeriod() != null) { |
| | | entity.setNextThirdMaintenance(DateUtils.addYear(entity.getLatestThirdMaintenance(), entity.getThirdMaintenancePeriod())); |
| | | } |
| | | } |
| | | |
| | | EamEquipment eamEquipment = eamEquipmentMapper.selectById(equipmentId); |
| | | EamThirdMaintenanceWorkPlanSheet eamThirdMaintenanceWorkPlanSheet=new EamThirdMaintenanceWorkPlanSheet(); |
| | | BeanUtils.copyProperties(eamEquipment,eamThirdMaintenanceWorkPlanSheet); |
| | | eamThirdMaintenanceWorkPlanSheet.setId(null); |
| | | eamThirdMaintenanceWorkPlanSheet.setMaintenanceDate(eamEquipment.getLatestThirdMaintenance()); |
| | | eamThirdMaintenanceWorkPlanSheetService.add(eamThirdMaintenanceWorkPlanSheet); |
| | | |
| | | return this.getBaseMapper().updateById(entity) > 0; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updateSecondMaintenanceParam(String equipmentId, String status,String secondMaintenanceGenerateFlag){ |
| | | if (StringUtils.isBlank(status) && StringUtils.isBlank(secondMaintenanceGenerateFlag)) { |
| | | return false; |
| | | } |
| | | EamEquipmentExtend entity = this.getBaseMapper().selectById(equipmentId); |
| | | UpdateWrapper<EamEquipmentExtend> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("id", equipmentId); |
| | | if (StringUtils.isNotBlank(status)) { |
| | | entity.setMaintenanceStatus(status); |
| | | } |
| | | //二保默认生成六个月后 |
| | | // 转换为LocalDate处理日期 |
| | | LocalDate localDate = DateUtils.dateToLocalDate(entity.getLatestSecondMaintenance()); |
| | | // 计算六个月后的日期 |
| | | LocalDate sixMonthsLater = localDate.plusMonths(6); |
| | | // 调整到当月的最后一天 |
| | | LocalDate lastDayOfMonth = sixMonthsLater.with(TemporalAdjusters.lastDayOfMonth()); |
| | | entity.setNextSecondMaintenance(DateUtils.localDateToDate(lastDayOfMonth)); |
| | | |
| | | return this.getBaseMapper().updateById(entity) > 0; |
| | | } |
| | | } |