This commit is contained in:
parent
a4ac6b6652
commit
676c5a664b
|
|
@ -0,0 +1,48 @@
|
|||
package com.syjiaer.clinic.server.entity.social;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.io.Serializable;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
/**
|
||||
* <p>
|
||||
* 医保目录3301上传编号对照表
|
||||
* </p>
|
||||
*
|
||||
* @author NiuZiYuan
|
||||
* @since 2025-06-03
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
@TableName("social_compare_code")
|
||||
@ApiModel(value = "SocialCompareCode对象", description = "医保目录3301上传编号对照表")
|
||||
public class SocialCompareCode implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("医保目录编码")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty("来源表 goods item item_group_list")
|
||||
private String tableName;
|
||||
|
||||
@ApiModelProperty("3301上报编号")
|
||||
private String compareCode;
|
||||
|
||||
@ApiModelProperty("逻辑删除 0是默认")
|
||||
private Byte delFlag;
|
||||
|
||||
@ApiModelProperty("原始请求参数")
|
||||
private String request;
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.syjiaer.clinic.server.mapper.social;
|
||||
|
||||
import com.syjiaer.clinic.server.entity.social.SocialCompareCode;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 医保目录3301上传编号对照表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author NiuZiYuan
|
||||
* @since 2025-06-03
|
||||
*/
|
||||
public interface SocialCompareCodeMapper extends BaseMapper<SocialCompareCode> {
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -28,6 +28,7 @@ import com.syjiaer.clinic.server.mapper.social.SocialDirectoryMapper;
|
|||
import com.syjiaer.clinic.server.mapper.social.SocialDirectoryUpinfoMapper;
|
||||
import com.syjiaer.clinic.server.mapper.social.SocialItemMapper;
|
||||
import com.syjiaer.clinic.server.service.BaseService;
|
||||
import com.syjiaer.clinic.server.service.social.SocialCompareService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -64,6 +65,8 @@ public class ItemService extends BaseService {
|
|||
private SocialRequest socialRequest;
|
||||
@Autowired
|
||||
private Config config;
|
||||
@Autowired
|
||||
private SocialCompareService socialCompareService;
|
||||
|
||||
/*
|
||||
* 获取项目列表
|
||||
|
|
@ -424,185 +427,197 @@ public class ItemService extends BaseService {
|
|||
|
||||
HashMap<String,Object> resultMap = new HashMap<>();
|
||||
|
||||
resultMap.put("createOrDelete",createOrDelete);
|
||||
|
||||
QueryWrapper<SocialItem> socialItemQueryWrapper = new QueryWrapper<>();
|
||||
socialItemQueryWrapper.eq("code",code);
|
||||
socialItemQueryWrapper.last("limit 1");
|
||||
|
||||
QueryWrapper<SocialDirectory> directoryQueryWrapper = new QueryWrapper<>();
|
||||
directoryQueryWrapper.eq("code",code);
|
||||
directoryQueryWrapper.last("limit 1");
|
||||
|
||||
//请求入参目录类别
|
||||
String requestListType = "";
|
||||
//查询3301编号是否存在已及更新的表
|
||||
String handleTable = "social_item";
|
||||
//自己系统的自增ID
|
||||
String selfId = "";
|
||||
//自己系统的名称
|
||||
String selfName = "";
|
||||
|
||||
if (type.equals("goods")) {
|
||||
QueryWrapper<Goods> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("hilist_code",code);
|
||||
queryWrapper.last(" limit 1");
|
||||
|
||||
|
||||
|
||||
Goods goods = goodsMapper.selectOne(queryWrapper);
|
||||
|
||||
if (goods == null) {
|
||||
throw new MessageException("商品医保编码不存在");
|
||||
}
|
||||
|
||||
//1301 西药中成药
|
||||
//1302 中药饮片
|
||||
//1306 医用材料
|
||||
requestListType = switch (goods.getType()) {
|
||||
case 1301 -> "101";
|
||||
case 1302 -> "102";
|
||||
case 1306 -> "301";
|
||||
default -> requestListType;
|
||||
};
|
||||
|
||||
handleTable = "social_directory";
|
||||
selfId = "sd_"+goods.getId().toString();
|
||||
selfName = goods.getName();
|
||||
} else if (type.equals("item")) {
|
||||
QueryWrapper<Item> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("social_code",code);
|
||||
queryWrapper.last(" limit 1");
|
||||
Item item = itemMapper.selectOne(queryWrapper);
|
||||
if (item == null) {
|
||||
throw new MessageException("诊疗项目医保编码不存在");
|
||||
}
|
||||
|
||||
//全部对应服务项目
|
||||
requestListType = "201";
|
||||
|
||||
selfId = "i_"+item.getId().toString();
|
||||
selfName = item.getName();
|
||||
|
||||
}else if (type.equals("item_group_list")) {
|
||||
QueryWrapper<ItemGroupList> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("social_code",code);
|
||||
queryWrapper.last(" limit 1");
|
||||
ItemGroupList itemGroupListInfo = itemGroupListMapper.selectOne(queryWrapper);
|
||||
if (itemGroupListInfo == null) {
|
||||
throw new MessageException("组套医保编码不存在");
|
||||
}
|
||||
|
||||
//全部对应服务项目
|
||||
requestListType = "201";
|
||||
selfId = "igl_"+itemGroupListInfo.getId().toString();
|
||||
selfName = itemGroupListInfo.getName();
|
||||
}
|
||||
|
||||
|
||||
if (requestListType.isEmpty()) {
|
||||
throw new MessageException("请求参数错误");
|
||||
}
|
||||
|
||||
|
||||
if (handleTable.equals("social_directory")) {
|
||||
SocialDirectory socialDirectory = socialDirectoryMapper.selectOne(directoryQueryWrapper);
|
||||
|
||||
if (socialDirectory == null) {
|
||||
throw new MessageException("医保目录编码不存在");
|
||||
}
|
||||
|
||||
//当前商品已经处设置过compareCode socialDirectory.getCompareCode()!=""
|
||||
|
||||
|
||||
if (socialDirectory.getCompareCode()!=null && !socialDirectory.getCompareCode().isEmpty() && !Objects.equals(createOrDelete, "delete")) {
|
||||
|
||||
System.out.println(socialDirectory.getCompareCode());
|
||||
|
||||
log.info("call3301:socialDirectory已存在compareCode:code:{}:compareCode:{}",code,socialDirectory.getCompareCode());
|
||||
|
||||
resultMap.put("compareCode",socialDirectory.getCompareCode());
|
||||
return resultMap;
|
||||
}
|
||||
}else{
|
||||
SocialItem socialItem = socialItemMapper.selectOne(socialItemQueryWrapper);
|
||||
|
||||
if (socialItem == null) {
|
||||
throw new MessageException("诊疗项目-医保目录编码不存在");
|
||||
}
|
||||
|
||||
if (socialItem.getCompareCode()!=null && !socialItem.getCompareCode().isEmpty() && !Objects.equals(createOrDelete, "delete")) {
|
||||
|
||||
log.info("call3301:socialItem已存在compareCode:code:{}:compareCode:{}",code,socialItem.getCompareCode());
|
||||
|
||||
resultMap.put("compareCode",socialItem.getCompareCode());
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
|
||||
if (createOrDelete.equals("delete"))
|
||||
//兼容之前写好的代码
|
||||
if (Objects.equals(createOrDelete, "create"))
|
||||
{
|
||||
|
||||
if (handleTable.equals("social_directory")) {
|
||||
//更新socialDirectoryMapper中compareCode字段为空
|
||||
socialDirectoryMapper.update(
|
||||
new SocialDirectory(),
|
||||
new UpdateWrapper<SocialDirectory>().set("compare_code","").eq("code",code)
|
||||
);
|
||||
}else{
|
||||
//更新socialItemMapper中compareCode字段为空
|
||||
socialItemMapper.update(
|
||||
new SocialItem(),
|
||||
new UpdateWrapper<SocialItem>().set("compare_code","").eq("code",code)
|
||||
);
|
||||
}
|
||||
|
||||
IM3302 iM3302 = new IM3302();
|
||||
iM3302.setFixmedinsCode(config.get("social","msgid"));
|
||||
iM3302.setFixmedinsHilistId(selfId);
|
||||
iM3302.setListType(requestListType);
|
||||
iM3302.setMedListCodg(code);
|
||||
|
||||
socialRequest.call3302(iM3302);
|
||||
|
||||
log.info("call3302:socialItem删除compareCode:code:{}:compareCode:{}",code,selfId);
|
||||
|
||||
resultMap.put("compareCode",code);
|
||||
return socialCompareService.report(code,type);
|
||||
}else{
|
||||
socialCompareService.delete(code,type);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
IM3301 iM3301 = new IM3301();
|
||||
iM3301.setFixmedinsHilistId(selfId);
|
||||
iM3301.setFixmedinsHilistName(selfName);
|
||||
iM3301.setListType(requestListType);
|
||||
iM3301.setMedListCodg(code);
|
||||
iM3301.setBegndate(LocalDateTime.of(2025,1,1,0,0,0));
|
||||
iM3301.setEnddate(LocalDateTime.of(2050,1,1,0,0,0));
|
||||
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add(iM3301.buildToMap());
|
||||
|
||||
socialRequest.call3301(list);
|
||||
|
||||
if (handleTable.equals("social_directory")) {
|
||||
//更新socialDirectoryMapper中compareCode字段为code
|
||||
UpdateWrapper<SocialDirectory> socialDirectoryUpdateWrapper = new UpdateWrapper<>();
|
||||
socialDirectoryUpdateWrapper.eq("code",code);
|
||||
socialDirectoryUpdateWrapper.set("compare_code",selfId);
|
||||
socialDirectoryMapper.update(socialDirectoryUpdateWrapper);
|
||||
log.info("call3301:socialDirectoryMapper更新compareCode:code:{}:compareCode:{}",code,code);
|
||||
}else{
|
||||
//更新socialItemMapper中compareCode字段为code
|
||||
UpdateWrapper<SocialItem> socialItemUpdateWrapper = new UpdateWrapper<>();
|
||||
socialItemUpdateWrapper.eq("code",code);
|
||||
socialItemUpdateWrapper.set("compare_code",selfId);
|
||||
socialItemMapper.update(socialItemUpdateWrapper);
|
||||
log.info("call3301:socialItemMapper更新compareCode:code:{}:compareCode:{}",code,code);
|
||||
}
|
||||
|
||||
resultMap.put("compareCode",code);
|
||||
|
||||
return resultMap;
|
||||
//
|
||||
// resultMap.put("createOrDelete",createOrDelete);
|
||||
//
|
||||
// QueryWrapper<SocialItem> socialItemQueryWrapper = new QueryWrapper<>();
|
||||
// socialItemQueryWrapper.eq("code",code);
|
||||
// socialItemQueryWrapper.last("limit 1");
|
||||
//
|
||||
// QueryWrapper<SocialDirectory> directoryQueryWrapper = new QueryWrapper<>();
|
||||
// directoryQueryWrapper.eq("code",code);
|
||||
// directoryQueryWrapper.last("limit 1");
|
||||
//
|
||||
// //请求入参目录类别
|
||||
// String requestListType = "";
|
||||
// //查询3301编号是否存在已及更新的表
|
||||
// String handleTable = "social_item";
|
||||
// //自己系统的自增ID
|
||||
// String selfId = "";
|
||||
// //自己系统的名称
|
||||
// String selfName = "";
|
||||
//
|
||||
// if (type.equals("goods")) {
|
||||
// QueryWrapper<Goods> queryWrapper = new QueryWrapper<>();
|
||||
// queryWrapper.eq("hilist_code",code);
|
||||
// queryWrapper.last(" limit 1");
|
||||
//
|
||||
//
|
||||
//
|
||||
// Goods goods = goodsMapper.selectOne(queryWrapper);
|
||||
//
|
||||
// if (goods == null) {
|
||||
// throw new MessageException("商品医保编码不存在");
|
||||
// }
|
||||
//
|
||||
// //1301 西药中成药
|
||||
// //1302 中药饮片
|
||||
// //1306 医用材料
|
||||
// requestListType = switch (goods.getType()) {
|
||||
// case 1301 -> "101";
|
||||
// case 1302 -> "102";
|
||||
// case 1306 -> "301";
|
||||
// default -> requestListType;
|
||||
// };
|
||||
//
|
||||
// handleTable = "social_directory";
|
||||
// selfId = "sd_"+goods.getId().toString();
|
||||
// selfName = goods.getName();
|
||||
// } else if (type.equals("item")) {
|
||||
// QueryWrapper<Item> queryWrapper = new QueryWrapper<>();
|
||||
// queryWrapper.eq("social_code",code);
|
||||
// queryWrapper.last(" limit 1");
|
||||
// Item item = itemMapper.selectOne(queryWrapper);
|
||||
// if (item == null) {
|
||||
// throw new MessageException("诊疗项目医保编码不存在");
|
||||
// }
|
||||
//
|
||||
// //全部对应服务项目
|
||||
// requestListType = "201";
|
||||
//
|
||||
// selfId = "i_"+item.getId().toString();
|
||||
// selfName = item.getName();
|
||||
//
|
||||
// }else if (type.equals("item_group_list")) {
|
||||
// QueryWrapper<ItemGroupList> queryWrapper = new QueryWrapper<>();
|
||||
// queryWrapper.eq("social_code",code);
|
||||
// queryWrapper.last(" limit 1");
|
||||
// ItemGroupList itemGroupListInfo = itemGroupListMapper.selectOne(queryWrapper);
|
||||
// if (itemGroupListInfo == null) {
|
||||
// throw new MessageException("组套医保编码不存在");
|
||||
// }
|
||||
//
|
||||
// //全部对应服务项目
|
||||
// requestListType = "201";
|
||||
// selfId = "igl_"+itemGroupListInfo.getId().toString();
|
||||
// selfName = itemGroupListInfo.getName();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if (requestListType.isEmpty()) {
|
||||
// throw new MessageException("请求参数错误");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if (handleTable.equals("social_directory")) {
|
||||
// SocialDirectory socialDirectory = socialDirectoryMapper.selectOne(directoryQueryWrapper);
|
||||
//
|
||||
// if (socialDirectory == null) {
|
||||
// throw new MessageException("医保目录编码不存在");
|
||||
// }
|
||||
//
|
||||
// //当前商品已经处设置过compareCode socialDirectory.getCompareCode()!=""
|
||||
//
|
||||
//
|
||||
// if (socialDirectory.getCompareCode()!=null && !socialDirectory.getCompareCode().isEmpty() && !Objects.equals(createOrDelete, "delete")) {
|
||||
//
|
||||
// System.out.println(socialDirectory.getCompareCode());
|
||||
//
|
||||
// log.info("call3301:socialDirectory已存在compareCode:code:{}:compareCode:{}",code,socialDirectory.getCompareCode());
|
||||
//
|
||||
// resultMap.put("compareCode",socialDirectory.getCompareCode());
|
||||
// return resultMap;
|
||||
// }
|
||||
// }else{
|
||||
// SocialItem socialItem = socialItemMapper.selectOne(socialItemQueryWrapper);
|
||||
//
|
||||
// if (socialItem == null) {
|
||||
// throw new MessageException("诊疗项目-医保目录编码不存在");
|
||||
// }
|
||||
//
|
||||
// if (socialItem.getCompareCode()!=null && !socialItem.getCompareCode().isEmpty() && !Objects.equals(createOrDelete, "delete")) {
|
||||
//
|
||||
// log.info("call3301:socialItem已存在compareCode:code:{}:compareCode:{}",code,socialItem.getCompareCode());
|
||||
//
|
||||
// resultMap.put("compareCode",socialItem.getCompareCode());
|
||||
// return resultMap;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (createOrDelete.equals("delete"))
|
||||
// {
|
||||
//
|
||||
// if (handleTable.equals("social_directory")) {
|
||||
// //更新socialDirectoryMapper中compareCode字段为空
|
||||
// socialDirectoryMapper.update(
|
||||
// new SocialDirectory(),
|
||||
// new UpdateWrapper<SocialDirectory>().set("compare_code","").eq("code",code)
|
||||
// );
|
||||
// }else{
|
||||
// //更新socialItemMapper中compareCode字段为空
|
||||
// socialItemMapper.update(
|
||||
// new SocialItem(),
|
||||
// new UpdateWrapper<SocialItem>().set("compare_code","").eq("code",code)
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// IM3302 iM3302 = new IM3302();
|
||||
// iM3302.setFixmedinsCode(config.get("social","msgid"));
|
||||
// iM3302.setFixmedinsHilistId(selfId);
|
||||
// iM3302.setListType(requestListType);
|
||||
// iM3302.setMedListCodg(code);
|
||||
//
|
||||
// socialRequest.call3302(iM3302);
|
||||
//
|
||||
// log.info("call3302:socialItem删除compareCode:code:{}:compareCode:{}",code,selfId);
|
||||
//
|
||||
// resultMap.put("compareCode",code);
|
||||
//
|
||||
// return resultMap;
|
||||
// }
|
||||
//
|
||||
// IM3301 iM3301 = new IM3301();
|
||||
// iM3301.setFixmedinsHilistId(selfId);
|
||||
// iM3301.setFixmedinsHilistName(selfName);
|
||||
// iM3301.setListType(requestListType);
|
||||
// iM3301.setMedListCodg(code);
|
||||
// iM3301.setBegndate(LocalDateTime.of(2025,1,1,0,0,0));
|
||||
// iM3301.setEnddate(LocalDateTime.of(2050,1,1,0,0,0));
|
||||
//
|
||||
// List<Object> list = new ArrayList<>();
|
||||
// list.add(iM3301.buildToMap());
|
||||
//
|
||||
// socialRequest.call3301(list);
|
||||
//
|
||||
// if (handleTable.equals("social_directory")) {
|
||||
// //更新socialDirectoryMapper中compareCode字段为code
|
||||
// UpdateWrapper<SocialDirectory> socialDirectoryUpdateWrapper = new UpdateWrapper<>();
|
||||
// socialDirectoryUpdateWrapper.eq("code",code);
|
||||
// socialDirectoryUpdateWrapper.set("compare_code",selfId);
|
||||
// socialDirectoryMapper.update(socialDirectoryUpdateWrapper);
|
||||
// log.info("call3301:socialDirectoryMapper更新compareCode:code:{}:compareCode:{}",code,code);
|
||||
// }else{
|
||||
// //更新socialItemMapper中compareCode字段为code
|
||||
// UpdateWrapper<SocialItem> socialItemUpdateWrapper = new UpdateWrapper<>();
|
||||
// socialItemUpdateWrapper.eq("code",code);
|
||||
// socialItemUpdateWrapper.set("compare_code",selfId);
|
||||
// socialItemMapper.update(socialItemUpdateWrapper);
|
||||
// log.info("call3301:socialItemMapper更新compareCode:code:{}:compareCode:{}",code,code);
|
||||
// }
|
||||
//
|
||||
// resultMap.put("compareCode",code);
|
||||
//
|
||||
// return resultMap;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,253 @@
|
|||
package com.syjiaer.clinic.server.service.social;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.syjiaer.clinic.server.common.api.input.im3301.IM3301;
|
||||
import com.syjiaer.clinic.server.common.api.input.im3302.IM3302;
|
||||
import com.syjiaer.clinic.server.common.api.request.SocialRequest;
|
||||
import com.syjiaer.clinic.server.common.config.Config;
|
||||
import com.syjiaer.clinic.server.common.exception.MessageException;
|
||||
import com.syjiaer.clinic.server.entity.goods.Goods;
|
||||
import com.syjiaer.clinic.server.entity.item.Item;
|
||||
import com.syjiaer.clinic.server.entity.item.ItemGroupList;
|
||||
import com.syjiaer.clinic.server.entity.social.SocialCompareCode;
|
||||
import com.syjiaer.clinic.server.mapper.goods.GoodsMapper;
|
||||
import com.syjiaer.clinic.server.mapper.item.ItemGroupListMapper;
|
||||
import com.syjiaer.clinic.server.mapper.item.ItemMapper;
|
||||
import com.syjiaer.clinic.server.mapper.social.SocialCompareCodeMapper;
|
||||
import com.syjiaer.clinic.server.mapper.social.SocialDirectoryMapper;
|
||||
import com.syjiaer.clinic.server.mapper.social.SocialDirectoryUpinfoMapper;
|
||||
import com.syjiaer.clinic.server.mapper.social.SocialItemMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import springfox.documentation.spring.web.json.Json;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SocialCompareService {
|
||||
@Autowired
|
||||
private ItemMapper itemMapper;
|
||||
@Autowired
|
||||
private SocialDirectoryUpinfoMapper socialDirectoryUpinfoMapper;
|
||||
|
||||
@Autowired
|
||||
private ItemGroupListMapper itemGroupListMapper;
|
||||
@Autowired
|
||||
private SocialItemMapper socialItemMapper;
|
||||
|
||||
@Autowired
|
||||
private GoodsMapper goodsMapper;
|
||||
@Autowired
|
||||
private SocialDirectoryMapper socialDirectoryMapper;
|
||||
@Autowired
|
||||
private SocialRequest socialRequest;
|
||||
@Autowired
|
||||
private Config config;
|
||||
@Autowired
|
||||
private SocialCompareCodeMapper socialCompareCodeMapper;
|
||||
|
||||
|
||||
public static String socialCompareGoods = "goods";
|
||||
public static String socialCompareItem = "item";
|
||||
public static String socialCompareItemGroup = "item_group_list";
|
||||
|
||||
/*
|
||||
* @Description 获取对比信息
|
||||
* @Author 佟明轩
|
||||
* @Date 14:22 2025/6/3
|
||||
* @param code 医保目录编号
|
||||
* @param type 类型
|
||||
* @return SocialCompareCode
|
||||
**/
|
||||
public SocialCompareCode socialCompareInfo(String code, String type)
|
||||
{
|
||||
QueryWrapper<SocialCompareCode> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("code",code);
|
||||
queryWrapper.eq("table_name",type);
|
||||
queryWrapper.ne("del_flag",1);
|
||||
|
||||
return socialCompareCodeMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @Description 判断3301ID是否已经上报
|
||||
* @Author 佟明轩
|
||||
* @Date 14:12 2025/6/3
|
||||
* @param code 医保编号
|
||||
* @param type 数据表类型
|
||||
* @return HashMap<String,Object>
|
||||
**/
|
||||
public HashMap<String,Object> getSocialCompare(String code, String type)
|
||||
{
|
||||
HashMap<String,Object> resultMap = new HashMap<>();
|
||||
|
||||
SocialCompareCode socialCompareInfo = socialCompareInfo(code,type);
|
||||
|
||||
if (socialCompareInfo != null && socialCompareInfo.getCompareCode() != null && !socialCompareInfo.getCompareCode().isEmpty())
|
||||
{
|
||||
resultMap.put("status",true);
|
||||
resultMap.put("message","幂等:该医保编号已上报");
|
||||
resultMap.put("compare_code",socialCompareInfo.getCompareCode());
|
||||
resultMap.put("code",socialCompareInfo.getCode());
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
resultMap.put("status",false);
|
||||
resultMap.put("message","该医保编号未上报或数据不存在");
|
||||
resultMap.put("compare_code","");
|
||||
resultMap.put("code","");
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 调用3301医保目录医保码上报
|
||||
* @param code 医保目录编号
|
||||
* @param type 类型 type goods:商品 item:诊疗项目 item_group_list:组套
|
||||
* @return hashMap
|
||||
*/
|
||||
public HashMap<String,Object> report(String code, String type)
|
||||
{
|
||||
HashMap<String,Object> resultMap = new HashMap<>();
|
||||
|
||||
log.info("socialCompare:接收到数据:code:{}:type:{}:",code,type);
|
||||
|
||||
HashMap<String,Object> socialCompare = getSocialCompare(code,type);
|
||||
|
||||
if ((boolean)socialCompare.get("status"))
|
||||
{
|
||||
log.info("socialCompare:上报数据已存在:code:{}:type:{}:result:{}",code,type,socialCompare);
|
||||
|
||||
return socialCompare;
|
||||
}
|
||||
|
||||
String requestListType = "";
|
||||
String selfName = "";
|
||||
|
||||
if (type.equals("goods")) {
|
||||
QueryWrapper<Goods> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("hilist_code",code);
|
||||
queryWrapper.last(" limit 1");
|
||||
|
||||
Goods goods = goodsMapper.selectOne(queryWrapper);
|
||||
|
||||
if (goods == null) {
|
||||
throw new MessageException("商品医保编码不存在");
|
||||
}
|
||||
|
||||
//1301 西药中成药
|
||||
//1302 中药饮片
|
||||
//1306 医用材料
|
||||
requestListType = switch (goods.getType()) {
|
||||
case 1301 -> "101";
|
||||
case 1302 -> "102";
|
||||
case 1306 -> "301";
|
||||
default -> requestListType;
|
||||
};
|
||||
selfName = goods.getName();
|
||||
|
||||
} else if (type.equals("item")) {
|
||||
QueryWrapper<Item> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("social_code",code);
|
||||
queryWrapper.last(" limit 1");
|
||||
Item item = itemMapper.selectOne(queryWrapper);
|
||||
if (item == null) {
|
||||
throw new MessageException("诊疗项目医保编码不存在");
|
||||
}
|
||||
|
||||
//全部对应服务项目
|
||||
requestListType = "201";
|
||||
selfName = item.getName();
|
||||
}else if (type.equals("item_group_list")) {
|
||||
QueryWrapper<ItemGroupList> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("social_code",code);
|
||||
queryWrapper.last(" limit 1");
|
||||
ItemGroupList itemGroupListInfo = itemGroupListMapper.selectOne(queryWrapper);
|
||||
if (itemGroupListInfo == null) {
|
||||
throw new MessageException("组套医保编码不存在");
|
||||
}
|
||||
|
||||
//全部对应服务项目
|
||||
requestListType = "201";
|
||||
selfName = itemGroupListInfo.getName();
|
||||
}
|
||||
|
||||
if (requestListType.isEmpty()) {
|
||||
throw new MessageException("类型请求参数错误");
|
||||
}
|
||||
|
||||
SocialCompareCode socialCompareCode = new SocialCompareCode();
|
||||
socialCompareCode.setCode(code);
|
||||
socialCompareCode.setTableName(type);
|
||||
socialCompareCodeMapper.insert(socialCompareCode);
|
||||
|
||||
IM3301 iM3301 = new IM3301();
|
||||
iM3301.setFixmedinsHilistId(String.valueOf(socialCompareCode.getId()));
|
||||
iM3301.setFixmedinsHilistName(selfName);
|
||||
iM3301.setListType(requestListType);
|
||||
iM3301.setMedListCodg(code);
|
||||
iM3301.setBegndate(LocalDateTime.of(2025,1,1,0,0,0));
|
||||
iM3301.setEnddate(LocalDateTime.of(2050,1,1,0,0,0));
|
||||
|
||||
List<Object> list = new ArrayList<>();
|
||||
|
||||
Map<String, Object> requestMap = iM3301.buildToMap();
|
||||
|
||||
list.add(requestMap);
|
||||
|
||||
socialRequest.call3301(list);
|
||||
|
||||
//更新socialCompareCode
|
||||
UpdateWrapper<SocialCompareCode> socialCompareCodeUpdateWrapper = new UpdateWrapper<>();
|
||||
socialCompareCodeUpdateWrapper.eq("id",socialCompareCode.getId());
|
||||
socialCompareCodeUpdateWrapper.set("compare_code",socialCompareCode.getId());
|
||||
//把requestMap转化成json存储到socialCompareCode的request字段
|
||||
socialCompareCodeUpdateWrapper.set("request", JSON.toJSONString(requestMap));
|
||||
socialCompareCodeMapper.update(socialCompareCode,socialCompareCodeUpdateWrapper);
|
||||
|
||||
|
||||
resultMap.put("status",false);
|
||||
resultMap.put("message","上报成功");
|
||||
resultMap.put("compare_code",socialCompareCode.getId());
|
||||
resultMap.put("code",code);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
public void delete(String code, String type) {
|
||||
SocialCompareCode socialCompareInfo= socialCompareInfo(code,type);
|
||||
|
||||
if (socialCompareInfo == null || socialCompareInfo.getCode().isEmpty()) {
|
||||
throw new MessageException("医保编码上报信息不存在");
|
||||
}
|
||||
|
||||
String requestJson = socialCompareInfo.getRequest();
|
||||
|
||||
JSONObject requestMap = JSON.parseObject(requestJson);
|
||||
|
||||
IM3302 iM3302 = new IM3302();
|
||||
iM3302.setFixmedinsCode(config.get("social","msgid"));
|
||||
iM3302.setFixmedinsHilistId(socialCompareInfo.getCompareCode());
|
||||
iM3302.setListType((String) requestMap.get("list_type"));
|
||||
iM3302.setMedListCodg(code);
|
||||
|
||||
socialRequest.call3302(iM3302);
|
||||
|
||||
log.info("call3302:delete:compareCode:调用API成功:code:{}:compareCode:{}",code,socialCompareInfo.getCompareCode());
|
||||
|
||||
UpdateWrapper<SocialCompareCode> socialCompareCodeUpdateWrapper = new UpdateWrapper<>();
|
||||
socialCompareCodeUpdateWrapper.eq("id",socialCompareInfo.getId());
|
||||
socialCompareCodeUpdateWrapper.set("del_flag",1);
|
||||
socialCompareCodeMapper.update(socialCompareCodeUpdateWrapper);
|
||||
|
||||
log.info("call3302:delete:compareCode:删除成功:code:{}:compareCode:{}",code,socialCompareInfo.getCompareCode());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<?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.syjiaer.clinic.server.mapper.social.SocialCompareCodeMapper">
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue