Parcourir la source

Merge branch 'master' of chenyj/cyj into master

esb il y a 9 ans
Parent
commit
e58fcc05e8

+ 1 - 1
Hos-resource/src/main/java/com/yihu/ehr/standard/service/standard/StdDictEntryService.java

@ -183,7 +183,7 @@ public class StdDictEntryService extends SQLGeneralDAO {
        query.executeUpdate();
    }
    private void add(StandardVersion standardVersion, StdDictionaryEntryModel stdDictionaryEntryModel) throws IOException {
    public void add(StandardVersion standardVersion, StdDictionaryEntryModel stdDictionaryEntryModel) throws IOException {
        Session session = getCurrentSession();
        String dictEntryTableName = standardVersion.getDictEntryTableName();

+ 49 - 2
Hos-resource/src/main/java/com/yihu/ehr/standard/service/standard/StdDictService.java

@ -17,12 +17,12 @@ import com.yihu.ehr.framework.util.sql.BeanTransformer;
import com.yihu.ehr.framework.util.sql.RequestParamTransformer;
import com.yihu.ehr.framework.util.sql.SqlCreator;
import com.yihu.ehr.standard.model.Select2;
import com.yihu.ehr.standard.model.adapter.AdapterDictModel;
import com.yihu.ehr.standard.model.standard.StdDataSetModel;
import com.yihu.ehr.standard.model.standard.StdDictionaryEntryModel;
import com.yihu.ehr.standard.model.standard.StdDictionaryModel;
import com.yihu.ehr.standard.service.bo.StandardVersion;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -39,6 +39,8 @@ import java.util.*;
public class StdDictService extends SQLGeneralDAO {
    public static final String BEAN_ID = "StdDictService";
    @Autowired
    StdDictEntryService stdDictEntryService;
    public StdDictService() {
    }
@ -70,6 +72,31 @@ public class StdDictService extends SQLGeneralDAO {
            existFlg = dictCodeValidate(standardVersion, stdDictionaryModel.getCode());
            if (!existFlg) {
                this.add(standardVersion, stdDictionaryModel);
                //取得新增字典表记录
                Map<String, Object> query = new HashMap<>();
                Map<String, String> order = new HashMap<>();
                query.put("code", stdDictionaryModel.getCode());
                List<StdDictionaryModel> list = this.getList(standardVersion, query, order, 1, 0);
                Integer id = list.get(0).getId();
                Integer parentId = list.get(0).getParentId();
                if (parentId != null) {
                    Map<String, Object> query1 = new HashMap<>();
                    Map<String, String> order1 = new HashMap<>();
                    query1.put("dictId", parentId);
                    List<StdDictionaryEntryModel> dicEntryList = this.getDicEntryList(standardVersion,query1,order,null,null);
                    for (StdDictionaryEntryModel entryModel : dicEntryList) {
                        StdDictionaryEntryModel model =  new StdDictionaryEntryModel();
                        model.setDictId(id);
                        model.setstandardId(entryModel.getstandardId());
                        model.setCode(entryModel.getCode());
                        model.setValue(entryModel.getValue());
                        model.setDescription(entryModel.getDescription());
                        stdDictEntryService.add(standardVersion,model);
                    }
                }
                stdDictionaryModel.setSuccessFlg(true);
                stdDictionaryModel.setMessage("保存标准字典成功");
                return stdDictionaryModel;
@ -236,6 +263,26 @@ public class StdDictService extends SQLGeneralDAO {
        return (List<StdDictionaryModel>) sessionQuery.list();
    }
    private List<StdDictionaryEntryModel> getDicEntryList(StandardVersion standardVersion, Map<String, Object> query, Map<String, String> order, Integer limit, Integer offset) {
        SqlCreator sqlCreator = new SqlCreator(StdDictionaryEntryModel.class);
        for (String key : query.keySet()) {
            sqlCreator.equalCondition(key, query.get(key));
        }
        for (String key : order.keySet()) {
            sqlCreator.order(key, order.get(key));
        }
        String sql = sqlCreator.selectData(standardVersion.getDictEntryTableName());
        Query sessionQuery = getQuery(sqlCreator, sql);
        if (limit != null) {
            sessionQuery.setMaxResults(limit);
            if (offset != null) {
                sessionQuery.setFirstResult((offset - 1) * limit);
            }
        }
        return (List<StdDictionaryEntryModel>) sessionQuery.list();
    }
    public DictionaryResult getDictionaryList(String stdVersion, String query, String order, Integer rows, Integer page) {
        try {
            List<StdDictionaryModel> stdDictionaryModelList = getList(stdVersion, query, order, rows, page);