|
|
|
@ -1,14 +1,27 @@
|
|
|
|
|
package com.logpm.factory.oupai.controller; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
|
import com.logpm.factory.comfac.service.IAsyncDataService; |
|
|
|
|
import com.logpm.factory.comfac.service.IOrderStatusLogService; |
|
|
|
|
import com.logpm.factory.oupai.service.IOuPaiFactoryDataService; |
|
|
|
|
import com.logpm.factory.oupai.vo.OuPaiDataPushVO; |
|
|
|
|
import com.logpm.factory.snm.entity.OrderStatusLog; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
|
|
import javax.servlet.ServletException; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 欧派工厂推送数据 |
|
|
|
|
*/ |
|
|
|
@ -19,16 +32,42 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
@Api(value = "欧派工厂数据", tags = "欧派工厂数据") |
|
|
|
|
public class OupaiFactoryDataController { |
|
|
|
|
|
|
|
|
|
private final IOuPaiFactoryDataService mtFactoryDataService; |
|
|
|
|
private final IOrderStatusLogService orderStatusLogService; |
|
|
|
|
|
|
|
|
|
private final IAsyncDataService syncDataService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/acceptOupaiFactoryData") |
|
|
|
|
public R acceptOupaiFactoryData(OuPaiDataPushVO ouPaiDataPushVO){ |
|
|
|
|
// log.info("acceptOupaiFactoryData 参数 json {}",json);
|
|
|
|
|
public R acceptOupaiFactoryData(@Validated @RequestBody OuPaiDataPushVO ouPaiDataPushVO, HttpServletRequest request) { |
|
|
|
|
log.info("acceptOupaiFactoryData 参数ouPaiDataPushVO {}",ouPaiDataPushVO.toString()); |
|
|
|
|
|
|
|
|
|
//先保存原始请求数据
|
|
|
|
|
OrderStatusLog orderStatusLog = new OrderStatusLog(); |
|
|
|
|
orderStatusLog.setArgs(JSONObject.toJSONString(ouPaiDataPushVO)); |
|
|
|
|
orderStatusLog.setStatus(1); |
|
|
|
|
orderStatusLog.setType(3); |
|
|
|
|
orderStatusLog.setBrand("欧派"); |
|
|
|
|
orderStatusLogService.save(orderStatusLog); |
|
|
|
|
Long id = null; |
|
|
|
|
try { |
|
|
|
|
id = mtFactoryDataService.saveData(ouPaiDataPushVO); |
|
|
|
|
orderStatusLog.setStatus(0); |
|
|
|
|
|
|
|
|
|
} catch (ServiceException e) { |
|
|
|
|
log.warn("############data: 保存数据失败 carNum={}",ouPaiDataPushVO.getCarNum()); |
|
|
|
|
log.error("############data: 保存数据失败",e); |
|
|
|
|
//修改保存数据的状态
|
|
|
|
|
orderStatusLog.setStatus(2); |
|
|
|
|
} |
|
|
|
|
orderStatusLogService.saveOrUpdate(orderStatusLog); |
|
|
|
|
|
|
|
|
|
//开启异步线程处理数据
|
|
|
|
|
if(!Objects.isNull(id)){ |
|
|
|
|
syncDataService.handlerOuPaiDataToHt(id); |
|
|
|
|
} |
|
|
|
|
return R.data(ouPaiDataPushVO.getCarNum()); |
|
|
|
|
|
|
|
|
|
return R.data(null); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|