package org.jeecg.modules.eam.service.impl; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import org.jeecg.modules.eam.entity.Equipment; import org.jeecg.modules.eam.entity.EquipmentMaintenancePlan; import org.jeecg.modules.eam.entity.MaintenanceStandard; import org.jeecg.modules.eam.entity.MaintenanceStandardDetail; import org.jeecg.modules.eam.mapper.EamEquipmentMapper; import org.jeecg.modules.eam.mapper.EquipmentMaintenancePlanDetailMapper; import org.jeecg.modules.eam.mapper.EquipmentMaintenancePlanMapper; import org.jeecg.modules.eam.service.IEquipmentMaintenancePlanService; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import java.io.Serializable; import java.util.*; /** * @Description: 保养计划 * @Author: jeecg-boot * @Date: 2023-10-16 * @Version: V1.0 */ @Service public class EquipmentMaintenancePlanServiceImpl extends ServiceImpl implements IEquipmentMaintenancePlanService { @Autowired private EquipmentMaintenancePlanMapper equipmentMaintenancePlanMapper; @Autowired private EquipmentMaintenancePlanDetailMapper equipmentMaintenancePlanDetailMapper; @Autowired private EamEquipmentMapper equipmentMapper; @Override @Transactional(rollbackFor = Exception.class) public void delMain(String id) { equipmentMaintenancePlanDetailMapper.deleteByMainId(id); equipmentMaintenancePlanMapper.deleteById(id); } @Override @Transactional(rollbackFor = Exception.class) public void delBatchMain(Collection idList) { for(Serializable id:idList) { equipmentMaintenancePlanDetailMapper.deleteByMainId(id.toString()); equipmentMaintenancePlanMapper.deleteById(id); } } @Override public List getCycle(String mainId, String type) { return baseMapper.getCycle(mainId,type); } @Override public Map getStandards(List equipmentIds, String maintenanceType) { String msg = ""; Map map = new HashMap<>(2); List maintenanceStandards = new ArrayList<>(); for(String equipmentId:equipmentIds){ Equipment equipment = equipmentMapper.selectById(equipmentId); List list = baseMapper.getStandards(equipmentId,maintenanceType); if(list.size()==0){ msg = msg+"统一编码为"+equipment.getNum()+"的设备不存在生效保养标注;"; }else if(list.size()>1){ msg = msg+"统一编码为"+equipment.getNum()+"的设备存在多条生效保养标注;"; }else { if(equipment.getIsLineEquip().equals("yes")&&maintenanceType.equals("3")){ String lineId = equipment.getLineId(); if(StringUtils.isNotBlank(lineId)){ List lineStandard = baseMapper.getStandards(lineId,maintenanceType); if(lineStandard.size()==0){ msg = msg+"统一编码为"+equipment.getNum()+"的设备不存在生效保养标注;"; }else if(list.size()>1){ msg = msg+"统一编码为"+equipment.getNum()+"的设备存在多条生效保养标注;"; }else{ maintenanceStandards.add(lineStandard.get(0)); } }else { msg = msg+"统一编码为"+equipment.getNum()+"的设备不存在生效保养标注;"; } }else{ maintenanceStandards.add(list.get(0)); } } } map.put("records",maintenanceStandards); map.put("message",msg); return map ; } }