From d25b0321e7aaea95d135f1e7025c4bae9e7db736 Mon Sep 17 00:00:00 2001 From: x_z Date: Thu, 20 Oct 2022 16:54:07 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=B0=83=E6=95=B4=E5=BE=80=E6=9D=A5=E5=8D=95?= =?UTF-8?q?=E4=BD=8D=E5=92=8C=E8=87=AA=E5=8A=A9=E5=B9=B3=E5=8F=B0=E5=85=B3?= =?UTF-8?q?=E8=81=94=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basic/StackRulesController.java | 11 ++ .../controller/info/PlatformController.java | 41 ++++--- .../controller/inout/OrderController.java | 96 ++++++++--------- .../glxp/udi/admin/dao/info/PlatformDao.java | 9 -- .../udi/admin/dao/inout/UnitMaintainDao.java | 9 -- .../entity/inout/UnitMaintainPlatform.java | 100 +++++++++++++++++ .../SystemParamConfigCustomerEntity.java | 3 + .../admin/req/info/PlatformLinkRequest.java | 15 --- .../admin/req/inout/PlatformLinkRequest.java | 41 +++++++ .../service/basic/StackRulesService.java | 15 ++- .../admin/service/info/PlatformService.java | 101 +++++++++++++++--- .../udi/admin/service/inout/OrderService.java | 12 ++- .../admin/thread/SubmitOrderToSpmsTask.java | 14 +-- .../udi/admin/thread/SupplementOrderTask.java | 7 +- .../glxp/udi/admin/thread/TransInoutTask.java | 9 +- .../mybatis/mapper/info/PlatformDao.xml | 26 ----- .../mybatis/mapper/inout/UnitMaintainDao.xml | 8 -- .../mapper/inout/UnitMaintainPlatformDao.xml | 27 +++++ 18 files changed, 370 insertions(+), 174 deletions(-) create mode 100644 src/main/java/com/glxp/udi/admin/entity/inout/UnitMaintainPlatform.java delete mode 100644 src/main/java/com/glxp/udi/admin/req/info/PlatformLinkRequest.java create mode 100644 src/main/java/com/glxp/udi/admin/req/inout/PlatformLinkRequest.java create mode 100644 src/main/resources/mybatis/mapper/inout/UnitMaintainPlatformDao.xml diff --git a/src/main/java/com/glxp/udi/admin/controller/basic/StackRulesController.java b/src/main/java/com/glxp/udi/admin/controller/basic/StackRulesController.java index 53acb51..9962e91 100644 --- a/src/main/java/com/glxp/udi/admin/controller/basic/StackRulesController.java +++ b/src/main/java/com/glxp/udi/admin/controller/basic/StackRulesController.java @@ -110,4 +110,15 @@ public class StackRulesController { return ResultVOUtils.success(); } + /** + * 获取当前用户启用规则的数量 + * + * @return + */ + @GetMapping("/udims/stackRules/getEnableRulesNum") + public BaseResponse getEnableRulesNum() { + Long num = stackRulesService.getEnableRulesNum(); + return ResultVOUtils.success(num); + } + } diff --git a/src/main/java/com/glxp/udi/admin/controller/info/PlatformController.java b/src/main/java/com/glxp/udi/admin/controller/info/PlatformController.java index 23b039d..e87b604 100644 --- a/src/main/java/com/glxp/udi/admin/controller/info/PlatformController.java +++ b/src/main/java/com/glxp/udi/admin/controller/info/PlatformController.java @@ -1,20 +1,22 @@ package com.glxp.udi.admin.controller.info; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.metadata.IPage; import com.glxp.udi.admin.annotation.AuthRuleAnnotation; +import com.glxp.udi.admin.common.enums.ResultEnum; import com.glxp.udi.admin.common.res.BaseResponse; +import com.glxp.udi.admin.common.util.ResultVOUtils; import com.glxp.udi.admin.entity.info.PlatformEntity; -import com.glxp.udi.admin.entity.inout.UnitMaintainEntity; -import com.glxp.udi.admin.req.info.PlatformLinkRequest; +import com.glxp.udi.admin.entity.inout.UnitMaintainPlatform; import com.glxp.udi.admin.req.info.PlatformUserInfoRequest; +import com.glxp.udi.admin.req.inout.DeleteRequest; +import com.glxp.udi.admin.req.inout.PlatformLinkRequest; import com.glxp.udi.admin.res.PageSimpleResponse; import com.glxp.udi.admin.res.info.PlatformLinkResponse; import com.glxp.udi.admin.service.info.PlatformService; import com.glxp.udi.admin.service.inout.UnitMaintainService; -import com.glxp.udi.admin.common.enums.ResultEnum; -import com.glxp.udi.admin.common.util.ResultVOUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; @@ -105,14 +107,20 @@ public class PlatformController { @AuthRuleAnnotation("") @PostMapping("/udims/platform/link") - public BaseResponse update(@RequestBody UnitMaintainEntity unitMaintainEntity) { - PlatformEntity platformEntity = platformService.get(unitMaintainEntity.getPlatformId()); + public BaseResponse update(@RequestBody PlatformLinkRequest platformLinkRequest) { + //判断此数据是否重复 + String verifyResult = platformService.verifyUnitMaintainPlatform(platformLinkRequest); + if (!verifyResult.equals("success")) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, verifyResult); + } + + PlatformEntity platformEntity = platformService.get(platformLinkRequest.getPlatformId()); if (platformEntity != null) { String url = platformEntity.getHost() + "/verify"; Map map = new HashMap(); - map.put("username", unitMaintainEntity.getPlatformUsername()); - map.put("password", unitMaintainEntity.getPlatformPassword()); + map.put("username", platformLinkRequest.getPlatformUsername()); + map.put("password", platformLinkRequest.getPlatformPassword()); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON_UTF8); @@ -129,12 +137,12 @@ public class PlatformController { Map data = JSON.parseObject(JSON.toJSONString(object.get("data")), Map.class); log.error(JSON.toJSONString(object.get("data"))); if (data.get("appid") != null) { - unitMaintainEntity.setAppid(data.get("appid").toString()); + platformLinkRequest.setAppid(data.get("appid").toString()); if (data.get("apiKey") != null) { - unitMaintainEntity.setApiKey(data.get("apiKey").toString()); + platformLinkRequest.setApiKey(data.get("apiKey").toString()); } if (data.get("secretKey") != null) { - unitMaintainEntity.setSecretKey(data.get("secretKey").toString()); + platformLinkRequest.setSecretKey(data.get("secretKey").toString()); } } else { return ResultVOUtils.error(500, "关联验证失败,请联系管理人员"); @@ -144,11 +152,12 @@ public class PlatformController { } else { return ResultVOUtils.error(500, "关联失败,请联系管理人员"); } - } else { return ResultVOUtils.error(500, "未查询到平台信息"); } - unitMaintainService.updateUnit(unitMaintainEntity); + UnitMaintainPlatform unitMaintainPlatform = new UnitMaintainPlatform(); + BeanUtil.copyProperties(platformLinkRequest, unitMaintainPlatform); + platformService.saveUnitPlatform(unitMaintainPlatform); return ResultVOUtils.success("关联成功"); } @@ -176,11 +185,11 @@ public class PlatformController { */ @AuthRuleAnnotation("") @PostMapping("/udims/platform/unbind") - public BaseResponse unbindPlatform(String corpId) { - if (StrUtil.isBlank(corpId)) { + public BaseResponse unbindPlatform(DeleteRequest deleteRequest) { + if (StrUtil.isBlank(deleteRequest.getId())) { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); } - platformService.unbindPlatform(corpId); + platformService.unbindPlatform(deleteRequest.getId()); return ResultVOUtils.success(); } diff --git a/src/main/java/com/glxp/udi/admin/controller/inout/OrderController.java b/src/main/java/com/glxp/udi/admin/controller/inout/OrderController.java index c68e212..56ad96f 100644 --- a/src/main/java/com/glxp/udi/admin/controller/inout/OrderController.java +++ b/src/main/java/com/glxp/udi/admin/controller/inout/OrderController.java @@ -315,66 +315,62 @@ public class OrderController { if (orderUploadRequest.getOrderIds() != null && orderUploadRequest.getOrderIds().size() > 0) { PostUdimsOrderRequest postUdimsOrderRequest = new PostUdimsOrderRequest(); List orderBeans = new ArrayList<>(); - UnitMaintainEntity unitMaintainEntity = null; String orderId = orderUploadRequest.getOrderIds().get(0); OrderEntity orderEntity = orderService.findByOne(orderId); - if (orderEntity != null) { - unitMaintainEntity = unitMaintainService.selectByUnitId(orderEntity.getFromCorpId()); - if (unitMaintainEntity == null || unitMaintainEntity.getAppid() == null) { - return ResultVOUtils.error(500, "该往来单位未绑定UDI自助平台!"); - } - if (!orderEntity.getAction().equals(unitMaintainEntity.getSourceAction())) { - return ResultVOUtils.error(500, "该单据类型不支持提交!"); - } - PostUdimsOrderRequest.OrderBean orderBean = new PostUdimsOrderRequest.OrderBean(); - BeanUtils.copyProperties(orderEntity, orderBean); - orderBean.setAction(unitMaintainEntity.getTargetAction()); - orderBean.setInvStorageCode(unitMaintainEntity.getInvCode()); - orderBean.setInvWarehouseCode(unitMaintainEntity.getInvSubCode()); - WarehouseQueryRequest warehouseQueryRequest = new WarehouseQueryRequest(); - warehouseQueryRequest.setOrderId(orderEntity.getOrderId()); - List warehouseEntities = warehouseService.filterWarehouse(warehouseQueryRequest); - List codeBeans = new ArrayList<>(); - UnitMaintainEntity finalUnitMaintainEntity = unitMaintainEntity; - warehouseEntities.forEach(data -> { - PostUdimsOrderRequest.OrderBean.CodeBean codeBean = new PostUdimsOrderRequest.OrderBean.CodeBean(); - BeanUtils.copyProperties(data, codeBean); - codeBean.setInvStorageCode(finalUnitMaintainEntity.getInvCode()); - codeBean.setInvWarehouseCode(finalUnitMaintainEntity.getInvSubCode()); - codeBeans.add(codeBean); - }); - //查询单据详情 - FilterOrderDetailRequest filterOrderDetailRequest = new FilterOrderDetailRequest(); - filterOrderDetailRequest.setOrderId(orderBean.getOrderId()); - //单据详情 - List erpOrderEntities = orderDetailService.filterOrderDetails(filterOrderDetailRequest); - if (CollUtil.isNotEmpty(erpOrderEntities)) { - List orderDetails = new ArrayList<>(); - for (OrderDetailEntity orderDetailEntity : erpOrderEntities) { - PostUdimsOrderDetailRequest orderDetail = new PostUdimsOrderDetailRequest(); - orderDetail.setUuidFk(orderDetailEntity.getUuidFk()); - orderDetail.setFirstSalesInvNo(orderDetailEntity.getFirstSalesInvNo()); - orderDetail.setSecSalesInvNo(orderDetailEntity.getSecSalesInvNo()); - orderDetail.setPrice(orderDetailEntity.getPrice()); - orderDetail.setInvoiceDate(orderDetailEntity.getInvoiceDate()); - orderDetail.setSecSalesListNo(orderDetailEntity.getSecSalesListNo()); - orderDetail.setBatchNo(orderDetailEntity.getBatchNo()); - orderDetails.add(orderDetail); - } - orderBean.setOrderDetails(orderDetails); + UnitMaintainPlatform unitMaintainPlatform = platformService.findLinkData(customerService.getCustomerId(), orderEntity.getAction(), orderEntity.getFromCorpId()); + if (unitMaintainPlatform == null || unitMaintainPlatform.getAppid() == null) { + return ResultVOUtils.error(500, "该往来单位未绑定UDI自助平台!"); + } + if (!orderEntity.getAction().equals(unitMaintainPlatform.getSourceAction())) { + return ResultVOUtils.error(500, "该单据类型不支持提交!"); + } + PostUdimsOrderRequest.OrderBean orderBean = new PostUdimsOrderRequest.OrderBean(); + BeanUtils.copyProperties(orderEntity, orderBean); + orderBean.setAction(unitMaintainPlatform.getTargetAction()); + orderBean.setInvStorageCode(unitMaintainPlatform.getInvCode()); + orderBean.setInvWarehouseCode(unitMaintainPlatform.getInvSubCode()); + WarehouseQueryRequest warehouseQueryRequest = new WarehouseQueryRequest(); + warehouseQueryRequest.setOrderId(orderEntity.getOrderId()); + List warehouseEntities = warehouseService.filterWarehouse(warehouseQueryRequest); + List codeBeans = new ArrayList<>(); + warehouseEntities.forEach(data -> { + PostUdimsOrderRequest.OrderBean.CodeBean codeBean = new PostUdimsOrderRequest.OrderBean.CodeBean(); + BeanUtils.copyProperties(data, codeBean); + codeBean.setInvStorageCode(unitMaintainPlatform.getInvCode()); + codeBean.setInvWarehouseCode(unitMaintainPlatform.getInvSubCode()); + codeBeans.add(codeBean); + }); + //查询单据详情 + FilterOrderDetailRequest filterOrderDetailRequest = new FilterOrderDetailRequest(); + filterOrderDetailRequest.setOrderId(orderBean.getOrderId()); + //单据详情 + List erpOrderEntities = orderDetailService.filterOrderDetails(filterOrderDetailRequest); + if (CollUtil.isNotEmpty(erpOrderEntities)) { + List orderDetails = new ArrayList<>(); + for (OrderDetailEntity orderDetailEntity : erpOrderEntities) { + PostUdimsOrderDetailRequest orderDetail = new PostUdimsOrderDetailRequest(); + orderDetail.setUuidFk(orderDetailEntity.getUuidFk()); + orderDetail.setFirstSalesInvNo(orderDetailEntity.getFirstSalesInvNo()); + orderDetail.setSecSalesInvNo(orderDetailEntity.getSecSalesInvNo()); + orderDetail.setPrice(orderDetailEntity.getPrice()); + orderDetail.setInvoiceDate(orderDetailEntity.getInvoiceDate()); + orderDetail.setSecSalesListNo(orderDetailEntity.getSecSalesListNo()); + orderDetail.setBatchNo(orderDetailEntity.getBatchNo()); + orderDetails.add(orderDetail); } - orderBean.setCodes(codeBeans); - orderBeans.add(orderBean); - postUdimsOrderRequest.setOrderBeans(orderBeans); + orderBean.setOrderDetails(orderDetails); } - PlatformEntity platformEntity = platformService.get(unitMaintainEntity.getPlatformId()); + orderBean.setCodes(codeBeans); + orderBeans.add(orderBean); + postUdimsOrderRequest.setOrderBeans(orderBeans); + PlatformEntity platformEntity = platformService.get(unitMaintainPlatform.getPlatformId()); postUdimsOrderRequest.setOrderBeans(orderBeans); log.info("提交单据到自助平台,单据数据:{}", JSONUtil.toJsonStr(postUdimsOrderRequest)); String response = HttpClient.uCloudPostSmp(platformEntity.getHost() + "/warehouse/inout/postOrdersUdims", - postUdimsOrderRequest, unitMaintainEntity.getApiKey(), unitMaintainEntity.getSecretKey()); + postUdimsOrderRequest, unitMaintainPlatform.getApiKey(), unitMaintainPlatform.getSecretKey()); log.info("自助平台响应结果:{}", response); BaseResponse baseResponse = JSONObject.parseObject(response, new TypeReference() { diff --git a/src/main/java/com/glxp/udi/admin/dao/info/PlatformDao.java b/src/main/java/com/glxp/udi/admin/dao/info/PlatformDao.java index 0464ff1..b46942a 100644 --- a/src/main/java/com/glxp/udi/admin/dao/info/PlatformDao.java +++ b/src/main/java/com/glxp/udi/admin/dao/info/PlatformDao.java @@ -3,7 +3,6 @@ package com.glxp.udi.admin.dao.info; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.glxp.udi.admin.entity.info.PlatformEntity; -import com.glxp.udi.admin.res.info.PlatformLinkResponse; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -21,14 +20,6 @@ public interface PlatformDao extends BaseMapper { PlatformEntity get(String id); - /** - * 查询往来单位和自助平台关联数据 - * - * @param platformLinkRequest - * @return - */ - List getLinkPlatformList(@Param("customerId") String customerId, @Param("key") String key); - /** * 根据名称和访问地址查询平台信息 * diff --git a/src/main/java/com/glxp/udi/admin/dao/inout/UnitMaintainDao.java b/src/main/java/com/glxp/udi/admin/dao/inout/UnitMaintainDao.java index 6012252..9ce94b5 100644 --- a/src/main/java/com/glxp/udi/admin/dao/inout/UnitMaintainDao.java +++ b/src/main/java/com/glxp/udi/admin/dao/inout/UnitMaintainDao.java @@ -56,15 +56,6 @@ public interface UnitMaintainDao extends BaseMapper { */ List getboundUnitMaintains(); - /** - * 查询单据是否可以上传 - * - * @param customerId - * @param action - * @return - */ - Integer checkUpload(@Param("customerId") Long customerId, @Param("action") String action); - /** * 根据名称统计往来单位 * diff --git a/src/main/java/com/glxp/udi/admin/entity/inout/UnitMaintainPlatform.java b/src/main/java/com/glxp/udi/admin/entity/inout/UnitMaintainPlatform.java new file mode 100644 index 0000000..de15098 --- /dev/null +++ b/src/main/java/com/glxp/udi/admin/entity/inout/UnitMaintainPlatform.java @@ -0,0 +1,100 @@ +package com.glxp.udi.admin.entity.inout; + +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 lombok.Data; + +/** + * 医院客户表 + */ +@Data +@TableName(value = "io_unit_maintain_platform") +public class UnitMaintainPlatform { + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + /** + * 往来单位ID + */ + @TableField(value = "unitId") + private String unitId; + + /** + * 客户ID + */ + @TableField(value = "customerId") + private Long customerId; + + /** + * 平台ID + */ + @TableField(value = "platformId") + private String platformId; + + /** + * 源单据类型 + */ + @TableField(value = "sourceAction") + private String sourceAction; + + /** + * 目标单据类型 + */ + @TableField(value = "targetAction") + private String targetAction; + + /** + * 仓库码 + */ + @TableField(value = "invCode") + private String invCode; + + /** + * 分库码 + */ + @TableField(value = "invSubCode") + private String invSubCode; + + /** + * 应用名称 + */ + @TableField(value = "appid") + private String appid; + + /** + * 秘钥 + */ + @TableField(value = "secretKey") + private String secretKey; + + /** + * 应用ID + */ + @TableField(value = "apiKey") + private String apiKey; + + public static final String COL_ID = "id"; + + public static final String COL_UNITID = "unitId"; + + public static final String COL_CUSTOMERID = "customerId"; + + public static final String COL_PLATFORMID = "platformId"; + + public static final String COL_SOURCEACTION = "sourceAction"; + + public static final String COL_TARGETACTION = "targetAction"; + + public static final String COL_INVCODE = "invCode"; + + public static final String COL_INVSUBCODE = "invSubCode"; + + public static final String COL_APPID = "appid"; + + public static final String COL_APIKEY = "apiKey"; + + public static final String COL_SECRETKEY = "secretKey"; +} \ No newline at end of file diff --git a/src/main/java/com/glxp/udi/admin/entity/param/SystemParamConfigCustomerEntity.java b/src/main/java/com/glxp/udi/admin/entity/param/SystemParamConfigCustomerEntity.java index b8e43a7..22dea3a 100644 --- a/src/main/java/com/glxp/udi/admin/entity/param/SystemParamConfigCustomerEntity.java +++ b/src/main/java/com/glxp/udi/admin/entity/param/SystemParamConfigCustomerEntity.java @@ -1,5 +1,7 @@ package com.glxp.udi.admin.entity.param; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; @@ -13,6 +15,7 @@ public class SystemParamConfigCustomerEntity { /** * 主键ID */ + @TableId(value = "id", type = IdType.AUTO) private Integer id; /** diff --git a/src/main/java/com/glxp/udi/admin/req/info/PlatformLinkRequest.java b/src/main/java/com/glxp/udi/admin/req/info/PlatformLinkRequest.java deleted file mode 100644 index 29bd09c..0000000 --- a/src/main/java/com/glxp/udi/admin/req/info/PlatformLinkRequest.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.glxp.udi.admin.req.info; - -import com.glxp.udi.admin.req.ListPageRequest; -import lombok.Data; - -/** - * 往来单位关联自助平台数据查询实体类 - */ -@Data -public class PlatformLinkRequest extends ListPageRequest { - - private String key; - private String customerId; - -} diff --git a/src/main/java/com/glxp/udi/admin/req/inout/PlatformLinkRequest.java b/src/main/java/com/glxp/udi/admin/req/inout/PlatformLinkRequest.java new file mode 100644 index 0000000..db2f1b5 --- /dev/null +++ b/src/main/java/com/glxp/udi/admin/req/inout/PlatformLinkRequest.java @@ -0,0 +1,41 @@ +package com.glxp.udi.admin.req.inout; + +import com.glxp.udi.admin.req.ListPageRequest; +import lombok.Data; + +/** + * 医院客户请求参数 + */ +@Data +public class PlatformLinkRequest extends ListPageRequest { + + private Integer id; + + private String unitId; + + private String corpName; + + private String platformId; + + private String platformUsername; + + private String platformPassword; + + private String appid; + + private String apiKey; + + private String secretKey; + + private String sourceAction; + + private String targetAction; + + private String invCode; + + private String invSubCode; + + private String key; + + private String customerId; +} diff --git a/src/main/java/com/glxp/udi/admin/service/basic/StackRulesService.java b/src/main/java/com/glxp/udi/admin/service/basic/StackRulesService.java index 7d246dd..c1c3b29 100644 --- a/src/main/java/com/glxp/udi/admin/service/basic/StackRulesService.java +++ b/src/main/java/com/glxp/udi/admin/service/basic/StackRulesService.java @@ -167,7 +167,7 @@ public class StackRulesService { } else if (list.size() == 1) { for (StackRulesEntity stackRulesEntity : list) { if (stackRulesEntity.getId().equals(stackRules.getId())) { - return "succcess"; + return "success"; } } } @@ -177,4 +177,17 @@ public class StackRulesService { return "只能启用一个规则"; } } + + /** + * 获取当前用户启用的规则的数量 + * + * @return + */ + public Long getEnableRulesNum() { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("status", 1) + .eq("customerId", authAdminService.getCurrentUserCustomerId()); + Long count = stackRulesDao.selectCount(wrapper); + return count; + } } diff --git a/src/main/java/com/glxp/udi/admin/service/info/PlatformService.java b/src/main/java/com/glxp/udi/admin/service/info/PlatformService.java index 6a9576e..b89054c 100644 --- a/src/main/java/com/glxp/udi/admin/service/info/PlatformService.java +++ b/src/main/java/com/glxp/udi/admin/service/info/PlatformService.java @@ -11,13 +11,15 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.glxp.udi.admin.common.enums.ResultEnum; import com.glxp.udi.admin.common.res.BaseResponse; +import com.glxp.udi.admin.common.util.ResultVOUtils; import com.glxp.udi.admin.dao.info.PlatformDao; import com.glxp.udi.admin.dao.inout.UnitMaintainDao; +import com.glxp.udi.admin.dao.inout.UnitMaintainPlatformDao; import com.glxp.udi.admin.entity.info.PlatformEntity; -import com.glxp.udi.admin.req.info.PlatformLinkRequest; +import com.glxp.udi.admin.entity.inout.UnitMaintainPlatform; +import com.glxp.udi.admin.req.inout.PlatformLinkRequest; import com.glxp.udi.admin.res.info.PlatformLinkResponse; import com.glxp.udi.admin.util.HttpClient; -import com.glxp.udi.admin.common.util.ResultVOUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -37,6 +39,8 @@ public class PlatformService { private PlatformDao platformDao; @Resource private UnitMaintainDao unitMaintainDao; + @Resource + private UnitMaintainPlatformDao unitMaintainPlatformDao; public int save(PlatformEntity platformEntity) { if (StringUtils.isEmpty(platformEntity.getId())) { @@ -102,28 +106,24 @@ public class PlatformService { /** * 查询往来单位和自助平台关联数据 * - * @param customerId + * @param platformLinkRequest * @return */ public IPage getLinkPlatformList(PlatformLinkRequest platformLinkRequest) { if (null == platformLinkRequest) { return new Page<>(); } - - IPage page = new Page<>(); - List list = platformDao.getLinkPlatformList(platformLinkRequest.getCustomerId(), platformLinkRequest.getKey()); - page.setRecords(list); - page.setTotal(list.size()); - return page; + IPage page = new Page<>(platformLinkRequest.getPage(), platformLinkRequest.getLimit()); + return unitMaintainPlatformDao.getLinkPlatformList(page, platformLinkRequest.getCustomerId(), platformLinkRequest.getKey()); } /** * 往来单位和自助平台解绑 * - * @param corpId + * @param id */ - public void unbindPlatform(String corpId) { - unitMaintainDao.unbindPlatform(corpId); + public void unbindPlatform(String id) { + unitMaintainPlatformDao.deleteById(id); } /** @@ -157,12 +157,20 @@ public class PlatformService { return ResultVOUtils.success(); } String host = platformEntity.getHost(); - String resp = HttpUtil.get(host + "/spms/inv/warehouse/filterInv/forUdims"); + String url = host + "/spms/inv/warehouse/filterInv/forUdims"; + log.info("拉取自助平台仓库数据:" + url); + String resp = HttpUtil.get(url); + log.info("拉取结果:" + resp); if (StrUtil.isNotBlank(resp) && resp.contains("20000")) { - return JSON.parseObject(resp, BaseResponse.class); + try { + return JSON.parseObject(resp, BaseResponse.class); + } catch (Exception e) { + log.error("格式化自助平台仓库信息异常", e); + return ResultVOUtils.error(500, "调用自助平台接口异常"); + } } else { log.error("获取自助平台仓库失败"); - return ResultVOUtils.error(500, "获取自助平台接口异常"); + return ResultVOUtils.error(500, "调用自助平台接口异常"); } } @@ -218,4 +226,67 @@ public class PlatformService { public PlatformEntity getPlatformById(String platformId) { return platformDao.selectById(platformId); } + + /** + * 保存医院客户关联关系 + * + * @param unitMaintainPlatform + */ + public void saveUnitPlatform(UnitMaintainPlatform unitMaintainPlatform) { + if (null != unitMaintainPlatform.getId()) { + unitMaintainPlatformDao.updateById(unitMaintainPlatform); + } else { + unitMaintainPlatformDao.insert(unitMaintainPlatform); + } + } + + /** + * 校验关联数据 + * + * @param platformLinkRequest + * @return + */ + public String verifyUnitMaintainPlatform(PlatformLinkRequest platformLinkRequest) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StrUtil.isNotBlank(platformLinkRequest.getUnitId()), UnitMaintainPlatform.COL_UNITID, platformLinkRequest.getUnitId()) + .eq(null != platformLinkRequest.getCustomerId(), UnitMaintainPlatform.COL_CUSTOMERID, platformLinkRequest.getCustomerId()) + .eq(StrUtil.isNotBlank(platformLinkRequest.getPlatformId()), UnitMaintainPlatform.COL_PLATFORMID, platformLinkRequest.getPlatformId()) + .eq(StrUtil.isNotBlank(platformLinkRequest.getSourceAction()), UnitMaintainPlatform.COL_SOURCEACTION, platformLinkRequest.getSourceAction()) + .eq(StrUtil.isNotBlank(platformLinkRequest.getTargetAction()), UnitMaintainPlatform.COL_TARGETACTION, platformLinkRequest.getTargetAction()) + .eq(StrUtil.isNotBlank(platformLinkRequest.getInvCode()), UnitMaintainPlatform.COL_INVCODE, platformLinkRequest.getInvCode()) + .eq(StrUtil.isNotBlank(platformLinkRequest.getInvSubCode()), UnitMaintainPlatform.COL_INVSUBCODE, platformLinkRequest.getInvSubCode()) + .eq(StrUtil.isNotBlank(platformLinkRequest.getAppid()), UnitMaintainPlatform.COL_APPID, platformLinkRequest.getAppid()) + .eq(StrUtil.isNotBlank(platformLinkRequest.getApiKey()), UnitMaintainPlatform.COL_APIKEY, platformLinkRequest.getApiKey()) + .eq(StrUtil.isNotBlank(platformLinkRequest.getSecretKey()), UnitMaintainPlatform.COL_SECRETKEY, platformLinkRequest.getSecretKey()); + List list = unitMaintainPlatformDao.selectList(wrapper); + if (CollUtil.isEmpty(list)) { + return "success"; + } else { + for (UnitMaintainPlatform maintainPlatform : list) { + if (maintainPlatform.getId().equals(platformLinkRequest.getId())) { + return "success"; + } else { + return "重复添加"; + } + } + } + return "重复添加"; + } + + /** + * 查询关联数据 + * + * @param customerId + * @param action + * @param unitId + * @return + */ + public UnitMaintainPlatform findLinkData(long customerId, String action, String unitId) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("customerId", customerId) + .eq("sourceAction", action) + .eq("unitId", unitId); + return unitMaintainPlatformDao.selectOne(wrapper); + } + } diff --git a/src/main/java/com/glxp/udi/admin/service/inout/OrderService.java b/src/main/java/com/glxp/udi/admin/service/inout/OrderService.java index 38c587d..7a3e125 100644 --- a/src/main/java/com/glxp/udi/admin/service/inout/OrderService.java +++ b/src/main/java/com/glxp/udi/admin/service/inout/OrderService.java @@ -78,6 +78,8 @@ public class OrderService { private InvProductDao invProductDao; @Resource private InvProductDetailDao invProductDetailDao; + @Resource + private UnitMaintainPlatformDao unitMaintainPlatformDao; public IPage filterList(OrderFilterRequest orderFilterRequest) { @@ -265,11 +267,11 @@ public class OrderService { */ public boolean checkUpload(OrderEntity order) { //查询此往来单位的本地单据类型 - Integer count = unitMaintainDao.checkUpload(order.getCustomerId(), order.getAction()); - if (count > 0) { - return true; - } - return false; + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("customerId", order.getCustomerId()) + .eq("sourceAction", order.getAction()); + Long count = unitMaintainPlatformDao.selectCount(wrapper); + return count > 0; } /** diff --git a/src/main/java/com/glxp/udi/admin/thread/SubmitOrderToSpmsTask.java b/src/main/java/com/glxp/udi/admin/thread/SubmitOrderToSpmsTask.java index c11ed54..cf7c791 100644 --- a/src/main/java/com/glxp/udi/admin/thread/SubmitOrderToSpmsTask.java +++ b/src/main/java/com/glxp/udi/admin/thread/SubmitOrderToSpmsTask.java @@ -2,7 +2,6 @@ package com.glxp.udi.admin.thread; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; @@ -10,22 +9,20 @@ import com.glxp.udi.admin.common.res.BaseResponse; import com.glxp.udi.admin.constant.SystemParamConstant; import com.glxp.udi.admin.dao.info.ScheduledDao; import com.glxp.udi.admin.entity.info.PlatformEntity; -import com.glxp.udi.admin.entity.info.ScheduledEntity; import com.glxp.udi.admin.entity.inout.OrderDetailEntity; import com.glxp.udi.admin.entity.inout.OrderEntity; import com.glxp.udi.admin.entity.inout.UnitMaintainEntity; import com.glxp.udi.admin.entity.inout.WarehouseEntity; import com.glxp.udi.admin.entity.param.SystemParamConfigEntity; -import com.glxp.udi.admin.service.inout.OrderDetailService; -import com.glxp.udi.admin.service.inout.OrderService; -import com.glxp.udi.admin.service.inout.WarehouseService; import com.glxp.udi.admin.req.inout.FilterOrderDetailRequest; import com.glxp.udi.admin.req.inout.PostUdimsOrderDetailRequest; import com.glxp.udi.admin.req.inout.PostUdimsOrderRequest; import com.glxp.udi.admin.req.inout.WarehouseQueryRequest; -import com.glxp.udi.admin.req.udidl.ScheduledRequest; import com.glxp.udi.admin.service.info.PlatformService; +import com.glxp.udi.admin.service.inout.OrderDetailService; +import com.glxp.udi.admin.service.inout.OrderService; import com.glxp.udi.admin.service.inout.UnitMaintainService; +import com.glxp.udi.admin.service.inout.WarehouseService; import com.glxp.udi.admin.service.param.SystemParamConfigService; import com.glxp.udi.admin.service.param.SystemParamCustomerConfigService; import com.glxp.udi.admin.util.HttpClient; @@ -34,7 +31,6 @@ import org.springframework.beans.BeanUtils; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.SchedulingConfigurer; import org.springframework.scheduling.config.ScheduledTaskRegistrar; -import org.springframework.scheduling.support.CronTrigger; import org.springframework.stereotype.Component; import javax.annotation.Resource; @@ -69,7 +65,7 @@ public class SubmitOrderToSpmsTask implements SchedulingConfigurer { @Override public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { - taskRegistrar.addTriggerTask(this::process, triggerContext -> { + /* taskRegistrar.addTriggerTask(this::process, triggerContext -> { ScheduledRequest scheduledRequest = new ScheduledRequest(); scheduledRequest.setCronName("submitOrderToSpmsTask"); ScheduledEntity scheduled = scheduledDao.findScheduled(scheduledRequest); @@ -78,7 +74,7 @@ public class SubmitOrderToSpmsTask implements SchedulingConfigurer { log.error("cron is null"); } return new CronTrigger(cron).nextExecutionTime(triggerContext); - }); + });*/ } private void process() { diff --git a/src/main/java/com/glxp/udi/admin/thread/SupplementOrderTask.java b/src/main/java/com/glxp/udi/admin/thread/SupplementOrderTask.java index 95bc5a2..5c47924 100644 --- a/src/main/java/com/glxp/udi/admin/thread/SupplementOrderTask.java +++ b/src/main/java/com/glxp/udi/admin/thread/SupplementOrderTask.java @@ -4,17 +4,14 @@ import cn.hutool.core.collection.CollUtil; import com.glxp.udi.admin.common.res.BaseResponse; import com.glxp.udi.admin.constant.SystemParamConstant; import com.glxp.udi.admin.dao.info.ScheduledDao; -import com.glxp.udi.admin.entity.info.ScheduledEntity; import com.glxp.udi.admin.entity.inout.OrderEntity; import com.glxp.udi.admin.entity.param.SystemParamConfigEntity; import com.glxp.udi.admin.service.inout.OrderService; -import com.glxp.udi.admin.req.udidl.ScheduledRequest; import com.glxp.udi.admin.service.param.SystemParamConfigService; import lombok.extern.slf4j.Slf4j; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.SchedulingConfigurer; import org.springframework.scheduling.config.ScheduledTaskRegistrar; -import org.springframework.scheduling.support.CronTrigger; import org.springframework.stereotype.Component; import javax.annotation.Resource; @@ -38,7 +35,7 @@ public class SupplementOrderTask implements SchedulingConfigurer { @Override public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { - taskRegistrar.addTriggerTask(this::process, + /*taskRegistrar.addTriggerTask(this::process, triggerContext -> { ScheduledRequest scheduledRequest = new ScheduledRequest(); scheduledRequest.setCronName("supplementOrderTask"); @@ -48,7 +45,7 @@ public class SupplementOrderTask implements SchedulingConfigurer { log.error("cron is null"); } return new CronTrigger(cron).nextExecutionTime(triggerContext); - }); + });*/ } private void process() { diff --git a/src/main/java/com/glxp/udi/admin/thread/TransInoutTask.java b/src/main/java/com/glxp/udi/admin/thread/TransInoutTask.java index 189ad6e..55de5f0 100644 --- a/src/main/java/com/glxp/udi/admin/thread/TransInoutTask.java +++ b/src/main/java/com/glxp/udi/admin/thread/TransInoutTask.java @@ -4,19 +4,16 @@ import cn.hutool.core.collection.CollUtil; import com.glxp.udi.admin.constant.ConstantStatus; import com.glxp.udi.admin.constant.SystemParamConstant; import com.glxp.udi.admin.dao.info.ScheduledDao; -import com.glxp.udi.admin.entity.info.ScheduledEntity; import com.glxp.udi.admin.entity.inout.OrderEntity; import com.glxp.udi.admin.entity.param.SystemParamConfigEntity; -import com.glxp.udi.admin.service.inout.OrderService; import com.glxp.udi.admin.req.inout.OrderFilterRequest; -import com.glxp.udi.admin.req.udidl.ScheduledRequest; +import com.glxp.udi.admin.service.inout.OrderService; import com.glxp.udi.admin.service.param.SystemParamConfigService; import com.glxp.udi.admin.service.param.SystemParamCustomerConfigService; import lombok.extern.slf4j.Slf4j; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.SchedulingConfigurer; import org.springframework.scheduling.config.ScheduledTaskRegistrar; -import org.springframework.scheduling.support.CronTrigger; import org.springframework.stereotype.Component; import javax.annotation.Resource; @@ -40,7 +37,7 @@ public class TransInoutTask implements SchedulingConfigurer { @Override public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) { - scheduledTaskRegistrar.addTriggerTask(this::process, + /* scheduledTaskRegistrar.addTriggerTask(this::process, triggerContext -> { ScheduledRequest scheduledRequest = new ScheduledRequest(); scheduledRequest.setCronName("transInout"); @@ -50,7 +47,7 @@ public class TransInoutTask implements SchedulingConfigurer { log.error("cron is null"); } return new CronTrigger(cron).nextExecutionTime(triggerContext); - }); + });*/ } private void process() { diff --git a/src/main/resources/mybatis/mapper/info/PlatformDao.xml b/src/main/resources/mybatis/mapper/info/PlatformDao.xml index 0f9acb9..33ab96e 100644 --- a/src/main/resources/mybatis/mapper/info/PlatformDao.xml +++ b/src/main/resources/mybatis/mapper/info/PlatformDao.xml @@ -51,32 +51,6 @@ - - - - + select up.id, + up.unitId, + u.name corpName, + u.corpType, + u.pinyinCode, + ap.name platformName, + ap.id platformId, + up.sourceAction, + up.targetAction, + up.invCode, + up.invSubCode + from io_unit_maintain_platform up + left join io_unit_maintain u on up.unitId = u.unitId + left join auth_platform ap on up.platformId = ap.id + where up.customerId = #{customerId} + + AND (u.unitId like concat('%', #{key}, '%') + or u.name like concat('%', #{key}, '%') + or u.pinyinCode like concat('%', #{key}, '%') + ) + + + \ No newline at end of file