package com.gk.hotwork.Service.ServiceImpl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gk.hotwork.Domain.*; import com.gk.hotwork.Domain.Utils.BeanUtils; import com.gk.hotwork.Domain.Utils.StringUtils; import com.gk.hotwork.Domain.Vo.TaskWorkerVo; import com.gk.hotwork.Mapper.TaskWorkerMapper; import com.gk.hotwork.Service.EquipmentService; import com.gk.hotwork.Service.TaskLocationService; import com.gk.hotwork.Service.TaskWorkerService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Date; import java.util.List; /** * @author : jingjy * @date : 2021/8/20 14:15 */ @Service("TaskWorkerService") public class TaskWorkerServiceImpl extends ServiceImpl implements TaskWorkerService { @Autowired private TaskWorkerMapper taskWorkerMapper; @Autowired private EquipmentService equipmentService; @Autowired private TaskWorkerService taskWorkerService; @Autowired private TaskLocationService taskLocationService; @Override public List getListByTaskCode(String code) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(TaskWorker::getTaskcode,code); wrapper.eq(TaskWorker::getFlag,(byte)0); return baseMapper.selectList(wrapper); } @Override public void deleteByTaskCode(String code) { Byte isDeleted = 1; List workers = getListByTaskCode(code); for (TaskWorker worker : workers){ worker.setFlag(isDeleted); baseMapper.updateById(worker); } } @Override public List getVoByTaskCode(String code) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(TaskWorker::getTaskcode,code); wrapper.eq(TaskWorker::getFlag,(byte)0); List workers = baseMapper.selectList(wrapper); ListworkerVos = new ArrayList<>(); for (TaskWorker worker : workers){ TaskWorkerVo workerVo = BeanUtils.copy(worker,TaskWorkerVo.class); ListequipmentInfos = equipmentService.selectByTaskAndWorker(code,worker.getWorker()); workerVo.setEquipments(equipmentInfos); String photoAddress = ""; for (EquipmentInfo equipmentInfo: equipmentInfos){ if (equipmentInfo.getIsphoto().equals((byte)1)){ photoAddress = equipmentInfo.getPhotoaddress(); } } TaskLocationInfo taskLocationInfo = taskLocationService.getLocationByTaskAndWorker(code,workerVo.getWorker()); if (taskLocationInfo !=null){ workerVo.setLongitude(StringUtils.isBlank(taskLocationInfo.getLongitude())?"":taskLocationInfo.getLongitude()); workerVo.setLatitude(StringUtils.isBlank(taskLocationInfo.getLatitude())?"":taskLocationInfo.getLatitude()); workerVo.setPhotoAddress(photoAddress); } workerVos.add(workerVo); } return workerVos; } @Override public void saveBatch(List workers, UserInfo userInfo) { List taskWorkers = new ArrayList<>(); for (TaskWorkerVo workerVo : workers){ TaskWorker taskWorker = BeanUtils.copy(workerVo,TaskWorker.class); taskWorker.setCreatedat(new Date()); taskWorker.setCreatedby(userInfo.getRealname()); taskWorkers.add(taskWorker); } taskWorkerService.saveBatch(taskWorkers); } }