浏览代码

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

# Conflicts:
#	common/common-entity/sql记录
yeshijie 3 年之前
父节点
当前提交
3170b37d95
共有 60 个文件被更改,包括 5328 次插入322 次删除
  1. 24 0
      business/base-service/src/main/java/com/yihu/jw/dict/dao/BaseDictIcd10Dao.java
  2. 14 0
      business/base-service/src/main/java/com/yihu/jw/dict/dao/BaseDrugDictDao.java
  3. 24 0
      business/base-service/src/main/java/com/yihu/jw/dict/dao/BaseDrugUseDictDao.java
  4. 22 0
      business/base-service/src/main/java/com/yihu/jw/dict/dao/BaseFrequencyDictDao.java
  5. 6 0
      business/base-service/src/main/java/com/yihu/jw/dict/dao/BaseTemplateDictDao.java
  6. 13 0
      business/base-service/src/main/java/com/yihu/jw/dict/dao/BaseTemplateOrgDao.java
  7. 0 109
      business/base-service/src/main/java/com/yihu/jw/dict/service/BaseDrugDictService.java
  8. 0 113
      business/base-service/src/main/java/com/yihu/jw/dict/service/TemplateManageService.java
  9. 10 1
      business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java
  10. 52 0
      common/common-entity/sql记录
  11. 57 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/BaseDrugDictDO.java
  12. 111 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/BaseDrugUseDictDO.java
  13. 93 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/BaseFrequencyDictDO.java
  14. 19 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/BaseTemplateOrgDO.java
  15. 65 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictIcd10DO.java
  16. 255 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/birthday/BirthDayWishesToPatient.java
  17. 112 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/birthday/BirthdayWishesTemplate.java
  18. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/lifeCare/LifeCareItemDictDO.java
  19. 11 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/message/SystemMessageDO.java
  20. 123 0
      common/common-util/src/main/java/com/yihu/jw/util/healthIndex/HealthIndexUtil.java
  21. 8 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/dict/DictIcd10Dao.java
  22. 86 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/dict/BaseDrugUseEndpoint.java
  23. 84 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/dict/BaseFrequencyEndpoint.java
  24. 27 25
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/dict/DictDrugEndpoint.java
  25. 43 32
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/dict/DictIcd10Endpoint.java
  26. 430 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/dict/TemplateManageEndpoint.java
  27. 183 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/BaseDrugDictService.java
  28. 145 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/BaseDrugUseService.java
  29. 137 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/BaseFrequencyService.java
  30. 122 3
      svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/DictIcd10Service.java
  31. 682 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/TemplateManageService.java
  32. 304 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/importManage/BasDrugExcelDO.java
  33. 142 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/importManage/BasDrugUseExcelDO.java
  34. 119 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/importManage/BasFrequencyExcelDO.java
  35. 127 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/importManage/BasIcd10ExcelDO.java
  36. 136 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/importManage/BaseDrugExcelDOReader.java
  37. 101 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/importManage/BaseDrugUseExcelDOReader.java
  38. 96 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/importManage/BaseFrequencyExcelDOReader.java
  39. 98 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/importManage/BaseIcd10ExcelDOReader.java
  40. 1 1
      svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java
  41. 12 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/birthday/BirthDayWishesToPatientDao.java
  42. 29 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/birthday/BirthdayWishesTemplateDao.java
  43. 281 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorBirthdayWishesEndpoint.java
  44. 25 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/family/FamilyMemberEndpoint.java
  45. 17 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/message/PatientMessageEndpoint.java
  46. 12 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientContactsEndpoint.java
  47. 5 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java
  48. 500 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/birthday/BirthdayWishesService.java
  49. 20 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/contacts/ContactsService.java
  50. 24 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/DeviceService.java
  51. 4 11
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java
  52. 76 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/family/PatientFamilyMemberService.java
  53. 6 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/label/PatientLableService.java
  54. 25 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/PatientMessageService.java
  55. 23 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java
  56. 8 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MessageUtil.java
  57. 1 1
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/DeviceController.java
  58. 97 7
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java
  59. 72 1
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceUploadService.java
  60. 0 2
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/SyncWlyyHospitalService.java

+ 24 - 0
business/base-service/src/main/java/com/yihu/jw/dict/dao/BaseDictIcd10Dao.java

@ -0,0 +1,24 @@
package com.yihu.jw.dict.dao;
import com.yihu.jw.entity.base.dict.BaseDrugDictDO;
import com.yihu.jw.entity.base.dict.BaseFrequencyDictDO;
import com.yihu.jw.entity.base.dict.DictIcd10DO;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface BaseDictIcd10Dao extends PagingAndSortingRepository<DictIcd10DO, Integer>, JpaSpecificationExecutor<DictIcd10DO> {
    List<DictIcd10DO>  findByCodeAndName(String code, String name);
    @Query("from DictIcd10DO t where t.is_del='1' and t.status ='1' order by t.createTime desc")
    List<DictIcd10DO> findByDel(Pageable pageRequest);
    @Query("select  count(1) from DictIcd10DO t where t.is_del='1' and t.status='1'")
    Integer getconuntByDel();
    @Query("from DictIcd10DO t where t.is_del='1' and t.status ='1' and t.name like %?1% order by t.createTime desc")
    List<DictIcd10DO> findByNameDel(String name,Pageable pageRequest);
}

+ 14 - 0
business/base-service/src/main/java/com/yihu/jw/dict/dao/BaseDrugDictDao.java

@ -1,10 +1,24 @@
package com.yihu.jw.dict.dao;
import com.yihu.jw.entity.base.dict.BaseDrugDictDO;
import com.yihu.jw.entity.base.dict.BaseFrequencyDictDO;
import com.yihu.jw.entity.base.dict.DictJobTitleDO;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface BaseDrugDictDao  extends PagingAndSortingRepository<BaseDrugDictDO, String>, JpaSpecificationExecutor<BaseDrugDictDO> {
    @Query("from BaseDrugDictDO t where t.charge_code=?1 and t.drugname=?2 and t.dosage=?3")
    List<BaseDrugDictDO>  findByCodeAndNameAndDosage(String code,String name,String dosage);
    @Query("from BaseDrugDictDO t where t.is_del='1' and t.status='1' order by  t.create_time desc")
    List<BaseDrugDictDO> findByDel(Pageable pageRequest);
    @Query("select  count(1) from BaseDrugDictDO t where t.is_del='1' and t.status='1'")
    Integer getconuntByDel();
    @Query("from BaseDrugDictDO t where t.is_del='1' and t.status='1' and t.drugname like %?1% order by  t.create_time desc")
    List<BaseDrugDictDO> findByNameDel(String name,Pageable pageRequest);
}

+ 24 - 0
business/base-service/src/main/java/com/yihu/jw/dict/dao/BaseDrugUseDictDao.java

@ -0,0 +1,24 @@
package com.yihu.jw.dict.dao;
import com.yihu.jw.entity.base.dict.BaseDrugDictDO;
import com.yihu.jw.entity.base.dict.BaseDrugUseDictDO;
import com.yihu.jw.entity.base.dict.DictIcd10DO;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface BaseDrugUseDictDao extends PagingAndSortingRepository<BaseDrugUseDictDO, String>, JpaSpecificationExecutor<BaseDrugUseDictDO> {
    @Query("from BaseDrugUseDictDO t where t.supply_code=?1 and t.supply_name=?2")
    List<BaseDrugUseDictDO>  findByCodeAndName(String code, String name);
    @Query("from BaseDrugUseDictDO t where t.del_flag='1' and t.status ='1' order by t.createTime desc")
    List<BaseDrugUseDictDO> findByDel(Pageable pageRequest);
    @Query("select  count(1) from BaseDrugUseDictDO t where t.del_flag='1' and t.status='1'")
    Integer getconuntByDel();
    @Query("from BaseDrugUseDictDO t where t.del_flag='1' and t.status ='1' and t.supply_name like %?1% order by t.createTime desc")
    List<BaseDrugUseDictDO> findByNameDel(String name,Pageable pageRequest);
}

+ 22 - 0
business/base-service/src/main/java/com/yihu/jw/dict/dao/BaseFrequencyDictDao.java

@ -0,0 +1,22 @@
package com.yihu.jw.dict.dao;
import com.yihu.jw.entity.base.dict.BaseDrugUseDictDO;
import com.yihu.jw.entity.base.dict.BaseFrequencyDictDO;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface BaseFrequencyDictDao extends PagingAndSortingRepository<BaseFrequencyDictDO, String>, JpaSpecificationExecutor<BaseFrequencyDictDO> {
    @Query("from BaseFrequencyDictDO t where  t.freq_code=?1 and t.freq_name=?2")
    List<BaseFrequencyDictDO>  findByCodeAndIdName(String code, String name);
    @Query("from BaseFrequencyDictDO t where t.is_del='1' and t.status ='1' order by t.createTime desc")
    List<BaseFrequencyDictDO> findByDel(Pageable pageRequest);
    @Query("select  count(1) from BaseFrequencyDictDO t where t.is_del='1' and t.status='1'")
    Integer getconuntByDel();
    @Query("from BaseFrequencyDictDO t where t.is_del='1' and t.status ='1' and t.freq_name like %?1% order by t.createTime desc")
    List<BaseFrequencyDictDO> findByNameDel(String name ,Pageable pageRequest);
}

+ 6 - 0
business/base-service/src/main/java/com/yihu/jw/dict/dao/BaseTemplateDictDao.java

@ -6,9 +6,15 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface BaseTemplateDictDao extends PagingAndSortingRepository<BaseTemplateDictDO, String>, JpaSpecificationExecutor<BaseTemplateDictDO> {
    @Query("select  count(1) from BaseTemplateDictDO t where t.isDel = '1' and t.templateId=?1")
    Integer getCountByTemplateId(String templateId);
    @Query("from BaseTemplateDictDO t where t.dictId=?1 and t.templateId=?2")
    BaseTemplateDictDO findByDictIdAndTemplateId(String dictId,String templateId);
    @Query("from BaseTemplateDictDO t where t.templateId=?1 and t.isDel='1'")
    List<BaseTemplateDictDO> findByTemplateId(String templateId);
}

+ 13 - 0
business/base-service/src/main/java/com/yihu/jw/dict/dao/BaseTemplateOrgDao.java

@ -3,7 +3,20 @@ package com.yihu.jw.dict.dao;
import com.yihu.jw.entity.base.dict.BaseDrugDictDO;
import com.yihu.jw.entity.base.dict.BaseTemplateOrgDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface BaseTemplateOrgDao extends PagingAndSortingRepository<BaseTemplateOrgDO, String>, JpaSpecificationExecutor<BaseTemplateOrgDO> {
    @Query("from BaseTemplateOrgDO t where  t.orgCode =?1 and t.templateType=?2 ")
    BaseTemplateOrgDO findByOrgCodeAndtemplateType(String orgCode,String templateType);
    @Query("from BaseTemplateOrgDO t where  t.orgCode =?1 and t.isDel='1' ")
    List<BaseTemplateOrgDO> findByOrgCode(String saasId);
    @Query("from BaseTemplateOrgDO t where  t.templateId =?1 and t.isDel='1' ")
    List<BaseTemplateOrgDO> findByTemplateId(String templateId);
}

+ 0 - 109
business/base-service/src/main/java/com/yihu/jw/dict/service/BaseDrugDictService.java

@ -1,109 +0,0 @@
package com.yihu.jw.dict.service;
import com.sun.jndi.toolkit.dir.SearchFilter;
import com.yihu.jw.dict.dao.BaseDrugDictDao;
import com.yihu.jw.entity.base.dict.BaseDrugDictDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.prescription.BaseNationalDrugDictDO;
import com.yihu.jw.hospital.prescription.dao.BaseNationalDrugDictDao;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.util.common.ConvertToSpellUtils;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.yihu.jw.util.common.BeanUtils.getNullPropertyNames;
@Service
public class BaseDrugDictService extends BaseJpaService<BaseDrugDictDO, BaseDrugDictDao> {
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private BaseDrugDictDao baseDrugDictDao;
    public BaseDrugDictDO saveNationalDrug(BaseDrugDictDO nationalDrugDictDO) {
        //判断新增或编辑
        if (nationalDrugDictDO.getId() == null) {
            nationalDrugDictDO.setCreate_time(new Date());
            nationalDrugDictDO.setUpdate_time(new Date());
            return baseDrugDictDao.save(nationalDrugDictDO);
        }else {
            BaseDrugDictDO oldDurgDictDO =  baseDrugDictDao.findOne(nationalDrugDictDO.getId());
            BeanUtils.copyProperties(nationalDrugDictDO, oldDurgDictDO, getNullPropertyNames(nationalDrugDictDO));
            oldDurgDictDO.setUpdate_time(new Date());
            return baseDrugDictDao.save(oldDurgDictDO);
        }
    }
    public MixEnvelop  findDrugDict(String name,String status,Integer page,Integer pageSize){
        String sql = "select t.id as \"id\"," +
                " t.charge_code as \"charge_code\"," +
                " t.drugname as \"drugname\"," +
                " t.specification as \"specification\"," +
                " t.py_code as \"py_code\"," +
                " t.supply_code as \"supply_code\"," +
                " t.supply_name as \"supply_name\"," +
                " t.retprice as \"retprice\"," +
                " t.manu_name as \"manu_name\"," +
                " t.weigh_unit as \"weigh_unit\"," +
                " t.mini_unit_name as \"mini_unit_name\"," +
                " t.pack_unit_name as \"pack_unit_name\"," +
                " t.weigh_unit_name as \"weigh_unit_name\"," +
                " t.vol_unit_name as \"vol_unit_name\"," +
                " t.win_no as \"win_no\"," +
                " t.pack_retprice as \"pack_retprice\"," +
                " t.mini_unit as \"mini_unit\"," +
                " t.pack_size as \"pack_size\"," +
                " t.action as \"action\"," +
                " t.serial as \"serial\"," +
                " t.group_no as \"group_no\"," +
                " t.stock_amount as \"stock_amount\"," +
                " t.visible_flag as \"visible_flag\"," +
                " t.drug_flag as \"drug_flag\"," +
                " t.create_time as \"create_time\"," +
                " t.update_time as \"update_time\"," +
                " t.status as \"status\"," +
                " t.is_del as \"is_del\"" +
                " from base_drug_dict t " +
                " where t.is_del='1' ";
        String sqlCount = "select count(1) as \"count\" from base_drug_dict t where t.is_del='1' ";
        if (StringUtils.isNoneBlank(name)){
            sql+=" and t.drugname like '%"+name+"%'";
            sqlCount+=" and t.drugname like '%"+name+"%'";
        }
        if (StringUtils.isNoneBlank(status)){
            sql+=" and t.status = '"+status+"'";
            sqlCount+=" and t.status = '"+status+"'";
        }
        List<Map<String,Object>> coutList=hibenateUtils.createSQLQuery(sqlCount);
        Integer count=0 ;
        if (coutList!=null&&coutList.size()>0){
            count=Integer.valueOf(coutList.get(0).get("count").toString());
        }
        List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql,page,pageSize);
        MixEnvelop mixEnvelop = new MixEnvelop();
        mixEnvelop.setDetailModelList(list);
        mixEnvelop.setCurrPage(page);
        mixEnvelop.setPageSize(pageSize);
        mixEnvelop.setTotalCount(count);
        return mixEnvelop;
    }
    public BaseDrugDictDO findOneDrug(String id){
        return baseDrugDictDao.findOne(id);
    }
}

+ 0 - 113
business/base-service/src/main/java/com/yihu/jw/dict/service/TemplateManageService.java

@ -1,113 +0,0 @@
package com.yihu.jw.dict.service;
import com.yihu.jw.dict.dao.BaseDrugDictDao;
import com.yihu.jw.dict.dao.BaseTemplateDao;
import com.yihu.jw.dict.dao.BaseTemplateDictDao;
import com.yihu.jw.dict.dao.BaseTemplateOrgDao;
import com.yihu.jw.entity.base.dict.BaseTemplateDO;
import com.yihu.jw.entity.base.dict.BaseTemplateDictDO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import jdk.nashorn.internal.ir.IfNode;
import jdk.nashorn.internal.runtime.ListAdapter;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Service
public class TemplateManageService {
    @Autowired
    private BaseDrugDictDao baseDrugDictDao;
    @Autowired
    private BaseTemplateDao baseTemplateDao;
    @Autowired
    private BaseTemplateDictDao baseTemplateDictDao;
    @Autowired
    private BaseTemplateOrgDao baseTemplateOrgDao;
    @Autowired
    private HibenateUtils hibenateUtils;
    public MixEnvelop findTempalte(String templateType,Integer page ,Integer pageSize){
        String sql =" select t.id as \"id\" ," +
                " t.name as \"name\"," +
                " t.code as \"code\"," +
                " t.children_count as \"childrenCount\"," +
                " t.update_user as \"updateUser\"," +
                " t.update_user_name as \"updateUserName\"," +
                " t.update_time as \"updateTime\"," +
                " t.template_type as \"templateType\"," +
                " t.is_del as \"isDel\" " +
                " from base_template t " +
                " where t.is_del='1' ";
        String sqlCount=" select count(1) as \"count\" from base_template t where t.is_del='1'";
        if (StringUtils.isNotBlank(templateType)){
            sql+= " and t.template_type='"+templateType+"'";
            sqlCount+= " and t.template_type='"+templateType+"'";
        }
        sql+=" order by t.update_time desc";
        Integer count=0;
        List<Map<String,Object>> countList=hibenateUtils.createSQLQuery(sql);
        if (countList!=null&&countList.size()>0){
            count = Integer.parseInt(countList.get(0).get("count").toString());
        }
        List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql,page,pageSize);
        MixEnvelop mixEnvelop = new MixEnvelop();
        mixEnvelop.setDetailModelList(list);
        mixEnvelop.setPageSize(pageSize);
        mixEnvelop.setCurrPage(page);
        mixEnvelop.setTotalCount(count);
        return mixEnvelop;
    }
   public void addOrRemoveChildrenDict(String templateId,String dictId,String isDel){
       BaseTemplateDictDO baseTemplateDictDO = baseTemplateDictDao.findByDictIdAndTemplateId(dictId,templateId);
       if ("1".equalsIgnoreCase(isDel)){
           if (baseTemplateDictDO!=null){
               baseTemplateDictDO.setIsDel("1");
           }else {
               baseTemplateDictDO = new BaseTemplateDictDO();
               baseTemplateDictDO.setTemplateId(templateId);
               baseTemplateDictDO.setDictId(dictId);
               baseTemplateDictDO.setCreateTime(new Date());
               baseTemplateDictDO.setIsDel("1");
           }
       }else {
           if (baseTemplateDictDO!=null){
               baseTemplateDictDO.setIsDel("0");
           }
       }
       baseTemplateDictDao.save(baseTemplateDictDO);
       BaseTemplateDO baseTemplateDO = baseTemplateDao.findOne(templateId);
       Integer chuildrenCount =  baseTemplateDictDao.getCountByTemplateId(templateId);
       if (baseTemplateDO !=null ){
           baseTemplateDO.setChildrenCount(chuildrenCount.toString());
       }
       baseTemplateDao.save(baseTemplateDO);
   }
   public void saveOrUpdateTemplate(String templateId,String code,String name,String user,String userName,String templateType){
       BaseTemplateDO baseTemplateDO = baseTemplateDao.findOne(templateId);
       if (baseTemplateDO!=null){
           baseTemplateDO.setCode(code);
           baseTemplateDO.setName(name);
           baseTemplateDO.setUpdateTime(new Date());
           baseTemplateDO.setUpdateUser(user);
           baseTemplateDO.setUpdateUserName(userName);
           baseTemplateDO.setTemplateType(templateType);
       }else {
           baseTemplateDO = new BaseTemplateDO();
           baseTemplateDO.setCode(code);
           baseTemplateDO.setName(name);
           baseTemplateDO.setCreateTime(new Date());
           baseTemplateDO.setCreateUser(user);
           baseTemplateDO.setCreateUserName(userName);
           baseTemplateDO.setTemplateType(templateType);
           baseTemplateDO.setIsDel("1");
       }
       baseTemplateDao.save(baseTemplateDO);
   }
}

+ 10 - 1
business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java

@ -90,6 +90,15 @@ public class ImUtil {
		return response;
	}
	public String sendPatientSystemMessage(String targetUserId, String message) {
		String imAddr = im_host + "api/v2/message/patientSystemMessage";
		JSONObject params = new JSONObject();
		params.put("targetUserId", targetUserId);
		params.put("message", message);
		String response = HttpClientUtil.postBody(imAddr,params);
		return response;
	}
	/**
	 * 发送消息
	 * @param senderId 发送者的code
@ -879,7 +888,7 @@ public class ImUtil {
	 * 返回 {"status":200,"data":1} data>0 说明在线 data =0 不在线
	 */
	public String findByUserIdAndType(String userId,String type) {
		String url = im_host + "api/v2/sessions/findByUserIdAndType?userId?="+userId+"&type="+type;
		String url = im_host + "api/v2/sessions/findByUserIdAndType?userId="+userId+"&type="+type;
		String ret = HttpClientUtil.get(url, "UTF-8");
		return ret;
	}

+ 52 - 0
common/common-entity/sql记录

@ -1094,6 +1094,55 @@ ALTER table base.dm_device add column need_register tinyint(2) DEFAULT '0' COMME
ALTER TABLE wlyy_patient_rehabilitation_plan add COLUMN  `admin_team_code` int(11) DEFAULT NULL COMMENT '家签行政团队Id';
-- 2021-07-12 lb
ALTER table base.dm_device modify column need_register varchar(255) DEFAULT NULL COMMENT '注册至iot接口,为空表示不注册'
-- 2021-07-16 lb
CREATE TABLE `wlyy_birthday_wishes_template` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `code` varchar(50) DEFAULT NULL,
  `type` int(2) DEFAULT NULL COMMENT '类型(1系统模板、2服务人员创建)',
  `applicable_range` int(2) DEFAULT NULL COMMENT '适用范围(1未成年、2成年、3老年人)',
  `content` text COMMENT '祝福语',
  `del` int(2) DEFAULT NULL COMMENT '是否删除(0是、1否)',
  `create_user` varchar(50) DEFAULT NULL COMMENT '创建人(系统模板为null)',
  `create_user_name` varchar(50) DEFAULT NULL COMMENT '创建人名称',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `is_default` int(2) DEFAULT '0' COMMENT '是否为默认模板(1是 0否)',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=4474 DEFAULT CHARSET=utf8mb4 COMMENT='生日祝福模板';
CREATE TABLE `birthday_wishes_to_patient` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `batch_no` varchar(50) DEFAULT NULL comment '批次号记录发送所属批次',
  `patient_code` varchar(50) DEFAULT NULL comment '患者标识',
  `patient_name` varchar(50) DEFAULT NULL comment '患者名称',
  `doctor_code` varchar(50) DEFAULT NULL comment '发送人code',
  `doctor_name` varchar(50) DEFAULT NULL comment '发送人名称',
  `user_type` int(2) DEFAULT NULL comment '1、患者,2医生',
  `send_pic` varchar(100) DEFAULT NULL comment '发送人头像',
  `send_sex` varchar(50) DEFAULT NULL comment '发送人性别',
  `admin_team_code` int(50) DEFAULT NULL comment '医生所在',
  `admin_team_name` varchar(50) DEFAULT NULL comment '行政团队名称',
  `hospital` varchar(50) DEFAULT NULL comment '所属机构',
  `hospital_name` varchar(50) DEFAULT NULL comment '所属机构名称',
  `town` varchar(50) DEFAULT NULL comment '所属区划',
  `town_name` varchar(50) DEFAULT NULL comment '所属区划名称',
  `send_type` int(3) DEFAULT NULL comment '发送类型 1医生发送 2管理员',
  `send_level` int(3) DEFAULT NULL comment '发送人级别 1社区医生,2助老员, 3教师 4管理员',
  `current_user_role_code` varchar(255) DEFAULT NULL comment '当前登录角色code ',
  `current_user_role_level` varchar(255) DEFAULT NULL comment 		'当前登录的角色级别,1、省,2、市,3、区,4、机构',
  `send_source` int(11) DEFAULT NULL comment '发送平台',
  `all_count` int(11) DEFAULT NULL comment '批次发送排序',
  `openid_set` text comment '本次批号推送openid集合',
  `birthday` varchar(10) DEFAULT NULL comment '居民生日 MM-dd',
  `template_id` int(15) DEFAULT NULL comment '生日模板id',
  `content` text comment '生日祝福内容',
  `create_time` varchar(20) DEFAULT NULL comment '创建时间',
  PRIMARY KEY (`id`),
	KEY index_pd(patient_code,doctor_code) USING BTREE,
	KEY index_time(create_time) USING BTREE,
	KEY index_birthday(birthday)USING BTREE
) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COMMENT='生日祝福发送记录';
ALTER table base.dm_device modify column need_register varchar(255) DEFAULT NULL COMMENT '注册至iot接口,为空表示不注册';
@ -1115,5 +1164,8 @@ ALTER table base.base_login_log add column name varchar(50) DEFAULT NULL COMMENT
ALTER table base.base_login_log add column client_type varchar(10) DEFAULT NULL COMMENT '客服端类型app,wx,pad,pc';
-- 2021-7-22 lb
alter table base_life_care_item_dict add column pad_icon_img varchar(255) DEFAULT NULL COMMENT 'pad图标'

+ 57 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/BaseDrugDictDO.java

@ -39,6 +39,63 @@ public class BaseDrugDictDO extends UuidIdentityEntity {
    private String status;
    private Date update_time;
    private String is_del;
    private String dosage;
    private String mini_stock_amount;
    private String max_stock_amount;
    private String pack_unit;
    private String vol_unit;
    private String manufactory;
    @Column(name = "vol_unit")
    public String getVol_unit() {
        return vol_unit;
    }
    public void setVol_unit(String vol_unit) {
        this.vol_unit = vol_unit;
    }
    @Column(name = "manufactory")
    public String getManufactory() {
        return manufactory;
    }
    public void setManufactory(String manufactory) {
        this.manufactory = manufactory;
    }
    @Column(name = "pack_unit")
    public String getPack_unit() {
        return pack_unit;
    }
    public void setPack_unit(String pack_unit) {
        this.pack_unit = pack_unit;
    }
    @Column(name = "dosage")
    public String getDosage() {
        return dosage;
    }
    public void setDosage(String dosage) {
        this.dosage = dosage;
    }
    @Column(name = "mini_stock_amount")
    public String getMini_stock_amount() {
        return mini_stock_amount;
    }
    public void setMini_stock_amount(String mini_stock_amount) {
        this.mini_stock_amount = mini_stock_amount;
    }
    @Column(name = "max_stock_amount")
    public String getMax_stock_amount() {
        return max_stock_amount;
    }
    public void setMax_stock_amount(String max_stock_amount) {
        this.max_stock_amount = max_stock_amount;
    }
    @Column(name = "is_del")
    public String getIs_del() {
        return is_del;

+ 111 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/BaseDrugUseDictDO.java

@ -0,0 +1,111 @@
package com.yihu.jw.entity.base.dict;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name = "base_drug_use_dict")
public class BaseDrugUseDictDO extends UuidIdentityEntityWithCreateTime {
    private String supply_code;
    private String supply_name;
    private String supply_occ;
    private String del_flag;
    private String sort_code;
    private String print_name;
    private String py_code;
    private String d_code;
    private String yb_name;
    private String yb_code;
    private String status;
    @Column(name = "supply_code")
    public String getSupply_code() {
        return supply_code;
    }
    public void setSupply_code(String supply_code) {
        this.supply_code = supply_code;
    }
    @Column(name = "supply_name")
    public String getSupply_name() {
        return supply_name;
    }
    public void setSupply_name(String supply_name) {
        this.supply_name = supply_name;
    }
    @Column(name = "supply_occ")
    public String getSupply_occ() {
        return supply_occ;
    }
    public void setSupply_occ(String supply_occ) {
        this.supply_occ = supply_occ;
    }
    @Column(name = "del_flag")
    public String getDel_flag() {
        return del_flag;
    }
    public void setDel_flag(String del_flag) {
        this.del_flag = del_flag;
    }
    @Column(name = "sort_code")
    public String getSort_code() {
        return sort_code;
    }
    public void setSort_code(String sort_code) {
        this.sort_code = sort_code;
    }
    @Column(name = "print_name")
    public String getPrint_name() {
        return print_name;
    }
    public void setPrint_name(String print_name) {
        this.print_name = print_name;
    }
    @Column(name = "py_code")
    public String getPy_code() {
        return py_code;
    }
    public void setPy_code(String py_code) {
        this.py_code = py_code;
    }
    @Column(name = "d_code")
    public String getD_code() {
        return d_code;
    }
    public void setD_code(String d_code) {
        this.d_code = d_code;
    }
    @Column(name = "yb_name")
    public String getYb_name() {
        return yb_name;
    }
    public void setYb_name(String yb_name) {
        this.yb_name = yb_name;
    }
    @Column(name = "yb_code")
    public String getYb_code() {
        return yb_code;
    }
    public void setYb_code(String yb_code) {
        this.yb_code = yb_code;
    }
    @Column(name = "status")
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
}

+ 93 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/BaseFrequencyDictDO.java

@ -0,0 +1,93 @@
package com.yihu.jw.entity.base.dict;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name = "base_frequency_dict")
public class BaseFrequencyDictDO extends UuidIdentityEntityWithCreateTime {
    private String freq_code;
    private String freq_name;
    private String freq_sp;
    private String daily_times;
    private String weekly_times;
    private String hosp_code;
    private String is_op_ip;
    private String is_del;
    private String status;
    @Column(name = "freq_code")
    public String getFreq_code() {
        return freq_code;
    }
    public void setFreq_code(String freq_code) {
        this.freq_code = freq_code;
    }
    @Column(name = "freq_name")
    public String getFreq_name() {
        return freq_name;
    }
    public void setFreq_name(String freq_name) {
        this.freq_name = freq_name;
    }
    @Column(name = "freq_sp")
    public String getFreq_sp() {
        return freq_sp;
    }
    public void setFreq_sp(String freq_sp) {
        this.freq_sp = freq_sp;
    }
    @Column(name = "daily_times")
    public String getDaily_times() {
        return daily_times;
    }
    public void setDaily_times(String daily_times) {
        this.daily_times = daily_times;
    }
    @Column(name = "weekly_times")
    public String getWeekly_times() {
        return weekly_times;
    }
    public void setWeekly_times(String weekly_times) {
        this.weekly_times = weekly_times;
    }
    @Column(name = "hosp_code")
    public String getHosp_code() {
        return hosp_code;
    }
    public void setHosp_code(String hosp_code) {
        this.hosp_code = hosp_code;
    }
    @Column(name = "is_op_ip")
    public String getIs_op_ip() {
        return is_op_ip;
    }
    public void setIs_op_ip(String is_op_ip) {
        this.is_op_ip = is_op_ip;
    }
    @Column(name = "is_del")
    public String getIs_del() {
        return is_del;
    }
    public void setIs_del(String is_del) {
        this.is_del = is_del;
    }
    @Column(name = "status")
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
}

