1.迁移医院客户功能代码,解决报错问题
parent
3e4cf0c316
commit
b9b19c6808
@ -0,0 +1,247 @@
|
||||
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.basic.UnitMaintainService;
|
||||
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 UnitMaintainService unitMaintainService;
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
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,5 +1,101 @@
|
||||
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);
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue