ソースを参照

公共模块整合编号模板管理

lizhenhao 2 年 前
コミット
4cb59f7bad

+ 64 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/serialNumTpl/controller/SerialnumTplController.java

@@ -0,0 +1,64 @@
+package com.jeeplus.pubmodules.serialNumTpl.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.jeeplus.core.query.QueryWrapperGenerator;
+import com.jeeplus.pubmodules.serialNumTpl.domain.SysSerialnumTpl;
+import com.jeeplus.pubmodules.serialNumTpl.service.SerialnumTplService;
+import com.jeeplus.sys.domain.User;
+import com.jeeplus.sys.service.dto.UserDTO;
+import com.jeeplus.sys.utils.UserUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+
+@Api(tags ="template")
+@RestController
+@RequestMapping(value = "/sys/template")
+public class SerialnumTplController {
+
+    @Resource
+    private SerialnumTplService serialnumTplService;
+
+    /**
+     * 编号模板列表
+     */
+    @ApiOperation(value = "编号模板列表")
+    @GetMapping(value = "/list")
+    public ResponseEntity<IPage<SysSerialnumTpl>> list(Page<SysSerialnumTpl> page, SysSerialnumTpl sysSerialnumTpl) throws Exception{
+        QueryWrapper<SysSerialnumTpl> sysSerialnumTplQueryWrapper = QueryWrapperGenerator.buildQueryCondition(sysSerialnumTpl, SysSerialnumTpl.class);
+        IPage<SysSerialnumTpl> list = serialnumTplService.list(page, sysSerialnumTplQueryWrapper);
+        return ResponseEntity.ok (list);
+    }
+
+    /**
+     * 编号模板删除
+     */
+    @ApiOperation(value = "编号模板列表")
+    @GetMapping(value = "/remove")
+    public String remove(@RequestParam String id){
+        return serialnumTplService.remove(id);
+    }
+
+    /**
+     * 编号模板查询
+     */
+    @ApiOperation(value = "编号模板列表")
+    @GetMapping(value = "/findById")
+    public SysSerialnumTpl findById(@RequestParam String id){
+        return serialnumTplService.findById(id);
+    }
+
+    /**
+     * 编号模板保存、修改
+     */
+    @ApiOperation(value = "编号模板保存、修改")
+    @PostMapping(value = "/save")
+    public String save(@RequestBody SysSerialnumTpl sysSerialnumTpl){
+        return serialnumTplService.save(sysSerialnumTpl);
+    }
+}

+ 64 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/serialNumTpl/domain/SysSerialnumTpl.java

@@ -0,0 +1,64 @@
+package com.jeeplus.pubmodules.serialNumTpl.domain;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.jeeplus.core.domain.BaseEntity;
+import com.jeeplus.core.query.Query;
+import lombok.Data;
+
+@Data
+@TableName(value = "sys_serialnum_tpl")
+public class SysSerialnumTpl extends BaseEntity {
+
+    /**
+     * 公司id
+     */
+    @TableField(value = "company_id")
+    private String companyId;
+
+    /**
+     * 业务标识
+     */
+    @TableField(value = "biz_code")
+    private String bizCode;
+
+    /**
+     * 年度
+     */
+    @TableField(value = "year_built")
+    private String yearBuilt;
+
+    /**
+     * 序列号
+     */
+    @TableField(value = "serial_num")
+    private Integer serialNum;
+
+    /**
+     * 编号模板
+     */
+    @TableField(value = "serial_tpl")
+    private String serialTpl;
+
+    /**
+     * 序列号长度
+     */
+    @TableField(value = "serial_num_len")
+    private Integer serialNumLen;
+
+    /**
+     * 模板名称
+     */
+    @Query
+    @TableField(value = "tpl_name")
+    private String tplName;
+
+    /**
+     * 模板示例
+     */
+    @TableField(value = "serial_tpl_ex")
+    private String serialTplEx;
+
+    @TableField(exist = false)
+    private String companyName;
+}

+ 20 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/serialNumTpl/mapper/SerialnumTplMapper.java