+ 19 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/BaseTemplateOrgDO.java

@ -14,6 +14,25 @@ public class BaseTemplateOrgDO extends UuidIdentityEntityWithCreateTime {
    private String orgCode;
    private String isDel;
    private String orgName;
    private String templateType;
    private String saasId;
    @Column(name = "template_type")
    public String getTemplateType() {
        return templateType;
    }
    public void setTemplateType(String templateType) {
        this.templateType = templateType;
    }
    @Column(name = "saas_id")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    @Column(name = "template_id")
    public String getTemplateId() {
        return templateId;

+ 65 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictIcd10DO.java

@ -40,6 +40,71 @@ public class DictIcd10DO extends IntegerIdentityEntity {
	 */
	private String description;
	private String disea_reason;
	private String death_reason;
	private String py_code;
    private String flag;
    private String d_code;
    private String is_del;
    private String status;
    @Column(name = "is_del")
    public String getIs_del() {
        return is_del;
    }
    public void setIs_del(String is_del) {
        this.is_del = is_del;
    }
    @Column(name = "status")
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    @Column(name = "disea_reason")
    public String getDisea_reason() {
        return disea_reason;
    }
    public void setDisea_reason(String disea_reason) {
        this.disea_reason = disea_reason;
    }
    @Column(name = "death_reason")
    public String getDeath_reason() {
        return death_reason;
    }
    public void setDeath_reason(String death_reason) {
        this.death_reason = death_reason;
    }
    @Column(name = "py_code")
    public String getPy_code() {
        return py_code;
    }
    public void setPy_code(String py_code) {
        this.py_code = py_code;
    }
    @Column(name = "flag")
    public String getFlag() {
        return flag;
    }
    public void setFlag(String flag) {
        this.flag = flag;
    }
    @Column(name = "d_code")
    public String getD_code() {
        return d_code;
    }
    public void setD_code(String d_code) {
        this.d_code = d_code;
    }
    /**
	 * 创建时间
	 */

+ 255 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/birthday/BirthDayWishesToPatient.java

@ -0,0 +1,255 @@
package com.yihu.jw.entity.care.birthday;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 生日祝福推送记录表
 * Created by humingfen on 2018/10/24.
 */
@Entity
@Table(name = "birthday_wishes_to_patient")
public class BirthDayWishesToPatient extends IdEntity {
    //说明:如医生推送生日祝福给5个居民,则保存5条userType=1的记录和1条userType=2的记录(共6条)batchNo批次号一样。
    private String batchNo;//批次号记录发送所属批次(ES:必填)
    private String patientCode; // 患者标识(ES)(根据userType的值,userType=1,必填;userType=2,为空)
    private String patientName; // 患者名称(ES)(根据userType的值,userType=1,必填;userType=2,为空)
    private String doctorCode;  //发送人code(doctor表中的code)(ES:必填)
    private String doctorName;  //发送人名称(doctor表中的name)(ES:必填)
    private Integer userType; // 1、患者,2医生(ES:必填)
    //备注:从发送人的信息中获取(doctor表获取)
    private String sendPic;   // 发送人头像(ES)
    private String sendSex;   // 发送人性别(ES)
    private Long adminTeamCode;// 行政团队(ES)
    private String adminTeamName;// 行政团队(ES)
    private String hospital; // 所属机构(ES)
    private String hospitalName; // 所属机构(ES)
    private String town; // 所属区划(ES)
    private String townName; // 所属区划(ES)
    private Integer sendType;//发送类型 1医生发送 2(管理员)卫纪委发送(ES:必填)
    private Integer sendLevel;   // 发送人级别  1专科医生,2全科医生,3健康管理师 4 管理员(ES)
    //说明:如普通医生推送则保存doctor表中的hospital字段,如管理员推送则保存当前角色的code(取wlyy_user_role表中的role字段)
    private String currentUserRoleCode;//发送者当前登录的角色code(ES:必填)
    private String currentUserRoleLevel;//发送者当前登录的角色级别,1、省,2、市,3、区,4、机构(ES:必填)
    private Integer sendSource; //1或者为空 i健康后台推送  2PC端推送(默认旧数据为1)(为后续平台推送统计做备用字段)
    private Integer allCount;//所有的推送数目(ES:必填)
    private String openidSet;//本次发送生日祝福的openid的总集合
    //生日祝福
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM-dd")
    private String birthday;  // 居民生日(ES:必填)
    private Long templateId; //生日模板id
    private String content; //生日祝福内容 (ES:必填)
    private String createTime;  // 创建时间(ES:必填)
    public String getBatchNo() {
        return batchNo;
    }
    public void setBatchNo(String batchNo) {
        this.batchNo = batchNo;
    }
    public String getPatientCode() {
        return patientCode;
    }
    public void setPatientCode(String patientCode) {
        this.patientCode = patientCode;
    }
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    public String getDoctorCode() {
        return doctorCode;
    }
    public void setDoctorCode(String doctorCode) {
        this.doctorCode = doctorCode;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public Integer getUserType() {
        return userType;
    }
    public void setUserType(Integer userType) {
        this.userType = userType;
    }
    public String getSendPic() {
        return sendPic;
    }
    public void setSendPic(String sendPic) {
        this.sendPic = sendPic;
    }
    public String getSendSex() {
        return sendSex;
    }
    public void setSendSex(String sendSex) {
        this.sendSex = sendSex;
    }
    public Long getAdminTeamCode() {
        return adminTeamCode;
    }
    public void setAdminTeamCode(Long adminTeamCode) {
        this.adminTeamCode = adminTeamCode;
    }
    public String getAdminTeamName() {
        return adminTeamName;
    }
    public void setAdminTeamName(String adminTeamName) {
        this.adminTeamName = adminTeamName;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public String getTown() {
        return town;
    }
    public void setTown(String town) {
        this.town = town;
    }
    public String getTownName() {
        return townName;
    }
    public void setTownName(String townName) {
        this.townName = townName;
    }
    public String getCurrentUserRoleCode() {
        return currentUserRoleCode;
    }
    public void setCurrentUserRoleCode(String currentUserRoleCode) {
        this.currentUserRoleCode = currentUserRoleCode;
    }
    public String getCurrentUserRoleLevel() {
        return currentUserRoleLevel;
    }
    public void setCurrentUserRoleLevel(String currentUserRoleLevel) {
        this.currentUserRoleLevel = currentUserRoleLevel;
    }
    public Integer getSendSource() {
        return sendSource;
    }
    public void setSendSource(Integer sendSource) {
        this.sendSource = sendSource;
    }
    public Integer getAllCount() {
        return allCount;
    }
    public void setAllCount(Integer allCount) {
        this.allCount = allCount;
    }
    public String getBirthday() {
        return birthday;
    }
    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getCreateTime() {
        return createTime;
    }
    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }
    public Integer getSendType() {
        return sendType;
    }
    public void setSendType(Integer sendType) {
        this.sendType = sendType;
    }
    public Integer getSendLevel() {
        return sendLevel;
    }
    public void setSendLevel(Integer sendLevel) {
        this.sendLevel = sendLevel;
    }
    public String getOpenidSet() {
        return openidSet;
    }
    public void setOpenidSet(String openidSet) {
        this.openidSet = openidSet;
    }
    public Long getTemplateId() {
        return templateId;
    }
    public void setTemplateId(Long templateId) {
        this.templateId = templateId;
    }
}

+ 112 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/birthday/BirthdayWishesTemplate.java

@ -0,0 +1,112 @@
package com.yihu.jw.entity.care.birthday;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 生日祝福语模板
 *
 * @author humingfen
 */
@Entity
@Table(name = "wlyy_birthday_wishes_template")
public class BirthdayWishesTemplate extends IdEntity {
    private String code;//业务主键
    private Integer type;//类型(1系统模板、2服务人员创建)
    private Integer applicableRange;//适用范围(1小孩、2中年、3老年人)
    private String content;//祝福语
    private Integer del;//是否删除(0否、1是)
    private String createUser;//创建人(系统模板值为空)
    private String createUserName;//创建人姓名
    private Date createTime;//创建时间
    private Integer isDefault;//是否为默认模板(1是 0否)
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "type")
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    @Column(name = "applicable_range")
    public Integer getApplicableRange() {
        return applicableRange;
    }
    public void setApplicableRange(Integer applicableRange) {
        this.applicableRange = applicableRange;
    }
    @Column(name = "content")
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    @Column(name = "del")
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    @Column(name = "create_user")
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    @Column(name = "create_user_name")
    public String getCreateUserName() {
        return createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Integer getIsDefault() {
        return isDefault;
    }
    public void setIsDefault(Integer isDefault) {
        this.isDefault = isDefault;
    }
}

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/lifeCare/LifeCareItemDictDO.java

@ -21,6 +21,7 @@ public class LifeCareItemDictDO extends UuidIdentityEntity{
    private Integer sort;//排序字段
    private Integer del;//删除标志 1正常,0删除
    private String lifeCareImg;//服务项目图片
    private String padIconImg;//pad图标
    public String getCode() {
        return code;
@ -78,4 +79,12 @@ public class LifeCareItemDictDO extends UuidIdentityEntity{
    public void setLifeCareImg(String lifeCareImg) {
        this.lifeCareImg = lifeCareImg;
    }
    public String getPadIconImg() {
        return padIconImg;
    }
    public void setPadIconImg(String padIconImg) {
        this.padIconImg = padIconImg;
    }
}

+ 11 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/message/SystemMessageDO.java

@ -19,6 +19,8 @@ public class SystemMessageDO extends UuidIdentityEntity {
    /**
     *消息类型 上门服务400开头,生活照料500开头 ,安防监控600开头, 上门辅导700开头,紧急救助800开头
     * 人文关怀系统消息 41
     * 体征设备测量系统消息 42
     * 家属紧急预警系统消息 50
     * 新生儿在线咨询 850
     * 老人在线咨询 851
@ -76,6 +78,7 @@ public class SystemMessageDO extends UuidIdentityEntity {
    private Integer state;
    private Integer readonly;
    private String reason;
    private String code;
    private String senderPhoto;
    @Column(name = "content")
    public String getContent() {
@ -222,4 +225,12 @@ public class SystemMessageDO extends UuidIdentityEntity {
    public void setOver(String over) {
        this.over = over;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
}

+ 123 - 0
common/common-util/src/main/java/com/yihu/jw/util/healthIndex/HealthIndexUtil.java

@ -0,0 +1,123 @@
package com.yihu.jw.util.healthIndex;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.stereotype.Component;
/**
 * Created by Bing on 2021/7/20.
 * 体征数据
 */
@Component
public class HealthIndexUtil {
    // 血糖餐前最小值
    public static final double HEALTH_STANDARD_ST_MIN_BEFORE = 4;
    // 血糖餐前最大值
    public static final double HEALTH_STANDARD_ST_MAX_BEFORE = 7;
    // 血糖餐后最小值
    public static final double HEALTH_STANDARD_ST_MIN_AFTER = 4;
    // 血糖餐后最大值
    public static final double HEALTH_STANDARD_ST_MAX_AFTER = 11.1;
    // 舒张压最小值
    public static final double HEALTH_STANDARD_SZY_MIN = 60;
    // 舒张压最大值
    public static final double HEALTH_STANDARD_SZY_MAX = 90;
    // 收缩压最小值
    public static final double HEALTH_STANDARD_SSY_MIN = 90;
    // 收缩压最大值
    public static final double HEALTH_STANDARD_SSY_MAX = 140;
    //最小值
    public static final double HEALTH_STANDARD_HEART_RATE_MIN = 60;
    //最大值
    public static final double HEALTH_STANDARD_HEART_RATE_MAX = 100;
    /**
     * type:1血糖2血压,3体重/身高/BMI,4腰围,5心率,6体温
     * @return
     */
    public JSONArray verifyHealthIndex(Integer type, String ...values) {
        //血糖校验
        JSONArray result = new JSONArray();
        JSONObject tmp = new JSONObject();
        if (1 ==type) {
            // 血糖记录,查询患者血糖预警值
            Double maxValueBefore = HEALTH_STANDARD_ST_MAX_BEFORE;
            Double minValueBefore = HEALTH_STANDARD_ST_MIN_BEFORE;
            Double maxValueAfter = HEALTH_STANDARD_ST_MAX_AFTER;
            Double minValueAfter = HEALTH_STANDARD_ST_MIN_AFTER;
            int index = Integer.valueOf(values[1]);
            String value1 = values[0];
            // 餐后
            if (index % 2 == 0) {
                tmp.put("value1",value1);
                tmp.put("indexName","血糖");
                tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), maxValueAfter, minValueAfter));
            } else { //餐前
                tmp.put("value1",value1);
                tmp.put("indexName","血糖");
                tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), maxValueBefore, minValueBefore));
            }
            result.add(tmp);
        }
        //血压校验
        else if (type == 2) {
            String value1 = values[0];//收缩压
            String value2 = values[1];//舒张压
            String value3 = values[2];//脉搏
            // 血压记录,查询患者血压预警值
            Double maxValueSSY = HEALTH_STANDARD_SSY_MAX;
            Double minValueSSY = HEALTH_STANDARD_SSY_MIN;
            Double maxValueSZY = HEALTH_STANDARD_SZY_MAX;
            Double minValueSZY = HEALTH_STANDARD_SZY_MIN;
            // 收缩压/舒张压校验
            tmp.put("value1",value1);
            tmp.put("indexName","收缩压");
            tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), maxValueSSY, minValueSSY));
            result.add(tmp);
            //舒张压校验
            tmp = new JSONObject();
            tmp.put("value1",value1);
            tmp.put("indexName","舒张压");
            tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value2), maxValueSZY, minValueSZY));
            result.add(tmp);
            tmp = new JSONObject();
            //脉搏检验
            if (StringUtils.isNotBlank(value3)){
                tmp.put("value1",value1);
                tmp.put("indexName","脉搏");
                tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value3), HEALTH_STANDARD_HEART_RATE_MAX, HEALTH_STANDARD_HEART_RATE_MIN));
                result.add(tmp);
            }
        }
        else if (type == 5) {//心率
            String value1 = values[0];//心率
            tmp.put("value1",value1);
            tmp.put("indexName","心率");
            tmp.put("error",checkHealthIndex(NumberUtils.toDouble(value1), HEALTH_STANDARD_HEART_RATE_MAX, HEALTH_STANDARD_HEART_RATE_MIN));
            result.add(tmp);
        }
        return result;
    }
    /**
     * 判断当前值是否在区间内
     */
    private Integer checkHealthIndex(Double current, Double max, Double min) {
        if (current > max  ) {
            return 1;//指标过高
        }else if(current < min || current < 0) {
            return -1;//指标过低
        }
        else {//正常
            return 0;
        }
    }
}

+ 8 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/dict/DictIcd10Dao.java

@ -33,4 +33,12 @@ public interface DictIcd10Dao extends PagingAndSortingRepository<DictIcd10DO, In
    List<DictIcd10DO> findBySaasId(String saasId);
    Long countBySaasId(String saasId);
    List<DictIcd10DO>  findByCodeAndName(String code, String name);
    @Query("from DictIcd10DO t where t.is_del='1' and t.status ='1' order by t.createTime desc")
    List<DictIcd10DO> findByDel(Pageable pageRequest);
    @Query("select  count(1) from DictIcd10DO t where t.is_del='1' and t.status='1'")
    Integer getconuntByDel();
}

+ 86 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/dict/BaseDrugUseEndpoint.java

@ -0,0 +1,86 @@
package com.yihu.jw.base.endpoint.dict;
import com.yihu.jw.base.service.dict.BaseDrugDictService;
import com.yihu.jw.base.service.dict.BaseDrugUseService;
import com.yihu.jw.entity.base.dict.BaseDrugDictDO;
import com.yihu.jw.entity.base.dict.BaseDrugUseDictDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping(value = "/baseDrugUse")
@Api(value = "药品使用方式字典", description = "药品使用方式字典", tags = {"药品使用方式字典"})
public class BaseDrugUseEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private BaseDrugUseService baseDrugUseService;
    @PostMapping("/saveDrugUse")
    @ApiOperation(value = "保存")
    public Envelop saveDrugUse(@ApiParam(name = "jsonData", value = "药品json串")
                                       @RequestParam(name = "jsonData", required = true) String jsonData) throws Exception {
        try {
            BaseDrugUseDictDO baseDrugUseDictDO = objectMapper.readValue(jsonData, BaseDrugUseDictDO.class);
            baseDrugUseService.saveBaseDrugUse(baseDrugUseDictDO);
            return success("操作成功");
        }catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping("/findDrugUseList")
    @ApiOperation(value = "列表")
    public MixEnvelop findDrugDict(@ApiParam(name = "name", value = "药品名称")
                                   @RequestParam(name = "name", required = false) String name,
                                   @ApiParam(name = "status", value = "状态")
                                   @RequestParam(name = "status", required = false) String status,
                                   @ApiParam(name = "page", value = "当前页")
                                   @RequestParam(name = "page", required = false) Integer page,
                                   @ApiParam(name = "pageSize", value = "页面大小")
                                   @RequestParam(name = "pageSize", required = false) Integer pageSize) throws Exception {
        try {
            return baseDrugUseService.findDrugUseList(name,status, page, pageSize);
        }catch (Exception e) {
            return failedMixEnvelopException(e);
        }
    }
    @GetMapping("/findOneDrug")
    @ApiOperation(value = "根据id查询")
    public Envelop findOneDrug(@ApiParam(name = "id", value = "药品id")
                               @RequestParam(name = "id", required = true) String id){
        try {
            return success(baseDrugUseService.findOneUseDict(id));
        }catch (Exception e) {
            return failedException(e);
        }
    }
    @GetMapping("/updateDruguseStatus")
    @ApiOperation(value = "修改状态")
    public Envelop updateDruguseStatus(@ApiParam(name = "id", value = "id")
                               @RequestParam(name = "id", required = true) String id,
                               @ApiParam(name = "status", value = "状态1使用0作废")
                               @RequestParam(name = "status", required = false) String status,
                               @ApiParam(name = "del", value = "0删除")
                               @RequestParam(name = "del", required = false) String del){
        try {
            baseDrugUseService.updateDrugUseStatus(id,status,del);
            return success("操作成功");
        }catch (Exception e) {
            return failedException(e);
        }
    }
}

+ 84 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/dict/BaseFrequencyEndpoint.java

@ -0,0 +1,84 @@
package com.yihu.jw.base.endpoint.dict;
import com.yihu.jw.base.service.dict.BaseDrugUseService;
import com.yihu.jw.base.service.dict.BaseFrequencyService;
import com.yihu.jw.entity.base.dict.BaseDrugUseDictDO;
import com.yihu.jw.entity.base.dict.BaseFrequencyDictDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping(value = "/baseFrequency")
@Api(value = "药品使用方式字典", description = "药品使用方式字典", tags = {"药品使用方式字典"})
public class BaseFrequencyEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private BaseFrequencyService baseFrequencyService;
    @PostMapping("/saveFrequency")
    @ApiOperation(value = "保存")
    public Envelop saveDrugUse(@ApiParam(name = "jsonData", value = "药品json串")
                                       @RequestParam(name = "jsonData", required = true) String jsonData) throws Exception {
        try {
            BaseFrequencyDictDO baseFrequencyDictDO = objectMapper.readValue(jsonData, BaseFrequencyDictDO.class);
            baseFrequencyService.saveFrequency(baseFrequencyDictDO);
            return success("操作成功");
        }catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping("/findFrequencyList")
    @ApiOperation(value = "获取列表接口")
    public MixEnvelop findDrugDict(@ApiParam(name = "name", value = "药品名称")
                                   @RequestParam(name = "name", required = false) String name,
                                   @ApiParam(name = "status", value = "状态")
                                   @RequestParam(name = "status", required = false) String status,
                                   @ApiParam(name = "page", value = "当前页")
                                   @RequestParam(name = "page", required = false) Integer page,
                                   @ApiParam(name = "pageSize", value = "页面大小")
                                   @RequestParam(name = "pageSize", required = false) Integer pageSize) throws Exception {
        try {
            return baseFrequencyService.findFrequencyList(name,status, page, pageSize);
        }catch (Exception e) {
            return failedMixEnvelopException(e);
        }
    }
    @GetMapping("/findOneFrequency")
    @ApiOperation(value = "根据id查询")
    public Envelop findOneDrug(@ApiParam(name = "id", value = "药品id")
                               @RequestParam(name = "id", required = true) String id){
        try {
            return success(baseFrequencyService.findOneFrequency(id));
        }catch (Exception e) {
            return failedException(e);
        }
    }
    @GetMapping("/updateFrequencyStatus")
    @ApiOperation(value = "修改状态")
    public Envelop updateFrequencyStatus(@ApiParam(name = "id", value = "id")
                               @RequestParam(name = "id", required = true) String id,
                               @ApiParam(name = "status", value = "状态1使用0作废")
                               @RequestParam(name = "status", required = false) String status,
                               @ApiParam(name = "del", value = "0删除")
                                   @RequestParam(name = "del", required = false) String del){
        try {
            baseFrequencyService.updateFrequencyStatus(id,status,del);
            return success("操作成功");
        }catch (Exception e) {
            return failedException(e);
        }
    }
}

+ 27 - 25
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/dict/DictDrugEndpoint.java

@ -1,6 +1,8 @@
package com.yihu.jw.base.endpoint.dict;
import com.yihu.jw.base.service.dict.BaseDrugDictService;
import com.yihu.jw.entity.base.dict.BaseDrugDictDO;
import com.yihu.jw.entity.hospital.prescription.BaseNationalDrugDictDO;
import com.yihu.jw.hospital.prescription.service.NationalDrugDictService;
import com.yihu.jw.restmodel.web.Envelop;
@ -19,15 +21,15 @@ import org.springframework.web.bind.annotation.*;
@Api(value = "药品字典维护", description = "药品字典维护", tags = {"药品字典维护"})
public class DictDrugEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private NationalDrugDictService nationalDrugDictService;
    private BaseDrugDictService nationalDrugDictService;
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.saveNationalDrug)
    @PostMapping("/saveNationalDrug")
    @ApiOperation(value = "保存药品字典接口")
    public ObjEnvelop saveNationalDrug(@ApiParam(name = "jsonData", value = "药品json串")
                                       @RequestParam(name = "jsonData", required = true) String jsonData) throws Exception {
        try {
            BaseNationalDrugDictDO nationalDrugDictDO = objectMapper.readValue(jsonData, BaseNationalDrugDictDO.class);
            BaseDrugDictDO nationalDrugDictDO = objectMapper.readValue(jsonData, BaseDrugDictDO.class);
            return success(nationalDrugDictService.saveNationalDrug(nationalDrugDictDO));
        }catch (Exception e) {
            return failedObjEnvelopException(e);
@ -35,52 +37,52 @@ public class DictDrugEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getNationalDrugList)
    @GetMapping("/findDrugDictList")
    @ApiOperation(value = "获取药品字典接口")
    public MixEnvelop getNationalDrugList(@ApiParam(name = "name", value = "药品名称")
    public MixEnvelop findDrugDict(@ApiParam(name = "name", value = "药品名称")
                                          @RequestParam(name = "name", required = false) String name,
                                          @ApiParam(name = "number", value = "药品编码")
                                          @RequestParam(name = "number", required = false) String number,
                                          @ApiParam(name = "hospital", value = "所属机构")
                                          @RequestParam(name = "hospital", required = false) String hospital,
                                          @ApiParam(name = "status", value = "状态")
                                          @RequestParam(name = "status", required = false) Integer status,
                                          @RequestParam(name = "status", required = false) String status,
                                          @ApiParam(name = "page", value = "当前页")
                                          @RequestParam(name = "page", required = false) Integer page,
                                          @ApiParam(name = "pageSize", value = "页面大小")
                                          @RequestParam(name = "pageSize", required = false) Integer pageSize) throws Exception {
        try {
            return nationalDrugDictService.getNationalDrugList(name, number, hospital, status, page, pageSize);
            return nationalDrugDictService.findDrugDict(name,status, page, pageSize);
        }catch (Exception e) {
            return failedMixEnvelopException(e);
        }
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.updateNationalDrugStatus)
    @ApiOperation(value = "更新药品字典状态")
    public Envelop updateNationalDrugStatus(@ApiParam(name = "id", value = "药品id")
                                            @RequestParam(name = "id", required = true) Integer id,
                                            @ApiParam(name = "status", value = "状态", required = true)
                                            @RequestParam(name = "status") Integer status){
    @GetMapping("/findOneDrug")
    @ApiOperation(value = "根据药品id查询")
    public Envelop findOneDrug(@ApiParam(name = "id", value = "药品id")
                                            @RequestParam(name = "id", required = true) String id){
        try {
            nationalDrugDictService.updateNationalDrugStatus(id,status);
            return success();
            return success(nationalDrugDictService.findOneDrug(id));
        }catch (Exception e) {
            return failedException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getNationalDrugById)
    @ApiOperation(value = "根据id获取药品字典")
    public ObjEnvelop getNationalDrugById(@ApiParam(name = "id", value = "药品id")
                                          @RequestParam(name = "id", required = true) Integer id) {
    @GetMapping("/updateDrugStatus")
    @ApiOperation(value = "修改状态")
    public Envelop updateDruguseStatus(@ApiParam(name = "id", value = "id")
                                       @RequestParam(name = "id", required = true) String id,
                                       @ApiParam(name = "status", value = "状态1使用0作废")
                                       @RequestParam(name = "status", required = false) String status,
                                       @ApiParam(name = "del", value = "0删除")
                                       @RequestParam(name = "del", required = false) String del){
        try {
            return success(nationalDrugDictService.getNationalDrugById(id));
            nationalDrugDictService.updateDrugStatus(id,status,del);
            return success("操作成功");
        }catch (Exception e) {
            return failedObjEnvelopException(e);
            return failedException(e);
        }
    }
}

+ 43 - 32
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/dict/DictIcd10Endpoint.java

@ -2,10 +2,7 @@ package com.yihu.jw.base.endpoint.dict;
import com.yihu.jw.base.service.dict.DictIcd10Service;
import com.yihu.jw.restmodel.base.dict.DictIcd10VO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.*;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
@ -37,13 +34,14 @@ public class DictIcd10Endpoint extends EnvelopRestEndpoint {
    @Autowired
    private DictIcd10Service dictIcd10Service;
    @PostMapping(value = BaseRequestMapping.DictIcd10.CREATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping("/icd1oCreateUpdate")
    @ApiOperation(value = "创建")
    public ObjEnvelop<DictIcd10VO> create(
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
    public ObjEnvelop<DictIcd10VO> createOrupdate(
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam(value = "jsonData") String jsonData) throws Exception {
        System.out.println(jsonData);
        DictIcd10DO dictIcd10 = toEntity(jsonData, DictIcd10DO.class);
        dictIcd10 = dictIcd10Service.save(dictIcd10);
        dictIcd10Service.saveIcd10(dictIcd10);
        return success(dictIcd10, DictIcd10VO.class);
    }
@ -56,19 +54,6 @@ public class DictIcd10Endpoint extends EnvelopRestEndpoint {
        return success("删除成功");
    }
    @PostMapping(value = BaseRequestMapping.DictIcd10.UPDATE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "更新")
    public ObjEnvelop<DictIcd10VO> update(
            @ApiParam(name = "json_data", value = "Json数据", required = true)
            @RequestBody String jsonData) throws Exception {
        DictIcd10DO dictIcd10 = toEntity(jsonData, DictIcd10DO.class);
        if (null == dictIcd10.getId()) {
            return failed("ID不能为空", ObjEnvelop.class);
        }
        dictIcd10 = dictIcd10Service.save(dictIcd10);
        return success(dictIcd10, DictIcd10VO.class);
    }
    @GetMapping(value = BaseRequestMapping.DictIcd10.PAGE)
    @ApiOperation(value = "获取分页")
    public PageEnvelop<DictIcd10VO> page(
@ -87,17 +72,43 @@ public class DictIcd10Endpoint extends EnvelopRestEndpoint {
        return success(dictIcd10s, count, page, size, DictIcd10VO.class);
    }
    @GetMapping(value = BaseRequestMapping.DictIcd10.LIST)
    @GetMapping("/findIcd10List")
    @ApiOperation(value = "获取列表")
    public ListEnvelop<DictIcd10VO> list(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        List<DictIcd10DO> dictIcd10s = dictIcd10Service.search(fields, filters, sorts);
        return success(dictIcd10s, DictIcd10VO.class);
    public MixEnvelop list(
            @ApiParam(name = "name", value = "")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "status", value = "")
            @RequestParam(value = "status", required = false) String status,
            @ApiParam(name = "page", value = "")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "pageSize", value = "")
            @RequestParam(value = "pageSize", required = false) Integer pageSize) throws Exception {
        return dictIcd10Service.findIcd10List(name, status, page,pageSize);
    }
    @GetMapping("/findIcd10One")
    @ApiOperation(value = "获取单条")
    public Envelop findIcd10One(
            @ApiParam(name = "id", value = "")
            @RequestParam(value = "id", required = false) Integer id) throws Exception {
        return success(dictIcd10Service.findOneIcd10(id));
    }
    @GetMapping("/updateIcd10Status")
    @ApiOperation(value = "修改状态")
    public Envelop updateIcd10Status(@ApiParam(name = "id", value = "id")
                                       @RequestParam(name = "id", required = true) Integer id,
                                       @ApiParam(name = "status", value = "状态1使用0作废")
                                       @RequestParam(name = "status", required = false) String status,
                                       @ApiParam(name = "del", value = "0删除")
                                       @RequestParam(name = "del", required = false) String del){
        try {
            dictIcd10Service.updateIcd10Status(id,status,del);
            return success("操作成功");
        }catch (Exception e) {
            return failedException(e);
        }
    }
}

+ 430 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/dict/TemplateManageEndpoint.java

@ -0,0 +1,430 @@
package com.yihu.jw.base.endpoint.dict;
import com.yihu.jw.base.service.dict.*;
import com.yihu.jw.base.service.dict.importManage.*;
import com.yihu.jw.base.service.doctor.excelImport.BaseDoctorExcelDO;
import com.yihu.jw.base.service.doctor.excelImport.BaseDoctorExcelDOReader;
import com.yihu.jw.entity.base.dict.DictDiseaseDO;
import com.yihu.jw.entity.base.dict.DiseaseManageDO;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.restmodel.base.dict.DictDiseaseVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/templateManage")
@Api(value = "字典模板维护", description = "字典模板维护", tags = {"字典模板维护"})
public class TemplateManageEndpoint  extends EnvelopRestEndpoint {
    @Autowired
    private TemplateManageService templateManageService;
    @Autowired
    private BaseDrugDictService baseDrugDictService;
    @Autowired
    private BaseDrugExcelDOReader baseDrugExcelDOReader;
    @Autowired
    private BaseDrugUseExcelDOReader baseDrugUseExcelDOReader;
    @Autowired
    private BaseDrugUseService baseDrugUseService;
    @Autowired
    private BaseFrequencyExcelDOReader baseFrequencyExcelDOReader;
    @Autowired
    private BaseFrequencyService baseFrequencyService;
    @Autowired
    private BaseIcd10ExcelDOReader icd10ExcelDOReader;
    @Autowired
    private DictIcd10Service dictIcd10Service;
    @PostMapping("/excelControl/importDrug")
    @Transactional(rollbackFor = Exception.class)
    @ApiOperation(value = "基础药品字典信息列表导入")
    public Envelop importData(
            @ApiParam(name = "file", value = "文件", required = true)
            @RequestPart(value = "file") MultipartFile file,
            @ApiParam(name = "templateId", value = "templateId", required = false)
            @RequestPart(value = "templateId" ,required = false) String  templateId,
            HttpServletRequest request) throws IOException, ManageException {
        try {
            request.setCharacterEncoding("UTF-8");
//            AExcelReader excelReader = new BaseDoctorExcelDOReader();
            InputStream inputStream = file.getInputStream();
            Workbook workbook = getWorkbook(inputStream,file.getOriginalFilename());
            baseDrugExcelDOReader.read(workbook);
            //验证未通过(暂无验证)
            List<BasDrugExcelDO> errorLs = baseDrugExcelDOReader.getErrorLs();
            List<BasDrugExcelDO> correctLs = baseDrugExcelDOReader.getCorrectLs();
            Map<String, Object> result =new HashMap<>();
            String msg ="";
            if(correctLs.size()>0){
                result = baseDrugDictService.batchInsertDrugs(correctLs,templateId);
                result.put("errorLs", errorLs);
                int errors = errorLs.size();
                int corrects = correctLs.size();
                msg = "当前导入成功"+corrects+"条数据"+";失败"+errors+"条数据";
            }
            return success(msg, result);
        }catch (Exception e){
            e.printStackTrace();
            return failed("导入异常,请检查导入文件格式" + e.getMessage());
        }
    }
    /**
     * 判断文件格式
     * @param in
     * @param fileName
     * @return
     */
    private static Workbook getWorkbook(InputStream in, String fileName) throws Exception {
        Workbook book = null;
        String filetype = fileName.substring(fileName.lastIndexOf("."));
        if(".xls".equals(filetype)) {
            book = new HSSFWorkbook(in);
        } else if (".xlsx".equals(filetype)) {
            book = new XSSFWorkbook(in);
        } else {
            throw new Exception("请上传excel文件!");
        }
        return book;
    }
    @GetMapping("/getTemplateList")
    @ApiOperation(value = "获取列表")
    public MixEnvelop list (
            @ApiParam(name = "templateType", value = "模板类型")
            @RequestParam(value = "templateType", required = false) String templateType,
            @ApiParam(name = "code", value = "")
            @RequestParam(value = "code", required = false) String code,
            @ApiParam(name = "name", value = "")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "page", value = "")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "pageSize", value = "")
            @RequestParam(value = "pageSize", required = false) Integer pageSize) throws Exception {
        try {
            return templateManageService.findTempalte(templateType,code,name,page,pageSize);
        }catch (Exception e){
            e.printStackTrace();
            return failedMixEnvelopException(e);
        }
    }
    @GetMapping("/addOrRemoveChild")
    @ApiOperation(value = "")
    public Envelop addOrRemoveChild (
            @ApiParam(name = "templateId", value = "模板id")
            @RequestParam(value = "templateId", required = false) String templateId,
            @ApiParam(name = "dictId", value = "")
            @RequestParam(value = "dictId", required = false) String  dictId,
            @ApiParam(name = "del", value = "")
            @RequestParam(value = "del", required = false) String  del) throws Exception {
        try {
            templateManageService.addOrRemoveChildrenDict(templateId,dictId,del);
            return success("操作成功");
        }catch (Exception e){
            e.printStackTrace();
            return failedException(e);
        }
    }
    @GetMapping("/saveOrUpdateTemplate")
    @ApiOperation(value = "")
    public Envelop saveOrUpdateTemplate (
            @ApiParam(name = "templateId", value = "模板id")
            @RequestParam(value = "templateId", required = false) String templateId,
            @ApiParam(name = "code", value = "")
            @RequestParam(value = "code", required = false) String  code,
            @ApiParam(name = "name", value = "")
            @RequestParam(value = "name", required = false) String  name,
            @ApiParam(name = "templateType", value = "")
            @RequestParam(value = "templateType", required = false) String  templateType) throws Exception {
        try {
            if (!StringUtils.isNoneBlank(templateId)){
                templateId="1";
            }
            templateManageService.saveOrUpdateTemplate(templateId,code,name,getUID(),getUNAME(),templateType);
            return success("操作成功");
        }catch (Exception e){
            e.printStackTrace();
            return failedException(e);
        }
    }
    @GetMapping("/getTemplateChildList")
    @ApiOperation(value = "获取列表")
    public MixEnvelop getTemplateChildList (
            @ApiParam(name = "templateId", value = "模板id")
            @RequestParam(value = "templateId", required = false) String templateId,
            @ApiParam(name = "name", value = "模板id")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "isSelectUse", value = "1查询已添加的2查询未添加")
            @RequestParam(value = "isSelectUse", required = false) String isSelectUse,
            @ApiParam(name = "page", value = "")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "pageSize", value = "")
            @RequestParam(value = "pageSize", required = false) Integer pageSize) throws Exception {
        try {
            if(StringUtils.isNoneBlank(isSelectUse)&&"1".equalsIgnoreCase(isSelectUse)){
                return templateManageService.findTemlateAddChildList(templateId,page,pageSize);
            }else if(StringUtils.isNoneBlank(isSelectUse)&&"2".equalsIgnoreCase(isSelectUse)){
                return templateManageService.findTemlateNotAddChildList(templateId,page,pageSize);
            } else {
                return templateManageService.findTemlateChildList(templateId,name,page,pageSize);
            }
        }catch (Exception e){
            e.printStackTrace();
            return failedMixEnvelopException(e);
        }
    }
    @GetMapping("/saveOrgTemplate")
    @ApiOperation(value = "保存租户模板")
    public Envelop saveSaasTemplate (
            @ApiParam(name = "orgCode", value = "orgCode")
            @RequestParam(value = "orgCode", required = false) String orgCode,
            @ApiParam(name = "templateIds", value = "")
            @RequestParam(value = "templateIds", required = false) String templateIds) throws Exception {
        try {
            templateManageService.saveUserTemplateRelation(orgCode,templateIds);
            return success("保存成功");
        }catch (Exception e){
            e.printStackTrace();
            return failedMixEnvelopException(e);
        }
    }
    @GetMapping("/findOrgTemplate")
    @ApiOperation(value = "保存租户模板")
    public Envelop saveSaasTemplate (
            @ApiParam(name = "orgCode", value = "orgCode")
            @RequestParam(value = "orgCode", required = false) String orgCode) throws Exception {
        try {
            return success(templateManageService.findUseTemplate(orgCode));
        }catch (Exception e){
            e.printStackTrace();
            return failedMixEnvelopException(e);
        }
    }
    @PostMapping("/excelControl/importDrugUse")
    @Transactional(rollbackFor = Exception.class)
    @ApiOperation(value = "基础药品用法列表导入")
    public Envelop importDrugUse(
            @ApiParam(name = "file", value = "文件", required = true)
            @RequestPart(value = "file") MultipartFile file,
            @ApiParam(name = "templateId", value = "templateId", required = false)
            @RequestPart(value = "templateId" ,required = false) String  templateId,
            HttpServletRequest request) throws IOException, ManageException {
        try {
            request.setCharacterEncoding("UTF-8");
//            AExcelReader excelReader = new BaseDoctorExcelDOReader();
            InputStream inputStream = file.getInputStream();
            Workbook workbook = getWorkbook(inputStream,file.getOriginalFilename());
            baseDrugUseExcelDOReader.read(workbook);
            //验证未通过(暂无验证)
            List<BasDrugUseExcelDO> errorLs = baseDrugUseExcelDOReader.getErrorLs();
            List<BasDrugUseExcelDO> correctLs = baseDrugUseExcelDOReader.getCorrectLs();
            Map<String, Object> result =new HashMap<>();
            String msg ="";
            if(correctLs.size()>0){
                result = baseDrugUseService.batchInsertDrugs(correctLs,templateId);
                result.put("errorLs", errorLs);
                int errors = errorLs.size();
                int corrects = correctLs.size();
                msg = "当前导入成功"+corrects+"条数据"+";失败"+errors+"条数据";
                return success(msg, result);
            }
            return success(msg, result);
        }catch (Exception e){
            e.printStackTrace();
            return failed("导入异常,请检查导入文件格式" + e.getMessage());
        }
    }
    @PostMapping("/excelControl/importfrequency")
    @Transactional(rollbackFor = Exception.class)
    @ApiOperation(value = "基础药品频次信息列表导入")
    public Envelop importfrequency(
            @ApiParam(name = "file", value = "文件", required = true)
            @RequestPart(value = "file") MultipartFile file,
            @ApiParam(name = "templateId", value = "templateId", required = false)
            @RequestPart(value = "templateId" ,required = false) String  templateId,
            HttpServletRequest request) throws IOException, ManageException {
        try {
            request.setCharacterEncoding("UTF-8");
//            AExcelReader excelReader = new BaseDoctorExcelDOReader();
            InputStream inputStream = file.getInputStream();
            Workbook workbook = getWorkbook(inputStream,file.getOriginalFilename());
            baseFrequencyExcelDOReader.read(workbook);
            //验证未通过(暂无验证)
            List<BasFrequencyExcelDO> errorLs = baseFrequencyExcelDOReader.getErrorLs();
            List<BasFrequencyExcelDO> correctLs = baseFrequencyExcelDOReader.getCorrectLs();
            Map<String, Object> result =new HashMap<>();
            String msg ="";
            if(correctLs.size()>0){
                 result = baseFrequencyService.batchInsertDrugs(correctLs,templateId);
                result.put("errorLs", errorLs);
                int errors = errorLs.size();
                int corrects = correctLs.size();
                msg = "当前导入成功"+corrects+"条数据"+";失败"+errors+"条数据";
            }
            return success(msg, result);
        }catch (Exception e){
            e.printStackTrace();
            return failed("导入异常,请检查导入文件格式" + e.getMessage());
        }
    }
    @PostMapping("/excelControl/importIcd10")
    @Transactional(rollbackFor = Exception.class)
    @ApiOperation(value = "基础诊断信息列表导入")
    public Envelop importIcd10(
            @ApiParam(name = "file", value = "文件", required = true)
            @RequestPart(value = "file") MultipartFile file,
            @ApiParam(name = "templateId", value = "templateId", required = false)
            @RequestPart(value = "templateId" ,required = false) String  templateId,
            HttpServletRequest request) throws IOException, ManageException {
        try {
            request.setCharacterEncoding("UTF-8");
//            AExcelReader excelReader = new BaseDoctorExcelDOReader();
            InputStream inputStream = file.getInputStream();
            Workbook workbook = getWorkbook(inputStream,file.getOriginalFilename());
            icd10ExcelDOReader.read(workbook);
            //验证未通过(暂无验证)
            List<BasIcd10ExcelDO> errorLs = icd10ExcelDOReader.getErrorLs();
            List<BasIcd10ExcelDO> correctLs = icd10ExcelDOReader.getCorrectLs();
            Map<String, Object> result =new HashMap<>();
            String msg ="";
            if(correctLs.size()>0){
                result = dictIcd10Service.batchInsertDrugs(correctLs,templateId);
                result.put("errorLs", errorLs);
                int errors = errorLs.size();
                int corrects = correctLs.size();
                msg = "当前导入成功"+corrects+"条数据"+";失败"+errors+"条数据";
            }
            return success(msg, result);
        }catch (Exception e){
            e.printStackTrace();
            return failed("导入异常,请检查导入文件格式" + e.getMessage());
        }
    }
    @GetMapping("/excelControl/exportExcel")
    public void exportExcel(HttpServletRequest request, HttpServletResponse response,@ApiParam(name = "templateId", value = "templateId", required = true)
    @RequestPart(value = "templateType") String  templateType) {
        try {
            String filePath="";
            if ("frequencyDict".equalsIgnoreCase(templateType)){
                filePath="/home/频次模板.xls";
            }else if ("drugUseDict".equalsIgnoreCase(templateType)){
                filePath="/home/用药类型模板.xls";
            }else if ("drugListDict".equalsIgnoreCase(templateType)){
                filePath="/home/药品字典模板.xls";
            }else if ("icd10ListDict".equalsIgnoreCase(templateType)){
                filePath="/home/诊断模板.xls";
            }
            HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(filePath));
// 根据页面index 获取sheet页
            HSSFSheet sheet = wb.getSheet("Sheet1");
            /*for (int i = 0; i < 2; i++) {
// 创建HSSFRow对象
                HSSFRow row = sheet.createRow(i + 1);
// 创建HSSFCell对象 设置单元格的值
                row.createCell(0).setCellValue("张三" + i);
                row.createCell(1).setCellValue("1");
                row.createCell(2).setCellValue("1");
                row.createCell(3).setCellValue("210503199507250333");
                row.createCell(4).setCellValue("18841409773");
                row.createCell(5).setCellValue("350211A1002/0000001/1303");
                row.createCell(6).setCellValue("1302");
                row.createCell(7).setCellValue("admin");
                row.createCell(8).setCellValue("1");
            }*/
// 输出Excel文件
            OutputStream output = new BufferedOutputStream(response.getOutputStream());
            response.reset();
// 设置文件头
            /*response.setHeader("Content-Disposition",
                    "attchement;filename=" + new String("人员信息.xls".getBytes("gb2312"), "ISO8859-1"));
            response.setContentType("application/msexcel");*/
            response.setCharacterEncoding("UTF-8");
            response.setContentType("application/x-msdownload");
            /*response.setHeader("Content-Disposition", "attachment; filename="
                    + new String( "医生模板信息".getBytes("gb2312"), "ISO8859-1" )+".xls");*/
            response.setHeader("Content-Disposition", "attachment; filename="
                    + URLEncoder.encode("医生模板信息.xls","UTF-8"));
            wb.write(output);
            wb.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @GetMapping("/findOneTemplate")
    @ApiOperation(value = "根据药品id查询")
    public Envelop findOneTemplate(@ApiParam(name = "id", value = "药品id")
                               @RequestParam(name = "id", required = true) String id){
        try {
            return success(templateManageService.findOneTemplateById(id));
        }catch (Exception e) {
            return failedException(e);
        }
    }
}

+ 183 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/BaseDrugDictService.java

@ -0,0 +1,183 @@
package com.yihu.jw.base.service.dict;
import com.yihu.jw.base.service.dict.importManage.BasDrugExcelDO;
import com.yihu.jw.base.service.doctor.excelImport.BaseDoctorExcelDO;
import com.yihu.jw.dict.dao.BaseDrugDictDao;
import com.yihu.jw.dict.dao.BaseTemplateDictDao;
import com.yihu.jw.entity.base.dict.*;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import static com.yihu.jw.util.common.BeanUtils.getNullPropertyNames;
@Service
public class BaseDrugDictService extends BaseJpaService<BaseDrugDictDO, BaseDrugDictDao> {
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private BaseDrugDictDao baseDrugDictDao;
    @Autowired
    private BaseTemplateDictDao baseTemplateDictDao;
    public BaseDrugDictDO saveNationalDrug(BaseDrugDictDO nationalDrugDictDO) {
        //判断新增或编辑
        if (!StringUtils.isNoneBlank(nationalDrugDictDO.getId())) {
            nationalDrugDictDO.setCreate_time(new Date());
            nationalDrugDictDO.setUpdate_time(new Date());
            nationalDrugDictDO.setIs_del("1");
            return baseDrugDictDao.save(nationalDrugDictDO);
        }else {
            System.out.println("===="+nationalDrugDictDO.getId());
            BaseDrugDictDO oldDurgDictDO =  baseDrugDictDao.findOne(nationalDrugDictDO.getId());
            BeanUtils.copyProperties(nationalDrugDictDO, oldDurgDictDO, getNullPropertyNames(nationalDrugDictDO));
            oldDurgDictDO.setUpdate_time(new Date());
            return baseDrugDictDao.save(oldDurgDictDO);
        }
    }
    public MixEnvelop  findDrugDict(String name,String status,Integer page,Integer pageSize){
        String sql = "select t.id as \"id\"," +
                " t.charge_code as \"charge_code\"," +
                " t.drugname as \"drugname\"," +
                " t.specification as \"specification\"," +
                " t.py_code as \"py_code\"," +
                " t.supply_code as \"supply_code\"," +
                " t.supply_name as \"supply_name\"," +
                " t.retprice as \"retprice\"," +
                " t.manu_name as \"manu_name\"," +
                " t.weigh_unit as \"weigh_unit\"," +
                " t.mini_unit_name as \"mini_unit_name\"," +
                " t.pack_unit_name as \"pack_unit_name\"," +
                " t.weigh_unit_name as \"weigh_unit_name\"," +
                " t.vol_unit_name as \"vol_unit_name\"," +
                " t.win_no as \"win_no\"," +
                " t.pack_retprice as \"pack_retprice\"," +
                " t.mini_unit as \"mini_unit\"," +
                " t.pack_size as \"pack_size\"," +
                " t.action as \"action\"," +
                " t.serial as \"serial\"," +
                " t.group_no as \"group_no\"," +
                " t.stock_amount as \"stock_amount\"," +
                " t.visible_flag as \"visible_flag\"," +
                " t.drug_flag as \"drug_flag\"," +
                " t.create_time as \"create_time\"," +
                " t.update_time as \"update_time\"," +
                " t.status as \"status\"," +
                " t.mini_stock_amount as \"mini_stock_amount\"," +
                " t.dosage as \"dosage\"," +
                " t.max_stock_amount as \"max_stock_amount\"," +
                " t.pack_unit as \"pack_unit\"," +
                " t.manufactory as \"manufactory\"," +
                " t.vol_unit as \"vol_unit\"," +
                " t.is_del as \"is_del\"" +
                " from base_drug_dict t " +
                " where t.is_del='1' ";
        String sqlCount = "select count(1) as \"count\" from base_drug_dict t where t.is_del='1' ";
        if (StringUtils.isNoneBlank(name)){
            sql+=" and t.drugname like '%"+name+"%'";
            sqlCount+=" and t.drugname like '%"+name+"%'";
        }
        if (StringUtils.isNoneBlank(status)){
            sql+=" and t.status = '"+status+"'";
            sqlCount+=" and t.status = '"+status+"'";
        }
        List<Map<String,Object>> coutList=hibenateUtils.createSQLQuery(sqlCount);
        Integer count=0 ;
        if (coutList!=null&&coutList.size()>0){
            count=Integer.valueOf(coutList.get(0).get("count").toString());
        }
        List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql,page,pageSize);
        for (Map<String,Object> map:list){
            if (map.get("status")!=null&&"1".equalsIgnoreCase(map.get("status").toString())){
                map.put("statusName","生效中");
            }else {
                map.put("statusName","已失效");
            }
        }
        MixEnvelop mixEnvelop = new MixEnvelop();
        mixEnvelop.setDetailModelList(list);
        mixEnvelop.setCurrPage(page);
        mixEnvelop.setPageSize(pageSize);
        mixEnvelop.setTotalCount(count);
        return mixEnvelop;
    }
    public BaseDrugDictDO findOneDrug(String id){
        return baseDrugDictDao.findOne(id);
    }
    public Map<String, Object> batchInsertDrugs(List<BasDrugExcelDO> drugs,String templateId) throws ManageException {
        Map<String, Object> result = new HashMap<>();
        //批量存储的集合
//        int correctCount = 0;
//        List<BasDrugExcelDO> corrects = new ArrayList<>();
        BaseDrugDictDO baseDrugDictDO;
        //批量存储
        for(BasDrugExcelDO one:drugs) {
            baseDrugDictDO = new BaseDrugDictDO();
            baseDrugDictDO.setCreate_time(new Date());
            baseDrugDictDO.setIs_del("1");
            baseDrugDictDO.setCharge_code(one.getCharge_code());
            baseDrugDictDO.setDosage(one.getDosage());
            baseDrugDictDO.setDrug_flag(one.getDrug_flag());
            baseDrugDictDO.setDrugname(one.getDrugname());
            baseDrugDictDO.setPack_retprice(one.getPack_retprice());
            baseDrugDictDO.setPack_size(one.getPack_size());
            baseDrugDictDO.setPack_unit_name(one.getPack_unit_name());
            baseDrugDictDO.setPack_unit(one.getPack_unit());
            baseDrugDictDO.setWin_no(one.getWin_no());
            baseDrugDictDO.setRetprice(one.getRetprice());
            baseDrugDictDO.setGroup_no(one.getGroup_no());
            baseDrugDictDO.setSerial(one.getSerial());
            baseDrugDictDO.setManu_name(one.getManu_name());
            baseDrugDictDO.setMax_stock_amount(one.getMax_stock_amount());
            baseDrugDictDO.setMini_stock_amount(one.getMini_stock_amount());
            baseDrugDictDO.setMini_unit(one.getMini_unit());
            baseDrugDictDO.setMini_unit_name(one.getMini_unit_name());
            baseDrugDictDO.setPy_code(one.getPy_code());
            baseDrugDictDO.setStock_amount(one.getStock_amount());
            baseDrugDictDO.setVisible_flag(one.getVisible_flag());
            baseDrugDictDO.setSpecification(one.getSpecification());
            baseDrugDictDO.setVol_unit_name(one.getVol_unit_name());
            baseDrugDictDO.setWeigh_unit(one.getWeigh_unit());
            baseDrugDictDO.setWeigh_unit_name(one.getWeigh_unit_name());
            baseDrugDictDO=baseDrugDictDao.save(baseDrugDictDO);
            if (StringUtils.isNoneBlank(templateId)){
                BaseTemplateDictDO baseTemplateDictDO = new BaseTemplateDictDO();
                baseTemplateDictDO.setTemplateId(templateId);
                baseTemplateDictDO.setIsDel("1");
                baseTemplateDictDO.setDictId(baseDrugDictDO.getId());
                baseTemplateDictDO.setCreateTime(new Date());
                baseTemplateDictDao.save(baseTemplateDictDO);
            }
        }
        result.put("correctCount", drugs.size());
        return result;
    }
    public void updateDrugStatus(String id,String status,String del){
        BaseDrugDictDO baseDrugDictDO = baseDrugDictDao.findOne(id);
        if (baseDrugDictDO!=null){
            if (StringUtils.isNoneBlank(status)){
                baseDrugDictDO.setStatus(status);
            }
            if (StringUtils.isNoneBlank(del)){
                baseDrugDictDO.setIs_del(del);
            }
            baseDrugDictDao.save(baseDrugDictDO);
        }
    }
}

+ 145 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/BaseDrugUseService.java

@ -0,0 +1,145 @@
package com.yihu.jw.base.service.dict;
import com.yihu.jw.base.service.dict.importManage.BasDrugExcelDO;
import com.yihu.jw.base.service.dict.importManage.BasDrugUseExcelDO;
import com.yihu.jw.dict.dao.BaseDrugDictDao;
import com.yihu.jw.dict.dao.BaseDrugUseDictDao;
import com.yihu.jw.dict.dao.BaseTemplateDictDao;
import com.yihu.jw.entity.base.dict.BaseDrugDictDO;
import com.yihu.jw.entity.base.dict.BaseDrugUseDictDO;
import com.yihu.jw.entity.base.dict.BaseTemplateDictDO;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.yihu.jw.util.common.BeanUtils.getNullPropertyNames;
@Service
public class BaseDrugUseService extends BaseJpaService<BaseDrugUseDictDO, BaseDrugUseDictDao> {
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private BaseDrugUseDictDao baseDrugUseDictDao;
    @Autowired
    private BaseTemplateDictDao baseTemplateDictDao;
    public void saveBaseDrugUse(BaseDrugUseDictDO baseDrugUseDictDO){
        if (StringUtils.isNotBlank(baseDrugUseDictDO.getId())){
            BaseDrugUseDictDO oldDurgDictDO= baseDrugUseDictDao.findOne(baseDrugUseDictDO.getId());
            BeanUtils.copyProperties(baseDrugUseDictDO, oldDurgDictDO, getNullPropertyNames(baseDrugUseDictDO));
            baseDrugUseDictDao.save(oldDurgDictDO);
        }else {
            baseDrugUseDictDO.setCreateTime(new Date());
            baseDrugUseDictDO.setDel_flag("1");
            baseDrugUseDictDao.save(baseDrugUseDictDO);
        }
    }
    public MixEnvelop findDrugUseList(String name,String status,Integer page ,Integer pageSize){
        String sql="select t.id as \"id\"," +
                " t.supply_code as \"supply_code\"," +
                " t.supply_name as \"supply_name\"," +
                " t.supply_occ as \"supply_occ\"," +
                " t.del_flag as \"del_flag\"," +
                " t.sort_code as \"sort_code\"," +
                " t.print_name as \"print_name\"," +
                " t.py_code as \"py_code\"," +
                " t.d_code as \"d_code\"," +
                " t.yb_name as \"yb_name\"," +
                " t.yb_code as \"yb_code\"," +
                " t.status as \"status\"," +
                " t.create_time as \"create_time\" " +
                "from base_drug_use_dict t " +
                " where t.del_flag='1'";
        String sqlCount =" select count(1) as \"count\" from base_drug_use_dict t where t.del_flag='1'";
        if (StringUtils.isNoneBlank(name)){
            sql+=" and t.supply_name like '%"+name+"%'";
            sqlCount+=" and t.supply_name like '%"+name+"%'";
        }
        if (StringUtils.isNoneBlank(status)){
            sql+=" and t.status ='"+status+"'";
            sqlCount+=" and t.status ='"+status+"'";
        }
        List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql,page,pageSize);
        for (Map<String,Object> map:list){
            if (map.get("status")!=null&&"1".equalsIgnoreCase(map.get("status").toString())){
                map.put("statusName","生效中");
            }else {
                map.put("statusName","已失效");
            }
        }
        List<Map<String,Object>> countList=hibenateUtils.createSQLQuery(sqlCount);
        Integer count=0;
        if (countList!=null&&countList.size()>0) {
            count = Integer.valueOf(countList.get(0).get("count").toString());
        }
        MixEnvelop mixEnvelop = new MixEnvelop();
        mixEnvelop.setPageSize(pageSize);
        mixEnvelop.setCurrPage(page);
        mixEnvelop.setDetailModelList(list);
        mixEnvelop.setTotalCount(count);
        return mixEnvelop;
    }
    public BaseDrugUseDictDO findOneUseDict(String dictId){
        return baseDrugUseDictDao.findOne(dictId);
    }
    public Map<String, Object> batchInsertDrugs(List<BasDrugUseExcelDO> drugs, String templateId) throws ManageException {
        Map<String, Object> result = new HashMap<>();
        //批量存储的集合
//        int correctCount = 0;
//        List<BasDrugExcelDO> corrects = new ArrayList<>();
        BaseDrugUseDictDO baseDrugUseDictDO;
        //批量存储
        for(BasDrugUseExcelDO one:drugs) {
            baseDrugUseDictDO = new BaseDrugUseDictDO();
            baseDrugUseDictDO.setCreateTime(new Date());
            baseDrugUseDictDO.setStatus("1");
            baseDrugUseDictDO.setDel_flag(one.getDel_flag());
            baseDrugUseDictDO.setD_code(one.getD_code());
            baseDrugUseDictDO.setPrint_name(one.getPrint_name());
            baseDrugUseDictDO.setPy_code(one.getPy_code());
            baseDrugUseDictDO.setSort_code(one.getSort_code());
            baseDrugUseDictDO.setSupply_code(one.getSupply_code());
            baseDrugUseDictDO.setSupply_name(one.getSupply_name());
            baseDrugUseDictDO.setSupply_occ(one.getSupply_occ());
            baseDrugUseDictDO.setYb_code(one.getYb_code());
            baseDrugUseDictDO.setYb_name(one.getYb_name());
            baseDrugUseDictDO=baseDrugUseDictDao.save(baseDrugUseDictDO);
            if (StringUtils.isNoneBlank(templateId)){
                BaseTemplateDictDO baseTemplateDictDO = new BaseTemplateDictDO();
                baseTemplateDictDO.setTemplateId(templateId);
                baseTemplateDictDO.setIsDel("1");
                baseTemplateDictDO.setDictId(baseDrugUseDictDO.getId());
                baseTemplateDictDO.setCreateTime(new Date());
                baseTemplateDictDao.save(baseTemplateDictDO);
            }
        }
        result.put("correctCount", drugs.size());
        return result;
    }
    public void updateDrugUseStatus(String id,String status,String del){
        BaseDrugUseDictDO baseDrugUseDictDO = baseDrugUseDictDao.findOne(id);
        if (baseDrugUseDictDO!=null){
            if (StringUtils.isNoneBlank(status)){
                baseDrugUseDictDO.setStatus(status);
            }
            if (StringUtils.isNoneBlank(del)){
                baseDrugUseDictDO.setDel_flag(del);
            }
            baseDrugUseDictDao.save(baseDrugUseDictDO);
        }
    }
}

+ 137 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/BaseFrequencyService.java

@ -0,0 +1,137 @@
package com.yihu.jw.base.service.dict;
import com.yihu.jw.base.service.dict.importManage.BasDrugUseExcelDO;
import com.yihu.jw.base.service.dict.importManage.BasFrequencyExcelDO;
import com.yihu.jw.dict.dao.BaseDrugUseDictDao;
import com.yihu.jw.dict.dao.BaseFrequencyDictDao;
import com.yihu.jw.dict.dao.BaseTemplateDictDao;
import com.yihu.jw.entity.base.dict.BaseDrugUseDictDO;
import com.yihu.jw.entity.base.dict.BaseFrequencyDictDO;
import com.yihu.jw.entity.base.dict.BaseTemplateDictDO;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.yihu.jw.util.common.BeanUtils.getNullPropertyNames;
@Service
public class BaseFrequencyService extends BaseJpaService<BaseFrequencyDictDO, BaseFrequencyDictDao> {
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private BaseFrequencyDictDao baseFrequencyDictDao;
    @Autowired
    private BaseTemplateDictDao baseTemplateDictDao;
    public void saveFrequency(BaseFrequencyDictDO baseFrequencyDictDO){
        if (StringUtils.isNotBlank(baseFrequencyDictDO.getId())){
            BaseFrequencyDictDO oldFrequency= baseFrequencyDictDao.findOne(baseFrequencyDictDO.getId());
            BeanUtils.copyProperties(baseFrequencyDictDO, oldFrequency, getNullPropertyNames(baseFrequencyDictDO));
            baseFrequencyDictDao.save(oldFrequency);
        }else {
            baseFrequencyDictDO.setCreateTime(new Date());
            baseFrequencyDictDO.setIs_del("1");
            baseFrequencyDictDao.save(baseFrequencyDictDO);
        }
    }
    public MixEnvelop findFrequencyList(String name, String status, Integer page , Integer pageSize){
        String sql="select t.id as \"id\"," +
                " t.freq_code as \"freq_code\"," +
                " t.freq_name as \"freq_name\"," +
                " t.freq_sp as \"freq_sp\"," +
                " t.daily_times as \"daily_times\"," +
                " t.weekly_times as \"weekly_times\"," +
                " t.hosp_code as \"hosp_code\"," +
                " t.is_del as \"is_del\"," +
                " t.is_op_ip as \"is_op_ip\"," +
                " t.status as \"status\"," +
                " t.create_time as \"create_time\"" +
                "from base_frequency_dict t " +
                " where t.is_del='1'";
        String sqlCount =" select count(1) as \"count\" from base_frequency_dict t where t.is_del='1'";
        if (StringUtils.isNoneBlank(name)){
            sql+=" and (t.freq_code like '%"+name+"%' or t.freq_name like '%"+name+"%')";
            sqlCount+=" and (t.freq_code like '%"+name+"%' or t.freq_name like '%"+name+"%')";
        }
        if (StringUtils.isNoneBlank(status)){
            sql+=" and t.status ='"+status+"'";
            sqlCount+=" and t.status ='"+status+"'";
        }
        List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql,page,pageSize);
        for (Map<String,Object> map:list){
            if (map.get("status")!=null&&"1".equalsIgnoreCase(map.get("status").toString())){
                map.put("statusName","生效中");
            }else {
                map.put("statusName","已失效");
            }
        }
        List<Map<String,Object>> countList=hibenateUtils.createSQLQuery(sqlCount);
        Integer count=0;
        if (countList!=null&&countList.size()>0) {
            count = Integer.valueOf(countList.get(0).get("count").toString());
        }
        MixEnvelop mixEnvelop = new MixEnvelop();
        mixEnvelop.setPageSize(pageSize);
        mixEnvelop.setCurrPage(page);
        mixEnvelop.setDetailModelList(list);
        mixEnvelop.setTotalCount(count);
        return mixEnvelop;
    }
    public BaseFrequencyDictDO findOneFrequency(String id){
        return baseFrequencyDictDao.findOne(id);
    }
    public Map<String, Object> batchInsertDrugs(List<BasFrequencyExcelDO> drugs, String templateId) throws ManageException {
        Map<String, Object> result = new HashMap<>();
        //批量存储的集合
//        int correctCount = 0;
//        List<BasDrugExcelDO> corrects = new ArrayList<>();
        BaseFrequencyDictDO baseFrequencyDictDO;
        //批量存储
        for(BasFrequencyExcelDO one:drugs) {
            baseFrequencyDictDO = new BaseFrequencyDictDO();
            baseFrequencyDictDO.setCreateTime(new Date());
            baseFrequencyDictDO.setIs_del("1");
            baseFrequencyDictDO.setDaily_times(one.getDaily_times());
            baseFrequencyDictDO.setFreq_code(one.getFreq_code());
            baseFrequencyDictDO.setFreq_name(one.getFreq_name());
            baseFrequencyDictDO.setFreq_sp(one.getFreq_sp());
            baseFrequencyDictDO.setHosp_code(one.getHosp_code());
            baseFrequencyDictDO.setIs_op_ip(one.getIs_op_ip());
            baseFrequencyDictDO.setStatus(one.getStatus());
            baseFrequencyDictDO.setWeekly_times(one.getWeekly_times());
            baseFrequencyDictDO=baseFrequencyDictDao.save(baseFrequencyDictDO);
            if (StringUtils.isNoneBlank(templateId)){
                BaseTemplateDictDO baseTemplateDictDO = new BaseTemplateDictDO();
                baseTemplateDictDO.setTemplateId(templateId);
                baseTemplateDictDO.setIsDel("1");
                baseTemplateDictDO.setDictId(baseFrequencyDictDO.getId());
                baseTemplateDictDO.setCreateTime(new Date());
                baseTemplateDictDao.save(baseTemplateDictDO);
            }
        }
        result.put("correctCount", drugs.size());
        return result;
    }
    public void updateFrequencyStatus(String id,String status,String del){
        BaseFrequencyDictDO baseFrequencyDictDO = baseFrequencyDictDao.findOne(id);
        if (baseFrequencyDictDO!=null){
            if (StringUtils.isNotBlank(status)){
                baseFrequencyDictDO.setStatus(status);
            }
            if (StringUtils.isNotBlank(del)){
                baseFrequencyDictDO.setIs_del(del);
            }
            baseFrequencyDictDao.save(baseFrequencyDictDO);
        }
    }
}

