平和县医院提交单据接口调整

dev
anthonywj 1 year ago
parent ab4e8c6a8c
commit 475d1b4469

@ -2,10 +2,13 @@ package com.glxp.mipsdl.client.phxyy;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.exceptions.ExceptionUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.glxp.mipsdl.client.BaseHttpClient;
import com.glxp.mipsdl.config.ThirdSysConfig;
import com.glxp.mipsdl.constant.ConstantType;
@ -23,11 +26,9 @@ import com.glxp.mipsdl.dao.thrsys.ThrProductsDao;
import com.glxp.mipsdl.dao.thrsys.ThrSystemBusApiDao;
import com.glxp.mipsdl.entity.auth.AuthWarehouseEntity;
import com.glxp.mipsdl.entity.basic.BasicBussinessTypeEntity;
import com.glxp.mipsdl.entity.basic.BasicCorpEntity;
import com.glxp.mipsdl.entity.basic.BasicUdirelEntity;
import com.glxp.mipsdl.entity.inout.IoCodeEntity;
import com.glxp.mipsdl.entity.inout.IoOrderDetailBizEntity;
import com.glxp.mipsdl.entity.inout.IoOrderEntity;
import com.glxp.mipsdl.entity.inout.IoOrderUploadLogEntity;
import com.glxp.mipsdl.entity.inout.*;
import com.glxp.mipsdl.entity.thrsys.ThrCorpEntity;
import com.glxp.mipsdl.entity.thrsys.ThrInvWarehouseEntity;
import com.glxp.mipsdl.entity.thrsys.ThrProductsEntity;
@ -56,6 +57,7 @@ import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* Client
@ -184,13 +186,27 @@ public class PhxyyClient implements BaseHttpClient {
}
} else if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_SP)) {
//供应商
ThrCorpEntity thrCorp = thrCorpService.getThrCorp(udiwmsOrderRequest.getCorpId());
if (null != thrCorp) {
phOrderRequest.setCorpId(thrCorp.getUnitId());
phOrderRequest.setCorpName(thrCorp.getName());
BasicCorpEntity basicCorpEntity = basicCorpDao.selectByErpId(orderEntity.getFromCorp());
if (null != basicCorpEntity) {
udiwmsOrderRequest.setCorpId(basicCorpEntity.getThirdId());
udiwmsOrderRequest.setCorpName(basicCorpEntity.getName());
} else {
log.error("查询单据对应的第三方往来单位信息异常");
String msg = "查询单据对应的第三方往来单位信息异常";
orderUploadLogService.updateLocalErr(orderEntity, msg);
log.error("----单据提交-----" + orderEntity.getBillNo() + msg);
return ResultVOUtils.error(500, msg);
}
// ThrCorpEntity thrCorp = thrCorpService.getThrCorp(udiwmsOrderRequest.getCorpId());
// if (null != thrCorp) {
// phOrderRequest.setCorpId(thrCorp.getUnitId());
// phOrderRequest.setCorpName(thrCorp.getName());
// } else {
// String msg = "查询单据对应的第三方往来单位信息异常";
// orderUploadLogService.updateLocalErr(orderEntity, msg);
// log.error("----单据提交-----" + orderEntity.getBillNo() + msg);
// return ResultVOUtils.error(500, msg);
// }
}
//查询仓库信息
@ -199,27 +215,34 @@ public class PhxyyClient implements BaseHttpClient {
ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper<ThrInvWarehouseEntity>()
.eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity))
.eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId()));
if (thrInvWarehouseEntity != null) {
phOrderRequest.setLocInvCode(thrInvWarehouseEntity.getCode());
phOrderRequest.setLocInvName(thrInvWarehouseEntity.getName());
phOrderRequest.setLocInvCode(thrInvWarehouseEntity.getCode());
phOrderRequest.setLocInvName(thrInvWarehouseEntity.getName());
phOrderRequest.setLocStorageCode(thrInvWarehouseEntity.getCode());
phOrderRequest.setLocStorageName(thrInvWarehouseEntity.getName());
phOrderRequest.setLocStorageCode(thrInvWarehouseEntity.getCode());
phOrderRequest.setLocStorageName(thrInvWarehouseEntity.getName());
} else {
orderUploadLogService.updateLocalErr(orderEntity, "查询第三方系统仓库信息异常");
return ResultVOUtils.error(500, "查询第三方系统仓库信息异常");
}
} catch (Exception e) {
log.info("查询第三方系统仓库信息异常", e);
log.error("查询第三方系统仓库信息异常", ExceptionUtil.stacktraceToString(e));
orderUploadLogService.updateLocalErr(orderEntity, "查询第三方系统仓库信息异常" + ExceptionUtil.stacktraceToString(e));
return ResultVOUtils.error(500, "查询第三方系统仓库信息异常");
}
phOrderRequest.setBillFlag("1");
if (StrUtil.nullToEmpty(thrSystemBusApiEntity.getUrl()).equals("useOut")) {
phOrderRequest.setCorpId(phOrderRequest.getLocStorageCode());
phOrderRequest.setCorpName(phOrderRequest.getLocStorageName());
ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper<ThrInvWarehouseEntity>().eq(ThrInvWarehouseEntity::getCode, "29")
.eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId()));
phOrderRequest.setLocStorageCode("29");
phOrderRequest.setLocStorageName(thrInvWarehouseEntity.getName());
}
phOrderRequest.setBillFlag("1");
//设置单据出入库类型
if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_PUT)) {
phOrderRequest.setInoutType(1); //入库
@ -238,15 +261,14 @@ public class PhxyyClient implements BaseHttpClient {
//查询业务单据详情
List<IoOrderDetailBizEntity> detailBizEntities = orderDetailBizDao.selectList(new LambdaQueryWrapper<IoOrderDetailBizEntity>().eq(IoOrderDetailBizEntity::getOrderIdFk, orderEntity.getBillNo()));
// setOrderDetailList(ioCodeEntities, items, detailBizEntities);
List<IoOrderDetailBizEntity> stockOrderDetailEntities = transferSerList(detailBizEntities, orderEntity.getBillNo());
Collections.sort(stockOrderDetailEntities, (o1, o2) -> {
String o1Str = o1.getCoName() + o1.getSpec() + o1.getBatchNo() + o1.getSerialNo();
String o2Str = o2.getCoName() + o2.getSpec() + o2.getBatchNo() + o1.getSerialNo();
Integer cp = o1Str.compareTo(o2Str);
return cp;
});
// Collections.sort(stockOrderDetailEntities, (o1, o2) -> {
// String o1Str = o1.getCoName() + o1.getSpec() + o1.getBatchNo() + o1.getSerialNo();
// String o2Str = o2.getCoName() + o2.getSpec() + o2.getBatchNo() + o1.getSerialNo();
// Integer cp = o1Str.compareTo(o2Str);
// return cp;
// });
for (IoOrderDetailBizEntity stockOrderDetailEntity : stockOrderDetailEntities) {
BasicUdirelEntity udiRelevanceEntity = basicUdirelDao.selectById(stockOrderDetailEntity.getBindRlFk());
@ -258,6 +280,10 @@ public class PhxyyClient implements BaseHttpClient {
}
UdiwmsOrderDetailRequest item = new UdiwmsOrderDetailRequest();
BeanUtil.copyProperties(stockOrderDetailEntity, item);
item.setManufactory(stockOrderDetailEntity.getManufacturer());
item.setProductDate(stockOrderDetailEntity.getProductDate());
item.setExpireDate(stockOrderDetailEntity.getExpireDate());
item.setBatchNo(stockOrderDetailEntity.getBatchNo());
if (StrUtil.isNotEmpty(stockOrderDetailEntity.getProductDate())) {
// item.setProductDate(com.glxp.mipsdl.admin.util.DateUtil.formatExpireTime("20" + stockOrderDetailEntity.getProductDate()));
}
@ -270,17 +296,33 @@ public class PhxyyClient implements BaseHttpClient {
IoOrderUploadLogEntity uploadLog = new IoOrderUploadLogEntity();
try {
item.setPrice(stockOrderDetailEntity.getPrice());
item.setFirstSalesInvNo(stockOrderDetailEntity.getFirstSalesInvNo());
item.setSecSalesInvNo(stockOrderDetailEntity.getSecSalesInvNo());
item.setInvoiceDate(stockOrderDetailEntity.getInvoiceDate());
item.setSecSalesListNo(stockOrderDetailEntity.getSecSalesListNo());
// item.setFirstSalesInvNo(stockOrderDetailEntity.getFirstSalesInvNo());
// item.setSecSalesInvNo(stockOrderDetailEntity.getSecSalesInvNo());
// item.setInvoiceDate(stockOrderDetailEntity.getInvoiceDate());
// item.setSecSalesListNo(stockOrderDetailEntity.getSecSalesListNo());
item.setBillNo(orderEntity.getBillNo());
String fphm = "";
String fprq = null;
List<IoOrderInvoiceEntity> invoiceList = IoOrderInvoiceEntity.builder().build()
.selectList(Wrappers.lambdaQuery(IoOrderInvoiceEntity.class).eq(IoOrderInvoiceEntity::getOrderIdFk, orderEntity.getBillNo())
.eq(IoOrderInvoiceEntity::getBindRlFk, stockOrderDetailEntity.getBindRlFk())
.eq(StrUtil.isNotEmpty(stockOrderDetailEntity.getBatchNo()), IoOrderInvoiceEntity::getBatchNo, stockOrderDetailEntity.getBatchNo()).
groupBy(IoOrderInvoiceEntity::getInvoiceEncode));
if (CollectionUtil.isNotEmpty(invoiceList)) {
fphm = invoiceList.stream().map(IoOrderInvoiceEntity::getInvoiceEncode).collect(Collectors.joining(","));
if (invoiceList.get(0).getInvoiceDate() != null)
fprq = DateUtil.formatDateTime(invoiceList.get(0).getInvoiceDate());
}
item.setFirstSalesInvNo(fphm);
item.setInvoiceDate(fprq);
ThrProductsEntity thrProductsEntity = thrProductsDao.selectOne(new QueryWrapper<ThrProductsEntity>().eq("code", udiRelevanceEntity.getMainId()).last("limit 1"));
if (StrUtil.isEmpty(thrProductsEntity.getCode())) {
if (StrUtil.isEmpty(udiRelevanceEntity.getMainId()) || thrProductsEntity == null || StrUtil.isEmpty(thrProductsEntity.getCode())) {
uploadLog.setStatus(3);
uploadLog.setResult("提交失败,错误信息:" + "产品DI未关联第三方产品信息");
String errMsg = "提交失败,错误信息:" + "产品DI未关联第三方产品信息";
uploadLog.setResult(errMsg);
orderUploadLogService.insertOrUpdate(uploadLog);
return ResultVOUtils.error(500, "提交失败");
return ResultVOUtils.error(500, errMsg);
} else {
item.setProductId(thrProductsEntity.getCode());
item.setProductName(thrProductsEntity.getName());
@ -289,9 +331,10 @@ public class PhxyyClient implements BaseHttpClient {
} catch (Exception e) {
log.error(e.getMessage(), e);
uploadLog.setStatus(3);
uploadLog.setResult("提交失败,错误信息:" + e.getMessage());
String errMsg = "提交失败,错误信息:" + e.getMessage();
uploadLog.setResult(errMsg);
orderUploadLogService.insertOrUpdate(uploadLog);
return ResultVOUtils.error(500, "提交失败");
return ResultVOUtils.error(500, errMsg);
}
}
Collections.reverse(items);
@ -381,9 +424,9 @@ public class PhxyyClient implements BaseHttpClient {
udiwmsUnitRequest.setLimit(2);
BaseResponse baseResponse = getUnit(udiwmsUnitRequest);
if (baseResponse.getCode() == 20000) {
return ResultVOUtils.success("连接成功!");
return ResultVOUtils.success("连接第三方系统成功!");
}
return ResultVOUtils.error(500, "连接失败");
return ResultVOUtils.success("连接第三方服务成功,连接第三方系统成功");
}
@Override

@ -234,10 +234,10 @@ public class PtxhyyClient extends CommonHttpClient {
}
Collections.reverse(items);
for (UdiwmsOrderDetailRequest i : items) {
String udim = "";
if (CollectionUtil.isNotEmpty(i.getCodeList())) {
udim = i.getCodeList().stream().map(UdiwmsOrderDetailRequest.CodeDetailEntity::getCode).collect(Collectors.joining(","));
}
// String udim = "";
// if (CollectionUtil.isNotEmpty(i.getCodeList())) {
// udim = i.getCodeList().stream().map(UdiwmsOrderDetailRequest.CodeDetailEntity::getCode).collect(Collectors.joining(","));
// }
String fphm = "";
String fprq = null;
List<IoOrderInvoiceEntity> invoiceList = IoOrderInvoiceEntity.builder().build()

@ -128,6 +128,12 @@ public class UdiWmsController {
}
@PostMapping("/udiwms/erp/testLocal")
public BaseResponse testLocal() {
return ResultVOUtils.success("连接第三方服务成功!");
}
//片仔癀用友U8专属接口
/**

@ -2,17 +2,23 @@ package com.glxp.mipsdl.service.order;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.glxp.mipsdl.constant.Constants;
import com.glxp.mipsdl.dao.inout.IoOrderDao;
import com.glxp.mipsdl.dao.inout.IoOrderUploadLogDao;
import com.glxp.mipsdl.entity.inout.IoOrderEntity;
import com.glxp.mipsdl.entity.inout.IoOrderUploadLogEntity;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
@Service
public class OrderUploadLogService extends ServiceImpl<IoOrderUploadLogDao, IoOrderUploadLogEntity> {
@Resource
IoOrderUploadLogDao orderUploadLogDao;
@Resource
IoOrderDao orderDao;
public void insertOrUpdate(IoOrderUploadLogEntity orderUploadLogEntity) {
boolean b = orderUploadLogDao.exists(new QueryWrapper<IoOrderUploadLogEntity>().eq("billNo", orderUploadLogEntity.getBillNo()));
@ -22,4 +28,24 @@ public class OrderUploadLogService extends ServiceImpl<IoOrderUploadLogDao, IoOr
orderUploadLogDao.insert(orderUploadLogEntity);
}
}
/**
*
*
* @param orderEntity
* @param errMsg
*/
public void updateLocalErr(IoOrderEntity orderEntity, String errMsg) {
IoOrderUploadLogEntity uploadLog = new IoOrderUploadLogEntity();
uploadLog.setBillDate(orderEntity.getCreateTime());
uploadLog.setBillType(orderEntity.getAction());
uploadLog.setSubmitTime(new Date());
uploadLog.setBillNo(orderEntity.getBillNo());
uploadLog.setFromType(Constants.THIRD_ORDER_UPLOAD);
orderDao.updateById(orderEntity);
uploadLog.setStatus(4);
uploadLog.setResult("单据数据异常:" + errMsg);
insertOrUpdate(uploadLog);
}
}

@ -1,7 +1,7 @@
spring:
datasource:
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
url: jdbc:p6spy:mysql://127.0.0.1:3306/udi_wms_pt?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
url: jdbc:p6spy:mysql://127.0.0.1:3306/udi_wms_ph?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: 123456
hikari:

Loading…
Cancel
Save