1.移除提交单据到自助平台功能代码
parent
8615658570
commit
064ccaef2b
@ -1,250 +0,0 @@
|
||||
package com.glxp.api.admin.controller.info;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.glxp.api.admin.annotation.AuthRuleAnnotation;
|
||||
import com.glxp.api.admin.entity.info.PlatformEntity;
|
||||
import com.glxp.api.admin.entity.inout.UnitMaintainPlatformEntity;
|
||||
import com.glxp.api.admin.req.info.PlatformUserInfoRequest;
|
||||
import com.glxp.api.admin.req.inout.DeleteRequest;
|
||||
import com.glxp.api.admin.req.inout.PlatformLinkRequest;
|
||||
import com.glxp.api.admin.res.PageSimpleResponse;
|
||||
import com.glxp.api.admin.res.info.PlatformLinkResponse;
|
||||
import com.glxp.api.admin.service.auth.CustomerService;
|
||||
import com.glxp.api.admin.service.info.PlatformService;
|
||||
import com.glxp.api.common.enums.ResultEnum;
|
||||
import com.glxp.api.common.res.BaseResponse;
|
||||
import com.glxp.api.common.util.ResultVOUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@Slf4j
|
||||
public class PlatformController {
|
||||
|
||||
@Resource
|
||||
private PlatformService platformService;
|
||||
@Resource
|
||||
private CustomerService customerService;
|
||||
|
||||
@AuthRuleAnnotation("")
|
||||
@PostMapping("/udiwms/platform/remove")
|
||||
public BaseResponse remove(@RequestBody PlatformEntity platformEntity) {
|
||||
if (platformService.remove(platformEntity.getId()) > 0) {
|
||||
ResultVOUtils.success("删除成功");
|
||||
}
|
||||
return ResultVOUtils.error(500, "删除失败");
|
||||
}
|
||||
|
||||
|
||||
@AuthRuleAnnotation("")
|
||||
@PostMapping("/udiwms/platform/update")
|
||||
public BaseResponse update(@RequestBody PlatformEntity platformEntity) {
|
||||
if (StrUtil.isBlank(platformEntity.getName()) || StrUtil.isBlank(platformEntity.getHost())) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "参数不能为空");
|
||||
}
|
||||
return platformService.update(platformEntity);
|
||||
}
|
||||
|
||||
@AuthRuleAnnotation("")
|
||||
@GetMapping("/udiwms/platform/list")
|
||||
public BaseResponse list(@RequestParam Map<String, Object> params) {
|
||||
List<PlatformEntity> list = platformService.list(params);
|
||||
PageInfo<PlatformEntity> pageInfo = new PageInfo<>(list);
|
||||
PageSimpleResponse<PlatformEntity> pageSimpleResponse = new PageSimpleResponse<>();
|
||||
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
||||
pageSimpleResponse.setList(pageInfo.getList());
|
||||
return ResultVOUtils.success(pageSimpleResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试账号连通性
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@AuthRuleAnnotation("")
|
||||
@PostMapping("/udiwms/platform/testUserInfo")
|
||||
public BaseResponse testUserInfo(@RequestBody PlatformUserInfoRequest platformUserInfoRequest, BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||||
}
|
||||
|
||||
PlatformEntity platformEntity = platformService.getPlatformById(platformUserInfoRequest.getPlatformId());
|
||||
if (null == platformEntity || StrUtil.isBlank(platformEntity.getHost())) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||||
}
|
||||
|
||||
String url = platformEntity.getHost() + "/verify";
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("username", platformUserInfoRequest.getUsername());
|
||||
map.put("password", platformUserInfoRequest.getPassword());
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
|
||||
|
||||
HttpEntity<String> request = new HttpEntity<>(JSON.toJSONString(map), headers);
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
log.error(url);
|
||||
|
||||
String result = restTemplate.postForObject(url, request, String.class, map);
|
||||
log.error(result);
|
||||
Map<String, Object> object = JSON.parseObject(result, Map.class);
|
||||
if (!String.valueOf(object.get("code")).equals("20000")) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, String.valueOf(object.get("message")));
|
||||
}
|
||||
return ResultVOUtils.success();
|
||||
}
|
||||
|
||||
@AuthRuleAnnotation("")
|
||||
@PostMapping("/udiwms/platform/link")
|
||||
public BaseResponse update(@RequestBody PlatformLinkRequest platformLinkRequest) {
|
||||
//判断此数据是否重复
|
||||
String verifyResult = platformService.verifyUnitMaintainPlatform(platformLinkRequest);
|
||||
if (!verifyResult.equals("success")) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, verifyResult);
|
||||
}
|
||||
|
||||
platformLinkRequest.setCustomerId(String.valueOf(customerService.getUserBean().getCustomerId()));
|
||||
|
||||
PlatformEntity platformEntity = platformService.get(platformLinkRequest.getPlatformId());
|
||||
if (platformEntity != null) {
|
||||
String url = platformEntity.getHost() + "/verify";
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("username", platformLinkRequest.getPlatformUsername());
|
||||
map.put("password", platformLinkRequest.getPlatformPassword());
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
|
||||
|
||||
HttpEntity<String> request = new HttpEntity<String>(JSON.toJSONString(map), headers);
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
log.error(url);
|
||||
|
||||
String result = restTemplate.postForObject(url, request, String.class, map);
|
||||
log.error(result);
|
||||
Map<String, Object> object = JSON.parseObject(result, Map.class);
|
||||
|
||||
if (object != null && object.get("data") != null) {
|
||||
Map<String, Object> data = JSON.parseObject(JSON.toJSONString(object.get("data")), Map.class);
|
||||
log.error(JSON.toJSONString(object.get("data")));
|
||||
if (data.get("appid") != null) {
|
||||
platformLinkRequest.setAppid(data.get("appid").toString());
|
||||
if (data.get("apiKey") != null) {
|
||||
platformLinkRequest.setApiKey(data.get("apiKey").toString());
|
||||
}
|
||||
if (data.get("secretKey") != null) {
|
||||
platformLinkRequest.setSecretKey(data.get("secretKey").toString());
|
||||
}
|
||||
} else {
|
||||
return ResultVOUtils.error(500, "关联验证失败,请联系管理人员");
|
||||
}
|
||||
} else if (object != null && object.get("message") != null) {
|
||||
return ResultVOUtils.error(500, object.get("message").toString());
|
||||
} else {
|
||||
return ResultVOUtils.error(500, "关联失败,请联系管理人员");
|
||||
}
|
||||
} else {
|
||||
return ResultVOUtils.error(500, "未查询到平台信息");
|
||||
}
|
||||
UnitMaintainPlatformEntity unitMaintainPlatform = new UnitMaintainPlatformEntity();
|
||||
BeanUtil.copyProperties(platformLinkRequest, unitMaintainPlatform);
|
||||
platformService.saveUnitPlatform(unitMaintainPlatform);
|
||||
return ResultVOUtils.success("关联成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取往来单位与自助平台关联数据
|
||||
*/
|
||||
@AuthRuleAnnotation("")
|
||||
@GetMapping("/udiwms/platform/getLinkPlatformList")
|
||||
public BaseResponse getLinkPlatformList(PlatformLinkRequest platformLinkRequest, BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||||
}
|
||||
platformLinkRequest.setCustomerId(String.valueOf(customerService.getUserBean().getCustomerId()));
|
||||
List<PlatformLinkResponse> list = platformService.getLinkPlatformList(platformLinkRequest);
|
||||
PageInfo<PlatformLinkResponse> pageInfo = new PageInfo<>(list);
|
||||
PageSimpleResponse<PlatformLinkResponse> pageSimpleResponse = new PageSimpleResponse<>();
|
||||
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
||||
pageSimpleResponse.setList(pageInfo.getList());
|
||||
return ResultVOUtils.success(pageSimpleResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解绑往来单位和自助平台的关联
|
||||
*
|
||||
* @param corpId
|
||||
* @return
|
||||
*/
|
||||
@AuthRuleAnnotation("")
|
||||
@PostMapping("/udiwms/platform/unbind")
|
||||
public BaseResponse unbindPlatform(DeleteRequest deleteRequest) {
|
||||
if (StrUtil.isBlank(deleteRequest.getId())) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||||
}
|
||||
platformService.unbindPlatform(deleteRequest.getId());
|
||||
return ResultVOUtils.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应平台单据类型
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@AuthRuleAnnotation("")
|
||||
@GetMapping("/udiwms/platform/getTargetActions")
|
||||
public BaseResponse getTargetActions(String platformId, String invSubCode) {
|
||||
if (StrUtil.isBlank(platformId)) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||||
}
|
||||
return platformService.getTargetActions(platformId, invSubCode);
|
||||
}
|
||||
|
||||
|
||||
@AuthRuleAnnotation("")
|
||||
@GetMapping("/udiwms/platform/getTargetInv")
|
||||
public BaseResponse getTargetInv(String platformId) {
|
||||
if (StrUtil.isBlank(platformId)) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||||
}
|
||||
return platformService.getTargetInv(platformId);
|
||||
}
|
||||
|
||||
@AuthRuleAnnotation("")
|
||||
@GetMapping("/udiwms/platform/getTargetSubInv")
|
||||
public BaseResponse getTargetSubInv(String platformId, String invCode) {
|
||||
if (StrUtil.isBlank(platformId)) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||||
}
|
||||
return platformService.getTargetSubInv(platformId, invCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试自助平台连通性
|
||||
*
|
||||
* @param host
|
||||
* @return
|
||||
*/
|
||||
@AuthRuleAnnotation("")
|
||||
@GetMapping("udiwms/platform/testPlatformConnection")
|
||||
public BaseResponse testPlatformConnection(String host) {
|
||||
if (StrUtil.isBlank(host)) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||||
}
|
||||
return platformService.testPlatformConnection(host);
|
||||
}
|
||||
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
package com.glxp.api.admin.dao.info;
|
||||
|
||||
import com.glxp.api.admin.entity.info.PlatformEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface PlatformDao{
|
||||
|
||||
int batchSave(List<PlatformEntity> list);
|
||||
|
||||
List<PlatformEntity> list( Map<String, Object> map);
|
||||
|
||||
int count(Map<String, Object> map);
|
||||
|
||||
PlatformEntity get(String id);
|
||||
|
||||
/**
|
||||
* 根据名称和访问地址查询平台信息
|
||||
*
|
||||
* @param name
|
||||
* @param host
|
||||
* @return
|
||||
*/
|
||||
List<PlatformEntity> selectByNameAndHost(@Param("name") String name, @Param("host") String host);
|
||||
|
||||
PlatformEntity selectById(@Param("platformId") String platformId);
|
||||
|
||||
int insert(PlatformEntity platformEntity);
|
||||
|
||||
List<PlatformEntity> selectList(@Param("id") String id, @Param("name") String name, @Param("host") String host);
|
||||
|
||||
int deleteById(@Param("id") String id);
|
||||
|
||||
void updateById(PlatformEntity platformEntity);
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package com.glxp.api.admin.dao.inout;
|
||||
|
||||
import com.glxp.api.admin.entity.inout.UnitMaintainPlatformEntity;
|
||||
import com.glxp.api.admin.req.inout.PlatformLinkRequest;
|
||||
import com.glxp.api.admin.res.info.PlatformLinkResponse;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface UnitMaintainPlatformDao{
|
||||
|
||||
/**
|
||||
* 查询医院客户列表
|
||||
*
|
||||
* @param page
|
||||
* @param customerId
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
List<PlatformLinkResponse> getLinkPlatformList(@Param("customerId") String customerId, @Param("key") String key);
|
||||
|
||||
/**
|
||||
* 根据客户ID查询关联数据
|
||||
*
|
||||
* @param customerId
|
||||
* @return
|
||||
*/
|
||||
List<UnitMaintainPlatformEntity> selectByCustomerId(@Param("customerId") Long customerId);
|
||||
|
||||
void updateById(UnitMaintainPlatformEntity maintainPlatform);
|
||||
|
||||
void insert(UnitMaintainPlatformEntity unitMaintainPlatformEntity);
|
||||
|
||||
List<UnitMaintainPlatformEntity> selectList(PlatformLinkRequest platformLinkRequest);
|
||||
|
||||
UnitMaintainPlatformEntity findLinkData(@Param("customerId") long customerId, @Param("action") String action, @Param("unitId") String unitId);
|
||||
|
||||
void deleteById(String id);
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
package com.glxp.api.admin.entity.inout;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 医院客户表
|
||||
*/
|
||||
@Data
|
||||
public class UnitMaintainPlatformEntity {
|
||||
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 往来单位ID
|
||||
*/
|
||||
private String unitId;
|
||||
|
||||
/**
|
||||
* 客户ID
|
||||
*/
|
||||
private Long customerId;
|
||||
|
||||
/**
|
||||
* 平台ID
|
||||
*/
|
||||
private String platformId;
|
||||
|
||||
/**
|
||||
* 源单据类型
|
||||
*/
|
||||
private String sourceAction;
|
||||
|
||||
/**
|
||||
* 目标单据类型
|
||||
*/
|
||||
private String targetAction;
|
||||
|
||||
/**
|
||||
* 仓库码
|
||||
*/
|
||||
private String invCode;
|
||||
|
||||
/**
|
||||
* 分库码
|
||||
*/
|
||||
private String invSubCode;
|
||||
|
||||
/**
|
||||
* 应用名称
|
||||
*/
|
||||
private String appid;
|
||||
|
||||
/**
|
||||
* 秘钥
|
||||
*/
|
||||
private String secretKey;
|
||||
|
||||
/**
|
||||
* 应用ID
|
||||
*/
|
||||
private String apiKey;
|
||||
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package com.glxp.api.admin.req.inout;
|
||||
|
||||
import com.glxp.api.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;
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package com.glxp.api.admin.req.inout;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PostUdimsOrderRequest {
|
||||
|
||||
List<OrderBean> orderBeans;
|
||||
private String customerId;
|
||||
|
||||
|
||||
@Data
|
||||
public static class OrderBean {
|
||||
private String orderId;
|
||||
private String corpOrderId;
|
||||
private String action;
|
||||
private String actDate;
|
||||
private String actor;
|
||||
private String mainAction;
|
||||
private String fromCorpId;
|
||||
private String fromCorp;
|
||||
private String remark;
|
||||
private String invStorageCode;
|
||||
private String invWarehouseCode;
|
||||
private List<PostUdimsOrderDetailRequest> orderDetails;
|
||||
private List<CodeBean> codes;
|
||||
|
||||
@Data
|
||||
public static class CodeBean {
|
||||
private String action;
|
||||
private String mainAction;
|
||||
private String code;
|
||||
private String corpOrderId;
|
||||
private String actor;
|
||||
private String actDate;
|
||||
private String fromCorpId;
|
||||
private String fromCorp;
|
||||
private String orderId;
|
||||
private String batchNo;
|
||||
private String produceDate;
|
||||
private String expireDate;
|
||||
private String serialNo;
|
||||
private Integer count;
|
||||
private String packageLevel;
|
||||
private String warehouseCode;
|
||||
|
||||
private String customerId;
|
||||
private String nameCode;
|
||||
private String supId;//供应商ID
|
||||
private String invStorageCode;
|
||||
private String invWarehouseCode;
|
||||
private String relId;
|
||||
private Integer status;
|
||||
private String locStorageCode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
package com.glxp.api.admin.service.info;
|
||||
|
||||
|
||||
import com.glxp.api.admin.entity.info.PlatformEntity;
|
||||
import com.glxp.api.admin.entity.inout.UnitMaintainPlatformEntity;
|
||||
import com.glxp.api.admin.req.inout.PlatformLinkRequest;
|
||||
import com.glxp.api.admin.res.info.PlatformLinkResponse;
|
||||
import com.glxp.api.common.res.BaseResponse;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface PlatformService {
|
||||
|
||||
|
||||
public int save(PlatformEntity platformEntity);
|
||||
|
||||
public int remove(String id);
|
||||
|
||||
public BaseResponse update(PlatformEntity platformEntity);
|
||||
|
||||
List<PlatformEntity> list(Map<String, Object> map);
|
||||
|
||||
int count(Map<String, Object> map);
|
||||
|
||||
PlatformEntity get(String id);
|
||||
|
||||
/**
|
||||
* 查询往来单位和自助平台关联数据
|
||||
*
|
||||
* @param platformLinkRequest
|
||||
* @return
|
||||
*/
|
||||
List<PlatformLinkResponse> getLinkPlatformList(PlatformLinkRequest platformLinkRequest);
|
||||
|
||||
/**
|
||||
* 往来单位和自助平台解绑
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void unbindPlatform(String id);
|
||||
|
||||
/**
|
||||
* 获取自助平台单据类型
|
||||
*
|
||||
* @param platformId
|
||||
* @return
|
||||
*/
|
||||
BaseResponse getTargetActions(String platformId, String invSubCode);
|
||||
|
||||
|
||||
//获取自助平台一级仓库
|
||||
BaseResponse getTargetInv(String platformId);
|
||||
|
||||
|
||||
//获取自助平台一级仓库所属分库
|
||||
BaseResponse getTargetSubInv(String platformId, String invCode);
|
||||
|
||||
/**
|
||||
* 测试自助平台连通性
|
||||
*
|
||||
* @param host
|
||||
* @return
|
||||
*/
|
||||
BaseResponse testPlatformConnection(String host);
|
||||
|
||||
/**
|
||||
* 根据ID查询自助平台信息
|
||||
*
|
||||
* @param platformId
|
||||
* @return
|
||||
*/
|
||||
PlatformEntity getPlatformById(String platformId);
|
||||
|
||||
/**
|
||||
* 保存医院客户关联关系
|
||||
*
|
||||
* @param unitMaintainPlatform
|
||||
*/
|
||||
void saveUnitPlatform(UnitMaintainPlatformEntity unitMaintainPlatform);
|
||||
|
||||
/**
|
||||
* 校验关联数据
|
||||
*
|
||||
* @param platformLinkRequest
|
||||
* @return
|
||||
*/
|
||||
public String verifyUnitMaintainPlatform(PlatformLinkRequest platformLinkRequest);
|
||||
|
||||
/**
|
||||
* 查询关联数据
|
||||
*
|
||||
* @param customerId
|
||||
* @param action
|
||||
* @param unitId
|
||||
* @return
|
||||
*/
|
||||
UnitMaintainPlatformEntity findLinkData(long customerId, String action, String unitId);
|
||||
|
||||
|
||||
}
|
@ -1,272 +0,0 @@
|
||||
package com.glxp.api.admin.service.info.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.glxp.api.admin.dao.info.PlatformDao;
|
||||
import com.glxp.api.admin.dao.inout.UnitMaintainPlatformDao;
|
||||
import com.glxp.api.admin.entity.info.PlatformEntity;
|
||||
import com.glxp.api.admin.entity.inout.UnitMaintainPlatformEntity;
|
||||
import com.glxp.api.admin.req.inout.PlatformLinkRequest;
|
||||
import com.glxp.api.admin.res.info.PlatformLinkResponse;
|
||||
import com.glxp.api.admin.service.info.PlatformService;
|
||||
import com.glxp.api.admin.util.HttpClient;
|
||||
import com.glxp.api.common.enums.ResultEnum;
|
||||
import com.glxp.api.common.res.BaseResponse;
|
||||
import com.glxp.api.common.util.ResultVOUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class PlatformServiceImpl implements PlatformService {
|
||||
|
||||
@Resource
|
||||
private PlatformDao platformDao;
|
||||
@Resource
|
||||
private UnitMaintainPlatformDao unitMaintainPlatformDao;
|
||||
|
||||
public int save(PlatformEntity platformEntity) {
|
||||
if (StringUtils.isEmpty(platformEntity.getId())) {
|
||||
platformEntity.setId(String.valueOf(IdUtil.getSnowflake().nextId()));
|
||||
}
|
||||
return platformDao.insert(platformEntity);
|
||||
}
|
||||
|
||||
public int remove(String id) {
|
||||
return platformDao.deleteById(id);
|
||||
}
|
||||
|
||||
public BaseResponse update(PlatformEntity platformEntity) {
|
||||
if (StrUtil.isBlank(platformEntity.getId())) {
|
||||
if (!verifyPlatformExist(platformEntity)) {
|
||||
save(platformEntity);
|
||||
return ResultVOUtils.success("添加成功");
|
||||
} else {
|
||||
return ResultVOUtils.error(500, "已存在相同数据");
|
||||
}
|
||||
}
|
||||
platformDao.updateById(platformEntity);
|
||||
return ResultVOUtils.success("更新成功");
|
||||
}
|
||||
|
||||
private boolean verifyPlatformExist(PlatformEntity platformEntity) {
|
||||
//校验名称和地址是否重复
|
||||
List<PlatformEntity> list = platformDao.selectByNameAndHost(platformEntity.getName(), platformEntity.getHost());
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<PlatformEntity> list(Map<String, Object> map) {
|
||||
if (map.get("page") != null && map.get("limit") != null) {
|
||||
Integer page = Integer.valueOf(String.valueOf(map.get("page")));
|
||||
Integer limit = Integer.valueOf(String.valueOf(map.get("limit")));
|
||||
PageHelper.offsetPage((page - 1) * limit, limit);
|
||||
}
|
||||
List<PlatformEntity> list = platformDao.selectList(String.valueOf(map.get("id")), String.valueOf(map.get("name")), String.valueOf(map.get("host")));
|
||||
return list;
|
||||
}
|
||||
|
||||
public int count(Map<String, Object> map) {
|
||||
return platformDao.count(map);
|
||||
}
|
||||
|
||||
public PlatformEntity get(String id) {
|
||||
return platformDao.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询往来单位和自助平台关联数据
|
||||
*
|
||||
* @param platformLinkRequest
|
||||
* @return
|
||||
*/
|
||||
public List<PlatformLinkResponse> getLinkPlatformList(PlatformLinkRequest platformLinkRequest) {
|
||||
if (null == platformLinkRequest) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (null != platformLinkRequest.getPage() && null != platformLinkRequest.getLimit()) {
|
||||
PageHelper.offsetPage((platformLinkRequest.getPage() - 1) * platformLinkRequest.getLimit(), platformLinkRequest.getLimit());
|
||||
}
|
||||
return unitMaintainPlatformDao.getLinkPlatformList(platformLinkRequest.getCustomerId(), platformLinkRequest.getKey());
|
||||
}
|
||||
|
||||
/**
|
||||
* 往来单位和自助平台解绑
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void unbindPlatform(String id) {
|
||||
unitMaintainPlatformDao.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取自助平台单据类型
|
||||
*
|
||||
* @param platformId
|
||||
* @return
|
||||
*/
|
||||
public BaseResponse getTargetActions(String platformId, String invSubCode) {
|
||||
PlatformEntity platformEntity = platformDao.get(platformId);
|
||||
if (null == platformEntity) {
|
||||
return ResultVOUtils.success();
|
||||
}
|
||||
String host = platformEntity.getHost();
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("invSubCode", invSubCode);
|
||||
String resp = HttpClient.mipsGet(host + "/udiwms/bussinessType/udimsFilter", paramMap);
|
||||
if (StrUtil.isNotBlank(resp) && resp.contains("20000")) {
|
||||
return JSON.parseObject(resp, BaseResponse.class);
|
||||
} else {
|
||||
log.error("获取自助平台单据类型异常");
|
||||
return ResultVOUtils.error(500, "获取自助平台接口异常");
|
||||
}
|
||||
}
|
||||
|
||||
//获取自助平台一级仓库
|
||||
public BaseResponse getTargetInv(String platformId) {
|
||||
PlatformEntity platformEntity = platformDao.get(platformId);
|
||||
if (null == platformEntity) {
|
||||
return ResultVOUtils.success();
|
||||
}
|
||||
String host = platformEntity.getHost();
|
||||
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")) {
|
||||
try {
|
||||
return JSON.parseObject(resp, BaseResponse.class);
|
||||
} catch (Exception e) {
|
||||
log.error("格式化自助平台仓库信息异常", e);
|
||||
return ResultVOUtils.error(500, "调用自助平台接口异常");
|
||||
}
|
||||
} else {
|
||||
log.error("获取自助平台仓库失败");
|
||||
return ResultVOUtils.error(500, "调用自助平台接口异常");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//获取自助平台一级仓库所属分库
|
||||
public BaseResponse getTargetSubInv(String platformId, String invCode) {
|
||||
PlatformEntity platformEntity = platformDao.get(platformId);
|
||||
if (null == platformEntity) {
|
||||
return ResultVOUtils.success();
|
||||
}
|
||||
String host = platformEntity.getHost();
|
||||
Map<String, String> paramMap = new HashMap<>();
|
||||
paramMap.put("invCode", invCode);
|
||||
String resp = HttpClient.mipsGet(host + "/spms/sub/inv/warehouse/getSubInvForUdims", paramMap);
|
||||
if (StrUtil.isNotBlank(resp) && resp.contains("20000")) {
|
||||
return JSON.parseObject(resp, BaseResponse.class);
|
||||
} else {
|
||||
log.error("获取自助平台分库失败");
|
||||
return ResultVOUtils.error(500, "获取自助平台接口异常");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试自助平台连通性
|
||||
*
|
||||
* @param host
|
||||
* @return
|
||||
*/
|
||||
public BaseResponse testPlatformConnection(String host) {
|
||||
String testUrl = host + "/udiwms/auth/device/connect";
|
||||
String response = HttpUtil.get(testUrl);
|
||||
if (StrUtil.isNotBlank(response)) {
|
||||
try {
|
||||
BaseResponse result = JSONUtil.toBean(response, BaseResponse.class);
|
||||
if (result.getCode() == 20000) {
|
||||
return ResultVOUtils.success();
|
||||
}
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||||
} catch (Exception e) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||||
}
|
||||
} else {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询自助平台信息
|
||||
*
|
||||
* @param platformId
|
||||
* @return
|
||||
*/
|
||||
public PlatformEntity getPlatformById(String platformId) {
|
||||
return platformDao.selectById(platformId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存医院客户关联关系
|
||||
*
|
||||
* @param unitMaintainPlatformEntity
|
||||
*/
|
||||
public void saveUnitPlatform(UnitMaintainPlatformEntity unitMaintainPlatformEntity) {
|
||||
if (null != unitMaintainPlatformEntity.getId()) {
|
||||
unitMaintainPlatformDao.updateById(unitMaintainPlatformEntity);
|
||||
} else {
|
||||
unitMaintainPlatformDao.insert(unitMaintainPlatformEntity);
|
||||
}
|
||||
|
||||
//更新当前客户关联数据的所有key
|
||||
List<UnitMaintainPlatformEntity> list = unitMaintainPlatformDao.selectByCustomerId(unitMaintainPlatformEntity.getCustomerId());
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
for (UnitMaintainPlatformEntity maintainPlatform : list) {
|
||||
maintainPlatform.setAppid(unitMaintainPlatformEntity.getAppid());
|
||||
maintainPlatform.setApiKey(unitMaintainPlatformEntity.getApiKey());
|
||||
maintainPlatform.setSecretKey(unitMaintainPlatformEntity.getSecretKey());
|
||||
unitMaintainPlatformDao.updateById(maintainPlatform);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String verifyUnitMaintainPlatform(PlatformLinkRequest platformLinkRequest) {
|
||||
List<UnitMaintainPlatformEntity> list = unitMaintainPlatformDao.selectList(platformLinkRequest);
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return "success";
|
||||
} else {
|
||||
for (UnitMaintainPlatformEntity maintainPlatform : list) {
|
||||
if (maintainPlatform.getId().equals(platformLinkRequest.getId())) {
|
||||
return "success";
|
||||
} else {
|
||||
return "重复添加";
|
||||
}
|
||||
}
|
||||
}
|
||||
return "重复添加";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询关联数据
|
||||
*
|
||||
* @param customerId
|
||||
* @param action
|
||||
* @param unitId
|
||||
* @return
|
||||
*/
|
||||
public UnitMaintainPlatformEntity findLinkData(long customerId, String action, String unitId) {
|
||||
return unitMaintainPlatformDao.findLinkData(customerId, action, unitId);
|
||||
}
|
||||
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
|
||||
<mapper namespace="com.glxp.api.admin.dao.info.PlatformDao">
|
||||
<insert id="batchSave" parameterType="java.util.List">
|
||||
replace into auth_platform
|
||||
(id, name, host)
|
||||
values
|
||||
<foreach item="item" index="index" collection="list"
|
||||
separator=",">
|
||||
(#{item.id}, #{item.name,jdbcType=VARCHAR}, #{item.host,jdbcType=VARCHAR})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
<select id="get" resultType="com.glxp.api.admin.entity.info.PlatformEntity">
|
||||
select *
|
||||
from auth_platform
|
||||
where id = #{value}
|
||||
</select>
|
||||
|
||||
<select id="list" resultType="com.glxp.api.admin.entity.info.PlatformEntity">
|
||||
select *
|
||||
from auth_platform
|
||||
<where>
|
||||
<if test="id != null and id != ''">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
and instr(name, #{name})
|
||||
</if>
|
||||
<if test="host != null and host != ''">
|
||||
and instr(host, #{host})
|
||||
</if>
|
||||
</where>
|
||||
order by id desc
|
||||
</select>
|
||||
<select id="count" resultType="int">
|
||||
select count(*)
|
||||
from auth_platform
|
||||
<where>
|
||||
<if test="id != null and id != ''">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
and instr(name, #{name})
|
||||
</if>
|
||||
<if test="host != null and host != ''">
|
||||
and instr(host, #{host})
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectByNameAndHost" resultType="com.glxp.api.admin.entity.info.PlatformEntity">
|
||||
select *
|
||||
from auth_platform
|
||||
where name = #{name}
|
||||
and host = #{host}
|
||||
</select>
|
||||
|
||||
<select id="selectById" resultType="com.glxp.api.admin.entity.info.PlatformEntity">
|
||||
select *
|
||||
from auth_platform
|
||||
where id = #{platformId}
|
||||
</select>
|
||||
|
||||
<insert id="insert">
|
||||
insert into auth_platform(id, name, host)
|
||||
VALUES (#{id}, #{name}, #{host})
|
||||
</insert>
|
||||
|
||||
<select id="selectList" resultType="com.glxp.api.admin.entity.info.PlatformEntity">
|
||||
select *
|
||||
from auth_platform
|
||||
<where>
|
||||
<if test="id != null and id != '' and id != 'null'">
|
||||
AND id = #{id}
|
||||
</if>
|
||||
<if test="name != null and name != '' and name != 'null'">
|
||||
AND name like concat('%', #{name}, '%')
|
||||
</if>
|
||||
<if test="host != null and host != '' and host != 'null'">
|
||||
AND host like concat('%', #{host}, '%')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<delete id="deleteById">
|
||||
delete
|
||||
from auth_platform
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
<update id="updateById">
|
||||
update auth_platform
|
||||
<trim prefix="set" suffixOverrides=",">
|
||||
<if test="name != null and name != ''">
|
||||
name = #{name},
|
||||
</if>
|
||||
<if test="host != null and host != ''">
|
||||
host = #{host},
|
||||
</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
</mapper>
|
@ -1,133 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.glxp.api.admin.dao.inout.UnitMaintainPlatformDao">
|
||||
<select id="getLinkPlatformList" resultType="com.glxp.api.admin.res.info.PlatformLinkResponse">
|
||||
select up.id,
|
||||
up.unitId,
|
||||
u.name corpName,
|
||||
u.corpType,
|
||||
u.spell pinyinCode,
|
||||
ap.name platformName,
|
||||
ap.id platformId,
|
||||
up.sourceAction,
|
||||
up.targetAction,
|
||||
up.invCode,
|
||||
up.invSubCode
|
||||
from io_unit_maintain_platform up
|
||||
left join basic_corp u on up.unitId = u.erpId
|
||||
left join auth_platform ap on up.platformId = ap.id
|
||||
where up.customerId = #{customerId}
|
||||
<if test="key != null and key != ''">
|
||||
AND (u.erpId like concat('%', #{key}, '%')
|
||||
or u.name like concat('%', #{key}, '%')
|
||||
or u.spell like concat('%', #{key}, '%')
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectByCustomerId" resultType="com.glxp.api.admin.entity.inout.UnitMaintainPlatformEntity">
|
||||
select *
|
||||
from io_unit_maintain_platform
|
||||
where customerId = #{customerId}
|
||||
</select>
|
||||
|
||||
<update id="updateById" parameterType="com.glxp.api.admin.entity.inout.UnitMaintainPlatformEntity">
|
||||
update io_unit_maintain_platform
|
||||
<trim prefix="set" suffixOverrides=",">
|
||||
<if test="unitId != null and unitId != ''">
|
||||
unitId = #{unitId},
|
||||
</if>
|
||||
<if test="customerId != null">
|
||||
customerId = #{customerId},
|
||||
</if>
|
||||
<if test="platformId != null and platformId != ''">
|
||||
platformId = #{platformId},
|
||||
</if>
|
||||
<if test="sourceAction != null and sourceAction != ''">
|
||||
sourceAction = #{sourceAction},
|
||||
</if>
|
||||
<if test="targetAction != null and targetAction != ''">
|
||||
targetAction = #{targetAction},
|
||||
</if>
|
||||
<if test="invCode != null and invCode != ''">
|
||||
invCode = #{invCode},
|
||||
</if>
|
||||
<if test="invSubCode != null and invSubCode != ''">
|
||||
invSubCode = #{invSubCode},
|
||||
</if>
|
||||
<if test="appid != null and appid != ''">
|
||||
appid = #{appid},
|
||||
</if>
|
||||
<if test="apiKey != null and apiKey != ''">
|
||||
apiKey = #{apiKey},
|
||||
</if>
|
||||
<if test="secretKey != null and secretKey != ''">
|
||||
secretKey = #{secretKey}
|
||||
</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyColumn="id" keyProperty="id"
|
||||
parameterType="com.glxp.api.admin.entity.inout.UnitMaintainPlatformEntity">
|
||||
insert into io_unit_maintain_platform (unitId, customerId, platformId, sourceAction, targetAction, invCode,
|
||||
invSubCode, appid, apiKey, secretKey)
|
||||
VALUES (#{unitId}, #{customerId}, #{platformId}, #{sourceAction}, #{targetAction}, #{invCode}, #{invSubCode},
|
||||
#{appid}, #{apiKey}, #{secretKey})
|
||||
</insert>
|
||||
|
||||
<select id="selectList" resultType="com.glxp.api.admin.entity.inout.UnitMaintainPlatformEntity">
|
||||
select * from io_unit_maintain_platform
|
||||
<where>
|
||||
<if test="unitId != null and unitId != ''">
|
||||
AND unitId = #{unitId}
|
||||
</if>
|
||||
<if test="customerId != null and customerId != ''">
|
||||
AND customerId = #{customerId}
|
||||
</if>
|
||||
<if test="platformId != null and platformId != ''">
|
||||
AND platformId = #{platformId}
|
||||
</if>
|
||||
<if test="sourceAction != null and sourceAction != ''">
|
||||
AND sourceAction = #{sourceAction}
|
||||
</if>
|
||||
<if test="targetAction != null and targetAction != ''">
|
||||
AND targetAction = #{targetAction}
|
||||
</if>
|
||||
<if test="invSubCode != null and invSubCode != ''">
|
||||
AND invCode = #{invCode}
|
||||
</if>
|
||||
<if test="invSubCode != null and invSubCode != ''">
|
||||
AND invSubCode = #{invSubCode}
|
||||
</if>
|
||||
<if test="appid != null and appid != ''">
|
||||
AND appid = #{appid}
|
||||
</if>
|
||||
<if test="apiKey != null and apiKey != ''">
|
||||
AND apiKey = #{apiKey}
|
||||
</if>
|
||||
<if test="secretKey != null and secretKey != ''">
|
||||
AND secretKey = #{secretKey}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="findLinkData" resultType="com.glxp.api.admin.entity.inout.UnitMaintainPlatformEntity">
|
||||
select * from io_unit_maintain_platform
|
||||
<where>
|
||||
<if test="unitId != null and unitId != ''">
|
||||
AND unitId = #{unitId}
|
||||
</if>
|
||||
<if test="customerId != null">
|
||||
AND customerId = #{customerId}
|
||||
</if>
|
||||
<if test="action != null and action != ''">
|
||||
AND sourceAction = #{action}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<delete id="deleteById">
|
||||
delete from io_unit_maintain_platform where id = #{id}
|
||||
</delete>
|
||||
</mapper>
|
Loading…
Reference in New Issue