123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- package thyyxxk.webserver.service.nationalmatch;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import thyyxxk.webserver.config.exception.ExceptionEnum;
- import thyyxxk.webserver.constants.Capacity;
- import thyyxxk.webserver.constants.NationalMatchType;
- import thyyxxk.webserver.dao.his.nationalmatch.NationalMatchDao;
- import thyyxxk.webserver.entity.ResultVo;
- import thyyxxk.webserver.entity.nationalmatch.*;
- import thyyxxk.webserver.utils.ResultVoUtil;
- import thyyxxk.webserver.utils.StringUtil;
- import thyyxxk.webserver.utils.TokenUtil;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * @description: 新医保国家目录匹配Service
- * @author: DingJie
- * @create: 2021-06-10 14:50:27
- **/
- @Slf4j
- @Service
- public class NationalMatchService {
- private final NationalMatchDao dao;
- @Autowired
- public NationalMatchService(NationalMatchDao dao) {
- this.dao = dao;
- }
- public ResultVo<Map<String, Object>> selectLocalItems(QueryParam param) {
- log.info("是否导出:{}", param.getExport());
- IPage<StandardLocalItem> iPage = param.getExport() ? new Page<>(1, -1) :
- new Page<>(param.getCurrentPage(), param.getPageSize());
- String code = param.getCode();
- code = StringUtil.isBlank(code) ? "%%" : code.trim().toUpperCase();
- String name = param.getName();
- name = StringUtil.isBlank(name) ? "%%" : "%" + name.trim() + "%";
- if (param.getType() == NationalMatchType.MEDICINE) {
- iPage = dao.selectLocalMedicines(iPage, code, name, param.getType(), param.getDelFlag(), param.getStatus());
- } else if(param.getType() == NationalMatchType.HERBAL) {
- iPage = dao.selectLocalHerbals(iPage, code, name, param.getType(), param.getDelFlag(), param.getStatus());
- } else if (param.getType() == NationalMatchType.SERVICE) {
- iPage = dao.selectLocalServices(iPage, code, name, param.getType(), param.getDelFlag(), param.getStatus());
- } else {
- iPage = dao.selectLocalSupplies(iPage, code, name, param.getType(), param.getDelFlag(), param.getStatus());
- }
- if (iPage.getRecords().size() == 0) {
- return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有符合条件的数据。");
- }
- Map<String, Object> map = new HashMap<>(Capacity.TWO);
- map.put("total", iPage.getTotal());
- map.put("list", iPage.getRecords());
- return ResultVoUtil.success(map);
- }
- public ResultVo<String> asyncNewNameForServicesOrItems() {
- dao.asyncNewNameForServices();
- return ResultVoUtil.success("同步成功。");
- }
- public ResultVo<List> selectNationalItems(StandardLocalItem param) {
- int type = param.getType();
- if (type == NationalMatchType.MEDICINE) {
- String approve = param.getApprovalNumber();
- approve = StringUtil.isBlank(approve) ? "%%" : "%" + approve.replace("国药准字", "") + "%";
- List<SiCentralMedicine> list = dao.selectNationalMedicines(param.getFuzzyName(), approve);
- if (null == list || list.isEmpty()) {
- list = dao.selectNationalMedicines(param.getFuzzyName(), "%%");
- if (null == list || list.isEmpty()) {
- return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有符合条件的国家目录。");
- }
- }
- return ResultVoUtil.success(list);
- } else if (type == NationalMatchType.HERBAL){
- String name = param.getFuzzyName();
- if (name.contains("颗粒")) {
- String[] splits = param.getFuzzyName().split("(");
- splits = splits[0].split("\\(");
- name = splits[0].replaceAll("颗粒", "");
- }
- name = "%" + name.trim() + "%";
- List<SiCentralHerbal> list = dao.selectNationalHerbals(name);
- if (null == list || list.isEmpty()) {
- return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有符合条件的国家目录。");
- }
- return ResultVoUtil.success(list);
- } else if (type == NationalMatchType.SERVICE) {
- String[] splits = param.getFuzzyName().split("外送");
- String name;
- if (splits.length == 1) {
- name = splits[0];
- } else {
- name = splits[0].substring(0, splits[0].length() - 1);
- }
- name = "%" + name + "%";
- List<SiCentralServices> list = dao.selectNationalServices(name);
- if (null == list || list.isEmpty()) {
- return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有符合条件的国家目录。");
- }
- return ResultVoUtil.success(list);
- } else {
- String name = "%" + param.getFuzzyName() + "%";
- List<SiCentralSuppliesMini> list = dao.selectNationalSupplies(name);
- if (null == list || list.isEmpty()) {
- return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有符合条件的国家目录。");
- }
- return ResultVoUtil.success(list);
- }
- }
- public ResultVo<String> executeMatch(StandardLocalItem param) {
- String staffId = TokenUtil.getTokenUserId();
- if (param.getType() < NationalMatchType.SERVICE) {
- dao.matchMedicineAndHerbal(param.getCode(), staffId, param.getNationalCode(), param.getNationalName());
- } else {
- dao.matchServcieAndSupply(param.getCode(), staffId, param.getNationalCode(), param.getNationalName());
- }
- log.info("【操作员:{}】匹配国家目录:{}", staffId, param);
- return ResultVoUtil.success("匹配成功。");
- }
- public ResultVo<String> cancelMatch(StandardLocalItem param) {
- String staffId = TokenUtil.getTokenUserId();
- if (param.getType() < NationalMatchType.SERVICE) {
- dao.cancelMatchYp(param.getCode(), param.getSerial(), staffId);
- } else {
- dao.cancelMatchXm(param.getCode(), staffId);
- }
- log.info("【操作员:{}】取消匹配国家目录:{}", staffId, param);
- return ResultVoUtil.success("取消匹配成功。");
- }
- public ResultVo<String> updateLocalItem(StandardLocalItem param) {
- String staffId = TokenUtil.getTokenUserId();
- if (param.getType() < NationalMatchType.SERVICE) {
- dao.updateMedicine(param.getName(), staffId, param.getCode());
- } else if (param.getType() == NationalMatchType.SERVICE) {
- dao.updateServiceItem(param.getName(), param.getUnit(), param.getPrice(), staffId,
- param.getStandardCode(), param.getDiscription(), param.getCode());
- } else {
- dao.updateSupply(param.getName(), staffId, param.getFactory(), param.getSpecification(), param.getCode());
- }
- log.info("【操作员:{}】修改项目:{}", staffId, param);
- return ResultVoUtil.success("修改成功。");
- }
- }
|