no message
							parent
							
								
									3c8b0d33df
								
							
						
					
					
						commit
						f44a8355bf
					
				| 
						 | 
					@ -79,9 +79,9 @@ public interface KMReService {
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 下发agv任务
 | 
					     * 下发agv任务
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param agvTasks 任务
 | 
					     * @param agvTask 任务
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    void sendAgvTask(AgvTask agvTasks, String json);
 | 
					    void sendAgvTask(AgvTask agvTask, String json);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 任务回报更新状态
 | 
					     * 任务回报更新状态
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,14 +9,17 @@ import com.youchain.basicdata.domain.Stock;
 | 
				
			||||||
import com.youchain.basicdata.service.PointService;
 | 
					import com.youchain.basicdata.service.PointService;
 | 
				
			||||||
import com.youchain.basicdata.service.StockService;
 | 
					import com.youchain.basicdata.service.StockService;
 | 
				
			||||||
import com.youchain.businessdata.domain.AgvTask;
 | 
					import com.youchain.businessdata.domain.AgvTask;
 | 
				
			||||||
 | 
					import com.youchain.businessdata.domain.Les;
 | 
				
			||||||
import com.youchain.businessdata.domain.Task;
 | 
					import com.youchain.businessdata.domain.Task;
 | 
				
			||||||
import com.youchain.businessdata.inputJson.Dolly;
 | 
					import com.youchain.businessdata.inputJson.Dolly;
 | 
				
			||||||
import com.youchain.businessdata.inputJson.UpdateTuggerTrailerInfo;
 | 
					import com.youchain.businessdata.inputJson.UpdateTuggerTrailerInfo;
 | 
				
			||||||
import com.youchain.businessdata.service.*;
 | 
					import com.youchain.businessdata.service.*;
 | 
				
			||||||
 | 
					import com.youchain.config.SignConfig;
 | 
				
			||||||
import com.youchain.exception.BadRequestException;
 | 
					import com.youchain.exception.BadRequestException;
 | 
				
			||||||
import com.youchain.modules.quartz.utils.TimeNumberUtils;
 | 
					import com.youchain.modules.quartz.utils.TimeNumberUtils;
 | 
				
			||||||
import com.youchain.modules.system.domain.Dict;
 | 
					import com.youchain.modules.system.domain.Dict;
 | 
				
			||||||
import com.youchain.modules.system.repository.DictRepository;
 | 
					import com.youchain.modules.system.repository.DictRepository;
 | 
				
			||||||
 | 
					import com.youchain.modules.system.service.DictService;
 | 
				
			||||||
import com.youchain.utils.*;
 | 
					import com.youchain.utils.*;
 | 
				
			||||||
import lombok.RequiredArgsConstructor;
 | 
					import lombok.RequiredArgsConstructor;
 | 
				
			||||||
import lombok.extern.slf4j.Slf4j;
 | 
					import lombok.extern.slf4j.Slf4j;
 | 
				
			||||||
| 
						 | 
					@ -33,7 +36,7 @@ import java.util.stream.Collectors;
 | 
				
			||||||
@Slf4j
 | 
					@Slf4j
 | 
				
			||||||
@RequiredArgsConstructor
 | 
					@RequiredArgsConstructor
 | 
				
			||||||
public class KMReServiceImpl implements KMReService {
 | 
					public class KMReServiceImpl implements KMReService {
 | 
				
			||||||
    private final DictRepository dictRepository;
 | 
					    private final DictService dictService;
 | 
				
			||||||
    private final StockService stockService;
 | 
					    private final StockService stockService;
 | 
				
			||||||
    private final PointService pointService;
 | 
					    private final PointService pointService;
 | 
				
			||||||
    private final AgvTaskService agvTaskService;
 | 
					    private final AgvTaskService agvTaskService;
 | 
				
			||||||
| 
						 | 
					@ -153,22 +156,16 @@ public class KMReServiceImpl implements KMReService {
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void sendAgvTaskToContainer(String url, String json) {
 | 
					    public void sendAgvTaskToContainer(String url, String json) {
 | 
				
			||||||
        log.info(json);
 | 
					        log.info(json);
 | 
				
			||||||
        Dict dict = dictRepository.findDictByName("OPEN");
 | 
					        // 检查接口开关
 | 
				
			||||||
        if (dict != null) {
 | 
					        if (!dictService.isInterfaceEnabled()) {
 | 
				
			||||||
            String resultJson = HttpPostUtil.sendPostReq(url, json);
 | 
					            return;
 | 
				
			||||||
            if (StringUtils.isEmpty(resultJson)) {
 | 
					 | 
				
			||||||
                throw new BadRequestException("AGV返回信息:接口调用失败!");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            JSONObject resultObject = JSON.parseObject(resultJson);
 | 
					 | 
				
			||||||
            if (resultObject == null) {
 | 
					 | 
				
			||||||
                throw new BadRequestException("AGV返回信息:接口数据返回为空!");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            String code = resultObject.getString("code");
 | 
					 | 
				
			||||||
            String message = resultObject.getString("message");
 | 
					 | 
				
			||||||
            if (!"0".equals(code)) {
 | 
					 | 
				
			||||||
                throw new BadRequestException("AGV返回信息:接口调用失败!" + message);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        //请求
 | 
				
			||||||
 | 
					        String result = HttpPostUtil.sendPostReq(url, json);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //验证响应
 | 
				
			||||||
 | 
					        validateAgvTaskResponse(result);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -395,33 +392,63 @@ public class KMReServiceImpl implements KMReService {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void sendAgvTask(AgvTask agvTasks, String json) {
 | 
					    public void sendAgvTask(AgvTask agvTask, String json) {
 | 
				
			||||||
        Dict dict = dictRepository.findDictByName("OPEN");
 | 
					        try {
 | 
				
			||||||
        String resultJson = "";
 | 
					            // 请求
 | 
				
			||||||
        if (dict != null) {
 | 
					            String result = HttpPostUtil.sendPostReq(UrlApi.submitMission(), json);
 | 
				
			||||||
            resultJson = HttpPostUtil.sendPostReq(UrlApi.submitMission(), json);
 | 
					            log.info("LES回传参数: {}", json);
 | 
				
			||||||
            if (StringUtils.isEmpty(resultJson)) {
 | 
					
 | 
				
			||||||
                throw new BadRequestException("AGV返回信息:下发任务接口调用失败!");
 | 
					            // 检查接口开关
 | 
				
			||||||
            }
 | 
					            if (!dictService.isInterfaceEnabled()) {
 | 
				
			||||||
            JSONObject resulObject = JSON.parseObject(resultJson);
 | 
					                // 更新LES状态
 | 
				
			||||||
            if (resulObject == null) {
 | 
					                updateAgvTaskStatus(agvTask, null, json);
 | 
				
			||||||
                throw new BadRequestException("AGV返回信息:下发任务接口返回为空!");
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            String code = resulObject.getString("code");
 | 
					            //验证响应
 | 
				
			||||||
            String message = resulObject.getString("message");
 | 
					            validateAgvTaskResponse(result);
 | 
				
			||||||
            if (!"0".equals(code)) {
 | 
					
 | 
				
			||||||
                throw new BadRequestException("AGV返回消息:" + message);
 | 
					            // 更新AgvTask状态
 | 
				
			||||||
            }
 | 
					            updateAgvTaskStatus(agvTask, result, json);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
					            log.error("AGV下发失败", e);
 | 
				
			||||||
 | 
					            throw new BadRequestException("AGV下发失败:" + e.getMessage());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 验证AgvTask响应
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private void validateAgvTaskResponse(String result) {
 | 
				
			||||||
 | 
					        if (StringUtils.isEmpty(result)) {
 | 
				
			||||||
 | 
					            throw new BadRequestException("AGV返回信息:下发任务接口调用失败!");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        JSONObject resulObject = JSON.parseObject(result);
 | 
				
			||||||
 | 
					        if (resulObject == null) {
 | 
				
			||||||
 | 
					            throw new BadRequestException("AGV返回信息:下发任务接口返回为空!");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        agvTasks.setJobForce(agvTasks.getId().toString());
 | 
					        String code = resulObject.getString("code");
 | 
				
			||||||
        agvTasks.setJobForceAsc((1));
 | 
					        String message = resulObject.getString("message");
 | 
				
			||||||
        agvTasks.setStatus(BizStatus.ATCALL);
 | 
					        if (!"0".equals(code)) {
 | 
				
			||||||
        agvTasks.setJobMessage(resultJson);
 | 
					            throw new BadRequestException("AGV返回消息:" + message);
 | 
				
			||||||
        agvTasks.setReqMessage(json);
 | 
					        }
 | 
				
			||||||
        agvTasks.setStartTime(new Timestamp(System.currentTimeMillis()));
 | 
					    }
 | 
				
			||||||
        agvTaskService.update(agvTasks);
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 更新AgvTask状态(成功)
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private void updateAgvTaskStatus(AgvTask agvTask, String result, String json) {
 | 
				
			||||||
 | 
					        agvTask.setJobForce(agvTask.getId().toString());
 | 
				
			||||||
 | 
					        agvTask.setJobForceAsc((1));
 | 
				
			||||||
 | 
					        agvTask.setStatus(BizStatus.ATCALL);
 | 
				
			||||||
 | 
					        agvTask.setJobMessage(result);
 | 
				
			||||||
 | 
					        agvTask.setReqMessage(json);
 | 
				
			||||||
 | 
					        agvTask.setStartTime(new Timestamp(System.currentTimeMillis()));
 | 
				
			||||||
 | 
					        agvTaskService.update(agvTask);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +17,7 @@ import com.youchain.exception.BadRequestException;
 | 
				
			||||||
import com.youchain.modules.system.domain.Dict;
 | 
					import com.youchain.modules.system.domain.Dict;
 | 
				
			||||||
import com.youchain.modules.system.domain.DictDetail;
 | 
					import com.youchain.modules.system.domain.DictDetail;
 | 
				
			||||||
import com.youchain.modules.system.repository.DictDetailRepository;
 | 
					import com.youchain.modules.system.repository.DictDetailRepository;
 | 
				
			||||||
import com.youchain.modules.system.repository.DictRepository;
 | 
					import com.youchain.modules.system.service.DictService;
 | 
				
			||||||
import com.youchain.utils.*;
 | 
					import com.youchain.utils.*;
 | 
				
			||||||
import lombok.RequiredArgsConstructor;
 | 
					import lombok.RequiredArgsConstructor;
 | 
				
			||||||
import lombok.extern.slf4j.Slf4j;
 | 
					import lombok.extern.slf4j.Slf4j;
 | 
				
			||||||
| 
						 | 
					@ -46,12 +46,12 @@ public class LesServiceImpl implements LesService {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final LesRepository lesRepository;
 | 
					    private final LesRepository lesRepository;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final DictRepository dictRepository;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private final DictDetailRepository dictDetailRepository;
 | 
					    private final DictDetailRepository dictDetailRepository;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final PointService pointService;
 | 
					    private final PointService pointService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final DictService dictService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final LesMapper lesMapper;
 | 
					    private final LesMapper lesMapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
| 
						 | 
					@ -182,7 +182,7 @@ public class LesServiceImpl implements LesService {
 | 
				
			||||||
            log.info("LES回传参数: {}", json);
 | 
					            log.info("LES回传参数: {}", json);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // 检查接口开关
 | 
					            // 检查接口开关
 | 
				
			||||||
            if (!isInterfaceEnabled()) {
 | 
					            if (!dictService.isInterfaceEnabled()) {
 | 
				
			||||||
                // 更新LES状态
 | 
					                // 更新LES状态
 | 
				
			||||||
                updateLesStatus(les, null, json);
 | 
					                updateLesStatus(les, null, json);
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
| 
						 | 
					@ -206,19 +206,12 @@ public class LesServiceImpl implements LesService {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * 检查接口开关是否启用
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    private boolean isInterfaceEnabled() {
 | 
					 | 
				
			||||||
        Dict dict = dictRepository.findDictByName("OPEN");
 | 
					 | 
				
			||||||
        return dict != null;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 获取签名配置
 | 
					     * 获取签名配置
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private SignConfig getSignConfig() {
 | 
					    private SignConfig getSignConfig() {
 | 
				
			||||||
        Dict signeDict = dictRepository.findDictByName("signe");
 | 
					        Dict signeDict = dictService.findDictByName("signe");
 | 
				
			||||||
        if (signeDict == null) {
 | 
					        if (signeDict == null) {
 | 
				
			||||||
            throw new BadRequestException("signe签名未配置");
 | 
					            throw new BadRequestException("signe签名未配置");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -419,7 +412,7 @@ public class LesServiceImpl implements LesService {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void sendLesTask(String json) {
 | 
					    private void sendLesTask(String json) {
 | 
				
			||||||
        Dict dict = dictRepository.findDictByName("OPEN");
 | 
					        Dict dict = dictService.findDictByName("OPEN");
 | 
				
			||||||
        String resultJson;
 | 
					        String resultJson;
 | 
				
			||||||
        if (dict != null) {
 | 
					        if (dict != null) {
 | 
				
			||||||
            resultJson = HttpPostUtil.sendPostReq(UrlApi.submitMission(), json);
 | 
					            resultJson = HttpPostUtil.sendPostReq(UrlApi.submitMission(), json);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,6 +19,7 @@ import com.youchain.modules.system.domain.Dict;
 | 
				
			||||||
import com.youchain.modules.system.service.dto.DictDto;
 | 
					import com.youchain.modules.system.service.dto.DictDto;
 | 
				
			||||||
import com.youchain.modules.system.service.dto.DictQueryCriteria;
 | 
					import com.youchain.modules.system.service.dto.DictQueryCriteria;
 | 
				
			||||||
import org.springframework.data.domain.Pageable;
 | 
					import org.springframework.data.domain.Pageable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import javax.servlet.http.HttpServletResponse;
 | 
					import javax.servlet.http.HttpServletResponse;
 | 
				
			||||||
import java.io.IOException;
 | 
					import java.io.IOException;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
| 
						 | 
					@ -26,21 +27,23 @@ import java.util.Map;
 | 
				
			||||||
import java.util.Set;
 | 
					import java.util.Set;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
* @author Liu Xue
 | 
					 * @author Liu Xue
 | 
				
			||||||
* @date 2019-04-10
 | 
					 * @date 2019-04-10
 | 
				
			||||||
*/
 | 
					 */
 | 
				
			||||||
public interface DictService {
 | 
					public interface DictService {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 分页查询
 | 
					     * 分页查询
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
     * @param criteria 条件
 | 
					     * @param criteria 条件
 | 
				
			||||||
     * @param pageable 分页参数
 | 
					     * @param pageable 分页参数
 | 
				
			||||||
     * @return /
 | 
					     * @return /
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    Map<String,Object> queryAll(DictQueryCriteria criteria, Pageable pageable);
 | 
					    Map<String, Object> queryAll(DictQueryCriteria criteria, Pageable pageable);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 查询全部数据
 | 
					     * 查询全部数据
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
     * @param dict /
 | 
					     * @param dict /
 | 
				
			||||||
     * @return /
 | 
					     * @return /
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
| 
						 | 
					@ -48,6 +51,7 @@ public interface DictService {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 创建
 | 
					     * 创建
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
     * @param resources /
 | 
					     * @param resources /
 | 
				
			||||||
     * @return /
 | 
					     * @return /
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
| 
						 | 
					@ -55,18 +59,21 @@ public interface DictService {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 编辑
 | 
					     * 编辑
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
     * @param resources /
 | 
					     * @param resources /
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    void update(Dict resources);
 | 
					    void update(Dict resources);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 删除
 | 
					     * 删除
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
     * @param ids /
 | 
					     * @param ids /
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    void delete(Set<Long> ids);
 | 
					    void delete(Set<Long> ids);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 导出数据
 | 
					     * 导出数据
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
     * @param queryAll 待导出的数据
 | 
					     * @param queryAll 待导出的数据
 | 
				
			||||||
     * @param response /
 | 
					     * @param response /
 | 
				
			||||||
     * @throws IOException /
 | 
					     * @throws IOException /
 | 
				
			||||||
| 
						 | 
					@ -74,4 +81,13 @@ public interface DictService {
 | 
				
			||||||
    void download(List<DictDto> queryAll, HttpServletResponse response) throws IOException;
 | 
					    void download(List<DictDto> queryAll, HttpServletResponse response) throws IOException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Dict findDictByName(String name);
 | 
					    Dict findDictByName(String name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 检测接口是否开启
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return Boolean
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    Boolean isInterfaceEnabled();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -122,6 +122,12 @@ public class DictServiceImpl implements DictService {
 | 
				
			||||||
        return dictRepository.findDictByName(name);
 | 
					        return dictRepository.findDictByName(name);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public Boolean isInterfaceEnabled() {
 | 
				
			||||||
 | 
					        Dict dict = dictRepository.findDictByName("OPEN");
 | 
				
			||||||
 | 
					        return dict != null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void delCaches(Dict dict){
 | 
					    public void delCaches(Dict dict){
 | 
				
			||||||
        redisUtils.del(CacheKey.DICT_NAME + dict.getName());
 | 
					        redisUtils.del(CacheKey.DICT_NAME + dict.getName());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue