diff --git a/src/main/java/com/glxp/mipsdl/client/ctqyy/CtqyyClient.java b/src/main/java/com/glxp/mipsdl/client/ctqyy/CtqyyClient.java deleted file mode 100644 index 2e487d3..0000000 --- a/src/main/java/com/glxp/mipsdl/client/ctqyy/CtqyyClient.java +++ /dev/null @@ -1,2271 +0,0 @@ -package com.glxp.mipsdl.client.ctqyy; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ReflectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.json.JSONUtil; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.alibaba.fastjson.TypeReference; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.glxp.mipsdl.client.CommonHttpClient; -import com.glxp.mipsdl.client.ctqyy.entity.InvCodeResultEntity; -import com.glxp.mipsdl.client.ctqyy.entity.InvProjectResultEntity; -import com.glxp.mipsdl.client.ctqyy.entity.InvResultEntity; -import com.glxp.mipsdl.config.ThirdSysConfig; -import com.glxp.mipsdl.constant.BusTypeConstant; -import com.glxp.mipsdl.constant.ConstantType; -import com.glxp.mipsdl.constant.Constants; -import com.glxp.mipsdl.dao.auth.AuthUserDao; -import com.glxp.mipsdl.dao.auth.AuthWarehouseDao; -import com.glxp.mipsdl.dao.auth.AuthWarehouseUserMapper; -import com.glxp.mipsdl.dao.basic.*; -import com.glxp.mipsdl.dao.inout.*; -import com.glxp.mipsdl.dao.thrsys.ThrInvWarehouseDao; -import com.glxp.mipsdl.dao.thrsys.ThrProductsDao; -import com.glxp.mipsdl.dao.thrsys.ThrSystemBusApiDao; -import com.glxp.mipsdl.entity.auth.AuthUserEntity; -import com.glxp.mipsdl.entity.auth.AuthWarehouseEntity; -import com.glxp.mipsdl.entity.basic.*; -import com.glxp.mipsdl.entity.ctqyy.*; -import com.glxp.mipsdl.entity.inout.*; -import com.glxp.mipsdl.entity.system.UdiEntity; -import com.glxp.mipsdl.entity.thrsys.*; -import com.glxp.mipsdl.http.HttpClient; -import com.glxp.mipsdl.req.base.*; -import com.glxp.mipsdl.req.base.forthird.ForInvProductsFilter; -import com.glxp.mipsdl.req.ctqyy.*; -import com.glxp.mipsdl.req.post.*; -import com.glxp.mipsdl.req.yb.*; -import com.glxp.mipsdl.req.zaxyy.ZaxzyyOrderRequest; -import com.glxp.mipsdl.req.zzzyy.ZzzyyRequest; -import com.glxp.mipsdl.res.BaseResponse; -import com.glxp.mipsdl.res.PageSimpleResponse; -import com.glxp.mipsdl.res.ctqyy.CtBaseResponse; -import com.glxp.mipsdl.res.ctqyy.ThrOrderResponse; -import com.glxp.mipsdl.res.udiwms.*; -import com.glxp.mipsdl.service.auth.AuthWarehouseService; -import com.glxp.mipsdl.service.basic.RelCodeDetailService; -import com.glxp.mipsdl.service.order.OrderUploadLogService; -import com.glxp.mipsdl.service.system.SysParamConfigService; -import com.glxp.mipsdl.service.thrsys.ThrCorpService; -import com.glxp.mipsdl.service.thrsys.ThrSystemDetailService; -import com.glxp.mipsdl.service.yb.YbClient; -import com.glxp.mipsdl.thirddao.ctqyy.*; -import com.glxp.mipsdl.util.*; -import lombok.extern.slf4j.Slf4j; -import org.dom4j.Document; -import org.dom4j.DocumentException; -import org.dom4j.DocumentHelper; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.*; -import java.util.stream.Collectors; - -@Slf4j -@Service(value = "100011HttpClient") -public class CtqyyClient extends CommonHttpClient { - private final String[] buyType_3501 = {"24"}; - private final String[] buyType_3502 = {"7", "6", "5", "4", "1", "16", "12", "28", "35"}; - private final String[] buyType_3505 = {"QXCF001", "YPCF002"}; - private final String[] buyType_3506 = {"YPTH001"}; - @Resource - AuthWarehouseUserMapper authWarehouseUserMapper; - @Resource - private ThrSystemDetailService thrSystemDetailService; - @Resource - private HttpClient httpClient; - - @Resource - private SubmitOrderUtil submitOrderUtil; - @Resource - private IoOrderUploadLogDao orderUploadLogDao; - - @Resource - private IoOrderDao orderDao; - @Resource - private ThrSystemBusApiDao thrSystemBusApiDao; - @Resource - private BasicBussinessTypeDao basicBussinessTypeDao; - @Resource - private BasicCorpDao basicCorpDao; - @Resource - private IoCodeDao codeDao; - @Resource - private AuthWarehouseDao authWarehouseDao; - @Resource - private ThrInvWarehouseDao thrInvWarehouseDao; - @Resource - private AuthWarehouseService authWarehouseService; - @Resource - private ThirdSysConfig thirdSysConfig; - @Resource - private ThrCorpService thrCorpService; - @Resource - private IoOrderDetailBizDao orderDetailBizDao; - @Resource - private IoOrderDetailCodeDao orderDetailCodeDao; - @Resource - private AuthUserDao authUserDao; - @Resource - BasicUdirelDao basicUdirelDao; - @Resource - BasicProductsDao basicProductsDao; - @Resource - private OrderUploadLogService orderUploadLogService; - @Resource - private VYpzsPhysicDictMapper vYpzsPhysicDictMapper; - @Resource - private VYpzsPresInfoMapper vYpzsPresInfoMapper; - @Resource - private VInsurNationGoodsClMapper vInsurNationGoodsClMapper; - @Resource - private VYpzsPresInfoReturnMapper vYpzsPresInfoReturnMapper; - @Resource - private VYpzsPlanInfoMapper vYpzsPlanInfoMapper; - @Resource - private VYpzsIoInfoMapper vYpzsIoInfoMapper; - @Resource - private YbClient ybClient; - @Resource - SysParamConfigService sysParamConfigService; - @Resource - BasicSkProjectMapper basicSkProjectMapper; - @Resource - UdiRlSupDao udiRlSupDao; - @Resource - BasicDestinyRelMapper basicDestinyRelMapper; - @Resource - VInsurNationGoodsPhysicMapper goodsPhysicMapper; - @Resource - VInsurNationGoodsReturnMapper vInsurNationGoodsReturnMapper; - @Resource - private ThrProductsDao thrProductsDao; - @Resource - private RelCodeDetailService relCodeDetailService; - @Value("${DSF_XML_SQL_TYPE:MySql}") - private String defXmlSqlType; - /** - * 拼接xml请求头 - * - * @param methodName 方法名 - * @return - */ - public String getMsgHeader(String methodName) { - return "" + - "" + - "" + - methodName + - "" + - ""; - } - - - public String parserResult(String response) { - if (response.contains(" wrapper = new LambdaQueryWrapper(); - //补充其他查询条件 - wrapper.eq(StrUtil.isNotBlank(udiwmsProductRequest.getCode()), VYpzsPhysicDict::getPHYSIC_CODE, udiwmsProductRequest.getCode()); - wrapper.eq(StrUtil.isNotBlank(udiwmsProductRequest.getName()), VYpzsPhysicDict::getPHYSIC_NAME, udiwmsProductRequest.getName()); - wrapper.eq(StrUtil.isNotBlank(udiwmsProductRequest.getRegisterNo()), VYpzsPhysicDict::getPHYSIC_NO, udiwmsProductRequest.getRegisterNo()); - IPage page = vYpzsPhysicDictMapper.selectPage(new Page(udiwmsProductRequest.getPage(), udiwmsProductRequest.getLimit()), wrapper); - List physicDictEntities = page.getRecords(); - List thrProductsEntityList = null; - if (CollUtil.isNotEmpty(physicDictEntities)) { - //数据处理以thr_products 返回 - thrProductsEntityList = physicDictEntities.stream().map(dict -> { - ThrProductsEntity products = new ThrProductsEntity(); - products.setCode(dict.getPHYSIC_CODE()); - products.setName(dict.getPHYSIC_NAME()); - products.setMeasname(dict.getPACK_UNIT()); - products.setSpec(dict.getPACK_SPEC()); - products.setYbbm(dict.getCOUNTRY_CODE()); - products.setPrepnSpec(dict.getPHYSIC_SPEC()); - products.setPrepnUnit(dict.getPHYSIC_UNIT()); - products.setProductType(2); - products.setId(IdUtil.getSnowflakeNextId()); - products.setThirdSysFk("thirdId1"); - return products; - }).collect(Collectors.toList()); - thrProductsDao.batchInsert(thrProductsEntityList); - thrProductsEntityList = thrProductsEntityList.stream() - .collect(Collectors.groupingBy(ThrProductsEntity::getYbbm, - LinkedHashMap::new, - Collectors.collectingAndThen(Collectors.toList(), list -> list.get(0)))) - .values() - .stream() - .collect(Collectors.toList()); - } - - for (ThrProductsEntity entity : thrProductsEntityList) { - entity.setId(null); - entity.setRemark(entity.getCode()); - entity.setCode(entity.getYbbm()); - } - PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(page.getTotal()); - pageSimpleResponse.setList(thrProductsEntityList); - return ResultVOUtils.success(pageSimpleResponse); - } - - @Override - public BaseResponse getOrderTypes(UdiwmsBusTypeRequest udiwmsBusTypeRequest) { - CtqyyRequest ctqyyRequest = new CtqyyRequest(); - ctqyyRequest.setMsgHeader(getMsgHeader("getMaterialType")); - ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsBusTypeRequest)); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_BUS_TYPE_QUERY_URL), ctqyyRequest); - response = parserResult(response); - try { - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } catch (Exception e) { - log.error("解析长泰区医院智业接口返回单据类型数据异常,返回结果:{}", response); - log.error("异常信息:{}", e); - return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")"); - } - } - - /** - * 提交关联产品更新 - * - * @return - */ - @Override - public BaseResponse postRelProduct(PostRelProductRequest postThrInvProductsRequest) { - UdiRelevanceResponse udiRelevanceResponse = postThrInvProductsRequest.getUdiRelevanceResponse(); - - if (udiRelevanceResponse == null) { - return ResultVOUtils.error(500, "提交产品列表不能为空!"); - } - MaterialDictEntity materialDictEntity = new MaterialDictEntity(); - if (StrUtil.isEmpty(udiRelevanceResponse.getMainId())) - materialDictEntity.setOperatType("1"); - else - materialDictEntity.setOperatType("2"); - materialDictEntity.setMaterialName(udiRelevanceResponse.getCpmctymc()); - materialDictEntity.setCostlySign("1"); - if (StrUtil.isNotEmpty(udiRelevanceResponse.getMainId()) && udiRelevanceResponse.getMainId().endsWith("x")) { - materialDictEntity.setMaterialMasterCode(null); - materialDictEntity.setHisMaterialCode(null); - materialDictEntity.setCostlySign("0"); - materialDictEntity.setOperatType("1"); - } else { - materialDictEntity.setMaterialMasterCode(udiRelevanceResponse.getNameCode()); - materialDictEntity.setHisMaterialCode(udiRelevanceResponse.getMainId()); - } - - materialDictEntity.setMaterialSpec(udiRelevanceResponse.getGgxh()); - materialDictEntity.setMaterialUnit(udiRelevanceResponse.getMeasname()); - //暂无区分进货价,零售价 - materialDictEntity.setImportPrice(udiRelevanceResponse.getPrice() == null ? "0" : udiRelevanceResponse.getPrice().toString()); - materialDictEntity.setRetailPrice(udiRelevanceResponse.getPrice() == null ? "0" : udiRelevanceResponse.getPrice().toString()); - materialDictEntity.setFactoryName(udiRelevanceResponse.getManufactory()); - materialDictEntity.setSupplierName(udiRelevanceResponse.getSupName()); - materialDictEntity.setInsuranceCode(udiRelevanceResponse.getYbbm()); - materialDictEntity.setRegeditNo(udiRelevanceResponse.getZczbhhzbapzbh()); - materialDictEntity.setMaterialClass(udiRelevanceResponse.getBasicPrductRemak7()); - //暂无中标标识 - materialDictEntity.setPublicFlag("1"); - materialDictEntity.setPriceItemClass(udiRelevanceResponse.getBasicPrductRemak8()); - //暂无收费标志 - materialDictEntity.setFeeFlag(udiRelevanceResponse.getBasicPrductRemak6()); - - - CtqyyRequest ctqyyRequest = new CtqyyRequest(); - ctqyyRequest.setMsgHeader(getMsgHeader("addMaterialDict")); - ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(materialDictEntity)); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_PRODUCT_SUBMIT_URL), ctqyyRequest); - response = parserResult(response); - try { - log.error("提交新增产品信息:" + ctqyyRequest.getMsgBody()); - CtBaseResponse baseResponse = JSONObject.parseObject(response, CtBaseResponse.class); - if (baseResponse.getCode() != 20000) { - String errMsg = "提交新增产品信息,异常:{}" + response; - log.error(errMsg); - return ResultVOUtils.error(500, "提交新增产品失败!"); - - } else { -// materialDictEntity.setMaterialNo(baseResponse.getMaterialNo()); - log.error("提交新增产品信息,成功:{}", response); - return ResultVOUtils.success(baseResponse.getMaterialNo()); - } - } catch (Exception e) { - String errMsg = "提交新增产品信息,异常:{}" + response; - log.error(errMsg); - log.error("异常信息:{}", e); - return ResultVOUtils.error(500, errMsg); - - } - } - - - /** - * 获取患者信息 - * - * @param getSickRequest - * @return - */ - public BaseResponse getSickInfo(GetSickRequest getSickRequest) { - CtqyyRequest ctqyyRequest = new CtqyyRequest(); - ctqyyRequest.setMsgHeader(getMsgHeader("getSickVisitInfo")); - ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(getSickRequest)); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URI_GET_SICKER), ctqyyRequest); - response = parserResult(response); - try { - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - Map map = (Map) baseResponse.getData(); - List basicSkSickerResponses = JSON.parseArray(map.get("list") + "", BasicSkSickerResponse.class); -// for (BasicSkSickerResponse productsResponse : basicSkSickerResponses) { -// -// } - map.put("list", JSON.toJSON(basicSkSickerResponses)); - baseResponse.setData(""); - baseResponse.setData(map); - return baseResponse; - } catch (Exception e) { - log.error("解析长泰医院智业返回病人信息数据异常,返回结果:{}", response); - log.error("异常信息:{}", e); - return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")"); - } - } - - /** - * 获取患者处方信息 - * - * @param getSickPrescribeRequest - * @return - */ - public BaseResponse getSickPescribe(GetSickPrescribeRequest getSickPrescribeRequest) { - CtqyyRequest ctqyyRequest = new CtqyyRequest(); - ctqyyRequest.setMsgHeader(getMsgHeader("getResiPresInfo")); - getSickPrescribeRequest.setResiNo(getSickPrescribeRequest.getAdNum()); - getSickPrescribeRequest.setAdNum(null); - ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(getSickPrescribeRequest)); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URI_GET_SICKER_PRESCIRBE), ctqyyRequest); - response = parserResult(response); - try { - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - Map map = (Map) baseResponse.getData(); - List basicSkPrescribeResponses = JSON.parseArray(map.get("list") + "", BasicSkPrescribeResponse.class); - for (BasicSkPrescribeResponse basicSkPrescribeResponse : basicSkPrescribeResponses) { - List itemEntities = basicSkPrescribeResponse.getItemList(); - if (CollUtil.isNotEmpty(itemEntities)) { - for (BasicSkPrescribeItemEntity itemEntity : itemEntities) { - itemEntity.setCount("0"); - } - } - } - map.put("list", JSON.toJSON(basicSkPrescribeResponses)); - baseResponse.setData(""); - baseResponse.setData(map); - return baseResponse; - } catch (Exception e) { - log.error("解析长泰医院智业返回处方信息数据异常,返回结果:{}", response); - log.error("异常信息:{}", e); - return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")"); - } - - } -// public String getStrConut(String str) { -// if (StrUtil.isNotEmpty(str)) { -// return "0"; -// } -// Pattern pattern = Pattern.compile("\\d+"); -// Matcher matcher = pattern.matcher(str); -// String strCount = ""; -// while (matcher.find()) { -// strCount = strCount + matcher.group(); -// } -// return strCount; -// } - - /** - * 获取项目组套字典 - * - * @param dlThirdProjectRequest - * @return - */ - @Override - public BaseResponse getBasicProject(DlThirdProjectRequest dlThirdProjectRequest) { - CtqyyRequest ctqyyRequest = new CtqyyRequest(); - ctqyyRequest.setMsgHeader(getMsgHeader("getMaterialDict")); - ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(dlThirdProjectRequest)); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URI_GET_PROJECT), ctqyyRequest); - response = parserResult(response); - try { - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - Map map = (Map) baseResponse.getData(); - List basicSkProjectResponses = JSON.parseArray(map.get("list") + "", BasicSkProjectResponse.class); - for (BasicSkProjectResponse basicSkProjectResponse : basicSkProjectResponses) { - - } - map.put("list", JSON.toJSON(basicSkProjectResponses)); - baseResponse.setData(""); - baseResponse.setData(map); - return baseResponse; - } catch (Exception e) { - log.error("解析长泰医院智业返回项目信息数据异常,返回结果:{}", response); - log.error("异常信息:{}", e); - return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")"); - } - } - - - /** - * 获取核算类别 - * - * @param hslbRequest - * @return - */ - @Override - public BaseResponse getHsfl(FilterThrHslbRequest hslbRequest) { - CtqyyRequest ctqyyRequest = new CtqyyRequest(); - ctqyyRequest.setMsgHeader(getMsgHeader("getItemClass")); - ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(hslbRequest)); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URI_GET_HSLB), ctqyyRequest); - response = parserResult(response); - try { - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - Map map = (Map) baseResponse.getData(); - List priceClassEntities = JSON.parseArray(map.get("list") + "", PriceClassEntity.class); - - List hslbEntities = new ArrayList<>(); - for (PriceClassEntity priceClassEntity : priceClassEntities) { - ThrHslbEntity thrHslbEntity = new ThrHslbEntity(); - thrHslbEntity.setHsbm(priceClassEntity.getClassCode()); - thrHslbEntity.setHsmc(priceClassEntity.getClassName()); - hslbEntities.add(thrHslbEntity); - } - map.put("list", JSON.toJSON(hslbEntities)); - baseResponse.setData(""); - baseResponse.setData(map); - return baseResponse; - } catch (Exception e) { - log.error("解析长泰医院智业返回物价类别信息异常,返回结果:{}", response); - log.error("异常信息:{}", e); - return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")"); - } - } - - @Override - public BaseResponse queryUdiHighInvProductsFilter(ForInvProductsFilter forInvProductsFilter) { - return null; - } - - - @Override - public BaseResponse getOrders(UdiwmsOrderQueryRequest udiwmsOrderQueryRequest) { - return null; - } - - - @Override - public BaseResponse submitOrders(UdiwmsOrderRequest udiwmsOrderRequest) { - if (StrUtil.isBlank(udiwmsOrderRequest.getBillNo())) { - return ResultVOUtils.error(500, "单据号不能为空"); - } - - ZaxzyyOrderRequest zaxzyyOrderRequest = new ZaxzyyOrderRequest(); - BeanUtil.copyProperties(udiwmsOrderRequest, zaxzyyOrderRequest); - //查询单据和详情信息,组装第三方系统接口所需参数 - IoOrderEntity orderEntity = orderDao.selectOne(new QueryWrapper().eq("billNo", udiwmsOrderRequest.getBillNo())); - - zaxzyyOrderRequest.setBillDate(DateUtil.formatDateTime(orderEntity.getCreateTime())); - //查询对应的第三方单据类型 - ThrSystemBusApiEntity thrSystemBusApiEntity = thrSystemBusApiDao.selectOne(new QueryWrapper().eq("code", udiwmsOrderRequest.getBillType())); - zaxzyyOrderRequest.setThirdSys(getUserName(orderEntity)); - zaxzyyOrderRequest.setBillType(thrSystemBusApiEntity.getThirdBuyCode()); - zaxzyyOrderRequest.setBillFlag("1"); - - //查询单据类型 - BasicBussinessTypeEntity basicBussinessTypeEntity = basicBussinessTypeDao.selectByAction(udiwmsOrderRequest.getBillType()); - if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_HOSPTIAL)) { - //医院客户 - zaxzyyOrderRequest.setCorpId(orderEntity.getFromCorp()); - //查询客户名称 - String corpName = basicCorpDao.selectNameByErpId(orderEntity.getFromCorp()); - zaxzyyOrderRequest.setCorpName(corpName); - } else if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_INTTERNAL)) { - //内部科室 - BasicCorpEntity basicCorpEntity = null; - if (StrUtil.isNotEmpty(orderEntity.getFromCorp())) { - basicCorpEntity = basicCorpDao.selectByErpId(orderEntity.getFromCorp()); - } - if (basicCorpEntity != null) { - zaxzyyOrderRequest.setCorpId(basicCorpEntity.getThirdId()); - zaxzyyOrderRequest.setCorpName(basicCorpEntity.getName()); - } else { - AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new QueryWrapper().eq("code", udiwmsOrderRequest.getCorpId())); - try { - //根据第三方系统标识,获取对应字段的值 - ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper() - .eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity)) - .eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId())); - - zaxzyyOrderRequest.setCorpId(thrInvWarehouseEntity.getCode()); - zaxzyyOrderRequest.setCorpName(thrInvWarehouseEntity.getName()); - } catch (Exception e) { - String msg = "查询单据对应往来单位的第三方仓库信息异常"; - orderUploadLogService.updateLocalErr(orderEntity, msg); - log.error("----单据提交-----" + orderEntity.getBillNo() + msg); - return ResultVOUtils.error(500, msg); - } - } - - } else { - //供应商 - BasicCorpEntity basicCorpEntity = null; - if (StrUtil.isNotEmpty(orderEntity.getFromCorp())) { - basicCorpEntity = basicCorpDao.selectByErpId(orderEntity.getFromCorp()); - } - if (basicCorpEntity != null) { - zaxzyyOrderRequest.setCorpId(basicCorpEntity.getThirdId()); - zaxzyyOrderRequest.setCorpName(basicCorpEntity.getName()); - } else { - String msg = "查询单据对应的第三方往来单位信息异常"; - orderUploadLogService.updateLocalErr(orderEntity, msg); - log.error("----单据提交-----" + orderEntity.getBillNo() + msg); - return ResultVOUtils.error(500, msg); - } - } - - - //查询仓库信息 - AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new QueryWrapper().eq("code", orderEntity.getInvCode())); - try { - ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper() - .eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity)) - .eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId())); - - zaxzyyOrderRequest.setLocInvCode(thrInvWarehouseEntity.getCode()); - zaxzyyOrderRequest.setLocInvName(thrInvWarehouseEntity.getName()); - - zaxzyyOrderRequest.setLocStorageCode(thrInvWarehouseEntity.getCode()); - zaxzyyOrderRequest.setLocStorageName(thrInvWarehouseEntity.getName()); - } catch (Exception e) { - log.error("查询第三方系统仓库信息异常", e); - String msg = "查询第三方系统仓库信息异常"; - orderUploadLogService.updateLocalErr(orderEntity, msg); - return ResultVOUtils.error(500, msg); - } - - //设置单据出入库类型 - if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_PUT)) { - zaxzyyOrderRequest.setInoutType(1); //入库 - } else if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT)) { - zaxzyyOrderRequest.setInoutType(2); //出库 - } - - //设置备注信息 - zaxzyyOrderRequest.setRemark("udi管理系统提交单据"); - //组装单据明细数据 - List ioCodeEntities = codeDao.selectList(new QueryWrapper() - .eq("orderId", orderEntity.getBillNo()) - .ne("action", "StockCheck") - ); - List items = new ArrayList<>(); - //查询业务单据详情 - List detailBizEntities = orderDetailBizDao.selectList(new QueryWrapper().eq("orderIdFk", orderEntity.getBillNo())); - String errMsg = setOrderDetailList(ioCodeEntities, items, detailBizEntities); - zaxzyyOrderRequest.setItem(items); - if (CollUtil.isEmpty(items)) { - orderUploadLogService.updateLocalErr(orderEntity, errMsg); - return ResultVOUtils.error(500, errMsg); - } - - if (StrUtil.isNotEmpty(errMsg)) { - orderUploadLogService.updateLocalErr(orderEntity, errMsg); - return ResultVOUtils.error(500, errMsg); - } - - - for (UdiwmsOrderDetailRequest i : items) { - String fphm = ""; - String fprq = null; - List invoiceList = IoOrderInvoiceEntity.builder().build() - .selectList(Wrappers.lambdaQuery(IoOrderInvoiceEntity.class).eq(IoOrderInvoiceEntity::getOrderIdFk, orderEntity.getBillNo()) - .eq(IoOrderInvoiceEntity::getBindRlFk, i.getBindRlFk()) - .eq(StrUtil.isNotEmpty(i.getBatchNo()), IoOrderInvoiceEntity::getBatchNo, i.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()); - } - i.setFirstSalesInvNo(fphm); - i.setSecSalesInvNo(fphm); - i.setInvoiceDate(fprq); - } - - - //构造诏安接口参数 - ZzzyyRequest zaZyRequest = new ZzzyyRequest(); - - //提交到第三方系统 - if (thrSystemBusApiEntity.getUrl().equals("saveMasterialInput")) { -// //采购入库单据 - if (vailHightMaterial(detailBizEntities.get(0))) { - zaZyRequest.setMsgHeader(getMsgHeader("saveMaterialHight")); - UdiwmsPreInOrderRequest udiwmsPreInOrderRequest = submitPreInOrderToThirdSys(zaxzyyOrderRequest, orderEntity); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsPreInOrderRequest)); - } else { - zaZyRequest.setMsgHeader(getMsgHeader("saveMasterialInput")); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(zaxzyyOrderRequest)); - } - Boolean b = sysParamConfigService.selectByKey("ct_split_groupbuy"); - if (b) { - Map> splitMap = items.stream() - .collect(Collectors.groupingBy(UdiwmsOrderDetailRequest::getFirstSalesInvNo)); - BaseResponse baseResponse = null; - int index = 1; - if (splitMap.size() > 1) { - for (List splitItems : splitMap.values()) { - zaxzyyOrderRequest.setItem(splitItems); - zaZyRequest.setMsgHeader(getMsgHeader("saveMasterialInput")); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(zaxzyyOrderRequest)); - orderEntity.setBillNo(orderEntity.getBillNo() + "-" + index); - baseResponse = submitOrder(orderEntity, zaZyRequest); - } - return baseResponse; - } else { - zaZyRequest.setMsgHeader(getMsgHeader("saveMasterialInput")); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(zaxzyyOrderRequest)); - return submitOrder(orderEntity, zaZyRequest); - } - } else { - zaZyRequest.setMsgHeader(getMsgHeader("saveMasterialInput")); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(zaxzyyOrderRequest)); - return submitOrder(orderEntity, zaZyRequest); - } - - - } else if (thrSystemBusApiEntity.getUrl().equals("saveMaterialHight")) { - -// // 1.先提交到物资 -// zaZyRequest.setMsgHeader(getMsgHeader("saveMasterialInput")); -// zaZyRequest.setMsgBody(JSONUtil.toJsonStr(zaxzyyOrderRequest)); -// submitOrder(orderEntity, zaZyRequest); - - - //2.提交到预备货 - zaZyRequest.setMsgHeader(getMsgHeader("saveMaterialHight")); - UdiwmsPreInOrderRequest udiwmsPreInOrderRequest = submitPreInOrderToThirdSys(zaxzyyOrderRequest, orderEntity); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsPreInOrderRequest)); - return submitOrder(orderEntity, zaZyRequest); - } - - return ResultVOUtils.error(500, "提交失败!"); - } - - - /** - * 校验是否高值耗材 - * - * @return - */ - public boolean vailHightMaterial(IoOrderDetailBizEntity orderDetailBizEntity) { - BasicUdirelEntity basicUdirel = basicUdirelDao.selectById(orderDetailBizEntity.getBindRlFk()); -// BasicProductsEntity basicProductsEntity = basicProductsDao.selectOne(new QueryWrapper().eq("uuid", basicUdirel.getUuid()).last("limit 1")); - if (basicUdirel != null && IntUtil.value(basicUdirel.getHcType()) == 1) { - return true; - } else - return false; - - } - - - public String getUserName(IoOrderEntity orderEntity) { - - return "王欣/L164"; -// String userName = null; -// //创建人非供应商 -// if (StrUtil.isNotEmpty(orderEntity.getCheckUser())) { -// AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getCheckUser()); -// if (authUserEntity == null) -// userName = null; -// userName = authUserEntity.getUserName() + authUserEntity.getEmployeeName(); -// } else if (StrUtil.isNotEmpty(orderEntity.getReviewUser())) { -// AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getReviewUser()); -// userName = authUserEntity.getUserName() + authUserEntity.getEmployeeName(); -// } else if (StrUtil.isNotEmpty(orderEntity.getCreateUser()) && orderEntity.getCreateUser().length() != 14) { -// AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getCreateUser()); -// userName = authUserEntity.getUserName() + authUserEntity.getEmployeeName(); -// } else if (StrUtil.isNotEmpty(orderEntity.getUpdateUser()) && orderEntity.getUpdateUser().length() != 14) { -// AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getUpdateUser()); -// userName = authUserEntity.getUserName() + authUserEntity.getEmployeeName(); -// } -// if (userName == null) { -// List authWarehouseUsers = authWarehouseUserMapper.selectList(new QueryWrapper().eq("code", orderEntity.getInvCode())); -// if (CollUtil.isNotEmpty(authWarehouseUsers)) { -// AuthWarehouseUser authWarehouseUser = authWarehouseUsers.get(0); -// AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getCheckUser()); -// userName = authUserEntity.getUserName() + authUserEntity.getEmployeeName(); -// return userName; -// } -// } -// return userName; - - } - - /** - * 获取库存出入库明细 (普耗出库明细) - * - * @param udiwmsInvProductsRequest - * @return - */ - @Override - public BaseResponse getInvResult(UdiwmsInvProductsRequest udiwmsInvProductsRequest) { - CtqyyInvRequest ptxhyyInvRequest = new CtqyyInvRequest(); - ptxhyyInvRequest.setStartdate(DateUtil.formatDate(udiwmsInvProductsRequest.getStartDate(), "yyyy-MM-dd")); - ptxhyyInvRequest.setEnddate(DateUtil.formatDate(udiwmsInvProductsRequest.getEndDate(), "yyyy-MM-dd")); - - CtqyyRequest ctqyyRequest = new CtqyyRequest(); - ctqyyRequest.setMsgHeader(getMsgHeader("getMaterialSheet")); - ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(ptxhyyInvRequest)); - - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_GET_INV_RESULT), ctqyyRequest); -// String response = "{\"code\":20000,\"message\":\"success\",\"data\":{\"list\":[{\"applyNo\":\"74192\",\"ioFlag\":\"出库业务\",\"ioType\":\"104\",\"ioTypeName\":\"科室领用\",\"Debit\":\"50\",\"DebitName\":\"供应室仓库\",\"Credit\":\"65\",\"CreditName\":\"急诊科\",\"AccoutDate\":\"2024-02-2210:36:28\",\"Accoutant\":\"徐秀娥/160\",\"receiveOper\":\"\",\"materialCode\":\"66666666\",\"materialName\":\"一次性注射器2ml\",\"materialSpec\":\"0.6\",\"materialUnit\":\"支\",\"batchNo\":65212,\"invoiceNo\":\"\",\"invoiceDate\":\"\",\"quantity\":200,\"importPrc\":0.21,\"importMoney\":42,\"factoryCode\":\"0006064349\",\"factoryName\":\"河南曙光汇知康生物科技股份有限公司\"},{\"applyNo\":\"74208\",\"ioFlag\":\"出库业务\",\"ioType\":\"104\",\"ioTypeName\":\"科室领用\",\"Debit\":\"50\",\"DebitName\":\"供应室仓库\",\"Credit\":\"70\",\"CreditName\":\"手术室\",\"AccoutDate\":\"2024-02-2315:29:48\",\"Accoutant\":\"徐秀娥/160\",\"receiveOper\":\"\",\"materialCode\":\"31585\",\"materialName\":\"一次性使用鼻氧管(吸氧管)\",\"materialSpec\":\"长单鼻/条\",\"materialUnit\":\"条\",\"batchNo\":64113,\"invoiceNo\":\"\",\"invoiceDate\":\"\",\"quantity\":19,\"importPrc\":1.15,\"importMoney\":21.85,\"factoryCode\":\"0006063576\",\"factoryName\":\"苏州市麦克林医疗器械制品有限公司\"},{\"applyNo\":\"74208\",\"ioFlag\":\"出库业务\",\"ioType\":\"104\",\"ioTypeName\":\"科室领用\",\"Debit\":\"50\",\"DebitName\":\"供应室仓库\",\"Credit\":\"70\",\"CreditName\":\"手术室\",\"AccoutDate\":\"2024-02-2315:29:48\",\"Accoutant\":\"徐秀娥/160\",\"receiveOper\":\"\",\"materialCode\":\"31585\",\"materialName\":\"一次性使用鼻氧管(吸氧管)\",\"materialSpec\":\"长单鼻/条\",\"materialUnit\":\"条\",\"batchNo\":65526,\"invoiceNo\":\"\",\"invoiceDate\":\"\",\"quantity\":81,\"importPrc\":1.15,\"importMoney\":93.15,\"factoryCode\":\"0006063576\",\"factoryName\":\"苏州市麦克林医疗器械制品有限公司\"},{\"applyNo\":\"74209\",\"ioFlag\":\"出库业务\",\"ioType\":\"104\",\"ioTypeName\":\"科室领用\",\"Debit\":\"50\",\"DebitName\":\"供应室仓库\",\"Credit\":\"92\",\"CreditName\":\"儿科\",\"AccoutDate\":\"2024-02-2315:31:58\",\"Accoutant\":\"徐秀娥/160\",\"receiveOper\":\"\",\"materialCode\":\"30936\",\"materialName\":\"一次性静脉输液针5(1/2)\",\"materialSpec\":\"/条\",\"materialUnit\":\"条\",\"batchNo\":64898,\"invoiceNo\":\"\",\"invoiceDate\":\"\",\"quantity\":250,\"importPrc\":0.17,\"importMoney\":42.5,\"factoryCode\":\"0006063565\",\"factoryName\":\"浙江康康\"}],\"total\":4}}"; - - BaseResponse> baseResponse = - JSONObject.parseObject(response, new TypeReference>>() { - }); - if (baseResponse.getCode() == 20000) { - List ptxhInvResponses = baseResponse.getData().getList(); - List thrInvResultResponses = new ArrayList<>(); - if (CollUtil.isNotEmpty(ptxhInvResponses)) { - for (InvResultEntity ptxhInvResponse : ptxhInvResponses) { - ThrInvResultResponse thrInvResultResponse = new ThrInvResultResponse(); - thrInvResultResponse.setThrCode(ptxhInvResponse.getMaterialCode()); - thrInvResultResponse.setCpmctymc(ptxhInvResponse.getMaterialName()); - thrInvResultResponse.setGgxh(ptxhInvResponse.getMaterialSpec()); - thrInvResultResponse.setBatchNo(ptxhInvResponse.getBatchNo()); - thrInvResultResponse.setMeasname(ptxhInvResponse.getMaterialUnit()); - thrInvResultResponse.setPrice(BigDecimal.valueOf(ptxhInvResponse.getImportPrc())); - thrInvResultResponse.setAmount(BigDecimal.valueOf(ptxhInvResponse.getImportMoney())); -// thrInvResultResponse.setDeptName(ptxhInvResponse.getDebitName()); -// thrInvResultResponse.setDeptCode(ptxhInvResponse.getDebit()); -// thrInvResultResponse.setInvName(ptxhInvResponse.getCreditName()); -// thrInvResultResponse.setInvCode(ptxhInvResponse.getCredit()); - - thrInvResultResponse.setDeptName(ptxhInvResponse.getDebitName()); - thrInvResultResponse.setDeptCode("1002"); - thrInvResultResponse.setInvName(ptxhInvResponse.getCreditName()); - thrInvResultResponse.setInvCode("1000003"); - - thrInvResultResponse.setManufacturer(ptxhInvResponse.getFactoryName()); - thrInvResultResponse.setManufactoryCode(ptxhInvResponse.getFactoryCode()); - thrInvResultResponse.setMainAction(ConstantType.TYPE_OUT); - thrInvResultResponse.setBillType(ptxhInvResponse.getIoType()); - thrInvResultResponse.setType("1"); - thrInvResultResponse.setOutCount(ptxhInvResponse.getQuantity() + ""); - thrInvResultResponse.setReCount(ptxhInvResponse.getQuantity() + ""); - thrInvResultResponses.add(thrInvResultResponse); - } - } - PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(thrInvResultResponses.size() + 0l); - pageSimpleResponse.setList(thrInvResultResponses); - return ResultVOUtils.success(pageSimpleResponse); - } - return baseResponse; - } - - - /** - * 获取库存扫码出入库明细(高值耗材出库明细) - * - * @param udiwmsInvProductsRequest - * @return - */ - @Override - public BaseResponse getInvCodeResult(UdiwmsInvProductsRequest udiwmsInvProductsRequest) { - CtqyyInvRequest ptxhyyInvRequest = new CtqyyInvRequest(); - ptxhyyInvRequest.setStartdate(DateUtil.formatDate(udiwmsInvProductsRequest.getStartDate(), "yyyy-MM-dd")); - ptxhyyInvRequest.setEnddate(DateUtil.formatDate(udiwmsInvProductsRequest.getEndDate(), "yyyy-MM-dd")); - - CtqyyRequest ctqyyRequest = new CtqyyRequest(); - ctqyyRequest.setMsgHeader(getMsgHeader("getSickHighitem")); - ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(ptxhyyInvRequest)); - - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_GET_INV_RESULT), ctqyyRequest); -// String response = -// "{\"code\": 20000,\"message\": \"success\",\"data\": {\"list\": [{\"recordNo\": 391,\"visitNo\": \"1711088001\",\"sickName\": \"黄瑞梅\",\"inDept\": \"88\",\"deptName\": \"骨科\",\"materialCode\": \"63374\",\"materialName\": \"调节杠\",\"materialPrc\": 2100,\"dictBarcode\": \"0106971221560052\",\"Barcode\": \"111704022117000188340055\",\"feeTime\": \"2024-03-01 19:29:02\",\"feeOper\": \"郑淑环/2032\"},{\"recordNo\": 390,\"visitNo\": \"1711088001\",\"sickName\": \"黄瑞梅\",\"inDept\": \"88\",\"deptName\": \"骨科\",\"materialCode\": \"63374\",\"materialName\": \"调节杠\",\"materialPrc\": 2100,\"dictBarcode\": \"0106946149100093\",\"Barcode\": \"111704022117000188340007\",\"feeTime\": \"2024-03-01 19:29:02\",\"feeOper\": \"郑淑环/2032\"},{\"recordNo\": 408,\"visitNo\": \"1711088001\",\"sickName\": \"黄瑞梅\",\"inDept\": \"88\",\"deptName\": \"骨科\",\"materialCode\": \"63182\",\"materialName\": \"椎弓根螺钉\",\"materialPrc\": 4000,\"dictBarcode\": \"0106938695502193\",\"Barcode\": \"111703012117000076800035\",\"feeTime\": \"2024-03-01 19:29:02\",\"feeOper\": \"郑淑环/2032\"},{\"recordNo\": 401,\"visitNo\": \"1711088001\",\"sickName\": \"黄瑞梅\",\"inDept\": \"88\",\"deptName\": \"骨科\",\"materialCode\": \"63186\",\"materialName\": \"椎弓根螺钉\",\"materialPrc\": 4000,\"dictBarcode\": \"0106938695522023\",\"Barcode\": \"111612212116120902040009\",\"feeTime\": \"2024-03-01 19:29:02\",\"feeOper\": \"郑淑环/2032\"},{\"recordNo\": 423,\"visitNo\": \"1711088001\",\"sickName\": \"黄瑞梅\",\"inDept\": \"88\",\"deptName\": \"骨科\",\"materialCode\": \"63186\",\"materialName\": \"椎弓根螺钉\",\"materialPrc\": 4000,\"dictBarcode\": \"0106938695525055\",\"Barcode\": \"111701062116122700670005\",\"feeTime\": \"2024-03-01 19:29:02\",\"feeOper\": \"郑淑环/2032\"},{\"recordNo\": 400,\"visitNo\": \"1711088001\",\"sickName\": \"黄瑞梅\",\"inDept\": \"88\",\"deptName\": \"骨科\",\"materialCode\": \"63186\",\"materialName\": \"椎弓根螺钉\",\"materialPrc\": 4000,\"dictBarcode\": \"0106921814249918\",\"Barcode\": \"111612212116120902040047\",\"feeTime\": \"2024-03-01 19:29:02\",\"feeOper\": \"郑淑环/2032\"},{\"recordNo\": 422,\"visitNo\": \"1711088001\",\"sickName\": \"黄瑞梅\",\"inDept\": \"88\",\"deptName\": \"骨科\",\"materialCode\": \"63186\",\"materialName\": \"椎弓根螺钉\",\"materialPrc\": 4000,\"dictBarcode\": \"0106921814249918\",\"Barcode\": \"111701062116122700670013\",\"feeTime\": \"2024-03-01 19:29:02\",\"feeOper\": \"郑淑环/2032\"}],\"total\": 7}}"; -// String response = null; -// try { -// response = FileUtils.getFileContent("E://ghresponse.json"); -// } catch (IOException e) { -// e.printStackTrace(); -// } - - BaseResponse> baseResponse = - JSONObject.parseObject(response, new TypeReference>>() { - }); - if (baseResponse.getCode() == 20000) { - Map mapArry = new HashMap<>(); - List newArry = new ArrayList<>(); - List ptxhInvResponses = baseResponse.getData().getList(); - List thrInvResultResponses = new ArrayList<>(); - if (CollUtil.isNotEmpty(ptxhInvResponses)) { - for (InvCodeResultEntity ptxhInvResponse : ptxhInvResponses) { - ThrInvResultResponse thrInvResultResponse = new ThrInvResultResponse(); - thrInvResultResponse.setThrCode(ptxhInvResponse.getMaterialCode()); - thrInvResultResponse.setCpmctymc(ptxhInvResponse.getMaterialName()); - thrInvResultResponse.setPrice(BigDecimal.valueOf(ptxhInvResponse.getMaterialPrc())); - - - thrInvResultResponse.setInvName(ptxhInvResponse.getDeptName()); - -// AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new LambdaQueryWrapper().eq(AuthWarehouseEntity::getThirdId, ptxhInvResponse.getInDept())); -// if (warehouseEntity != null) -// thrInvResultResponse.setInvCode(warehouseEntity.getCode()); -// else -// thrInvResultResponse.setInvCode(ptxhInvResponse.getInDept()); - - thrInvResultResponse.setSickerCode(ptxhInvResponse.getVisitNo()); - thrInvResultResponse.setSickerName(ptxhInvResponse.getSickName()); - thrInvResultResponse.setChargeTime(ptxhInvResponse.getFeeTime()); - thrInvResultResponse.setChargeUser(ptxhInvResponse.getFeeOper()); - - thrInvResultResponse.setInvCode("1000003"); - thrInvResultResponse.setDeptCode("1002"); - thrInvResultResponse.setSickerCode(ptxhInvResponse.getVisitNo()); - thrInvResultResponse.setSickerName(ptxhInvResponse.getSickName()); - thrInvResultResponse.setBillType("SC71090077430919"); - thrInvResultResponse.setMainAction(ConstantType.TYPE_OUT); - thrInvResultResponse.setType("1"); - thrInvResultResponse.setOutCount("1"); - thrInvResultResponse.setReCount("1"); - - String barCode = ptxhInvResponse.getBarcode(); - if (!barCode.contains(ptxhInvResponse.getDictBarcode())) { - barCode = "01" + barCode + ptxhInvResponse.getDictBarcode(); - } - //获取完整UDI码 - IoCodeEntity codeEntity = codeDao.selectOne(new LambdaQueryWrapper().eq(IoCodeEntity::getCode, barCode).last("limit 1")); - if (codeEntity == null) { - codeEntity = codeDao.selectOne(new LambdaQueryWrapper().eq(IoCodeEntity::getErrUdiCode, barCode).last("limit 1")); - } - if (codeEntity != null) - thrInvResultResponse.setUdiCode(codeEntity.getCode()); - else - thrInvResultResponse.setUdiCode(ptxhInvResponse.getBarcode()); - thrInvResultResponses.add(thrInvResultResponse); - } - - for (ThrInvResultResponse thrInvResultResponse : thrInvResultResponses) { - mapArry.merge(thrInvResultResponse.getUdiCode(), thrInvResultResponse, (existingValue, newValue) -> { - // Assuming reCount can be directly handled as an integer to avoid String to Integer conversions - int updatedReCount = Integer.parseInt(existingValue.getReCount()) + Integer.parseInt(newValue.getReCount()); - existingValue.setReCount(String.valueOf(updatedReCount)); - existingValue.setOutCount(existingValue.getReCount()); - return existingValue; - }); - } - for (String key : mapArry.keySet()) { - newArry.add(mapArry.get(key)); - } - - } - PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(newArry.size() + 0l); - pageSimpleResponse.setList(newArry); - return ResultVOUtils.success(pageSimpleResponse); - } - return baseResponse; - } - - - @Override - public BaseResponse getInvFeeResult(UdiwmsInvProductsRequest udiwmsInvProductsRequest) { - CtqyyInvRequest ptxhyyInvRequest = new CtqyyInvRequest(); - ptxhyyInvRequest.setStartdate(DateUtil.formatDate(udiwmsInvProductsRequest.getStartDate(), "yyyy-MM-dd")); - ptxhyyInvRequest.setEnddate(DateUtil.formatDate(udiwmsInvProductsRequest.getEndDate(), "yyyy-MM-dd")); - - CtqyyRequest ctqyyRequest = new CtqyyRequest(); - ctqyyRequest.setMsgHeader(getMsgHeader("getSickPriceitem")); - ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(ptxhyyInvRequest)); - - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_GET_INV_RESULT), ctqyyRequest); -// String response = -// "{\"code\": 20000,\"message\": \"success\",\"data\": {\"list\": [{\"seqNo\": \"97425947\",\"visitNo\": \"1471827014\",\"sickName\": \"杨玉聪\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000004\",\"itemName\": \"一次性使用人体静脉血样采集容器(血常规管 2ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 00:53:56\"},{\"seqNo\": \"97425950\",\"visitNo\": \"1471827014\",\"sickName\": \"杨玉聪\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 00:53:56\"},{\"seqNo\": \"97426036\",\"visitNo\": \"1940696001\",\"sickName\": \"郑良屹\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950057000000\",\"itemName\": \"热敏胶片 8in*10in/HQ-KX411 A型\",\"Price\": 7.8,\"quantity\": 4,\"Cost\": 31.2,\"materialCode\": \"00087\",\"materialName\": \"热敏胶片\",\"OperTime\": \"2024-02-21 01:39:39\"},{\"seqNo\": \"97426048\",\"visitNo\": \"1746585006\",\"sickName\": \"张杨妍\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950030000005\",\"itemName\": \"一次性注射器2ml(/支)\",\"Price\": 0.21,\"quantity\": 1,\"Cost\": 0.21,\"materialCode\": \"77375\",\"materialName\": \"一次性注射器2ml\",\"OperTime\": \"2024-02-21 02:06:05\"},{\"seqNo\": \"97426113\",\"visitNo\": \"1735717004\",\"sickName\": \"林文秀\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 04:49:46\"},{\"seqNo\": \"97426233\",\"visitNo\": \"1735717004\",\"sickName\": \"林文秀\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000005\",\"itemName\": \"一次性使用人体静脉血样采集容器(生化管 5ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68973\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 04:54:51\"},{\"seqNo\": \"97426247\",\"visitNo\": \"1735717004\",\"sickName\": \"林文秀\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000004\",\"itemName\": \"一次性使用人体静脉血样采集容器(血常规管 2ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 04:54:55\"},{\"seqNo\": \"97426250\",\"visitNo\": \"1735717004\",\"sickName\": \"林文秀\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950029000010\",\"itemName\": \"一次性使用输液器BI-IT带针0.7# /支)\",\"Price\": 0.81,\"quantity\": 1,\"Cost\": 0.81,\"materialCode\": \"02585\",\"materialName\": \"一次性使用输液器 带针\",\"OperTime\": \"2024-02-21 04:56:20\"},{\"seqNo\": \"97426251\",\"visitNo\": \"1735717004\",\"sickName\": \"林文秀\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950030000006\",\"itemName\": \"一次性无菌注射器20ml(/支)\",\"Price\": 0.48,\"quantity\": 2,\"Cost\": 0.96,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 04:56:21\"},{\"seqNo\": \"97426252\",\"visitNo\": \"1735717004\",\"sickName\": \"林文秀\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950031000025\",\"itemName\": \"一次性使用静脉留置针22GII型A(直型连接座式安全型)Y型2225601\",\"Price\": 4.82,\"quantity\": 1,\"Cost\": 4.82,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 04:56:21\"},{\"seqNo\": \"97426258\",\"visitNo\": \"1735717004\",\"sickName\": \"林文秀\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950030000005\",\"itemName\": \"一次性注射器2ml(/支)\",\"Price\": 0.21,\"quantity\": 1,\"Cost\": 0.21,\"materialCode\": \"77375\",\"materialName\": \"一次性注射器2ml\",\"OperTime\": \"2024-02-21 04:56:24\"},{\"seqNo\": \"97426284\",\"visitNo\": \"1801137003\",\"sickName\": \"杨立群\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950030000005\",\"itemName\": \"一次性注射器2ml(/支)\",\"Price\": 0.21,\"quantity\": 1,\"Cost\": 0.21,\"materialCode\": \"77375\",\"materialName\": \"一次性注射器2ml\",\"OperTime\": \"2024-02-21 05:03:40\"},{\"seqNo\": \"97426357\",\"visitNo\": \"1940699001\",\"sickName\": \"严明祥\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950031000025\",\"itemName\": \"一次性使用静脉留置针22GII型A(直型连接座式安全型)Y型2225601\",\"Price\": 4.82,\"quantity\": 1,\"Cost\": 4.82,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 05:28:40\"},{\"seqNo\": \"97426358\",\"visitNo\": \"1940699001\",\"sickName\": \"严明祥\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950030000006\",\"itemName\": \"一次性无菌注射器20ml(/支)\",\"Price\": 0.48,\"quantity\": 2,\"Cost\": 0.96,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 05:28:40\"},{\"seqNo\": \"97426359\",\"visitNo\": \"1940699001\",\"sickName\": \"严明祥\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950029000010\",\"itemName\": \"一次性使用输液器BI-IT带针0.7# /支)\",\"Price\": 0.81,\"quantity\": 1,\"Cost\": 0.81,\"materialCode\": \"02585\",\"materialName\": \"一次性使用输液器 带针\",\"OperTime\": \"2024-02-21 05:28:40\"},{\"seqNo\": \"97426433\",\"visitNo\": \"1940702001\",\"sickName\": \"伍邦柏\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950030000005\",\"itemName\": \"一次性注射器2ml(/支)\",\"Price\": 0.21,\"quantity\": 1,\"Cost\": 0.21,\"materialCode\": \"77375\",\"materialName\": \"一次性注射器2ml\",\"OperTime\": \"2024-02-21 06:51:25\"},{\"seqNo\": \"97426478\",\"visitNo\": \"1927463002\",\"sickName\": \"林海龙\",\"applyDept\": \"187\",\"deptName\": \"门诊呼吸与危重症医学科\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:42:23\"},{\"seqNo\": \"97426486\",\"visitNo\": \"1927463002\",\"sickName\": \"林海龙\",\"applyDept\": \"187\",\"deptName\": \"门诊呼吸与危重症医学科\",\"itemCode\": \"950046000005\",\"itemName\": \"一次性使用人体静脉血样采集容器(生化管 5ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68973\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:42:24\"},{\"seqNo\": \"97426518\",\"visitNo\": \"1940705001\",\"sickName\": \"姚连菊\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000004\",\"itemName\": \"一次性使用人体静脉血样采集容器(血常规管 2ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:48:31\"},{\"seqNo\": \"97426521\",\"visitNo\": \"1940705001\",\"sickName\": \"姚连菊\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:48:31\"},{\"seqNo\": \"97426523\",\"visitNo\": \"1940703001\",\"sickName\": \"薛连辉\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:49:10\"},{\"seqNo\": \"97426529\",\"visitNo\": \"1940703001\",\"sickName\": \"薛连辉\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000007\",\"itemName\": \"一次性使用人体静脉血样采集容器(肝素锂 绿色 5ml/支)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68972\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:49:11\"},{\"seqNo\": \"97426535\",\"visitNo\": \"1940703001\",\"sickName\": \"薛连辉\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000005\",\"itemName\": \"一次性使用人体静脉血样采集容器(生化管 5ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68973\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:49:13\"},{\"seqNo\": \"97426537\",\"visitNo\": \"1940703001\",\"sickName\": \"薛连辉\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000004\",\"itemName\": \"一次性使用人体静脉血样采集容器(血常规管 2ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:49:15\"},{\"seqNo\": \"97426557\",\"visitNo\": \"1629086067\",\"sickName\": \"杨培恭\",\"applyDept\": \"113\",\"deptName\": \"内一门诊\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:50:11\"},{\"seqNo\": \"97426559\",\"visitNo\": \"1629086067\",\"sickName\": \"杨培恭\",\"applyDept\": \"113\",\"deptName\": \"内一门诊\",\"itemCode\": \"950046000004\",\"itemName\": \"一次性使用人体静脉血样采集容器(血常规管 2ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:50:12\"},{\"seqNo\": \"97426561\",\"visitNo\": \"1629086067\",\"sickName\": \"杨培恭\",\"applyDept\": \"113\",\"deptName\": \"内一门诊\",\"itemCode\": \"950046000005\",\"itemName\": \"一次性使用人体静脉血样采集容器(生化管 5ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68973\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:50:14\"},{\"seqNo\": \"97426567\",\"visitNo\": \"1629086067\",\"sickName\": \"杨培恭\",\"applyDept\": \"113\",\"deptName\": \"内一门诊\",\"itemCode\": \"950046000007\",\"itemName\": \"一次性使用人体静脉血样采集容器(肝素锂 绿色 5ml/支)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68972\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:50:15\"},{\"seqNo\": \"97426570\",\"visitNo\": \"1407999064\",\"sickName\": \"蔡美花\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000004\",\"itemName\": \"一次性使用人体静脉血样采集容器(血常规管 2ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:50:24\"},{\"seqNo\": \"97426572\",\"visitNo\": \"1407999064\",\"sickName\": \"蔡美花\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000005\",\"itemName\": \"一次性使用人体静脉血样采集容器(生化管 5ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68973\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:50:24\"},{\"seqNo\": \"97426574\",\"visitNo\": \"1407999064\",\"sickName\": \"蔡美花\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:50:24\"},{\"seqNo\": \"97426576\",\"visitNo\": \"1547551020\",\"sickName\": \"黄靖宇\",\"applyDept\": \"56\",\"deptName\": \"门诊内科\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:50:44\"},{\"seqNo\": \"97426581\",\"visitNo\": \"1547551020\",\"sickName\": \"黄靖宇\",\"applyDept\": \"56\",\"deptName\": \"门诊内科\",\"itemCode\": \"950046000007\",\"itemName\": \"一次性使用人体静脉血样采集容器(肝素锂 绿色 5ml/支)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68972\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:50:46\"},{\"seqNo\": \"97426583\",\"visitNo\": \"1547551020\",\"sickName\": \"黄靖宇\",\"applyDept\": \"56\",\"deptName\": \"门诊内科\",\"itemCode\": \"950046000004\",\"itemName\": \"一次性使用人体静脉血样采集容器(血常规管 2ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:50:47\"},{\"seqNo\": \"97426591\",\"visitNo\": \"1547551020\",\"sickName\": \"黄靖宇\",\"applyDept\": \"56\",\"deptName\": \"门诊内科\",\"itemCode\": \"950046000005\",\"itemName\": \"一次性使用人体静脉血样采集容器(生化管 5ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68973\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:50:48\"},{\"seqNo\": \"97426642\",\"visitNo\": \"1613276019\",\"sickName\": \"黄英连\",\"applyDept\": \"56\",\"deptName\": \"门诊内科\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:56:13\"},{\"seqNo\": \"97426649\",\"visitNo\": \"1613276019\",\"sickName\": \"黄英连\",\"applyDept\": \"56\",\"deptName\": \"门诊内科\",\"itemCode\": \"950046000005\",\"itemName\": \"一次性使用人体静脉血样采集容器(生化管 5ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68973\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:56:16\"},{\"seqNo\": \"97426654\",\"visitNo\": \"1613276019\",\"sickName\": \"黄英连\",\"applyDept\": \"56\",\"deptName\": \"门诊内科\",\"itemCode\": \"950046000004\",\"itemName\": \"一次性使用人体静脉血样采集容器(血常规管 2ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:56:18\"},{\"seqNo\": \"97426704\",\"visitNo\": \"1408701039\",\"sickName\": \"胡玮坤\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000005\",\"itemName\": \"一次性使用人体静脉血样采集容器(生化管 5ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68973\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:56:40\"},{\"seqNo\": \"97426705\",\"visitNo\": \"1408701039\",\"sickName\": \"胡玮坤\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000004\",\"itemName\": \"一次性使用人体静脉血样采集容器(血常规管 2ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:56:40\"},{\"seqNo\": \"97426713\",\"visitNo\": \"1408701039\",\"sickName\": \"胡玮坤\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:56:40\"},{\"seqNo\": \"97426714\",\"visitNo\": \"1408701039\",\"sickName\": \"胡玮坤\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000007\",\"itemName\": \"一次性使用人体静脉血样采集容器(肝素锂 绿色 5ml/支)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68972\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:56:40\"},{\"seqNo\": \"97426719\",\"visitNo\": \"1900545011\",\"sickName\": \"李光婷\",\"applyDept\": \"113\",\"deptName\": \"内一门诊\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 07:56:42\"},{\"seqNo\": \"97426724\",\"visitNo\": \"1900545011\",\"sickName\": \"李光婷\",\"applyDept\": \"113\",\"deptName\": \"内一门诊\",\"itemCode\": \"950046000007\",\"itemName\": \"一次性使用人体静脉血样采集容器(肝素锂 绿色 5ml/支)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68972\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 07:56:42\"},{\"seqNo\": \"97426934\",\"visitNo\": \"1719779006\",\"sickName\": \"吴玉秀\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 08:00:20\"},{\"seqNo\": \"97427072\",\"visitNo\": \"1719779006\",\"sickName\": \"吴玉秀\",\"applyDept\": \"65\",\"deptName\": \"急诊科\",\"itemCode\": \"950046000007\",\"itemName\": \"一次性使用人体静脉血样采集容器(肝素锂 绿色 5ml/支)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68972\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 08:00:22\"},{\"seqNo\": \"97427377\",\"visitNo\": \"1537583008\",\"sickName\": \"刘阿花\",\"applyDept\": \"113\",\"deptName\": \"内一门诊\",\"itemCode\": \"950027000004\",\"itemName\": \"一次性使用静脉采血针\",\"Price\": 0.19,\"quantity\": 1,\"Cost\": 0.19,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 08:02:37\"},{\"seqNo\": \"97427380\",\"visitNo\": \"1537583008\",\"sickName\": \"刘阿花\",\"applyDept\": \"113\",\"deptName\": \"内一门诊\",\"itemCode\": \"950046000005\",\"itemName\": \"一次性使用人体静脉血样采集容器(生化管 5ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68973\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 08:02:39\"},{\"seqNo\": \"97427383\",\"visitNo\": \"1537583008\",\"sickName\": \"刘阿花\",\"applyDept\": \"113\",\"deptName\": \"内一门诊\",\"itemCode\": \"950046000004\",\"itemName\": \"一次性使用人体静脉血样采集容器(血常规管 2ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"\",\"materialName\": \"\",\"OperTime\": \"2024-02-21 08:02:41\"},{\"seqNo\": \"97427390\",\"visitNo\": \"1398769053\",\"sickName\": \"徐丽松\",\"applyDept\": \"56\",\"deptName\": \"门诊内科\",\"itemCode\": \"950046000005\",\"itemName\": \"一次性使用人体静脉血样采集容器(生化管 5ml)\",\"Price\": 0.59,\"quantity\": 1,\"Cost\": 0.59,\"materialCode\": \"68973\",\"materialName\": \"一次性使用人体静脉血样采集容器\",\"OperTime\": \"2024-02-21 08:02:48\"}],\"total\": 12296}}"; - BaseResponse> baseResponse = - JSONObject.parseObject(response, new TypeReference>>() { - }); - if (baseResponse.getCode() == 20000) { - List ptxhInvResponses = baseResponse.getData().getList(); - List thrInvResultResponses = new ArrayList<>(); - Set seenNames = new HashSet<>(); - List itemData = new ArrayList<>(); - if (CollUtil.isNotEmpty(ptxhInvResponses)) { - for (InvProjectResultEntity ptxhInvResponse : ptxhInvResponses) { - ThrInvResultResponse thrInvResultResponse = new ThrInvResultResponse(); - thrInvResultResponse.setThrCode(ptxhInvResponse.getMaterialCode()); - thrInvResultResponse.setCpmctymc(ptxhInvResponse.getItemName()); - thrInvResultResponse.setSickerCode(ptxhInvResponse.getVisitNo()); - thrInvResultResponse.setSickerName(ptxhInvResponse.getSickName()); - thrInvResultResponse.setPrice(BigDecimal.valueOf(ptxhInvResponse.getPrice())); - thrInvResultResponse.setAmount(BigDecimal.valueOf(ptxhInvResponse.getCost())); - thrInvResultResponse.setDeptName(ptxhInvResponse.getDeptName()); - thrInvResultResponse.setDeptCode("1002"); - thrInvResultResponse.setInvName(ptxhInvResponse.getDeptName()); - thrInvResultResponse.setInvCode("1000003"); - thrInvResultResponse.setThrCode(ptxhInvResponse.getItemCode()); - thrInvResultResponse.setMainAction(ConstantType.TYPE_OUT); - thrInvResultResponse.setType("1"); - thrInvResultResponse.setOutCount(ptxhInvResponse.getQuantity() + ""); - thrInvResultResponse.setReCount(ptxhInvResponse.getQuantity() + ""); - thrInvResultResponses.add(thrInvResultResponse); - if (seenNames.add(ptxhInvResponse.getItemCode())) { - itemData.add(ptxhInvResponse); - } - } - } - for (InvProjectResultEntity invProjectResultEntity : itemData) { - if (!basicSkProjectMapper.exists(new QueryWrapper().eq("code", invProjectResultEntity.getItemCode()))) { - BasicSkProjectEntity basicSkProjectEntity = new BasicSkProjectEntity(); - basicSkProjectEntity.setCode(invProjectResultEntity.getItemCode()); - basicSkProjectEntity.setName(invProjectResultEntity.getItemName()); - basicSkProjectEntity.setType(2); - basicSkProjectEntity.setCreateTime(new Date()); - basicSkProjectEntity.setUpdateTime(new Date()); - basicSkProjectEntity.setRemark("出入库明细自动生成"); - basicSkProjectEntity.setId(IdUtil.getSnowflakeNextId()); - basicSkProjectMapper.insert(basicSkProjectEntity); - List thrProductsEntitys = thrProductsDao.selectList(new QueryWrapper().eq("prcitmcode", invProjectResultEntity.getItemCode())); - if (CollUtil.isNotEmpty(thrProductsEntitys)) { - for (ThrProductsEntity thrProductsEntity : thrProductsEntitys) { - CompanyProductRelevanceRequest companyProductRelevanceRequest = new CompanyProductRelevanceRequest(); - companyProductRelevanceRequest.setThirdId(thrProductsEntity.getCode()); - List udiRlSupResponses = udiRlSupDao.filterUdiGp(companyProductRelevanceRequest); - if (CollUtil.isNotEmpty(udiRlSupResponses)) { - UdiRlSupResponse udiRlSupResponse = udiRlSupResponses.get(0); - BasicSkProjectDetailEntity basicSkProjectDetailEntity = new BasicSkProjectDetailEntity(); - basicSkProjectDetailEntity.setId(IdUtil.getSnowflakeNextId()); - basicSkProjectDetailEntity.setRelId(udiRlSupResponse.getRlId()); - basicSkProjectDetailEntity.setSupId(udiRlSupResponse.getCustomerId()); - basicSkProjectDetailEntity.setPId(basicSkProjectEntity.getId()); - basicSkProjectDetailEntity.setThrCode(thrProductsEntity.getCode()); - basicSkProjectDetailEntity.setThrName(thrProductsEntity.getName()); - basicSkProjectDetailEntity.setCreateTime(DateUtil.formatDateTime(new Date())); - basicSkProjectDetailEntity.setCreateUser("1"); - basicSkProjectDetailEntity.setUpdateTime(DateUtil.formatDateTime(new Date())); - basicSkProjectDetailEntity.setUpdateUser("1"); - basicSkProjectDetailEntity.setRemark("出入库明细自动生成"); - basicSkProjectDetailEntity.setCount(1); - basicDestinyRelMapper.insert(basicSkProjectDetailEntity); - } - } - } - - } - } - - PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(thrInvResultResponses.size() + 0l); - pageSimpleResponse.setList(thrInvResultResponses); - return ResultVOUtils.success(pageSimpleResponse); - } - return baseResponse; - } - - @Override - public BaseResponse getInvProducts(UdiwmsInvProductsRequest udiwmsInvProductsRequest) { - return null; - } - - @Override - public BaseResponse getWarehouse(UdiwmsWarehouseRequest udiwmsWarehouseRequest) { - return null; - } - - @Override - public BaseResponse testConnect() { - UdiwmsUnitRequest udiwmsUnitRequest = new UdiwmsUnitRequest(); - udiwmsUnitRequest.setPage(1); - udiwmsUnitRequest.setLimit(1); - BaseResponse baseResponse = getUnit(udiwmsUnitRequest); - if (baseResponse.getCode() == 20000) { - return ResultVOUtils.success("连接成功!"); - } - return ResultVOUtils.error(500, "连接失败!"); - } - - @Override - public BaseResponse queryUdiInvProducts(UdiwmsQueryUdiInvProductsRequest queryUdiInvProductsRequest) { - return null; - } - - @Override - public BaseResponse submitProducts(UdiwmsAddProductsRequest udiwmsAddProductsRequest) { - return null; - } - - @Override - public BaseResponse submitUnit(UdiwmsAddUnitRequest udiwmsAddUnitRequest) { - - - CtqyyRequest ctqyyRequest = new CtqyyRequest(); - ctqyyRequest.setMsgHeader(getMsgHeader("addSupplierDict")); - ctqyyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsAddUnitRequest)); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_PRODUCT_SUBMIT_URL), ctqyyRequest); - response = parserResult(response); - try { - log.error("提交往来单位/生产厂家:" + ctqyyRequest.getMsgBody()); - CtBaseResponse baseResponse = JSONObject.parseObject(response, CtBaseResponse.class); - if (baseResponse.getCode() != 20000) { - String errMsg = "提交往来单位/生产厂家,异常:{}" + response; - log.error(errMsg); - return ResultVOUtils.error(500, "提交往来单位/生产厂家失败!"); - } else { - BasicCorpEntity basicCorpEntity = new BasicCorpEntity(); - basicCorpEntity.setErpId(CustomUtil.getUnitId()); - basicCorpEntity.setName(udiwmsAddUnitRequest.getSupplierName()); - basicCorpEntity.setCorpType(2); - basicCorpEntity.setThirdId(baseResponse.getSupplierCode()); - basicCorpDao.insert(basicCorpEntity); - log.error("提交往来单位/生产厂家,成功:{}", response); - return ResultVOUtils.success(baseResponse.getMaterialNo()); - } - } catch (Exception e) { - String errMsg = "提交往来单位/生产厂家,异常:{}" + response; - log.error(errMsg); - log.error("异常信息:{}", e); - return ResultVOUtils.error(500, errMsg); - - } - } - - @Override - public BaseResponse postProducts(PostThrProductsRequest postThrProductsRequest) { - return null; - } - - @Override - public BaseResponse postCorps(PostThrCorpRequest postThrCorpRequest) { - return null; - } - - @Override - public BaseResponse postOrderDetail(PostFileThrOrderRequest postFileThrOrderRequest) { - return null; - } - - @Override - public BaseResponse postInvProducts(PostThrInvProductsRequest postThrInvProductsRequest) { - return null; - } - - - /** - * 封装单据详情参数 - * - * @param ioCodeEntities 单据码明细 - * @param orderDetailRequests 单据详情参数 - * @param detailBizEntities 单据业务详情 - */ - private String setOrderDetailList(List ioCodeEntities, List orderDetailRequests, List detailBizEntities) { - String errMsg = ""; - for (IoOrderDetailBizEntity detailBizEntity : detailBizEntities) { - - IoOrderDetailCodeEntity orderDetailCodeEntity = orderDetailCodeDao - .selectOne(new QueryWrapper() - .eq("orderIdFk", detailBizEntity.getOrderIdFk()) - .eq("bindRlFk", detailBizEntity.getBindRlFk()) - .eq(StrUtil.isNotEmpty(detailBizEntity.getBatchNo()), "batchNo", detailBizEntity.getBatchNo()) - .isNull(StrUtil.isEmpty(detailBizEntity.getBatchNo()), "batchNo").last("LIMIT 1")); - if (orderDetailCodeEntity != null && IntUtil.value(orderDetailCodeEntity.getReCount()) > 0) { - detailBizEntity.setCount(orderDetailCodeEntity.getReCount()); - UdiwmsOrderDetailRequest item = buildProductInfo(detailBizEntity); - if (item != null) { - //封装条码信息 - submitOrderUtil.setCodeList(ioCodeEntities, detailBizEntity, item); - orderDetailRequests.add(item); - } else { - errMsg = detailBizEntity.getCoName() + "," + "第三方产品编码未关联"; - } - } - } - return errMsg; - } - - - public UdiwmsOrderDetailRequest buildProductInfo(IoOrderDetailBizEntity detailBizEntity) { - //查询产品信息 - BasicUdirelEntity basicUdirel = basicUdirelDao.selectById(detailBizEntity.getBindRlFk()); - BasicProductsEntity basicProducts = basicProductsDao.selectOne(new LambdaQueryWrapper().eq(BasicProductsEntity::getUuid, basicUdirel.getUuid()).last("limit 1")); - - UdiwmsOrderDetailRequest item = new UdiwmsOrderDetailRequest(); - BeanUtil.copyProperties(detailBizEntity, item); - - item.setProductDate(DateUtil.formatExpireTime(StrUtil.isBlank(detailBizEntity.getProductDate()) ? null : "20" + detailBizEntity.getProductDate())); - item.setExpireDate(DateUtil.formatExpireTime(StrUtil.isBlank(detailBizEntity.getExpireDate()) ? null : "20" + detailBizEntity.getExpireDate())); - - String thirdProductId = (String) ReflectUtil.getFieldValue(basicUdirel, thirdSysConfig.getThirdId()); - item.setProductId(thirdProductId); //产品ID - //查询第三方产品名称 - ThrProductsEntity thrProductsEntity = thrProductsDao.selectOne(new LambdaQueryWrapper() - .eq(ThrProductsEntity::getCode, thirdProductId).last("limit 1")); - if (thrProductsEntity == null) { - log.error("第三方产品编码未关联"); - return null; - } - item.setProductName(thrProductsEntity.getName()); //产品名称 - item.setBindRlFk(detailBizEntity.getBindRlFk()); - item.setStandard(detailBizEntity.getSpec()); //规格型号 - item.setBillNo(detailBizEntity.getOrderIdFk()); //单据号 - item.setRegisterNo(detailBizEntity.getCertCode()); //注册/备案证号 - item.setManufactory(basicProducts.getManufactory()); //生产厂家 - item.setMeasname(thrProductsEntity.getMeasname()); //计量单位 - item.setAllowNoBatch(IntUtil.value(basicProducts.getAllowNoBatch())); //是否允许无批次号 - if (StrUtil.isNotEmpty(item.getManufactory())) { - ThrCorpEntity thrCorpEntity = thrCorpService.getThrCorpByName(item.getManufactory()); - if (thrCorpEntity != null) - item.setManufactoryCode(thrCorpEntity.getUnitId()); - } - item.setSupCode(thrProductsEntity.getSupCode()); - item.setCplb(thrProductsEntity.getFlbm()); - item.setHslb(thrProductsEntity.getCplb()); - item.setCount(detailBizEntity.getCount()); - return item; - } - - - /** - * 处理提交单据,记录日志,解析结果逻辑 - * - * @param orderEntity - * @param zaZyRequest - * @return - */ - private BaseResponse submitOrder(IoOrderEntity orderEntity, ZzzyyRequest zaZyRequest) { - //记录日志 - 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); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_ORDER_SUBMIT_URL), zaZyRequest); - response = parserResult(response); - if (StrUtil.isNotBlank(response)) { - try { - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - if (baseResponse.getCode() == 20000) { - String thirdBillNo = String.valueOf(baseResponse.getData()); - orderEntity.setThirdBillNo(thirdBillNo); - orderEntity.setExportStatus(1); //提交成功 - uploadLog.setStatus(2); - uploadLog.setThrBillNo(thirdBillNo); - uploadLog.setResult("提交成功"); - orderDao.updateById(orderEntity); - orderUploadLogDao.insert(uploadLog); - return ResultVOUtils.success("提交成功"); - } - uploadLog.setStatus(3); - uploadLog.setResult("提交失败,错误信息:" + baseResponse.getMessage()); - orderEntity.setExportStatus(2); //上传失败 - orderDao.updateById(orderEntity); - orderUploadLogDao.insert(uploadLog); - return baseResponse; - } catch (Exception e) { - log.error("解析提交到智业单据返回结果异常,结果信息:{}", response); - log.error("异常信息:{}", e); - uploadLog.setStatus(3); - uploadLog.setResult("提交失败,错误信息:" + response); - orderEntity.setExportStatus(2); //上传失败 - orderDao.updateById(orderEntity); - orderUploadLogDao.insert(uploadLog); - return ResultVOUtils.error(500, "提交失败"); - } - } else { - uploadLog.setStatus(3); - uploadLog.setResult("提交失败,调用接口返回为空"); - orderEntity.setExportStatus(2); //上传失败 - orderDao.updateById(orderEntity); - orderUploadLogDao.insert(uploadLog); - return ResultVOUtils.error(500, "提交失败"); - } - } - - - @Override - public BaseResponse submitPreInOrders(UdiwmsPreInOrderRequest udiwmsPreInOrderRequest) { - ZzzyyRequest zaZyRequest = new ZzzyyRequest(); - zaZyRequest.setMsgHeader(getMsgHeader("saveMaterialHight")); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsPreInOrderRequest)); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_PRE_IN_ORDER_SUBMIT_URL), zaZyRequest); - response = parserResult(response); - try { - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } catch (Exception e) { - log.error("解析长泰区医院智业接口提交单据返回数据异常,返回结果:{}", response); - log.error("异常信息:{}", e); - return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")"); - } - } - - - /** - * 转换提交单据参数 - * - * @param udiwmsOrderRequest - * @param orderEntity - * @return - */ - public UdiwmsPreInOrderRequest submitPreInOrderToThirdSys(ZaxzyyOrderRequest udiwmsOrderRequest, IoOrderEntity orderEntity) { - UdiwmsPreInOrderRequest udiwmsPreInOrderRequest = new UdiwmsPreInOrderRequest(); - if (udiwmsOrderRequest != null) { - BeanUtils.copyProperties(udiwmsOrderRequest, udiwmsPreInOrderRequest); - udiwmsPreInOrderRequest.setLocInvCode(udiwmsOrderRequest.getLocStorageCode()); - udiwmsPreInOrderRequest.setLocInvName(udiwmsOrderRequest.getLocStorageName()); - String deptCode = "70"; - if (StrUtil.isNotEmpty(orderEntity.getOriginUllageSupNo())) { - IoOrderEntity temp = orderDao.selectOne(new QueryWrapper().eq("billNo", orderEntity.getOriginUllageSupNo()).last("limit 1")); - if (temp != null && StrUtil.isNotEmpty(temp.getFromInvCode())) { - AuthWarehouseEntity authWarehouseEntity = - authWarehouseDao.selectOne(new QueryWrapper().eq("code", temp.getFromInvCode()).last("limit 1")); - deptCode = authWarehouseEntity.getThirdId(); - } - } - udiwmsPreInOrderRequest.setDeptCode(deptCode); - if (orderEntity.getReviewUser() != null) { - AuthUserEntity authUser = authUserDao.selectById(orderEntity.getReviewUser()); - udiwmsPreInOrderRequest.setActor(authUser.getEmployeeName()); - } else if (orderEntity.getCreateUser() != null) { - AuthUserEntity authUser = authUserDao.selectById(orderEntity.getCreateUser()); - udiwmsPreInOrderRequest.setActor(authUser.getEmployeeName()); - } - List itemDTOS = new ArrayList<>(); - if (CollUtil.isNotEmpty(udiwmsOrderRequest.getItem())) { - for (UdiwmsOrderDetailRequest udiwmsOrderDetail : udiwmsOrderRequest.getItem()) { - if (CollUtil.isNotEmpty(udiwmsOrderDetail.getCodeList())) { - for (UdiwmsOrderDetailRequest.CodeDetailEntity codeDetaiEntity : udiwmsOrderDetail.getCodeList()) { - UdiwmsPreInOrderRequest.ItemDTO itemDTO = new UdiwmsPreInOrderRequest.ItemDTO(); - BeanUtils.copyProperties(udiwmsOrderDetail, itemDTO); - if (StrUtil.isNotEmpty(itemDTO.getManufactory())) { - ThrCorpEntity thrCorpEntity = thrCorpService.getThrCorpByName(itemDTO.getManufactory()); - if (thrCorpEntity != null) - itemDTO.setManufactoryCode(thrCorpEntity.getUnitId()); - } - String code = codeDetaiEntity.getCode(); - if (code.contains("\u001D")) { -// code = code.replace("\u001D", "zysoft"); 智业无法识别GS1符号 - code = code.replace("\u001D", ""); - } - if (!code.startsWith("MA")) { - code = code.replace(codeDetaiEntity.getNameCode(), ""); - code = code.substring(1, code.length() - 1); - } - itemDTO.setCode(code); - itemDTO.setNameCode(code.substring(0, 16)); - - if (IntUtil.value(codeDetaiEntity.getCount()) > 1) { - for (int i = 0; i < codeDetaiEntity.getCount(); i++) { - itemDTO.setCount(1); - itemDTOS.add(itemDTO); - } - } else { - itemDTO.setCount(codeDetaiEntity.getCount()); - itemDTOS.add(itemDTO); - } - - - } - } - } - } - udiwmsPreInOrderRequest.setItems(itemDTOS); - } - return udiwmsPreInOrderRequest; - } - - - /** - * ------------------------------------------现场管理医保相关接口方法-------------------------------------------------------------- - */ - /** - * 处方拉取视图 - * - * @param udiwmsBasicSkPrescribeRequest - * @return - */ - @Override - public BaseResponse getPrescribes(UdiwmsBasicSkPrescribeRequest udiwmsBasicSkPrescribeRequest) { - udiwmsBasicSkPrescribeRequest.setDatabaseProductName(getDataSourceType()); - if (IntUtil.value(udiwmsBasicSkPrescribeRequest.getInOutType()) == 0) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - - String startTime = udiwmsBasicSkPrescribeRequest.getStartTime(); - String endTime = udiwmsBasicSkPrescribeRequest.getEndTime(); - wrapper.ge(StrUtil.isNotEmpty(startTime), VInsurNationGoodsPhysic::getSEL_RETN_TIME, startTime); - wrapper.le(StrUtil.isNotEmpty(endTime), VInsurNationGoodsPhysic::getSEL_RETN_TIME, endTime); - - String code = udiwmsBasicSkPrescribeRequest.getCode(); - String fromCorpName = udiwmsBasicSkPrescribeRequest.getFromCorpName(); - String key = udiwmsBasicSkPrescribeRequest.getKey(); - wrapper.and(StrUtil.isNotEmpty(code), t -> t.eq(VInsurNationGoodsPhysic::getSTOOUT_NO, code).or().eq(VInsurNationGoodsPhysic::getRXNO, code)); - wrapper.and(StrUtil.isNotEmpty(key), t -> t.like(VInsurNationGoodsPhysic::getSTOOUT_NO, key) - .or().like(VInsurNationGoodsPhysic::getRXNO, key) - .or().like(VInsurNationGoodsPhysic::getPSN_NAME, key) - .or().like(VInsurNationGoodsPhysic::getPSN_NO, key) - ); - wrapper.and(StrUtil.isNotEmpty(fromCorpName), t -> t.eq(VInsurNationGoodsPhysic::getPSN_NAME, fromCorpName)); - if (udiwmsBasicSkPrescribeRequest.getBusType().equals("YPCF003")) { - udiwmsBasicSkPrescribeRequest.setIN_HOSP("1"); - } else { - udiwmsBasicSkPrescribeRequest.setIN_HOSP("2"); - } - udiwmsBasicSkPrescribeRequest.setDatabaseProductName(getDataSourceType()); - - // 拉取处方时,改成拉取v_ypzs_pres_info - IPage page = vYpzsPresInfoMapper - .selectGroupedWithPagination(new Page(udiwmsBasicSkPrescribeRequest.getPage(), udiwmsBasicSkPrescribeRequest.getLimit()), - udiwmsBasicSkPrescribeRequest); - - if (page.getTotal() == 0) { - PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(page.getTotal()); - pageSimpleResponse.setList(null); - return ResultVOUtils.success(pageSimpleResponse); - } - return this.covertSellOrder(udiwmsBasicSkPrescribeRequest, page); - } else { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - - String startTime = udiwmsBasicSkPrescribeRequest.getStartTime(); - String endTime = udiwmsBasicSkPrescribeRequest.getEndTime(); - wrapper.ge(StrUtil.isNotEmpty(startTime), VInsurNationGoodsReturn::getSEL_RETN_TIME, startTime); - wrapper.le(StrUtil.isNotEmpty(endTime), VInsurNationGoodsReturn::getSEL_RETN_TIME, endTime); - - - String code = udiwmsBasicSkPrescribeRequest.getCode(); - String fromCorpName = udiwmsBasicSkPrescribeRequest.getFromCorpName(); - String key = udiwmsBasicSkPrescribeRequest.getKey(); - wrapper.and(StrUtil.isNotEmpty(key), t -> t.like(VInsurNationGoodsReturn::getAPPLY_NO, key) - .or().like(VInsurNationGoodsReturn::getPSN_NAME, key) - .or().like(VInsurNationGoodsReturn::getPSN_NO, key) - ); - wrapper.and(StrUtil.isNotEmpty(code), t -> t.eq(VInsurNationGoodsReturn::getAPPLY_NO, code)); - wrapper.and(StrUtil.isNotEmpty(fromCorpName), t -> t.eq(VInsurNationGoodsReturn::getPSN_NAME, fromCorpName)); - - udiwmsBasicSkPrescribeRequest.setDatabaseProductName(getDataSourceType()); - - - //拉取处方退货时,改成拉取v_ypzs_pres_info_return - IPage page = vYpzsPresInfoReturnMapper.selectGroupedWithPagination(new Page(udiwmsBasicSkPrescribeRequest.getPage(), udiwmsBasicSkPrescribeRequest.getLimit()), - udiwmsBasicSkPrescribeRequest); - if (page.getTotal() == 0) { - PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(page.getTotal()); - pageSimpleResponse.setList(null); - return ResultVOUtils.success(pageSimpleResponse); - } - return this.covertReturnOrder(udiwmsBasicSkPrescribeRequest, page); - } - - } - - - /** - * 采购计划拉取视图 - * - * @param udiwmsThrOrderRequest - * @return - */ - @Override - public BaseResponse getThrOrders(UdiwmsThrOrderRequest udiwmsThrOrderRequest) { - PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - if (BusTypeConstant.CGJH001.getBusType().equals(udiwmsThrOrderRequest.getBusType())) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - -// String startTime = udiwmsThrOrderRequest.getStartTime(); -// String endTime = udiwmsThrOrderRequest.getEndTime(); -// wrapper.ge(StrUtil.isNotEmpty(startTime),VYpzsPlanInfo::getKEEP_BOOK_TIME,startTime+" 00:00:00"); -// wrapper.le(StrUtil.isNotEmpty(endTime),VYpzsPlanInfo::getKEEP_BOOK_TIME,endTime+" 23:59:59"); - - wrapper.eq(StrUtil.isNotBlank(udiwmsThrOrderRequest.getBillNo()), VYpzsPlanInfo::getCGDBH, udiwmsThrOrderRequest.getBillNo()); - //关键字模糊处理 - String keywords = udiwmsThrOrderRequest.getKeyWords(); - wrapper.and(StrUtil.isNotEmpty(keywords), t -> t.like(VYpzsPlanInfo::getCGDBH, keywords)//单据号 - ); - wrapper.like(StrUtil.isNotEmpty(udiwmsThrOrderRequest.getFromCorpName()), VYpzsPlanInfo::getSCQYMC, udiwmsThrOrderRequest.getFromCorpName()); - udiwmsThrOrderRequest.setDatabaseProductName(getDataSourceType()); - Page page = vYpzsPlanInfoMapper.selectGroupedWithPagination( - new Page(udiwmsThrOrderRequest.getPage(), udiwmsThrOrderRequest.getLimit()), udiwmsThrOrderRequest); - - List planInfos = page.getRecords(); - List ioCollectOrders = new ArrayList<>(); - if (CollUtil.isNotEmpty(planInfos)) { - - List collect = planInfos.stream().map(VYpzsPlanInfo::getCGDBH).collect(Collectors.toList()); - LambdaQueryWrapper wrapper1 = new LambdaQueryWrapper<>(); - wrapper1.in(VYpzsPlanInfo::getCGDBH, collect); - List vYpzsPlanInfos = vYpzsPlanInfoMapper.selectList(wrapper1); - - Map> groupedByBz = vYpzsPlanInfos.stream() - .collect(Collectors.groupingBy(VYpzsPlanInfo::getCGDBH)); - groupedByBz.forEach((key, value) -> { - VYpzsPlanInfo planInfo = value.get(0); - StringBuilder errorMsg = new StringBuilder(); - IoCollectOrder ioCollectOrder = new IoCollectOrder(); - ioCollectOrder.setBillNo(planInfo.getCGDBH()); -// ioCollectOrder.setBilldate(planInfo.()); - ioCollectOrder.setFromType("HIS系统"); - ioCollectOrder.setBillTime(new Date()); - ioCollectOrder.setFromCorp(planInfo.getSCQYBM()); - ioCollectOrder.setFromCorpName(planInfo.getSCQYMC()); - ioCollectOrder.setBusType(udiwmsThrOrderRequest.getBusType()); - ioCollectOrder.setWorkPlaceCode(udiwmsThrOrderRequest.getWorkPlaceCode()); - ioCollectOrder.setCreateTime(new Date()); - ioCollectOrder.setUpdateTime(new Date()); - ioCollectOrder.setSplitStatus(0); - ioCollectOrder.setTagStatus(0); - List bizList = new ArrayList<>(); - value.forEach(entity -> { - IoCollectOrderBiz collectOrderBiz = new IoCollectOrderBiz(); - BasicUdirelEntity basicUdirelEntity = basicUdirelDao.selectOne(new LambdaQueryWrapper().eq(BasicUdirelEntity::getMainId, entity.getYPBM())); - if (basicUdirelEntity != null) { - collectOrderBiz.setRelId(basicUdirelEntity.getId()); - } else { - errorMsg.append(entity.getYPMC()).append("字典未对照").append(";"); - } - collectOrderBiz.setThrCode(entity.getYPBM()); - collectOrderBiz.setCpmctymc(entity.getYPMC()); - collectOrderBiz.setBatchNo(entity.getYPBM()); - collectOrderBiz.setGgxh(entity.getGGMC()); - collectOrderBiz.setCount(entity.getGMSL()); - collectOrderBiz.setOrderIdFk(ioCollectOrder.getBillNo()); - collectOrderBiz.setMeasureUnit(entity.getBZDW()); - collectOrderBiz.setTagStatus(1); - collectOrderBiz.setUnTagCount(0); - bizList.add(collectOrderBiz); - }); - ioCollectOrder.setBizList(bizList); - ioCollectOrders.add(ioCollectOrder); - }); - } - pageSimpleResponse.setTotal(page.getTotal()); - pageSimpleResponse.setList(ioCollectOrders); - } else { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - - String startTime = udiwmsThrOrderRequest.getStartTime(); - String endTime = udiwmsThrOrderRequest.getEndTime(); - wrapper.ge(StrUtil.isNotEmpty(startTime), VYpzsIoInfo::getKEEP_BOOK_TIME, startTime); - wrapper.le(StrUtil.isNotEmpty(endTime), VYpzsIoInfo::getKEEP_BOOK_TIME, endTime); - wrapper.and(StrUtil.isNotEmpty(udiwmsThrOrderRequest.getCorpName()), t -> t.like(VYpzsIoInfo::getCONSIGNEE_NAME, udiwmsThrOrderRequest.getCorpName()).or().eq(VYpzsIoInfo::getCONSIGNOR_NAME, udiwmsThrOrderRequest.getCorpName())); - - wrapper.eq(StrUtil.isNotBlank(udiwmsThrOrderRequest.getBillNo()), VYpzsIoInfo::getRECEIPT_NUMBER, udiwmsThrOrderRequest.getBillNo()); - wrapper.eq(StrUtil.isNotBlank(udiwmsThrOrderRequest.getBusType()), VYpzsIoInfo::getIO_SORT, udiwmsThrOrderRequest.getBusType()); - - wrapper.like(StrUtil.isNotEmpty(udiwmsThrOrderRequest.getFromCorpName()), VYpzsIoInfo::getCONSIGNEE_NAME, udiwmsThrOrderRequest.getFromCorpName()); - wrapper.like(StrUtil.isNotEmpty(udiwmsThrOrderRequest.getShipperName()), VYpzsIoInfo::getCONSIGNOR_NAME, udiwmsThrOrderRequest.getShipperName()); - //关键字模糊处理 - String keywords = udiwmsThrOrderRequest.getKeyWords(); - wrapper.and(StrUtil.isNotEmpty(keywords), t -> t.like(VYpzsIoInfo::getPHYSIC_CODE, keywords)//单据号 - .or().like(VYpzsIoInfo::getCONSIGNOR_NAME, keywords)//发货方 - .or().like(VYpzsIoInfo::getCONSIGNEE_NAME, keywords)//收货方 - .or().like(VYpzsIoInfo::getKEEP_BOOK_TIME, keywords)//收货方 - .or().like(VYpzsIoInfo::getIO_SORT, keywords)//收货方 - ); - - udiwmsThrOrderRequest.setDatabaseProductName(getDataSourceType()); - - Page page = vYpzsIoInfoMapper.selectGroupedWithPagination(new Page(udiwmsThrOrderRequest.getPage(), udiwmsThrOrderRequest.getLimit()), udiwmsThrOrderRequest); - - List ioInfos = page.getRecords(); - List ioCollectOrders = new ArrayList<>(); - if (CollUtil.isNotEmpty(ioInfos)) { - List collect = ioInfos.stream().map(VYpzsIoInfo::getRECEIPT_NUMBER).collect(Collectors.toList()); - LambdaQueryWrapper vYpzsIoInfoLambdaQueryWrapper = new LambdaQueryWrapper<>(); - vYpzsIoInfoLambdaQueryWrapper.in(VYpzsIoInfo::getRECEIPT_NUMBER, collect); - List vYpzsIoInfos = vYpzsIoInfoMapper.selectList(vYpzsIoInfoLambdaQueryWrapper); - - Map> groupedByPhysicCode = vYpzsIoInfos.stream() - .collect(Collectors.groupingBy(VYpzsIoInfo::getRECEIPT_NUMBER)); - groupedByPhysicCode.forEach((key, value) -> { - VYpzsIoInfo info = value.get(0); - StringBuilder errorMsg = new StringBuilder(); - IoCollectOrder ioCollectOrder = new IoCollectOrder(); - ioCollectOrder.setBillNo(info.getRECEIPT_NUMBER()); - ioCollectOrder.setFromType("HIS系统"); - ioCollectOrder.setBillTime(DateUtil.parseDate(info.getKEEP_BOOK_TIME())); - ioCollectOrder.setFromCorp(info.getCONSIGNEE()); - ioCollectOrder.setFromCorpName(info.getCONSIGNEE_NAME()); - - ioCollectOrder.setShipper(info.getCONSIGNOR()); - ioCollectOrder.setShipperName(info.getCONSIGNOR_NAME()); - - ioCollectOrder.setBusType(udiwmsThrOrderRequest.getBusType()); - ioCollectOrder.setWorkPlaceCode(udiwmsThrOrderRequest.getWorkPlaceCode()); - ioCollectOrder.setCreateTime(new Date()); - ioCollectOrder.setUpdateTime(new Date()); - ioCollectOrder.setSplitStatus(0); - ioCollectOrder.setTagStatus(0); - List bizList = new ArrayList<>(); - value.forEach(entity -> { - IoCollectOrderBiz collectOrderBiz = new IoCollectOrderBiz(); - BasicUdirelEntity basicUdirelEntity = basicUdirelDao.selectOne(new LambdaQueryWrapper().eq(BasicUdirelEntity::getMainId, entity.getPHYSIC_CODE()).last("limit 1")); - if (basicUdirelEntity != null) { - collectOrderBiz.setRelId(basicUdirelEntity.getId()); - } else { - errorMsg.append(entity.getPHYSIC_NAME()).append("字典未对照").append(";"); - } - collectOrderBiz.setThrCode(entity.getPHYSIC_CODE()); - collectOrderBiz.setCpmctymc(entity.getPHYSIC_NAME()); - collectOrderBiz.setBatchNo(entity.getBATCH_NO()); - collectOrderBiz.setCount(entity.getQUANTITY()); - collectOrderBiz.setYbbm(entity.getCOUNTRY_CODE()); - collectOrderBiz.setOrderIdFk(ioCollectOrder.getBillNo()); - collectOrderBiz.setMeasureUnit(entity.getPACK_UNIT1()); - collectOrderBiz.setGgxh(entity.getPACK_SPEC() + ":" + entity.getPHYSIC_UNIT()); - collectOrderBiz.setTagStatus(1); - collectOrderBiz.setUnTagCount(0); - collectOrderBiz.setRemark1(entity.getRETAIL_PRICE().toString()); - collectOrderBiz.setRemark2(entity.getRETAIL_MONEY().toString()); - collectOrderBiz.setRemark3(entity.getIMPORT_PRICE().toString()); - collectOrderBiz.setRemark4(entity.getIMPORT_MONEY().toString()); - collectOrderBiz.setRemark5(entity.getFIXMEDINS_BCHNO()); - collectOrderBiz.setRemark6(entity.getRX_FLAG()); - collectOrderBiz.setRemark7(entity.getINV_CHG_TYPE()); - bizList.add(collectOrderBiz); - }); - if (StrUtil.isNotBlank(errorMsg)) { - ioCollectOrder.setErrorMsg(errorMsg.toString()); - ioCollectOrder.setTagStatus(4); - } - ioCollectOrder.setBizList(bizList); - ioCollectOrders.add(ioCollectOrder); - }); - } - pageSimpleResponse.setTotal(page.getTotal()); - pageSimpleResponse.setList(ioCollectOrders); - } - return ResultVOUtils.success(pageSimpleResponse); - } - - - /** - * 业务单据上传医保 - * - * @param postCollectOrderRequest - * @return - */ - @Override - public BaseResponse uploadCollectOrder(PostCollectOrderRequest postCollectOrderRequest) { - - - List collectOrderList = postCollectOrderRequest.getCollectOrderList(); - - if (CollUtil.isNotEmpty(collectOrderList)) { - for (IoCollectOrder ioCollectOrder : collectOrderList) { - String busType = ioCollectOrder.getBusType(); - - if (matchBusType(busType, buyType_3501)) { - optionUploadCollectOrder3501(ioCollectOrder); - } else if (matchBusType(busType, buyType_3502)) { - optionUploadCollectOrder3502(ioCollectOrder); - } else if (matchBusType(busType, buyType_3505)) { - optionUploadCollectOrder3505(ioCollectOrder); - } else if (matchBusType(busType, buyType_3506)) { - optionUploadCollectOrder3506(ioCollectOrder); - } else { - return ResultVOUtils.error(500, "业务类型未找到对应上传接口"); - } - } - } - return ResultVOUtils.success(); - } - - @Override - public BaseResponse getPrescribesQx(UdiwmsBasicSkPrescribeRequest udiwmsBasicSkPrescribeRequest) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - - String startTime = udiwmsBasicSkPrescribeRequest.getStartTime(); - String endTime = udiwmsBasicSkPrescribeRequest.getEndTime(); - wrapper.ge(StrUtil.isNotEmpty(startTime), VInsurNationGoodsCl::getSEL_RETN_TIME, startTime); - wrapper.le(StrUtil.isNotEmpty(endTime), VInsurNationGoodsCl::getSEL_RETN_TIME, endTime); - - String code = udiwmsBasicSkPrescribeRequest.getCode(); - String fromCorpName = udiwmsBasicSkPrescribeRequest.getFromCorpName(); - String key = udiwmsBasicSkPrescribeRequest.getKey(); - wrapper.and(StrUtil.isNotEmpty(code), t -> t.eq(VInsurNationGoodsCl::getSTOOUT_NO, code).or().eq(VInsurNationGoodsCl::getRXNO, code)); - wrapper.and(StrUtil.isNotEmpty(key), t -> t.like(VInsurNationGoodsCl::getSTOOUT_NO, key) - .or().like(VInsurNationGoodsCl::getRXNO, key) - .or().like(VInsurNationGoodsCl::getPSN_NAME, key) - .or().like(VInsurNationGoodsCl::getPSN_NO, key) - ); - wrapper.and(StrUtil.isNotEmpty(fromCorpName), t -> t.eq(VInsurNationGoodsCl::getPSN_NAME, fromCorpName)); - - udiwmsBasicSkPrescribeRequest.setDatabaseProductName(getDataSourceType()); - - // 拉取处方时,改成拉取v_ypzs_pres_info - IPage page = vInsurNationGoodsClMapper.selectGroupedWithPagination(new Page(udiwmsBasicSkPrescribeRequest.getPage(), udiwmsBasicSkPrescribeRequest.getLimit()), - udiwmsBasicSkPrescribeRequest); - - if (page.getTotal() == 0) { - PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(page.getTotal()); - pageSimpleResponse.setList(null); - return ResultVOUtils.success(pageSimpleResponse); - } - return this.covertSellOrderQx(udiwmsBasicSkPrescribeRequest, page); - } - - // 辅助方法,用于检查busType是否存在于指定的buyType数组中 - private static boolean matchBusType(String busType, String[] buyTypes) { - for (String buyType : buyTypes) { - if (busType.equals(buyType)) { - return true; // 如果找到匹配项,则返回true - } - } - return false; // 如果没有找到匹配项,则返回false - } - - /** - * 单据 - * - * @param udiwmsBasicSkPrescribeRequest - * @return - */ - private BaseResponse covertSellOrder(UdiwmsBasicSkPrescribeRequest udiwmsBasicSkPrescribeRequest, IPage page) { - List presInfoEntities = page.getRecords(); - List vInsurNationGoodsPhysics = new ArrayList<>(); - if (CollUtil.isNotEmpty(presInfoEntities)) { - List collect = presInfoEntities.stream().map(VYpzsPresInfo::getPRESCRIBE_NUMBER).collect(Collectors.toList()); - LambdaQueryWrapper wrapper1 = new LambdaQueryWrapper<>(); - wrapper1.in(VYpzsPresInfo::getPRESCRIBE_NUMBER, collect); - vInsurNationGoodsPhysics = vYpzsPresInfoMapper.selectList(wrapper1); - } - - // TODO: 2024/9/19 这边在转换的时候就不能用VInsurNationGoodsPhysic - if (CollUtil.isNotEmpty(vInsurNationGoodsPhysics)) { - Map> groupedByPrescribeNumber = vInsurNationGoodsPhysics.stream() - .collect(Collectors.groupingBy(VYpzsPresInfo::getPRESCRIBE_NUMBER)); - List ioCollectOrders = new ArrayList<>(); - groupedByPrescribeNumber.forEach((key, value) -> { - VYpzsPresInfo presInfoEntity = value.get(0); - StringBuilder errorMsg = new StringBuilder(); - IoCollectOrder ioCollectOrder = new IoCollectOrder(); - - //区分住院、门诊处方 - if (IntUtil.value(presInfoEntity.getIN_HOSP()) == 1) { - ioCollectOrder.setBusType("YPCF003"); - ioCollectOrder.setBillNo(presInfoEntity.getSTOOUT_NO()); - } else { - ioCollectOrder.setBusType("YPCF002"); - ioCollectOrder.setBillNo(presInfoEntity.getPRESCRIBE_NUMBER()); - } - - ioCollectOrder.setFromType("HIS系统"); - ioCollectOrder.setFromCorp(presInfoEntity.getSICK_ID()); - ioCollectOrder.setWorkPlaceCode(udiwmsBasicSkPrescribeRequest.getWorkPlaceCode()); - ioCollectOrder.setFromCorpName(presInfoEntity.getSICK_NAME()); - Date date = DateUtil.parseDate(presInfoEntity.getLAY_TIME()); - ioCollectOrder.setBillTime(date); - ioCollectOrder.setCreateTime(new Date()); - ioCollectOrder.setCreateUser(udiwmsBasicSkPrescribeRequest.getCreateUser()); - ioCollectOrder.setBackupOrderRemark1(presInfoEntity.getSTOOUT_NO()); - ioCollectOrder.setBackupOrderRemark2(presInfoEntity.getSICK_ID()); -// ioCollectOrder.setBackupOrderRemark3(presInfoEntity.getPSN_NAME()); -// ioCollectOrder.setBackupOrderRemark4(presInfoEntity.getPSN_NO()); - ioCollectOrder.setUpdateTime(new Date()); - ioCollectOrder.setSplitStatus(0); - ioCollectOrder.setTagStatus(0); - List bizList = new ArrayList<>(); - value.forEach(entity -> { - IoCollectOrderBiz collectOrderBiz = new IoCollectOrderBiz(); - BasicUdirelEntity basicUdirelEntity = basicUdirelDao.selectOne(new LambdaQueryWrapper().eq(BasicUdirelEntity::getMainId, entity.getPHYSIC_CODE()).last(" limit 1")); - if (basicUdirelEntity != null) { - collectOrderBiz.setRelId(basicUdirelEntity.getId()); - } else { - errorMsg.append(entity.getPHYSIC_NAME()).append("字典未对照").append(";"); - } -// List vYpzsPresInfos = vYpzsPresInfoMapper.selectList(new LambdaQueryWrapper().eq(VYpzsPresInfo::getPRESCRIBE_NUMBER, entity.getPRESCRIBE_NUMBER()).eq(VYpzsPresInfo::getPHYSIC_CODE, entity.getPHYSIC_CODE())); -// if (CollUtil.isNotEmpty(vYpzsPresInfos)) { -// VYpzsPresInfo vYpzsPresInfo = vYpzsPresInfos.get(0); -// -// } - collectOrderBiz.setGgxh(entity.getPACK_SPEC()); - collectOrderBiz.setMeasureUnit(entity.getPHYSIC_UNIT()); - collectOrderBiz.setCount(IntUtil.value(entity.getLAY_PHYSIC_QUANTITY())); - collectOrderBiz.setThrCode(entity.getPHYSIC_CODE()); - collectOrderBiz.setCpmctymc(entity.getPHYSIC_NAME()); - collectOrderBiz.setOrderIdFk(ioCollectOrder.getBillNo()); - collectOrderBiz.setYbbm(entity.getCOUNTRY_CODE()); -// if (StrUtil.isNotEmpty(entity.getCODE_LIST())) { -// String[] codeArray = entity.getCODE_LIST().split(";"); -// if (codeArray != null && codeArray.length > 0) { -// List codeList = Arrays.asList(codeArray); -// for (String code : codeList) { -// UdiEntity udiEntity = FilterUdiUtils.getUdi(code); -// IoCollectOrderCodeMan.builder() -// .udiCode(code) -// .orderIdFk(ioCollectOrder.getBillNo()) -// .bizIdFk(collectOrderBiz.getId()) -// .relId(collectOrderBiz.getRelId()) -// .nameCode(udiEntity.getUdi()) -// .batchNo(udiEntity.getBatchNo()) -// .serialNo(udiEntity.getSerialNo()) -// .productDate(udiEntity.getProduceDate()) -// .expireDate(udiEntity.getExpireDate()) -// .createTime(new Date()) -// .createUser(1l) -// .updateTime(new Date()) -// .updateUser(1l) -// .scanCount(1) -// .isSplitCode(true) -// .scanActCount(1) -// .build(); -// } -// -// } -// -// -// } -// collectOrderBiz.setRemark1(entity.get() + ""); - - collectOrderBiz.setTagStatus(1); - collectOrderBiz.setUnTagCount(0); - bizList.add(collectOrderBiz); - }); - if (StrUtil.isNotBlank(errorMsg)) { - ioCollectOrder.setErrorMsg(errorMsg.toString()); - ioCollectOrder.setTagStatus(4); - } - ioCollectOrder.setBizList(summarizeByCode(bizList)); - ioCollectOrders.add(ioCollectOrder); - }); - PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(page.getTotal()); - pageSimpleResponse.setList(ioCollectOrders); - return ResultVOUtils.success(pageSimpleResponse); - } else { - return ResultVOUtils.error(500, "下载失败!"); - } - } - - - public static List summarizeByCode(List bizList) { - Map summarizedMap = new HashMap<>(); - - for (IoCollectOrderBiz biz : bizList) { - String code = biz.getThrCode(); - - if (summarizedMap.containsKey(code)) { - IoCollectOrderBiz existingBiz = summarizedMap.get(code); - existingBiz.setCount(existingBiz.getCount() + biz.getCount()); - } else { - summarizedMap.put(code, biz); - } - } - - return new ArrayList<>(summarizedMap.values()); - } - - - /** - * 单据 - * - * @param udiwmsBasicSkPrescribeRequest - * @return - */ - private BaseResponse covertSellOrderQx(UdiwmsBasicSkPrescribeRequest udiwmsBasicSkPrescribeRequest, IPage page) { - List presInfoEntities = page.getRecords(); - List vInsurNationGoodsPhysics = new ArrayList<>(); - if (CollUtil.isNotEmpty(presInfoEntities)) { - List collect = presInfoEntities.stream().map(VInsurNationGoodsCl::getSTOOUT_NO).collect(Collectors.toList()); - LambdaQueryWrapper wrapper1 = new LambdaQueryWrapper<>(); - wrapper1.in(VInsurNationGoodsCl::getSTOOUT_NO, collect); - vInsurNationGoodsPhysics = vInsurNationGoodsClMapper.selectList(wrapper1); - } - - // TODO: 2024/9/19 这边在转换的时候就不能用VInsurNationGoodsPhysic - if (CollUtil.isNotEmpty(vInsurNationGoodsPhysics)) { - Map> groupedByPrescribeNumber = vInsurNationGoodsPhysics.stream() - .collect(Collectors.groupingBy(VInsurNationGoodsCl::getSTOOUT_NO)); - List ioCollectOrders = new ArrayList<>(); - groupedByPrescribeNumber.forEach((key, value) -> { - VInsurNationGoodsCl presInfoEntity = value.get(0); - StringBuilder errorMsg = new StringBuilder(); - IoCollectOrder ioCollectOrder = new IoCollectOrder(); - ioCollectOrder.setBillNo(presInfoEntity.getSTOOUT_NO()); - ioCollectOrder.setFromType("HIS系统"); - ioCollectOrder.setFromCorp(presInfoEntity.getSICK_ID()); - ioCollectOrder.setWorkPlaceCode(udiwmsBasicSkPrescribeRequest.getWorkPlaceCode()); - ioCollectOrder.setFromCorpName(presInfoEntity.getPSN_NAME()); - Date date = DateUtil.parseDate(presInfoEntity.getSEL_RETN_TIME()); - ioCollectOrder.setBillTime(date); - ioCollectOrder.setCreateTime(new Date()); - ioCollectOrder.setCreateUser(udiwmsBasicSkPrescribeRequest.getCreateUser()); - ioCollectOrder.setBackupOrderRemark1(presInfoEntity.getSTOOUT_NO()); - ioCollectOrder.setBackupOrderRemark2(presInfoEntity.getSICK_ID()); -// ioCollectOrder.setBackupOrderRemark3(presInfoEntity.getPSN_NAME()); -// ioCollectOrder.setBackupOrderRemark4(presInfoEntity.getPSN_NO()); - ioCollectOrder.setUpdateTime(new Date()); - ioCollectOrder.setSplitStatus(0); - ioCollectOrder.setTagStatus(0); - List bizList = new ArrayList<>(); - value.forEach(entity -> { - IoCollectOrderBiz collectOrderBiz = new IoCollectOrderBiz(); - String med_list_codg = entity.getMED_LIST_CODG(); - collectOrderBiz.setThrCode(entity.getMATERIAL_CODE()); - BasicProductsEntity basicProductsEntity = null; - if (StrUtil.isNotBlank(med_list_codg)) { - basicProductsEntity = basicProductsDao.selectOne(new LambdaQueryWrapper() - .eq(BasicProductsEntity::getYbbm, med_list_codg).last(" limit 1")); - if (basicProductsEntity != null) { - collectOrderBiz.setGgxh(basicProductsEntity.getGgxh()); - collectOrderBiz.setMeasureUnit(basicProductsEntity.getPackUnit()); - collectOrderBiz.setNameCode(basicProductsEntity.getNameCode()); - BasicUdirelEntity basicUdirelEntity = basicUdirelDao.selectOne(new LambdaQueryWrapper() - .eq(BasicUdirelEntity::getUuid, basicProductsEntity.getUuid()).last(" limit 1")); - if (basicProductsEntity != null) { - collectOrderBiz.setRelId(basicUdirelEntity.getId()); - collectOrderBiz.setThrCode(basicUdirelEntity.getMainId()); - } else { - errorMsg.append(entity.getFIXMEDINS_HILIST_NAME()).append("字典未对照").append(";"); - } - } else { - errorMsg.append(entity.getFIXMEDINS_HILIST_NAME()).append("字典未对照").append(";"); - } - } else { - errorMsg.append(entity.getFIXMEDINS_HILIST_NAME()).append("字典未对照").append(";"); - } -//==================================== - collectOrderBiz.setCpmctymc(entity.getFIXMEDINS_HILIST_NAME()); - collectOrderBiz.setOrderIdFk(ioCollectOrder.getBillNo()); - collectOrderBiz.setYbbm(entity.getMED_LIST_CODG()); - collectOrderBiz.setProductDate(entity.getMANU_DATE()); - collectOrderBiz.setExpireDate(entity.getEXPY_END()); - collectOrderBiz.setBatchNo(entity.getMANU_LOTNUM()); -//==================================== - collectOrderBiz.setTagStatus(1); - collectOrderBiz.setCount(entity.getSEL_RETN_CNT()); - collectOrderBiz.setUnTagCount(0); - bizList.add(collectOrderBiz); - }); - if (StrUtil.isNotBlank(errorMsg)) { - ioCollectOrder.setErrorMsg(errorMsg.toString()); - ioCollectOrder.setTagStatus(4); - } - ioCollectOrder.setBizList(bizList); - ioCollectOrders.add(ioCollectOrder); - }); - PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(page.getTotal()); - pageSimpleResponse.setList(ioCollectOrders); - return ResultVOUtils.success(pageSimpleResponse); - } else { - return ResultVOUtils.error(500, "下载失败!"); - } - } - - private BaseResponse covertReturnOrder(UdiwmsBasicSkPrescribeRequest udiwmsBasicSkPrescribeRequest, IPage page) { - List presInfoEntities = page.getRecords(); - List vInsurNationGoodsReturns = new ArrayList<>(); - if (CollUtil.isNotEmpty(presInfoEntities)) { - List collect = presInfoEntities.stream().map(VYpzsPresInfoReturn::getAPPLY_NO).collect(Collectors.toList()); - LambdaQueryWrapper wrapper1 = new LambdaQueryWrapper<>(); - wrapper1.in(VYpzsPresInfoReturn::getAPPLY_NO, collect); - vInsurNationGoodsReturns = vYpzsPresInfoReturnMapper.selectList(wrapper1); - } - // TODO: 2024/9/19 这边在转换的时候就不能用vInsurNationGoodsReturns - if (CollUtil.isNotEmpty(vInsurNationGoodsReturns)) { - Map> groupedByPrescribeNumber = vInsurNationGoodsReturns.stream() - .collect(Collectors.groupingBy(VYpzsPresInfoReturn::getAPPLY_NO)); - List ioCollectOrders = new ArrayList<>(); - groupedByPrescribeNumber.forEach((key, value) -> { - VYpzsPresInfoReturn presInfoEntity = value.get(0); - StringBuilder errorMsg = new StringBuilder(); - IoCollectOrder ioCollectOrder = new IoCollectOrder(); - ioCollectOrder.setBillNo(presInfoEntity.getAPPLY_NO()); - ioCollectOrder.setFromType("HIS系统"); - ioCollectOrder.setFromCorp(presInfoEntity.getSICK_ID()); - ioCollectOrder.setWorkPlaceCode(udiwmsBasicSkPrescribeRequest.getWorkPlaceCode()); - ioCollectOrder.setFromCorpName(presInfoEntity.getSICK_NAME()); -// Date date = DateUtil.parseDate(presInfoEntity.get()); - ioCollectOrder.setBillTime(presInfoEntity.getKEEP_BOOK_TIME()); - ioCollectOrder.setCreateTime(new Date()); - ioCollectOrder.setCreateUser(udiwmsBasicSkPrescribeRequest.getCreateUser()); - ioCollectOrder.setUpdateTime(new Date()); - ioCollectOrder.setSplitStatus(0); - ioCollectOrder.setTagStatus(0); - List bizList = new ArrayList<>(); - value.forEach(entity -> { - IoCollectOrderBiz collectOrderBiz = new IoCollectOrderBiz(); - BasicUdirelEntity basicUdirelEntity = basicUdirelDao.selectOne(new LambdaQueryWrapper().eq(BasicUdirelEntity::getMainId, entity.getPHYSIC_CODE()).last(" limit 1")); - if (basicUdirelEntity != null) { - collectOrderBiz.setRelId(basicUdirelEntity.getId()); - } else { - errorMsg.append(entity.getPHYSIC_NAME()).append("字典未对照").append(";"); - } - List vYpzsPresInfoReturns = vYpzsPresInfoReturnMapper.selectList(new LambdaQueryWrapper().eq(VYpzsPresInfoReturn::getAPPLY_NO, entity.getAPPLY_NO()).eq(VYpzsPresInfoReturn::getPHYSIC_CODE, entity.getPHYSIC_CODE())); - - if (CollUtil.isNotEmpty(vYpzsPresInfoReturns)) { - VYpzsPresInfoReturn vYpzsPresInfo = vYpzsPresInfoReturns.get(0); - collectOrderBiz.setGgxh(vYpzsPresInfo.getPHYSIC_SPEC()); - collectOrderBiz.setMeasureUnit(vYpzsPresInfo.getPHYSIC_UNIT()); - } - collectOrderBiz.setThrCode(entity.getPHYSIC_CODE()); - collectOrderBiz.setCpmctymc(entity.getPHYSIC_NAME()); -// collectOrderBiz.setBatchNo(entity.getBATCH_NUMBER()); - collectOrderBiz.setOrderIdFk(ioCollectOrder.getBillNo()); - collectOrderBiz.setYbbm(entity.getFEE_SEQUENCE_NO()); - collectOrderBiz.setCount(entity.getQUANTITY()); - collectOrderBiz.setTagStatus(1); - collectOrderBiz.setUnTagCount(0); - bizList.add(collectOrderBiz); - }); - if (StrUtil.isNotBlank(errorMsg)) { - ioCollectOrder.setErrorMsg(errorMsg.toString()); - ioCollectOrder.setTagStatus(4); - } - ioCollectOrder.setBizList(bizList); - ioCollectOrders.add(ioCollectOrder); - }); - PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(page.getTotal()); - pageSimpleResponse.setList(ioCollectOrders); - return ResultVOUtils.success(pageSimpleResponse); - } else { - return ResultVOUtils.error(500, "下载失败!"); - } - } - - - public void optionUploadCollectOrder3505(IoCollectOrder ioCollectOrder) { - //摆药流水号 - String stoout_no = ioCollectOrder.getBackupOrderRemark1(); - List vInsurNationGoodsPhysics = goodsPhysicMapper.selectList(new LambdaQueryWrapper().eq(VInsurNationGoodsPhysic::getSTOOUT_NO, stoout_no)); - if (CollUtil.isNotEmpty(vInsurNationGoodsPhysics)) { - List collectOrderBizResponseList = ioCollectOrder.getCollectOrderBizResponseList(); - List xsck3505Requests = new ArrayList<>(); - for (CollectOrderBizResponse collectOrderBizResponse : collectOrderBizResponseList) { - BasicUdirelEntity basicUdirelEntity = basicUdirelDao.selectById(collectOrderBizResponse.getRelId()); - String itemCode = basicUdirelEntity.getMainId(); - for (VInsurNationGoodsPhysic vInsurNationGoodsPhysic : vInsurNationGoodsPhysics) { - if (vInsurNationGoodsPhysic.getFIXMEDINS_HILIST_ID().equals(itemCode)) { - String[] codes = collectOrderBizResponse.getFinishUdiCode().split(","); - List drugTraceList = new ArrayList<>(); - // 遍历fruits数组 - for (String code : codes) { - if (StrUtil.isNotBlank(code)) { - List relCodeDetailList = relCodeDetailService.getAllNext(code); - if (relCodeDetailList != null && relCodeDetailList.size() > 0) { - DrugInfoRequest request = new DrugInfoRequest(); - request.setDrug_trac_codg(code); - drugTraceList.add(request); - } - } - } - Xsck3505Request xsck3505Request = Xsck3505Request.builder() - .med_list_codg(vInsurNationGoodsPhysic.getMED_LIST_CODG()) - .fixmedins_hilist_id(vInsurNationGoodsPhysic.getFIXMEDINS_HILIST_ID()) - .fixmedins_hilist_name(vInsurNationGoodsPhysic.getFIXMEDINS_HILIST_NAME()) - .fixmedins_bchno(vInsurNationGoodsPhysic.getFIXMEDINS_BCHNO()) - .prsc_dr_cert_type(vInsurNationGoodsPhysic.getPRSC_DR_CERT_TYPE()) - .prsc_dr_certno(vInsurNationGoodsPhysic.getPRSC_DR_CERTNO()) - .prsc_dr_name(vInsurNationGoodsPhysic.getPRSC_DR_NAME()) - .phar_cert_type(vInsurNationGoodsPhysic.getPHAR_CERT_TYPE()) - .phar_certno(vInsurNationGoodsPhysic.getPHAR_CERTNO()) - .phar_name(vInsurNationGoodsPhysic.getPHAR_NAME()) - .phar_prac_cert_no(vInsurNationGoodsPhysic.getPHAR_PRAC_CERT_NO()) - .hi_feesetl_type(vInsurNationGoodsPhysic.getHI_FEESETL_TYPE()) - .setl_id(vInsurNationGoodsPhysic.getSETL_ID()) - .mdtrt_sn(vInsurNationGoodsPhysic.getMDTRT_SN()) - .psn_no(vInsurNationGoodsPhysic.getPSN_NO()) - .psn_cert_type(vInsurNationGoodsPhysic.getPSN_CERT_TYPE()) - .certno(vInsurNationGoodsPhysic.getCERTNO()) - .psn_name(vInsurNationGoodsPhysic.getPSN_NAME()) - .manu_lotnum(vInsurNationGoodsPhysic.getMANU_LOTNUM()) - .manu_date(vInsurNationGoodsPhysic.getMANU_DATE()) - .expy_end(vInsurNationGoodsPhysic.getEXPY_END()) - .rx_flag(vInsurNationGoodsPhysic.getRX_FLAG()) - .trdn_flag(vInsurNationGoodsPhysic.getTRDN_FLAG()) - .finl_trns_pric(vInsurNationGoodsPhysic.getFINL_TRNS_PRIC()) - .rxno(vInsurNationGoodsPhysic.getRXNO()) - .rx_circ_flag(vInsurNationGoodsPhysic.getRX_CIRC_FLAG()) - .rtal_docno(vInsurNationGoodsPhysic.getRTAL_DOCNO()) - .stoout_no(vInsurNationGoodsPhysic.getSTOOUT_NO()) - .bchno(vInsurNationGoodsPhysic.getBCHNO()) - .drug_prod_barc(vInsurNationGoodsPhysic.getRUG_PROD_BARC()) - .shelf_posi(vInsurNationGoodsPhysic.getSHELF_POSI()) - .sel_retn_cnt(vInsurNationGoodsPhysic.getSEL_RETN_CNT()) - .sel_retn_time(vInsurNationGoodsPhysic.getSEL_RETN_TIME()) - .sel_retn_opter_name(vInsurNationGoodsPhysic.getSEL_RETN_OPTER_NAME()) - .memo(vInsurNationGoodsPhysic.getMEMO()) - .mdtrt_setl_type(vInsurNationGoodsPhysic.getMDTRT_SETL_TYPE()) - .drugtracinfo(drugTraceList).build(); - xsck3505Requests.add(xsck3505Request); - } - } - } - BaseXsck3505Request baseXsck3505Request = new BaseXsck3505Request(); - baseXsck3505Request.setSelinfoDetail(xsck3505Requests); - String jsonStr = JSONUtil.toJsonStr(baseXsck3505Request); - JSONObject dataJson = JSONObject.parseObject(jsonStr); - ybClient.ybPost("3505A", dataJson); - } - } - - - public void optionUploadCollectOrder3501(IoCollectOrder ioCollectOrder) { - List bizList = ioCollectOrder.getBizList(); - if (CollUtil.isNotEmpty(bizList)) { - List collectOrderBizResponseList = ioCollectOrder.getCollectOrderBizResponseList(); - List pcsc3501Requests = new ArrayList<>(); - for (CollectOrderBizResponse collectOrderBizResponse : collectOrderBizResponseList) { - BasicUdirelEntity basicUdirelEntity = basicUdirelDao.selectById(collectOrderBizResponse.getRelId()); - String itemCode = basicUdirelEntity.getMainId(); - for (IoCollectOrderBiz item : bizList) { - if (item.getNameCode().equals(itemCode)) { - String[] codes = collectOrderBizResponse.getFinishUdiCode().split(","); - List drugTraceList = new ArrayList<>(); - // 遍历fruits数组 - for (String code : codes) { - if (StrUtil.isNotBlank(code)) { - List relCodeDetailList = relCodeDetailService.getAllNext(code); - if (relCodeDetailList != null && relCodeDetailList.size() > 0) { - DrugInfoRequest request = new DrugInfoRequest(); - request.setDrug_trac_codg(code); - drugTraceList.add(request); - } - } - } - // TODO: 2024/9/10 字段未完全正确对应 - Pcsc3501Request pcsc3501Request = Pcsc3501Request.builder() - .med_list_codg(item.getYbbm()) - .fixmedins_hilist_id(item.getThrCode()) - .fixmedins_hilist_name(item.getCpmctymc()) - .fixmedins_bchno(item.getRemark5()) - .rx_flag(item.getRemark6()) - .invdate(item.getUpdateTime()) - .inv_cnt(item.getActCount()) - .manu_lotnum(item.getBatchNo()) - .manu_date(item.getProductDate()) - .expy_end(item.getExpireDate()) - .memo(item.getRemark()) - .drugtracinfo(drugTraceList).build(); - pcsc3501Requests.add(pcsc3501Request); - } - } - } - BasePcsc3501Request basePcsc3501Request = new BasePcsc3501Request(); - basePcsc3501Request.setSelinfoDetail(pcsc3501Requests); - String jsonStr = JSONUtil.toJsonStr(basePcsc3501Request); - JSONObject dataJson = JSONObject.parseObject(jsonStr); - ybClient.ybPost("3501A", dataJson); - } - } - - - public void optionUploadCollectOrder3502(IoCollectOrder ioCollectOrder) { - List bizList = ioCollectOrder.getBizList(); - if (CollUtil.isNotEmpty(bizList)) { - List collectOrderBizResponseList = ioCollectOrder.getCollectOrderBizResponseList(); - List kcbg3502Requests = new ArrayList<>(); - for (CollectOrderBizResponse collectOrderBizResponse : collectOrderBizResponseList) { - BasicUdirelEntity basicUdirelEntity = basicUdirelDao.selectById(collectOrderBizResponse.getRelId()); - String itemCode = basicUdirelEntity.getMainId(); - for (IoCollectOrderBiz item : bizList) { - if (item.getNameCode().equals(itemCode)) { - String[] codes = collectOrderBizResponse.getFinishUdiCode().split(","); - List drugTraceList = new ArrayList<>(); - // 遍历fruits数组 - for (String code : codes) { - if (StrUtil.isNotBlank(code)) { - List relCodeDetailList = relCodeDetailService.getAllNext(code); - if (relCodeDetailList != null && relCodeDetailList.size() > 0) { - DrugInfoRequest request = new DrugInfoRequest(); - request.setDrug_trac_codg(code); - drugTraceList.add(request); - } - } - } - // TODO: 2024/9/10 字段未完全正确对应 - Kcbg3502Request kcbg3502Request = Kcbg3502Request.builder() - .med_list_codg(item.getYbbm()) - .inv_chg_type(item.getRemark7()) - .fixmedins_hilist_id(item.getThrCode()) - .fixmedins_hilist_name(item.getCpmctymc()) - .fixmedins_bchno(item.getRemark5()) - .pric(item.getRemark1()) - .cnt(item.getActCount()) - .rx_flag(item.getRemark6()) - .inv_chg_time(item.getUpdateTime()) - .inv_chg_opter_name(ioCollectOrder.getCreateUser()) - .memo(item.getRemark()) - .trdn_flag("0") - .drugtracinfo(drugTraceList).build(); - kcbg3502Requests.add(kcbg3502Request); - } - } - } - BaseKcbg3502Request baseKcbg3502Request = new BaseKcbg3502Request(); - baseKcbg3502Request.setSelinfoDetail(kcbg3502Requests); - String jsonStr = JSONUtil.toJsonStr(baseKcbg3502Request); - JSONObject dataJson = JSONObject.parseObject(jsonStr); - ybClient.ybPost("3502A", dataJson); - } - } - - public void optionUploadCollectOrder3506(IoCollectOrder ioCollectOrder) { -// List bizList = ioCollectOrder.getBizList(); - List collectOrderBizResponseList = ioCollectOrder.getCollectOrderBizResponseList(); - List xsth3506Requests = new ArrayList<>(); - List vInsurNationGoodsReturns = vInsurNationGoodsReturnMapper.selectList(new LambdaQueryWrapper().eq(VInsurNationGoodsReturn::getAPPLY_NO, ioCollectOrder.getBillNo())); - if (CollUtil.isEmpty(vInsurNationGoodsReturns)) { - log.error("申请单号{}不存在", ioCollectOrder.getBillNo()); - return; - } - - for (CollectOrderBizResponse item : collectOrderBizResponseList) { - BasicUdirelEntity basicUdirelEntity = basicUdirelDao.selectById(item.getRelId()); - String itemCode = basicUdirelEntity.getMainId(); - for (VInsurNationGoodsReturn vInsurNationGoodsPhysic : vInsurNationGoodsReturns) { - if (vInsurNationGoodsPhysic.getFIXMEDINS_HILIST_ID().equals(itemCode)) { - String[] codes = item.getFinishUdiCode().split(","); - List drugTraceList = new ArrayList<>(); - // 遍历fruits数组 - for (String code : codes) { - if (StrUtil.isNotBlank(code)) { - List relCodeDetailList = relCodeDetailService.getAllNext(code); - if (relCodeDetailList != null && relCodeDetailList.size() > 0) { - DrugInfoRequest request = new DrugInfoRequest(); - request.setDrug_trac_codg(code); - drugTraceList.add(request); - } - } - } - // TODO: 2024/9/10 字段未完全正确对应 - Xsth3506Request xsth3506Request = Xsth3506Request.builder() - .med_list_codg(item.getYbbm()) - .fixmedins_hilist_id(item.getThrCode()) - .fixmedins_hilist_name(item.getCpmctymc()) - .fixmedins_bchno(vInsurNationGoodsPhysic.getFIXMEDINS_BCHNO()) - .setl_id(vInsurNationGoodsPhysic.getSETL_ID()) - .psn_no(vInsurNationGoodsPhysic.getPSN_NO()) - .psn_cert_type(vInsurNationGoodsPhysic.getPSN_CERT_TYPE()) - .certno(vInsurNationGoodsPhysic.getCERTNO()) - .psn_name(vInsurNationGoodsPhysic.getPSN_NAME()) - .manu_lotnum(vInsurNationGoodsPhysic.getMANU_LOTNUM()) - .manu_date(vInsurNationGoodsPhysic.getMANU_DATE()) - .expy_end(vInsurNationGoodsPhysic.getEXPY_END()) - .rx_flag(vInsurNationGoodsPhysic.getRX_FLAG()) - .trdn_flag(vInsurNationGoodsPhysic.getTRDN_FLAG()) - .finl_trns_pric(vInsurNationGoodsPhysic.getFINL_TRNS_PRIC()) - .sel_retn_cnt(vInsurNationGoodsPhysic.getSEL_RETN_CNT()) - .sel_retn_time(vInsurNationGoodsPhysic.getSEL_RETN_TIME()) - .sel_retn_opter_name(vInsurNationGoodsPhysic.getSEL_RETN_OPTER_NAME()) - .memo(item.getRemark()) - .medins_prod_sel_no(vInsurNationGoodsPhysic.getMEDINS_PROL_SEL_NO()) - .mdtrt_sn(vInsurNationGoodsPhysic.getMDTRT_SN()) - .drugtracinfo(drugTraceList).build(); - - xsth3506Requests.add(xsth3506Request); - } - } - } - - - BaseXsth3506Request baseXsth3506Request = new BaseXsth3506Request(); - baseXsth3506Request.setSelinfoDetail(xsth3506Requests); - String jsonStr = JSONUtil.toJsonStr(baseXsth3506Request); - JSONObject dataJson = JSONObject.parseObject(jsonStr); - ybClient.ybPost("3506A", dataJson); - } - - /** - * 获取交易类型集合 - * - * @return - */ - @Override - public BaseResponse getBuyType() { - Map buyTypeMap = new HashMap<>(); - buyTypeMap.put("buyType_3501", buyType_3501); - buyTypeMap.put("buyType_3502", buyType_3502); - buyTypeMap.put("buyType_3505", buyType_3505); - buyTypeMap.put("buyType_3506", buyType_3506); - return ResultVOUtils.success(buyTypeMap); - } - public String getDataSourceType(){ - return defXmlSqlType; - } - - -} diff --git a/src/main/java/com/glxp/mipsdl/client/ctqyy/entity/InvCodeResultEntity.java b/src/main/java/com/glxp/mipsdl/client/ctqyy/entity/InvCodeResultEntity.java deleted file mode 100644 index e58bffb..0000000 --- a/src/main/java/com/glxp/mipsdl/client/ctqyy/entity/InvCodeResultEntity.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.glxp.mipsdl.client.ctqyy.entity; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 高值耗材出入库明细 - */ -@NoArgsConstructor -@Data -public class InvCodeResultEntity { - - - @JsonProperty("recordNo") - private Integer recordNo; - @JsonProperty("visitNo") - private String visitNo; - @JsonProperty("sickName") - private String sickName; - @JsonProperty("inDept") - private String inDept; - @JsonProperty("deptName") - private String deptName; - @JsonProperty("materialCode") - private String materialCode; - @JsonProperty("materialName") - private String materialName; - @JsonProperty("materialPrc") - private Integer materialPrc; - @JsonProperty("dictBarcode") - private String dictBarcode; - @JsonProperty("Barcode") - private String barcode; - @JsonProperty("feeTime") - private String feeTime; - @JsonProperty("feeOper") - private String feeOper; -} - - diff --git a/src/main/java/com/glxp/mipsdl/client/ctqyy/entity/InvProjectResultEntity.java b/src/main/java/com/glxp/mipsdl/client/ctqyy/entity/InvProjectResultEntity.java deleted file mode 100644 index 775aa9f..0000000 --- a/src/main/java/com/glxp/mipsdl/client/ctqyy/entity/InvProjectResultEntity.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.glxp.mipsdl.client.ctqyy.entity; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 收费项目出入库明细 - */ -@NoArgsConstructor -@Data -public class InvProjectResultEntity { - - - @JsonProperty("seqNo") - private String seqNo; - @JsonProperty("visitNo") - private String visitNo; - @JsonProperty("sickName") - private String sickName; - @JsonProperty("applyDept") - private String applyDept; - @JsonProperty("deptName") - private String deptName; - @JsonProperty("itemCode") - private String itemCode; - @JsonProperty("itemName") - private String itemName; - @JsonProperty("Price") - private Double price; - @JsonProperty("quantity") - private Integer quantity; - @JsonProperty("Cost") - private Double cost; - @JsonProperty("materialCode") - private String materialCode; - @JsonProperty("materialName") - private String materialName; - @JsonProperty("OperTime") - private String operTime; -} diff --git a/src/main/java/com/glxp/mipsdl/client/ctqyy/entity/InvResultEntity.java b/src/main/java/com/glxp/mipsdl/client/ctqyy/entity/InvResultEntity.java deleted file mode 100644 index 9e1f0df..0000000 --- a/src/main/java/com/glxp/mipsdl/client/ctqyy/entity/InvResultEntity.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.glxp.mipsdl.client.ctqyy.entity; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 库存出入库明细 - */ -@NoArgsConstructor -@Data -public class InvResultEntity { - - @JsonProperty("applyNo") - private String applyNo; - @JsonProperty("ioFlag") - private String ioFlag; - @JsonProperty("ioType") - private String ioType; - @JsonProperty("ioTypeName") - private String ioTypeName; - @JsonProperty("Debit") - private String debit; - @JsonProperty("DebitName") - private String debitName; - @JsonProperty("Credit") - private String credit; - @JsonProperty("CreditName") - private String creditName; - @JsonProperty("AccoutDate") - private String accoutDate; - @JsonProperty("Accoutant") - private String accoutant; - @JsonProperty("receiveOper") - private String receiveOper; - @JsonProperty("materialCode") - private String materialCode; - @JsonProperty("materialName") - private String materialName; - @JsonProperty("materialSpec") - private String materialSpec; - @JsonProperty("materialUnit") - private String materialUnit; - @JsonProperty("batchNo") - private String batchNo; - @JsonProperty("invoiceNo") - private String invoiceNo; - @JsonProperty("invoiceDate") - private String invoiceDate; - @JsonProperty("quantity") - private Integer quantity; - @JsonProperty("importPrc") - private Double importPrc; - @JsonProperty("importMoney") - private Integer importMoney; - @JsonProperty("factoryCode") - private String factoryCode; - @JsonProperty("factoryName") - private String factoryName; -} diff --git a/src/main/java/com/glxp/mipsdl/client/dsxyy/DsxyyClient.java b/src/main/java/com/glxp/mipsdl/client/dsxyy/DsxyyClient.java deleted file mode 100644 index c83c488..0000000 --- a/src/main/java/com/glxp/mipsdl/client/dsxyy/DsxyyClient.java +++ /dev/null @@ -1,492 +0,0 @@ -package com.glxp.mipsdl.client.dsxyy; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.util.ReflectUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; -import com.alibaba.fastjson.TypeReference; -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.CommonHttpClient; -import com.glxp.mipsdl.config.ThirdSysConfig; -import com.glxp.mipsdl.constant.ConstantType; -import com.glxp.mipsdl.constant.Constants; -import com.glxp.mipsdl.dao.auth.AuthUserDao; -import com.glxp.mipsdl.dao.auth.AuthWarehouseDao; -import com.glxp.mipsdl.dao.basic.BasicBussinessTypeDao; -import com.glxp.mipsdl.dao.basic.BasicCorpDao; -import com.glxp.mipsdl.dao.basic.BasicProductsDao; -import com.glxp.mipsdl.dao.basic.BasicUdirelDao; -import com.glxp.mipsdl.dao.inout.IoCodeDao; -import com.glxp.mipsdl.dao.inout.IoOrderDao; -import com.glxp.mipsdl.dao.inout.IoOrderDetailBizDao; -import com.glxp.mipsdl.dao.thrsys.*; -import com.glxp.mipsdl.entity.auth.AuthUserEntity; -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.BasicProductsEntity; -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.IoOrderInvoiceEntity; -import com.glxp.mipsdl.entity.thrsys.*; -import com.glxp.mipsdl.http.HttpClient; -import com.glxp.mipsdl.req.base.*; -import com.glxp.mipsdl.req.dsxyy.DsBusTypeRequest; -import com.glxp.mipsdl.req.dsxyy.DsOrderRequest; -import com.glxp.mipsdl.req.dsxyy.DsProductRequest; -import com.glxp.mipsdl.req.dsxyy.DsUnitRequest; -import com.glxp.mipsdl.req.post.PostFileThrOrderRequest; -import com.glxp.mipsdl.req.post.PostThrCorpRequest; -import com.glxp.mipsdl.req.post.PostThrInvProductsRequest; -import com.glxp.mipsdl.req.post.PostThrProductsRequest; -import com.glxp.mipsdl.res.BaseResponse; -import com.glxp.mipsdl.res.PageSimpleResponse; -import com.glxp.mipsdl.res.udiwms.ThrProductsResponse; -import com.glxp.mipsdl.service.auth.AuthWarehouseService; -import com.glxp.mipsdl.service.order.OrderUploadLogService; -import com.glxp.mipsdl.service.thrsys.ThrCorpService; -import com.glxp.mipsdl.service.thrsys.ThrSystemDetailService; -import com.glxp.mipsdl.util.*; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.*; -import java.util.stream.Collectors; - -/** - * 东山县医院接口对接 - */ -@Slf4j -@Service(value = "100006HttpClient") //bean注册名称,使用编码 + HttpClient,文件接口加 FileClient -public class DsxyyClient extends CommonHttpClient { - - @Resource - private ThrSystemDetailService thrSystemDetailService; - @Resource - private HttpClient httpClient; - @Resource - private ThrBustypeOriginDao thrBustypeOriginDao; - @Resource - private IoOrderDao orderDao; - @Resource - private ThrSystemBusApiDao thrSystemBusApiDao; - @Resource - private BasicBussinessTypeDao basicBussinessTypeDao; - @Resource - private BasicCorpDao basicCorpDao; - @Resource - private IoCodeDao codeDao; - @Resource - private AuthWarehouseDao authWarehouseDao; - @Resource - private ThrInvWarehouseDao thrInvWarehouseDao; - @Resource - private AuthWarehouseService authWarehouseService; - @Resource - private ThirdSysConfig thirdSysConfig; - @Resource - private ThrCorpService thrCorpService; - @Resource - private IoOrderDetailBizDao orderDetailBizDao; - @Resource - private SubmitOrderUtil submitOrderUtil; - @Resource - AuthUserDao authUserDao; - @Resource - private BasicUdirelDao basicUdirelDao; - @Resource - private BasicProductsDao basicProductsDao; - @Resource - private ThrProductsDao thrProductsDao; - @Resource - private OrderUploadLogService orderUploadLogService; - @Resource - private ThrOrderUploadBustypesMapper thrOrderUploadBustypesMapper; - @Resource - ThrCorpDao thrCorpDao; - - @Override - public BaseResponse getUnit(UdiwmsUnitRequest udiwmsUnitRequest) { - DsUnitRequest dsUnitRequest = new DsUnitRequest(); - BeanUtil.copyProperties(udiwmsUnitRequest, dsUnitRequest); - String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_CORP_URL), dsUnitRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse getProducts(UdiwmsProductRequest udiwmsProductRequest) { - DsProductRequest dsProductRequest = new DsProductRequest(); - BeanUtil.copyProperties(udiwmsProductRequest, dsProductRequest); - String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_PI_QUERY_URL), dsProductRequest); - - BaseResponse> baseResponse = - JSONObject.parseObject(response, new TypeReference>>() { - }); - - // 过滤西药库产品 - if (CollUtil.isNotEmpty(baseResponse.getData().getList())) { - Iterator iterator = baseResponse.getData().getList().iterator(); - while (iterator.hasNext()) { - ThrProductsResponse item = iterator.next(); - if (item.getRemark() != null && item.getRemark().contains("西药库")) { - iterator.remove(); - baseResponse.getData().setTotal(-555l); - } - } - } -// BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse getOrderTypes(UdiwmsBusTypeRequest udiwmsBusTypeRequest) { - DsBusTypeRequest dsBusTypeRequest = new DsBusTypeRequest(); - BeanUtil.copyProperties(udiwmsBusTypeRequest, dsBusTypeRequest); - String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_BUS_TYPE_QUERY_URL), udiwmsBusTypeRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse getOrders(UdiwmsOrderQueryRequest udiwmsOrderQueryRequest) { - if (StrUtil.isBlank(udiwmsOrderQueryRequest.getBillType())) { - return ResultVOUtils.error(500, "单据类型不能为空"); - } - //查询绑定的第三方单据类型 - String thirdAction = thrBustypeOriginDao.findThirdActionByBillType(udiwmsOrderQueryRequest.getBillType(), DictUtl.CURRENT_HOSP_CODE); - udiwmsOrderQueryRequest.setBillType(thirdAction); - String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_ORDER_QUERY_URL), udiwmsOrderQueryRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse submitOrders(UdiwmsOrderRequest udiwmsOrderRequest) { - if (StrUtil.isBlank(udiwmsOrderRequest.getBillNo())) { - return ResultVOUtils.error(500, "单据号不能为空"); - } - - DsOrderRequest dsOrderRequest = new DsOrderRequest(); - BeanUtil.copyProperties(udiwmsOrderRequest, dsOrderRequest); - - //查询单据和详情信息,组装第三方系统接口参数 - IoOrderEntity orderEntity = orderDao.selectOne(new LambdaQueryWrapper().eq(IoOrderEntity::getBillNo, udiwmsOrderRequest.getBillNo()).last("limit 1")); - - if (orderEntity.getAuditTime() == null) - dsOrderRequest.setBillDate(DateUtil.formatDateTime(orderEntity.getCreateTime())); - else { - dsOrderRequest.setBillDate(DateUtil.formatDateTime(orderEntity.getAuditTime())); - } - - //设置操作人 - if (orderEntity.getReviewUser() != null) { - AuthUserEntity authAdmin = authUserDao.selectById(orderEntity.getReviewUser()); - dsOrderRequest.setOperUser(authAdmin.getUserName()); - } else if (orderEntity.getCreateUser() != null) { - AuthUserEntity authAdmin = authUserDao.selectById(orderEntity.getCreateUser()); - dsOrderRequest.setOperUser(authAdmin.getUserName()); - } - //查询对应的第三方单据类型 - ThrSystemBusApiEntity thrSystemBusApiEntity = thrSystemBusApiDao.selectOne(new LambdaQueryWrapper().eq(ThrSystemBusApiEntity::getCode, udiwmsOrderRequest.getBillType())); - if (StrUtil.isBlank(thrSystemBusApiEntity.getUrl())) { - return ResultVOUtils.error(500, "接口未配置,无法提交!"); - } - - dsOrderRequest.setBillType(thrSystemBusApiEntity.getThirdBuyCode()); - if (orderEntity.getInvCode().equals("1000000")) { - dsOrderRequest.setLocInvCode("1161"); - dsOrderRequest.setLocInvName("设备科"); - } else { - dsOrderRequest.setLocInvCode("4050"); - dsOrderRequest.setLocInvName("西药库"); - } - - - //查询单据类型,设置往来单位信息 - BasicBussinessTypeEntity basicBussinessTypeEntity = basicBussinessTypeDao.selectByAction(udiwmsOrderRequest.getBillType()); - if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_HOSPTIAL)) { - //医院客户 - dsOrderRequest.setCorpId(orderEntity.getFromCorp()); - //查询客户名称 - String corpName = basicCorpDao.selectNameByErpId(orderEntity.getFromCorp()); - dsOrderRequest.setCorpName(corpName); - } else if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_INTTERNAL)) { - - - BasicCorpEntity basicCorpEntity = null; - if (StrUtil.isNotEmpty(orderEntity.getFromCorp())) { - basicCorpEntity = basicCorpDao.selectByErpId(orderEntity.getFromCorp()); - } - if (basicCorpEntity != null) { - dsOrderRequest.setCorpId(basicCorpEntity.getThirdId()); - dsOrderRequest.setCorpName(basicCorpEntity.getName()); - List thrCorpEntities = thrCorpDao.selectList(new QueryWrapper().eq("name", basicCorpEntity.getThirdName())); - if (CollUtil.isNotEmpty(thrCorpEntities)) { - for (ThrCorpEntity temp : thrCorpEntities) { - if (StrUtil.isNotEmpty(temp.getKfdm()) && temp.getKfdm().equals(udiwmsOrderRequest.getLocInvCode())) { - udiwmsOrderRequest.setCorpId(temp.getUnitId()); //往来单位编码,需转换为第三方系统的ID - udiwmsOrderRequest.setCorpName(temp.getName()); //往来单位名称,需转换为第三方系统的名称 - } - } - } - - } else { - AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new QueryWrapper().eq("code", udiwmsOrderRequest.getCorpId())); - try { - //根据第三方系统标识,获取对应字段的值 - ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper() - .eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity)) - .eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId())); - - dsOrderRequest.setCorpId(thrInvWarehouseEntity.getCode()); - dsOrderRequest.setCorpName(thrInvWarehouseEntity.getName()); - } catch (Exception e) { - String msg = "查询单据对应往来单位的第三方仓库信息异常"; - orderUploadLogService.updateLocalErr(orderEntity, msg); - log.error("----单据提交-----" + orderEntity.getBillNo() + msg); - return ResultVOUtils.error(500, msg); - } - } - - } else if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_SP)) { - //供应商 - BasicCorpEntity basicCorpEntity = basicCorpDao.selectByErpId(orderEntity.getFromCorp()); - if (null != basicCorpEntity) { - dsOrderRequest.setCorpId(basicCorpEntity.getThirdId()); - dsOrderRequest.setCorpName(basicCorpEntity.getName()); - - List thrCorpEntities = thrCorpDao.selectList(new QueryWrapper().eq("name", basicCorpEntity.getThirdName())); - if (CollUtil.isNotEmpty(thrCorpEntities)) { - for (ThrCorpEntity temp : thrCorpEntities) { - if (StrUtil.isNotEmpty(temp.getKfdm()) && temp.getKfdm().equals(udiwmsOrderRequest.getLocInvCode())) { - udiwmsOrderRequest.setCorpId(temp.getUnitId()); //往来单位编码,需转换为第三方系统的ID - udiwmsOrderRequest.setCorpName(temp.getName()); //往来单位名称,需转换为第三方系统的名称 - } - } - } - - } else { - String msg = "查询单据对应的第三方往来单位信息异常"; - orderUploadLogService.updateLocalErr(orderEntity, msg); - log.error("----单据提交-----" + orderEntity.getBillNo() + msg); - return ResultVOUtils.error(500, msg); - } - - - } - -// //查询仓库信息 -// AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new LambdaQueryWrapper().eq(AuthWarehouseEntity::getCode, orderEntity.getInvCode())); -// try { -// ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper() -// .eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity)) -// .eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId())); -// -// dsOrderRequest.setLocInvCode(thrInvWarehouseEntity.getCode()); -// dsOrderRequest.setLocInvName(thrInvWarehouseEntity.getName()); -// -// dsOrderRequest.setLocStorageCode(thrInvWarehouseEntity.getCode()); -// dsOrderRequest.setLocStorageName(thrInvWarehouseEntity.getName()); -// } catch (Exception e) { -// log.info("查询第三方系统仓库信息异常", e); -// } - -// if (StrUtil.nullToEmpty(thrSystemBusApiEntity.getUrl()).equals("useOut")) { -// dsOrderRequest.setCorpId(dsOrderRequest.getLocStorageCode()); -// dsOrderRequest.setCorpName(dsOrderRequest.getLocStorageName()); -// -// ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper().eq(ThrInvWarehouseEntity::getCode, "29") -// .eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId())); -// dsOrderRequest.setLocStorageCode("29"); -// dsOrderRequest.setLocStorageName(thrInvWarehouseEntity.getName()); -// } - - dsOrderRequest.setBillFlag("1"); - //设置单据出入库类型 - if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_PUT)) { - dsOrderRequest.setInoutType(1); //入库 - } else if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT)) { - dsOrderRequest.setInoutType(2); //出库 - } - - dsOrderRequest.setRemark("udi管理系统提交单据"); - - //组装单据明细数据 - List ioCodeEntities = codeDao.selectList(new LambdaQueryWrapper() - .eq(IoCodeEntity::getOrderId, orderEntity.getBillNo()) - ); - - List items = new ArrayList<>(); - //查询业务单据详情 - List detailBizEntities = orderDetailBizDao.selectList(new LambdaQueryWrapper().eq(IoOrderDetailBizEntity::getOrderIdFk, orderEntity.getBillNo())); - - for (IoOrderDetailBizEntity detailBizEntity : detailBizEntities) { - - //查询产品信息 - BasicUdirelEntity basicUdirel = basicUdirelDao.selectById(detailBizEntity.getBindRlFk()); - BasicProductsEntity basicProducts = basicProductsDao.selectOne(new LambdaQueryWrapper().eq(BasicProductsEntity::getUuid, basicUdirel.getUuid()).last("limit 1")); - - UdiwmsOrderDetailRequest item = new UdiwmsOrderDetailRequest(); - BeanUtil.copyProperties(detailBizEntity, item); - - item.setProductDate(StrUtil.isBlank(detailBizEntity.getProductDate()) ? "19990101" : "20" + detailBizEntity.getProductDate()); - item.setExpireDate(StrUtil.isBlank(detailBizEntity.getExpireDate()) ? "20991231" : "20" + detailBizEntity.getExpireDate()); - - String thirdProductId = (String) ReflectUtil.getFieldValue(basicUdirel, thirdSysConfig.getThirdId()); - item.setProductId(thirdProductId); //产品ID - - //查询第三方产品名称 - ThrProductsEntity thrProductsEntity = thrProductsDao.selectOne(new LambdaQueryWrapper() - .eq(ThrProductsEntity::getCode, thirdProductId).last("limit 1")); - if (thrProductsEntity == null) { - String errMsg = "提交失败,错误信息:" + detailBizEntity.getCoName() + "产品DI未关联第三方产品信息"; - orderUploadLogService.updateLocalErr(orderEntity, errMsg); - return ResultVOUtils.error(500, errMsg); - } - if (StrUtil.isEmpty(thrProductsEntity.getPrice())) { - item.setPrice(new BigDecimal(0)); - } else - item.setPrice(new BigDecimal(thrProductsEntity.getPrice())); - - - String fphm = ""; - String fprq = null; - List invoiceList = IoOrderInvoiceEntity.builder().build() - .selectList(Wrappers.lambdaQuery(IoOrderInvoiceEntity.class).eq(IoOrderInvoiceEntity::getOrderIdFk, orderEntity.getBillNo()) - .eq(IoOrderInvoiceEntity::getBindRlFk, detailBizEntity.getBindRlFk()) - .eq(StrUtil.isNotEmpty(detailBizEntity.getBatchNo()), IoOrderInvoiceEntity::getBatchNo, detailBizEntity.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.setSecSalesInvNo(fphm); - item.setInvoiceDate(fprq); - boolean isNeedFp = false; - ThrOrderUploadBustypesEntity thrOrderUploadBustypesEntity = thrOrderUploadBustypesMapper.selectOne(new QueryWrapper().eq("action", basicBussinessTypeEntity.getAction()).last("limit 1")); - if (thrOrderUploadBustypesEntity != null && IntUtil.value(thrOrderUploadBustypesEntity.getOrderStatus()) == 3) { - isNeedFp = true; - } - if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_PUT) && StrUtil.isEmpty(fphm) && isNeedFp) { - String errMsg = "提交失败,错误信息:" + detailBizEntity.getCoName() + "发票缺失,请补齐后重新提交"; - orderUploadLogService.updateLocalErr(orderEntity, errMsg); - return ResultVOUtils.error(500, errMsg); - } - - item.setProductName(thrProductsEntity.getName()); //产品名称 - item.setBindRlFk(detailBizEntity.getBindRlFk()); - item.setStandard(detailBizEntity.getSpec()); //规格型号 - item.setBillNo(detailBizEntity.getOrderIdFk()); //单据号 - item.setRegisterNo(detailBizEntity.getCertCode()); //注册/备案证号 - item.setManufactory(basicProducts.getManufactory()); //生产厂家 - item.setMeasname(basicProducts.getMeasname()); //计量单位 - item.setAllowNoBatch(IntUtil.value(basicProducts.getAllowNoBatch())); //是否允许无批次号 - item.setManufactoryCode(thrProductsEntity.getManufactoryCode()); - item.setSupCode(thrProductsEntity.getSupCode()); - item.setCplb(thrProductsEntity.getFlbm()); - item.setCount(detailBizEntity.getCount()); - //封装条码信息 - submitOrderUtil.setCodeList(ioCodeEntities, detailBizEntity, item); - items.add(item); - } - - Collections.reverse(items); - dsOrderRequest.setItem(items); - - return submitOrderUtil.submitOrder(orderEntity, dsOrderRequest); - } - - - @Override - public BaseResponse getInvProducts(UdiwmsInvProductsRequest udiwmsInvProductsRequest) { - String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_INV_PI_URL), udiwmsInvProductsRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse getWarehouse(UdiwmsWarehouseRequest udiwmsWarehouseRequest) { - String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_WAREHOUSE_QUERY_URL), udiwmsWarehouseRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse postProducts(PostThrProductsRequest postThrProductsRequest) { - postThrProductsRequest.setUploadType("文件导入"); - String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostPiUrl(), postThrProductsRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse postCorps(PostThrCorpRequest postThrCorpRequest) { - postThrCorpRequest.setUploadType("文件导入"); - String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostCorpUrl(), postThrCorpRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse postOrderDetail(PostFileThrOrderRequest postFileThrOrderRequest) { - postFileThrOrderRequest.setUploadType("文件导入"); - String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostOrderUrl(), postFileThrOrderRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse postInvProducts(PostThrInvProductsRequest postThrInvProductsRequest) { - String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostInvPiUrl(), postThrInvProductsRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse testConnect() { - UdiwmsUnitRequest udiwmsUnitRequest = new UdiwmsUnitRequest(); - udiwmsUnitRequest.setPage(1); - udiwmsUnitRequest.setLimit(1); - BaseResponse baseResponse = getUnit(udiwmsUnitRequest); - if (baseResponse.getCode() == 20000) { - return ResultVOUtils.success("连接成功"); - } - return ResultVOUtils.error(500, "连接失败!"); - } - - @Override - public BaseResponse queryUdiInvProducts(UdiwmsQueryUdiInvProductsRequest queryUdiInvProductsRequest) { - String response = httpClient.postUDIWMSJson(thirdSysConfig.getQueryInvUrl(), queryUdiInvProductsRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse submitProducts(UdiwmsAddProductsRequest udiwmsAddProductsRequest) { - return null; - } - - @Override - public BaseResponse submitUnit(UdiwmsAddUnitRequest udiwmsAddUnitRequest) { - return null; - } - - @Override - public BaseResponse submitPreInOrders(UdiwmsPreInOrderRequest udiwmsPreInOrderRequest) { - return null; - } - - -} diff --git a/src/main/java/com/glxp/mipsdl/client/ptxhyy/PtxhyyClient.java b/src/main/java/com/glxp/mipsdl/client/ptxhyy/PtxhyyClient.java deleted file mode 100644 index 1c59b7d..0000000 --- a/src/main/java/com/glxp/mipsdl/client/ptxhyy/PtxhyyClient.java +++ /dev/null @@ -1,641 +0,0 @@ -package com.glxp.mipsdl.client.ptxhyy; - -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.fastjson.JSONObject; -import com.alibaba.fastjson.TypeReference; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.StringUtils; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.glxp.mipsdl.client.CommonHttpClient; -import com.glxp.mipsdl.client.ptxhyy.entity.HisProductEntity; -import com.glxp.mipsdl.client.ptxhyy.entity.OrderUploadResponse; -import com.glxp.mipsdl.client.ptxhyy.entity.ThrHslbEntity; -import com.glxp.mipsdl.client.ptxhyy.entity.ThrHslbService; -import com.glxp.mipsdl.config.ThirdSysConfig; -import com.glxp.mipsdl.constant.ConstantType; -import com.glxp.mipsdl.constant.Constants; -import com.glxp.mipsdl.dao.auth.AuthUserDao; -import com.glxp.mipsdl.dao.auth.AuthWarehouseDao; -import com.glxp.mipsdl.dao.auth.AuthWarehouseUserMapper; -import com.glxp.mipsdl.dao.basic.*; -import com.glxp.mipsdl.dao.inout.IoCodeDao; -import com.glxp.mipsdl.dao.inout.IoOrderDao; -import com.glxp.mipsdl.dao.inout.IoOrderDetailBizDao; -import com.glxp.mipsdl.dao.inout.IoOrderUploadLogDao; -import com.glxp.mipsdl.dao.thrsys.ThrDeptDao; -import com.glxp.mipsdl.dao.thrsys.ThrInvWarehouseDao; -import com.glxp.mipsdl.dao.thrsys.ThrProductsDao; -import com.glxp.mipsdl.dao.thrsys.ThrSystemBusApiDao; -import com.glxp.mipsdl.entity.auth.AuthUserEntity; -import com.glxp.mipsdl.entity.auth.AuthWarehouseEntity; -import com.glxp.mipsdl.entity.auth.AuthWarehouseUser; -import com.glxp.mipsdl.entity.basic.BasicBussinessTypeEntity; -import com.glxp.mipsdl.entity.basic.BasicCorpEntity; -import com.glxp.mipsdl.entity.basic.BasicSkProjectEntity; -import com.glxp.mipsdl.entity.inout.*; -import com.glxp.mipsdl.entity.ptxhyy.SickerEntity; -import com.glxp.mipsdl.entity.thrsys.ThrInvWarehouseEntity; -import com.glxp.mipsdl.entity.thrsys.ThrSystemBusApiEntity; -import com.glxp.mipsdl.http.HttpClient; -import com.glxp.mipsdl.req.base.UdiwmsInvProductsRequest; -import com.glxp.mipsdl.req.base.UdiwmsOrderDetailRequest; -import com.glxp.mipsdl.req.base.UdiwmsOrderRequest; -import com.glxp.mipsdl.req.ctqyy.DlThirdProjectRequest; -import com.glxp.mipsdl.req.ctqyy.GetSickRequest; -import com.glxp.mipsdl.req.ptxhyy.PtxhyyInvRequest; -import com.glxp.mipsdl.req.ptxhyy.PtxhyyOrderDetailRequest; -import com.glxp.mipsdl.req.ptxhyy.PtxhyyOrderRequest; -import com.glxp.mipsdl.res.BaseResponse; -import com.glxp.mipsdl.res.PageSimpleResponse; -import com.glxp.mipsdl.res.ptxhyy.PtxhInvResponse; -import com.glxp.mipsdl.res.udiwms.BasicSkSickerResponse; -import com.glxp.mipsdl.res.udiwms.ThrInvResultResponse; -import com.glxp.mipsdl.service.auth.AuthWarehouseService; -import com.glxp.mipsdl.service.order.OrderUploadLogService; -import com.glxp.mipsdl.service.thrsys.ThrCorpService; -import com.glxp.mipsdl.service.thrsys.ThrSystemDetailService; -import com.glxp.mipsdl.thirddao.ptxhyy.PtxhyySickerMapper; -import com.glxp.mipsdl.util.*; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.io.IOException; -import java.math.BigDecimal; -import java.util.*; -import java.util.stream.Collectors; - - -/** - * 平潭协和医院接口 - */ -@Slf4j -@Service(value = "100008HttpClient") -@RequiredArgsConstructor -public class PtxhyyClient extends CommonHttpClient { - - - private final ThirdSysConfig thirdSysConfig; - private final IoOrderDao orderDao; - private final ThrSystemBusApiDao thrSystemBusApiDao; - private final BasicBussinessTypeDao basicBussinessTypeDao; - private final BasicCorpDao basicCorpDao; - private final AuthWarehouseDao authWarehouseDao; - private final ThrInvWarehouseDao thrInvWarehouseDao; - private final AuthWarehouseService authWarehouseService; - private final IoCodeDao codeDao; - private final IoOrderDetailBizDao orderDetailBizDao; - private final SubmitOrderUtil submitOrderUtil; - @Resource - ThrHslbService thrHslbService; - @Resource - PtxhyySickerMapper ptxhyySickerMapper; - - @Override - public BaseResponse submitOrders(UdiwmsOrderRequest udiwmsOrderRequest) { - if (StrUtil.isBlank(udiwmsOrderRequest.getBillNo())) { - return ResultVOUtils.error(500, "单据号不能为空"); - } - //查询单据和详情信息,组装第三方系统接口参数 - IoOrderEntity orderEntity = orderDao.selectOne(new LambdaQueryWrapper().eq(IoOrderEntity::getBillNo, udiwmsOrderRequest.getBillNo())); - - Date billDate = orderEntity.getConfirmTime() == null ? orderEntity.getUpdateTime() : orderEntity.getConfirmTime(); - udiwmsOrderRequest.setBillDate(DateUtil.formatDateTime(billDate)); - //查询对应的第三方单据类型 - ThrSystemBusApiEntity thrSystemBusApiEntity = thrSystemBusApiDao.selectOne(new LambdaQueryWrapper().eq(ThrSystemBusApiEntity::getCode, udiwmsOrderRequest.getBillType())); - if (StrUtil.isBlank(thrSystemBusApiEntity.getUrl())) { - String errMsg = "接口未配置,无法提交!"; - updateLocalErr(orderEntity, errMsg); - return ResultVOUtils.error(500, errMsg); - } - udiwmsOrderRequest.setBillType(thrSystemBusApiEntity.getThirdBuyCode()); - //查询单据类型,设置往来单位信息 - BasicBussinessTypeEntity basicBussinessTypeEntity = basicBussinessTypeDao.selectByAction(orderEntity.getAction()); - if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_HOSPTIAL)) { - //医院客户 - udiwmsOrderRequest.setCorpId(orderEntity.getFromCorp()); - //查询客户名称 - String corpName = basicCorpDao.selectNameByErpId(orderEntity.getFromCorp()); - udiwmsOrderRequest.setCorpName(corpName); - } else if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_INTTERNAL)) { - BasicCorpEntity basicCorpEntity = null; - if (StrUtil.isNotEmpty(orderEntity.getFromCorp())) { - basicCorpEntity = basicCorpDao.selectByErpId(orderEntity.getFromCorp()); - if (null != basicCorpEntity) { - udiwmsOrderRequest.setCorpId(basicCorpEntity.getThirdId()); - udiwmsOrderRequest.setCorpName(basicCorpEntity.getName()); - } else { - String msg = "查询单据对应的第三方往来单位信息异常"; - updateLocalErr(orderEntity, msg); - log.error("----单据提交-----" + orderEntity.getBillNo() + msg); - return ResultVOUtils.error(500, msg); - } - } else { - //内部科室 - AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new LambdaQueryWrapper().eq(AuthWarehouseEntity::getCode, orderEntity.getFromInvCode())); - try { - //根据第三方系统标识,获取对应字段的值 - ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper() - .eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity)) - .eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId())); - udiwmsOrderRequest.setCorpId(thrInvWarehouseEntity.getCode()); - udiwmsOrderRequest.setCorpName(thrInvWarehouseEntity.getName()); - } catch (Exception e) { - String msg = "查询单据对应往来单位的第三方仓库信息异常"; - updateLocalErr(orderEntity, msg); - log.error("----单据提交-----" + orderEntity.getBillNo() + msg + ExceptionUtil.stacktraceToString(e)); - return ResultVOUtils.error(500, msg); - } - } - } else if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_SP)) { - //供应商 - - BasicCorpEntity basicCorpEntity = basicCorpDao.selectByErpId(orderEntity.getFromCorp()); - if (null != basicCorpEntity) { - udiwmsOrderRequest.setCorpId(basicCorpEntity.getThirdId()); - udiwmsOrderRequest.setCorpName(basicCorpEntity.getName()); - } else { - String msg = "查询单据对应的第三方往来单位信息异常"; - updateLocalErr(orderEntity, msg); - log.error("----单据提交-----" + orderEntity.getBillNo() + msg); - return ResultVOUtils.error(500, msg); - } - } - - //查询仓库信息 - AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new LambdaQueryWrapper().eq(AuthWarehouseEntity::getCode, orderEntity.getInvCode())); - try { - List thrInvWarehouseEntitys = thrInvWarehouseDao.selectList(new LambdaQueryWrapper() - .eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity)) - .eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId())); - if (CollUtil.isNotEmpty(thrInvWarehouseEntitys)) { - udiwmsOrderRequest.setLocInvCode(thrInvWarehouseEntitys.get(0).getCode()); - udiwmsOrderRequest.setLocInvName(thrInvWarehouseEntitys.get(0).getName()); - } - } catch (Exception e) { - log.error("查询第三方系统仓库信息异常", ExceptionUtil.stacktraceToString(e)); - updateLocalErr(orderEntity, "查询第三方系统仓库信息异常" + ExceptionUtil.stacktraceToString(e)); - return ResultVOUtils.error(500, "查询第三方系统仓库信息异常"); - } - udiwmsOrderRequest.setBillFlag("1"); - //设置单据出入库类型 - if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_PUT)) { - udiwmsOrderRequest.setInoutType(1); //入库 - } else if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT)) { - udiwmsOrderRequest.setInoutType(2); //出库 - } - - udiwmsOrderRequest.setRemark("udi管理系统提交单据:" + orderEntity.getBillNo()); - - //组装单据明细数据 - List ioCodeEntities = codeDao.selectList(new LambdaQueryWrapper() - .eq(IoCodeEntity::getOrderId, orderEntity.getBillNo()) - .ne(IoCodeEntity::getAction, "StockCheck") - ); - - List items = new ArrayList<>(); - //查询业务单据详情 - List detailBizEntities = orderDetailBizDao.selectList(new LambdaQueryWrapper().eq(IoOrderDetailBizEntity::getOrderIdFk, orderEntity.getBillNo())); - - //单据金额 - BigDecimal djje = detailBizEntities.stream() - .filter(x -> x.getPrice() != null). - map(IoOrderDetailBizEntity::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add); - List ioOrderInvoiceEntities = IoOrderInvoiceEntity.builder().build() - .selectList(Wrappers.lambdaQuery(IoOrderInvoiceEntity.class).eq(IoOrderInvoiceEntity::getOrderIdFk, orderEntity.getBillNo()).groupBy(IoOrderInvoiceEntity::getInvoiceEncode)); - int fbbz = 0; - if (CollectionUtil.isNotEmpty(ioOrderInvoiceEntities) && ioOrderInvoiceEntities.size() > 0) { - fbbz = 1; - } - String userName; - try { - userName = getUserName(orderEntity); - if (StrUtil.isEmpty(userName)) { - updateLocalErr(orderEntity, "该单据无创建人!"); - return ResultVOUtils.error(500, "该单据无创建人!"); - } - } catch (Exception e) { - log.error("----单据提交-----" + orderEntity.getBillNo() + "查询操作人异常", ExceptionUtil.stacktraceToString(e)); - userName = getUserName(orderEntity); - } - PtxhyyOrderRequest ptxhyyOrderRequest = PtxhyyOrderRequest - .builder() - .kfxh(udiwmsOrderRequest.getLocInvCode()) - .czgh(userName) - .lzfs(udiwmsOrderRequest.getBillType()) - .dwxh(udiwmsOrderRequest.getCorpId()) - .rkrq(udiwmsOrderRequest.getBillDate()) - .djje(djje) - .fpbz(fbbz) - .zdrq(udiwmsOrderRequest.getBillDate()) - .lsje(djje) - .fpzs(CollectionUtil.isNotEmpty(ioOrderInvoiceEntities) ? ioOrderInvoiceEntities.size() : 0) - .udixh(udiwmsOrderRequest.getBillNo()) - .lzdh(udiwmsOrderRequest.getBillNo()) - .build(); - - ptxhyyOrderRequest.setDetailList(new ArrayList<>()); - String errMs = setOrderDetailList(ioCodeEntities, items, detailBizEntities); - if (errMs != null) { - updateLocalErr(orderEntity, errMs); - log.error(errMs); - return ResultVOUtils.error(500, errMs); - } - 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 fphm = ""; - String fprq = null; - List invoiceList = IoOrderInvoiceEntity.builder().build() - .selectList(Wrappers.lambdaQuery(IoOrderInvoiceEntity.class).eq(IoOrderInvoiceEntity::getOrderIdFk, orderEntity.getBillNo()) - .eq(IoOrderInvoiceEntity::getBindRlFk, i.getBindRlFk()) - .eq(StrUtil.isNotEmpty(i.getBatchNo()), IoOrderInvoiceEntity::getBatchNo, i.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()); - } - String hsfl = ""; - if (StrUtil.isNotEmpty(i.getHslb())) { - ThrHslbEntity thrHslbEntity = thrHslbService.getOne(new QueryWrapper().eq("hslb", i.getHslb()), false); - if (thrHslbEntity != null) { - hsfl = thrHslbEntity.getHsbm(); - } - } -// .udim(udim) - BigDecimal wzje = null; - if (i.getPrice() != null) - wzje = i.getPrice().multiply(BigDecimal.valueOf(i.getCount().intValue())); - PtxhyyOrderDetailRequest detailRequest = PtxhyyOrderDetailRequest.builder() - .wzxh(i.getProductId()) - .cjxh(i.getManufactoryCode()) - .bzdw(i.getMeasname()) - .bzsl(i.getCount()) - .wzjg(i.getPrice()) - .lsjg(i.getPrice() + "") - .lsje(wzje) - .wzje(wzje + "") - .hsfl(i.getHslb()) -// .hsfl(hsfl) - .wzph(i.getBatchNo()) - .fphm(fphm) - .fprq(fprq) - .djrq(DateUtil.formatDate(orderEntity.getCreateTime(), "yyyy-MM-dd")) - .producedDate(i.getProductDate()) - .expireDate(i.getExpireDate()) - .registerNo(i.getRegisterNo()) - .build(); - ptxhyyOrderRequest.getDetailList().add(detailRequest); - } - - return submitOrder(orderEntity, ptxhyyOrderRequest); - } - - - /** - * 本地提交错误 - * - * @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); - orderUploadLogService.insertOrUpdate(uploadLog); - } - - /** - * 封装单据详情参数 - * - * @param ioCodeEntities 单据码明细 - * @param orderDetailRequests 单据详情参数 - * @param detailBizEntities 单据业务详情 - */ - private String setOrderDetailList(List ioCodeEntities, List orderDetailRequests, List detailBizEntities) { - for (IoOrderDetailBizEntity detailBizEntity : detailBizEntities) { - UdiwmsOrderDetailRequest item = submitOrderUtil.buildProductInfo(detailBizEntity); - if (item == null) { - return detailBizEntity.getNameCode() + "第三方产品编码未关联"; - } - //封装条码信息 - submitOrderUtil.setCodeList(ioCodeEntities, detailBizEntity, item); - orderDetailRequests.add(item); - } - return null; - } - - @Resource - AuthUserDao authUserDao; - @Resource - AuthWarehouseUserMapper authWarehouseUserMapper; - @Resource - private HttpClient httpClient; - @Resource - private ThrSystemDetailService thrSystemDetailService; - @Resource - private OrderUploadLogService orderUploadLogService; - - - public String getUserName(IoOrderEntity orderEntity) { - - //创建人非供应商 - - if (StrUtil.isNotEmpty(orderEntity.getConfirmUser())) { - AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getConfirmUser()); - return authUserEntity.getUserName(); - } else if (StrUtil.isNotEmpty(orderEntity.getReviewUser())) { - AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getReviewUser()); - return authUserEntity.getUserName(); - } else { - List authWarehouseUsers = authWarehouseUserMapper.selectList(new QueryWrapper().eq("code", orderEntity.getInvCode())); - if (CollUtil.isNotEmpty(authWarehouseUsers)) { - return authWarehouseUsers.get(0).getUserName(); - } - } - return null; - } - - - public String getDefaultUserName(IoOrderEntity orderEntity) { - List authWarehouseUsers = authWarehouseUserMapper.selectList(new QueryWrapper().eq("code", orderEntity.getInvCode())); - if (CollUtil.isNotEmpty(authWarehouseUsers)) { - return authWarehouseUsers.get(0).getUserName(); - } - return null; - } - - - /** - * 提交单据 - * - * @param orderEntity - * @param udiwmsOrderRequest - * @return - */ - public BaseResponse submitOrder(IoOrderEntity orderEntity, Object udiwmsOrderRequest) { - //记录日志 - 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); - String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_ORDER_SUBMIT_URL), udiwmsOrderRequest); - if (StrUtil.isNotBlank(response)) { - try { - BaseResponse baseResponse = - JSONObject.parseObject(response, new TypeReference>() { - }); - if (baseResponse.getCode() == 20000) { - String thirdBillNo = baseResponse.getData().getDjxh(); - orderEntity.setThirdBillNo(thirdBillNo); - orderEntity.setExportStatus(1); //上传成功 - uploadLog.setStatus(2); - uploadLog.setThrBillNo(thirdBillNo); - uploadLog.setResult("提交成功"); - orderDao.updateById(orderEntity); - orderUploadLogService.insertOrUpdate(uploadLog); - return ResultVOUtils.success("提交成功"); - } - orderEntity.setExportStatus(2); //上传失败 - orderDao.updateById(orderEntity); - uploadLog.setStatus(3); - uploadLog.setResult("提交失败,错误信息:" + baseResponse.getMessage()); - orderUploadLogService.insertOrUpdate(uploadLog); - return baseResponse; - } catch (Exception e) { - log.error("解析提交单据返回结果异常,结果信息:{}", response); - log.error("异常信息:{}", e); - uploadLog.setStatus(3); - uploadLog.setResult("提交失败,错误信息:" + response); - orderEntity.setExportStatus(2); //上传失败 - orderDao.updateById(orderEntity); - orderUploadLogService.insertOrUpdate(uploadLog); - return ResultVOUtils.error(500, "提交失败"); - } - } else { - uploadLog.setStatus(3); - uploadLog.setResult("提交失败,调用接口返回为空"); - orderEntity.setExportStatus(2); //上传失败 - orderDao.updateById(orderEntity); - orderUploadLogService.insertOrUpdate(uploadLog); - return ResultVOUtils.error(500, "提交失败"); - } - } - - - /** - * 获取库存/出入库明细信息 - */ - @Override - public BaseResponse getInvFeeResult(UdiwmsInvProductsRequest udiwmsInvProductsRequest) { - PtxhyyInvRequest ptxhyyInvRequest = new PtxhyyInvRequest(); - ptxhyyInvRequest.setKssj(DateUtil.formatDate(udiwmsInvProductsRequest.getStartDate(), "yyyy-MM-dd")); - ptxhyyInvRequest.setJssj(DateUtil.formatDate(udiwmsInvProductsRequest.getEndDate(), "yyyy-MM-dd")); - String response = null; - try { - response = FileUtils.getFileContent("D://UDI/response.json"); - } catch (IOException e) { - e.printStackTrace(); - } -// response = httpClient.postJson(thrSystemDetailService.getUrlExclude(null) + "/CKCX", ptxhyyInvRequest); -// String response = "{\"code\": 20000,\"data\": {\"list\": [{\"zsl\": 1,\"fyxh\": 30274,\"dw\": \"根\",\"lb\": \"住院\",\"fymc\": \"一次性使用避光压力延长管/根\",\"fydj\": 13,\"rq\": 1709222400000,\"zxks\": \"新10区\"},{\"zsl\": 3,\"fyxh\": 35550,\"dw\": \"个\",\"lb\": \"住院\",\"fymc\": \"静脉林华留置针(苏州林华)/个\",\"fydj\": 3.12,\"rq\": 1709222400000,\"zxks\": \"精神科病区\"},{\"zsl\": 2,\"fyxh\": 29290,\"dw\": \"支\",\"lb\": \"住院\",\"fymc\": \"一次性采血针/支 (100.000%)\",\"fydj\": 0.28,\"rq\": 1709222400000,\"zxks\": \"精神科病区\"},{\"zsl\": 6,\"fyxh\": 29976,\"dw\": \"个\",\"lb\": \"住院\",\"fymc\": \"雾化面罩(口含式)/个 (100.000%)\",\"fydj\": 14.4,\"rq\": 1709222400000,\"zxks\": \"新11区\"},{\"zsl\": 1,\"fyxh\": 29298,\"dw\": \"支\",\"lb\": \"住院\",\"fymc\": \"一次性无菌注射器(1ml 带针)/支\",\"fydj\": 0.27,\"rq\": 1709222400000,\"zxks\": \"03区\"},{\"zsl\": 1,\"fyxh\": 29291,\"dw\": \"支\",\"lb\": \"住院\",\"fymc\": \"一次性使用静脉输液针(头皮针)/支 (100.000%)\",\"fydj\": 0.14,\"rq\": 1709222400000,\"zxks\": \"03区\"},{\"zsl\": 62,\"fyxh\": 29292,\"dw\": \"副\",\"lb\": \"住院\",\"fymc\": \"一次性使用代贴输液器(带针)/副 (100.000%)\",\"fydj\": 0.95,\"rq\": 1709222400000,\"zxks\": \"16区\"},{\"zsl\": 9,\"fyxh\": 30621,\"dw\": \"个\",\"lb\": \"住院\",\"fymc\": \"一次性使用真空采血管(促凝剂)/个\",\"fydj\": 0.58,\"rq\": 1709222400000,\"zxks\": \"05区\"},{\"zsl\": 66,\"fyxh\": 29294,\"dw\": \"支\",\"lb\": \"住院\",\"fymc\": \"一次性无菌注射器(5ml 带针)/支\",\"fydj\": 0.28,\"rq\": 1709222400000,\"zxks\": \"16区\"},{\"zsl\": 4,\"fyxh\": 29278,\"dw\": \"个\",\"lb\": \"住院\",\"fymc\": \"一次性使用负压引流袋/个\",\"fydj\": 5.8,\"rq\": 1709222400000,\"zxks\": \"04区\"}]}}"; - BaseResponse> baseResponse = - JSONObject.parseObject(response, new TypeReference>>() { - }); - if (baseResponse.getCode() == 20000) { - List ptxhInvResponses = baseResponse.getData().getList(); - List thrInvResultResponses = new ArrayList<>(); - - Set seenNames = new HashSet<>(); - List itemData = new ArrayList<>(); - - if (CollUtil.isNotEmpty(ptxhInvResponses)) { - for (PtxhInvResponse ptxhInvResponse : ptxhInvResponses) { - - ThrInvResultResponse thrInvResultResponse = new ThrInvResultResponse(); - thrInvResultResponse.setBillType("SC71021292871198"); //科室收费出库 - thrInvResultResponse.setMainAction(ConstantType.TYPE_OUT); - - List thrInvWarehouseEntitys = thrInvWarehouseDao.selectList(new QueryWrapper().eq("code", ptxhInvResponse.getZxksdm())); - if (CollUtil.isNotEmpty(thrInvWarehouseEntitys)) { - for (ThrInvWarehouseEntity thrInvWarehouseEntity : thrInvWarehouseEntitys) { - AuthWarehouseEntity authWarehouseEntity = authWarehouseDao.selectOne(new QueryWrapper().eq("thirdId", thrInvWarehouseEntity.getCode()).last("limit 1")); - if (authWarehouseEntity != null) { - thrInvResultResponse.setInvCode(authWarehouseEntity.getCode()); - thrInvResultResponse.setDeptCode(authWarehouseEntity.getParentId()); - thrInvResultResponse.setDeptName(ptxhInvResponse.getZxks()); - thrInvResultResponse.setInvName(ptxhInvResponse.getZxks()); - thrInvResultResponse.setThrCode(ptxhInvResponse.getFyxh()); - thrInvResultResponse.setCpmctymc(ptxhInvResponse.getFymc()); - thrInvResultResponse.setPrice(BigDecimal.valueOf(Double.parseDouble(ptxhInvResponse.getFydj()))); - thrInvResultResponse.setMeasname(ptxhInvResponse.getDw()); - thrInvResultResponse.setType(ptxhInvResponse.getLb()); - thrInvResultResponse.setOutCount(ptxhInvResponse.getZsl()); - thrInvResultResponse.setReCount(ptxhInvResponse.getZsl()); - thrInvResultResponse.setBatchNo(null); - thrInvResultResponse.setSickerName(ptxhInvResponse.getBrxm()); - thrInvResultResponse.setSickerCode(ptxhInvResponse.getJzhm()); - if (StrUtil.isNotEmpty(ptxhInvResponse.getRq())) { - thrInvResultResponse.setChargeTime(ptxhInvResponse.getRq()); - } - thrInvResultResponses.add(thrInvResultResponse); - if (seenNames.add(ptxhInvResponse.getFyxh())) { - itemData.add(ptxhInvResponse); - break; - } - } else { -// thrInvWarehouseEntity.setCode(CustomUtil.getId()); -// thrInvWarehouseEntity.setName(ptxhInvResponse.getZxks()); -// thrInvWarehouseEntity.setThirdSysFk("thirdId"); -// thrInvWarehouseEntity.setId(IdUtil.getSnowflakeNextId() + ""); -// thrInvWarehouseEntity.setParentId(thrInvWarehouseEntity.getCode()); -// thrInvWarehouseEntity.setRemark("收费出库自动生成"); -// thrInvWarehouseEntity.setUpdateTime(new Date()); -// thrInvWarehouseDao.insert(thrInvWarehouseEntity); -// -// ThrDeptEntity thrDeptEntity = new ThrDeptEntity(); -// thrDeptEntity.setCode(thrInvWarehouseEntity.getCode()); -// thrDeptEntity.setName(thrInvWarehouseEntity.getName()); -// thrDeptEntity.setPId(0); -// thrDeptEntity.setId(IdUtil.getSnowflakeNextId()); -// thrDeptEntity.setStatus(1); -// thrDeptEntity.setRemark("收费出库自动生成"); -// thrInvWarehouseEntity.setUpdateTime(new Date()); -// thrDeptEntity.setThirdSysFk(thrDeptEntity.getThirdSysFk()); -// thrDeptDao.insert(thrDeptEntity); -// return ResultVOUtils.error(500, ptxhInvResponse.getZxks() + "第三方科室仓库未创建!"); - log.error(ptxhInvResponse.getZxks() + "--科室仓库未对照!"); - } - } - } else { - log.error(ptxhInvResponse.getZxks() + "第三方科室仓库未创建!"); - } - } - } - -// for (PtxhInvResponse invProjectResultEntity : itemData) { -// if (!basicSkProjectMapper.exists(new QueryWrapper().eq("code", invProjectResultEntity.getFyxh()))) { -// BasicSkProjectEntity basicSkProjectEntity = new BasicSkProjectEntity(); -// basicSkProjectEntity.setCode(invProjectResultEntity.getFyxh()); -// basicSkProjectEntity.setName(invProjectResultEntity.getFymc()); -// basicSkProjectEntity.setType(2); -// basicSkProjectEntity.setCreateTime(new Date()); -// basicSkProjectEntity.setUpdateTime(new Date()); -// basicSkProjectEntity.setRemark("出入库明细自动生成"); -// basicSkProjectEntity.setId(IdUtil.getSnowflakeNextId()); -// basicSkProjectMapper.insert(basicSkProjectEntity); -// } -// } - - PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(thrInvResultResponses.size() + 0l); - pageSimpleResponse.setList(thrInvResultResponses); - return ResultVOUtils.success(pageSimpleResponse); - } - return baseResponse; - } - - -// public void getHslb() { -// String response = httpClient.postJson(thrSystemDetailService.getUrl(null), udiwmsUnitRequest); -// BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); -// return baseResponse; -// } - - - /** - * 获取项目组套字典 - * - * @param dlThirdProjectRequest - * @return - */ - @Override - public BaseResponse getBasicProject(DlThirdProjectRequest dlThirdProjectRequest) { - - dlThirdProjectRequest.setFygb("14"); - dlThirdProjectRequest.setPage(1); - dlThirdProjectRequest.setLimit(10000); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(null) + "/YLSF", dlThirdProjectRequest); - BaseResponse> baseResponse = - JSONObject.parseObject(response, new TypeReference>>() { - }); - if (baseResponse.getCode() == 20000) { - PageSimpleResponse pageSimpleResponse = baseResponse.getData(); - List list = pageSimpleResponse.getList(); - List basicSkProjectEntities = new ArrayList<>(); - int index = 1; - int index2 = 1; - log.info("总数:" + list.size()); - for (HisProductEntity hisProductEntity : list) { - BasicSkProjectEntity basicSkProjectEntity = new BasicSkProjectEntity(); - basicSkProjectEntity.setCode(hisProductEntity.getFyxh()); - basicSkProjectEntity.setName(hisProductEntity.getFymc()); - basicSkProjectEntity.setType(2); - basicSkProjectEntity.setCreateTime(new Date()); - basicSkProjectEntity.setUpdateTime(new Date()); - basicSkProjectEntity.setRemark("自动下载"); - basicSkProjectEntity.setCategory(hisProductEntity.getFydw()); - basicSkProjectEntity.setGgxh(hisProductEntity.getSm()); - basicSkProjectEntity.setUnit(hisProductEntity.getFydw()); - basicSkProjectEntity.setPrice(hisProductEntity.getFydj()); - if (hisProductEntity.getZfpb().equals("0")) { - log.info("在用" + index++ + ""); - basicSkProjectEntities.add(basicSkProjectEntity); - } else { - log.info("作废" + index2++ + ""); - } - } - PageSimpleResponse dataResponse = new PageSimpleResponse<>(); - dataResponse.setTotal(-666l); - dataResponse.setList(basicSkProjectEntities); - return ResultVOUtils.success(dataResponse); - } - return ResultVOUtils.error(500, "获取项目组套字典失败!"); - - - } - - @Override - public BaseResponse getSickInfo(GetSickRequest getSickRequest) { - IPage page = new Page<>(getSickRequest.getPage(), getSickRequest.getLimit()); - IPage productEntityIPage = ptxhyySickerMapper.selectPage(page, new QueryWrapper() - .lambda() - .like(StringUtils.isNotBlank(getSickRequest.getCode()), SickerEntity::getZYHM, getSickRequest.getCode()) - .like(StringUtils.isNotBlank(getSickRequest.getName()), SickerEntity::getBRXM, getSickRequest.getName())); - List basicSkSickerResponses = new ArrayList<>(); - productEntityIPage.getRecords().forEach(sickerEntity -> { - basicSkSickerResponses.add(BasicSkSickerResponse.builder() - .sickerId(sickerEntity.getZYH()) - .code(sickerEntity.getZYH()) - .name(sickerEntity.getBRXM()) - .adNum(sickerEntity.getZYHM()) - .inHospTime(sickerEntity.getRYRQ()) - .outHospTime(sickerEntity.getCYRQ()) - .build()); - }); - - PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(productEntityIPage.getTotal()); - pageSimpleResponse.setList(basicSkSickerResponses); - return ResultVOUtils.success(pageSimpleResponse); - } -} diff --git a/src/main/java/com/glxp/mipsdl/client/ptxhyy/PtxhyyFileClient.java b/src/main/java/com/glxp/mipsdl/client/ptxhyy/PtxhyyFileClient.java deleted file mode 100644 index 6681cea..0000000 --- a/src/main/java/com/glxp/mipsdl/client/ptxhyy/PtxhyyFileClient.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.glxp.mipsdl.client.ptxhyy; - -import cn.hutool.core.thread.ThreadUtil; -import com.glxp.mipsdl.client.BaseFileClient; -import com.glxp.mipsdl.client.CommonFileClient; -import com.glxp.mipsdl.req.post.PostThrProductsRequest; -import com.glxp.mipsdl.res.BaseResponse; -import com.glxp.mipsdl.res.udiwms.UdiwmsProductInfoResponse; -import com.glxp.mipsdl.service.file.UdiInfoUploadService; -import com.glxp.mipsdl.util.ExcelUtil; -import com.glxp.mipsdl.util.ExecutorUtil; -import com.glxp.mipsdl.util.ResultVOUtils; -import com.glxp.mipsdl.vo.file.ptxhyy.PtxhyyProductEntity; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; - -import javax.annotation.Resource; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - -/** - * 平潭协和医院物资系统文件接口 - */ -@Slf4j -@Service(value = "100008FileClient") -public class PtxhyyFileClient extends CommonFileClient { - - @Resource - private UdiInfoUploadService udiInfoUploadService; - @Resource - private ExecutorUtil executorUtil; - - @Override - public BaseResponse uploadPi(List files, String thirdSys) { - for (int i = 0; i < files.size(); i++) { - MultipartFile file = files.get(i); - if (file.isEmpty()) { - return ResultVOUtils.error(500, "上传第" + (i++) + "个文件失败"); - } - try { - InputStream inputStream = file.getInputStream(); - ExcelUtil util = new ExcelUtil(PtxhyyProductEntity.class); - List udiwmsProductInfoResponses = util.importPi(inputStream); - PostThrProductsRequest postThrProductsRequest = new PostThrProductsRequest(); - postThrProductsRequest.setDatas(udiwmsProductInfoResponses); - postThrProductsRequest.setUploadType("文件导入"); - postThrProductsRequest.setThirdSys(thirdSys); - executorUtil.getUploadExecutor().execute(ThreadUtil.newThread(() -> { - udiInfoUploadService.postProducts(postThrProductsRequest); - }, "uploadPi")); - log.error("上传完" + System.currentTimeMillis()); - } catch (IOException e) { - log.error("解析上传excel文件IO异常,异常信息:{}", e); - return ResultVOUtils.error(500, "数据异常"); - } catch (Exception e) { - log.error("处理产品信息excel文件异常,异常信息:{}", e); - return ResultVOUtils.error(500, "数据异常"); - } - } - return ResultVOUtils.success("文件解析成功,正在上传,请稍后刷新查看"); - } -} diff --git a/src/main/java/com/glxp/mipsdl/client/ptxhyy/PtxhyyHisClient.java b/src/main/java/com/glxp/mipsdl/client/ptxhyy/PtxhyyHisClient.java deleted file mode 100644 index 0c903dc..0000000 --- a/src/main/java/com/glxp/mipsdl/client/ptxhyy/PtxhyyHisClient.java +++ /dev/null @@ -1,173 +0,0 @@ -package com.glxp.mipsdl.client.ptxhyy; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ReflectUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; -import com.alibaba.fastjson.TypeReference; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.glxp.mipsdl.client.CommonHttpClient; -import com.glxp.mipsdl.client.ptxhyy.entity.HisFyRequest; -import com.glxp.mipsdl.client.ptxhyy.entity.HisProductEntity; -import com.glxp.mipsdl.client.ptxhyy.entity.PostHisDetailRequest; -import com.glxp.mipsdl.client.ptxhyy.entity.PostHisRequest; -import com.glxp.mipsdl.config.ThirdSysConfig; -import com.glxp.mipsdl.constant.Constants; -import com.glxp.mipsdl.dao.basic.BasicBussinessTypeDao; -import com.glxp.mipsdl.dao.basic.BasicProductsDao; -import com.glxp.mipsdl.dao.basic.BasicUdirelDao; -import com.glxp.mipsdl.dao.inout.IoCodeDao; -import com.glxp.mipsdl.dao.inout.IoOrderDao; -import com.glxp.mipsdl.dao.inout.IoOrderDetailBizDao; -import com.glxp.mipsdl.dao.thrsys.ThrSystemBusApiDao; -import com.glxp.mipsdl.entity.basic.BasicBussinessTypeEntity; -import com.glxp.mipsdl.entity.basic.BasicProductsEntity; -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.thrsys.ThrSystemBusApiEntity; -import com.glxp.mipsdl.http.HttpClient; -import com.glxp.mipsdl.req.base.UdiwmsOrderRequest; -import com.glxp.mipsdl.req.base.UdiwmsProductRequest; -import com.glxp.mipsdl.res.BaseResponse; -import com.glxp.mipsdl.res.PageSimpleResponse; -import com.glxp.mipsdl.res.udiwms.ThrProductsResponse; -import com.glxp.mipsdl.service.thrsys.ThrSystemDetailService; -import com.glxp.mipsdl.util.DateUtil; -import com.glxp.mipsdl.util.ResultVOUtils; -import com.glxp.mipsdl.util.SubmitOrderUtil; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - - -/** - * 平潭协和医院HIS系统接口 - */ -@Slf4j -@Service(value = "100009HttpClient") -public class PtxhyyHisClient extends CommonHttpClient { - - @Resource - private HttpClient httpClient; - @Resource - private ThirdSysConfig thirdSysConfig; - @Autowired - private ThrSystemDetailService thrSystemDetailService; - - @Override - public BaseResponse getProducts(UdiwmsProductRequest udiwmsProductRequest) { - - HisFyRequest hisFyRequest = new HisFyRequest(); - hisFyRequest.setFyxh(udiwmsProductRequest.getCode()); - hisFyRequest.setFymc(udiwmsProductRequest.getName()); - String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_PI_QUERY_URL), hisFyRequest); - BaseResponse> baseResponse = JSONObject.parseObject(response, new TypeReference>>() { - }); - List thrProductsResponses = new ArrayList<>(); - List hisProductEntities = baseResponse.getData().getList(); - if (CollUtil.isNotEmpty(hisProductEntities)) { - for (HisProductEntity hisProductEntity : hisProductEntities) { - ThrProductsResponse thrProductsResponse = new ThrProductsResponse(); - thrProductsResponse.setCode(hisProductEntity.getFyxh()); - thrProductsResponse.setName(hisProductEntity.getFymc()); - thrProductsResponse.setFlbm(hisProductEntity.getFygb()); - thrProductsResponse.setPrice(hisProductEntity.getFydj()); - thrProductsResponse.setQtbm(hisProductEntity.getSm()); - thrProductsResponse.setCpms(hisProductEntity.getSfmc()); - thrProductsResponse.setMeasname(hisProductEntity.getFydw()); - thrProductsResponses.add(thrProductsResponse); - } - } - PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setList(thrProductsResponses); - pageSimpleResponse.setTotal(-666l); //表示全量下载 - return ResultVOUtils.success(pageSimpleResponse); - } - - @Resource - private IoOrderDao orderDao; - @Resource - private ThrSystemBusApiDao thrSystemBusApiDao; - @Resource - private BasicBussinessTypeDao basicBussinessTypeDao; - @Resource - private IoCodeDao codeDao; - @Resource - private IoOrderDetailBizDao orderDetailBizDao; - @Resource - private BasicUdirelDao basicUdirelDao; - @Resource - private BasicProductsDao basicProductsDao; - @Resource - private SubmitOrderUtil submitOrderUtil; - - @Override - public BaseResponse submitOrders(UdiwmsOrderRequest udiwmsOrderRequest) { - if (StrUtil.isBlank(udiwmsOrderRequest.getBillNo())) { - return ResultVOUtils.error(500, "单据号不能为空"); - } - //查询单据和详情信息,组装第三方系统接口参数 - IoOrderEntity orderEntity = orderDao.selectOne(new LambdaQueryWrapper().eq(IoOrderEntity::getBillNo, udiwmsOrderRequest.getBillNo())); - udiwmsOrderRequest.setBillDate(DateUtil.formatDateTime(orderEntity.getCreateTime())); - //查询对应的第三方单据类型 - ThrSystemBusApiEntity thrSystemBusApiEntity = thrSystemBusApiDao.selectOne(new LambdaQueryWrapper().eq(ThrSystemBusApiEntity::getCode, udiwmsOrderRequest.getBillType())); - if (StrUtil.isBlank(thrSystemBusApiEntity.getUrl())) { - return ResultVOUtils.error(500, "接口未配置,无法提交!"); - } - - PostHisRequest postHisRequest = new PostHisRequest(); - - //查询单据类型,设置往来单位信息 - BasicBussinessTypeEntity basicBussinessTypeEntity = basicBussinessTypeDao.selectByAction(orderEntity.getAction()); - if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_HOSPTIAL)) { - //医院客户 - postHisRequest.setZyh(orderEntity.getFromCorp()); - } else { - return ResultVOUtils.error(500, "非使用出库单据"); - } - - //组装单据明细数据 - List ioCodeEntities = codeDao.selectList(new LambdaQueryWrapper() - .eq(IoCodeEntity::getOrderId, orderEntity.getBillNo()) - ); - List items = new ArrayList<>(); - //查询业务单据详情 - List detailBizEntities = orderDetailBizDao.selectList(new LambdaQueryWrapper().eq(IoOrderDetailBizEntity::getOrderIdFk, orderEntity.getBillNo())); - for (IoOrderDetailBizEntity orderDetailBizEntity : detailBizEntities) { - List codeEntities = filterCodes(orderDetailBizEntity, ioCodeEntities); - String udibm = codeEntities.stream().map(IoCodeEntity::getCode).collect(Collectors.joining(",")); - PostHisDetailRequest postHisDetailRequest = new PostHisDetailRequest(); - postHisDetailRequest.setUdibm(udibm); - BasicUdirelEntity basicUdirel = basicUdirelDao.selectById(orderDetailBizEntity.getBindRlFk()); - BasicProductsEntity basicProducts = basicProductsDao.selectOne(new LambdaQueryWrapper().eq(BasicProductsEntity::getUuid, basicUdirel.getUuid())); - String thirdProductId = (String) ReflectUtil.getFieldValue(basicUdirel, thirdSysConfig.getThirdId()); - postHisDetailRequest.setYldj(basicProducts.getPrice() + ""); - postHisDetailRequest.setYlsl(orderDetailBizEntity.getReCount() + ""); - postHisDetailRequest.setYlxh(thirdProductId); - items.add(postHisDetailRequest); - } - postHisRequest.setDetailList(items); - return submitOrderUtil.submitOrder(orderEntity, postHisRequest); - } - - - public List filterCodes(IoOrderDetailBizEntity orderDetailBizEntity, List codeEntities) { - List result = new ArrayList<>(); - if (CollUtil.isNotEmpty(codeEntities)) { - for (IoCodeEntity codeEntity : codeEntities) { - if ((codeEntity.getRelId() + "").equals(orderDetailBizEntity.getBindRlFk()) - && StrUtil.trimToEmpty(codeEntity.getBatchNo()).equals(StrUtil.trimToEmpty(orderDetailBizEntity.getBatchNo()))) { - result.add(codeEntity); - } - } - } - return result; - } -} diff --git a/src/main/java/com/glxp/mipsdl/client/ptxhyy/PtxhyyHisFileClient.java b/src/main/java/com/glxp/mipsdl/client/ptxhyy/PtxhyyHisFileClient.java deleted file mode 100644 index f3cdb6e..0000000 --- a/src/main/java/com/glxp/mipsdl/client/ptxhyy/PtxhyyHisFileClient.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.glxp.mipsdl.client.ptxhyy; - -import cn.hutool.core.thread.ThreadUtil; -import com.glxp.mipsdl.client.BaseFileClient; -import com.glxp.mipsdl.client.CommonFileClient; -import com.glxp.mipsdl.req.post.PostThrProductsRequest; -import com.glxp.mipsdl.res.BaseResponse; -import com.glxp.mipsdl.res.udiwms.UdiwmsProductInfoResponse; -import com.glxp.mipsdl.service.file.UdiInfoUploadService; -import com.glxp.mipsdl.util.ExcelUtil; -import com.glxp.mipsdl.util.ExecutorUtil; -import com.glxp.mipsdl.util.ResultVOUtils; -import com.glxp.mipsdl.vo.file.ptxhyy.PtxhyyHisProductEntity; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; - -import javax.annotation.Resource; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - -/** - * 平潭协和医院His文件接口 - */ -@Slf4j -@Service(value = "100009FileClient") -public class PtxhyyHisFileClient extends CommonFileClient { - - @Resource - private UdiInfoUploadService udiInfoUploadService; - @Resource - private ExecutorUtil executorUtil; - - @Override - public BaseResponse uploadPi(List files, String thirdSys) { - for (int i = 0; i < files.size(); i++) { - MultipartFile file = files.get(i); - if (file.isEmpty()) { - return ResultVOUtils.error(500, "上传第" + (i++) + "个文件失败"); - } - try { - InputStream inputStream = file.getInputStream(); - ExcelUtil util = new ExcelUtil(PtxhyyHisProductEntity.class); - List udiwmsProductInfoResponses = util.importPi(inputStream); - PostThrProductsRequest postThrProductsRequest = new PostThrProductsRequest(); - postThrProductsRequest.setDatas(udiwmsProductInfoResponses); - postThrProductsRequest.setUploadType("文件导入"); - postThrProductsRequest.setThirdSys(thirdSys); - executorUtil.getUploadExecutor().execute(ThreadUtil.newThread(() -> { - udiInfoUploadService.postProducts(postThrProductsRequest); - }, "uploadPi")); - log.error("上传完" + System.currentTimeMillis()); - } catch (IOException e) { - log.error("解析上传excel文件IO异常,异常信息:{}", e); - return ResultVOUtils.error(500, "数据异常"); - } catch (Exception e) { - log.error("处理产品信息excel文件异常,异常信息:{}", e); - return ResultVOUtils.error(500, "数据异常"); - } - } - return ResultVOUtils.success("文件解析成功,正在上传,请稍后刷新查看"); - } -} diff --git a/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/DictHslbEntity.java b/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/DictHslbEntity.java deleted file mode 100644 index fe356a5..0000000 --- a/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/DictHslbEntity.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.glxp.mipsdl.client.ptxhyy.entity; - -import lombok.Data; - -@Data -public class DictHslbEntity { - private Integer hslb; - private String hsmc; - private String hsbm; -} diff --git a/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/HisFyRequest.java b/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/HisFyRequest.java deleted file mode 100644 index 320da58..0000000 --- a/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/HisFyRequest.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.glxp.mipsdl.client.ptxhyy.entity; - -import lombok.Data; - -@Data -public class HisFyRequest { - - - private String fyxh; - private String fymc; - private String fygb; - private String sm; -} diff --git a/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/HisProductEntity.java b/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/HisProductEntity.java deleted file mode 100644 index 38b355a..0000000 --- a/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/HisProductEntity.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.glxp.mipsdl.client.ptxhyy.entity; - -import lombok.Data; - -@Data -public class HisProductEntity { - - //费用序号 - private String fyxh; - //费用单位 - private String fydw; - //费用名称 - private String fymc; - //费用单价 - private String fydj; - private String sm; - private String sfmc; - private String fygb; - private String fygbmc; - private String RN; - private String zfpb; -} diff --git a/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/OrderUploadResponse.java b/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/OrderUploadResponse.java deleted file mode 100644 index 13bcdf0..0000000 --- a/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/OrderUploadResponse.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.glxp.mipsdl.client.ptxhyy.entity; - -import lombok.Data; - -@Data -public class OrderUploadResponse { - - private String djxh; -} diff --git a/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/PostHisDetailRequest.java b/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/PostHisDetailRequest.java deleted file mode 100644 index d53640e..0000000 --- a/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/PostHisDetailRequest.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.glxp.mipsdl.client.ptxhyy.entity; - -import lombok.Data; - -@Data -public class PostHisDetailRequest { - // 费用序号 - private String ylxh; - // 单价 - private String yldj; - // 数量 - private String ylsl; - // UDI编码 - private String udibm; - -} diff --git a/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/PostHisRequest.java b/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/PostHisRequest.java deleted file mode 100644 index 0c33b7a..0000000 --- a/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/PostHisRequest.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.glxp.mipsdl.client.ptxhyy.entity; - -import lombok.Data; - -import java.util.List; - -@Data -public class PostHisRequest { - - private String zyh; - private List detailList; -} diff --git a/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/ThrHslbEntity.java b/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/ThrHslbEntity.java deleted file mode 100644 index 1e57765..0000000 --- a/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/ThrHslbEntity.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.glxp.mipsdl.client.ptxhyy.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import java.io.Serializable; -import lombok.Data; - -@Data -@TableName(value = "thr_hslb") -public class ThrHslbEntity implements Serializable { - @TableField(value = "hslb") - private String hslb; - - @TableField(value = "hsmc") - private String hsmc; - - @TableField(value = "hsbm") - private String hsbm; - - private static final long serialVersionUID = 1L; -} diff --git a/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/ThrHslbService.java b/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/ThrHslbService.java deleted file mode 100644 index d3f3375..0000000 --- a/src/main/java/com/glxp/mipsdl/client/ptxhyy/entity/ThrHslbService.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.glxp.mipsdl.client.ptxhyy.entity; - -import com.glxp.mipsdl.dao.ptxyy.ThrHslbMapper; -import org.springframework.stereotype.Service; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - -@Service -public class ThrHslbService extends ServiceImpl { -} diff --git a/src/main/java/com/glxp/mipsdl/client/zaxyy/ZaxyyClient.java b/src/main/java/com/glxp/mipsdl/client/zaxyy/ZaxyyClient.java deleted file mode 100644 index ac4d9c4..0000000 --- a/src/main/java/com/glxp/mipsdl/client/zaxyy/ZaxyyClient.java +++ /dev/null @@ -1,672 +0,0 @@ -package com.glxp.mipsdl.client.zaxyy; - -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 cn.hutool.json.JSONUtil; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.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.CommonHttpClient; -import com.glxp.mipsdl.config.ThirdSysConfig; -import com.glxp.mipsdl.constant.ConstantType; -import com.glxp.mipsdl.constant.Constants; -import com.glxp.mipsdl.dao.auth.AuthUserDao; -import com.glxp.mipsdl.dao.auth.AuthWarehouseDao; -import com.glxp.mipsdl.dao.auth.AuthWarehouseUserMapper; -import com.glxp.mipsdl.dao.basic.BasicBussinessTypeDao; -import com.glxp.mipsdl.dao.basic.BasicCorpDao; -import com.glxp.mipsdl.dao.inout.*; -import com.glxp.mipsdl.dao.thrsys.ThrInvWarehouseDao; -import com.glxp.mipsdl.dao.thrsys.ThrOrderUploadBustypesMapper; -import com.glxp.mipsdl.dao.thrsys.ThrSystemBusApiDao; -import com.glxp.mipsdl.entity.auth.AuthUserEntity; -import com.glxp.mipsdl.entity.auth.AuthWarehouseEntity; -import com.glxp.mipsdl.entity.auth.AuthWarehouseUser; -import com.glxp.mipsdl.entity.basic.BasicBussinessTypeEntity; -import com.glxp.mipsdl.entity.basic.BasicCorpEntity; -import com.glxp.mipsdl.entity.inout.*; -import com.glxp.mipsdl.entity.thrsys.ThrInvWarehouseEntity; -import com.glxp.mipsdl.entity.thrsys.ThrOrderUploadBustypesEntity; -import com.glxp.mipsdl.entity.thrsys.ThrSystemBusApiEntity; -import com.glxp.mipsdl.http.HttpClient; -import com.glxp.mipsdl.req.base.*; -import com.glxp.mipsdl.req.post.*; -import com.glxp.mipsdl.req.zaxyy.ZaZyRequest; -import com.glxp.mipsdl.req.zaxyy.ZaxzyyOrderRequest; -import com.glxp.mipsdl.res.BaseResponse; -import com.glxp.mipsdl.res.udiwms.ZzzyyProductsResponse; -import com.glxp.mipsdl.service.auth.AuthWarehouseService; -import com.glxp.mipsdl.service.order.OrderUploadLogService; -import com.glxp.mipsdl.service.thrsys.ThrCorpService; -import com.glxp.mipsdl.service.thrsys.ThrSystemDetailService; -import com.glxp.mipsdl.util.DateUtil; -import com.glxp.mipsdl.util.IntUtil; -import com.glxp.mipsdl.util.ResultVOUtils; -import com.glxp.mipsdl.util.SubmitOrderUtil; -import lombok.extern.slf4j.Slf4j; -import org.dom4j.Document; -import org.dom4j.DocumentException; -import org.dom4j.DocumentHelper; -import org.springframework.beans.BeanUtils; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * 诏安县医院,智业V1接口对接 - */ -@Slf4j -@Service(value = "100003HttpClient") //bean注册名称,使用编码 + HttpClient,文件接口加 FileClient -public class ZaxyyClient extends CommonHttpClient { - - @Resource - private ThrSystemDetailService thrSystemDetailService; - @Resource - private HttpClient httpClient; - @Resource - private IoOrderDao orderDao; - @Resource - private ThrSystemBusApiDao thrSystemBusApiDao; - @Resource - private AuthUserDao authUserDao; - @Resource - private BasicBussinessTypeDao basicBussinessTypeDao; - @Resource - private BasicCorpDao basicCorpDao; - @Resource - private IoCodeDao codeDao; - @Resource - private AuthWarehouseDao authWarehouseDao; - @Resource - private ThrInvWarehouseDao thrInvWarehouseDao; - @Resource - private AuthWarehouseService authWarehouseService; - @Resource - private ThirdSysConfig thirdSysConfig; - @Resource - private ThrCorpService thrCorpService; - @Resource - private IoOrderDetailBizDao orderDetailBizDao; - @Resource - private IoOrderDetailCodeDao orderDetailCodeDao; - - - @Resource - private IoOrderUploadLogDao orderUploadLogDao; - @Resource - private SubmitOrderUtil submitOrderUtil; - @Resource - AuthWarehouseUserMapper authWarehouseUserMapper; - @Resource - private ThrOrderUploadBustypesMapper thrOrderUploadBustypesMapper; - - /** - * 拼接xml请求头 - * - * @param methodName 方法名 - * @return - */ - public String getMsgHeader(String methodName) { - return "" + - "" + - "" + - methodName + - "" + - ""; - } - - public String parserResult(String response) { - if (response.contains(" zzzyyProductsResponse = JSON.parseArray(map.get("list") + "", ZzzyyProductsResponse.class); - for (ZzzyyProductsResponse productsResponse : zzzyyProductsResponse) { - //判断要是规格和型号一致就是取规格 不一致就合并 - if (StrUtil.isNotEmpty(productsResponse.getModel_number()) && StrUtil.isNotEmpty(productsResponse.getStandard())) { - if (productsResponse.getModel_number().equals(productsResponse.getStandard())) { - productsResponse.setStandard(productsResponse.getStandard()); - } else { - productsResponse.setStandard(productsResponse.getStandard() + productsResponse.getModel_number()); - } - } else if (StrUtil.isNotEmpty(productsResponse.getModel_number()) && StrUtil.isBlank(productsResponse.getStandard())) { - productsResponse.setStandard(productsResponse.getModel_number()); - } - } - map.put("list", JSON.toJSON(zzzyyProductsResponse)); - baseResponse.setData(""); - baseResponse.setData(map); - return baseResponse; - } catch (Exception e) { - log.error("解析诏安智业接口返回产品信息字典数据异常,返回结果:{}", response); - log.error("异常信息:{}", e); - return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")"); - } - } - - @Override - public BaseResponse getOrderTypes(UdiwmsBusTypeRequest udiwmsBusTypeRequest) { - ZaZyRequest zaZyRequest = new ZaZyRequest(); - zaZyRequest.setMsgHeader(getMsgHeader("getMaterialType")); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsBusTypeRequest)); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_BUS_TYPE_QUERY_URL), zaZyRequest); - response = parserResult(response); - try { - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } catch (Exception e) { - log.error("解析诏安智业接口返回单据类型数据异常,返回结果:{}", response); - log.error("异常信息:{}", e); - return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")"); - } - } - - @Override - public BaseResponse getOrders(UdiwmsOrderQueryRequest udiwmsOrderQueryRequest) { - ZaZyRequest zaZyRequest = new ZaZyRequest(); - zaZyRequest.setMsgHeader(getMsgHeader("getMaterialApply")); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsOrderQueryRequest)); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_BUS_TYPE_QUERY_URL), zaZyRequest); - response = parserResult(response); - try { - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } catch (Exception e) { - log.error("解析诏安智业接口返回单据类型数据异常,返回结果:{}", response); - log.error("异常信息:{}", e); - return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")"); - } - } - - @Resource - private OrderUploadLogService orderUploadLogService; - - @Override - public BaseResponse submitOrders(UdiwmsOrderRequest udiwmsOrderRequest) { - if (StrUtil.isBlank(udiwmsOrderRequest.getBillNo())) { - return ResultVOUtils.error(500, "单据号不能为空"); - } - - ZaxzyyOrderRequest zaxzyyOrderRequest = new ZaxzyyOrderRequest(); - BeanUtil.copyProperties(udiwmsOrderRequest, zaxzyyOrderRequest); - //查询单据和详情信息,组装第三方系统接口所需参数 - IoOrderEntity orderEntity = orderDao.selectOne(new QueryWrapper().eq("billNo", udiwmsOrderRequest.getBillNo()).last("limit 1")); - zaxzyyOrderRequest.setBillDate(DateUtil.formatDateTime(orderEntity.getCreateTime())); - //查询对应的第三方单据类型 - ThrSystemBusApiEntity thrSystemBusApiEntity = thrSystemBusApiDao.selectOne(new QueryWrapper().eq("code", udiwmsOrderRequest.getBillType())); - if (StrUtil.isBlank(thrSystemBusApiEntity.getUrl())) { - return ResultVOUtils.error(500, "接口未配置,无法提交!"); - } - zaxzyyOrderRequest.setThirdSys(getUserName(orderEntity)); - zaxzyyOrderRequest.setBillType(thrSystemBusApiEntity.getThirdBuyCode()); - zaxzyyOrderRequest.setBillFlag("1"); - - //查询单据类型 - BasicBussinessTypeEntity basicBussinessTypeEntity = basicBussinessTypeDao.selectByAction(udiwmsOrderRequest.getBillType()); - if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_HOSPTIAL)) { - //医院客户 - zaxzyyOrderRequest.setCorpId(orderEntity.getFromCorp()); - //查询客户名称 - String corpName = basicCorpDao.selectNameByErpId(orderEntity.getFromCorp()); - zaxzyyOrderRequest.setCorpName(corpName); - } else if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_INTTERNAL)) { - //内部科室 - BasicCorpEntity basicCorpEntity = null; - if (StrUtil.isNotEmpty(orderEntity.getFromCorp())) { - basicCorpEntity = basicCorpDao.selectByErpId(orderEntity.getFromCorp()); - } - if (basicCorpEntity != null) { - zaxzyyOrderRequest.setCorpId(basicCorpEntity.getThirdId()); - zaxzyyOrderRequest.setCorpName(basicCorpEntity.getName()); - } else { - AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new QueryWrapper().eq("code", udiwmsOrderRequest.getCorpId())); - try { - //根据第三方系统标识,获取对应字段的值 - ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper() - .eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity)) - .eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId())); - - zaxzyyOrderRequest.setCorpId(thrInvWarehouseEntity.getCode()); - zaxzyyOrderRequest.setCorpName(thrInvWarehouseEntity.getName()); - } catch (Exception e) { - log.error("查询单据对应往来单位的第三方仓库信息异常", e); - } - } - - } else if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_SP)) { - //供应商 - BasicCorpEntity basicCorpEntity = null; - if (StrUtil.isNotEmpty(orderEntity.getFromCorp())) { - basicCorpEntity = basicCorpDao.selectByErpId(orderEntity.getFromCorp()); - } - if (basicCorpEntity != null) { - zaxzyyOrderRequest.setCorpId(basicCorpEntity.getThirdId()); - zaxzyyOrderRequest.setCorpName(basicCorpEntity.getName()); - } else { - log.error("查询单据对应的第三方往来单位信息异常"); - } - } - - - //查询仓库信息 - AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new QueryWrapper().eq("code", orderEntity.getInvCode())); - try { - ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper() - .eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity)) - .eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId())); - - if (thrInvWarehouseEntity != null) { - zaxzyyOrderRequest.setLocInvCode(thrInvWarehouseEntity.getCode()); - zaxzyyOrderRequest.setLocInvName(thrInvWarehouseEntity.getName()); - - zaxzyyOrderRequest.setLocStorageCode(thrInvWarehouseEntity.getCode()); - zaxzyyOrderRequest.setLocStorageName(thrInvWarehouseEntity.getName()); - } else { - orderUploadLogService.updateLocalErr(orderEntity, "查询第三方系统仓库信息异常"); - return ResultVOUtils.error(500, "查询第三方系统仓库信息异常"); - } - - } catch (Exception e) { - log.error("查询第三方系统仓库信息异常", ExceptionUtil.stacktraceToString(e)); - orderUploadLogService.updateLocalErr(orderEntity, "查询第三方系统仓库信息异常" + ExceptionUtil.stacktraceToString(e)); - return ResultVOUtils.error(500, "查询第三方系统仓库信息异常"); - } - - //设置单据出入库类型 - if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_PUT)) { - zaxzyyOrderRequest.setInoutType(1); //入库 - } else if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT)) { - zaxzyyOrderRequest.setInoutType(2); //出库 - } - - //设置备注信息 - zaxzyyOrderRequest.setRemark("udi管理系统提交单据"); - //组装单据明细数据 - List ioCodeEntities = codeDao.selectList(new QueryWrapper() - .eq("orderId", orderEntity.getBillNo()) - .ne("action", "StockCheck") - ); - List items = new ArrayList<>(); - //查询业务单据详情 - List detailBizEntities = orderDetailBizDao.selectList(new QueryWrapper().eq("orderIdFk", orderEntity.getBillNo())); - setOrderDetailList(ioCodeEntities, items, detailBizEntities); - zaxzyyOrderRequest.setItem(items); - if (CollUtil.isEmpty(items)) { - log.error("\"产品信息对照异常,无法上传\""); - orderUploadLogService.updateLocalErr(orderEntity, "产品信息对照异常,无法上传"); - return ResultVOUtils.error(500, "产品信息对照异常,无法上传"); - } - - for (UdiwmsOrderDetailRequest i : items) { - String fphm = ""; - String fprq = null; - List invoiceList = IoOrderInvoiceEntity.builder().build() - .selectList(Wrappers.lambdaQuery(IoOrderInvoiceEntity.class).eq(IoOrderInvoiceEntity::getOrderIdFk, orderEntity.getBillNo()) - .eq(IoOrderInvoiceEntity::getBindRlFk, i.getBindRlFk()) - .eq(StrUtil.isNotEmpty(i.getBatchNo()), IoOrderInvoiceEntity::getBatchNo, i.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()); - } - i.setFirstSalesInvNo(fphm); - i.setSecSalesInvNo(fphm); - i.setInvoiceDate(fprq); - boolean isNeedFp = false; - ThrOrderUploadBustypesEntity thrOrderUploadBustypesEntity = thrOrderUploadBustypesMapper.selectOne(new QueryWrapper().eq("action", basicBussinessTypeEntity.getAction()).last("limit 1")); - if (thrOrderUploadBustypesEntity != null && IntUtil.value(thrOrderUploadBustypesEntity.getOrderStatus()) == 3) { - isNeedFp = true; - } - if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_PUT) && StrUtil.isEmpty(fphm) && isNeedFp) { - String errMsg = "提交失败,错误信息:" + i.getProductName() + "发票缺失,请补齐后重新提交"; - orderUploadLogService.updateLocalErr(orderEntity, errMsg); - return ResultVOUtils.error(500, errMsg); - } - } - - - //构造诏安接口参数 - ZaZyRequest zaZyRequest = new ZaZyRequest(); -// - //提交到第三方系统 - if (thrSystemBusApiEntity.getUrl().equals("saveMasterialInput")) { - //采购入库单据 - zaZyRequest.setMsgHeader(getMsgHeader("saveMasterialInput")); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(zaxzyyOrderRequest)); - return submitOrder(orderEntity, zaZyRequest); - } else if (thrSystemBusApiEntity.getUrl().equals("saveMaterialHight")) { -// 1.先提交到物资; -// zaZyRequest.setMsgHeader(getMsgHeader("saveMasterialInput")); -// zaZyRequest.setMsgBody(JSONUtil.toJsonStr(zaxzyyOrderRequest)); -// submitOrder(orderEntity, zaZyRequest); -// 2.提交到预备货 - zaxzyyOrderRequest.setLocStorageCode("1001304"); - zaxzyyOrderRequest.setLocStorageName("骨科耗材及试剂仓库"); - zaZyRequest.setMsgHeader(getMsgHeader("saveMaterialHight")); - UdiwmsPreInOrderRequest udiwmsPreInOrderRequest = submitPreInOrderToThirdSys(zaxzyyOrderRequest, orderEntity); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsPreInOrderRequest)); - return submitOrder(orderEntity, zaZyRequest); - } - return ResultVOUtils.error(500, "提交失败!"); - } - - public String getUserName(IoOrderEntity orderEntity) { - AuthUserEntity authUserEntity = null; - //创建人非供应商 - if (StrUtil.isNotEmpty(orderEntity.getReviewUser())) { - authUserEntity = authUserDao.selectById(orderEntity.getReviewUser()); - } else if (StrUtil.isNotEmpty(orderEntity.getCreateUser()) && orderEntity.getCreateUser().length() != 14) { - authUserEntity = authUserDao.selectById(orderEntity.getCreateUser()); - } else if (StrUtil.isNotEmpty(orderEntity.getUpdateUser()) && orderEntity.getUpdateUser().length() != 14) { - authUserEntity = authUserDao.selectById(orderEntity.getUpdateUser()); - } else { - List authWarehouseUsers = authWarehouseUserMapper.selectList(new QueryWrapper().eq("code", orderEntity.getInvCode())); - if (CollUtil.isNotEmpty(authWarehouseUsers)) { - return authWarehouseUsers.get(0).getUserName(); - } - } - if (authUserEntity != null) - return authUserEntity.getUserName(); - return null; - } - - /** - * 处理提交单据,记录日志,解析结果逻辑 - * - * @param orderEntity - * @param zaZyRequest - * @return - */ - private BaseResponse submitOrder(IoOrderEntity orderEntity, ZaZyRequest zaZyRequest) { - //记录日志 - 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); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_ORDER_SUBMIT_URL), zaZyRequest); - response = parserResult(response); - if (StrUtil.isNotBlank(response)) { - try { - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - if (baseResponse.getCode() == 20000) { - String thirdBillNo = String.valueOf(baseResponse.getData()); - orderEntity.setThirdBillNo(thirdBillNo); - orderEntity.setExportStatus(1); //提交成功 - uploadLog.setStatus(2); - uploadLog.setThrBillNo(thirdBillNo); - uploadLog.setResult("提交成功"); - orderDao.updateById(orderEntity); - orderUploadLogDao.insert(uploadLog); - return ResultVOUtils.success("提交成功"); - } - uploadLog.setStatus(3); - uploadLog.setResult("提交失败,错误信息:" + baseResponse.getMessage()); - orderEntity.setExportStatus(2); //上传失败 - orderDao.updateById(orderEntity); - orderUploadLogDao.insert(uploadLog); - return baseResponse; - } catch (Exception e) { - log.error("解析提交到智业单据返回结果异常,结果信息:{}", response); - log.error("异常信息:{}", e); - uploadLog.setStatus(3); - uploadLog.setResult("提交失败,错误信息:" + response); - orderEntity.setExportStatus(2); //上传失败 - orderDao.updateById(orderEntity); - orderUploadLogDao.insert(uploadLog); - return ResultVOUtils.error(500, "提交失败"); - } - } else { - uploadLog.setStatus(3); - uploadLog.setResult("提交失败,调用接口返回为空"); - orderEntity.setExportStatus(2); //上传失败 - orderDao.updateById(orderEntity); - orderUploadLogDao.insert(uploadLog); - return ResultVOUtils.error(500, "提交失败"); - } - } - - - /** - * 封装单据详情参数 - * - * @param ioCodeEntities 单据码明细 - * @param orderDetailRequests 单据详情参数 - * @param detailBizEntities 单据业务详情 - */ - private void setOrderDetailList(List ioCodeEntities, List orderDetailRequests, List detailBizEntities) { - for (IoOrderDetailBizEntity detailBizEntity : detailBizEntities) { - - IoOrderDetailCodeEntity orderDetailCodeEntity = orderDetailCodeDao - .selectOne(new QueryWrapper() - .eq("orderIdFk", detailBizEntity.getOrderIdFk()) - .eq("bindRlFk", detailBizEntity.getBindRlFk()) - .eq(StrUtil.isNotEmpty(detailBizEntity.getBatchNo()), "batchNo", detailBizEntity.getBatchNo()) - .isNull(StrUtil.isEmpty(detailBizEntity.getBatchNo()), "batchNo").last("LIMIT 1")); - if (orderDetailCodeEntity != null && IntUtil.value(orderDetailCodeEntity.getReCount()) > 0) { - detailBizEntity.setCount(orderDetailCodeEntity.getReCount()); - UdiwmsOrderDetailRequest item = submitOrderUtil.buildProductInfo(detailBizEntity); - if (item != null) { - //封装条码信息 - submitOrderUtil.setCodeList(ioCodeEntities, detailBizEntity, item); - orderDetailRequests.add(item); - } - } - } - } - - @Override - public BaseResponse getInvProducts(UdiwmsInvProductsRequest udiwmsInvProductsRequest) { - ZaZyRequest zaZyRequest = new ZaZyRequest(); - zaZyRequest.setMsgHeader(getMsgHeader("getMaterialStorage")); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsInvProductsRequest)); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_INV_PI_URL), zaZyRequest); - response = parserResult(response); - try { - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } catch (Exception e) { - log.error("解析诏安智业接口返回库存产品数据异常,返回结果:{}", response); - log.error("异常信息:{}", e); - return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")"); - } - } - - @Override - public BaseResponse getWarehouse(UdiwmsWarehouseRequest udiwmsWarehouseRequest) { - ZaZyRequest zaZyRequest = new ZaZyRequest(); - zaZyRequest.setMsgHeader(getMsgHeader("getMaterialDept")); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsWarehouseRequest)); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_WAREHOUSE_QUERY_URL), zaZyRequest); - response = parserResult(response); - try { - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } catch (Exception e) { - log.error("解析诏安智业接口返回仓库(科室)数据异常,返回结果:{}", response); - log.error("异常信息:{}", e); - return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")"); - } - } - - @Override - public BaseResponse postProducts(PostThrProductsRequest postThrProductsRequest) { - postThrProductsRequest.setUploadType("文件导入"); - String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostPiUrl(), postThrProductsRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse postCorps(PostThrCorpRequest postThrCorpRequest) { - postThrCorpRequest.setUploadType("文件导入"); - String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostCorpUrl(), postThrCorpRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse postOrderDetail(PostFileThrOrderRequest postFileThrOrderRequest) { - postFileThrOrderRequest.setUploadType("文件导入"); - String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostOrderUrl(), postFileThrOrderRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse postInvProducts(PostThrInvProductsRequest postThrInvProductsRequest) { - String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostInvPiUrl(), postThrInvProductsRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse postRelProduct(PostRelProductRequest postThrInvProductsRequest) { - - - return null; - } - - @Override - public BaseResponse testConnect() { - UdiwmsUnitRequest udiwmsUnitRequest = new UdiwmsUnitRequest(); - udiwmsUnitRequest.setPage(1); - udiwmsUnitRequest.setLimit(1); - BaseResponse baseResponse = getUnit(udiwmsUnitRequest); - if (baseResponse.getCode() == 20000) { - return ResultVOUtils.success("连接成功!"); - } - return ResultVOUtils.error(500, "连接失败!"); - } - - @Override - public BaseResponse queryUdiInvProducts(UdiwmsQueryUdiInvProductsRequest queryUdiInvProductsRequest) { - String response = httpClient.postUDIWMSJson(thirdSysConfig.getQueryInvUrl(), queryUdiInvProductsRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse submitProducts(UdiwmsAddProductsRequest udiwmsAddProductsRequest) { - return null; - } - - @Override - public BaseResponse submitUnit(UdiwmsAddUnitRequest udiwmsAddUnitRequest) { - return null; - } - - @Override - public BaseResponse submitPreInOrders(UdiwmsPreInOrderRequest udiwmsPreInOrderRequest) { - ZaZyRequest zaZyRequest = new ZaZyRequest(); - zaZyRequest.setMsgHeader(getMsgHeader("saveMaterialHight")); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsPreInOrderRequest)); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_PRE_IN_ORDER_SUBMIT_URL), zaZyRequest); - response = parserResult(response); - try { - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } catch (Exception e) { - log.error("解析诏安智业接口提交单据返回数据异常,返回结果:{}", response); - log.error("异常信息:{}", e); - return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")"); - } - } - - - /** - * 转换提交单据参数 - * - * @param udiwmsOrderRequest - * @param orderEntity - * @return - */ - public UdiwmsPreInOrderRequest submitPreInOrderToThirdSys(ZaxzyyOrderRequest udiwmsOrderRequest, IoOrderEntity orderEntity) { - UdiwmsPreInOrderRequest udiwmsPreInOrderRequest = new UdiwmsPreInOrderRequest(); - if (udiwmsOrderRequest != null) { - BeanUtils.copyProperties(udiwmsOrderRequest, udiwmsPreInOrderRequest); - udiwmsPreInOrderRequest.setLocInvCode(udiwmsOrderRequest.getLocStorageCode()); - udiwmsPreInOrderRequest.setLocInvName(udiwmsOrderRequest.getLocStorageName()); - if (orderEntity.getReviewUser() != null) { - AuthUserEntity authUser = authUserDao.selectById(orderEntity.getReviewUser()); - udiwmsPreInOrderRequest.setActor(authUser.getEmployeeName()); - } else if (orderEntity.getCreateUser() != null) { - AuthUserEntity authUser = authUserDao.selectById(orderEntity.getCreateUser()); - udiwmsPreInOrderRequest.setActor(authUser.getEmployeeName()); - } - List itemDTOS = new ArrayList<>(); - if (CollUtil.isNotEmpty(udiwmsOrderRequest.getItem())) { - for (UdiwmsOrderDetailRequest udiwmsOrderDetail : udiwmsOrderRequest.getItem()) { - if (CollUtil.isNotEmpty(udiwmsOrderDetail.getCodeList())) { - for (UdiwmsOrderDetailRequest.CodeDetailEntity codeDetaiEntity : udiwmsOrderDetail.getCodeList()) { - UdiwmsPreInOrderRequest.ItemDTO itemDTO = new UdiwmsPreInOrderRequest.ItemDTO(); - BeanUtils.copyProperties(udiwmsOrderDetail, itemDTO); - String code = codeDetaiEntity.getCode(); - if (code.contains("\u001D")) { -// code = code.replace("\u001D", "zysoft"); 智业无法识别GS1符号 - code = code.replace("\u001D", ""); - } - itemDTO.setCode(code); - itemDTO.setNameCode(code.substring(0, 16)); - itemDTO.setCount(codeDetaiEntity.getCount()); - itemDTOS.add(itemDTO); - - } - } - } - } - udiwmsPreInOrderRequest.setItems(itemDTOS); - } - return udiwmsPreInOrderRequest; - } - - -} diff --git a/src/main/java/com/glxp/mipsdl/client/zaxyy/ZazyyFileClient.java b/src/main/java/com/glxp/mipsdl/client/zaxyy/ZazyyFileClient.java deleted file mode 100644 index e7d1eb6..0000000 --- a/src/main/java/com/glxp/mipsdl/client/zaxyy/ZazyyFileClient.java +++ /dev/null @@ -1,162 +0,0 @@ -package com.glxp.mipsdl.client.zaxyy; - -import cn.hutool.core.thread.ThreadUtil; -import com.glxp.mipsdl.client.BaseFileClient; -import com.glxp.mipsdl.req.post.PostThrCorpRequest; -import com.glxp.mipsdl.req.post.PostThrProductsRequest; -import com.glxp.mipsdl.res.BaseResponse; -import com.glxp.mipsdl.res.udiwms.UdiwmsProductInfoResponse; -import com.glxp.mipsdl.res.udiwms.UdiwmsUnitResponse; -import com.glxp.mipsdl.service.file.UdiInfoUploadService; -import com.glxp.mipsdl.util.ExcelUtil; -import com.glxp.mipsdl.util.ExecutorUtil; -import com.glxp.mipsdl.util.ResultVOUtils; -import com.glxp.mipsdl.vo.file.zazyy.ZyCorpEntity; -import com.glxp.mipsdl.vo.file.zazyy.ZyProductEntity; -import lombok.extern.slf4j.Slf4j; -import org.apache.poi.ss.usermodel.CellType; -import org.apache.poi.ss.usermodel.Row; -import org.springframework.beans.BeanUtils; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; - -import javax.annotation.Resource; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -/** - * 诏安,职业V1文件规范 - */ -@Slf4j -@Service -public class ZazyyFileClient implements BaseFileClient { - - @Resource - private UdiInfoUploadService udiInfoUploadService; - @Resource - private ExecutorUtil executorUtil; - - @Override - public BaseResponse uploadPi(List files, String thirdSys) { - for (int i = 0; i < files.size(); i++) { - MultipartFile file = files.get(i); - if (file.isEmpty()) { - return ResultVOUtils.error(500, "上传第" + (i++) + "个文件失败"); - } - try { - InputStream inputStream = file.getInputStream(); - ExcelUtil util = new ExcelUtil(ZyProductEntity.class); - List zyProductEntities = util.importExcel(inputStream); - List udiwmsProductInfoResponses = new ArrayList<>(); - for (ZyProductEntity zyProductEntity : zyProductEntities) { - UdiwmsProductInfoResponse udiwmsProductInfoResponse = new UdiwmsProductInfoResponse(); - BeanUtils.copyProperties(zyProductEntity, udiwmsProductInfoResponse); - udiwmsProductInfoResponses.add(udiwmsProductInfoResponse); - } - PostThrProductsRequest postThrProductsRequest = new PostThrProductsRequest(); - postThrProductsRequest.setDatas(udiwmsProductInfoResponses); - postThrProductsRequest.setUploadType("文件导入"); - postThrProductsRequest.setThirdSys(thirdSys); - executorUtil.getUploadExecutor().execute(ThreadUtil.newThread(() -> { - udiInfoUploadService.postProducts(postThrProductsRequest); - }, "uploadPi")); - log.error("上传完" + System.currentTimeMillis()); - } catch (IOException e) { - log.error("解析上传excel文件IO异常,异常信息:{}", e); - return ResultVOUtils.error(500, "数据异常"); - } catch (Exception e) { - log.error("处理产品信息excel文件异常,异常信息:{}", e); - return ResultVOUtils.error(500, "数据异常"); - } - } - return ResultVOUtils.success("文件解析成功,正在上传,请稍后刷新查看"); - } - - @Override - public BaseResponse uploadCorps(List files, String thirdSys) { - for (int i = 0; i < files.size(); i++) { - MultipartFile file = files.get(i); - if (file.isEmpty()) { - return ResultVOUtils.error(500, "上传第" + (i++) + "个文件失败"); - } - List udiwmsUnitResponses = new ArrayList<>(); - try { - InputStream inputStream = file.getInputStream(); - ExcelUtil util = new ExcelUtil(ZyCorpEntity.class); - List zyCorpEntities = util.importExcel(inputStream); - for (ZyCorpEntity zyCorpEntity : zyCorpEntities) { - UdiwmsUnitResponse udiwmsUnitResponse = new UdiwmsUnitResponse(); - udiwmsUnitResponse.setName(zyCorpEntity.getCorpName()); - udiwmsUnitResponse.setUnitId(zyCorpEntity.getCorpCode()); - udiwmsUnitResponses.add(udiwmsUnitResponse); - } - PostThrCorpRequest postThrProductsRequest = new PostThrCorpRequest(); - postThrProductsRequest.setCorps(udiwmsUnitResponses); - postThrProductsRequest.setThirdSys(thirdSys); - executorUtil.getUploadExecutor().execute(ThreadUtil.newThread(() -> { - udiInfoUploadService.postCorps(postThrProductsRequest); - }, "uploadCorps")); - } catch (IOException e) { - log.error("解析往来单位excel文件IO异常,错误信息:{}", e); - return ResultVOUtils.error(500, "数据异常"); - } catch (Exception e) { - log.error("解析往来单位excel文件异常,异常信息:{}", e); - return ResultVOUtils.error(500, "数据异常"); - } - } - return ResultVOUtils.success("文件解析成功,正在上传,请稍后刷新查看"); - } - - @Override - public BaseResponse uploadInvPi(List files, String thirdSys) { - return ResultVOUtils.error(500, "暂不支持库存产品信息上传!"); - } - - @Override - public BaseResponse uploadOrders(List files, String thirdSys) { - return ResultVOUtils.error(500, "暂不支持业务单据上传!"); - } - - public boolean filterEmpty(Row row) { - - if (row.getCell(0) != null) { - row.getCell(0).setCellType(CellType.STRING); - } - if (row.getCell(1) != null) { - row.getCell(1).setCellType(CellType.STRING); - } - if (row.getCell(2) != null) { - row.getCell(2).setCellType(CellType.STRING); - } - if (row.getCell(3) != null) { - row.getCell(3).setCellType(CellType.STRING); - } - if (row.getCell(4) != null) { - row.getCell(4).setCellType(CellType.STRING); - } - if (row.getCell(5) != null) { - row.getCell(5).setCellType(CellType.STRING); - } - if (row.getCell(6) != null) { - row.getCell(6).setCellType(CellType.STRING); - } - if ((row.getCell(0) == null && row.getCell(1) == null && row.getCell(2) == null - && row.getCell(3) == null && row.getCell(4) == null && row.getCell(5) == null && row.getCell(6) == null) || - ( - (row.getCell(0) != null && row.getCell(1) != null && row.getCell(2) != null - && row.getCell(3) != null && row.getCell(4) != null && row.getCell(5) != null && row.getCell(6) != null) && - ("".equals(row.getCell(0).getStringCellValue()) - && "".equals(row.getCell(1).getStringCellValue()) - && "".equals(row.getCell(2).getStringCellValue()) - && "".equals(row.getCell(3).getStringCellValue()) - && "".equals(row.getCell(4).getStringCellValue()) - && "".equals(row.getCell(5).getStringCellValue()) - && "".equals(row.getCell(6).getStringCellValue())) - )) { - return true; - } - return false; - } -} diff --git a/src/main/java/com/glxp/mipsdl/client/zzzyy/ZzzyyClient.java b/src/main/java/com/glxp/mipsdl/client/zzzyy/ZzzyyClient.java deleted file mode 100644 index 1a4bd09..0000000 --- a/src/main/java/com/glxp/mipsdl/client/zzzyy/ZzzyyClient.java +++ /dev/null @@ -1,498 +0,0 @@ -package com.glxp.mipsdl.client.zzzyy; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.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.CommonHttpClient; -import com.glxp.mipsdl.config.ThirdSysConfig; -import com.glxp.mipsdl.constant.ConstantType; -import com.glxp.mipsdl.constant.Constants; -import com.glxp.mipsdl.dao.auth.AuthUserDao; -import com.glxp.mipsdl.dao.auth.AuthWarehouseDao; -import com.glxp.mipsdl.dao.auth.AuthWarehouseUserMapper; -import com.glxp.mipsdl.dao.basic.BasicBussinessTypeDao; -import com.glxp.mipsdl.dao.basic.BasicCorpDao; -import com.glxp.mipsdl.dao.inout.*; -import com.glxp.mipsdl.dao.thrsys.ThrInvWarehouseDao; -import com.glxp.mipsdl.dao.thrsys.ThrSystemBusApiDao; -import com.glxp.mipsdl.entity.auth.AuthUserEntity; -import com.glxp.mipsdl.entity.auth.AuthWarehouseEntity; -import com.glxp.mipsdl.entity.auth.AuthWarehouseUser; -import com.glxp.mipsdl.entity.basic.BasicBussinessTypeEntity; -import com.glxp.mipsdl.entity.basic.BasicCorpEntity; -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.ThrSystemBusApiEntity; -import com.glxp.mipsdl.http.HttpClient; -import com.glxp.mipsdl.req.base.*; -import com.glxp.mipsdl.req.post.*; -import com.glxp.mipsdl.req.zaxyy.ZaxzyyOrderRequest; -import com.glxp.mipsdl.res.BaseResponse; -import com.glxp.mipsdl.service.auth.AuthWarehouseService; -import com.glxp.mipsdl.service.thrsys.ThrCorpService; -import com.glxp.mipsdl.service.thrsys.ThrSystemDetailService; -import com.glxp.mipsdl.util.DateUtil; -import com.glxp.mipsdl.util.IntUtil; -import com.glxp.mipsdl.util.ResultVOUtils; -import com.glxp.mipsdl.util.SubmitOrderUtil; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.BeanUtils; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.stream.Collectors; - -/** - * 漳州中医院客户端--HIS接口对接 - */ - -@Slf4j -@Service(value = "100010HttpClient") -public class ZzzyyClient extends CommonHttpClient { - - @Resource - private ThrSystemDetailService thrSystemDetailService; - @Resource - private HttpClient httpClient; - @Resource - private IoOrderDao orderDao; - @Resource - private ThrSystemBusApiDao thrSystemBusApiDao; - @Resource - private AuthUserDao authUserDao; - @Resource - private BasicBussinessTypeDao basicBussinessTypeDao; - @Resource - private BasicCorpDao basicCorpDao; - @Resource - private IoCodeDao codeDao; - @Resource - private AuthWarehouseDao authWarehouseDao; - @Resource - private ThrInvWarehouseDao thrInvWarehouseDao; - @Resource - private AuthWarehouseService authWarehouseService; - @Resource - private ThirdSysConfig thirdSysConfig; - @Resource - private ThrCorpService thrCorpService; - @Resource - private IoOrderDetailBizDao orderDetailBizDao; - @Resource - private IoOrderDetailCodeDao orderDetailCodeDao; - - - @Resource - private IoOrderUploadLogDao orderUploadLogDao; - @Resource - private SubmitOrderUtil submitOrderUtil; - @Resource - AuthWarehouseUserMapper authWarehouseUserMapper; - - - @Override - public BaseResponse getUnit(UdiwmsUnitRequest udiwmsUnitRequest) { - String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_CORP_URL), udiwmsUnitRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse getProducts(UdiwmsProductRequest udiwmsProductRequest) { - String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_PI_QUERY_URL), udiwmsProductRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse getOrderTypes(UdiwmsBusTypeRequest udiwmsBusTypeRequest) { - String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_BUS_TYPE_QUERY_URL), udiwmsBusTypeRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse getOrders(UdiwmsOrderQueryRequest udiwmsOrderQueryRequest) { - return ResultVOUtils.error(500, "这个接口暂时没用"); - } - - @Override - public BaseResponse submitOrders(UdiwmsOrderRequest udiwmsOrderRequest) { - if (StrUtil.isBlank(udiwmsOrderRequest.getBillNo())) { - return ResultVOUtils.error(500, "单据号不能为空"); - } - ZaxzyyOrderRequest zaxzyyOrderRequest = new ZaxzyyOrderRequest(); - BeanUtil.copyProperties(udiwmsOrderRequest, zaxzyyOrderRequest); - //查询单据和详情信息,组装第三方系统接口所需参数 - IoOrderEntity orderEntity = orderDao.selectOne(new QueryWrapper().eq("billNo", udiwmsOrderRequest.getBillNo())); - - zaxzyyOrderRequest.setBillDate(DateUtil.formatDateTime(orderEntity.getCreateTime())); - //查询对应的第三方单据类型 - ThrSystemBusApiEntity thrSystemBusApiEntity = thrSystemBusApiDao.selectOne(new QueryWrapper().eq("code", orderEntity.getAction())); - if (StrUtil.isBlank(thrSystemBusApiEntity.getUrl())) { -// return ResultVOUtils.error(500, "接口未配置,无法提交!"); - } - zaxzyyOrderRequest.setThirdSys(getUserName(orderEntity)); - zaxzyyOrderRequest.setBillType(thrSystemBusApiEntity.getThirdBuyCode()); - zaxzyyOrderRequest.setBillFlag("1"); - - //查询单据类型 - BasicBussinessTypeEntity basicBussinessTypeEntity = basicBussinessTypeDao.selectByAction(orderEntity.getAction()); - - ThrCorpEntity thrCorp = thrCorpService.getThrCorp(orderEntity.getFromCorp()); - if (null != thrCorp) { - zaxzyyOrderRequest.setCorpId(thrCorp.getUnitId()); - zaxzyyOrderRequest.setCorpName(thrCorp.getName()); - } else { - log.error("查询单据对应的第三方往来单位信息异常"); - } -// if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_HOSPTIAL)) { -// //医院客户 -// zaxzyyOrderRequest.setCorpId(orderEntity.getFromCorp()); -// //查询客户名称 -// String corpName = basicCorpDao.selectNameByErpId(orderEntity.getFromCorp()); -// zaxzyyOrderRequest.setCorpName(corpName); -// } else if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_INTTERNAL)) { -// //内部科室 -// BasicCorpEntity basicCorpEntity = null; -// if (StrUtil.isNotEmpty(orderEntity.getFromCorp())) { -// basicCorpEntity = basicCorpDao.selectByErpId(orderEntity.getFromCorp()); -// } -// if (basicCorpEntity != null) { -// zaxzyyOrderRequest.setCorpId(basicCorpEntity.getThirdId()); -// zaxzyyOrderRequest.setCorpName(basicCorpEntity.getName()); -// } else { -// AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new QueryWrapper().eq("code", orderEntity.getFromCorp())); -// try { -// //根据第三方系统标识,获取对应字段的值 -// ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper() -// .eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity)) -// .eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId())); -// -// zaxzyyOrderRequest.setCorpId(thrInvWarehouseEntity.getCode()); -// zaxzyyOrderRequest.setCorpName(thrInvWarehouseEntity.getName()); -// } catch (Exception e) { -// log.error("查询单据对应往来单位的第三方仓库信息异常", e); -// } -// } -// -// } else if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_SP)) { -// //供应商 -// ThrCorpEntity thrCorp = thrCorpService.getThrCorp(orderEntity.getFromCorp()); -// if (null != thrCorp) { -// zaxzyyOrderRequest.setCorpId(thrCorp.getUnitId()); -// zaxzyyOrderRequest.setCorpName(thrCorp.getName()); -// } else { -// log.error("查询单据对应的第三方往来单位信息异常"); -// } -// } - - - //查询仓库信息 - AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new QueryWrapper().eq("code", orderEntity.getInvCode())); - try { - ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper() - .eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity)) - .eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId())); - - zaxzyyOrderRequest.setLocInvCode(thrInvWarehouseEntity.getCode()); - zaxzyyOrderRequest.setLocInvName(thrInvWarehouseEntity.getName()); - - zaxzyyOrderRequest.setLocStorageCode(thrInvWarehouseEntity.getCode()); - zaxzyyOrderRequest.setLocStorageName(thrInvWarehouseEntity.getName()); - } catch (Exception e) { - log.error("查询第三方系统仓库信息异常", e); - } - - //设置单据出入库类型 - if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_PUT)) { - zaxzyyOrderRequest.setInoutType(1); //入库 - } else if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT)) { - zaxzyyOrderRequest.setInoutType(2); //出库 - } - - //设置备注信息 - zaxzyyOrderRequest.setRemark("udi管理系统提交单据"); - //组装单据明细数据 - List ioCodeEntities = codeDao.selectList(new QueryWrapper() - .eq("orderId", orderEntity.getBillNo()) - .ne("action", "StockCheck") - ); - List items = new ArrayList<>(); - //查询业务单据详情 - List detailBizEntities = orderDetailBizDao.selectList(new QueryWrapper().eq("orderIdFk", orderEntity.getBillNo())); - setOrderDetailList(ioCodeEntities, items, detailBizEntities); - zaxzyyOrderRequest.setItem(items); - if (CollUtil.isEmpty(items)) { - log.error("\"产品信息对照异常,无法上传\""); - return ResultVOUtils.error(500, "产品信息对照异常,无法上传"); - } - - for (UdiwmsOrderDetailRequest i : items) { - String fphm = ""; - String fprq = null; - List invoiceList = IoOrderInvoiceEntity.builder().build() - .selectList(Wrappers.lambdaQuery(IoOrderInvoiceEntity.class).eq(IoOrderInvoiceEntity::getOrderIdFk, orderEntity.getBillNo()) - .eq(IoOrderInvoiceEntity::getBindRlFk, i.getBindRlFk()) - .eq(StrUtil.isNotEmpty(i.getBatchNo()), IoOrderInvoiceEntity::getBatchNo, i.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()); - } - i.setFirstSalesInvNo(fphm); - i.setInvoiceDate(fprq); - } - //构造诏安接口参数 - - -// UdiwmsPreInOrderRequest udiwmsPreInOrderRequest = submitPreInOrderToThirdSys(zaxzyyOrderRequest, orderEntity); - - return submitOrder(orderEntity, zaxzyyOrderRequest); - - } - - public String getUserName(IoOrderEntity orderEntity) { - - //创建人非供应商 - if (StrUtil.isNotEmpty(orderEntity.getCheckUser())) { - AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getCheckUser()); - return authUserEntity.getUserName(); - } else if (StrUtil.isNotEmpty(orderEntity.getReviewUser())) { - AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getReviewUser()); - return authUserEntity.getUserName(); - } else if (StrUtil.isNotEmpty(orderEntity.getCreateUser()) && orderEntity.getCreateUser().length() != 14) { - AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getCreateUser()); - return authUserEntity.getUserName(); - } else if (StrUtil.isNotEmpty(orderEntity.getUpdateUser()) && orderEntity.getUpdateUser().length() != 14) { - AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getUpdateUser()); - return authUserEntity.getUserName(); - } else { - List authWarehouseUsers = authWarehouseUserMapper.selectList(new QueryWrapper().eq("code", orderEntity.getInvCode())); - if (CollUtil.isNotEmpty(authWarehouseUsers)) { - return authWarehouseUsers.get(0).getUserName(); - } - } - return null; - } - - /** - * 处理提交单据,记录日志,解析结果逻辑 - * - * @param orderEntity - * @param zaZyRequest - * @return - */ - private BaseResponse submitOrder(IoOrderEntity orderEntity, ZaxzyyOrderRequest zaZyRequest) { - //记录日志 - 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); - String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_ORDER_SUBMIT_URL), zaZyRequest); - if (StrUtil.isNotBlank(response)) { - try { - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - if (baseResponse.getCode() == 20000) { - String thirdBillNo = String.valueOf(baseResponse.getData()); - orderEntity.setThirdBillNo(thirdBillNo); - orderEntity.setExportStatus(1); //提交成功 - uploadLog.setStatus(2); - uploadLog.setThrBillNo(thirdBillNo); - uploadLog.setResult("提交成功"); - orderDao.updateById(orderEntity); - orderUploadLogDao.insert(uploadLog); - return ResultVOUtils.success("提交成功"); - } - uploadLog.setStatus(3); - uploadLog.setResult("提交失败,错误信息:" + baseResponse.getMessage()); - orderEntity.setExportStatus(2); //上传失败 - orderDao.updateById(orderEntity); - orderUploadLogDao.insert(uploadLog); - return baseResponse; - } catch (Exception e) { - log.error("解析提交到HIS单据返回结果异常,结果信息:{}", response); - log.error("异常信息:{}", e); - uploadLog.setStatus(3); - uploadLog.setResult("提交失败,错误信息:" + response); - orderEntity.setExportStatus(2); //上传失败 - orderDao.updateById(orderEntity); - orderUploadLogDao.insert(uploadLog); - return ResultVOUtils.error(500, "提交失败"); - } - } else { - uploadLog.setStatus(3); - uploadLog.setResult("提交失败,调用接口返回为空"); - orderEntity.setExportStatus(2); //上传失败 - orderDao.updateById(orderEntity); - orderUploadLogDao.insert(uploadLog); - return ResultVOUtils.error(500, "提交失败"); - } - } - - - /** - * 封装单据详情参数 - * - * @param ioCodeEntities 单据码明细 - * @param orderDetailRequests 单据详情参数 - * @param detailBizEntities 单据业务详情 - */ - private void setOrderDetailList(List ioCodeEntities, List orderDetailRequests, List detailBizEntities) { - for (IoOrderDetailBizEntity detailBizEntity : detailBizEntities) { - - IoOrderDetailCodeEntity orderDetailCodeEntity = orderDetailCodeDao - .selectOne(new QueryWrapper() - .eq("orderIdFk", detailBizEntity.getOrderIdFk()) - .eq("bindRlFk", detailBizEntity.getBindRlFk()) - .eq(StrUtil.isNotEmpty(detailBizEntity.getBatchNo()), "batchNo", detailBizEntity.getBatchNo()) - .isNull(StrUtil.isEmpty(detailBizEntity.getBatchNo()), "batchNo").last("LIMIT 1")); - if (orderDetailCodeEntity != null && IntUtil.value(orderDetailCodeEntity.getReCount()) > 0) { - detailBizEntity.setCount(orderDetailCodeEntity.getReCount()); - UdiwmsOrderDetailRequest item = submitOrderUtil.buildProductInfo(detailBizEntity); - if (item != null) { - //封装条码信息 - submitOrderUtil.setCodeList(ioCodeEntities, detailBizEntity, item); - orderDetailRequests.add(item); - } - } - } - } - - @Override - public BaseResponse getInvProducts(UdiwmsInvProductsRequest udiwmsInvProductsRequest) { - return ResultVOUtils.error(500, "该接口暂时不用"); - } - - @Override - public BaseResponse getWarehouse(UdiwmsWarehouseRequest udiwmsWarehouseRequest) { - String response = httpClient.postJson(thrSystemDetailService.getUrl(Constants.URL_NAME_WAREHOUSE_QUERY_URL), udiwmsWarehouseRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse postProducts(PostThrProductsRequest postThrProductsRequest) { - postThrProductsRequest.setUploadType("文件导入"); - String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostPiUrl(), postThrProductsRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse postCorps(PostThrCorpRequest postThrCorpRequest) { - postThrCorpRequest.setUploadType("文件导入"); - String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostCorpUrl(), postThrCorpRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse postOrderDetail(PostFileThrOrderRequest postFileThrOrderRequest) { - postFileThrOrderRequest.setUploadType("文件导入"); - String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostOrderUrl(), postFileThrOrderRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse postInvProducts(PostThrInvProductsRequest postThrInvProductsRequest) { - String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostInvPiUrl(), postThrInvProductsRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse postRelProduct(PostRelProductRequest postThrInvProductsRequest) { - - return null; - } - - @Override - public BaseResponse testConnect() { - UdiwmsUnitRequest udiwmsUnitRequest = new UdiwmsUnitRequest(); - udiwmsUnitRequest.setPage(1); - udiwmsUnitRequest.setLimit(1); - BaseResponse baseResponse = getUnit(udiwmsUnitRequest); - if (baseResponse.getCode() == 20000) { - return ResultVOUtils.success("连接成功!"); - } - return ResultVOUtils.error(500, "连接失败!"); - } - - @Override - public BaseResponse queryUdiInvProducts(UdiwmsQueryUdiInvProductsRequest queryUdiInvProductsRequest) { - String response = httpClient.postUDIWMSJson(thirdSysConfig.getQueryInvUrl(), queryUdiInvProductsRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse submitProducts(UdiwmsAddProductsRequest udiwmsAddProductsRequest) { - return null; - } - - @Override - public BaseResponse submitUnit(UdiwmsAddUnitRequest udiwmsAddUnitRequest) { - return null; - } - - @Override - public BaseResponse submitPreInOrders(UdiwmsPreInOrderRequest udiwmsPreInOrderRequest) { - return ResultVOUtils.error(500, "这接口暂时不用!"); - } - - - /** - * 转换提交单据参数 - * - * @param udiwmsOrderRequest - * @param orderEntity - * @return - */ - public UdiwmsPreInOrderRequest submitPreInOrderToThirdSys(ZaxzyyOrderRequest udiwmsOrderRequest, IoOrderEntity orderEntity) { - UdiwmsPreInOrderRequest udiwmsPreInOrderRequest = new UdiwmsPreInOrderRequest(); - if (udiwmsOrderRequest != null) { - BeanUtils.copyProperties(udiwmsOrderRequest, udiwmsPreInOrderRequest); - udiwmsPreInOrderRequest.setLocInvCode(udiwmsOrderRequest.getLocStorageCode()); - udiwmsPreInOrderRequest.setLocInvName(udiwmsOrderRequest.getLocStorageName()); - if (orderEntity.getReviewUser() != null) { - AuthUserEntity authUser = authUserDao.selectById(orderEntity.getReviewUser()); - udiwmsPreInOrderRequest.setActor(authUser.getEmployeeName()); - } else if (orderEntity.getCreateUser() != null) { - AuthUserEntity authUser = authUserDao.selectById(orderEntity.getCreateUser()); - udiwmsPreInOrderRequest.setActor(authUser.getEmployeeName()); - } - List itemDTOS = new ArrayList<>(); - if (CollUtil.isNotEmpty(udiwmsOrderRequest.getItem())) { - for (UdiwmsOrderDetailRequest udiwmsOrderDetail : udiwmsOrderRequest.getItem()) { - if (CollUtil.isNotEmpty(udiwmsOrderDetail.getCodeList())) { - for (UdiwmsOrderDetailRequest.CodeDetailEntity codeDetaiEntity : udiwmsOrderDetail.getCodeList()) { - UdiwmsPreInOrderRequest.ItemDTO itemDTO = new UdiwmsPreInOrderRequest.ItemDTO(); - BeanUtils.copyProperties(udiwmsOrderDetail, itemDTO); - itemDTO.setCode(codeDetaiEntity.getCode()); - itemDTO.setCount(codeDetaiEntity.getCount()); - itemDTOS.add(itemDTO); - - } - } - } - } - udiwmsPreInOrderRequest.setItems(itemDTOS); - } - return udiwmsPreInOrderRequest; - } - -} diff --git a/src/main/java/com/glxp/mipsdl/client/zzzyy/ZzzyyClient1.java b/src/main/java/com/glxp/mipsdl/client/zzzyy/ZzzyyClient1.java deleted file mode 100644 index 7a8565b..0000000 --- a/src/main/java/com/glxp/mipsdl/client/zzzyy/ZzzyyClient1.java +++ /dev/null @@ -1,635 +0,0 @@ -package com.glxp.mipsdl.client.zzzyy; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.json.JSONUtil; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.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.CommonHttpClient; -import com.glxp.mipsdl.config.ThirdSysConfig; -import com.glxp.mipsdl.constant.ConstantType; -import com.glxp.mipsdl.constant.Constants; -import com.glxp.mipsdl.dao.auth.AuthUserDao; -import com.glxp.mipsdl.dao.auth.AuthWarehouseDao; -import com.glxp.mipsdl.dao.auth.AuthWarehouseUserMapper; -import com.glxp.mipsdl.dao.basic.BasicBussinessTypeDao; -import com.glxp.mipsdl.dao.basic.BasicCorpDao; -import com.glxp.mipsdl.dao.inout.*; -import com.glxp.mipsdl.dao.thrsys.ThrInvWarehouseDao; -import com.glxp.mipsdl.dao.thrsys.ThrSystemBusApiDao; -import com.glxp.mipsdl.entity.auth.AuthUserEntity; -import com.glxp.mipsdl.entity.auth.AuthWarehouseEntity; -import com.glxp.mipsdl.entity.auth.AuthWarehouseUser; -import com.glxp.mipsdl.entity.basic.BasicBussinessTypeEntity; -import com.glxp.mipsdl.entity.basic.BasicCorpEntity; -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.ThrSystemBusApiEntity; -import com.glxp.mipsdl.http.HttpClient; -import com.glxp.mipsdl.req.base.*; -import com.glxp.mipsdl.req.post.*; -import com.glxp.mipsdl.req.zaxyy.ZaxzyyOrderRequest; -import com.glxp.mipsdl.req.zzzyy.ZzzyyRequest; -import com.glxp.mipsdl.res.BaseResponse; -import com.glxp.mipsdl.res.udiwms.ZzzyyProductsResponse; -import com.glxp.mipsdl.service.auth.AuthWarehouseService; -import com.glxp.mipsdl.service.thrsys.ThrCorpService; -import com.glxp.mipsdl.service.thrsys.ThrSystemDetailService; -import com.glxp.mipsdl.util.DateUtil; -import com.glxp.mipsdl.util.IntUtil; -import com.glxp.mipsdl.util.ResultVOUtils; -import com.glxp.mipsdl.util.SubmitOrderUtil; -import lombok.extern.slf4j.Slf4j; -import org.dom4j.Document; -import org.dom4j.DocumentException; -import org.dom4j.DocumentHelper; -import org.springframework.beans.BeanUtils; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * 漳州中医院客户端--智业接口对接 - */ - -@Slf4j -public class ZzzyyClient1 extends CommonHttpClient { - - @Resource - private ThrSystemDetailService thrSystemDetailService; - @Resource - private HttpClient httpClient; - @Resource - private IoOrderDao orderDao; - @Resource - private ThrSystemBusApiDao thrSystemBusApiDao; - @Resource - private AuthUserDao authUserDao; - @Resource - private BasicBussinessTypeDao basicBussinessTypeDao; - @Resource - private BasicCorpDao basicCorpDao; - @Resource - private IoCodeDao codeDao; - @Resource - private AuthWarehouseDao authWarehouseDao; - @Resource - private ThrInvWarehouseDao thrInvWarehouseDao; - @Resource - private AuthWarehouseService authWarehouseService; - @Resource - private ThirdSysConfig thirdSysConfig; - @Resource - private ThrCorpService thrCorpService; - @Resource - private IoOrderDetailBizDao orderDetailBizDao; - @Resource - private IoOrderDetailCodeDao orderDetailCodeDao; - - - @Resource - private IoOrderUploadLogDao orderUploadLogDao; - @Resource - private SubmitOrderUtil submitOrderUtil; - @Resource - AuthWarehouseUserMapper authWarehouseUserMapper; - - /** - * 拼接xml请求头 - * - * @param methodName 方法名 - * @return - */ - public String getMsgHeader(String methodName) { - return "" + - "" + - "" + - methodName + - "" + - ""; - } - - public String parserResult(String response) { - if (response.contains(" zzzyyProductsResponse = JSON.parseArray(map.get("list") + "", ZzzyyProductsResponse.class); - for (ZzzyyProductsResponse productsResponse : zzzyyProductsResponse) { - //判断要是规格和型号一致就是取规格 不一致就合并 - if (StrUtil.isNotEmpty(productsResponse.getModel_number()) && StrUtil.isNotEmpty(productsResponse.getStandard())) { - if (productsResponse.getModel_number().equals(productsResponse.getStandard())) { - productsResponse.setStandard(productsResponse.getStandard()); - } else { - productsResponse.setStandard(productsResponse.getStandard() + productsResponse.getModel_number()); - } - } else if (StrUtil.isNotEmpty(productsResponse.getModel_number()) && StrUtil.isBlank(productsResponse.getStandard())) { - productsResponse.setStandard(productsResponse.getModel_number()); - } - } - map.put("list", JSON.toJSON(zzzyyProductsResponse)); - baseResponse.setData(""); - baseResponse.setData(map); - return baseResponse; - } catch (Exception e) { - log.error("解析漳州中医院智业接口返回产品信息字典数据异常,返回结果:{}", response); - log.error("异常信息:{}", e); - return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")"); - } - } - - @Override - public BaseResponse getOrderTypes(UdiwmsBusTypeRequest udiwmsBusTypeRequest) { - ZzzyyRequest zaZyRequest = new ZzzyyRequest(); - zaZyRequest.setMsgHeader(getMsgHeader("getMaterialType")); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsBusTypeRequest)); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_BUS_TYPE_QUERY_URL), zaZyRequest); - response = parserResult(response); - try { - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } catch (Exception e) { - log.error("解析漳州中医院智业接口返回单据类型数据异常,返回结果:{}", response); - log.error("异常信息:{}", e); - return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")"); - } - } - - @Override - public BaseResponse getOrders(UdiwmsOrderQueryRequest udiwmsOrderQueryRequest) { - ZzzyyRequest zaZyRequest = new ZzzyyRequest(); - zaZyRequest.setMsgHeader(getMsgHeader("getMaterialApply")); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsOrderQueryRequest)); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_BUS_TYPE_QUERY_URL), zaZyRequest); - response = parserResult(response); - try { - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } catch (Exception e) { - log.error("解析漳州中医院智业接口返回单据类型数据异常,返回结果:{}", response); - log.error("异常信息:{}", e); - return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")"); - } - } - - @Override - public BaseResponse submitOrders(UdiwmsOrderRequest udiwmsOrderRequest) { - if (StrUtil.isBlank(udiwmsOrderRequest.getBillNo())) { - return ResultVOUtils.error(500, "单据号不能为空"); - } - - ZaxzyyOrderRequest zaxzyyOrderRequest = new ZaxzyyOrderRequest(); - BeanUtil.copyProperties(udiwmsOrderRequest, zaxzyyOrderRequest); - //查询单据和详情信息,组装第三方系统接口所需参数 - IoOrderEntity orderEntity = orderDao.selectOne(new QueryWrapper().eq("billNo", udiwmsOrderRequest.getBillNo())); - - zaxzyyOrderRequest.setBillDate(DateUtil.formatDateTime(orderEntity.getCreateTime())); - //查询对应的第三方单据类型 - ThrSystemBusApiEntity thrSystemBusApiEntity = thrSystemBusApiDao.selectOne(new QueryWrapper().eq("code", udiwmsOrderRequest.getBillType())); - if (StrUtil.isBlank(thrSystemBusApiEntity.getUrl())) { -// return ResultVOUtils.error(500, "接口未配置,无法提交!"); - } - zaxzyyOrderRequest.setThirdSys(getUserName(orderEntity)); - zaxzyyOrderRequest.setBillType(thrSystemBusApiEntity.getThirdBuyCode()); - zaxzyyOrderRequest.setBillFlag("1"); - - //查询单据类型 - BasicBussinessTypeEntity basicBussinessTypeEntity = basicBussinessTypeDao.selectByAction(udiwmsOrderRequest.getBillType()); - if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_HOSPTIAL)) { - //医院客户 - zaxzyyOrderRequest.setCorpId(orderEntity.getFromCorp()); - //查询客户名称 - String corpName = basicCorpDao.selectNameByErpId(orderEntity.getFromCorp()); - zaxzyyOrderRequest.setCorpName(corpName); - } else if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_INTTERNAL)) { - //内部科室 - BasicCorpEntity basicCorpEntity = null; - if (StrUtil.isNotEmpty(orderEntity.getFromCorp())) { - basicCorpEntity = basicCorpDao.selectByErpId(orderEntity.getFromCorp()); - } - if (basicCorpEntity != null) { - zaxzyyOrderRequest.setCorpId(basicCorpEntity.getThirdId()); - zaxzyyOrderRequest.setCorpName(basicCorpEntity.getName()); - } else { - AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new QueryWrapper().eq("code", udiwmsOrderRequest.getCorpId())); - try { - //根据第三方系统标识,获取对应字段的值 - ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper() - .eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity)) - .eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId())); - - zaxzyyOrderRequest.setCorpId(thrInvWarehouseEntity.getCode()); - zaxzyyOrderRequest.setCorpName(thrInvWarehouseEntity.getName()); - } catch (Exception e) { - log.error("查询单据对应往来单位的第三方仓库信息异常", e); - } - } - - } else if (basicBussinessTypeEntity.getCorpType().equals(Constants.CORP_SP)) { - //供应商 - ThrCorpEntity thrCorp = thrCorpService.getThrCorp(udiwmsOrderRequest.getCorpId()); - if (null != thrCorp) { - zaxzyyOrderRequest.setCorpId(thrCorp.getUnitId()); - zaxzyyOrderRequest.setCorpName(thrCorp.getName()); - } else { - log.error("查询单据对应的第三方往来单位信息异常"); - } - } - - - //查询仓库信息 - AuthWarehouseEntity warehouseEntity = authWarehouseDao.selectOne(new QueryWrapper().eq("code", orderEntity.getInvCode())); - try { - ThrInvWarehouseEntity thrInvWarehouseEntity = thrInvWarehouseDao.selectOne(new LambdaQueryWrapper() - .eq(ThrInvWarehouseEntity::getCode, authWarehouseService.getThirdInvCode(warehouseEntity)) - .eq(ThrInvWarehouseEntity::getThirdSysFk, thirdSysConfig.getThirdId())); - - zaxzyyOrderRequest.setLocInvCode(thrInvWarehouseEntity.getCode()); - zaxzyyOrderRequest.setLocInvName(thrInvWarehouseEntity.getName()); - - zaxzyyOrderRequest.setLocStorageCode(thrInvWarehouseEntity.getCode()); - zaxzyyOrderRequest.setLocStorageName(thrInvWarehouseEntity.getName()); - } catch (Exception e) { - log.error("查询第三方系统仓库信息异常", e); - } - - //设置单据出入库类型 - if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_PUT)) { - zaxzyyOrderRequest.setInoutType(1); //入库 - } else if (basicBussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT)) { - zaxzyyOrderRequest.setInoutType(2); //出库 - } - - //设置备注信息 - zaxzyyOrderRequest.setRemark("udi管理系统提交单据"); - //组装单据明细数据 - List ioCodeEntities = codeDao.selectList(new QueryWrapper() - .eq("orderId", orderEntity.getBillNo()) - .ne("action", "StockCheck") - ); - List items = new ArrayList<>(); - //查询业务单据详情 - List detailBizEntities = orderDetailBizDao.selectList(new QueryWrapper().eq("orderIdFk", orderEntity.getBillNo())); - setOrderDetailList(ioCodeEntities, items, detailBizEntities); - zaxzyyOrderRequest.setItem(items); - if (CollUtil.isEmpty(items)) { - log.error("\"产品信息对照异常,无法上传\""); - return ResultVOUtils.error(500, "产品信息对照异常,无法上传"); - } - - for (UdiwmsOrderDetailRequest i : items) { - String fphm = ""; - String fprq = null; - List invoiceList = IoOrderInvoiceEntity.builder().build() - .selectList(Wrappers.lambdaQuery(IoOrderInvoiceEntity.class).eq(IoOrderInvoiceEntity::getOrderIdFk, orderEntity.getBillNo()) - .eq(IoOrderInvoiceEntity::getBindRlFk, i.getBindRlFk()) - .eq(StrUtil.isNotEmpty(i.getBatchNo()), IoOrderInvoiceEntity::getBatchNo, i.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()); - } - i.setFirstSalesInvNo(fphm); - i.setInvoiceDate(fprq); - } - //构造诏安接口参数 - ZzzyyRequest zaZyRequest = new ZzzyyRequest(); - - //提交到第三方系统 - if (thrSystemBusApiEntity.getUrl().equals("saveMasterialInput")) { - //采购入库单据 - zaZyRequest.setMsgHeader(getMsgHeader("saveMasterialInput")); - String key = "orderSubmitUrl"; - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(zaxzyyOrderRequest)); - } else if (thrSystemBusApiEntity.getUrl().equals("saveMaterialHight")) { -// zaxzyyOrderRequest.setLocStorageCode("1001304"); -// zaxzyyOrderRequest.setLocStorageName("骨科耗材及试剂仓库"); - //临床出库 - zaZyRequest.setMsgHeader(getMsgHeader("saveMaterialHight")); - String key = "preInOrderSubmit"; - - UdiwmsPreInOrderRequest udiwmsPreInOrderRequest = submitPreInOrderToThirdSys(zaxzyyOrderRequest, orderEntity); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsPreInOrderRequest)); - } - - return submitOrder(orderEntity, zaZyRequest); - - } - - public String getUserName(IoOrderEntity orderEntity) { - - //创建人非供应商 - if (StrUtil.isNotEmpty(orderEntity.getCheckUser())) { - AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getCheckUser()); - return authUserEntity.getUserName(); - } else if (StrUtil.isNotEmpty(orderEntity.getReviewUser())) { - AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getReviewUser()); - return authUserEntity.getUserName(); - } else if (StrUtil.isNotEmpty(orderEntity.getCreateUser()) && orderEntity.getCreateUser().length() != 14) { - AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getCreateUser()); - return authUserEntity.getUserName(); - } else if (StrUtil.isNotEmpty(orderEntity.getUpdateUser()) && orderEntity.getUpdateUser().length() != 14) { - AuthUserEntity authUserEntity = authUserDao.selectById(orderEntity.getUpdateUser()); - return authUserEntity.getUserName(); - } else { - List authWarehouseUsers = authWarehouseUserMapper.selectList(new QueryWrapper().eq("code", orderEntity.getInvCode())); - if (CollUtil.isNotEmpty(authWarehouseUsers)) { - return authWarehouseUsers.get(0).getUserName(); - } - } - return null; - } - - /** - * 处理提交单据,记录日志,解析结果逻辑 - * - * @param orderEntity - * @param zaZyRequest - * @return - */ - private BaseResponse submitOrder(IoOrderEntity orderEntity, ZzzyyRequest zaZyRequest) { - //记录日志 - 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); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_ORDER_SUBMIT_URL), zaZyRequest); - response = parserResult(response); - if (StrUtil.isNotBlank(response)) { - try { - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - if (baseResponse.getCode() == 20000) { - String thirdBillNo = String.valueOf(baseResponse.getData()); - orderEntity.setThirdBillNo(thirdBillNo); - orderEntity.setExportStatus(1); //提交成功 - uploadLog.setStatus(2); - uploadLog.setThrBillNo(thirdBillNo); - uploadLog.setResult("提交成功"); - orderDao.updateById(orderEntity); - orderUploadLogDao.insert(uploadLog); - return ResultVOUtils.success("提交成功"); - } - uploadLog.setStatus(3); - uploadLog.setResult("提交失败,错误信息:" + baseResponse.getMessage()); - orderEntity.setExportStatus(2); //上传失败 - orderDao.updateById(orderEntity); - orderUploadLogDao.insert(uploadLog); - return baseResponse; - } catch (Exception e) { - log.error("解析提交到智业单据返回结果异常,结果信息:{}", response); - log.error("异常信息:{}", e); - uploadLog.setStatus(3); - uploadLog.setResult("提交失败,错误信息:" + response); - orderEntity.setExportStatus(2); //上传失败 - orderDao.updateById(orderEntity); - orderUploadLogDao.insert(uploadLog); - return ResultVOUtils.error(500, "提交失败"); - } - } else { - uploadLog.setStatus(3); - uploadLog.setResult("提交失败,调用接口返回为空"); - orderEntity.setExportStatus(2); //上传失败 - orderDao.updateById(orderEntity); - orderUploadLogDao.insert(uploadLog); - return ResultVOUtils.error(500, "提交失败"); - } - } - - - /** - * 封装单据详情参数 - * - * @param ioCodeEntities 单据码明细 - * @param orderDetailRequests 单据详情参数 - * @param detailBizEntities 单据业务详情 - */ - private void setOrderDetailList(List ioCodeEntities, List orderDetailRequests, List detailBizEntities) { - for (IoOrderDetailBizEntity detailBizEntity : detailBizEntities) { - - IoOrderDetailCodeEntity orderDetailCodeEntity = orderDetailCodeDao - .selectOne(new QueryWrapper() - .eq("orderIdFk", detailBizEntity.getOrderIdFk()) - .eq("bindRlFk", detailBizEntity.getBindRlFk()) - .eq(StrUtil.isNotEmpty(detailBizEntity.getBatchNo()), "batchNo", detailBizEntity.getBatchNo()) - .isNull(StrUtil.isEmpty(detailBizEntity.getBatchNo()), "batchNo").last("LIMIT 1")); - if (orderDetailCodeEntity != null && IntUtil.value(orderDetailCodeEntity.getReCount()) > 0) { - detailBizEntity.setCount(orderDetailCodeEntity.getReCount()); - UdiwmsOrderDetailRequest item = submitOrderUtil.buildProductInfo(detailBizEntity); - if (item != null) { - //封装条码信息 - submitOrderUtil.setCodeList(ioCodeEntities, detailBizEntity, item); - orderDetailRequests.add(item); - } - } - } - } - - @Override - public BaseResponse getInvProducts(UdiwmsInvProductsRequest udiwmsInvProductsRequest) { - ZzzyyRequest zaZyRequest = new ZzzyyRequest(); - zaZyRequest.setMsgHeader(getMsgHeader("getMaterialStorage")); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsInvProductsRequest)); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_INV_PI_URL), zaZyRequest); - response = parserResult(response); - try { - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } catch (Exception e) { - log.error("解析漳州中医院智业接口返回库存产品数据异常,返回结果:{}", response); - log.error("异常信息:{}", e); - return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")"); - } - } - - @Override - public BaseResponse getWarehouse(UdiwmsWarehouseRequest udiwmsWarehouseRequest) { - ZzzyyRequest zaZyRequest = new ZzzyyRequest(); - zaZyRequest.setMsgHeader(getMsgHeader("getMaterialDept")); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsWarehouseRequest)); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_WAREHOUSE_QUERY_URL), zaZyRequest); - response = parserResult(response); - try { - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } catch (Exception e) { - log.error("解析漳州中医院智业接口返回仓库(科室)数据异常,返回结果:{}", response); - log.error("异常信息:{}", e); - return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")"); - } - } - - @Override - public BaseResponse postProducts(PostThrProductsRequest postThrProductsRequest) { - postThrProductsRequest.setUploadType("文件导入"); - String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostPiUrl(), postThrProductsRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse postCorps(PostThrCorpRequest postThrCorpRequest) { - postThrCorpRequest.setUploadType("文件导入"); - String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostCorpUrl(), postThrCorpRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse postOrderDetail(PostFileThrOrderRequest postFileThrOrderRequest) { - postFileThrOrderRequest.setUploadType("文件导入"); - String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostOrderUrl(), postFileThrOrderRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse postInvProducts(PostThrInvProductsRequest postThrInvProductsRequest) { - String response = httpClient.postUDIWMSJson(thirdSysConfig.getPostInvPiUrl(), postThrInvProductsRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse postRelProduct(PostRelProductRequest postThrInvProductsRequest) { - - return null; - } - - @Override - public BaseResponse testConnect() { - UdiwmsUnitRequest udiwmsUnitRequest = new UdiwmsUnitRequest(); - udiwmsUnitRequest.setPage(1); - udiwmsUnitRequest.setLimit(1); - BaseResponse baseResponse = getUnit(udiwmsUnitRequest); - if (baseResponse.getCode() == 20000) { - return ResultVOUtils.success("连接成功!"); - } - return ResultVOUtils.error(500, "连接失败!"); - } - - @Override - public BaseResponse queryUdiInvProducts(UdiwmsQueryUdiInvProductsRequest queryUdiInvProductsRequest) { - String response = httpClient.postUDIWMSJson(thirdSysConfig.getQueryInvUrl(), queryUdiInvProductsRequest); - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } - - @Override - public BaseResponse submitProducts(UdiwmsAddProductsRequest udiwmsAddProductsRequest) { - return null; - } - - @Override - public BaseResponse submitUnit(UdiwmsAddUnitRequest udiwmsAddUnitRequest) { - return null; - } - - @Override - public BaseResponse submitPreInOrders(UdiwmsPreInOrderRequest udiwmsPreInOrderRequest) { - ZzzyyRequest zaZyRequest = new ZzzyyRequest(); - zaZyRequest.setMsgHeader(getMsgHeader("saveMaterialHight")); - zaZyRequest.setMsgBody(JSONUtil.toJsonStr(udiwmsPreInOrderRequest)); - String response = httpClient.postJson(thrSystemDetailService.getUrlExclude(Constants.URL_NAME_PRE_IN_ORDER_SUBMIT_URL), zaZyRequest); - response = parserResult(response); - try { - BaseResponse baseResponse = JSONObject.parseObject(response, BaseResponse.class); - return baseResponse; - } catch (Exception e) { - log.error("解析漳州中医院智业接口提交单据返回数据异常,返回结果:{}", response); - log.error("异常信息:{}", e); - return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果(" + response + ")"); - } - } - - - /** - * 转换提交单据参数 - * - * @param udiwmsOrderRequest - * @param orderEntity - * @return - */ - public UdiwmsPreInOrderRequest submitPreInOrderToThirdSys(ZaxzyyOrderRequest udiwmsOrderRequest, IoOrderEntity orderEntity) { - UdiwmsPreInOrderRequest udiwmsPreInOrderRequest = new UdiwmsPreInOrderRequest(); - if (udiwmsOrderRequest != null) { - BeanUtils.copyProperties(udiwmsOrderRequest, udiwmsPreInOrderRequest); - udiwmsPreInOrderRequest.setLocInvCode(udiwmsOrderRequest.getLocStorageCode()); - udiwmsPreInOrderRequest.setLocInvName(udiwmsOrderRequest.getLocStorageName()); - if (orderEntity.getReviewUser() != null) { - AuthUserEntity authUser = authUserDao.selectById(orderEntity.getReviewUser()); - udiwmsPreInOrderRequest.setActor(authUser.getEmployeeName()); - } else if (orderEntity.getCreateUser() != null) { - AuthUserEntity authUser = authUserDao.selectById(orderEntity.getCreateUser()); - udiwmsPreInOrderRequest.setActor(authUser.getEmployeeName()); - } - List itemDTOS = new ArrayList<>(); - if (CollUtil.isNotEmpty(udiwmsOrderRequest.getItem())) { - for (UdiwmsOrderDetailRequest udiwmsOrderDetail : udiwmsOrderRequest.getItem()) { - if (CollUtil.isNotEmpty(udiwmsOrderDetail.getCodeList())) { - for (UdiwmsOrderDetailRequest.CodeDetailEntity codeDetaiEntity : udiwmsOrderDetail.getCodeList()) { - UdiwmsPreInOrderRequest.ItemDTO itemDTO = new UdiwmsPreInOrderRequest.ItemDTO(); - BeanUtils.copyProperties(udiwmsOrderDetail, itemDTO); - itemDTO.setCode(codeDetaiEntity.getCode()); - itemDTO.setCount(codeDetaiEntity.getCount()); - itemDTOS.add(itemDTO); - - } - } - } - } - udiwmsPreInOrderRequest.setItems(itemDTOS); - } - return udiwmsPreInOrderRequest; - } - -} diff --git a/src/main/java/com/glxp/mipsdl/dao/ptxyy/ThrHslbMapper.java b/src/main/java/com/glxp/mipsdl/dao/ptxyy/ThrHslbMapper.java deleted file mode 100644 index b8d4ff8..0000000 --- a/src/main/java/com/glxp/mipsdl/dao/ptxyy/ThrHslbMapper.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.glxp.mipsdl.dao.ptxyy; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.glxp.mipsdl.client.ptxhyy.entity.ThrHslbEntity; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface ThrHslbMapper extends BaseMapper { -} diff --git a/src/main/java/com/glxp/mipsdl/entity/lhsyy/MaterialDictEntity.java b/src/main/java/com/glxp/mipsdl/entity/lhsyy/MaterialDictEntity.java new file mode 100644 index 0000000..766a18e --- /dev/null +++ b/src/main/java/com/glxp/mipsdl/entity/lhsyy/MaterialDictEntity.java @@ -0,0 +1,29 @@ +package com.glxp.mipsdl.entity.lhsyy; + +import lombok.Data; + +@Data +public class MaterialDictEntity { + + private String materialCode; + + + /** + * 材料分类ID + */ + private Integer flid; + + /** + * 材料小类ID + */ + private Integer xlid; + + /** + * 耗材名称 + */ + private String ypspm; + + +// cd gg xh dw dw1 hsgx ybbm pfj lsj pzwh ghdw healthcode ybjsqr sfzht gjhcbm sfybfw + +} diff --git a/src/main/java/com/glxp/mipsdl/req/base/UdiwmsOrderDetailRequest.java b/src/main/java/com/glxp/mipsdl/req/base/UdiwmsOrderDetailRequest.java index 52054cc..be6cc5a 100644 --- a/src/main/java/com/glxp/mipsdl/req/base/UdiwmsOrderDetailRequest.java +++ b/src/main/java/com/glxp/mipsdl/req/base/UdiwmsOrderDetailRequest.java @@ -22,10 +22,10 @@ public class UdiwmsOrderDetailRequest { */ private String productName; - /** - * 耗材字典ID外键 - */ - private String bindRlFk; +// /** +// * 耗材字典ID外键 +// */ +// private String bindRlFk; /** * 单价 @@ -117,10 +117,7 @@ public class UdiwmsOrderDetailRequest { */ private String remark3; - /** - * 是否允许无批次号 - */ - private boolean allowNoBatch; + /** * 序列号 diff --git a/src/main/java/com/glxp/mipsdl/util/SubmitOrderUtil.java b/src/main/java/com/glxp/mipsdl/util/SubmitOrderUtil.java index cd2a503..3a8a10c 100644 --- a/src/main/java/com/glxp/mipsdl/util/SubmitOrderUtil.java +++ b/src/main/java/com/glxp/mipsdl/util/SubmitOrderUtil.java @@ -111,8 +111,11 @@ public class SubmitOrderUtil { BeanUtil.copyProperties(detailBizEntity, item); item.setProductDate(DateUtil.formatExpireTime(StrUtil.isBlank(detailBizEntity.getProductDate()) ? null : "20" + detailBizEntity.getProductDate())); - item.setExpireDate(DateUtil.formatExpireTime(StrUtil.isBlank(detailBizEntity.getExpireDate()) ? null : "20" + detailBizEntity.getExpireDate())); - + if (StrUtil.isEmpty(detailBizEntity.getExpireDate())){ + item.setExpireDate(""); + }else { + item.setExpireDate(DateUtil.formatExpireTime(StrUtil.isBlank(detailBizEntity.getExpireDate()) ? null : "20" + detailBizEntity.getExpireDate())); + } String thirdProductId = (String) ReflectUtil.getFieldValue(basicUdirel, thirdSysConfig.getThirdId()); item.setProductId(thirdProductId); //产品ID //查询第三方产品名称