YYC
2023-07-26 306e2714266cef35638514f05cf4f643857608d9
igds-recir/src/main/java/com/ld/igds/drug/service/HDrugLogService.java
@@ -9,6 +9,7 @@
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;
@@ -42,11 +43,11 @@
    }
    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";
@@ -62,18 +63,18 @@
        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;
@@ -91,7 +92,7 @@
        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);
@@ -103,6 +104,7 @@
            session.close();
        }
    }
    public String delData(DrugLog data) {
        Session session = this.getSessionFactory().openSession();
        try {