package com.huaheng.api.wcs.service.taskCancel; import com.alibaba.fastjson.JSON; import com.huaheng.api.wcs.domain.WcsTask; import com.huaheng.common.exception.service.ServiceException; import com.huaheng.common.utils.StringUtils; import com.huaheng.common.utils.http.HttpUtils; import com.huaheng.framework.web.domain.AjaxResult; import com.huaheng.pc.config.address.service.AddressService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class TaskCancelServiceImpl implements TaskCancelService { @Autowired private AddressService addressService; /**取消任务 * 1、判断参数是否为空 * 2、转换实体 * 3、发送数据 * @param id * @return */ @Override public AjaxResult TaskCance(Integer id) { //1、判断参数是否为空 if(id == null){ throw new ServiceException("任务号为空"); } //2、转换实体 WcsTask wcsTask = new WcsTask(); wcsTask.setTaskNo(id.toString()); //3、发送数据 String param="wcs"; String url=addressService.selectAddress(param)+"TaskCancel"; String JsonParam = JSON.toJSONString(wcsTask); String result = HttpUtils.bodypost(url, JsonParam); if(StringUtils.isEmpty(result)){ throw new ServiceException("接口地址错误"); } AjaxResult ajaxResult = JSON.parseObject(result, AjaxResult.class); return ajaxResult; } }