| | |
| | | import org.apache.commons.lang3.time.DateFormatUtils; |
| | | import org.hibernate.Session; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | |
| | | } |
| | | |
| | | private List<DrugLog> getDrugLogByTime(String companyId){ |
| | | private List<DrugLog> getDrugLogByTime(String companyId) { |
| | | String hql = " from " + DrugLog.class.getName() |
| | | + " where companyId =:companyId "; |
| | | |
| | | Map<String,Object> args = new HashMap<String,Object>(); |
| | | Map<String, Object> args = new HashMap<String, Object>(); |
| | | args.put("companyId", companyId); |
| | | |
| | | hql += " and updateTime >:startTime"; |
| | |
| | | return this.query(hql, args); |
| | | } |
| | | |
| | | public String getIndex(String companyId){ |
| | | public String getIndex(String companyId) { |
| | | List<DrugLog> list = getDrugLogByTime(companyId); |
| | | String index = "001"; |
| | | if(list != null && list.size() > 0){ |
| | | if (list != null && list.size() > 0) { |
| | | String id = list.get(0).getId().substring(8); |
| | | int temp = Integer.valueOf(id) + 1; |
| | | index = temp + ""; |
| | | } |
| | | if(index.length() == 1){ |
| | | if (index.length() == 1) { |
| | | index = "00" + index; |
| | | } |
| | | if(index.length() == 2){ |
| | | if (index.length() == 2) { |
| | | index = "0" + index; |
| | | } |
| | | return index; |
| | |
| | | data.setUpdateUser(ContextUtil.getLoginUserCName()); |
| | | try { |
| | | if (null == data.getId()) { |
| | | data.setId(DateFormatUtils.format(new Date(), "yyyyMMdd") + getIndex(data.getCompanyId())); |
| | | data.setId(data.getDepotId() + DateFormatUtils.format(new Date(), "yyyyMMdd") + getIndex(data.getCompanyId())); |
| | | session.save(data); |
| | | } else { |
| | | session.update(data); |
| | |
| | | session.close(); |
| | | } |
| | | } |
| | | |
| | | public String delData(DrugLog data) { |
| | | Session session = this.getSessionFactory().openSession(); |
| | | try { |