参数模块
This commit is contained in:
parent
5e2f3dc381
commit
5cded54a37
@ -5,9 +5,6 @@ import com.czlis.common.core.controller.BaseController;
|
||||
import com.czlis.common.core.domain.AjaxResult;
|
||||
import com.czlis.common.core.domain.entity.lis.ComConfigDict;
|
||||
import com.czlis.common.enums.BusinessType;
|
||||
import com.czlis.common.utils.SecurityUtils;
|
||||
import com.czlis.common.utils.poi.ExcelUtil;
|
||||
import com.czlis.liswork.service.ComConfigDictService;
|
||||
import com.czlis.liswork.service.ComLocalconfigService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -16,7 +13,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "参数模板设置")
|
||||
@ -25,7 +21,6 @@ import java.util.List;
|
||||
@Slf4j
|
||||
public class ComLocalconfigController extends BaseController {
|
||||
@Autowired
|
||||
ComConfigDictService ComConfigDictService;
|
||||
ComLocalconfigService ComLocalconfigService;
|
||||
/**
|
||||
* 获取字典列表
|
||||
@ -33,42 +28,38 @@ public class ComLocalconfigController extends BaseController {
|
||||
@ApiOperation("获取参数列表")
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list() {
|
||||
String localid= SecurityUtils.getLoginUser().getSysLoginParam().getLocalid();
|
||||
ComLocalconfigService.getComLocalconfigList(localid);
|
||||
return success(ComLocalconfigService.getComLocalconfigList(localid));
|
||||
return success(ComLocalconfigService.getComLocalconfigList());
|
||||
}
|
||||
/**
|
||||
* 根据字典编号获取详细信息
|
||||
* 重置参数到初始默认值
|
||||
*/
|
||||
@ApiOperation("获取详细信息")
|
||||
@GetMapping(value = "/{dictId}")
|
||||
public AjaxResult getInfo(@PathVariable Long dictId) {
|
||||
return success(ComConfigDictService.selectComConfigDictById(dictId));
|
||||
@ApiOperation("重置参数")
|
||||
@GetMapping("/resetdef")
|
||||
public AjaxResult resetdef() {
|
||||
List<ComConfigDict> posts = ComLocalconfigService.getComLocalconfigdef();
|
||||
return success(posts);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典
|
||||
* 修改本地参数
|
||||
*/
|
||||
@ApiOperation("修改字典")
|
||||
@Log(title = "字典管理", businessType = BusinessType.UPDATE)
|
||||
@ApiOperation("修改本地参数")
|
||||
@Log(title = "修改本地参数", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody ComConfigDict post) {
|
||||
if (!ComConfigDictService.checkDictNameUnique(post)) {
|
||||
return error("修改字典'" + post.getConfigName() + "'失败,字典名称已存在");
|
||||
} else if (!ComConfigDictService.checkDictCodeUnique(post)) {
|
||||
return error("修改字典'" + post.getConfigName() + "'失败,字典编码已存在");
|
||||
}
|
||||
post.setUpdateBy(getUsername());
|
||||
return toAjax(ComConfigDictService.updateDict(post));
|
||||
return success(ComLocalconfigService.updateComLocalconfig(post));
|
||||
}
|
||||
@ApiOperation("整体保存本地参数")
|
||||
@Log(title = "整体保存本地参数", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/editall")
|
||||
public AjaxResult editall(@Validated @RequestBody List<ComConfigDict> posts) {
|
||||
return success(ComLocalconfigService.updateComLocalconfigALL(posts));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典选择框列表
|
||||
*/
|
||||
@ApiOperation("获取字典选择框列表")
|
||||
@GetMapping("/optionselect/{dictId}")
|
||||
public AjaxResult optionselect() {
|
||||
List<ComConfigDict> posts = ComConfigDictService.selectComConfigDictAll();
|
||||
return success(posts);
|
||||
@GetMapping("/optionselect")
|
||||
public AjaxResult optionselect(String zdlb) {
|
||||
return success(ComLocalconfigService.getComDicts(zdlb));
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ import java.util.List;
|
||||
public interface LocalconfigMapper {
|
||||
|
||||
List<ComLocalconfig> selectComLocalconfigList(ComLocalconfig comLocalconfig);
|
||||
Long getCountById(Long sid);
|
||||
ComLocalconfig selectComLocalconfigById(Long sid);
|
||||
Long getCountBymic(String smac);
|
||||
Long getsid(String smac);
|
||||
List<ComLocalconfig> selectComLocalconfigAll();
|
||||
|
||||
@ -4,16 +4,12 @@ import com.czlis.common.core.domain.entity.lis.ComConfigDict;
|
||||
import com.czlis.common.core.domain.entity.lis.ComLocalconfig;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ComLocalconfigService {
|
||||
List<ComConfigDict> getComLocalconfigList(String smac);
|
||||
Long getCountById(Long sid);
|
||||
Long getCountBymic(String smac);
|
||||
Long getsid(String smac);
|
||||
List<ComLocalconfig> selectComLocalconfigAll();
|
||||
int insertComLocalconfig(ComLocalconfig comLocalconfig);
|
||||
int delComLocalconfigById(Long sid);
|
||||
int delComLocalconfigBymac(String smac);
|
||||
int delComLocalconfigByIds(Long[] sids);
|
||||
int updateComLocalconfig(ComLocalconfig comLocalconfig);
|
||||
List<ComConfigDict> getComLocalconfigList();
|
||||
List<ComConfigDict> getComLocalconfigdef();
|
||||
int updateComLocalconfig(ComConfigDict comConfigDict);
|
||||
int updateComLocalconfigALL(List<ComConfigDict> list);
|
||||
Object getComDicts(String zdlb);
|
||||
}
|
||||
|
||||
@ -1,15 +1,24 @@
|
||||
package com.czlis.liswork.service.impl.xtwh;
|
||||
|
||||
import com.czlis.common.core.domain.entity.lis.ComConfigDict;
|
||||
import com.czlis.common.core.domain.entity.lis.ComLocalconfig;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.czlis.common.core.domain.entity.lis.*;
|
||||
import com.czlis.common.utils.SecurityUtils;
|
||||
import com.czlis.interfaceCommon.utils.CommonUtil;
|
||||
import com.czlis.liswork.mapper.xtwh.LocalconfigMapper;
|
||||
import com.czlis.liswork.service.ComConfigDictService;
|
||||
import com.czlis.liswork.service.ComLocalconfigService;
|
||||
import com.itextpdf.commons.utils.JsonUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ComLocalconfigServiceImpl implements ComLocalconfigService {
|
||||
@ -17,57 +26,170 @@ public class ComLocalconfigServiceImpl implements ComLocalconfigService {
|
||||
ComConfigDictService ComConfigDictService;
|
||||
@Autowired
|
||||
LocalconfigMapper localconfigMapper;
|
||||
@Override
|
||||
public List<ComConfigDict> getComLocalconfigList(String smac){
|
||||
ComConfigDict post=new ComConfigDict();
|
||||
post.setConfigType("LOCAL");
|
||||
post.setStatus("0");
|
||||
List<ComConfigDict> list = ComConfigDictService.selectComConfigDictList(post);
|
||||
if(list.isEmpty())return null;
|
||||
ComLocalconfig comLocalconfig=new ComLocalconfig();
|
||||
@Autowired
|
||||
CommonUtil commonUtil;
|
||||
|
||||
/**
|
||||
* 获取登录客户端浏览器唯一ID
|
||||
**/
|
||||
private String getLocalid() {
|
||||
return SecurityUtils.getLoginUser().getSysLoginParam().getLocalid();
|
||||
}
|
||||
|
||||
private String getYLJG() {
|
||||
return SecurityUtils.getLoginUser().getSysLoginParam().getLoginYLJG();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录客户端IP地址
|
||||
**/
|
||||
private String getIpaddr() {
|
||||
return SecurityUtils.getLoginUser().getIpaddr();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录客户端工号
|
||||
**/
|
||||
private String getUsername() {
|
||||
return SecurityUtils.getLoginUser().getUsername();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取参数信息明细
|
||||
**/
|
||||
private Map<String, Object> getConfigvalue(String smac) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
ComLocalconfig comLocalconfig = new ComLocalconfig();
|
||||
comLocalconfig.setSmac(smac);
|
||||
List<ComLocalconfig> comLocalconfiglist=localconfigMapper.selectComLocalconfigList(comLocalconfig);
|
||||
if(comLocalconfiglist.size()>0){
|
||||
comLocalconfig= comLocalconfiglist.get(0);
|
||||
String configvalue=comLocalconfig.getConfigvalue();
|
||||
List<ComLocalconfig> comLocalconfiglist = localconfigMapper.selectComLocalconfigList(comLocalconfig);
|
||||
if (comLocalconfiglist.size() > 0) {
|
||||
comLocalconfig = comLocalconfiglist.get(0);
|
||||
String configvalue = comLocalconfig.getConfigvalue();
|
||||
map = JSON.parseObject(configvalue, Map.class);
|
||||
}
|
||||
return null;
|
||||
return map;
|
||||
}
|
||||
@Override
|
||||
public Long getCountById(Long sid){
|
||||
return null;
|
||||
|
||||
private String setConfigvalueALL(List<ComConfigDict> list) {
|
||||
if (list.isEmpty()) return null;
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
for (ComConfigDict comConfigDict : list) {
|
||||
map.put(comConfigDict.getConfigCode(), comConfigDict.getConfigDefvalue());
|
||||
}
|
||||
return JSON.toJSONString(map);
|
||||
}
|
||||
@Override
|
||||
public Long getCountBymic(String smac){
|
||||
return null;
|
||||
|
||||
private String setConfigvalue(ComConfigDict comConfigDict) {
|
||||
if (comConfigDict == null) return null;
|
||||
Map<String, Object> map = getConfigvalue(getLocalid());
|
||||
map.put(comConfigDict.getConfigCode(), comConfigDict.getConfigDefvalue());
|
||||
return JSON.toJSONString(map);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public Long getsid(String smac){
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public List<ComLocalconfig> selectComLocalconfigAll(){
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public int insertComLocalconfig(ComLocalconfig comLocalconfig){
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int delComLocalconfigById(Long sid){
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int delComLocalconfigBymac(String smac){
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int delComLocalconfigByIds(Long[] sids){
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int updateComLocalconfig(ComLocalconfig comLocalconfig){
|
||||
public int updateComLocalconfig(ComConfigDict comConfigDict) {
|
||||
String smac = getLocalid();
|
||||
if (smac == null) return 0;
|
||||
Long sid = localconfigMapper.getsid(smac);
|
||||
if (sid == null || sid == 0) {
|
||||
ComLocalconfig comLocalconfig = new ComLocalconfig();
|
||||
comLocalconfig.setSmac(smac);
|
||||
comLocalconfig.setSip(getIpaddr());
|
||||
comLocalconfig.setConfigvalue(setConfigvalue(comConfigDict));
|
||||
comLocalconfig.setCreate_by(getUsername());
|
||||
localconfigMapper.insertComLocalconfig(comLocalconfig);
|
||||
} else {
|
||||
ComLocalconfig comLocalconfig = localconfigMapper.selectComLocalconfigById(sid);
|
||||
comLocalconfig.setConfigvalue(setConfigvalue(comConfigDict));
|
||||
comLocalconfig.setUpdate_by(getUsername());
|
||||
comLocalconfig.setSip(getIpaddr());
|
||||
localconfigMapper.updateComLocalconfig(comLocalconfig);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int updateComLocalconfigALL(List<ComConfigDict> list) {
|
||||
String smac = getLocalid();
|
||||
if (smac == null) return 0;
|
||||
Long sid = localconfigMapper.getsid(smac);
|
||||
if (sid == null || sid == 0) {
|
||||
ComLocalconfig comLocalconfig = new ComLocalconfig();
|
||||
comLocalconfig.setSmac(smac);
|
||||
comLocalconfig.setSip(getIpaddr());
|
||||
comLocalconfig.setConfigvalue(setConfigvalueALL(list));
|
||||
comLocalconfig.setCreate_by(getUsername());
|
||||
localconfigMapper.insertComLocalconfig(comLocalconfig);
|
||||
} else {
|
||||
ComLocalconfig comLocalconfig = localconfigMapper.selectComLocalconfigById(sid);
|
||||
comLocalconfig.setConfigvalue(setConfigvalueALL(list));
|
||||
comLocalconfig.setUpdate_by(getUsername());
|
||||
comLocalconfig.setSip(getIpaddr());
|
||||
localconfigMapper.updateComLocalconfig(comLocalconfig);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ComConfigDict> getComLocalconfigList() {
|
||||
return getComLocalconfigList(getLocalid());
|
||||
}
|
||||
|
||||
public List<ComConfigDict> getComLocalconfigList(String smac) {
|
||||
ComConfigDict post = new ComConfigDict();
|
||||
post.setConfigType("LOCAL");
|
||||
post.setStatus("0");
|
||||
List<ComConfigDict> list = ComConfigDictService.selectComConfigDictList(post);
|
||||
if (list.isEmpty()) return null;
|
||||
Map<String, Object> map = getConfigvalue(smac);
|
||||
if (!map.isEmpty()) {
|
||||
for (ComConfigDict comConfigDict : list) {
|
||||
String configCode = comConfigDict.getConfigCode();
|
||||
if (map.containsKey(configCode)) {
|
||||
String value = map.get(configCode).toString();
|
||||
if (value != null) {
|
||||
comConfigDict.setConfigDefvalue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ComConfigDict> getComLocalconfigdef() {
|
||||
ComConfigDict post = new ComConfigDict();
|
||||
post.setConfigType("LOCAL");
|
||||
post.setStatus("0");
|
||||
List<ComConfigDict> list = ComConfigDictService.selectComConfigDictList(post);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComDicts(String zdlb) {
|
||||
if ("INSTR".equals(zdlb)) {
|
||||
return getInstr();
|
||||
}
|
||||
return commonUtil.getComDictList(zdlb);
|
||||
}
|
||||
|
||||
public List<Map<String, String>> getInstr() {
|
||||
List<Map<String, String>> list = new ArrayList<>();
|
||||
String yljg = getYLJG();
|
||||
if (yljg == null) {
|
||||
String yhdh = getUsername();
|
||||
List<ComUsr> ComUsrlist = commonUtil.getComUsrList(yhdh);
|
||||
yljg = ComUsrlist.get(0).getYljg();
|
||||
}
|
||||
List<LabInstr> labInstrlist = commonUtil.querybylisgroup("", yljg, "0");
|
||||
for (LabInstr labInstr : labInstrlist) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("zddh", labInstr.getYq().trim());
|
||||
map.put("zdmc", labInstr.getYqmc().trim());
|
||||
list.add(map);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,14 +20,14 @@
|
||||
</where>
|
||||
order by sid ASC
|
||||
</select>
|
||||
<select id="getCountById" resultType="Long">
|
||||
select count(1) from com_localconfig where sid = #{sid}
|
||||
<select id="selectComLocalconfigById" resultType="com.czlis.common.core.domain.entity.lis.ComLocalconfig">
|
||||
select * from com_localconfig where sid = #{sid}
|
||||
</select>
|
||||
<select id="getCountBymic" resultType="Long">
|
||||
select count(1) from com_localconfig where smac = #{smac}
|
||||
</select>
|
||||
<select id="getsid" resultType="Long">
|
||||
select sid from com_localconfig where smac = #{smac}
|
||||
select MAX(sid) from com_localconfig where smac = #{smac}
|
||||
</select>
|
||||
<select id="selectComLocalconfigAll" resultType="ComLocalconfig">
|
||||
select * from com_localconfig
|
||||
@ -70,7 +70,7 @@
|
||||
<update id="updateComLocalconfig" parameterType="com.czlis.common.core.domain.entity.lis.ComLocalconfig">
|
||||
update com_localconfig
|
||||
<set>
|
||||
<if test="smac != null and smac != ''">config_type = #{smac},</if>
|
||||
<if test="smac != null and smac != ''">smac = #{smac},</if>
|
||||
<if test="sip != null and sip != ''">sip = #{sip},</if>
|
||||
<if test="sname != null and sname != ''">sname = #{sname},</if>
|
||||
<if test="configvalue != null and configvalue != ''">configvalue = #{configvalue},</if>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user