| | |
| | | /** |
| | | * 缓存 药剂ID |
| | | */ |
| | | public static final String CACHE_DRUG_ID = "LOSS_DRUG_ID"; |
| | | public static final String CACHE_DRUG_ID = "DRUG_ID"; |
| | | |
| | | /** |
| | | * 分页查询药剂信息 |
| | |
| | | data.setUpdateUser(ContextUtil.getLoginUserCName()); |
| | | try { |
| | | if (null == data.getId()) { |
| | | String id = createId(data.getCompanyId(), data.getDeptId()); |
| | | String id = createId(data.getCompanyId()); |
| | | data.setId(id); |
| | | session.save(data); |
| | | } else { |
| | |
| | | |
| | | } |
| | | |
| | | public String createId(String companyId, String deptId) { |
| | | public String createId(String companyId) { |
| | | |
| | | // 从缓存中获取已有的组织编码 |
| | | String cacheKey = RedisConst.buildKey(companyId, HDrugService.CACHE_DRUG_ID); |
| | | |
| | | String cacheId = (String) redisUtil.get(cacheKey); |
| | | |
| | | if (null != cacheId && cacheId.indexOf(deptId) >= 0) { |
| | | if (null != cacheId) { |
| | | String temp = cacheId.substring(cacheId.length() - 3); |
| | | Integer i = Integer.valueOf(temp); |
| | | cacheId = deptId + String.format("%03d", ++i); |
| | | cacheId = String.format("%03d", ++i); |
| | | } else { |
| | | List<Drug> result = listDrug(companyId, null); |
| | | if (null == result || result.size() == 0) { |
| | | cacheId = deptId + "001"; |
| | | cacheId = "001"; |
| | | } else { |
| | | Drug drug = result.get(0); |
| | | String temp = drug.getId().substring(drug.getId().length() - 3); |
| | | Integer i = Integer.valueOf(temp); |
| | | cacheId = deptId + String.format("%03d", ++i); |
| | | cacheId = String.format("%03d", ++i); |
| | | } |
| | | } |
| | | // 更新缓存 |