@@ -0,0 +1,20 @@
+package com.jeeplus.pubmodules.serialNumTpl.mapper;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.jeeplus.pubmodules.serialNumTpl.domain.SysSerialnumTpl;
+import org.apache.ibatis.annotations.Param;
+
+public interface SerialnumTplMapper extends BaseMapper<SysSerialnumTpl> {
+
+    IPage<SysSerialnumTpl> pageList(Page<SysSerialnumTpl> page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper);
+
+    SysSerialnumTpl queryByComAndBizCode(@Param("id")String id, @Param("bizCode")String bizCode);
+
+    void resetSerialNum(@Param("id")String id,@Param("yearBuilt")String yearBuilt,@Param("newYear")String newYear);
+
+    int updateSerialNum(SysSerialnumTpl numTpl);
+}

+ 38 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/serialNumTpl/mapper/xml/TemplateMapper.xml

@@ -0,0 +1,38 @@
+<?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.jeeplus.pubmodules.serialNumTpl.mapper.SerialnumTplMapper">
+
+	<select id="pageList" resultType="com.jeeplus.pubmodules.serialNumTpl.domain.SysSerialnumTpl">
+		SELECT
+			a.id,
+			a.tpl_name,
+			(SELECT b.`name` FROM sys_office b WHERE b.del_flag = 0 AND b.id = a.company_id ) AS company_name,
+			a.biz_code,
+			a.serial_num_len,
+			a.serial_tpl_ex
+		FROM
+			sys_serialnum_tpl a
+		${ew.customSqlSegment}
+		ORDER BY create_date DESC
+	</select>
+
+	<select id="queryByComAndBizCode" resultType="com.jeeplus.pubmodules.serialNumTpl.domain.SysSerialnumTpl">
+		select	a.*
+		 from sys_serialnum_tpl a
+		where a.company_id = #{id} and a.biz_code = #{bizCode} and a.del_flag = 0
+		order by update_date desc
+		limit 1
+	</select>
+
+	<update id="resetSerialNum">
+		UPDATE sys_serialnum_tpl
+		SET serial_num = 0 , year_built = #{newYear}
+		WHERE id = #{id} AND  year_built = #{yearBuilt}
+	</update>
+
+	<update id="updateSerialNum">
+		UPDATE sys_serialnum_tpl
+		SET serial_num = serial_num +1
+		WHERE id = #{id}
+	</update>
+</mapper>

+ 312 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/serialNumTpl/service/SerialnumTplService.java

