diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/IAsyncDataService.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/IAsyncDataService.java index 9294e59b1..c00ef548a 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/IAsyncDataService.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/IAsyncDataService.java @@ -8,4 +8,7 @@ public interface IAsyncDataService { void handlerMtDataToHt(Long mainId); + + void handlerOuPaiDataToHt(Long mainId); + } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/AsyncDataServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/AsyncDataServiceImpl.java index 281179741..af0dfe89b 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/AsyncDataServiceImpl.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/comfac/service/impl/AsyncDataServiceImpl.java @@ -318,6 +318,11 @@ public class AsyncDataServiceImpl implements IAsyncDataService { log.info("##############handlerMtDataToHt: 处理数据完成"); } + @Override + public void handlerOuPaiDataToHt(Long mainId) { + + } + /** * 添加订单包件 * diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/controller/OupaiFactoryDataController.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/controller/OupaiFactoryDataController.java index c8d67b9bd..c48579547 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/controller/OupaiFactoryDataController.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/controller/OupaiFactoryDataController.java @@ -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); } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/IOuPaiFactoryDataService.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/IOuPaiFactoryDataService.java new file mode 100644 index 000000000..a0aff0d65 --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/IOuPaiFactoryDataService.java @@ -0,0 +1,13 @@ +package com.logpm.factory.oupai.service; + +import com.logpm.factory.oupai.vo.OuPaiDataPushVO; + +public interface IOuPaiFactoryDataService { + + /** + * 保存欧派的数据推送 + * @param ouPaiDataPushVO + * @return + */ + Long saveData(OuPaiDataPushVO ouPaiDataPushVO); +} diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryDataServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryDataServiceImpl.java new file mode 100644 index 000000000..1c3114d37 --- /dev/null +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryDataServiceImpl.java @@ -0,0 +1,16 @@ +package com.logpm.factory.oupai.service.impl; + +import com.logpm.factory.oupai.service.IOuPaiFactoryDataService; +import com.logpm.factory.oupai.vo.OuPaiDataPushVO; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Service +@Slf4j +public class OuPaiFactoryDataServiceImpl implements IOuPaiFactoryDataService { + + @Override + public Long saveData(OuPaiDataPushVO ouPaiDataPushVO) { + return null; + } +}