|
|
|
@ -2,7 +2,9 @@ package com.glxp.api.service.collect;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
|
@ -10,6 +12,8 @@ import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
|
import com.glxp.api.entity.basic.BasicSkPrescribeEntity;
|
|
|
|
|
import com.glxp.api.entity.basic.BasicSkPrescribeItemEntity;
|
|
|
|
|
import com.glxp.api.entity.collect.IoCollectOrder;
|
|
|
|
|
import com.glxp.api.entity.collect.IoCollectOrderBiz;
|
|
|
|
|
import com.glxp.api.exception.JsonException;
|
|
|
|
|
import com.glxp.api.http.ErpBasicClient;
|
|
|
|
|
import com.glxp.api.req.basic.GetSickPrescribeRequest;
|
|
|
|
|
import com.glxp.api.req.collect.CollectOrderRequest;
|
|
|
|
@ -18,6 +22,7 @@ import com.glxp.api.res.PageSimpleResponse;
|
|
|
|
|
import com.glxp.api.res.basic.BasicSkPrescribeResponse;
|
|
|
|
|
import com.glxp.api.service.basic.*;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
@ -40,6 +45,8 @@ public class IoCollectOriginService {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
IoCollectOrderService collectOrderService;
|
|
|
|
|
@Resource
|
|
|
|
|
IoCollectOrderBizService collectOrderBizService;
|
|
|
|
|
|
|
|
|
|
public BaseResponse downloadOrder(CollectOrderRequest collectOrderRequest) {
|
|
|
|
|
|
|
|
|
@ -91,6 +98,7 @@ public class IoCollectOriginService {
|
|
|
|
|
getSickPrescribeRequest.setCode(collectOrderRequest.getBillNo());
|
|
|
|
|
getSickPrescribeRequest.setThirdSys("thirdId");
|
|
|
|
|
getSickPrescribeRequest.setWorkPlaceCode(collectOrderRequest.getWorkPlaceCode());
|
|
|
|
|
getSickPrescribeRequest.setFromType(collectOrderRequest.getFromType());
|
|
|
|
|
BaseResponse<PageSimpleResponse<IoCollectOrder>> baseResponse = erpBasicClient.getPrescribeV2(getSickPrescribeRequest);
|
|
|
|
|
if (baseResponse.getCode() == 20000) {
|
|
|
|
|
List<IoCollectOrder> list = baseResponse.getData().getList();
|
|
|
|
@ -101,4 +109,34 @@ public class IoCollectOriginService {
|
|
|
|
|
return ResultVOUtils.error("下载失败");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 异常处理
|
|
|
|
|
* @param collectOrderRequest
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void errorHandle(CollectOrderRequest collectOrderRequest) {
|
|
|
|
|
if (StrUtil.isBlank(collectOrderRequest.getBillNo())){
|
|
|
|
|
throw new JsonException(500, "单据号不能为空");
|
|
|
|
|
}
|
|
|
|
|
if (collectOrderRequest.getTagStatus() != 4){
|
|
|
|
|
throw new JsonException(500, "非异常单据,无需处理");
|
|
|
|
|
}
|
|
|
|
|
if(StrUtil.isBlank(collectOrderRequest.getBusType())){
|
|
|
|
|
throw new JsonException(500, "单据类型不能为空");
|
|
|
|
|
}
|
|
|
|
|
if(collectOrderRequest.getWorkPlaceCode() == null){
|
|
|
|
|
throw new JsonException(500, "工位号不能为空");
|
|
|
|
|
}
|
|
|
|
|
//删除异常单据
|
|
|
|
|
collectOrderBizService.remove(new LambdaQueryWrapper<IoCollectOrderBiz>()
|
|
|
|
|
.eq(IoCollectOrderBiz::getOrderIdFk,collectOrderRequest.getBillNo()));
|
|
|
|
|
collectOrderService.remove(new LambdaQueryWrapper<IoCollectOrder>()
|
|
|
|
|
.eq(IoCollectOrder::getBillNo,collectOrderRequest.getBillNo())
|
|
|
|
|
.eq(IoCollectOrder::getTagStatus,4));
|
|
|
|
|
//重新拉取
|
|
|
|
|
this.downloadOrderV2(collectOrderRequest);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|