YYC
2023-10-20 d927426741a4fa32a7f250f645d916d778161e37
igds-recir/src/main/java/com/ld/igds/drug/service/HDrugLogApplyService.java
@@ -1,5 +1,6 @@
package com.ld.igds.drug.service;
import com.bstek.bdf2.core.model.RoleMember;
import com.bstek.bdf2.core.orm.hibernate.HibernateDao;
import com.bstek.dorado.data.provider.Page;
import com.ld.igds.constant.RedisConst;
@@ -8,6 +9,7 @@
import com.ld.igds.util.RedisUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -95,7 +97,7 @@
            session.saveOrUpdate(way);
            DrugLogDtl dtl = new DrugLogDtl();
            BeanUtils.copyProperties(data, dtl);
            way.setDrugLogId(data.getXzbm());
            dtl.setDrugLogId(data.getXzbm());
            session.saveOrUpdate(dtl);
        } catch (Exception e) {
            e.printStackTrace();
@@ -104,41 +106,6 @@
            session.close();
        }
        return null;
    }
    private void saveWay(DrugLogApply data) {
        Session session = this.getSessionFactory().openSession();
        try {
            DrugLogWay way = new DrugLogWay();
            BeanUtils.copyProperties(data, way);
            way.setWayId(ContextUtil.getUUID());
            session.saveOrUpdate(way);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            session.flush();
            session.close();
        }
    }
    /**
     * 根据主表信息添加粮情字表
     *
     * @param data
     */
    private void saveDtl(DrugLogApply data) {
        Session session = this.getSessionFactory().openSession();
        try {
            DrugLogDtl dtl = new DrugLogDtl();
            BeanUtils.copyProperties(data, dtl);
            session.saveOrUpdate(dtl);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            session.flush();
            session.close();
        }
    }
    /**
@@ -152,9 +119,20 @@
        try {
            if (null != data.getXzbm()) {
                session.delete(data);
                for (DrugLogPeople drugLogPeople : data.getDrugLogPeople()) {
                    session.delete(drugLogPeople);
                }
                String hqlPeople = "delete from " + DrugLogPeople.class.getName() + " where DRUG_LOG_ID_=:drugLogId";
                Query queryPeople = session.createQuery(hqlPeople);
                queryPeople.setString("drugLogId", data.getXzbm());
                queryPeople.executeUpdate();
                String hqlDtl = "delete from " + DrugLogDtl.class.getName() + " where DRUG_LOG_ID_=:drugLogId";
                Query queryDtl = session.createQuery(hqlDtl);
                queryDtl.setString("drugLogId", data.getXzbm());
                queryDtl.executeUpdate();
                String hqlWay = "delete from " + DrugLogWay.class.getName() + " where DRUG_LOG_ID_=:drugLogId";
                Query queryWay = session.createQuery(hqlWay);
                queryWay.setString("drugLogId", data.getXzbm());
                queryWay.executeUpdate();
            }
        } catch (Exception e) {
            e.printStackTrace();
@@ -257,13 +235,9 @@
        Map<String, Object> args = new HashMap<>();
        if (null != param) {
            String xzbm = (String) param.get("xzbm");
            String deptId = (String) param.get("deptId");
            String tbrq = DateFormatUtils.format((Date) param.get("tbrq"), "yyyyMMdd");
            String id = xzbm + deptId + tbrq;
            hql.append(" from " + DrugLogPeople.class.getName() + " where id=:id");
            args.put("id", id);
            hql.append(" from " + DrugLogPeople.class.getName() + " where DRUG_LOG_ID_=:id");
            args.put("id", xzbm);
            buildHql(hql, param, args);
        }
        return this.query(String.valueOf(hql), args);
@@ -434,7 +408,8 @@
                cacheId = timeKey + "0001";
            } else {
                String temp = drugLogApplies.get(0).getXzbm();
                Integer i = Integer.valueOf(temp);
                String tempNum = temp.substring(temp.length() - 4);
                Integer i = Integer.valueOf(tempNum);
                cacheId = timeKey + String.format("%04d", ++i);
            }
        }