+ 122 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/DictIcd10Service.java

@ -3,16 +3,25 @@ package com.yihu.jw.base.service.dict;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.base.dao.dict.DictIcd10Dao;
import com.yihu.jw.base.enums.SystemDictEnum;
import com.yihu.jw.base.service.dict.importManage.BasDrugUseExcelDO;
import com.yihu.jw.base.service.dict.importManage.BasIcd10ExcelDO;
import com.yihu.jw.dict.dao.BaseTemplateDictDao;
import com.yihu.jw.entity.base.dict.BaseDrugUseDictDO;
import com.yihu.jw.entity.base.dict.BaseTemplateDictDO;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import com.yihu.jw.entity.base.dict.DictIcd10DO;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.*;
import static com.yihu.jw.util.common.BeanUtils.getNullPropertyNames;
/**
 * 
@ -31,6 +40,10 @@ public class DictIcd10Service extends BaseJpaService<DictIcd10DO, DictIcd10Dao>
    @Autowired
    private DictIcd10Dao dictIcd10Dao;
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private BaseTemplateDictDao baseTemplateDictDao;
    /**
     * 查询某一租户下的Icd10字典信息,如果saadId为空表示当前用户角色为超级管理员,超级管理员可以看到所有数据
@ -56,4 +69,110 @@ public class DictIcd10Service extends BaseJpaService<DictIcd10DO, DictIcd10Dao>
        dictIcd10Dao.delete(id);
    }
    public MixEnvelop findIcd10List(String name,String status,Integer page ,Integer pageSize){
        String sql="select t.id as \"id\"," +
                " t.code as \"code\"," +
                " t.name as \"name\"," +
                " t.description as \"description\"," +
                " t.create_time as \"create_time\"," +
                " t.disea_reason as \"disea_reason\"," +
                " t.death_reason as \"death_reason\"," +
                " t.py_code as \"py_code\"," +
                " t.d_code as \"d_code\"," +
                " t.flag as \"flag\"," +
                " t.is_del as \"is_del\"," +
                " t.status as \"status\" " +
                "from dict_icd10 t " +
                " where t.is_del='1'";
        String sqlCount =" select count(1) as \"count\" from dict_icd10 t where t.is_del='1'";
        if (StringUtils.isNoneBlank(name)){
            sql+=" and t.name like '%"+name+"%'";
            sqlCount+=" and t.name like '%"+name+"%'";
        }
        if (StringUtils.isNoneBlank(status)){
            sql+=" and t.status ='"+status+"'";
            sqlCount+=" and t.status ='"+status+"'";
        }
        List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql,page,pageSize);
        for (Map<String,Object> map:list){
            if (map.get("status")!=null&&"1".equalsIgnoreCase(map.get("status").toString())){
                map.put("statusName","生效中");
            }else {
                map.put("statusName","已失效");
            }
        }
        List<Map<String,Object>> countList=hibenateUtils.createSQLQuery(sqlCount);
        Integer count=0;
        if (countList!=null&&countList.size()>0) {
            count = Integer.valueOf(countList.get(0).get("count").toString());
        }
        MixEnvelop mixEnvelop = new MixEnvelop();
        mixEnvelop.setPageSize(pageSize);
        mixEnvelop.setCurrPage(page);
        mixEnvelop.setDetailModelList(list);
        mixEnvelop.setTotalCount(count);
        return mixEnvelop;
    }
    public void saveIcd10(DictIcd10DO icd10DO){
        if (icd10DO.getId()!=null){
            DictIcd10DO icd10DO1= dictIcd10Dao.findOne(icd10DO.getId());
            BeanUtils.copyProperties(icd10DO, icd10DO1, getNullPropertyNames(icd10DO));
            dictIcd10Dao.save(icd10DO1);
        }else {
            icd10DO.setCreateTime(new Date());
            icd10DO.setIs_del("1");
            dictIcd10Dao.save(icd10DO);
        }
    }
    public DictIcd10DO findOneIcd10(Integer id){
        return dictIcd10Dao.findOne(id);
    }
    public Map<String, Object> batchInsertDrugs(List<BasIcd10ExcelDO> drugs, String templateId) throws ManageException {
        Map<String, Object> result = new HashMap<>();
        //批量存储的集合
//        int correctCount = 0;
//        List<BasDrugExcelDO> corrects = new ArrayList<>();
        DictIcd10DO dictIcd10DO;
        //批量存储
        for(BasIcd10ExcelDO one:drugs) {
            dictIcd10DO = new DictIcd10DO();
            dictIcd10DO.setCreateTime(new Date());
            dictIcd10DO.setIs_del("1");
            dictIcd10DO.setCode(one.getCode());
            dictIcd10DO.setD_code(one.getD_code());
            dictIcd10DO.setName(one.getName());
            dictIcd10DO.setPy_code(one.getPy_code());
            dictIcd10DO.setDeath_reason(one.getDeath_reason());
            dictIcd10DO.setDescription(one.getDescription());
            dictIcd10DO.setDisea_reason(one.getDisea_reason());
            dictIcd10DO.setFlag(one.getFlag());
            dictIcd10DO.setStatus(one.getStatus());
            dictIcd10DO=dictIcd10Dao.save(dictIcd10DO);
            if (StringUtils.isNoneBlank(templateId)){
                BaseTemplateDictDO baseTemplateDictDO = new BaseTemplateDictDO();
                baseTemplateDictDO.setTemplateId(templateId);
                baseTemplateDictDO.setIsDel("1");
                baseTemplateDictDO.setDictId(dictIcd10DO.getId().toString());
                baseTemplateDictDO.setCreateTime(new Date());
                baseTemplateDictDao.save(baseTemplateDictDO);
            }
        }
        result.put("correctCount", drugs.size());
        return result;
    }
    public void updateIcd10Status(Integer id,String status,String del){
        DictIcd10DO dictIcd10DO = dictIcd10Dao.findOne(id);
        if (dictIcd10DO!=null){
            if (StringUtils.isNoneBlank(status)){
                dictIcd10DO.setStatus(status);
            }
            if (StringUtils.isNoneBlank(del)){
                dictIcd10DO.setIs_del(del);
            }
            dictIcd10Dao.save(dictIcd10DO);
        }
    }
}

+ 682 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/TemplateManageService.java

@ -0,0 +1,682 @@
package com.yihu.jw.base.service.dict;
import com.yihu.jw.base.dao.saas.SaasDao;
import com.yihu.jw.dict.dao.*;
import com.yihu.jw.entity.base.dict.*;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.xerces.dom.PSVIAttrNSImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import java.util.*;
@Service
public class TemplateManageService {
    @Autowired
    private BaseDrugDictDao baseDrugDictDao;
    @Autowired
    private BaseTemplateDao baseTemplateDao;
    @Autowired
    private BaseTemplateDictDao baseTemplateDictDao;
    @Autowired
    private BaseTemplateOrgDao baseTemplateOrgDao;
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private BaseDrugUseDictDao baseDrugUseDictDao;
    @Autowired
    private BaseFrequencyDictDao baseFrequencyDictDao;
    @Autowired
    private BaseDictIcd10Dao baseDictIcd10Dao;
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Autowired
    private SaasDao saasDao;
    @Autowired
    private BaseOrgDao baseOrgDao;
    public MixEnvelop findTempalte(String templateType,String code,String name,Integer page ,Integer pageSize){
        String sql =" select t.id as \"id\" ," +
                " t.name as \"name\"," +
                " t.code as \"code\"," +
                " t.children_count as \"childrenCount\"," +
                " t.update_user as \"updateUser\"," +
                " t.update_user_name as \"updateUserName\"," +
                " t.update_time as \"updateTime\"," +
                " t.template_type as \"templateType\"," +
                " t.is_del as \"isDel\" " +
                " from base_template t " +
                " where t.is_del='1' ";
        String sqlCount=" select count(1) as \"count\" from base_template t where t.is_del='1'";
        if (StringUtils.isNotBlank(templateType)){
            sql+= " and t.template_type='"+templateType+"'";
            sqlCount+= " and t.template_type='"+templateType+"'";
        }
        if (StringUtils.isNotBlank(code)){
            sql+= " and t.code like '%"+code+"%'";
            sqlCount+= " and t.code like '%"+code+"%'";
        }
        if (StringUtils.isNotBlank(name)){
            sql+= " and t.name like '%"+name+"%'";
            sqlCount+= " and t.name like '%"+name+"%'";
        }
        sql+=" order by t.update_time desc";
        Integer count=0;
        List<Map<String,Object>> countList=hibenateUtils.createSQLQuery(sqlCount);
        if (countList!=null&&countList.size()>0){
            count = Integer.parseInt(countList.get(0).get("count").toString());
        }
        List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql,page,pageSize);
        for (Map<String,Object> map:list){
            List<BaseTemplateOrgDO> orgTemplate=baseTemplateOrgDao.findByTemplateId(map.get("id").toString());
            List<String> orgNames= new ArrayList<>();
            int i=0;
            for (BaseTemplateOrgDO baseTemplateOrgDO :orgTemplate){
                orgNames.add(baseTemplateOrgDO.getOrgName());
            }
            map.put("orgNames",orgNames.toString());
        }
        MixEnvelop mixEnvelop = new MixEnvelop();
        mixEnvelop.setDetailModelList(list);
        mixEnvelop.setPageSize(pageSize);
        mixEnvelop.setCurrPage(page);
        mixEnvelop.setTotalCount(count);
        return mixEnvelop;
    }
   public void addOrRemoveChildrenDict(String templateId,String dictId,String isDel){
       BaseTemplateDictDO baseTemplateDictDO = baseTemplateDictDao.findByDictIdAndTemplateId(dictId,templateId);
       if ("1".equalsIgnoreCase(isDel)){
           if (baseTemplateDictDO!=null){
               baseTemplateDictDO.setIsDel("1");
           }else {
               baseTemplateDictDO = new BaseTemplateDictDO();
               baseTemplateDictDO.setTemplateId(templateId);
               baseTemplateDictDO.setDictId(dictId);
               baseTemplateDictDO.setCreateTime(new Date());
               baseTemplateDictDO.setIsDel("1");
           }
       }else {
           if (baseTemplateDictDO!=null){
               baseTemplateDictDO.setIsDel("0");
           }else {
               return;
           }
       }
       baseTemplateDictDao.save(baseTemplateDictDO);
       BaseTemplateDO baseTemplateDO = baseTemplateDao.findOne(templateId);
       Integer chuildrenCount =  baseTemplateDictDao.getCountByTemplateId(templateId);
       if (baseTemplateDO !=null ){
           baseTemplateDO.setChildrenCount(chuildrenCount.toString());
       }
       baseTemplateDao.save(baseTemplateDO);
   }
   public void saveOrUpdateTemplate(String templateId,String code,String name,String user,String userName,String templateType){
       BaseTemplateDO baseTemplateDO = baseTemplateDao.findOne(templateId);
       String localCode="MD"+new Date().getTime();
       System.out.println("templatType"+templateType);
       if (baseTemplateDO!=null){
           baseTemplateDO.setCode(localCode);
           baseTemplateDO.setName(name);
           baseTemplateDO.setUpdateTime(new Date());
           baseTemplateDO.setUpdateUser(user);
           baseTemplateDO.setUpdateUserName(userName);
           baseTemplateDO.setTemplateType(templateType);
       }else {
           baseTemplateDO = new BaseTemplateDO();
           baseTemplateDO.setCode(localCode);
           baseTemplateDO.setName(name);
           baseTemplateDO.setCreateTime(new Date());
           baseTemplateDO.setCreateUser(user);
           baseTemplateDO.setCreateUserName(userName);
           baseTemplateDO.setTemplateType(templateType);
           baseTemplateDO.setIsDel("1");
       }
       baseTemplateDao.save(baseTemplateDO);
   }
   public MixEnvelop findTemlateChildList(String templateId,String name,Integer page,Integer pageSize){
        BaseTemplateDO baseTemplateDictDO = baseTemplateDao.findOne(templateId);
        PageRequest pageRequest = new PageRequest(page-1, pageSize);
        List<Map<String,Object>> returnList= new ArrayList<>();
        MixEnvelop mixEnvelop = new MixEnvelop();
        mixEnvelop.setPageSize(pageSize);
        mixEnvelop.setCurrPage(page);
        if (baseTemplateDictDO!=null){
            if ("frequencyDict".equalsIgnoreCase(baseTemplateDictDO.getTemplateType())){
                List<BaseFrequencyDictDO> list= new ArrayList<>();
                if (StringUtils.isNoneBlank(name)){
                    list= baseFrequencyDictDao.findByNameDel(name,pageRequest);
                }else {
                    list= baseFrequencyDictDao.findByDel(pageRequest);
                }
                Integer count = baseFrequencyDictDao.getconuntByDel();
                for (BaseFrequencyDictDO baseFrequencyDictDO:list){
                    Map<String,Object> map = new HashMap<>();
                    map.put("templateDetail",baseTemplateDictDO);
                    map.put("id",baseFrequencyDictDO.getId());
                    map.put("code",baseFrequencyDictDO.getFreq_code());
                    map.put("name",baseFrequencyDictDO.getFreq_name());
                    map.put("py_code",baseFrequencyDictDO.getFreq_sp());
                    map.put("daily_times",baseFrequencyDictDO.getDaily_times());
                    map.put("weekly_times",baseFrequencyDictDO.getWeekly_times());
                    BaseTemplateDictDO baseTemplateDictDO1= baseTemplateDictDao.findByDictIdAndTemplateId(baseFrequencyDictDO.getId(),templateId);
                    if (baseTemplateDictDO1!=null){
                        map.put("isAdd",1);
                    }else {
                        map.put("isAdd",0);
                    }
                    returnList.add(map);
                }
                mixEnvelop.setDetailModelList(returnList);
                mixEnvelop.setTotalCount(count);
                return mixEnvelop;
            }else if ("drugUseDict".equalsIgnoreCase(baseTemplateDictDO.getTemplateType())){
                List<BaseDrugUseDictDO> list= new ArrayList<>();
                if (StringUtils.isNoneBlank(name)){
                    list= baseDrugUseDictDao.findByNameDel(name,pageRequest);
                }else {
                    list= baseDrugUseDictDao.findByDel(pageRequest);
                }
                Integer count = baseDrugUseDictDao.getconuntByDel();
                for (BaseDrugUseDictDO baseDrugUseDictDO:list){
                    Map<String,Object> map = new HashMap<>();
                    map.put("id",baseDrugUseDictDO.getId());
                    map.put("templateDetail",baseTemplateDictDO);
                    map.put("code",baseDrugUseDictDO.getSupply_code());
                    map.put("name",baseDrugUseDictDO.getSupply_name());
                    map.put("py_code",baseDrugUseDictDO.getPy_code());
                    BaseTemplateDictDO baseTemplateDictDO1= baseTemplateDictDao.findByDictIdAndTemplateId(baseDrugUseDictDO.getId(),templateId);
                    if (baseTemplateDictDO1!=null){
                        map.put("isAdd",1);
                    }else {
                        map.put("isAdd",0);
                    }
                    returnList.add(map);
                }
                mixEnvelop.setDetailModelList(returnList);
                mixEnvelop.setTotalCount(count);
                return mixEnvelop;
            }else if ("drugListDict".equalsIgnoreCase(baseTemplateDictDO.getTemplateType())){
                List<BaseDrugDictDO> list= new ArrayList<>();
                if (StringUtils.isNoneBlank(name)){
                    list= baseDrugDictDao.findByNameDel(name,pageRequest);
                }else {
                    list= baseDrugDictDao.findByDel(pageRequest);
                }
                Integer count = baseDrugDictDao.getconuntByDel();
                for (BaseDrugDictDO baseDrugDictDO:list){
                    Map<String,Object> map = new HashMap<>();
                    map.put("id",baseDrugDictDO.getId());
                    map.put("templateDetail",baseTemplateDictDO);
                    map.put("code",baseDrugDictDO.getCharge_code());
                    map.put("name",baseDrugDictDO.getDrugname());
                    map.put("dosage",baseDrugDictDO.getDosage());
                    map.put("specification",baseDrugDictDO.getSpecification());
                    map.put("stock_amount",baseDrugDictDO.getStock_amount());
                    map.put("manu_name",baseDrugDictDO.getManu_name());
                    BaseTemplateDictDO baseTemplateDictDO1= baseTemplateDictDao.findByDictIdAndTemplateId(baseDrugDictDO.getId(),templateId);
                    if (baseTemplateDictDO1!=null){
                        map.put("isAdd",1);
                    }else {
                        map.put("isAdd",0);
                    }
                    returnList.add(map);
                }
                mixEnvelop.setDetailModelList(returnList);
                mixEnvelop.setTotalCount(count);
                return mixEnvelop;
            }else if ("icd10ListDict".equalsIgnoreCase(baseTemplateDictDO.getTemplateType())){
                List<DictIcd10DO> list= new ArrayList<>();
                if (StringUtils.isNoneBlank(name)){
                    list= baseDictIcd10Dao.findByNameDel(name,pageRequest);
                }else {
                    list= baseDictIcd10Dao.findByDel(pageRequest);
                }
                Integer count = baseDrugDictDao.getconuntByDel();
                for (DictIcd10DO dictIcd10DO:list){
                    Map<String,Object> map = new HashMap<>();
                    map.put("templateDetail",baseTemplateDictDO);
                    map.put("id",dictIcd10DO.getId());
                    map.put("code",dictIcd10DO.getCode());
                    map.put("name",dictIcd10DO.getName());
                    map.put("disea_reason",dictIcd10DO.getDisea_reason());
                    map.put("death_reason",dictIcd10DO.getDeath_reason());
                    map.put("py_code",dictIcd10DO.getPy_code());
                    map.put("d_code",dictIcd10DO.getD_code());
                    map.put("flag",dictIcd10DO.getFlag());
                    BaseTemplateDictDO baseTemplateDictDO1= baseTemplateDictDao.findByDictIdAndTemplateId(dictIcd10DO.getId().toString(),templateId);
                    if (baseTemplateDictDO1!=null){
                        map.put("isAdd",1);
                    }else {
                        map.put("isAdd",0);
                    }
                    returnList.add(map);
                }
                mixEnvelop.setDetailModelList(returnList);
                mixEnvelop.setTotalCount(count);
                return mixEnvelop;
            }else {
                return null;
            }
        }else {
            return null;
        }
   }
   public  BaseTemplateDO findOneTemplateById(String id){
        return baseTemplateDao.findOne(id);
   }
    public void saveUserTemplateRelation(String orgCode,String templateIds){
        String[] templateArray = templateIds.split(",");
        BaseOrgDO baseOrgDO= baseOrgDao.findByCode(orgCode);
        String orgName="";
        if (baseOrgDO!=null){
            orgName=baseOrgDO.getName();
        }
        for (int i=0;i<templateArray.length;i++){
            String templateId=templateArray[i];
            BaseTemplateDO baseTemplateDO = baseTemplateDao.findOne(templateId);
            if (baseTemplateDO!=null){
                String templateType = baseTemplateDO.getTemplateType();
                BaseTemplateOrgDO baseTemplateOrgDO=baseTemplateOrgDao.findByOrgCodeAndtemplateType(orgCode,templateType);
                if (baseTemplateOrgDO!=null){
                    if (baseTemplateOrgDO.getTemplateId().equalsIgnoreCase(templateId)){
                        baseTemplateOrgDO.setIsDel("1");
                        baseTemplateOrgDao.save(baseTemplateOrgDO);
                    }else {
                        baseTemplateOrgDO.setIsDel("0");
                        BaseTemplateOrgDO baseTemplateOrgNew=new BaseTemplateOrgDO();
                        baseTemplateOrgNew.setOrgCode(orgCode);
                        baseTemplateOrgNew.setOrgName(orgName);
                        baseTemplateOrgNew.setIsDel("1");
                        baseTemplateOrgNew.setTemplateId(templateId);
                        baseTemplateOrgNew.setTemplateType(templateType);
                        baseTemplateOrgDao.save(baseTemplateOrgDO);
                        baseTemplateOrgDao.save(baseTemplateOrgNew);
                    }
                }else {
                    baseTemplateOrgDO = new BaseTemplateOrgDO();
                    baseTemplateOrgDO.setOrgCode(orgCode);
                    baseTemplateOrgDO.setOrgName(orgName);
                    baseTemplateOrgDO.setIsDel("1");
                    baseTemplateOrgDO.setTemplateId(templateId);
                    baseTemplateOrgDO.setTemplateType(templateType);
                }
                baseTemplateOrgDao.save(baseTemplateOrgDO);
            }
        }
    }
    public Map<String,Object> findUseTemplate(String orgCode){
        List<BaseTemplateOrgDO> list = baseTemplateOrgDao.findByOrgCode(orgCode);
        List<WlyyHospitalSysDictDO> wlyyHospitalSysDictDOS = wlyyHospitalSysDictDao.findByDictName("dictManageList");
        Map map = new HashMap();
        for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:wlyyHospitalSysDictDOS){
            for (BaseTemplateOrgDO baseTemplateOrgDO:list){
                if (wlyyHospitalSysDictDO.getDictCode().equalsIgnoreCase(baseTemplateOrgDO.getTemplateType())){
                    map.put(wlyyHospitalSysDictDO.getDictCode(),baseTemplateOrgDO);
                }
            }
        }
        return  map;
    }
    public MixEnvelop findTemlateAddChildList(String templateId,Integer page,Integer pageSize){
        BaseTemplateDO baseTemplateDictDO = baseTemplateDao.findOne(templateId);
        MixEnvelop mixEnvelop = new MixEnvelop();
        mixEnvelop.setPageSize(pageSize);
        mixEnvelop.setCurrPage(page);
        if (baseTemplateDictDO!=null){
            if ("frequencyDict".equalsIgnoreCase(baseTemplateDictDO.getTemplateType())){
                String sql="select t.id as \"id\"," +
                        " t.freq_code as \"freq_code\"," +
                        " t.freq_name as \"freq_name\"," +
                        " t.freq_sp as \"freq_sp\"," +
                        " t.daily_times as \"daily_times\"," +
                        " t.weekly_times as \"weekly_times\"," +
                        " t.hosp_code as \"hosp_code\"," +
                        " t.is_del as \"is_del\"," +
                        " t.is_op_ip as \"is_op_ip\"," +
                        " t.status as \"status\"," +
                        " t.create_time as \"create_time\"" +
                        "from base_template_dict b left join  base_frequency_dict t on b.dict_id=t.id" +
                        " where t.is_del='1' and b.is_del='1' ";
                String sqlCount =" select count(1) as \"count\" from base_template_dict b left join  base_frequency_dict t on b.dict_id=t.id" +
                        "  where t.is_del='1 and b.is_del='1'";
                sql+=" and b.template_id = '"+baseTemplateDictDO.getId()+"'";
                sqlCount+=" and b.template_id = '"+baseTemplateDictDO.getId()+"'";
                List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql,page,pageSize);
                for (Map<String,Object> map:list){
                    if (map.get("status")!=null&&"1".equalsIgnoreCase(map.get("status").toString())){
                        map.put("statusName","生效中");
                    }else {
                        map.put("statusName","已失效");
                    }
                }
                List<Map<String,Object>> countList=hibenateUtils.createSQLQuery(sqlCount);
                Integer count=0;
                if (countList!=null&&countList.size()>0) {
                    count = Integer.valueOf(countList.get(0).get("count").toString());
                }
                mixEnvelop.setDetailModelList(list);
                mixEnvelop.setTotalCount(count);
                return mixEnvelop;
            }else if ("drugUseDict".equalsIgnoreCase(baseTemplateDictDO.getTemplateType())){
                String sql="select t.id as \"id\"," +
                        " t.supply_code as \"supply_code\"," +
                        " t.supply_name as \"supply_name\"," +
                        " t.supply_occ as \"supply_occ\"," +
                        " t.del_flag as \"del_flag\"," +
                        " t.sort_code as \"sort_code\"," +
                        " t.print_name as \"print_name\"," +
                        " t.py_code as \"py_code\"," +
                        " t.d_code as \"d_code\"," +
                        " t.yb_name as \"yb_name\"," +
                        " t.yb_code as \"yb_code\"," +
                        " t.status as \"status\"," +
                        " t.create_time as \"create_time\" " +
                        "from  base_template_dict b left join base_drug_use_dict t on b.dict_id=t.id" +
                        " where t.del_flag='1' and b.is_del='1'";
                String sqlCount =" select count(1) as \"count\" from  base_template_dict b left join base_drug_use_dict t on b.dict_id=t.id" +
                        " where t.del_flag='1 and b.is_del='1'";
                sql+=" and b.template_id = '"+baseTemplateDictDO.getId()+"'";
                sqlCount+=" and b.template_id = '"+baseTemplateDictDO.getId()+"'";
                List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql,page,pageSize);
                for (Map<String,Object> map:list){
                    if (map.get("status")!=null&&"1".equalsIgnoreCase(map.get("status").toString())){
                        map.put("statusName","生效中");
                    }else {
                        map.put("statusName","已失效");
                    }
                }
                List<Map<String,Object>> countList=hibenateUtils.createSQLQuery(sqlCount);
                Integer count=0;
                if (countList!=null&&countList.size()>0) {
                    count = Integer.valueOf(countList.get(0).get("count").toString());
                }
                mixEnvelop.setDetailModelList(list);
                mixEnvelop.setTotalCount(count);
                return mixEnvelop;
            }else if ("drugListDict".equalsIgnoreCase(baseTemplateDictDO.getTemplateType())){
                String sql = "select t.id as \"id\"," +
                        " t.charge_code as \"charge_code\"," +
                        " t.drugname as \"drugname\"," +
                        " t.specification as \"specification\"," +
                        " t.py_code as \"py_code\"," +
                        " t.supply_code as \"supply_code\"," +
                        " t.supply_name as \"supply_name\"," +
                        " t.retprice as \"retprice\"," +
                        " t.manu_name as \"manu_name\"," +
                        " t.weigh_unit as \"weigh_unit\"," +
                        " t.mini_unit_name as \"mini_unit_name\"," +
                        " t.pack_unit_name as \"pack_unit_name\"," +
                        " t.weigh_unit_name as \"weigh_unit_name\"," +
                        " t.vol_unit_name as \"vol_unit_name\"," +
                        " t.win_no as \"win_no\"," +
                        " t.pack_retprice as \"pack_retprice\"," +
                        " t.mini_unit as \"mini_unit\"," +
                        " t.pack_size as \"pack_size\"," +
                        " t.action as \"action\"," +
                        " t.serial as \"serial\"," +
                        " t.group_no as \"group_no\"," +
                        " t.stock_amount as \"stock_amount\"," +
                        " t.visible_flag as \"visible_flag\"," +
                        " t.drug_flag as \"drug_flag\"," +
                        " t.create_time as \"create_time\"," +
                        " t.update_time as \"update_time\"," +
                        " t.status as \"status\"," +
                        " t.mini_stock_amount as \"mini_stock_amount\"," +
                        " t.dosage as \"dosage\"," +
                        " t.max_stock_amount as \"max_stock_amount\"," +
                        " t.pack_unit as \"pack_unit\"," +
                        " t.is_del as \"is_del\"" +
                        " from base_template_dict b left join base_drug_dict t on b.dict_id = t.id " +
                        " where t.is_del='1' and b.is_del='1'";
                String sqlCount = "select count(1) as \"count\" from base_template_dict b left join base_drug_dict t on b.dict_id = t.id " +
                        " where t.is_del='1'and b.is_del='1' ";
                sql+=" and b.template_id = '"+baseTemplateDictDO.getId()+"'";
                sqlCount+=" and b.template_id = '"+baseTemplateDictDO.getId()+"'";
                List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql,page,pageSize);
                for (Map<String,Object> map:list){
                    if (map.get("status")!=null&&"1".equalsIgnoreCase(map.get("status").toString())){
                        map.put("statusName","生效中");
                    }else {
                        map.put("statusName","已失效");
                    }
                }
                List<Map<String,Object>> countList=hibenateUtils.createSQLQuery(sqlCount);
                Integer count=0;
                if (countList!=null&&countList.size()>0) {
                    count = Integer.valueOf(countList.get(0).get("count").toString());
                }
                mixEnvelop.setDetailModelList(list);
                mixEnvelop.setTotalCount(count);
                return mixEnvelop;
            }else if ("icd10ListDict".equalsIgnoreCase(baseTemplateDictDO.getTemplateType())){
                String sql="select t.id as \"id\"," +
                        " t.code as \"code\"," +
                        " t.name as \"name\"," +
                        " t.description as \"description\"," +
                        " t.create_time as \"create_time\"," +
                        " t.disea_reason as \"disea_reason\"," +
                        " t.death_reason as \"death_reason\"," +
                        " t.py_code as \"py_code\"," +
                        " t.d_code as \"d_code\"," +
                        " t.flag as \"flag\"," +
                        " t.is_del as \"is_del\"," +
                        " t.status as \"status\" " +
                        " from base_template_dict b left join dict_icd10 t on b.dict_id=t.id" +
                        " where t.is_del='1' and b.is_del='1'";
                String sqlCount =" select count(1) as \"count\" from base_template_dict b left join dict_icd10 t on b.dict_id=t.id" +
                        " where t.is_del='1' and b.is_del='1'";
                sql+=" and b.template_id = '"+baseTemplateDictDO.getId()+"'";
                sqlCount+=" and b.template_id = '"+baseTemplateDictDO.getId()+"'";
                List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql,page,pageSize);
                for (Map<String,Object> map:list){
                    if (map.get("status")!=null&&"1".equalsIgnoreCase(map.get("status").toString())){
                        map.put("statusName","生效中");
                    }else {
                        map.put("statusName","已失效");
                    }
                }
                List<Map<String,Object>> countList=hibenateUtils.createSQLQuery(sqlCount);
                Integer count=0;
                if (countList!=null&&countList.size()>0) {
                    count = Integer.valueOf(countList.get(0).get("count").toString());
                }
                mixEnvelop.setDetailModelList(list);
                mixEnvelop.setTotalCount(count);
                return mixEnvelop;
            }else {
                return null;
            }
        }else {
            return null;
        }
    }
    public MixEnvelop findTemlateNotAddChildList(String templateId,Integer page,Integer pageSize){
        BaseTemplateDO baseTemplateDictDO = baseTemplateDao.findOne(templateId);
        MixEnvelop mixEnvelop = new MixEnvelop();
        mixEnvelop.setPageSize(pageSize);
        mixEnvelop.setCurrPage(page);
        if (baseTemplateDictDO!=null){
            if ("frequencyDict".equalsIgnoreCase(baseTemplateDictDO.getTemplateType())){
                String sql="select DISTINCT t.id as \"id\"," +
                        " t.freq_code as \"freq_code\"," +
                        " t.freq_name as \"freq_name\"," +
                        " t.freq_sp as \"freq_sp\"," +
                        " t.daily_times as \"daily_times\"," +
                        " t.weekly_times as \"weekly_times\"," +
                        " t.hosp_code as \"hosp_code\"," +
                        " t.is_del as \"is_del\"," +
                        " t.is_op_ip as \"is_op_ip\"," +
                        " t.status as \"status\"," +
                        " t.create_time as \"create_time\"" +
                        " from  base_frequency_dict t where t.id not in ( SELECT DISTINCT g.id from base_frequency_dict g left join base_template_dict " +
                        "m on g.id = m.dict_id " +
                        "where m.template_id ='"+templateId+"')";
                String sqlCount =" select count(1) as \"count\" from  base_frequency_dict t where t.id not in ( SELECT DISTINCT g.id from base_frequency_dict g left join base_template_dict " +
                        "m on g.id = m.dict_id " +
                        "where m.template_id ='"+templateId+"')";
                List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql,page,pageSize);
                for (Map<String,Object> map:list){
                    if (map.get("status")!=null&&"1".equalsIgnoreCase(map.get("status").toString())){
                        map.put("statusName","生效中");
                    }else {
                        map.put("statusName","已失效");
                    }
                }
                List<Map<String,Object>> countList=hibenateUtils.createSQLQuery(sqlCount);
                Integer count=0;
                if (countList!=null&&countList.size()>0) {
                    count = Integer.valueOf(countList.get(0).get("count").toString());
                }
                mixEnvelop.setDetailModelList(list);
                mixEnvelop.setTotalCount(count);
                return mixEnvelop;
            }else if ("drugUseDict".equalsIgnoreCase(baseTemplateDictDO.getTemplateType())){
                String sql="select DISTINCT t.id as \"id\"," +
                        " t.supply_code as \"supply_code\"," +
                        " t.supply_name as \"supply_name\"," +
                        " t.supply_occ as \"supply_occ\"," +
                        " t.del_flag as \"del_flag\"," +
                        " t.sort_code as \"sort_code\"," +
                        " t.print_name as \"print_name\"," +
                        " t.py_code as \"py_code\"," +
                        " t.d_code as \"d_code\"," +
                        " t.yb_name as \"yb_name\"," +
                        " t.yb_code as \"yb_code\"," +
                        " t.status as \"status\"," +
                        " t.create_time as \"create_time\" " +
                        " from  base_drug_use_dict t where t.id not in ( SELECT DISTINCT g.id from base_drug_use_dict g left join base_template_dict " +
                        "m on g.id = m.dict_id " +
                        "where m.template_id ='"+templateId+"')";
                String sqlCount =" select count(1) as \"count\" from  base_drug_use_dict t where t.id not in ( SELECT DISTINCT g.id from base_drug_use_dict g left join base_template_dict " +
                        "m on g.id = m.dict_id " +
                        "where m.template_id ='"+templateId+"')";
                List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql,page,pageSize);
                for (Map<String,Object> map:list){
                    if (map.get("status")!=null&&"1".equalsIgnoreCase(map.get("status").toString())){
                        map.put("statusName","生效中");
                    }else {
                        map.put("statusName","已失效");
                    }
                }
                List<Map<String,Object>> countList=hibenateUtils.createSQLQuery(sqlCount);
                Integer count=0;
                if (countList!=null&&countList.size()>0) {
                    count = Integer.valueOf(countList.get(0).get("count").toString());
                }
                mixEnvelop.setDetailModelList(list);
                mixEnvelop.setTotalCount(count);
                return mixEnvelop;
            }else if ("drugListDict".equalsIgnoreCase(baseTemplateDictDO.getTemplateType())){
                String sql = "select DISTINCT t.id as \"id\"," +
                        " t.charge_code as \"charge_code\"," +
                        " t.drugname as \"drugname\"," +
                        " t.specification as \"specification\"," +
                        " t.py_code as \"py_code\"," +
                        " t.supply_code as \"supply_code\"," +
                        " t.supply_name as \"supply_name\"," +
                        " t.retprice as \"retprice\"," +
                        " t.manu_name as \"manu_name\"," +
                        " t.weigh_unit as \"weigh_unit\"," +
                        " t.mini_unit_name as \"mini_unit_name\"," +
                        " t.pack_unit_name as \"pack_unit_name\"," +
                        " t.weigh_unit_name as \"weigh_unit_name\"," +
                        " t.vol_unit_name as \"vol_unit_name\"," +
                        " t.win_no as \"win_no\"," +
                        " t.pack_retprice as \"pack_retprice\"," +
                        " t.mini_unit as \"mini_unit\"," +
                        " t.pack_size as \"pack_size\"," +
                        " t.action as \"action\"," +
                        " t.serial as \"serial\"," +
                        " t.group_no as \"group_no\"," +
                        " t.stock_amount as \"stock_amount\"," +
                        " t.visible_flag as \"visible_flag\"," +
                        " t.drug_flag as \"drug_flag\"," +
                        " t.create_time as \"create_time\"," +
                        " t.update_time as \"update_time\"," +
                        " t.status as \"status\"," +
                        " t.mini_stock_amount as \"mini_stock_amount\"," +
                        " t.dosage as \"dosage\"," +
                        " t.max_stock_amount as \"max_stock_amount\"," +
                        " t.pack_unit as \"pack_unit\"," +
                        " t.is_del as \"is_del\"" +
                        " from  base_drug_dict t where t.id not in ( SELECT DISTINCT g.id from base_drug_dict g left join base_template_dict " +
                        " m on g.id = m.dict_id " +
                        "where m.template_id ='"+templateId+"')";
                String sqlCount = "select count(1) as \"count\"  from  base_drug_dict t where t.id not in ( SELECT DISTINCT g.id from base_drug_dict g left join base_template_dict " +
                        "m on g.id = m.dict_id " +
                        "where m.template_id ='"+templateId+"')";
                List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql,page,pageSize);
                for (Map<String,Object> map:list){
                    if (map.get("status")!=null&&"1".equalsIgnoreCase(map.get("status").toString())){
                        map.put("statusName","生效中");
                    }else {
                        map.put("statusName","已失效");
                    }
                }
                List<Map<String,Object>> countList=hibenateUtils.createSQLQuery(sqlCount);
                Integer count=0;
                if (countList!=null&&countList.size()>0) {
                    count = Integer.valueOf(countList.get(0).get("count").toString());
                }
                mixEnvelop.setDetailModelList(list);
                mixEnvelop.setTotalCount(count);
                return mixEnvelop;
            }else if ("icd10ListDict".equalsIgnoreCase(baseTemplateDictDO.getTemplateType())){
                String sql="select DISTINCT t.id as \"id\"," +
                        " t.code as \"code\"," +
                        " t.name as \"name\"," +
                        " t.description as \"description\"," +
                        " t.create_time as \"create_time\"," +
                        " t.disea_reason as \"disea_reason\"," +
                        " t.death_reason as \"death_reason\"," +
                        " t.py_code as \"py_code\"," +
                        " t.d_code as \"d_code\"," +
                        " t.flag as \"flag\"," +
                        " t.is_del as \"is_del\"," +
                        " t.status as \"status\" " +
                        " from  dict_icd10 t where t.id not in ( SELECT DISTINCT g.id from dict_icd10 g left join base_template_dict " +
                        "m on g.id = m.dict_id " +
                        "where m.template_id ='"+templateId+"')";
                String sqlCount =" select count(1) as \"count\" from  dict_icd10 t where t.id not in ( SELECT DISTINCT g.id from dict_icd10 g left join base_template_dict " +
                        "m on g.id = m.dict_id " +
                        "where m.template_id ='"+templateId+"')";
                List<Map<String,Object>> list=hibenateUtils.createSQLQuery(sql,page,pageSize);
                for (Map<String,Object> map:list){
                    if (map.get("status")!=null&&"1".equalsIgnoreCase(map.get("status").toString())){
                        map.put("statusName","生效中");
                    }else {
                        map.put("statusName","已失效");
                    }
                }
                List<Map<String,Object>> countList=hibenateUtils.createSQLQuery(sqlCount);
                Integer count=0;
                if (countList!=null&&countList.size()>0) {
                    count = Integer.valueOf(countList.get(0).get("count").toString());
                }
                mixEnvelop.setDetailModelList(list);
                mixEnvelop.setTotalCount(count);
                return mixEnvelop;
            }else {
                return null;
            }
        }else {
            return null;
        }
    }
}

+ 304 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/importManage/BasDrugExcelDO.java

@ -0,0 +1,304 @@
package com.yihu.jw.base.service.dict.importManage;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.excel.ExcelUtil;
import com.yihu.jw.util.excel.Validation;
import com.yihu.jw.util.excel.annotation.Location;
import com.yihu.jw.util.excel.annotation.Row;
import com.yihu.jw.util.excel.annotation.Title;
import com.yihu.jw.util.excel.annotation.ValidRepeat;
import java.util.Date;
import java.util.Map;
import java.util.Set;
/**
 *  医生信息列表-excel实体类
 * @author lith
 * Created at 2018/10/22.
 */
