zhangherong
2025-04-07 d465f6537bda4c5b3844a15b73badf704f44c9a1
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java
@@ -9,12 +9,13 @@
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;
@@ -25,9 +26,10 @@
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: 周保工单
@@ -121,4 +123,45 @@
        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;
    }
}