@@ -0,0 +1,312 @@
+package com.jeeplus.pubmodules.serialNumTpl.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.jeeplus.pubmodules.serialNumTpl.domain.SysSerialnumTpl;
+import com.jeeplus.pubmodules.serialNumTpl.mapper.SerialnumTplMapper;
+import com.jeeplus.sys.domain.Office;
+import com.jeeplus.sys.mapper.OfficeMapper;
+import com.jeeplus.sys.service.dto.UserDTO;
+import com.jeeplus.sys.utils.UserUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.client.utils.DateUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.time.LocalDate;
+import java.time.Month;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+@Service
+public class SerialnumTplService {
+
+    @Resource
+    private SerialnumTplMapper serialnumTplMapper;
+
+    @Resource
+    private OfficeMapper officeMapper;
+
+    public IPage<SysSerialnumTpl> list(Page<SysSerialnumTpl> page, QueryWrapper<SysSerialnumTpl> sysSerialnumTplQueryWrapper) {
+        sysSerialnumTplQueryWrapper.eq("del_flag", 0);
+        IPage<SysSerialnumTpl> list = serialnumTplMapper.pageList(page, sysSerialnumTplQueryWrapper);
+        return list;
+    }
+
+    public String remove(String id) {
+        serialnumTplMapper.deleteById(id);
+        return "操作成功";
+    }
+
+    public SysSerialnumTpl findById(String id) {
+        SysSerialnumTpl sysSerialnumTpl = serialnumTplMapper.selectById(id);
+        return sysSerialnumTpl;
+    }
+
+    public String save(SysSerialnumTpl sysSerialnumTpl) {
+        //获取当前登录人信息
+        UserDTO dto = UserUtils.getCurrentUserDTO();
+        //新增
+        if (StringUtils.isEmpty(sysSerialnumTpl.getId())) {
+            String id = UUID.randomUUID().toString().replace("-", "");
+            sysSerialnumTpl.setId(id);
+            sysSerialnumTpl.setCreateById(dto.getId());
+            sysSerialnumTpl.setCreateTime(new Date());
+            sysSerialnumTpl.setUpdateById(dto.getId());
+            sysSerialnumTpl.setUpdateTime(new Date());
+            sysSerialnumTpl.setDelFlag(0);
+            serialnumTplMapper.insert(sysSerialnumTpl);
+        }
+        //修改
+        if (StringUtils.isNotEmpty(sysSerialnumTpl.getId())) {
+            sysSerialnumTpl.setUpdateById(dto.getId());
+            sysSerialnumTpl.setUpdateTime(new Date());
+            serialnumTplMapper.updateById(sysSerialnumTpl);
+        }
+        return "操作完成";
+    }
+
+    @Transactional(readOnly = false,propagation = Propagation.REQUIRES_NEW)
+    public String genSerialNum(String companyId, String bizCode) throws Exception {
+        //获取当前登录人信息
+        UserDTO dto = UserUtils.getCurrentUserDTO();
+        Office office = officeMapper.selectById(companyId);
+        if (StringUtils.isBlank(bizCode)){
+            throw new Exception("生成编号失败,业务类型不能为空");
+        }
+        if (office != null) {
+            SysSerialnumTpl numTpl = this.querySerialTpl(office, bizCode);
+            if (numTpl == null) {
+                //查询编号模板   {brspnm}DZ-{year}-{serialNum}
+                SysSerialnumTpl serialNumTpl = serialnumTplMapper.queryByComAndBizCode(companyId, bizCode);
+                serialNumTpl.setCompanyId(companyId);
+                serialNumTpl.setSerialNum(0);
+                serialNumTpl.setCreateById(dto.getId());
+                serialNumTpl.setId(UUID.randomUUID().toString().replace("-", ""));
+                serialnumTplMapper.insert(serialNumTpl);
+                numTpl = serialNumTpl;
+            }
+            if (numTpl == null) {
+                throw new Exception("生成编号失败,请先设置相关业务编号模板");
+            }
+            String year = DateUtils.formatDate(new Date(), "yyyy");
+            if (!year.equals(numTpl.getYearBuilt())) {
+                serialnumTplMapper.resetSerialNum(numTpl.getId(), numTpl.getYearBuilt(), year);
+            }
+            Map<String, String> map = new HashMap<>();
+            String serialTpl = numTpl.getSerialTpl();
+            int i = serialnumTplMapper.updateSerialNum(numTpl);
+            if (i != 1) {
+                throw new Exception("生成编号失败,请稍后重试");
+            }
+            String num = String.valueOf(numTpl.getSerialNum() + 1);
+            StringBuffer sb = new StringBuffer();
+            for (int x = 0; x < (numTpl.getSerialNumLen() - num.length()); x++) {
+                sb.append("0");
+            }
+            sb.append(num);
+            //查询公司简称
+            if (serialTpl.contains("spnm")) {
+                String companyShortname = UserUtils.getSysParam("company_shortname");
+                map.put("spnm", StringUtils.isBlank(companyShortname) ? "" : companyShortname);
+            }
+            //查询分公司简称
+            if (serialTpl.contains("brspnm")) {
+                String branchShortname = UserUtils.getSysParam("branch_shortname");
+                map.put("brspnm", StringUtils.isBlank(branchShortname) ? "" : branchShortname);
+            }
+            //年份
+            if (serialTpl.contains("year")) {
+                map.put("year", year);
+            }
+            //月份
+            if (serialTpl.contains("month")) {
+                int month = new Date().getMonth() + 1;
+                map.put("month", month + "");
+            }
+            //序列号
+            if (serialTpl.contains("serialNum")) {
+                map.put("serialNum", sb.toString());
+            }
+            //日期
+            if (serialTpl.contains("day")) {
+                map.put("day", new Date().getDate() + "");
+            }
+            String serNum = renderString(serialTpl, map);
+            return serNum;
+        }
+        return "";
+    }
+
+    @Transactional(readOnly = false,propagation = Propagation.REQUIRES_NEW)
+    public String genSerialNumNoSort(String companyId, String bizCode) throws Exception {
+        //获取当前登录人信息
+        UserDTO dto = UserUtils.getCurrentUserDTO();
+        Office office = officeMapper.selectById(companyId);
+        if (StringUtils.isBlank(bizCode)){
+            throw new Exception("生成编号失败,业务类型不能为空");
+        }
+        if (office != null) {
+            SysSerialnumTpl numTpl = this.querySerialTpl(office, bizCode);
+            if (numTpl == null) {
+                //查询编号模板   {brspnm}DZ-{year}-{serialNum}
+                SysSerialnumTpl serialNumTpl = serialnumTplMapper.queryByComAndBizCode(companyId, bizCode);
+                serialNumTpl.setCompanyId(companyId);
+                serialNumTpl.setSerialNum(0);
+                serialNumTpl.setCreateById(dto.getId());
+                serialNumTpl.setId(UUID.randomUUID().toString().replace("-", ""));
+                serialnumTplMapper.insert(serialNumTpl);
+                numTpl = serialNumTpl;
+            }
+            if (numTpl == null) {
+                throw new Exception("生成编号失败,请先设置相关业务编号模板");
+            }
+            String year = DateUtils.formatDate(new Date(), "yyyy");
+            if (!year.equals(numTpl.getYearBuilt())) {
+                serialnumTplMapper.resetSerialNum(numTpl.getId(), numTpl.getYearBuilt(), year);
+            }
+            Map<String, String> map = new HashMap<>();
+            String serialTpl = numTpl.getSerialTpl();
+            int i = serialnumTplMapper.updateSerialNum(numTpl);
+            if (i != 1) {
+                throw new Exception("生成编号失败,请稍后重试");
+            }
+            String num = String.valueOf(numTpl.getSerialNum() + 1);
+            StringBuffer sb = new StringBuffer();
+            sb.append(num);
+            //查询公司简称
+            if (serialTpl.contains("spnm")) {
+                String companyShortname = UserUtils.getSysParam("company_shortname");
+                map.put("spnm", StringUtils.isBlank(companyShortname) ? "" : companyShortname);
+            }
+            //查询分公司简称
+            if (serialTpl.contains("brspnm")) {
+                String branchShortname = UserUtils.getSysParam("branch_shortname");
+                map.put("brspnm", StringUtils.isBlank(branchShortname) ? "" : branchShortname);
+            }
+            //年份
+            if (serialTpl.contains("year")) {
+                map.put("year", year);
+            }
+            //月份
+            if (serialTpl.contains("month")) {
+                int month = new Date().getMonth() + 1;
+                map.put("month", month + "");
+            }
+            //序列号
+            if (serialTpl.contains("serialNum")) {
+                map.put("serialNum", sb.toString());
+            }
+            //日期
+            if (serialTpl.contains("day")) {
+                map.put("day", new Date().getDate() + "");
+            }
+            String serNum = renderString(serialTpl, map);
+            return serNum;
+        }
+        return "";
+    }
+
+    @Transactional(readOnly = false,propagation = Propagation.REQUIRES_NEW)
+    public String genSerialReviewNum(String companyId, String bizCode) throws Exception {
+        //获取当前登录人信息
+        UserDTO dto = UserUtils.getCurrentUserDTO();
+        Office office = officeMapper.selectById(companyId);
+        if (StringUtils.isBlank(bizCode)){
+            throw new Exception("生成编号失败,业务类型不能为空");
+        }
+        if (office != null) {
+            SysSerialnumTpl numTpl = this.querySerialTpl(office, bizCode);
+            if (numTpl == null) {
+                //查询编号模板   {brspnm}DZ-{year}-{serialNum}
+                SysSerialnumTpl serialNumTpl = serialnumTplMapper.queryByComAndBizCode(companyId, bizCode);
+                serialNumTpl.setCompanyId(companyId);
+                serialNumTpl.setSerialNum(0);
+                serialNumTpl.setCreateById(dto.getId());
+                serialNumTpl.setId(UUID.randomUUID().toString().replace("-", ""));
+                serialnumTplMapper.insert(serialNumTpl);
+                numTpl = serialNumTpl;
+            }
+            if (numTpl == null) {
+                throw new Exception("生成编号失败,请先设置相关业务编号模板");
+            }
+            String year = DateUtils.formatDate(new Date(), "yyyy");
+            if (!year.equals(numTpl.getYearBuilt())) {
+                serialnumTplMapper.resetSerialNum(numTpl.getId(), numTpl.getYearBuilt(), year);
+            }
+            Map<String, String> map = new HashMap<>();
+            String serialTpl = numTpl.getSerialTpl();
+            int i = serialnumTplMapper.updateSerialNum(numTpl);
+            if (i != 1) {
+                throw new Exception("生成编号失败,请稍后重试");
+            }
+            String num = String.valueOf(numTpl.getSerialNum() + 1);
+            StringBuffer sb = new StringBuffer();
+//            for (int x = 0; x < (numTpl.getSerialNumLen() - num.length()); x++) {
+//                sb.append("0");
+//            }
+            sb.append(num);
+            //查询公司简称
+            if (serialTpl.contains("spnm")) {
+                String companyShortname = UserUtils.getSysParam("company_shortname");
+                map.put("spnm", StringUtils.isBlank(companyShortname) ? "" : companyShortname);
+            }
+            //查询分公司简称
+            if (serialTpl.contains("brspnm")) {
+                String branchShortname = UserUtils.getSysParam("branch_shortname");
+                map.put("brspnm", StringUtils.isBlank(branchShortname) ? "" : branchShortname);
+            }
+            //年份
+            if (serialTpl.contains("year")) {
+                map.put("year", year);
+            }
+            //月份
+            if (serialTpl.contains("month")) {
+                int month = new Date().getMonth() + 1;
+                map.put("month", month + "");
+            }
+            //序列号
+            if (serialTpl.contains("serialNum")) {
+                map.put("serialNum", sb.toString());
+            }
+            //日期
+            if (serialTpl.contains("day")) {
+                map.put("day", new Date().getDate() + "");
+            }
+            String serNum = renderString(serialTpl, map);
+            return serNum;
+        }
+        return "";
+    }
+
+    private SysSerialnumTpl querySerialTpl(Office company, String bizCode) {
+        SysSerialnumTpl numTpl = serialnumTplMapper.queryByComAndBizCode(company.getId(), bizCode);
+        if (numTpl==null && company.getParentId()!=null && !"0".equals(company.getParentId())){
+            Office office = officeMapper.selectById(company.getParentId());
+            numTpl = this.querySerialTpl(office,bizCode);
+        }
+        return numTpl;
+    }
+
+    /**
+     * 根据键值对填充字符串,如("hello {name}",{name:"xiaoming"})
+     * 输出:
+     * @param content
+     * @param map
+     * @return
+     */
+    public static String renderString(String content, Map<String, String> map){
+        Set<Map.Entry<String, String>> sets = map.entrySet();
+        for(Map.Entry<String, String> entry : sets) {
+            String regex = "\\{" + entry.getKey() + "\\}";
+            Pattern pattern = Pattern.compile(regex);
+            Matcher matcher = pattern.matcher(content);
+            content = matcher.replaceAll(entry.getValue());
+        }
+        return content;
+    }
+}

