初步整合主界面前后端
This commit is contained in:
parent
b86fff9a80
commit
265af8a7a2
@ -6,6 +6,7 @@ import com.czlis.common.core.domain.entity.ComDict;
|
|||||||
import com.czlis.common.core.redis.RedisCache;
|
import com.czlis.common.core.redis.RedisCache;
|
||||||
import com.czlis.common.utils.spring.SpringUtils;
|
import com.czlis.common.utils.spring.SpringUtils;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,7 +25,13 @@ public class ComDictUtils {
|
|||||||
SpringUtils.getBean(RedisCache.class).deleteObject(key);
|
SpringUtils.getBean(RedisCache.class).deleteObject(key);
|
||||||
SpringUtils.getBean(RedisCache.class).setCacheObject(getCacheKey(key), dictDatas);
|
SpringUtils.getBean(RedisCache.class).setCacheObject(getCacheKey(key), dictDatas);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 清空字典缓存
|
||||||
|
*/
|
||||||
|
public static void clearDictCache() {
|
||||||
|
Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys("com_dict:" + "*");
|
||||||
|
SpringUtils.getBean(RedisCache.class).deleteObject(keys);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 获取字典缓存
|
* 获取字典缓存
|
||||||
*
|
*
|
||||||
|
|||||||
@ -19,4 +19,5 @@ public interface ComDictMapper {
|
|||||||
String getComDictNameById(String zdlb,String zddh);
|
String getComDictNameById(String zdlb,String zddh);
|
||||||
//根据名称查编号
|
//根据名称查编号
|
||||||
String getComDictIdByName(String zdlb,String zdmc);
|
String getComDictIdByName(String zdlb,String zdmc);
|
||||||
|
List<ComDict> getComDictListByZdlb(String zdlb);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package com.czlis.interfaceCommon.utils;
|
package com.czlis.interfaceCommon.utils;
|
||||||
|
|
||||||
import com.czlis.common.core.domain.Result;
|
|
||||||
import com.czlis.common.core.domain.entity.LabPat;
|
import com.czlis.common.core.domain.entity.LabPat;
|
||||||
import com.czlis.common.core.domain.entity.LabReqmain;
|
import com.czlis.common.core.domain.entity.LabReqmain;
|
||||||
import com.czlis.common.core.domain.entity.LabResult;
|
import com.czlis.common.core.domain.entity.LabResult;
|
||||||
@ -10,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@ -27,6 +27,7 @@ public class CommonUtil {
|
|||||||
ComDictMapper comDictMapper;
|
ComDictMapper comDictMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private LabResultMapper labResultMapper;
|
private LabResultMapper labResultMapper;
|
||||||
|
|
||||||
//====检验主表操作方法集合===
|
//====检验主表操作方法集合===
|
||||||
public LabPat getLabPatOne(Date jyrq, String yq, String ybh){
|
public LabPat getLabPatOne(Date jyrq, String yq, String ybh){
|
||||||
return labPatMapper.getLabPatOne(jyrq, yq, ybh);
|
return labPatMapper.getLabPatOne(jyrq, yq, ybh);
|
||||||
@ -87,4 +88,5 @@ public class CommonUtil {
|
|||||||
return comOptMapper.getComOptValue(yq,xxdh);
|
return comOptMapper.getComOptValue(yq,xxdh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,14 @@
|
|||||||
<sql id="selectComDictVo">
|
<sql id="selectComDictVo">
|
||||||
select zdlb,zddh,zdmc,zjf,zdbz,bz,yljg,userflag from com_dict
|
select zdlb,zddh,zdmc,zjf,zdbz,bz,yljg,userflag from com_dict
|
||||||
</sql>
|
</sql>
|
||||||
|
<select id="getComDictListByZdlb" resultType="com.czlis.common.core.domain.entity.ComDict">
|
||||||
|
<include refid="selectComDictVo"></include>
|
||||||
|
<where>
|
||||||
|
<if test="zdlb != null and zdlb != ''">
|
||||||
|
and zdlb = #{zdlb}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
<select id="getComDictList" resultType="com.czlis.common.core.domain.entity.ComDict">
|
<select id="getComDictList" resultType="com.czlis.common.core.domain.entity.ComDict">
|
||||||
<include refid="selectComDictVo"></include>
|
<include refid="selectComDictVo"></include>
|
||||||
<where>
|
<where>
|
||||||
|
|||||||
@ -36,12 +36,18 @@ public class DictController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@ApiOperation("查询字典列表")
|
@ApiOperation("查询字典列表")
|
||||||
@GetMapping("/query")
|
@GetMapping("/query")
|
||||||
public TableDataInfo getComDictList(ComDict comDict){
|
public TableDataInfo query(ComDict comDict){
|
||||||
log.info("调用查询字典列表,{}",comDict);
|
log.info("调用查询字典列表,{}",comDict);
|
||||||
startPage();
|
startPage();
|
||||||
List<ComDict> comDictList = comDictService.getComDictList(comDict);
|
List<ComDict> comDictList = comDictService.getComDictList(comDict);
|
||||||
return getDataTable(comDictList);
|
return getDataTable(comDictList);
|
||||||
}
|
}
|
||||||
|
@ApiOperation("查询字典列表(不分页)")
|
||||||
|
@GetMapping("/getComDicts")
|
||||||
|
public Result getComDicts(String zdlb){
|
||||||
|
log.info("调用查询字典列表不分页,{}",zdlb);
|
||||||
|
return comDictService.getComDicts(zdlb);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation("新增字典")
|
@ApiOperation("新增字典")
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@ -53,14 +59,14 @@ public class DictController extends BaseController {
|
|||||||
|
|
||||||
@ApiOperation("删除字典")
|
@ApiOperation("删除字典")
|
||||||
@DeleteMapping("/del")
|
@DeleteMapping("/del")
|
||||||
public Result delComDict(ComDict comDict){
|
public Result del(ComDict comDict){
|
||||||
log.info("调用删除字典接口{}",comDict);
|
log.info("调用删除字典接口{}",comDict);
|
||||||
return comDictService.delComDict(comDict);
|
return comDictService.delComDict(comDict);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("修改字典")
|
@ApiOperation("修改字典")
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
public Result updateComDict(@RequestBody ComDict comDict){
|
public Result update(@RequestBody ComDict comDict){
|
||||||
log.info("调用修改字典接口{}",comDict);
|
log.info("调用修改字典接口{}",comDict);
|
||||||
return comDictService.updateComDict(comDict);
|
return comDictService.updateComDict(comDict);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,9 @@ import java.util.List;
|
|||||||
|
|
||||||
public interface ComDictService {
|
public interface ComDictService {
|
||||||
List<ComDict> getComDictList(ComDict comDict);
|
List<ComDict> getComDictList(ComDict comDict);
|
||||||
|
Result getComDicts(String zdlb);
|
||||||
|
Result getComDictNameById(String zdlb,String zddh);
|
||||||
|
Result getComDictIdByName(String zdlb,String zdmc);
|
||||||
Result insertComDict(ComDict comDict);
|
Result insertComDict(ComDict comDict);
|
||||||
|
|
||||||
Result delComDict(ComDict comDict);
|
Result delComDict(ComDict comDict);
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
package com.czlis.liswork.service.impl;
|
package com.czlis.liswork.service.impl;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Map;
|
||||||
import cn.hutool.extra.pinyin.PinyinUtil;
|
import cn.hutool.extra.pinyin.PinyinUtil;
|
||||||
import com.czlis.common.core.domain.Result;
|
import com.czlis.common.core.domain.Result;
|
||||||
|
import com.czlis.common.core.domain.entity.SysDictData;
|
||||||
import com.czlis.common.utils.ComDictUtils;
|
import com.czlis.common.utils.ComDictUtils;
|
||||||
import com.czlis.common.utils.StringUtils;
|
import com.czlis.common.utils.StringUtils;
|
||||||
import com.czlis.interfaceCommon.mapper.ComDictMapper;
|
import com.czlis.interfaceCommon.mapper.ComDictMapper;
|
||||||
@ -14,34 +16,68 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Propagation;
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.czlis.common.utils.PageUtils.startPage;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* lis字典管理
|
* lis字典管理
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ComDictServiceImpl implements ComDictService {
|
public class ComDictServiceImpl implements ComDictService {
|
||||||
|
//选择性提供缓存的字典类别
|
||||||
|
private List<String> list = Arrays.asList("GROUP","AU","BT","DG", "DP", "FT", "HOS","LG","PT","PW","SRD","SX","UT","CM","VF");
|
||||||
@Autowired
|
@Autowired
|
||||||
private ComDictMapper comDictMapper;
|
private ComDictMapper comDictMapper;
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
loadingDictCache();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 加载字典缓存数据
|
||||||
|
*/
|
||||||
|
private void loadingDictCache() {
|
||||||
|
//清空所有com_dict缓存
|
||||||
|
ComDictUtils.clearDictCache();
|
||||||
|
list.stream().forEach(zdlb -> ComDictUtils.setDictCache(zdlb, comDictMapper.getComDictListByZdlb(zdlb)));
|
||||||
|
}
|
||||||
|
private void setDictCache(String zdlb,List<ComDict> comDictList) {
|
||||||
|
boolean isPresent = list.contains(zdlb);
|
||||||
|
if(isPresent)ComDictUtils.setDictCache(zdlb,comDictList);
|
||||||
|
}
|
||||||
|
private List<ComDict> getDictCache(String zdlb) {
|
||||||
|
boolean isPresent = list.contains(zdlb);
|
||||||
|
if(isPresent) return ComDictUtils.getDictCache(zdlb);
|
||||||
|
else return comDictMapper.getComDictListByZdlb(zdlb);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ComDict> getComDictList(ComDict comDict) {
|
public List<ComDict> getComDictList(ComDict comDict) {
|
||||||
//先从redis缓存中获取,如果没有,就从数据库取
|
return getDictCache(comDict.getZdlb());
|
||||||
// List<ComDict> dictCache = ComDictUtils.getDictCache(comDict.getZdlb());
|
}
|
||||||
// if (dictCache != null) return dictCache;
|
@Override
|
||||||
// List<ComDict> comDictList = comDictMapper.getComDictList(comDict);
|
public Result getComDicts(String zdlb) {
|
||||||
// //加载缓存
|
return new Result("0", "成功!",getDictCache(zdlb));
|
||||||
// ComDictUtils.setDictCache(comDict.getZdlb(),comDictList);
|
}
|
||||||
// return comDictMapper.getComDictList(comDict);
|
//根据编号查名称
|
||||||
|
public Result getComDictNameById(String zdlb,String zddh) {
|
||||||
|
List<ComDict> comDictList =getDictCache(zdlb);
|
||||||
return comDictMapper.getComDictList(comDict);
|
for (ComDict dict : comDictList) {
|
||||||
|
if (zddh.equals(dict.getZddh())) {
|
||||||
|
return new Result("0", "成功!",dict.getZdmc());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Result("-1", "失败!",null);
|
||||||
|
}
|
||||||
|
//根据名称查编号
|
||||||
|
public Result getComDictIdByName(String zdlb,String zdmc) {
|
||||||
|
List<ComDict> comDictList =getDictCache(zdlb);
|
||||||
|
for (ComDict dict : comDictList) {
|
||||||
|
if (zdmc.equals(dict.getZdmc())) {
|
||||||
|
return new Result("0", "成功!",dict.getZddh());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Result("-1", "失败!",null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 增加字典信息
|
* 增加字典信息
|
||||||
* @param comDict
|
* @param comDict
|
||||||
@ -59,7 +95,7 @@ public class ComDictServiceImpl implements ComDictService {
|
|||||||
int row = comDictMapper.insertComDict(comDict);
|
int row = comDictMapper.insertComDict(comDict);
|
||||||
if (row > 0) {
|
if (row > 0) {
|
||||||
List<ComDict> comDictList = comDictMapper.getComDictList(comDict);
|
List<ComDict> comDictList = comDictMapper.getComDictList(comDict);
|
||||||
ComDictUtils.setDictCache(comDict.getZdlb(), comDictList);
|
setDictCache(comDict.getZdlb(), comDictList);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -108,7 +144,7 @@ public class ComDictServiceImpl implements ComDictService {
|
|||||||
ComDict comDict0 = new ComDict();
|
ComDict comDict0 = new ComDict();
|
||||||
comDict0.setZdlb(zdlb);
|
comDict0.setZdlb(zdlb);
|
||||||
List<ComDict> comDictList1 = comDictMapper.getComDictList(comDict0);
|
List<ComDict> comDictList1 = comDictMapper.getComDictList(comDict0);
|
||||||
ComDictUtils.setDictCache(comDict0.getZdlb(), comDictList1);
|
setDictCache(comDict0.getZdlb(), comDictList1);
|
||||||
if (failureNum == comDictList.size()) {
|
if (failureNum == comDictList.size()) {
|
||||||
return new Result("0", "数据已全部导入成功!共 " + comDictList.size() + " 条");
|
return new Result("0", "数据已全部导入成功!共 " + comDictList.size() + " 条");
|
||||||
} else {
|
} else {
|
||||||
@ -146,6 +182,7 @@ public class ComDictServiceImpl implements ComDictService {
|
|||||||
if (zddh == null || zddh.equals("")) return new Result("-1", "字典代号不能为空!");
|
if (zddh == null || zddh.equals("")) return new Result("-1", "字典代号不能为空!");
|
||||||
if (yljg == null || yljg.equals("")) return new Result("-1", "医疗机构不能为空!");
|
if (yljg == null || yljg.equals("")) return new Result("-1", "医疗机构不能为空!");
|
||||||
int row = comDictMapper.delComDict(comDict);
|
int row = comDictMapper.delComDict(comDict);
|
||||||
|
if (row > 0) setDictCache(zdlb, comDictMapper.getComDictListByZdlb(zdlb));
|
||||||
return new Result("0", "删除成功!");
|
return new Result("0", "删除成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +192,7 @@ public class ComDictServiceImpl implements ComDictService {
|
|||||||
int row = comDictMapper.updateComDict(comDict);
|
int row = comDictMapper.updateComDict(comDict);
|
||||||
if (row > 0) {
|
if (row > 0) {
|
||||||
List<ComDict> comDictList = comDictMapper.getComDictList(comDict);
|
List<ComDict> comDictList = comDictMapper.getComDictList(comDict);
|
||||||
ComDictUtils.setDictCache(comDict.getZdlb(), comDictList);
|
setDictCache(comDict.getZdlb(), comDictList);
|
||||||
}
|
}
|
||||||
return new Result("0", "修改成功!");
|
return new Result("0", "修改成功!");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user