@Row(start = 1)
//@Title(names= "{'姓名', '状态(1生效,0失效)','性别(1男2女)', '身份证号', '联系方式', '机构/部门/职务', '职称','归属业务模块角色','是否名医','专长','简介'}")
public class BasDrugExcelDO extends ExcelUtil implements Validation {
    @Location(x=0)
    @ValidRepeat
    String charge_code;
    @Location(x=1)
    @ValidRepeat
    String serial;
    @Location(x=2)
    @ValidRepeat
    String  group_no;//
    @Location(x=3)
    @ValidRepeat
    String drugname;
    @Location(x=4)
    @ValidRepeat
    String dosage;//
    @Location(x=5)
    @ValidRepeat
    String mini_unit;
    @Location(x=6)
    @ValidRepeat
    String pack_size;
    @Location(x=7)
    @ValidRepeat
    String specification;//
    @Location(x=8)
    @ValidRepeat
    String retprice;
    @Location(x=9)
    @ValidRepeat
    String pack_retprice;
    @Location(x=10)
    @ValidRepeat
    String stock_amount;
    @Location(x=11)
    @ValidRepeat
    String  visible_flag;
    @Location(x=12)
    @ValidRepeat
    String  drug_flag;
    @Location(x=13)
    @ValidRepeat
    String  py_code;
    @Location(x=14)
    @ValidRepeat
    String  pack_unit;
    @Location(x=15)
    @ValidRepeat
    String  manu_name;
    @Location(x=16)
    @ValidRepeat
    String  weigh_unit;
    @Location(x=17)
    @ValidRepeat
    String  vol_unit;
    @Location(x=18)
    @ValidRepeat
    String  mini_unit_name;
    @Location(x=19)
    @ValidRepeat
    String  pack_unit_name;
    @Location(x=20)
    @ValidRepeat
    String  weigh_unit_name;
    @Location(x=21)
    @ValidRepeat
    String  vol_unit_name;
    @Location(x=22)
    @ValidRepeat
    String  win_no;
    @Location(x=23)
    @ValidRepeat
    String  max_stock_amount;
    @Location(x=24)
    @ValidRepeat
    String  mini_stock_amount;
    @Override
    public int validate(Map<String, Set> repeatMap) {
        int rs = 1;
        return rs;
    }
    public String getCharge_code() {
        return charge_code;
    }
    public void setCharge_code(String charge_code) {
        this.charge_code = charge_code;
    }
    public String getSerial() {
        return serial;
    }
    public void setSerial(String serial) {
        this.serial = serial;
    }
    public String getGroup_no() {
        return group_no;
    }
    public void setGroup_no(String group_no) {
        this.group_no = group_no;
    }
    public String getDrugname() {
        return drugname;
    }
    public void setDrugname(String drugname) {
        this.drugname = drugname;
    }
    public String getDosage() {
        return dosage;
    }
    public void setDosage(String dosage) {
        this.dosage = dosage;
    }
    public String getMini_unit() {
        return mini_unit;
    }
    public void setMini_unit(String mini_unit) {
        this.mini_unit = mini_unit;
    }
    public String getPack_size() {
        return pack_size;
    }
    public void setPack_size(String pack_size) {
        this.pack_size = pack_size;
    }
    public String getSpecification() {
        return specification;
    }
    public void setSpecification(String specification) {
        this.specification = specification;
    }
    public String getRetprice() {
        return retprice;
    }
    public void setRetprice(String retprice) {
        this.retprice = retprice;
    }
    public String getPack_retprice() {
        return pack_retprice;
    }
    public void setPack_retprice(String pack_retprice) {
        this.pack_retprice = pack_retprice;
    }
    public String getStock_amount() {
        return stock_amount;
    }
    public void setStock_amount(String stock_amount) {
        this.stock_amount = stock_amount;
    }
    public String getVisible_flag() {
        return visible_flag;
    }
    public void setVisible_flag(String visible_flag) {
        this.visible_flag = visible_flag;
    }
    public String getDrug_flag() {
        return drug_flag;
    }
    public void setDrug_flag(String drug_flag) {
        this.drug_flag = drug_flag;
    }
    public String getPy_code() {
        return py_code;
    }
    public void setPy_code(String py_code) {
        this.py_code = py_code;
    }
    public String getPack_unit() {
        return pack_unit;
    }
    public void setPack_unit(String pack_unit) {
        this.pack_unit = pack_unit;
    }
    public String getManu_name() {
        return manu_name;
    }
    public void setManu_name(String manu_name) {
        this.manu_name = manu_name;
    }
    public String getWeigh_unit() {
        return weigh_unit;
    }
    public void setWeigh_unit(String weigh_unit) {
        this.weigh_unit = weigh_unit;
    }
    public String getVol_unit() {
        return vol_unit;
    }
    public void setVol_unit(String vol_unit) {
        this.vol_unit = vol_unit;
    }
    public String getMini_unit_name() {
        return mini_unit_name;
    }
    public void setMini_unit_name(String mini_unit_name) {
        this.mini_unit_name = mini_unit_name;
    }
    public String getPack_unit_name() {
        return pack_unit_name;
    }
    public void setPack_unit_name(String pack_unit_name) {
        this.pack_unit_name = pack_unit_name;
    }
    public String getWeigh_unit_name() {
        return weigh_unit_name;
    }
    public void setWeigh_unit_name(String weigh_unit_name) {
        this.weigh_unit_name = weigh_unit_name;
    }
    public String getVol_unit_name() {
        return vol_unit_name;
    }
    public void setVol_unit_name(String vol_unit_name) {
        this.vol_unit_name = vol_unit_name;
    }
    public String getWin_no() {
        return win_no;
    }
    public void setWin_no(String win_no) {
        this.win_no = win_no;
    }
    public String getMax_stock_amount() {
        return max_stock_amount;
    }
    public void setMax_stock_amount(String max_stock_amount) {
        this.max_stock_amount = max_stock_amount;
    }
    public String getMini_stock_amount() {
        return mini_stock_amount;
    }
    public void setMini_stock_amount(String mini_stock_amount) {
        this.mini_stock_amount = mini_stock_amount;
    }
}

+ 142 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/importManage/BasDrugUseExcelDO.java

@ -0,0 +1,142 @@
package com.yihu.jw.base.service.dict.importManage;
import com.yihu.jw.util.excel.ExcelUtil;
import com.yihu.jw.util.excel.Validation;
import com.yihu.jw.util.excel.annotation.Location;
import com.yihu.jw.util.excel.annotation.Row;
import com.yihu.jw.util.excel.annotation.Title;
import com.yihu.jw.util.excel.annotation.ValidRepeat;
import java.util.Map;
import java.util.Set;
/**
 *  医生信息列表-excel实体类
 * @author lith
 * Created at 2018/10/22.
 */
@Row(start = 1)
//@Title(names= "{'姓名', '状态(1生效,0失效)','性别(1男2女)', '身份证号', '联系方式', '机构/部门/职务', '职称','归属业务模块角色','是否名医','专长','简介'}")
public class BasDrugUseExcelDO extends ExcelUtil implements Validation {
    @Location(x=0)
    @ValidRepeat
    String supply_code;
    @Location(x=1)
    @ValidRepeat
    String supply_name;
    @Location(x=2)
    @ValidRepeat
    String  supply_occ;//
    @Location(x=3)
    @ValidRepeat
    String del_flag;
    @Location(x=4)
    @ValidRepeat
    String sort_code;//
    @Location(x=5)
    @ValidRepeat
    String print_name;
    @Location(x=6)
    @ValidRepeat
    String py_code;
    @Location(x=7)
    @ValidRepeat
    String d_code;//
    @Location(x=8)
    @ValidRepeat
    String yb_name;
    @Location(x=9)
    @ValidRepeat
    String yb_code;
    public String getSupply_code() {
        return supply_code;
    }
    public void setSupply_code(String supply_code) {
        this.supply_code = supply_code;
    }
    public String getSupply_name() {
        return supply_name;
    }
    public void setSupply_name(String supply_name) {
        this.supply_name = supply_name;
    }
    public String getSupply_occ() {
        return supply_occ;
    }
    public void setSupply_occ(String supply_occ) {
        this.supply_occ = supply_occ;
    }
    public String getDel_flag() {
        return del_flag;
    }
    public void setDel_flag(String del_flag) {
        this.del_flag = del_flag;
    }
    public String getSort_code() {
        return sort_code;
    }
    public void setSort_code(String sort_code) {
        this.sort_code = sort_code;
    }
    public String getPrint_name() {
        return print_name;
    }
    public void setPrint_name(String print_name) {
        this.print_name = print_name;
    }
    public String getPy_code() {
        return py_code;
    }
    public void setPy_code(String py_code) {
        this.py_code = py_code;
    }
    public String getD_code() {
        return d_code;
    }
    public void setD_code(String d_code) {
        this.d_code = d_code;
    }
    public String getYb_name() {
        return yb_name;
    }
    public void setYb_name(String yb_name) {
        this.yb_name = yb_name;
    }
    public String getYb_code() {
        return yb_code;
    }
    public void setYb_code(String yb_code) {
        this.yb_code = yb_code;
    }
    @Override
    public int validate(Map<String, Set> repeatMap) {
        int rs = 1;
        return rs;
    }
}

+ 119 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/importManage/BasFrequencyExcelDO.java

@ -0,0 +1,119 @@
package com.yihu.jw.base.service.dict.importManage;
import com.yihu.jw.util.excel.ExcelUtil;
import com.yihu.jw.util.excel.Validation;
import com.yihu.jw.util.excel.annotation.Location;
import com.yihu.jw.util.excel.annotation.Row;
import com.yihu.jw.util.excel.annotation.Title;
import com.yihu.jw.util.excel.annotation.ValidRepeat;
import java.util.Map;
import java.util.Set;
/**
 *  医生信息列表-excel实体类
 * @author lith
 * Created at 2018/10/22.
 */
