| | |
| | | import com.ruoyi.common.config.FrameworkConfig; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.ShiroUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import org.apache.commons.lang3.RandomUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.commons.lang3.time.DateFormatUtils; |
| | | |
| | | import java.time.LocalDateTime; |
| | |
| | | |
| | | //全局用户实时坐在部门 |
| | | public static Map<String, String> contextUserDept = new HashMap<>(); |
| | | |
| | | /** |
| | | * 全局用于存放SN与组织编码的关系,例如分机SN和组织编码关系 |
| | | */ |
| | | public static Map<String, String> contextSnCompanyIdMap = new HashMap<>(); |
| | | |
| | | /** |
| | | * 生成顺序ID:年月日时分秒毫秒(17位) + 序列号(4位) = 21位 |
| | |
| | | if (null == deptId) return; |
| | | contextUserDept.put(userId, deptId); |
| | | } |
| | | |
| | | /** |
| | | * 获取顺序号 |
| | | * @param oldOrderId 原有顺序号 |
| | | * @param num 位数 |
| | | * @return |
| | | */ |
| | | public static String getOrderId(String oldOrderId, Integer num) { |
| | | Integer index3 = 1001; |
| | | Integer index4 = 10001; |
| | | Integer index5 = 100001; |
| | | Integer index = 0; |
| | | String orderId = "001"; |
| | | if(StringUtils.isNotEmpty(oldOrderId)){ |
| | | index = Integer.valueOf(oldOrderId); |
| | | } |
| | | if(3 == num){ |
| | | orderId = ((index3 + index) + "").substring(1); |
| | | } |
| | | if(4 == num){ |
| | | orderId = ((index4 + index) + "").substring(1); |
| | | } |
| | | if(5 == num){ |
| | | orderId = ((index5 + index) + "").substring(1); |
| | | } |
| | | return orderId; |
| | | } |
| | | |
| | | /** |
| | | * 存放SN与所属组织的关系 |
| | | * |
| | | * @param sn |
| | | * @param companyId |
| | | */ |
| | | public static void addSerCompany(String sn, String companyId) { |
| | | contextSnCompanyIdMap.put(sn, companyId); |
| | | } |
| | | |
| | | /** |
| | | * 通过SN获取当前SN所属的组织 |
| | | * |
| | | * @param sn |
| | | * @return |
| | | */ |
| | | public static String getCompanyIdBySn(String sn) { |
| | | return contextSnCompanyIdMap.get(sn); |
| | | } |
| | | } |