+ 23 - 0
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/domain/SysParameterValue.java

@@ -0,0 +1,23 @@
+package com.jeeplus.sys.domain;
+
+import com.jeeplus.core.domain.BaseEntity;
+import lombok.Data;
+
+@Data
+public class SysParameterValue extends BaseEntity {
+
+    private String remarks;
+
+    private String officeId;
+
+    private String companyId;
+
+    private String branchOffice;
+
+    private String parameterId;
+
+    private String falt;
+
+    private String value;
+
+}

+ 3 - 0
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/mapper/OfficeMapper.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.jeeplus.core.domain.TreeMapper;
 import com.jeeplus.sys.domain.Office;
+import com.jeeplus.sys.domain.SysParameterValue;
 import com.jeeplus.sys.service.dto.OfficeDTO;
 import org.apache.ibatis.annotations.Param;
 
@@ -26,4 +27,6 @@ public interface OfficeMapper extends TreeMapper <Office> {
      * @return
      */
     public List <OfficeDTO> findList(@Param(Constants.WRAPPER) QueryWrapper queryWrapper);
+
+    SysParameterValue findValueByParameter(@Param("parameter")String parameter, @Param("branchOffice")String branchOffice);
 }

+ 10 - 0
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/mapper/xml/OfficeMapper.xml

