| | |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.constant.DataBaseConstant; |
| | | import org.jeecg.common.exception.JeecgBootException; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.eam.constant.MaintenanceStatusEnum; |
| | | import org.jeecg.modules.eam.constant.OrderCreationMethodEnum; |
| | | import org.jeecg.modules.eam.entity.EamEquipment; |
| | | import org.jeecg.modules.eam.entity.EamWeekMaintenanceOrder; |
| | | import org.jeecg.modules.eam.entity.EamWeekMaintenanceOrderDetail; |
| | | import org.jeecg.modules.eam.mapper.EamWeekMaintenanceOrderMapper; |
| | | import org.jeecg.modules.eam.request.EamWeekMaintenanceQuery; |
| | | import org.jeecg.modules.eam.request.EamWeekMaintenanceRequest; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description: 周保工单 |
| | |
| | | |
| | | return eamWeekMaintenanceOrderMapper.queryPageList(page, queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean editWeekMaintenance(EamWeekMaintenanceRequest request) { |
| | | EamWeekMaintenanceOrder entity = eamWeekMaintenanceOrderMapper.selectById(request.getId()); |
| | | if(entity == null){ |
| | | throw new JeecgBootException("编辑的数据已删除,请刷新重试!"); |
| | | } |
| | | if(!MaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())){ |
| | | throw new JeecgBootException("只有待保养状态的数据才可编辑!"); |
| | | } |
| | | entity.setMaintenanceDate(request.getMaintenanceDate()); |
| | | entity.setOperator(request.getOperator()); |
| | | entity.setRemark(request.getRemark()); |
| | | |
| | | eamWeekMaintenanceOrderMapper.updateById(entity); |
| | | //处理详情 |
| | | if(CollectionUtil.isNotEmpty(request.getTableDetailList())) { |
| | | List<EamWeekMaintenanceOrderDetail> addList = new ArrayList<>(); |
| | | List<EamWeekMaintenanceOrderDetail> updateList = new ArrayList<>(); |
| | | request.getTableDetailList().forEach(tableDetail -> { |
| | | tableDetail.setOrderId(entity.getId()); |
| | | if(tableDetail.getId() == null){ |
| | | addList.add(tableDetail); |
| | | }else { |
| | | updateList.add(tableDetail); |
| | | } |
| | | }); |
| | | if(CollectionUtil.isNotEmpty(addList)){ |
| | | eamWeekMaintenanceOrderDetailService.saveBatch(addList); |
| | | } |
| | | if(CollectionUtil.isNotEmpty(updateList)){ |
| | | eamWeekMaintenanceOrderDetailService.updateBatchById(updateList); |
| | | } |
| | | } |
| | | if(CollectionUtil.isNotEmpty(request.getRemoveDetailList())) { |
| | | List<String> ids = request.getRemoveDetailList().stream().map(EamWeekMaintenanceOrderDetail::getId).collect(Collectors.toList()); |
| | | eamWeekMaintenanceOrderDetailService.removeBatchByIds(ids); |
| | | } |
| | | return true; |
| | | } |
| | | } |