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