方药查询-药材列表修改
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.entity.MedicinalDrug;
|
||||
import com.peanut.modules.book.entity.MedicinalMaterials;
|
||||
import com.peanut.modules.book.entity.SysDictDataEntity;
|
||||
import com.peanut.modules.book.service.MedicinalDrugService;
|
||||
import com.peanut.modules.book.service.MedicinalMaterialsService;
|
||||
import com.peanut.modules.sys.service.SysDictDataService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -26,6 +29,20 @@ public class MedicinalMaterialsController {
|
||||
@Autowired
|
||||
private MedicinalDrugService drugService;
|
||||
|
||||
@Autowired
|
||||
private SysDictDataService sysDictDataService;
|
||||
|
||||
/**
|
||||
* 类型列表
|
||||
*/
|
||||
@RequestMapping(path = "/getTypeList")
|
||||
public R getTypeList(String label) {
|
||||
LambdaQueryWrapper<SysDictDataEntity> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.select(SysDictDataEntity::getDictValue);
|
||||
wrapper.eq(SysDictDataEntity::getDictLabel,label);
|
||||
return R.ok().put("result",sysDictDataService.list(wrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取中药材列表
|
||||
* @return
|
||||
@@ -42,19 +59,56 @@ public class MedicinalMaterialsController {
|
||||
wrapper.like(MedicinalMaterials::getType,params.get("type"));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("effect").toString())){
|
||||
wrapper.like(MedicinalMaterials::getEffect,params.get("effect"));
|
||||
String[] str = params.get("effect").toString().split(",");
|
||||
String effect = "";
|
||||
for (String s : str) {
|
||||
if ("".equals(effect)){
|
||||
effect += " effect like '%" + s +"%'";
|
||||
}else {
|
||||
effect += " or effect like '%" + s +"%'";
|
||||
}
|
||||
}
|
||||
wrapper.apply("("+effect+")");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("taste").toString())){
|
||||
wrapper.like(MedicinalMaterials::getTaste,params.get("taste"));
|
||||
String[] str = params.get("taste").toString().split(",");
|
||||
String taste = "";
|
||||
for (String s : str) {
|
||||
if ("".equals(taste)){
|
||||
taste += " taste like '%" + s +"%'";
|
||||
}else {
|
||||
taste += " or taste like '%" + s +"%'";
|
||||
}
|
||||
}
|
||||
wrapper.apply("("+taste+")");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("property").toString())){
|
||||
wrapper.like(MedicinalMaterials::getProperty,params.get("property"));
|
||||
String[] str = params.get("property").toString().split(",");
|
||||
String property = "";
|
||||
for (String s : str) {
|
||||
if ("".equals(property)){
|
||||
property += " property like '%" + s +"%'";
|
||||
}else {
|
||||
property += " or property like '%" + s +"%'";
|
||||
}
|
||||
}
|
||||
wrapper.apply("("+property+")");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("tropism").toString())){
|
||||
wrapper.like(MedicinalMaterials::getTropism,params.get("tropism"));
|
||||
String[] str = params.get("tropism").toString().split(",");
|
||||
String tropism = "";
|
||||
for (String s : str) {
|
||||
if ("".equals(tropism)){
|
||||
tropism += " tropism like '%" + s +"%'";
|
||||
}else {
|
||||
tropism += " or tropism like '%" + s +"%'";
|
||||
}
|
||||
}
|
||||
wrapper.apply("("+tropism+")");
|
||||
}
|
||||
wrapper.orderByAsc(MedicinalMaterials::getSort);
|
||||
wrapper.orderByDesc(MedicinalMaterials::getHits);
|
||||
wrapper.orderByAsc(MedicinalMaterials::getId);
|
||||
Page<MedicinalMaterials> page = materialsService.page(new Page<>(
|
||||
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
|
||||
return R.ok().put("result", page);
|
||||
@@ -90,13 +144,16 @@ public class MedicinalMaterialsController {
|
||||
MPJLambdaWrapper<MedicinalDrug> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.select("id,name,english_name,pinyin_name,kind,prescription_type,insurance_type,type,sort,hits");
|
||||
if (StringUtils.isNotEmpty(params.get("name").toString())){
|
||||
wrapper.and(StringUtils.isNotEmpty(params.get("name").toString()),
|
||||
t->t.like(MedicinalDrug::getName,params.get("name"))
|
||||
wrapper.and(t->t.like(MedicinalDrug::getName,params.get("name"))
|
||||
.or().like(MedicinalDrug::getEnglishName,params.get("name"))
|
||||
.or().like(MedicinalDrug::getPinyinName,params.get("name")));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("kind").toString())){
|
||||
wrapper.like(MedicinalDrug::getKind,params.get("kind"));
|
||||
if (params.get("kind").toString().contains("麻醉")){
|
||||
wrapper.like(MedicinalDrug::getKind,params.get("kind").toString().substring(0,2));
|
||||
}else {
|
||||
wrapper.like(MedicinalDrug::getKind,params.get("kind").toString().replace("类",""));
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("prescriptionType").toString())){
|
||||
wrapper.like(MedicinalDrug::getPrescriptionType,params.get("prescriptionType"));
|
||||
@@ -105,7 +162,7 @@ public class MedicinalMaterialsController {
|
||||
wrapper.like(MedicinalDrug::getInsuranceType,params.get("insuranceType"));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("type").toString())){
|
||||
wrapper.like(MedicinalDrug::getType,params.get("type"));
|
||||
wrapper.eq(MedicinalDrug::getType,params.get("type"));
|
||||
}
|
||||
wrapper.orderByAsc(MedicinalDrug::getSort);
|
||||
wrapper.orderByDesc(MedicinalDrug::getHits);
|
||||
|
||||
Reference in New Issue
Block a user