| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | |
| | | import org.jeecg.modules.eam.base.entity.BaseFactoryUser; |
| | | import org.jeecg.modules.eam.base.service.IBaseFactoryService; |
| | | import org.jeecg.modules.eam.base.service.IBaseFactoryUserService; |
| | | import org.jeecg.modules.eam.constant.MaintenanceStandardStatusEnum; |
| | | import org.jeecg.modules.eam.constant.TechnicalStatusEvaluationStandardEnum; |
| | | import org.jeecg.modules.eam.entity.EamMaintenanceStandard; |
| | | import org.jeecg.modules.eam.entity.EamMaintenanceStandardDetail; |
| | | import org.jeecg.modules.eam.entity.EamTechnicalStatusEvaluationStandard; |
| | | import org.jeecg.modules.eam.entity.EamTechnicalStatusEvaluationStandardDetail; |
| | | import org.jeecg.modules.eam.mapper.EamTechnicalStatusEvaluationStandardMapper; |
| | |
| | | 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 java.util.ArrayList; |
| | |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean upgrade(EamTechnicalStatusEvaluationStandardRequest request) { |
| | | EamTechnicalStatusEvaluationStandard entity = this.getBaseMapper().selectById(request.getId()); |
| | | if(entity == null){ |
| | | throw new JeecgBootException("升版的数据已删除,请刷新重试!"); |
| | | } |
| | | |
| | | //新增一个版本 |
| | | EamTechnicalStatusEvaluationStandard newEntity = new EamTechnicalStatusEvaluationStandard(); |
| | | newEntity.setStandardCode(request.getStandardCode()); |
| | | newEntity.setStandardName(request.getStandardName()); |
| | | newEntity.setEvaluationPeriod(request.getEvaluationPeriod()); |
| | | newEntity.setStandardStatus(TechnicalStatusEvaluationStandardEnum.ENABLE.name()); |
| | | //版本递增 |
| | | newEntity.setStandardVersion(SimpleVersionGenerateUtil.addVersion(entity.getStandardVersion())); |
| | | //设备处理 |
| | | newEntity.setEquipmentId(request.getEquipmentId()); |
| | | //删除标记 |
| | | newEntity.setDelFlag(CommonConstant.DEL_FLAG_0); |
| | | //重复性校验 |
| | | EamTechnicalStatusEvaluationStandard exist = checkDuplicate(newEntity.getEquipmentId(), entity.getId()); |
| | | if(exist != null){ |
| | | throw new JeecgBootException("鉴定规范已存在,不能重复添加!"); |
| | | } |
| | | this.getBaseMapper().insert(newEntity); |
| | | //处理明细数据 |
| | | if(CollectionUtil.isNotEmpty(request.getTableDetailList())) { |
| | | request.getTableDetailList().forEach(tableDetail -> { |
| | | tableDetail.setId(null); |
| | | tableDetail.setCreateBy(null); |
| | | tableDetail.setUpdateBy(null); |
| | | tableDetail.setCreateTime(null); |
| | | tableDetail.setUpdateTime(null); |
| | | tableDetail.setStandardId(newEntity.getId()); |
| | | }); |
| | | standardDetailService.saveBatch(request.getTableDetailList()); |
| | | } |
| | | //禁用原来的版本 |
| | | entity.setStandardStatus(TechnicalStatusEvaluationStandardEnum.DISABLE.name()); |
| | | this.getBaseMapper().updateById(entity); |
| | | return true; |
| | | } |
| | | } |