1.迁移医院客户功能代码,解决报错问题

feature-order-fix
x_z 2 years ago
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);
}
}

@ -28,4 +28,12 @@ public interface PlatformDao{
List<PlatformEntity> selectByNameAndHost(@Param("name") String name, @Param("host") String host); List<PlatformEntity> selectByNameAndHost(@Param("name") String name, @Param("host") String host);
PlatformEntity selectById(@Param("platformId") String platformId); 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);
} }

@ -36,4 +36,6 @@ public interface UnitMaintainPlatformDao{
List<UnitMaintainPlatformEntity> selectList(PlatformLinkRequest platformLinkRequest); List<UnitMaintainPlatformEntity> selectList(PlatformLinkRequest platformLinkRequest);
UnitMaintainPlatformEntity findLinkData(@Param("customerId") long customerId, @Param("action") String action, @Param("unitId") String unitId); UnitMaintainPlatformEntity findLinkData(@Param("customerId") long customerId, @Param("action") String action, @Param("unitId") String unitId);
void deleteById(String id);
} }

@ -1,5 +1,101 @@
package com.glxp.api.admin.service.info; 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 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);
} }

@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageHelper;
import com.glxp.api.admin.dao.info.PlatformDao; import com.glxp.api.admin.dao.info.PlatformDao;
import com.glxp.api.admin.dao.inout.UnitMaintainPlatformDao; import com.glxp.api.admin.dao.inout.UnitMaintainPlatformDao;
import com.glxp.api.admin.entity.info.PlatformEntity; import com.glxp.api.admin.entity.info.PlatformEntity;
@ -23,6 +24,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -39,7 +41,7 @@ public class PlatformServiceImpl implements PlatformService {
public int save(PlatformEntity platformEntity) { public int save(PlatformEntity platformEntity) {
if (StringUtils.isEmpty(platformEntity.getId())) { if (StringUtils.isEmpty(platformEntity.getId())) {
platformEntity.setId(String.valueOf(IdUtil.getSnowflakeNextId())); platformEntity.setId(String.valueOf(IdUtil.getSnowflake().nextId()));
} }
return platformDao.insert(platformEntity); return platformDao.insert(platformEntity);
} }
@ -70,24 +72,14 @@ public class PlatformServiceImpl implements PlatformService {
return true; return true;
} }
public IPage<PlatformEntity> list(Map<String, Object> map) { public List<PlatformEntity> list(Map<String, Object> map) {
QueryWrapper<PlatformEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StrUtil.isNotBlank(String.valueOf(map.get("id"))) && !"null".equals(String.valueOf(map.get("id"))), "id", map.get("id"))
.like(StrUtil.isNotBlank(String.valueOf(map.get("name"))) && !"null".equals(String.valueOf(map.get("name"))), "name", map.get("name"))
.like(StrUtil.isNotBlank(String.valueOf(map.get("host"))) && !"null".equals(String.valueOf(map.get("host"))), "host", map.get("host"));
if (map.get("page") != null && map.get("limit") != null) { if (map.get("page") != null && map.get("limit") != null) {
Integer page = Integer.valueOf(map.get("page").toString()); Integer page = Integer.valueOf(String.valueOf(map.get("page")));
Integer limit = Integer.valueOf(map.get("limit").toString()); Integer limit = Integer.valueOf(String.valueOf(map.get("limit")));
IPage<PlatformEntity> pageParam = new Page<>(page, limit); PageHelper.offsetPage((page - 1) * limit, limit);
return platformDao.selectPage(pageParam, wrapper);
} else {
List<PlatformEntity> list = platformDao.selectList(wrapper);
IPage<PlatformEntity> pageResult = new Page<>();
pageResult.setTotal(list.size());
pageResult.setRecords(list);
return pageResult;
} }
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) { public int count(Map<String, Object> map) {
@ -104,12 +96,14 @@ public class PlatformServiceImpl implements PlatformService {
* @param platformLinkRequest * @param platformLinkRequest
* @return * @return
*/ */
public IPage<PlatformLinkResponse> getLinkPlatformList(PlatformLinkRequest platformLinkRequest) { public List<PlatformLinkResponse> getLinkPlatformList(PlatformLinkRequest platformLinkRequest) {
if (null == platformLinkRequest) { if (null == platformLinkRequest) {
return new Page<>(); return Collections.emptyList();
}
if (null != platformLinkRequest.getPage() && null != platformLinkRequest.getLimit()) {
PageHelper.offsetPage((platformLinkRequest.getPage() - 1) * platformLinkRequest.getLimit(), platformLinkRequest.getLimit());
} }
IPage<PlatformLinkResponse> page = new Page<>(platformLinkRequest.getPage(), platformLinkRequest.getLimit()); return unitMaintainPlatformDao.getLinkPlatformList(platformLinkRequest.getCustomerId(), platformLinkRequest.getKey());
return UnitMaintainPlatformEntityDao.getLinkPlatformList(page, platformLinkRequest.getCustomerId(), platformLinkRequest.getKey());
} }
/** /**
@ -118,7 +112,7 @@ public class PlatformServiceImpl implements PlatformService {
* @param id * @param id
*/ */
public void unbindPlatform(String id) { public void unbindPlatform(String id) {
UnitMaintainPlatformEntityDao.deleteById(id); unitMaintainPlatformDao.deleteById(id);
} }
/** /**
@ -144,7 +138,6 @@ public class PlatformServiceImpl implements PlatformService {
} }
} }
//获取自助平台一级仓库 //获取自助平台一级仓库
public BaseResponse getTargetInv(String platformId) { public BaseResponse getTargetInv(String platformId) {
PlatformEntity platformEntity = platformDao.get(platformId); PlatformEntity platformEntity = platformDao.get(platformId);
@ -247,13 +240,8 @@ public class PlatformServiceImpl implements PlatformService {
} }
/** @Override
* public String verifyUnitMaintainPlatform(PlatformLinkRequest platformLinkRequest) {
*
* @param platformLinkRequest
* @return
*/
public String verifyUnitMaintainPlatformEntity(PlatformLinkRequest platformLinkRequest) {
List<UnitMaintainPlatformEntity> list = unitMaintainPlatformDao.selectList(platformLinkRequest); List<UnitMaintainPlatformEntity> list = unitMaintainPlatformDao.selectList(platformLinkRequest);
if (CollUtil.isEmpty(list)) { if (CollUtil.isEmpty(list)) {
return "success"; return "success";

@ -59,6 +59,48 @@
</select> </select>
<select id="selectById" resultType="com.glxp.api.admin.entity.info.PlatformEntity"> <select id="selectById" resultType="com.glxp.api.admin.entity.info.PlatformEntity">
select * from auth_platform where id = #{platformId} select *
from auth_platform
where id = #{platformId}
</select> </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 = #{id}
</if>
<if test="name != null and name != ''">
AND name like concat('%', #{name}, '%')
</if>
<if test="host != null and host != ''">
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> </mapper>

@ -126,4 +126,8 @@
</if> </if>
</where> </where>
</select> </select>
<delete id="deleteById">
delete from io_unit_maintain_platform where id = #{id}
</delete>
</mapper> </mapper>
Loading…
Cancel
Save