| | |
| | | import com.lxzn.activiti.dao.ToEquipmentTaskMapper; |
| | | import com.lxzn.activiti.service.IToEquipmentTaskService; |
| | | import com.lxzn.framework.domain.activiti.ToEquipmentTask; |
| | | import com.lxzn.framework.domain.activiti.response.ActivitiCode; |
| | | import com.lxzn.framework.domain.nc.DeviceInfo; |
| | | import com.lxzn.framework.exception.ExceptionCast; |
| | | import com.lxzn.framework.utils.ValidateUtil; |
| | | import com.lxzn.framework.utils.file.FileUtil; |
| | | import com.lxzn.nc.service.IDeviceGroupService; |
| | | import com.lxzn.nc.service.IDeviceInfoService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.security.core.parameters.P; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | public class ToEquipmentTaskServiceImpl extends ServiceImpl<ToEquipmentTaskMapper, ToEquipmentTask> implements IToEquipmentTaskService { |
| | | |
| | | @Autowired |
| | | private IDeviceInfoService deviceInfoService; |
| | | @Autowired |
| | | private IDeviceGroupService deviceGroupService; |
| | | @Value("${fileNcGateway}") |
| | | private String fileNcGateway; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | @Scheduled(cron = "${taskSync}") |
| | | public void updateNcFileFromTask() { |
| | | List<ToEquipmentTask> list = selectTaskSyncFlag(1); |
| | | if(list == null || list.isEmpty()) { |
| | | return; |
| | | } |
| | | for (ToEquipmentTask task : list) { |
| | | //获取文件夹位置 |
| | | DeviceInfo deviceInfo = deviceInfoService.getByDeviceNo(task.getDeviceNo()); |
| | | if(deviceInfo == null) { |
| | | continue; |
| | | } |
| | | List<String> strings = deviceGroupService.findListParentTreeAll(deviceInfo.getGroupId()); |
| | | if (strings == null || strings.isEmpty()) { |
| | | continue; |
| | | } |
| | | String path = StringUtils.join(strings.toArray(), "/"); |
| | | Boolean b = FileUtil.copyFileUpName(task.getFilePath() + "/" + task.getFileEncodeName(), |
| | | fileNcGateway +"/" + path +"/" + task.getDeviceNo() + "/send/" + task.getFileName(),task.getFileSuffix()); |
| | | if (b) { |
| | | task.setSyncFlag(2); |
| | | } |
| | | } |
| | | super.saveOrUpdateBatch(list); |
| | | } |
| | | |
| | | @Override |
| | | public List<ToEquipmentTask> selectTaskSyncFlag(Integer syncFlag) { |
| | | if(!ValidateUtil.validateInteger(syncFlag)) { |
| | | return null; |
| | | } |
| | | List<ToEquipmentTask> list = super.lambdaQuery().eq(ToEquipmentTask::getSyncFlag, syncFlag).list(); |
| | | /* List<ToEquipmentTask> list = new ArrayList<>(); |
| | | ToEquipmentTask t = getById("1800797949617278977"); |
| | | list.add(t);*/ |
| | | if(list == null || list.isEmpty()) { |
| | | return null; |
| | | } |
| | | return list; |
| | | } |
| | | } |