@Row(start = 1)
//@Title(names= "{'姓名', '状态(1生效,0失效)','性别(1男2女)', '身份证号', '联系方式', '机构/部门/职务', '职称','归属业务模块角色','是否名医','专长','简介'}")
public class BasFrequencyExcelDO extends ExcelUtil implements Validation {
    @Location(x=0)
    @ValidRepeat
    String freq_code;
    @Location(x=1)
    @ValidRepeat
    String freq_name;
    @Location(x=2)
    @ValidRepeat
    String  freq_sp;//
    @Location(x=3)
    @ValidRepeat
    String daily_times;
    @Location(x=4)
    @ValidRepeat
    String weekly_times;//
    @Location(x=5)
    @ValidRepeat
    String hosp_code;
    @Location(x=6)
    @ValidRepeat
    String is_op_ip;
    @Location(x=7)
    @ValidRepeat
    String status;
    public String getFreq_code() {
        return freq_code;
    }
    public void setFreq_code(String freq_code) {
        this.freq_code = freq_code;
    }
    public String getFreq_name() {
        return freq_name;
    }
    public void setFreq_name(String freq_name) {
        this.freq_name = freq_name;
    }
    public String getFreq_sp() {
        return freq_sp;
    }
    public void setFreq_sp(String freq_sp) {
        this.freq_sp = freq_sp;
    }
    public String getDaily_times() {
        return daily_times;
    }
    public void setDaily_times(String daily_times) {
        this.daily_times = daily_times;
    }
    public String getWeekly_times() {
        return weekly_times;
    }
    public void setWeekly_times(String weekly_times) {
        this.weekly_times = weekly_times;
    }
    public String getHosp_code() {
        return hosp_code;
    }
    public void setHosp_code(String hosp_code) {
        this.hosp_code = hosp_code;
    }
    public String getIs_op_ip() {
        return is_op_ip;
    }
    public void setIs_op_ip(String is_op_ip) {
        this.is_op_ip = is_op_ip;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    @Override
    public int validate(Map<String, Set> repeatMap) {
        int rs = 1;
        return rs;
    }
}

+ 127 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/importManage/BasIcd10ExcelDO.java

@ -0,0 +1,127 @@
package com.yihu.jw.base.service.dict.importManage;
import com.yihu.jw.util.excel.ExcelUtil;
import com.yihu.jw.util.excel.Validation;
import com.yihu.jw.util.excel.annotation.Location;
import com.yihu.jw.util.excel.annotation.Row;
import com.yihu.jw.util.excel.annotation.ValidRepeat;
import java.util.Map;
import java.util.Set;
/**
 *  医生信息列表-excel实体类
 * @author lith
 * Created at 2018/10/22.
 */
@Row(start = 1)
//@Title(names= "{'姓名', '状态(1生效,0失效)','性别(1男2女)', '身份证号', '联系方式', '机构/部门/职务', '职称','归属业务模块角色','是否名医','专长','简介'}")
public class BasIcd10ExcelDO extends ExcelUtil implements Validation {
    @Location(x=0)
    @ValidRepeat
    String code;
    @Location(x=1)
    @ValidRepeat
    String name;
    @Location(x=2)
    @ValidRepeat
    String  description;//
    @Location(x=3)
    @ValidRepeat
    String disea_reason;
    @Location(x=4)
    @ValidRepeat
    String death_reason;//
    @Location(x=5)
    @ValidRepeat
    String py_code;
    @Location(x=6)
    @ValidRepeat
    String d_code;
    @Location(x=7)
    @ValidRepeat
    String flag;//
    @Location(x=8)
    @ValidRepeat
    String status;
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public String getDisea_reason() {
        return disea_reason;
    }
    public void setDisea_reason(String disea_reason) {
        this.disea_reason = disea_reason;
    }
    public String getDeath_reason() {
        return death_reason;
    }
    public void setDeath_reason(String death_reason) {
        this.death_reason = death_reason;
    }
    public String getPy_code() {
        return py_code;
    }
    public void setPy_code(String py_code) {
        this.py_code = py_code;
    }
    public String getD_code() {
        return d_code;
    }
    public void setD_code(String d_code) {
        this.d_code = d_code;
    }
    public String getFlag() {
        return flag;
    }
    public void setFlag(String flag) {
        this.flag = flag;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    @Override
    public int validate(Map<String, Set> repeatMap) {
        int rs = 1;
        return rs;
    }
}

+ 136 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/importManage/BaseDrugExcelDOReader.java

@ -0,0 +1,136 @@
package com.yihu.jw.base.service.dict.importManage;
import com.yihu.jw.base.dao.dict.DictJobTitleDao;
import com.yihu.jw.base.dao.doctor.BaseDoctorRoleDictDao;
import com.yihu.jw.base.dao.doctor.BaseDoctorRoleInfoDao;
import com.yihu.jw.base.endpoint.common.excel.AExcelReader;
import com.yihu.jw.dict.dao.BaseDrugDictDao;
import com.yihu.jw.dict.dao.BaseTemplateDictDao;
import com.yihu.jw.dict.dao.DictDoctorDutyDao;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.dict.BaseDrugDictDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.org.dao.BaseOrgDao;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
/**
 * 医生信息列表-excel解析类
 * Created by 刘文彬 on 2018/10/24.
 */
@Component
public class BaseDrugExcelDOReader extends AExcelReader {
    @Autowired
    private BaseDrugDictDao baseDrugDictDao;
    @Autowired
    private BaseTemplateDictDao baseTemplateDictDao;
    @Override
    public void read(Workbook rwb) throws Exception {
        try{
            Iterator<Sheet> sheets = rwb.sheetIterator();
            int j = 0, rows;
            BasDrugExcelDO basDrugExcelDO;
            getRepeat().put("charge_code", new HashSet<>());
            getRepeat().put("serial", new HashSet<>());
            getRepeat().put("group_no", new HashSet<>());
            getRepeat().put("drugname", new HashSet<>());
            getRepeat().put("dosage", new HashSet<>());
            getRepeat().put("mini_unit", new HashSet<>());
            getRepeat().put("pack_size", new HashSet<>());
            getRepeat().put("specification", new HashSet<>());
            getRepeat().put("retprice", new HashSet<>());
            getRepeat().put("pack_retprice", new HashSet<>());
            getRepeat().put("stock_amount", new HashSet<>());
            getRepeat().put("visible_flag", new HashSet<>());
            getRepeat().put("drug_flag", new HashSet<>());
            getRepeat().put("py_code", new HashSet<>());
            getRepeat().put("pack_unit", new HashSet<>());
            getRepeat().put("manu_name", new HashSet<>());
            getRepeat().put("weigh_unit", new HashSet<>());
            getRepeat().put("vol_unit", new HashSet<>());
            getRepeat().put("mini_unit_name", new HashSet<>());
            getRepeat().put("pack_unit_name", new HashSet<>());
            getRepeat().put("weigh_unit_name", new HashSet<>());
            getRepeat().put("vol_unit_name", new HashSet<>());
            getRepeat().put("win_no", new HashSet<>());
            getRepeat().put("max_stock_amount", new HashSet<>());
            getRepeat().put("mini_stock_amount", new HashSet<>());
            errorLs.clear();
            correctLs.clear();
            while (sheets.hasNext()){
                Sheet sheet = sheets.next();
                if ((rows = sheet.getLastRowNum()) == 0) {
                    continue;
                }
                for (int i = 1; i <= rows; i++) {
                    basDrugExcelDO = new BasDrugExcelDO();
                    basDrugExcelDO.setCharge_code(replaceBlank(getCellCont(sheet, i, 0)));
                    basDrugExcelDO.setSerial(replaceBlank(getCellCont(sheet, i, 1)));
                    basDrugExcelDO.setGroup_no(getCellCont(sheet, i, 2));
                    basDrugExcelDO.setDrugname(replaceBlank(getCellCont(sheet, i, 3)));
                    basDrugExcelDO.setDosage(replaceBlank(getCellCont(sheet, i, 4)));
                    basDrugExcelDO.setMini_unit(replaceBlank(getCellCont(sheet, i, 5)));
                    basDrugExcelDO.setPack_size(replaceBlank(getCellCont(sheet, i, 6)));
                    basDrugExcelDO.setSpecification(replaceBlank(getCellCont(sheet, i, 7)));
                    basDrugExcelDO.setRetprice(getCellCont(sheet, i, 8));
                    basDrugExcelDO.setPack_retprice(replaceBlank(getCellCont(sheet, i, 9)));
                    basDrugExcelDO.setStock_amount(replaceBlank(getCellCont(sheet, i, 10)));
                    basDrugExcelDO.setVisible_flag(replaceBlank(getCellCont(sheet, i, 11)));
                    basDrugExcelDO.setDrug_flag(replaceBlank(getCellCont(sheet, i, 12)));
                    basDrugExcelDO.setPy_code(replaceBlank(getCellCont(sheet, i, 13)));
                    basDrugExcelDO.setPack_unit(replaceBlank(getCellCont(sheet, i, 14)));
                    basDrugExcelDO.setManu_name(replaceBlank(getCellCont(sheet, i, 15)));
                    basDrugExcelDO.setWeigh_unit(replaceBlank(getCellCont(sheet, i, 16)));
                    basDrugExcelDO.setVol_unit(replaceBlank(getCellCont(sheet, i, 17)));
                    basDrugExcelDO.setMini_unit_name(replaceBlank(getCellCont(sheet, i, 18)));
                    basDrugExcelDO.setPack_unit_name(replaceBlank(getCellCont(sheet, i, 19)));
                    basDrugExcelDO.setWeigh_unit_name(replaceBlank(getCellCont(sheet, i, 20)));
                    basDrugExcelDO.setVol_unit_name(replaceBlank(getCellCont(sheet, i, 21)));
                    basDrugExcelDO.setWin_no(replaceBlank(getCellCont(sheet, i, 22)));
                    basDrugExcelDO.setMax_stock_amount(replaceBlank(getCellCont(sheet, i, 23)));
                    basDrugExcelDO.setMini_stock_amount(replaceBlank(getCellCont(sheet, i, 24)));
                    basDrugExcelDO.setExcelSeq(i);
                    int rs = basDrugExcelDO.validate(repeat);
                    if (validate(basDrugExcelDO)== 0||rs == 0) {
                        errorLs.add(basDrugExcelDO);
                    } else if (rs == 1) {
                        correctLs.add(basDrugExcelDO);
                    }
                }
                j++;
            }
        }catch (Exception e){
            e.printStackTrace();
            throw e;
        }finally {
            if (rwb != null) {
                rwb.close();
            }
        }
    }
    public int validate(BasDrugExcelDO basDrugExcelDO) {
        int rs = 1;
        if (StringUtils.isNoneBlank(basDrugExcelDO.getDosage())){
            List<BaseDrugDictDO> list  = baseDrugDictDao.findByCodeAndNameAndDosage(basDrugExcelDO.getCharge_code(),basDrugExcelDO.getDrugname(),basDrugExcelDO.getDosage());
            System.out.println("当前导入数据:"+ basDrugExcelDO.getCharge_code());
            if (list!=null&&list.size()>0){
                System.out.println("进验证有重复数据"+list.get(0).getCharge_code());
                return 0;
            }
        }
        return rs;
    }
}

+ 101 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/importManage/BaseDrugUseExcelDOReader.java

@ -0,0 +1,101 @@
package com.yihu.jw.base.service.dict.importManage;
import com.yihu.jw.base.endpoint.common.excel.AExcelReader;
import com.yihu.jw.dict.dao.BaseDrugDictDao;
import com.yihu.jw.dict.dao.BaseDrugUseDictDao;
import com.yihu.jw.dict.dao.BaseTemplateDictDao;
import com.yihu.jw.entity.base.dict.BaseDrugDictDO;
import com.yihu.jw.entity.base.dict.BaseDrugUseDictDO;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
/**
 * 医生信息列表-excel解析类
 * Created by 刘文彬 on 2018/10/24.
 */
@Component
public class BaseDrugUseExcelDOReader extends AExcelReader {
    @Autowired
    private BaseDrugUseDictDao baseDrugUseDictDao;
    @Autowired
    private BaseTemplateDictDao baseTemplateDictDao;
    @Override
    public void read(Workbook rwb) throws Exception {
        try{
            Iterator<Sheet> sheets = rwb.sheetIterator();
            int j = 0, rows;
            BasDrugUseExcelDO basDrugUseExcelDO;
            getRepeat().put("supply_code", new HashSet<>());
            getRepeat().put("supply_name", new HashSet<>());
            getRepeat().put("supply_occ", new HashSet<>());
            getRepeat().put("del_flag", new HashSet<>());
            getRepeat().put("sort_code", new HashSet<>());
            getRepeat().put("print_name", new HashSet<>());
            getRepeat().put("py_code", new HashSet<>());
            getRepeat().put("d_code", new HashSet<>());
            getRepeat().put("yb_name", new HashSet<>());
            getRepeat().put("yb_code", new HashSet<>());
            getRepeat().put("status", new HashSet<>());
            errorLs.clear();
            correctLs.clear();
            while (sheets.hasNext()){
                Sheet sheet = sheets.next();
                if ((rows = sheet.getLastRowNum()) == 0) {
                    continue;
                }
                for (int i = 1; i <= rows; i++) {
                    basDrugUseExcelDO = new BasDrugUseExcelDO();
                    basDrugUseExcelDO.setSupply_code(replaceBlank(getCellCont(sheet, i, 0)));
                    basDrugUseExcelDO.setSupply_name(replaceBlank(getCellCont(sheet, i, 1)));
                    basDrugUseExcelDO.setSupply_occ(getCellCont(sheet, i, 2));
                    basDrugUseExcelDO.setDel_flag(replaceBlank(getCellCont(sheet, i, 3)));
                    basDrugUseExcelDO.setSort_code(replaceBlank(getCellCont(sheet, i, 4)));
                    basDrugUseExcelDO.setPrint_name(replaceBlank(getCellCont(sheet, i, 5)));
                    basDrugUseExcelDO.setPy_code(replaceBlank(getCellCont(sheet, i, 6)));
                    basDrugUseExcelDO.setD_code(replaceBlank(getCellCont(sheet, i, 7)));
                    basDrugUseExcelDO.setYb_name(getCellCont(sheet, i, 8));
                    basDrugUseExcelDO.setYb_code(replaceBlank(getCellCont(sheet, i, 9)));
                    basDrugUseExcelDO.setExcelSeq(i);
                    int rs = basDrugUseExcelDO.validate(repeat);
                    if (validate(basDrugUseExcelDO)== 0||rs == 0) {
                        errorLs.add(basDrugUseExcelDO);
                    } else if (rs == 1) {
                        correctLs.add(basDrugUseExcelDO);
                    }
                }
                j++;
            }
        }catch (Exception e){
            e.printStackTrace();
            throw e;
        }finally {
            if (rwb != null) {
                rwb.close();
            }
        }
    }
    public int validate(BasDrugUseExcelDO basDrugUseExcelDO) {
        int rs = 1;
        if (StringUtils.isNoneBlank(basDrugUseExcelDO.getSupply_code())){
            List<BaseDrugUseDictDO> list  = baseDrugUseDictDao.findByCodeAndName(basDrugUseExcelDO.getSupply_code(),basDrugUseExcelDO.getSupply_name());
            System.out.println("当前导入数据:"+ basDrugUseExcelDO.getSupply_code());
            if (list!=null&&list.size()>0){
                System.out.println("进验证有重复数据"+list.get(0).getSupply_code());
                return 0;
            }
        }
        return rs;
    }
}

+ 96 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/importManage/BaseFrequencyExcelDOReader.java

@ -0,0 +1,96 @@
package com.yihu.jw.base.service.dict.importManage;
import com.yihu.jw.base.endpoint.common.excel.AExcelReader;
import com.yihu.jw.dict.dao.BaseDrugUseDictDao;
import com.yihu.jw.dict.dao.BaseFrequencyDictDao;
import com.yihu.jw.dict.dao.BaseTemplateDictDao;
import com.yihu.jw.entity.base.dict.BaseDrugUseDictDO;
import com.yihu.jw.entity.base.dict.BaseFrequencyDictDO;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
/**
 * 医生信息列表-excel解析类
 * Created by 刘文彬 on 2018/10/24.
 */
@Component
public class BaseFrequencyExcelDOReader extends AExcelReader {
    @Autowired
    private BaseFrequencyDictDao baseFrequencyDictDao;
    @Autowired
    private BaseTemplateDictDao baseTemplateDictDao;
    @Override
    public void read(Workbook rwb) throws Exception {
        try{
            Iterator<Sheet> sheets = rwb.sheetIterator();
            int j = 0, rows;
            BasFrequencyExcelDO basFrequencyExcelDO;
            getRepeat().put("freq_code", new HashSet<>());
            getRepeat().put("freq_name", new HashSet<>());
            getRepeat().put("freq_sp", new HashSet<>());
            getRepeat().put("daily_times", new HashSet<>());
            getRepeat().put("weekly_times", new HashSet<>());
            getRepeat().put("hosp_code", new HashSet<>());
            getRepeat().put("is_op_ip", new HashSet<>());
            getRepeat().put("status", new HashSet<>());
            errorLs.clear();
            correctLs.clear();
            while (sheets.hasNext()){
                Sheet sheet = sheets.next();
                if ((rows = sheet.getLastRowNum()) == 0) {
                    continue;
                }
                for (int i = 1; i <= rows; i++) {
                    basFrequencyExcelDO = new BasFrequencyExcelDO();
                    basFrequencyExcelDO.setFreq_code(replaceBlank(getCellCont(sheet, i, 0)));
                    basFrequencyExcelDO.setFreq_name(replaceBlank(getCellCont(sheet, i, 1)));
                    basFrequencyExcelDO.setFreq_sp(getCellCont(sheet, i, 2));
                    basFrequencyExcelDO.setDaily_times(replaceBlank(getCellCont(sheet, i, 3)));
                    basFrequencyExcelDO.setWeekly_times(replaceBlank(getCellCont(sheet, i, 4)));
                    basFrequencyExcelDO.setHosp_code(replaceBlank(getCellCont(sheet, i, 5)));
                    basFrequencyExcelDO.setIs_op_ip(replaceBlank(getCellCont(sheet, i, 6)));
                    basFrequencyExcelDO.setStatus(replaceBlank(getCellCont(sheet, i, 7)));
                    basFrequencyExcelDO.setExcelSeq(i);
                    int rs = basFrequencyExcelDO.validate(repeat);
                    if (validate(basFrequencyExcelDO)== 0||rs == 0) {
                        errorLs.add(basFrequencyExcelDO);
                    } else if (rs == 1) {
                        correctLs.add(basFrequencyExcelDO);
                    }
                }
                j++;
            }
        }catch (Exception e){
            e.printStackTrace();
            throw e;
        }finally {
            if (rwb != null) {
                rwb.close();
            }
        }
    }
    public int validate(BasFrequencyExcelDO basFrequencyExcelDO) {
        int rs = 1;
        if (StringUtils.isNoneBlank(basFrequencyExcelDO.getFreq_code())){
            List<BaseFrequencyDictDO> list  = baseFrequencyDictDao.findByCodeAndIdName(basFrequencyExcelDO.getFreq_code(),basFrequencyExcelDO.getFreq_name());
            System.out.println("当前导入数据:"+ basFrequencyExcelDO.getFreq_code());
            if (list!=null&&list.size()>0){
                System.out.println("进验证有重复数据"+list.get(0).getFreq_code());
                return 0;
            }
        }
        return rs;
    }
}

+ 98 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/dict/importManage/BaseIcd10ExcelDOReader.java

@ -0,0 +1,98 @@
package com.yihu.jw.base.service.dict.importManage;
import com.yihu.jw.base.dao.dict.DictIcd10Dao;
import com.yihu.jw.base.endpoint.common.excel.AExcelReader;
import com.yihu.jw.dict.dao.BaseDrugDictDao;
import com.yihu.jw.dict.dao.BaseTemplateDictDao;
import com.yihu.jw.entity.base.dict.BaseDrugDictDO;
import com.yihu.jw.entity.base.dict.DictIcd10DO;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
/**
 * 医生信息列表-excel解析类
 * Created by 刘文彬 on 2018/10/24.
 */
@Component
public class BaseIcd10ExcelDOReader extends AExcelReader {
    @Autowired
    private DictIcd10Dao dictIcd10Dao;
    @Autowired
    private BaseTemplateDictDao baseTemplateDictDao;
    @Override
    public void read(Workbook rwb) throws Exception {
        try{
            Iterator<Sheet> sheets = rwb.sheetIterator();
            int j = 0, rows;
            BasIcd10ExcelDO basIcd10ExcelDO;
            getRepeat().put("code", new HashSet<>());
            getRepeat().put("name", new HashSet<>());
            getRepeat().put("description", new HashSet<>());
            getRepeat().put("disea_reason", new HashSet<>());
            getRepeat().put("death_reason", new HashSet<>());
            getRepeat().put("py_code", new HashSet<>());
            getRepeat().put("d_code", new HashSet<>());
            getRepeat().put("flag", new HashSet<>());
            getRepeat().put("status", new HashSet<>());
            errorLs.clear();
            correctLs.clear();
            while (sheets.hasNext()){
                Sheet sheet = sheets.next();
                if ((rows = sheet.getLastRowNum()) == 0) {
                    continue;
                }
                for (int i = 1; i <= rows; i++) {
                    basIcd10ExcelDO = new BasIcd10ExcelDO();
                    basIcd10ExcelDO.setCode(replaceBlank(getCellCont(sheet, i, 0)));
                    basIcd10ExcelDO.setName(replaceBlank(getCellCont(sheet, i, 1)));
                    basIcd10ExcelDO.setDescription(getCellCont(sheet, i, 2));
                    basIcd10ExcelDO.setDisea_reason(replaceBlank(getCellCont(sheet, i, 3)));
                    basIcd10ExcelDO.setDeath_reason(replaceBlank(getCellCont(sheet, i, 4)));
                    basIcd10ExcelDO.setPy_code(replaceBlank(getCellCont(sheet, i, 5)));
                    basIcd10ExcelDO.setD_code(replaceBlank(getCellCont(sheet, i, 6)));
                    basIcd10ExcelDO.setFlag(replaceBlank(getCellCont(sheet, i, 7)));
                    basIcd10ExcelDO.setStatus(getCellCont(sheet, i, 8));
                    basIcd10ExcelDO.setExcelSeq(i);
                    int rs = basIcd10ExcelDO.validate(repeat);
                    if (validate(basIcd10ExcelDO)== 0||rs == 0) {
                        errorLs.add(basIcd10ExcelDO);
                    } else if (rs == 1) {
                        correctLs.add(basIcd10ExcelDO);
                    }
                }
                j++;
            }
        }catch (Exception e){
            e.printStackTrace();
            throw e;
        }finally {
            if (rwb != null) {
                rwb.close();
            }
        }
    }
    public int validate(BasIcd10ExcelDO basIcd10ExcelDO) {
        int rs = 1;
        if (StringUtils.isNoneBlank(basIcd10ExcelDO.getCode())){
            List<DictIcd10DO> list  = dictIcd10Dao.findByCodeAndName(basIcd10ExcelDO.getCode(),basIcd10ExcelDO.getName());
            System.out.println("当前导入数据:"+ basIcd10ExcelDO.getCode());
            if (list!=null&&list.size()>0){
                System.out.println("进验证有重复数据"+list.get(0).getCode());
                return 0;
            }
        }
        return rs;
    }
}

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java

@ -1000,7 +1000,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        Map<String, Object> result = new HashMap<>();
        //批量存储的集合
//        int correctCount = 0;
//        List<BaseDoctorExcelDO> corrects = new ArrayList<>();
//        List<BasDrugExcelDO> corrects = new ArrayList<>();
        BaseDoctorDO baseDoctorDO;
        //批量存储
        for(BaseDoctorExcelDO one:doctors){

+ 12 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/birthday/BirthDayWishesToPatientDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.care.dao.birthday;
import com.yihu.jw.entity.care.birthday.BirthDayWishesToPatient;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/7/16.
 */
public interface BirthDayWishesToPatientDao extends PagingAndSortingRepository<BirthDayWishesToPatient,Long>,
        JpaSpecificationExecutor<BirthDayWishesToPatient> {
}

+ 29 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/birthday/BirthdayWishesTemplateDao.java

@ -0,0 +1,29 @@
package com.yihu.jw.care.dao.birthday;
import com.yihu.jw.entity.care.birthday.BirthdayWishesTemplate;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by humingfen on 2018/10/26.
 */
public interface BirthdayWishesTemplateDao extends PagingAndSortingRepository<BirthdayWishesTemplate, Long> {
    @Query("SELECT t from BirthdayWishesTemplate t where t.applicableRange = ?2 and (t.createUser = ?1 or t.createUser is null ) and t.del = 1 ORDER BY t.isDefault desc,t.type, t.createTime desc ")
    List<BirthdayWishesTemplate> getTemplateByDoctorAndApplicableRange(String doctor, Integer applicableRange);
    @Query("SELECT t from BirthdayWishesTemplate t where (t.createUser = ?1 or t.createUser is null ) and t.del = 1 ORDER BY t.isDefault desc,t.type, t.createTime desc ")
    List<BirthdayWishesTemplate> getTemplateByDoctor(String doctor);
    @Query("select t from BirthdayWishesTemplate t where t.applicableRange = ?1 and t.type = 1 and t.del = 1")
    BirthdayWishesTemplate getTemplateByApplicableRange(Integer applicableRange);
    @Query("update BirthdayWishesTemplate t set t.isDefault = ?2 where t.id = ?1")
    @Modifying
    void setDefalutTemplateById(Long id, Integer isDefault);
    BirthdayWishesTemplate findByCreateUserAndApplicableRangeAndIsDefault(String doctor,Integer applicableRange, int isDefault);
}

+ 281 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorBirthdayWishesEndpoint.java

@ -0,0 +1,281 @@
package com.yihu.jw.care.endpoint.doctor;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.jw.care.endpoint.BaseController;
import com.yihu.jw.care.service.birthday.BirthdayWishesService;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.entity.care.birthday.BirthDayWishesToPatient;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.util.date.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by Bing on 2021/7/16.
 */
@RestController
@RequestMapping(value = "doctor/birthday")
@Api(tags = "医生生日祝福", description = "医生生日祝福")
public class DoctorBirthdayWishesEndpoint extends BaseController {
    @Autowired
    private BirthdayWishesService birthdayWishesService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private MessageUtil messageUtil;
    @Value("${wechat.id}")
    private String wxId;
    @Autowired
    private SystemMessageDao systemMessageDao;
    @Autowired
    private ImUtil imUtil;
    @RequestMapping(value = "/createTemplate", method = RequestMethod.POST)
    @ApiOperation(value = "创建模板")
    public String createTemplate(@ApiParam(name = "content", value = "医生新建的祝福语")
                                 @RequestParam(required = false) String content,
                                 @ApiParam(name = "applicableRange", value = "适用人群")
                                 @RequestParam(required = false) Integer applicableRange,
                                 @ApiParam(name = "id", value = "模板ID")
                                 @RequestParam(required = false) Long id,
                                 @ApiParam(name = "isDefault", value = "是否是默认模板")
                                 @RequestParam(required = false) Integer isDefault) {
        try {
            return write(200, "更新成功!", "data", birthdayWishesService.create(getUID(), content, applicableRange, id, isDefault));
        } catch (Exception e) {
            return errorResult(e);
        }
    }
    @RequestMapping(value = "/getTemplateByDoctor", method = RequestMethod.GET)
    @ApiOperation(value = "获取系统模板和当前医生创建的模板")
    public String getTemplateByDoctor(@ApiParam(name = "doctor", value = "医生code")
                                      @RequestParam(required = false) String doctor) {
        try {
            if(StringUtils.isBlank(doctor)){
                doctor = getUID();
            }
            return write(200, "查询成功!", "data", birthdayWishesService.getTemplateByDoctor(doctor));
        } catch (Exception e) {
            return errorResult(e);
        }
    }
    @RequestMapping(value = "/getTemplateById", method = RequestMethod.GET)
    @ApiOperation(value = "根据模板id获取祝福内容")
    public String getTemplateById(@ApiParam(name = "id", value = "模板id")
                                  @RequestParam(required = true) Long id) {
        try {
            return write(200, "查询成功!", "data", birthdayWishesService.getTemplateById(id));
        } catch (Exception e) {
            return errorResult(e);
        }
    }
    @RequestMapping(value = "/deleteTemplateById", method = RequestMethod.POST)
    @ApiOperation(value = "根据模板id删除祝福模板")
    public String deleteTemplateById(@ApiParam(name = "id", value = "模板id")
                                     @RequestParam(required = true) Long id) {
        try {
            birthdayWishesService.deleteTemplateById(id);
            return write(200, "删除成功!");
        } catch (Exception e) {
            return errorResult(e);
        }
    }
    @RequestMapping(value = "/setDefalutTemplateById", method = RequestMethod.POST)
    @ApiOperation(value = "设置默认模板")
    public String setDefalutTemplateById(
            @ApiParam(name = "id", value = "模板ID",required = true)
            @RequestParam Long id) {
        try {
            return write(200, "设置成功!", "data", birthdayWishesService.setDefalutTemplateById(getUID(), id));
        } catch (Exception e) {
            return errorResult(e);
        }
    }
    @ApiOperation("获取医生签约患者当天生日未发送")
    @RequestMapping(value = "getPatientByDoctor", method = RequestMethod.GET)
    public String getPatientByDoctor(){
        try {
            return write(200, "查询成功", "data", birthdayWishesService.getPatientByDoctor(getUID()));
        } catch (Exception e) {
            return errorResult(e);
        }
    }
    @ApiOperation("获取医生签约患者当天生日未发送数量")
    @RequestMapping(value = "getPatientByDoctorCount", method = RequestMethod.GET)
    public String getPatientByDoctorCount(){
        try {
            return write(200, "查询成功", "data", birthdayWishesService.getPatientByDoctorCount(getUID()));
        } catch (Exception e) {
            return errorResult(e);
        }
    }
    @ApiOperation("获取生日居民列表")
    @RequestMapping(value = "getBirthdayPatientList", method = RequestMethod.GET)
    public String getBirthdayPatientList(@ApiParam(name = "patientName", value = "居民姓名")
                                         @RequestParam(required = false) String patientName,
                                         @ApiParam(name = "signYear", value = "签约年度")
                                         @RequestParam(required = false) Integer signYear,
                                         @ApiParam(name = "startDate", value = "生日开始日期yyyy-MM-dd")
                                         @RequestParam String startDate,
                                         @ApiParam(name = "endDate", value = "生日截止日期yyyy-MM-dd")
                                         @RequestParam String endDate,
                                         @ApiParam(name = "status", value = "状态(1、已发送,2、未发送)")
                                         @RequestParam(required = false) Integer status,
                                         @ApiParam(name = "currentUserRole", value = "登录角色")
                                         @RequestParam(value = "currentUserRole", required = false) String currentUserRole,
                                         @ApiParam(name = "currentUserRoleLevel", value = "登录角色等级(1省2市3区4社区、机构)")
                                         @RequestParam(value = "currentUserRoleLevel", required = false)String currentUserRoleLevel,
                                         @ApiParam(name = "roleType", value = "1、普通医生,2、管理员")
                                         @RequestParam(value = "roleType") Integer roleType,
                                         @ApiParam(name = "teamId", value = "医生所在团队")
                                         @RequestParam(value = "teamId", required = false) Integer teamId,
                                         @ApiParam(name = "isLeader", value = "是否是团队长,0不是、1是")
                                         @RequestParam(value = "isLeader", required = false) Integer isLeader,
                                         @ApiParam(name = "page", value = "第几页,从1开始")
                                         @RequestParam Integer page,
                                         @ApiParam(name = "pageSize", value = "页面大小")
                                         @RequestParam Integer pageSize){
        try {
            return write(200, "查询成功", "data", birthdayWishesService.getBirthdayPatientList(getUID(), patientName, signYear, startDate, endDate, status, currentUserRole, currentUserRoleLevel, roleType, page, pageSize, teamId, isLeader));
        } catch (Exception e) {
            return errorResult(e);
        }
    }
    @RequestMapping(value = "/doctorSendBirthdayWishes", method = RequestMethod.POST)
    @ApiOperation(value = "医生发送生日祝福")
    public String pushBirthdayWishes(@ApiParam(name = "patient", value = "发送人群集合")
                                     @RequestParam(required = true) String patient,
                                     @ApiParam(name = "templateId", value = "生日祝福模板id")
                                     @RequestParam(required = false) Long templateId,
                                     @ApiParam(name = "content", value = "医生新建的祝福语")
                                     @RequestParam(required = false) String content,
                                     @ApiParam(name = "applicableRange", value = "适用人群")
                                     @RequestParam(required = false) Integer applicableRange,
                                     @ApiParam(name = "isSave", value = "是否保存")
                                     @RequestParam(required = false) Integer isSave,
                                     @RequestParam(value = "currentUserRole", required = false) String currentUserRole,
                                     @RequestParam(value = "currentUserRoleLevel", required = false)String currentUserRoleLevel) {
        try {
            Date currentTime = new Date();
            SimpleDateFormat format = new SimpleDateFormat("MM月dd日");
            String dateString = format.format(currentTime);
            if(StringUtils.isEmpty(currentUserRole)){
                currentUserRole = getCurrentRoleCode();
            }
            if(StringUtils.isEmpty(currentUserRoleLevel)){
                currentUserRoleLevel = getCurrentRoleLevel();
            }
            JSONObject json = new JSONObject();
            json.put("patient", patient);
            json.put("doctorCode", getUID());
            json.put("sendType", 1);
            json.put("birthday", dateString);
            json.put("currentUserRole", currentUserRole);
            json.put("currentUserRoleLevel", currentUserRoleLevel);
            if(templateId != null) {
                json.put("templateId", templateId);
                json.put("isSave", 1);
            }else {
                json.put("content", content);
                json.put("isSave", 0);
            }
            List<BirthDayWishesToPatient> birthDayWishesToPatientESList = birthdayWishesService.saveBirthdayWishesES(json);
            new Thread(() -> {
                sender(birthDayWishesToPatientESList);
            }).start();
            return write(200, "发送成功!");
        } catch (Exception e) {
            return errorResult(e);
        }
    }
    /**
     * 发送消息
     *
     */
    public void sender(List<BirthDayWishesToPatient> birthDayWishesToPatient) {
        //发送到队列
        birthDayWishesToPatient.stream().forEach(one -> {
            //根据openid进行发送祝福
            String patient = one.getPatientCode();
            if (StringUtils.isNotBlank(patient)){
                String sql = " select p.id as patient,p.name,we.openid from base_patient p inner join  base_patient_wechat we on p.id = we.patient_id " +
                        "and we.patient_id = '"+patient+"' " +
                        "  order by we.create_time desc  ";
                List<Map<String,Object>> patients = jdbcTemplate.queryForList(sql);
                if (patients.size()>0){//发送生日祝福
                    Map<String,Object> tmp = patients.get(0);
                    com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
                    String first = "助老员key1为您发送生日祝福,请点击查看。";
                    first = first.replace("key1",one.getDoctorName());
                    json.put("doctorName", one.getDoctorName());
                    json.put("toUser", patient);
                    json.put("name", tmp.get("name").toString());
                    json.put("content", one.getContent());
                    json.put("openid",tmp.get("openid").toString());
                    json.put("represented","");//被代理人
                    boolean success =  messageUtil.putTemplateWxMessage(wxId,"template_success_notice","srzf",tmp.get("openid").toString(),first,
                            null,one.getContent(),26,json,"已发送", DateUtil.dateToChineseTime(new Date()));
                    if (success){
                        SystemMessageDO messageDO = new SystemMessageDO();
                        messageDO.setTitle("收到来自"+one.getDoctorName()+"的关怀祝福:祝您"+tmp.get("name").toString()+"节日快乐!");
                        messageDO.setType("41");//41人文关怀
                        messageDO.setSender(one.getDoctorCode());
                        messageDO.setSenderName(one.getDoctorName());
                        messageDO.setRelationCode(one.getId()+"");
                        messageDO.setReceiver(patient);
                        messageDO.setReceiverName(tmp.get("name").toString());
                        messageDO.setOver("1");
                        messageDO.setCode("1");//1生日祝福
                        messageDO.setData(one.getContent());
                        messageDO.setDel("1");
                        messageDO.setCreateTime(new Date());
                        systemMessageDao.save(messageDO);
                        //推送socket
                        com.alibaba.fastjson.JSONObject message = new com.alibaba.fastjson.JSONObject();
                        message.put("title",messageDO.getTitle());
                        message.put("code",messageDO.getCode());
                        message.put("content",messageDO.getData());
                        message.put("relation_code",messageDO.getRelationCode());
                        message.put("content_type",41);
                        message.put("content_notice","");
                        String content_notice = null;
                        imUtil.sendPatientSystemMessage(messageDO.getReceiver(), JSON.toJSONString(message, SerializerFeature.WriteMapNullValue));
                    }
                }
            }
        });
    }
}

+ 25 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/family/FamilyMemberEndpoint.java

@ -197,6 +197,31 @@ public class FamilyMemberEndpoint extends EnvelopRestEndpoint {
        }
    }
    /**
     * 家庭成员查询
     * @param patient
     * @return
     */
    @RequestMapping(value = "/membersWithOnLineFlag", method = RequestMethod.GET)
    @ApiOperation(value = "家庭成员查询带是否在线标识")
    public ObjEnvelop membersWithOnLineFlag(@RequestParam(required = false) String patient) {
        try {
            JSONObject data = new JSONObject();
            JSONArray result = new JSONArray();
            if (StringUtils.isNotEmpty(patient)) {
                result = familyMemberService.membersWithOnLineFlag(patient);
            } else  {
                result = familyMemberService.membersWithOnLineFlag(getUID());
            }
            data.put("normalmembers",result);//家人关系
            return ObjEnvelop.getSuccess( "查询成功", data);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @RequestMapping(value = "/authorize_members", method = RequestMethod.GET)
    @ApiOperation(value = "家庭成员(有授权)查询")
    public ObjEnvelop getAuthorizeFamilyMembers(){

+ 17 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/message/PatientMessageEndpoint.java

@ -76,7 +76,23 @@ public class PatientMessageEndpoint extends EnvelopRestEndpoint {
                                            @RequestParam(value = "type")String type
                                            ){
        try {
            return ListEnvelop.getSuccess("查询成功",patientMessageService.getSystemMessageList(patient,type));
            return ListEnvelop.getSuccess("查询成功",patientMessageService.getSystemMessageList(patient,type,null));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "getSystemMessageListPad")
    @ApiOperation("居民平板端获取消息列表(生日祝福,体征设备)")
    public ListEnvelop getUnreadSystemMessageListPad(@ApiParam(name = "patient",required = true)
                                            @RequestParam(value = "patient")String patient,
                                            @ApiParam(name = "type",required = true)
                                            @RequestParam(value = "type",defaultValue = "41,42")String type,
                                            @ApiParam(name = "isRead",required = false,value = "1:为已读,0:未读")
                                            @RequestParam(value = "isRead",required = false)String isRead
    ){
        try {
            return ListEnvelop.getSuccess("查询成功",patientMessageService.getSystemMessageList(patient,type,isRead));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }

+ 12 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientContactsEndpoint.java

@ -4,10 +4,12 @@ import com.alibaba.fastjson.JSONArray;
import com.yihu.jw.care.service.contacts.ContactsService;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -117,4 +119,14 @@ public class PatientContactsEndpoint extends EnvelopRestEndpoint {
        }
    }
    @RequestMapping(value = "getAllOrgListWithSignFlag",method = RequestMethod.GET)
    @ApiOperation(value = "获取所有服务站列表--带是否签约标识")
    public ListEnvelop getAllOrgList(@ApiParam(name="patient",value = "居民id")
                                     @RequestParam(value = "patient",required = false)String patient){
        try {
            return ListEnvelop.getSuccess("获取成功",contactsService.getAllOrgListWithSignFlag(patient));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
}

+ 5 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java

@ -51,7 +51,7 @@ public class SignEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "findSignOrg")
    @ApiOperation(value = "查找签约机构")
    public ListEnvelop findSignOrg (
            @ApiParam(name = "patient", value = "医生code", required = true)
            @ApiParam(name = "patient", value = "患者code", required = true)
            @RequestParam(value = "patient",required = true) String patient,
            @ApiParam(name = "name", value = "机构名称", required = false)
            @RequestParam(value = "name",required = false) String name,
@ -519,9 +519,11 @@ public class SignEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value="getServerDoctorAll")
    @ApiOperation(value = "获取所有服务医生")
    public ListEnvelop getServerDoctorAll(@ApiParam(name = "patient", value = "患者id", required = true)
                                          @RequestParam(value = "patient") String patient){
                                          @RequestParam(value = "patient") String patient,
                                          @ApiParam(name = "onlineFlag", value = "获取在线状态获取 0不获取 1获取", required = false)
                                          @RequestParam(value = "onlineFlag",required = false) String onlineFlag){
        try {
            return ListEnvelop.getSuccess("查询成功",servicePackageService.getServerDoctorAll(patient));
            return ListEnvelop.getSuccess("查询成功",servicePackageService.getServerDoctorAll(patient,onlineFlag));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }

+ 500 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/birthday/BirthdayWishesService.java

@ -0,0 +1,500 @@
package com.yihu.jw.care.service.birthday;
import com.yihu.jw.care.dao.birthday.BirthDayWishesToPatientDao;
import com.yihu.jw.care.dao.birthday.BirthdayWishesTemplateDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.birthday.BirthDayWishesToPatient;
import com.yihu.jw.entity.care.birthday.BirthdayWishesTemplate;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
 * Created by Bing on 2021/7/16.
 */
@Service
public class BirthdayWishesService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    private static LinkedBlockingQueue<JSONObject> queue = new LinkedBlockingQueue<>();
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private BirthdayWishesTemplateDao bwTemplateDao;
    @Autowired
    private BirthDayWishesToPatientDao bwToPatientDao;
    @Autowired
    private BaseDoctorHospitalDao hospitalDao;
    @Autowired
    private RedisTemplate redisTemplate;
//    /**
//     * 发送到mq
//     *
//     */
//    public void sender(List<BirthDayWishesToPatientES> birthDayWishesToPatientES) {
//        //发送到队列
//        birthDayWishesToPatientES.stream().forEach(one -> {
//            jmsTemplate.send(channelName, new MessageCreator() {
//                @Override
//                public Message createMessage(Session session) throws JMSException {
//                    TextMessage textMessage = session.createTextMessage();
//                    textMessage.setText(net.sf.json.JSONObject.fromObject(one).toString());
//                    return textMessage;
//                }
//            });
//        });
//    }
    /**
     * 医生端--新建祝福语模板
     * @param doctor
     * @param content
     * @param applicableRange
     * @param id
     * @param isDefault
     */
    public Long create(String doctor, String content, Integer applicableRange, Long id, Integer isDefault) {
        BaseDoctorDO doctorDO = doctorDao.findById(doctor);
        BirthdayWishesTemplate template = null;
        //判断是编辑还是创建
        if(id != null){
            template = bwTemplateDao.findOne(id);
        }else {
            template = new BirthdayWishesTemplate();
            template.setCode(UUID.randomUUID().toString().replace("-",""));
            template.setType(2);
            template.setDel(1);
            template.setCreateUser(doctor);
            template.setCreateUserName(doctorDO.getName());
        }
        template.setApplicableRange(applicableRange);
        template.setContent(content);
        template.setCreateTime(new Date());
        if(isDefault != null) {
            if(isDefault == 1){
                //先取消该医生自创的默认模板
                BirthdayWishesTemplate docTemplate = bwTemplateDao.findByCreateUserAndApplicableRangeAndIsDefault(doctor, applicableRange, 1);
                if(docTemplate != null){
                    bwTemplateDao.setDefalutTemplateById(docTemplate.getId(), 0);
                }
            }
            template.setIsDefault(isDefault);
        }else if(id == null || template.getIsDefault() == null){
            template.setIsDefault(0);
        }
        bwTemplateDao.save(template);
        return template.getId();
    }
    /**
     * 获取系统模板和医生创建模板
     * @return
     */
    public List<BirthdayWishesTemplate> getTemplateByDoctor(String doctor) {
        return bwTemplateDao.getTemplateByDoctor(doctor);
    }
    /**
     * 根据id获取模板消息
     * @param id
     * @return
     */
    public BirthdayWishesTemplate getTemplateById(Long id) {
        return bwTemplateDao.findOne(id);
    }
    public void deleteTemplateById(Long id) {
        bwTemplateDao.delete(id);
    }
    /**
     * 根据ID设置为默认模板
     *
     * @param doctor
     * @param id
     * @return
     */
    @Transactional
    public BirthdayWishesTemplate setDefalutTemplateById(String doctor, Long id) {
        BirthdayWishesTemplate template = bwTemplateDao.findOne(id);
        //先取消该医生自创的默认模板
        BirthdayWishesTemplate docTemplate = bwTemplateDao.findByCreateUserAndApplicableRangeAndIsDefault(doctor, template.getApplicableRange(), 1);
        if(docTemplate != null){
            bwTemplateDao.setDefalutTemplateById(docTemplate.getId(), 0);
        }
        //如果不是系统模板,就添加默认模板标识
        if(template.getType() != 1){
            bwTemplateDao.setDefalutTemplateById(id, 1);
        }
        return template;
    }
    /**
     * 获取医生当天未发送生日祝福居民信息
     * @param doctor
     * @return
     */
    public List<Map<String, Object>> getPatientByDoctor(String doctor) throws Exception{
        //es日期格式
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String createTime = sdf.format(new Date()) + " 00:00:00";
        //今日推送的居民
        Set<String> sendPatients = (Set<String>) redisTemplate.opsForValue().get("birthday:wish:sendPatient");
        Date currentTime = new Date();
        SimpleDateFormat format = new SimpleDateFormat("MMdd");
        String dateString = format.format(currentTime);
        //获取当天0点
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
        String now = f.format(new Date());
        String sql = "SELECT p.id patient, p.`name`, " +
                "CASE p.sex WHEN 1 THEN '男' WHEN 2 THEN '女' END sex," +
                "p.idcard, p.photo," +
                " CASE LENGTH(p.idcard) WHEN  18 then SUBSTR(p.idcard,11,4) when 15 then SUBSTR(p.idcard, 9,4) END date " +
                "from wlyy_archive a,base_patient p WHERE  a.patient = p.id and a.sign_status = 1 and EXISTS( " +
                "SELECT DISTINCT sr.patient from base_service_package_sign_record sr,base_service_package_record r, " +
                "base_service_package_item i,base_team_member m " +
                "WHERE  sr.id = r.sign_id and sr.patient = a.patient  and r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = i.team_code and m.doctor_code = '"+doctor+"' ) "+
                " and (p.archive_status<>2 or p.archive_status is null) " +
                "AND CASE LENGTH(p.idcard) WHEN  18 then SUBSTR(p.idcard,11,4) when 15 then SUBSTR(p.idcard, 9,4) END =  '" + dateString + "' " ;
        List<Map<String, Object>> patientInfos =  jdbcTemplate.queryForList(sql);
        //整理未发送居民信息
        for(Map<String, Object> map : patientInfos){
            if (sendPatients == null || !sendPatients.contains(map.get("patient"))) {
                int age = IdCardUtil.getAgeForIdcard(map.get("idcard") + "");
                Date birthday = IdCardUtil.getBirthdayForIdcard(map.get("idcard") + "");
                map.put("age", age);
                map.put("birthday", DateUtil.dateToStr(birthday, "yyyy-MM-dd"));
            }
        }
        return patientInfos;
    }
    /**
     * 获取医生当天未发送生日祝福居民数量
     * @param doctor
     * @return
     */
    public Integer getPatientByDoctorCount(String doctor) throws Exception{
        //es日期格式
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String createTime = sdf.format(new Date()) + " 00:00:00";
        //今日推送的居民
        Set<String> sendPatients = (Set<String>) redisTemplate.opsForValue().get("birthday:wish:sendPatient");
        Date currentTime = new Date();
        SimpleDateFormat format = new SimpleDateFormat("MMdd");
        String dateString = format.format(currentTime);
        //获取当天0点
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
        String now = f.format(new Date());
        String sql = "SELECT p.id patient, p.`name`, " +
                "CASE p.sex WHEN 1 THEN '男' WHEN 2 THEN '女' END sex," +
                "p.idcard, p.photo," +
                " CASE LENGTH(p.idcard) WHEN  18 then SUBSTR(p.idcard,11,4) when 15 then SUBSTR(p.idcard, 9,4) END date " +
                "from wlyy_archive a,base_patient p WHERE  a.patient = p.id and a.sign_status = 1 and EXISTS( " +
                "SELECT DISTINCT sr.patient from base_service_package_sign_record sr,base_service_package_record r, " +
                "base_service_package_item i,base_team_member m " +
                "WHERE  sr.id = r.sign_id and sr.patient = a.patient  and r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = i.team_code and m.doctor_code = '"+doctor+"' ) "+
                " and (p.archive_status<>2 or p.archive_status is null) " +
                "AND CASE LENGTH(p.idcard) WHEN  18 then SUBSTR(p.idcard,11,4) when 15 then SUBSTR(p.idcard, 9,4) END =  '" + dateString + "' " ;
        List<Map<String, Object>> patientInfos =  jdbcTemplate.queryForList(sql);
        return patientInfos.size();
    }
    /**
     * 获取医生生日列表
     */
    public Map<String, Object> getBirthdayPatientList(String doctorCode, String patientName, Integer signYear, String startDate, String endDate, Integer status, String currentUserRole, String currentUserRoleLevel,
                                                      Integer roleType, Integer page, Integer pageSize, Integer teamId, Integer isLeader) throws Exception {
        Map<String, Object> resultMap = new HashMap<>();
        List<Map<String, Object>> resultList = new ArrayList();
        Long allCount = 0l;
        //判断是否筛选推送条件,若未筛选则从数据库直接查生日居民,再进行匹配是否推送,若选择已推送则从推送记录查,若未发送则从未推送表查
        //助老员签约患者
        String sql = " SELECT Distinct p.id patient,p.idcard,p.mobile,p.name,p.sex,p.id,p.photo," +
                "CASE LENGTH(p.idcard) WHEN 18 THEN SUBSTR(p.idcard, 11, 4) WHEN 15 THEN SUBSTR(p.idcard, 9, 4) END birthday  " ;
        String sqlCount = "SELECT count(distinct p.idcard) ";
        String whereSql = "from wlyy_archive a,base_patient p WHERE  a.patient = p.id and a.sign_status = 1 and EXISTS( " +
                "SELECT DISTINCT sr.patient from base_service_package_sign_record sr,base_service_package_record r, " +
                "base_service_package_item i,base_team_member m " +
                "WHERE  sr.id = r.sign_id and sr.patient = a.patient  and r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = i.team_code ";
        //根据权限获取生日居民列表
        if (roleType == 1) {
            whereSql += " and m.doctor_code = '"+doctorCode+"' ";
        } else {//管理员
            switch (currentUserRoleLevel) {
                case "1": {//省
                    whereSql += " and i.org_code in ( select org.code from base_org org where org.province_code = '"+currentUserRole+"' and org.del=1 )  ";
                    break;
                }
                case "2": {//市
                    whereSql += " and i.org_code in ( select org.code from base_org org where org.city_code = '"+currentUserRole+"' and org.del=1 )  ";
                    break;
                }
                case "3": {//区
                    whereSql += " and i.org_code in ( select org.code from base_org org where org.town_code = '"+currentUserRole+"' and org.del=1 )  ";
                    break;
                }
                case "4": {//社区机构
                    whereSql += " and i.org_code = '" + currentUserRole + "' ";
                    break;
                }
            }
        }
        if (StringUtils.isNotBlank(patientName)) {
            whereSql += "and p.name like '%" + patientName + "%' ";
        }
        //根据签约年限来获取生日居民
        if ( null==  signYear|| signYear == DateUtil.getNowYear()) {//当前年度
            whereSql += " and sr.status=1 ";
        } else {//
            whereSql += " and sr.status=-1 and sr.start_time >='" + signYear+" 01-01:00:00:00" + "' and sr.start_time <='" + signYear+" 12-31:23:59:59" + "'  ";
        }
        if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)) {
            String start = startDate.substring(4).replace("-", "");
            String end = endDate.substring(4).replace("-", "");
            Integer birStart = Integer.parseInt(start);
            Integer birEnd = Integer.parseInt(end);
            //判断生日日期
            if(birEnd > birStart) {
                whereSql += "AND CASE LENGTH(p.idcard) WHEN 18 THEN SUBSTR(p.idcard, 11, 4) WHEN 15 THEN SUBSTR(p.idcard, 9, 4) END >= '" + start + "' " +
                        "AND CASE LENGTH(p.idcard) WHEN 18 THEN SUBSTR(p.idcard, 11, 4) WHEN 15 THEN SUBSTR(p.idcard, 9, 4) END <= '" + end + "' ";
            }else if(birEnd < birStart){
                whereSql += "AND CASE LENGTH(p.idcard) WHEN 18 THEN SUBSTR(p.idcard, 11, 4) WHEN 15 THEN SUBSTR(p.idcard, 9, 4) END >= '" + end + "' " +
                        "AND CASE LENGTH(p.idcard) WHEN 18 THEN SUBSTR(p.idcard, 11, 4) WHEN 15 THEN SUBSTR(p.idcard, 9, 4) END <= '" + start + "' ";
            }else {
                whereSql += "AND CASE LENGTH(p.idcard) WHEN 18 THEN SUBSTR(p.idcard, 11, 4) WHEN 15 THEN SUBSTR(p.idcard, 9, 4) END = '" + end + "' ";
            }
        }
        whereSql += "and DATE_FORMAT(sr.create_time,'%m%d')< CASE LENGTH(p.idcard) WHEN 18 THEN SUBSTR(p.idcard, 11, 4) WHEN 15 THEN SUBSTR(p.idcard, 9, 4) END ";
        sql = sql + whereSql + " ) order by birthday limit "+(page-1)*pageSize + "," + pageSize;
        sqlCount = sqlCount + whereSql+")";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        allCount = jdbcTemplate.queryForObject(sqlCount, Long.class);
        resultMap.put("total", allCount);
        //获取生日居民code
        String patientString = "";
        for (Map<String, Object> map : list) {
            patientString += "'"+ map.get("patient") + "',";
        }
        if(patientString.length() > 0) {
            //查询该居民是否有推送过
            String es = "SELECT patient_code patientCode,doctor_name doctorName,content,birthday,create_time createTime FROM birthday_wishes_to_patient where patient_code in (" + patientString.substring(0, patientString.length() - 1) + ") and user_type =1 and create_time > '" + startDate + " 00:00:00' and create_time < '" + endDate + " 23:59:59'";
            List<Map<String, Object>> sendPatientList = jdbcTemplate.queryForList(es);
            Set<String> patientSet = new HashSet<>();
            for (Map<String, Object> map : list) {
                String patientCode = map.get("patient") + "";
                //判断是否在推送记录里
                if( null == status || 1 == status  ) {
                    for (Map<String, Object> esMap : sendPatientList) {
                        if (patientCode.equals(esMap.get("patientCode") + "")) {
                            map.put("birthday", esMap.get("birthday") + "");
                            map.put("doctorName", esMap.get("doctorName") + "");
                            map.put("content", esMap.get("content") + "");
                            map.put("createTime", (esMap.get("createTime") + "").replace("T", " ").replace("+0800", ""));
                            map.put("status", "已发送");
                            patientSet.add(patientCode);
                            resultList.add(map);
                        }
                    }
                }
            }
            if(null == status || 2 == status) {
                //存取未发送居民
                for (Map<String, Object> map : list) {
                    String patientCode = map.get("patient") + "";
                    if (!patientSet.contains(patientCode)) {
                        String birthday = map.get("birthday")+"日";
                        StringBuilder bir = new StringBuilder(birthday);
                        bir.insert(2, "月");
//                            int age = IdCardUtil.getAgeForIdcard(map.get("idcard") + "");
                        map.put("birthday", bir.toString());
//                        int age = IdCardUtil.getAgeForIdcard(map.get("idcard") + "");
//                        map.put("age", age);
                        map.put("status", "未发送");
                        resultList.add(map);
                    }
                }
            }
        }
        resultMap.put("detailModelList", resultList);
        resultMap.put("total", allCount);
        resultMap.put("pageCount", allCount%pageSize == 0 ?allCount/pageSize : allCount/pageSize +1);
        return resultMap;
    }
    /**
     * 将发送祝福的居民相关信息存到es
     * @param json
     * @return
     */
    public List<BirthDayWishesToPatient> saveBirthdayWishesES(JSONObject json) {
        List<BirthDayWishesToPatient> list = new ArrayList<>();
        List<BirthDayWishesToPatient> birthdayWishesList = new ArrayList<>();
        String p = json.get("patient") + "";
        String doctorCode = json.get("doctorCode") + "";
        Integer sendType = (Integer) json.get("sendType");
        String currentUserRole = json.has("currentUserRole")?json.get("currentUserRole") + "":null;
        String currentUserRoleLevel = json.has("currentUserRoleLevel")?json.get("currentUserRoleLevel") + "":null;
        String dateString = json.get("birthday") + "";
        Integer isSave = (Integer) json.get("isSave");
        Long templateId = null;
        String content = null;
        if(isSave == 1) {
            templateId = (Long) json.get("templateId");
            BirthdayWishesTemplate birthdayWishesTemplate = bwTemplateDao.findOne(templateId);
            content = birthdayWishesTemplate.getContent();
        }else if(isSave == 0){
            content = json.get("content") + "";
        }
        Set<String> patientSet = new HashSet<>();
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
        String createTime = f.format(new Date())+" 00:00:00";
        //医生今日推送的居民
        List<BirthDayWishesToPatient> sendPatientList = findSendPatientByCreateTime(p.toString(),createTime);
        Set<String> sendPatient = sendPatientList.stream().map(BirthDayWishesToPatient::getPatientCode).collect(Collectors.toSet());
        Set<String> openidSet = new HashSet<>();
        BaseDoctorDO doctor = doctorDao.findById(doctorCode);
        String sql = " select * from ( select p.id as patient,p.name,we.openid from base_patient p inner join  base_patient_wechat we on p.id = we.patient_id and we.patient_id in ( "+p.toString()+") " +
                "  order by we.create_time desc )A group by A.patient  ";
        List<Map<String, Object>> patientInfos = jdbcTemplate.queryForList(sql);
        //批量发送要属于同一批次
        String batchNo = UUID.randomUUID().toString();
        for (Map<String, Object> patientInfo : patientInfos) {
            String s = patientInfo.get("patient") + "";
            //已推送则不再重复推送
            if(!sendPatient.contains(s)) {
                patientSet.add(s);
                //获取已推送居民
                sendPatient.add(s);
            }else {
                continue;
            }
            openidSet.add(patientInfo.get("openid") + "");
            BirthDayWishesToPatient es = new BirthDayWishesToPatient();
            es.setBatchNo(batchNo);
            es.setPatientCode(s);
            es.setPatientName(patientInfo.get("name") + "");
            es.setDoctorCode(doctor.getId());
            es.setDoctorName(doctor.getName());
            es.setUserType(1);
            List<BaseDoctorHospitalDO> hospitalDOs = hospitalDao.findByDoctorCode(doctorCode);
            //存储发送人信息
            es.setSendPic(doctor.getPhoto());
            es.setSendSex(doctor.getSex()+"");
//            es.setAdminTeamName(patientInfo.get("teamName") + "");
//            es.setAdminTeamCode(Long.valueOf(patientInfo.get("admin_team_code")+""));
            if (hospitalDOs.size()>0){
                es.setHospital(hospitalDOs.get(0).getOrgCode());
                es.setHospitalName(hospitalDOs.get(0).getOrgName());
            }
            es.setTown(doctor.getTownCode());
            es.setTownName(doctor.getTownName());
            es.setSendType(sendType);
            es.setSendLevel(doctor.getLevel());
            if (StringUtils.isNotBlank(currentUserRole)){
                es.setCurrentUserRoleCode(currentUserRole);
            }
            if (StringUtils.isNotBlank(currentUserRoleLevel)){
                es.setCurrentUserRoleLevel(currentUserRoleLevel);
            }
            es.setAllCount(patientSet.size());
            es.setOpenidSet(openidSet.toString());
            //生日祝福信息
            es.setBirthday(dateString);
            es.setTemplateId(templateId);
            es.setContent(content);
            es.setCreateTime(DateUtil.getStringDate());
            list.add(es);
        }
        if(list.size()>0){
            //保存到ES中
//            elastricSearchSave.save(list, esIndex, esType);
            //另存一条发送祝福的医生信息,便于查询医生发送祝福的居民列表
            BirthDayWishesToPatient e = new BirthDayWishesToPatient();
            BeanUtils.copyProperties(list.get(0), e);
            e.setUserType(2);
            e.setPatientCode(null);
            e.setPatientName(null);
            list.add(e);
            bwToPatientDao.save(list);
//            System.out.println("ES保存成功!");
            //将发送生日祝福的居民code存起来
            Calendar today = Calendar.getInstance();
            today.set(Calendar.HOUR, 23);
            today.set(Calendar.MINUTE, 59);
            today.set(Calendar.SECOND, 59);
            today.set(Calendar.MILLISECOND, 999);
            redisTemplate.opsForValue().set("birthday:wish:sendPatient", sendPatient);
            redisTemplate.expire("birthday:wish:sendPatient", today.getTimeInMillis() - Calendar.getInstance().getTimeInMillis(), TimeUnit.MILLISECONDS);
        }
        return list;
    }
    /**
     * 获取今日已推送居民
     * @param
     * @return
     */
    public List<BirthDayWishesToPatient> findSendPatientByCreateTime(String patient,String createTime) {
        StringBuffer sql = new StringBuffer("select patient_code patientCode from  birthday_wishes_to_patient  "+
                " where user_type=1 and create_time>'" + createTime + "' ");
        if (StringUtils.isNotBlank(patient)){
            sql.append(" and patient_code in ( "+patient+" ) ") ;
        }
        sql.append(" limit 0,500000 ");
        List<BirthDayWishesToPatient> patientList = jdbcTemplate.query(sql.toString(),new BeanPropertyRowMapper<>(BirthDayWishesToPatient.class));
        return patientList;
    }
}

+ 20 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/contacts/ContactsService.java

@ -182,4 +182,24 @@ public class ContactsService {
        return result;
    }
    /**
     * 服务站列表(平台内所有养老机构)
     *
     */
    public List<Map<String,Object>> getAllOrgListWithSignFlag(String patient){
        List<Map<String,Object>> result = new ArrayList<>();
        String sql =  "select * from base_org org  " ;
        if (StringUtils.isNotBlank(patient)){
            sql +=" LEFT JOIN ( " +
                    "SELECT  DISTINCT i.org_code,'1' as signFlag FROM  base_service_package_sign_record sr,  base_service_package_record r, " +
                    " base_service_package_item i WHERE  sr.id = r.sign_id and sr.status=1 and sr.patient = '"+patient+"'" +
                    " AND r.service_package_id = i.service_package_id " +
                    " AND i.del = 1  AND sr.`status` = 1)A on org.code = A.org_code ";
        }
        sql +=  " where org.del=1 and org.type=3 " ;
        result = jdbcTemplate.queryForList(sql);
        return result;
    }
}

+ 24 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/DeviceService.java

@ -1,13 +1,17 @@
package com.yihu.jw.care.service.device;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.device.DeviceDao;
import com.yihu.jw.entity.care.device.Device;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
/**
 * 设备管理
@ -19,6 +23,8 @@ public class DeviceService extends BaseJpaService<Device, DeviceDao> {
	@Autowired
	private DeviceDao deviceDao;
	@Autowired
	private JdbcTemplate jdbcTemplate;
	/**
@ -35,4 +41,22 @@ public class DeviceService extends BaseJpaService<Device, DeviceDao> {
	{
		return deviceDao.findOne(Long.valueOf(id));
	}
	/**
	 * 获取用户设备绑定类型
	 * @param patient
	 * @return
	 */
	public String getPatientDeviceCategoryCode(String patient){
		if (StringUtils.isNotBlank(patient)){
			String sql = "select Distinct category_code from wlyy_patient_device where user='"+patient+"' and del=0 order by category_code asc";
			List<String> categorys = jdbcTemplate.queryForList(sql,String.class);
			if (categorys.size()>0){
				String categoryStr =  categorys.stream().map(String::valueOf).collect(Collectors.joining(","));
				return categoryStr;
			}
		}
		return "0";
	}
}

+ 4 - 11
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java

@ -2,6 +2,7 @@ package com.yihu.jw.care.service.doctor;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.doorCoach.BaseDoorCoachOrderDao;
import com.yihu.jw.care.service.device.DeviceService;
import com.yihu.jw.care.service.role.RoleService;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
@ -57,6 +58,8 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
    private BaseDoorCoachOrderDao baseDoorCoachOrderDao;
    @Autowired
    private ImService imService;
    @Autowired
    private DeviceService deviceService;
    /**
     * 获取医生详情
@ -364,17 +367,7 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
            }else {
                map.put("age", null);
            }
            if (map.get("deviceType")!=null){
                if ("1,2".equals(map.get("deviceType").toString())){
                    map.put("deviceType",3);//deviceType 设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                }
                else {
                    map.put("deviceType",Integer.valueOf(map.get("deviceType").toString()));
                }
            }
            else {
                map.put("deviceType",0);
            }
            map.put("deviceType",deviceService.getPatientDeviceCategoryCode(map.get("id").toString()));
        }
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }

+ 76 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/family/PatientFamilyMemberService.java

@ -8,6 +8,7 @@ import com.yihu.jw.care.service.wechat.WeiXinAccessTokenUtils;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientFamilyMemberDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.security.MD5;
@ -37,6 +38,8 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
    private ServicePackageSignRecordDao signRecordDao;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private ImUtil imUtil;
@ -444,6 +447,79 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
        return resultArray;
    }
    /**
     * 获取居民的家庭成员
     */
    public JSONArray membersWithOnLineFlag(String patient) {
        JSONArray resultArray = new JSONArray();
        String sql = "select *,CAST(t2.archive_type as char) as archive_type " +
                " from " +
                "    base_patient_family_member t1, " +
                "    base_patient t2 " +
                " where " +
                "    t2.id in (select family_member from base_patient_family_member where patient = ? ) " +
                "    and t1.patient = ? " +
                "    and t1.family_member = t2.id ";
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{patient, patient});
        if (result != null && result.size() > 0) {
            for (Map<String, Object> map : result) {
                JSONObject obj = new JSONObject();
                List<ServicePackageSignRecordDO> signs = signRecordDao.findByStatusAndPatient(1,map.get("family_member").toString());
                boolean jtSign = false;
                int status = 0;
                if(signs.size()>0){
                    jtSign = true;
                    status = 1;
                }
                Integer isAuthorize = (Integer) map.get("is_authorize");
                obj.put("id", map.get("id"));
                obj.put("name", map.get("name"));
                obj.put("isContacts", map.get("is_contacts"));
                obj.put("sex", map.get("sex"));
                obj.put("isAuthorize", isAuthorize);//0:未授权,1:已授权
                obj.put("birthday", map.get("birthday"));
                obj.put("idcard", StringUtils.isEmpty(String.valueOf(map.get("idcard"))) ? "" : map.get("idcard").toString());
                obj.put("photo", map.get("photo"));
                obj.put("mobile", map.get("mobile"));
                obj.put("address", StringUtils.isEmpty(String.valueOf(map.get("address"))) ? "" : map.get("address"));
                obj.put("familyRelation", map.get("family_relation"));
                obj.put("familyRelationName", relations.get(map.get("family_relation")));
                if (jtSign) {
                    obj.put("signType", 1);
                } else {
                    obj.put("signType", 0);
                }
                obj.put("state", "1");//0 :未处理;1:已同意;2:已拒绝
                String archive_type = null;
                Integer onLineFlag =0;
                switch (map.get("archive_type").toString()){
                    case "1":
                        archive_type = "older";//老人
                        break;
                    case "2":
                        archive_type = "child";//新生儿
                        break;
                }
                if (StringUtils.isNotBlank(archive_type)){
                    String onLineStr = imUtil.findByUserIdAndType(map.get("id").toString(),archive_type);
                    JSONObject oneLineObj = JSONObject.parseObject(onLineStr);
                    if (200 == oneLineObj.getInteger("status")){
                        if (oneLineObj.getInteger("data")>0){
                            onLineFlag=1;
                        }
                    }
                }
                obj.put("onLineFlag", onLineFlag);
                resultArray.add(obj);
            }
        }
        return resultArray;
    }
    /**
     * 获取有授权的家庭成员
     *

+ 6 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/label/PatientLableService.java

@ -2,6 +2,7 @@ package com.yihu.jw.care.service.label;
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
import com.yihu.jw.care.service.common.DictService;
import com.yihu.jw.care.service.device.DeviceService;
import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
import com.yihu.jw.restmodel.web.PageEnvelop;
@ -24,6 +25,8 @@ public class PatientLableService extends BaseJpaService<WlyyPatientLabelDO, Wlyy
    private WlyyPatientLabelDao patientLabelDao;
    @Autowired
    private DictService dictService;
    @Autowired
    private DeviceService deviceService;
    /**
     * 按团队查找签约居民的标签统计
@ -58,8 +61,8 @@ public class PatientLableService extends BaseJpaService<WlyyPatientLabelDO, Wlyy
     * @return
     */
    public PageEnvelop<List<Map<String,Object>>> findSignPatientLabelListByTeamCode(String teamCode, String labelCode, String name, int page, int size){
        String sql = "SELECT DISTINCT p.id,p.name,p.photo,p.idcard,p.mobile,p.openid,p.sex " ;
        String countSql = "SELECT count(p.id) ";
        String sql = "SELECT DISTINCT p.id,p.name,p.photo,p.idcard,p.mobile,p.openid,p.sex,p.pad_imei padImei " ;
        String countSql = "SELECT count(DISTINCT p.id) ";
        String filters = "from base_service_package_sign_record sr,base_service_package_record r,  " +
                "                base_service_package_item i,base_patient p,wlyy_patient_label l " +
                "                WHERE sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id  " +
@ -74,6 +77,7 @@ public class PatientLableService extends BaseJpaService<WlyyPatientLabelDO, Wlyy
        for (Map<String,Object> map : list){
            String idcard = map.get("idcard").toString();
            map.put("age", IdCardUtil.getAgeForIdcard(idcard));
            map.put("deviceType",deviceService.getPatientDeviceCategoryCode(map.get("id").toString()));
        }
        Long count = jdbcTemplate.queryForObject(countSql+filters,Long.class);
        return PageEnvelop.getSuccessListWithPage("success",list,page,size,count);

+ 25 - 5
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/PatientMessageService.java

@ -76,16 +76,36 @@ public class PatientMessageService {
    public List<Map<String,Object>> getSystemMessage(String patient){
        String sql = " select A.*,B.notRead from " +
                "(select  count(1) as 'all',type,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') create_time " +
                "from base_system_message where receiver = '"+patient+"' and del=1 and type='50' GROUP BY type ORDER BY create_time desc)A " +
                "from base_system_message where receiver = '"+patient+"' and del=1  GROUP BY type ORDER BY create_time desc)A " +
                "LEFT JOIN (select count(1) notRead,type " +
                "from base_system_message where receiver = '"+patient+"' and is_read=0 and del=1 and type='50' GROUP BY type)B on A.type = B.type " +
                "from base_system_message where receiver = '"+patient+"' and is_read=0 and del=1  GROUP BY type)B on A.type = B.type " +
                "ORDER BY A.create_time desc ";
        return jdbcTemplate.queryForList(sql);
    }
    public List<Map<String,Object>> getSystemMessageList(String patient,String type){
        String sql = " select id,title,type,relation_code,sender,sender_name,is_read,code,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') create_time " +
                "from base_system_message where receiver = '"+patient+"' and del=1 and type='"+type+"'  ORDER BY create_time desc";
    /**
     *
     * @param patient
     * @param type
     * type=50,code:20紧急救助 22安防监护
     * type=41,code:1 生日祝福
     * type=42,code与体征类型对应 体征设备数据
     *
     * @return
     */
    public List<Map<String,Object>> getSystemMessageList(String patient,String type,String isRead){
        String typeIn = " '"+type.replace(",","','")+"' ";
        String sql = " select id,title,type,relation_code,sender,content,sender_name,is_read,code,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') create_time,data " +
                "from base_system_message where receiver = '"+patient+"' and del=1 and type in ("+typeIn+" )  " ;
        if (StringUtils.isNotBlank(isRead)){
            if ("1".equals(isRead)){
                sql += " and is_read = '1'";
            }else {
                sql += " and ( is_read = '0' or is_read is null ) ";
            }
        }
         sql +=  "ORDER BY create_time desc";
        return jdbcTemplate.queryForList(sql);
    }

+ 23 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java

@ -15,6 +15,7 @@ import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
import com.yihu.jw.entity.care.apply.PatientBedApplyDo;
import com.yihu.jw.entity.care.archive.ArchiveDO;
import com.yihu.jw.entity.care.sign.CapacityAssessmentRecordDO;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.service.BasePatientMedicardCardService;
import com.yihu.jw.restmodel.ResponseContant;
@ -72,6 +73,8 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
    private StringRedisTemplate redisTemplate;
    @Autowired
    private PatientBedApplyDao bedApplyDao;
    @Autowired
    private ImUtil imUtil;
    /**
     * 查找签约机构
@ -520,8 +523,8 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        return result;
    }
    public List<Map<String,Object>> getServerDoctorAll(String patient){
        String sql="select DISTINCT doc.id doctor,CONCAT(doc.`name`,CASE WHEN doc.doctor_level=1 THEN '(社区医生)' ELSE '(助老员)' END) as name,doc.photo,doc.mobile\n" +
    public List<Map<String,Object>> getServerDoctorAll(String patient,String onlineFlag){
        String sql="select DISTINCT doc.id doctor,CONCAT(doc.`name`,CASE WHEN doc.doctor_level=1 THEN '(社区医生)' ELSE '(助老员)' END) as name,doc.photo,doc.mobile,0 as onLineFlag\n" +
                "from base_service_package_item item ,base_service_package pack,base_team_member mem,base_doctor doc\n" +
                "where item.service_package_id in (\n" +
                "SELECT spc.service_package_id FROM base_service_package_record spc ,base_service_package_sign_record spsr\n" +
@ -529,6 +532,24 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
                ") and item.service_package_id = pack.id\n" +
                "and item.team_code = mem.team_code and mem.doctor_code = doc.id and mem.del=1 and pack.del=1 and item.del = 1";
        List<Map<String,Object>>result = jdbcTemplate.queryForList(sql);
        if ("1".equals(onlineFlag)){//展示是否在线
            String listStr = imUtil.getOnlineListByType("helper");
            JSONObject onLineObj  = JSONObject.parseObject(listStr);
            if (200 == onLineObj.getInteger("status")){
                JSONObject oneLineInfo = onLineObj.getJSONObject("helper");
                for (Map<String,Object>tmp:result){
                    String doctorCode = tmp.get("doctor").toString();
                    if (oneLineInfo.containsKey(doctorCode)){
                        if (oneLineInfo.getInteger(doctorCode)>0){
                            tmp.put("onLineFlag",1);
                        }
                    }
                }
            }
            else {
                logger.info("获取用户在线列表失败:"+patient);
            }
        }
        return result;
    }

+ 8 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MessageUtil.java

@ -96,7 +96,7 @@ public class MessageUtil {
     * @param json 用于对跳转连接的修改,
     * @param keywords
     */
    public void putTemplateWxMessage(String wechatId, String templateName, String scene, String openId, String first
    public boolean putTemplateWxMessage(String wechatId, String templateName, String scene, String openId, String first
            ,String url, String remark, Integer type,JSONObject json,String ...keywords) {
        try {
            System.out.println(wechatId);
@ -104,14 +104,14 @@ public class MessageUtil {
            if (wxAccessTokenDO == null) {
                logger.info("wx_access_token表获取为空,wechatId" + wechatId);
                return;
                return false;
            }
            WxTemplateConfigDO templateConfig = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, templateName, scene, 1);
            WxTemplateConfigDO newConfig = new WxTemplateConfigDO();
            BeanUtils.copyProperties(templateConfig,newConfig);
            if (newConfig == null) {
                logger.info("微信模板不存在!请确认wechatId:" + wechatId + ",templateName:" + templateName + ",scene:" + scene);
                return;
                return false;
            }
            logger.info("微信模板推送前");
            if (StringUtils.isNoneBlank(first)){
@ -163,9 +163,11 @@ public class MessageUtil {
            //发起微信消息模板推送
            weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(), openId, newConfig);
            logger.info("微信模板消息推送后");
            return true;
        } catch (Exception e) {
            logger.info("微信模板推送异常");
            e.printStackTrace();
            return false;
        }
    }
@ -207,6 +209,9 @@ public class MessageUtil {
                }
                wxTemplateConfigDO.setUrl(url + urlStr );
                break;
            case 26://生日祝福
                wxTemplateConfigDO.setUrl(wxTemplateConfigDO.getUrl()+"?openid=" + openid + "&content=" + json.getString("content") + "&doctorName=" + json.getString("doctorName") + "&toUser=" + json.getString("toUser")  + "&toName=" + json.getString("name") + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):""));
                break;
            case 30:
                //反馈通知 测试 TPbq9m0SAiVfRhXtXq17SDmYIfrJ8Whp2NpSrq9wlfI
                if(json.containsKey("consult")) {

+ 1 - 1
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/DeviceController.java

@ -226,7 +226,7 @@ public class DeviceController {
        }
    }
    @ApiOperation("柏颐设备步数接收")
    @ApiOperation("设备步数接收")
    @RequestMapping(value = "bySteps", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String bySteps(
            @ApiParam(name="imei",required = false,value="15位设备唯一序号",defaultValue = "")

+ 97 - 7
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java

@ -1,7 +1,9 @@
package com.yihu.jw.care.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.jw.care.config.AqgConfig;
import com.yihu.jw.care.dao.device.DevicePatientHealthIndexDao;
import com.yihu.jw.care.dao.device.DeviceSosLogDao;
@ -10,11 +12,15 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.device.DeviceSosLogDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.util.AesEncryptUtils;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.GpsUtil;
import com.yihu.jw.util.common.LatitudeUtils;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.healthIndex.HealthIndexUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
@ -64,6 +70,12 @@ public class DeviceService {
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private GpsUtil gpsUtil;
    @Autowired
    private SystemMessageDao systemMessageDao;
    @Autowired
    private HealthIndexUtil healthIndexUtil;
    @Autowired
    private ImUtil imUtil;
    /**
     * 获取爱牵挂管理员cookie
@ -329,9 +341,9 @@ public class DeviceService {
    @Async
    public void byHeartRate(String imei,String time_begin,int heartrate,int theshold_heartrate_h,int theshold_heartrate_l) {
        try {
            if(StringUtils.isNotBlank(imei)){
            if(StringUtils.isNotBlank(imei)) {
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(imei);
                if (devicePatientDeviceDos.size()>0){
                if (devicePatientDeviceDos.size() > 0) {
                    DevicePatientDevice devicePatientDevice = devicePatientDeviceDos.get(0);
                    BasePatientDO patientDO = patientDao.findById(devicePatientDevice.getUser());
                    DevicePatientHealthIndex patientHealthIndex = new DevicePatientHealthIndex();
@ -339,23 +351,62 @@ public class DeviceService {
                    patientHealthIndex.setDeviceSn(imei);
                    patientHealthIndex.setUser(devicePatientDevice.getUser());
                    patientHealthIndex.setIdcard(devicePatientDevice.getUserIdcard());
                    patientHealthIndex.setValue1(heartrate+"");
                    patientHealthIndex.setValue1(heartrate + "");
                    patientHealthIndex.setType(5);
                    Date recordDate = DateUtil.strToDate(time_begin);
                    patientHealthIndex.setRecordDate(recordDate);
                    patientHealthIndex.setSortDate(recordDate);
                    patientHealthIndex.setCzrq(new Date());
                    if (heartrate>=theshold_heartrate_h||heartrate<=theshold_heartrate_l){
                    if (heartrate >= theshold_heartrate_h || heartrate <= theshold_heartrate_l) {
                        patientHealthIndex.setStatus(1);
                    }
                    else {
                    } else {
                        patientHealthIndex.setStatus(0);
                    }
                    patientHealthIndex.setDel("1");
                    healthIndexDao.save(patientHealthIndex);
                    SystemMessageDO messageDO = new SystemMessageDO();
                    String typeName = "您有新的心率测量记录。心率:" + patientHealthIndex.getValue1() + "次/min";
                    messageDO.setTitle(typeName);
                    messageDO.setType("52");//52体征测量
                    messageDO.setSender("system");
                    messageDO.setSenderName("养护助手");
                    messageDO.setRelationCode(patientHealthIndex.getId() + "");
                    messageDO.setReceiver(patientDO.getId());
                    messageDO.setReceiverName(patientDO.getName());
                    messageDO.setOver("1");
                    messageDO.setCode("5");//与体征类型对应
                    JSONArray errorIndex = healthIndexUtil.verifyHealthIndex(5,patientHealthIndex.getValue1(),patientHealthIndex.getValue2(),
                            patientHealthIndex.getValue3(),patientHealthIndex.getValue4(),patientHealthIndex.getValue5(),patientHealthIndex.getValue6(),
                            patientHealthIndex.getValue7());
                    messageDO.setData(JSON.toJSONString(errorIndex,SerializerFeature.WriteNullStringAsEmpty));
                    messageDO.setDel("1");
                    messageDO.setCreateTime(new Date());
                    //推送socket
                    com.alibaba.fastjson.JSONObject message = new com.alibaba.fastjson.JSONObject();
                    message.put("title","您刚刚测量了一次心率");
                    message.put("code",messageDO.getCode());
                    message.put("content",messageDO.getData());
                    message.put("relation_code",messageDO.getRelationCode());
                    message.put("content_type",42);
                    message.put("content_notice","");
                    String content_notice = null;
                    for (int i=0;i<errorIndex.size();i++){
                        com.alibaba.fastjson.JSONObject tmp = errorIndex.getJSONObject(i);
                        if (1 == tmp.getInteger("error")){
                            content_notice += tmp.getString("indexName"+"、");
                        }
                    }
                    if (org.apache.commons.lang3.StringUtils.isNotBlank(content_notice)){
                        content_notice.substring(0,content_notice.length()-2);
                        message.put("content_notice","您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice));
                    }
                    messageDO.setContent("您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice));
                    systemMessageDao.save(messageDO);
                    imUtil.sendPatientSystemMessage(messageDO.getReceiver(),JSON.toJSONString(message,SerializerFeature.WriteMapNullValue));
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
@ -398,6 +449,45 @@ public class DeviceService {
                    }
                    patientHealthIndex.setDel("1");
                    healthIndexDao.save(patientHealthIndex);
                    SystemMessageDO messageDO = new SystemMessageDO();
                    String typeName = "您有新的血压测量记录:收缩压:"+patientHealthIndex.getValue1()+"mmHg,收缩压:"
                            +patientHealthIndex.getValue2()+"mmHg,脉搏:"+patientHealthIndex.getValue3()+"次/min";
                    messageDO.setTitle(typeName);
                    messageDO.setType("52");//52体征测量
                    messageDO.setSender("system");
                    messageDO.setSenderName("养护助手");
                    messageDO.setRelationCode(patientHealthIndex.getId() + "");
                    messageDO.setReceiver(patientDO.getId());
                    messageDO.setReceiverName(patientDO.getName());
                    messageDO.setOver("1");
                    messageDO.setCode("2");//与体征类型对应
                    JSONArray errorIndex = healthIndexUtil.verifyHealthIndex(2,patientHealthIndex.getValue1(),patientHealthIndex.getValue2(),patientHealthIndex.getValue3());
                    messageDO.setData(JSON.toJSONString(errorIndex,SerializerFeature.WriteNullStringAsEmpty));
                    messageDO.setDel("1");
                    messageDO.setCreateTime(new Date());
                    //推送socket
                    com.alibaba.fastjson.JSONObject message = new com.alibaba.fastjson.JSONObject();
                    message.put("title","您刚刚测量了一次血压");
                    message.put("code",messageDO.getCode());
                    message.put("content",messageDO.getData());
                    message.put("relation_code",messageDO.getRelationCode());
                    message.put("content_type",42);
                    message.put("content_notice","");
                    String content_notice = null;
                    for (int i=0;i<errorIndex.size();i++){
                        com.alibaba.fastjson.JSONObject tmp = errorIndex.getJSONObject(i);
                        if (1 == tmp.getInteger("error")){
                            content_notice += tmp.getString("indexName"+"、");
                        }
                    }
                    if (org.apache.commons.lang3.StringUtils.isNotBlank(content_notice)){
                        content_notice.substring(0,content_notice.length()-2);
                        message.put("content_notice","您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice));
                    }
                    messageDO.setContent("您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice));
                    systemMessageDao.save(messageDO);
                    imUtil.sendPatientSystemMessage(messageDO.getReceiver(),JSON.toJSONString(message,SerializerFeature.WriteMapNullValue));
                }
            }

+ 72 - 1
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceUploadService.java

@ -1,5 +1,8 @@
package com.yihu.jw.care.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.dao.device.DeviceInfoDao;
@ -11,9 +14,14 @@ import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.DeviceInfo;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.healthIndex.HealthIndexUtil;
import com.yihu.jw.utils.StringUtil;
import jdk.management.resource.internal.inst.FileOutputStreamRMHooks;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -44,8 +52,14 @@ public class DeviceUploadService {
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private DevicePatientHealthIndexDao patientHealthIndexDao;
    @Autowired
    private SystemMessageDao systemMessageDao;
    @Autowired
    private HealthIndexUtil healthIndexUtil;
    @Autowired
    private ImUtil imUtil;
    public Result uploadDevicesData(String dataJson) {
    public Result uploadDevicesData(String dataJson)throws Exception {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            Map<String, Object> map = objectMapper.readValue(dataJson, Map.class);
@ -102,6 +116,63 @@ public class DeviceUploadService {
                logger.info("This device is not relate patient!:====="+dataJson);
                throw new Exception("This device is not relate patient!");
            }
            //保存消息
            BasePatientDO patientDO = patientDao.findById(result.getUser());
            if (null != patientDO){
                SystemMessageDO messageDO = new SystemMessageDO();
                String typeName = null;
                String typeName2 = null;
                switch (type){
                    case "1":
                        typeName = "您有新的血糖测量记录:血糖浓度:"+result.getValue1()+"mmol/L";
                        typeName2 = "您刚刚测量了一次血糖";
                        break;
                    case "2":
                        typeName = "您有新的血压测量记录:收缩压:"+result.getValue1()+"mmHg,收缩压:"
                                +result.getValue2()+"mmHg,脉搏:"+result.getValue3()+"次/min";
                        typeName2 = "您刚刚测量了一次血压";
                        break;
                }
                if (StringUtils.isNotBlank(typeName)){
                    messageDO.setTitle(typeName);
                    messageDO.setType("42");//42体征设备测量
                    messageDO.setSender("system");
                    messageDO.setSenderName("养护助手");
                    messageDO.setRelationCode(result.getId()+"");
                    messageDO.setReceiver(patientDO.getId());
                    messageDO.setReceiverName(patientDO.getName());
                    messageDO.setOver("1");
                    messageDO.setCode(type);//与体征类型对应
                    JSONArray errorIndex = healthIndexUtil.verifyHealthIndex(Integer.parseInt(type),result.getValue1(),result.getValue2(),
                            result.getValue3(),result.getValue4(),result.getValue5(),result.getValue6(),
                            result.getValue7());
                    messageDO.setData(JSON.toJSONString(errorIndex,SerializerFeature.WriteNullStringAsEmpty));
                    messageDO.setDel("1");
                    messageDO.setCreateTime(new Date());
                    //推送socket
                    com.alibaba.fastjson.JSONObject message = new com.alibaba.fastjson.JSONObject();
                    message.put("title",typeName2);
                    message.put("code",messageDO.getCode());
                    message.put("content",messageDO.getData());
                    message.put("relation_code",messageDO.getRelationCode());
                    message.put("content_type",42);
                    message.put("content_notice","");
                    String content_notice = null;
                    for (int i=0;i<errorIndex.size();i++){
                        com.alibaba.fastjson.JSONObject tmp = errorIndex.getJSONObject(i);
                        if (1 == tmp.getInteger("error")){
                            content_notice += tmp.getString("indexName"+"、");
                        }
                    }
                    if (StringUtils.isNotBlank(content_notice)){
                        content_notice.substring(0,content_notice.length()-2);
                        message.put("content_notice","您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice));
                    }
                    messageDO.setContent("您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice));
                    systemMessageDao.save(messageDO);
                    imUtil.sendPatientSystemMessage(messageDO.getReceiver(),JSON.toJSONString(message,SerializerFeature.WriteMapNullValue));
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.getMessage());

+ 0 - 2
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/SyncWlyyHospitalService.java

@ -204,10 +204,8 @@ public class SyncWlyyHospitalService {
                    }
                    WlyyAdminTeamMemberDO wlyyAdminTeamMemberDO=wlyyAdminTeamMemberDao.findOne(wlyyAdminTeamMember.getId());
                    if(wlyyAdminTeamMemberDO==null){
                        wlyyAdminTeamMemberDO.setLastModified(new Date());
                        addCount++;
                    }else{
                        wlyyAdminTeamMemberDO.setLastModified(new Date());
                        updateCount++;
                    }
                    wlyyAdminTeamMemberDao.save(wlyyAdminTeamMember);