|  |  |  | 
|---|
|  |  |  | data.setUpdateTime(new Date()); | 
|---|
|  |  |  | data.setUpdateUser(ContextUtil.getLoginUserCName()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | if (null == data.getId()) { | 
|---|
|  |  |  | IUser user = ContextUtil.getLoginUser(); | 
|---|
|  |  |  | 
|---|
|  |  |  | if (data.getSubmitTime().before(curDate)) { | 
|---|
|  |  |  | data.setSubmitTime(curDate); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String id = createId(data.getSubmitTime(), data.getCompanyId(), data.getHwdm()); | 
|---|
|  |  |  | String id = createId(data.getSubmitTime(), data.getCompanyId(), data.getType()); | 
|---|
|  |  |  | //                String id = addInoutDataByLossOver(data); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | data.setId(id); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | session.save(data); | 
|---|
|  |  |  | 
|---|
|  |  |  | return this.query(hql, args); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public String createId(Date date, String companyId, String freightId) { | 
|---|
|  |  |  | public String createId(Date date, String companyId, String type) { | 
|---|
|  |  |  | // 时间戳标签 | 
|---|
|  |  |  | String timeKey = DateFormatUtils.format(date, "yyyyMMdd"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String cacheId = (String) redisUtil.get(cacheKey); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null != cacheId && cacheId.indexOf(freightId + timeKey) >= 0) { | 
|---|
|  |  |  | if (null != cacheId && cacheId.indexOf(timeKey) >= 0) { | 
|---|
|  |  |  | String temp = cacheId.substring(cacheId.length() - 3); | 
|---|
|  |  |  | Integer i = Integer.valueOf(temp); | 
|---|
|  |  |  | cacheId = freightId + timeKey + String.format("%03d", ++i); | 
|---|
|  |  |  | cacheId = timeKey + String.format("%03d", ++i); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | Map<String, Object> args = new HashMap<>(); | 
|---|
|  |  |  | args.put("timeKey", freightId + timeKey + "%"); | 
|---|
|  |  |  | args.put("timeKey", timeKey + "%"); | 
|---|
|  |  |  | List<InoutLossOver> result = getMaxId(args); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null == result || result.size() == 0) { | 
|---|
|  |  |  | cacheId = freightId + timeKey + "001"; | 
|---|
|  |  |  | cacheId = timeKey + "001"; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | int max = 0; | 
|---|
|  |  |  | int num; | 
|---|
|  |  |  | 
|---|
|  |  |  | num = Integer.parseInt(inoutLossOver.getId().substring(inoutLossOver.getId().length() - 3)); | 
|---|
|  |  |  | max = Math.max(max, num); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | cacheId = freightId + timeKey + String.format("%03d", ++max); | 
|---|
|  |  |  | cacheId = timeKey + String.format("%03d", ++max); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 更新缓存 | 
|---|