@@ -33,4 +33,14 @@
             ${ew.customSqlSegment}
     </select>
 
+    <select id="findValueByParameter" resultType="com.jeeplus.sys.domain.SysParameterValue" >
+		SELECT
+		a.*
+		FROM sys_parameter_value a
+		WHERE a.parameter_id=(select s.id from sys_parameter s where s.parameter=#{parameter})
+		 and a.branch_office = #{branchOffice}
+		 and falt='0'
+		 and del_flag = '0'
+	</select>
+
 </mapper>

+ 37 - 4
jeeplus-modules/jeeplus-system/src/main/java/com/jeeplus/sys/utils/UserUtils.java

@@ -10,13 +10,12 @@ import com.google.common.collect.Lists;
 import com.jeeplus.common.SecurityUtils;
 import com.jeeplus.common.constant.CacheNames;
 import com.jeeplus.common.redis.RedisUtils;
+import com.jeeplus.sys.domain.SysParameterValue;
+import com.jeeplus.sys.mapper.OfficeMapper;
 import com.jeeplus.sys.service.DataRuleService;
 import com.jeeplus.sys.service.MenuService;
 import com.jeeplus.sys.service.UserService;
-import com.jeeplus.sys.service.dto.DataRuleDTO;
-import com.jeeplus.sys.service.dto.MenuDTO;
-import com.jeeplus.sys.service.dto.RoleDTO;
-import com.jeeplus.sys.service.dto.UserDTO;
+import com.jeeplus.sys.service.dto.*;
 import com.jeeplus.sys.service.mapstruct.MenuWrapper;
 
 import java.util.HashSet;
@@ -31,6 +30,7 @@ import java.util.Set;
  */
 public class UserUtils {
 
+    private static OfficeMapper officeMapper = SpringUtil.getBean(OfficeMapper.class);
 
     /**
      * 根据ID获取用户
@@ -201,5 +201,38 @@ public class UserUtils {
         return false;
     }
 
+    /**
+     * 获取系统参数
+     * parameter 参数类型
+     * branchOffice 分公司Id 分公司id为空传公司id
+     * @return
+     */
+    public static String getSysParam(String parameter) {
+        //查询当前登录人公司信息
+        UserDTO userDTO = UserUtils.getCurrentUserDTO();
+        OfficeDTO companyDTO = userDTO.getCompanyDTO();
+        //当前登录人所属公司是子公司
+        if (!"0".equals(companyDTO.getParentId()) && "1".equals(companyDTO.getType())) {
+            //查询子公司简称
+            if ("branch_shortname".equals(parameter)) {
+                SysParameterValue sysParameterValue = officeMapper.findValueByParameter(parameter, companyDTO.getId());
+                return sysParameterValue == null ? "" : sysParameterValue.getValue();
+            }
+            //查询公司简称
+            if ("company_shortname".equals(parameter)) {
+                SysParameterValue sysParameterValue = officeMapper.findValueByParameter(parameter, companyDTO.getParentId());
+                return sysParameterValue == null ? "" : sysParameterValue.getValue();
+            }
+        } else {
+            //当前登录人所属公司是总公司
+            //查询公司简称
+            if ("company_shortname".equals(parameter)) {
+                SysParameterValue sysParameterValue = officeMapper.findValueByParameter(parameter, companyDTO.getId());
+                return sysParameterValue == null ? "" : sysParameterValue.getValue();
+            }
+        }
+        return "";
+    }
+
 
 }