Browse Source

代码修改

chenweida 7 years ago
parent
commit
afabc11fb2

+ 14 - 0
common/common-entity/pom.xml

@ -45,5 +45,19 @@
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
        </dependency>
        <dependency>
            <groupId>io.searchbox</groupId>
            <artifactId>jest</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-commons</artifactId>
            <version>1.11.4.RELEASE</version>
        </dependency>
    </dependencies>
</project>

+ 189 - 0
common/common-entity/src/main/java/com/yihu/es/entity/HealthEduArticlePatient.java

@ -0,0 +1,189 @@
package com.yihu.es.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.searchbox.annotations.JestId;
import org.springframework.data.annotation.CreatedDate;
import java.util.Date;
/**
 * 推送记录表
 * Created by chenweida on 2017/9/7.
 */
public class HealthEduArticlePatient {
    @JestId
    private String id;
    private String patient; // 患者标识
    private String patientName;    // 患者标识
    private String sendCode;   // 发送人code
    private String sendName;   // 发送人名称
    private Integer sendType;//发送类型 1医生发送 2卫纪委发送
    private Long adminTeamCode;// 行政团队
    private String adminTeamName;// 行政团队
    private String hospital; // 所属机构
    private String hospitalName; // 所属机构
    private String town; // 所属区划
    private String townName; // 所属区划
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyyMMdd'T'HHmmss.SSS'Z'")
    @CreatedDate
    private Date createTime;  // 创建时间
    private String batchNo;//批次号记录发送所属批次
    private String articleId;  //文章id
    private String attachedTitle;  //文章标题
    private String attachedPic;//文章封面
    private String attachedContent; //文章内容
    private String attachedMessage; //文章附加文件
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    public String getSendCode() {
        return sendCode;
    }
    public void setSendCode(String sendCode) {
        this.sendCode = sendCode;
    }
    public String getSendName() {
        return sendName;
    }
    public void setSendName(String sendName) {
        this.sendName = sendName;
    }
    public Integer getSendType() {
        return sendType;
    }
    public void setSendType(Integer sendType) {
        this.sendType = sendType;
    }
    public Long getAdminTeamCode() {
        return adminTeamCode;
    }
    public void setAdminTeamCode(Long adminTeamCode) {
        this.adminTeamCode = adminTeamCode;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getTown() {
        return town;
    }
    public void setTown(String town) {
        this.town = town;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getBatchNo() {
        return batchNo;
    }
    public void setBatchNo(String batchNo) {
        this.batchNo = batchNo;
    }
    public String getArticleId() {
        return articleId;
    }
    public void setArticleId(String articleId) {
        this.articleId = articleId;
    }
    public String getAttachedTitle() {
        return attachedTitle;
    }
    public void setAttachedTitle(String attachedTitle) {
        this.attachedTitle = attachedTitle;
    }
    public String getAttachedPic() {
        return attachedPic;
    }
    public void setAttachedPic(String attachedPic) {
        this.attachedPic = attachedPic;
    }
    public String getAttachedContent() {
        return attachedContent;
    }
    public void setAttachedContent(String attachedContent) {
        this.attachedContent = attachedContent;
    }
    public String getAttachedMessage() {
        return attachedMessage;
    }
    public void setAttachedMessage(String attachedMessage) {
        this.attachedMessage = attachedMessage;
    }
    public String getAdminTeamName() {
        return adminTeamName;
    }
    public void setAdminTeamName(String adminTeamName) {
        this.adminTeamName = adminTeamName;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public String getTownName() {
        return townName;
    }
    public void setTownName(String townName) {
        this.townName = townName;
    }
}

+ 73 - 0
patient-co/patient-co-wlyy/doc/技术文档/es/统计新增索引.txt

@ -0,0 +1,73 @@
创建索引
POST  http://172.19.103.68:9200/health_edu_article_patient_test
查询索引
GET http://172.19.103.68:9200/health_edu_article_patient_test/
给索引加mapping
POST http://172.19.103.68:9200/health_edu_article_patient_test/health_edu_article_patient_test/_mapping
{
    "health_edu_article_patient_test": {
            "properties": {
                "patient": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "patientName": {
                    "type": "string"
                },
                "doctor": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "doctorName": {
                    "type": "string"
                },
                "adminTeamCode": {
                    "type": "integer"
                },
                "adminTeamName": {
                    "type": "string"
                },
                "hospital": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "hospitalName": {
                    "type": "string"
                },
                "town": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "townName": {
                    "type": "string"
                },
                "batchNo": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "articleId": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "attachedTitle": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "attachedPic": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "attachedContent": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "attachedMessage": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "createTime": {
                    "type": "date"
                }
            }
        }
  }

BIN
patient-co/patient-co-wlyy/doc/接口文档/对外接口文档/集美健康教育/集美健康教育对外接口文档.docx


+ 6 - 0
patient-co/patient-co-wlyy/pom.xml

@ -403,6 +403,12 @@
            <groupId>com.ylz</groupId>
            <artifactId>onpay-java-sdk-all</artifactId>
        </dependency>
        <dependency>
            <groupId>org.nlpcn</groupId>
            <artifactId>elasticsearch-sql</artifactId>
            <version>2.4.1.0</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>wlyy</finalName>

+ 94 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/es/ElasticFactory.java

@ -0,0 +1,94 @@
package com.yihu.wlyy.config.es;
import com.google.common.util.concurrent.MoreExecutors;
import io.searchbox.client.JestClient;
import io.searchbox.client.JestClientFactory;
import io.searchbox.client.config.HttpClientConfig;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.annotation.PostConstruct;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.concurrent.TimeUnit;
/**
 * Created by chenweida on 2017/6/5.
 */
@Component
public class ElasticFactory {
    private static JestClientFactory factory = null;
    @Value("${es.host}")
    private String esHost;
    @Value("${es.port}")
    private String port;
    @Value("${es.tPort}")
    private String tPort;
    @Value("${es.clusterName}")
    private String clusterName;
//-----------------------------------jestClient----------------------------------------
    /**
     * @param "http://localhost:9200"
     * @return
     */
    @PostConstruct
    public JestClient getJestClient() {
        synchronized (ElasticFactory.class) {
            if (factory == null) {
                //初始化链接
                init();
            }
        }
        return factory.getObject();
    }
    /**
     * 初始化链接
     */
    public synchronized void init() {
        // Construct a new Jest client according to configuration via factory
        factory = new JestClientFactory();
        factory.setHttpClientConfig(new HttpClientConfig
                .Builder("http://" + esHost + ":" + port)
                .multiThreaded(true)
                .maxTotalConnection(50)// 最大链接
                .maxConnectionIdleTime(120, TimeUnit.SECONDS)//链接等待时间
                .connTimeout(30000)
                .discoveryEnabled(true)
                .readTimeout(30000)//30秒
                .build());//得到链接
    }
    //-----------------------------------TransportClient----------------------------------------
    private Client transportClient;
    public Client getTransportClient() {
        try {
            initTranClient();
            return transportClient;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    private synchronized void initTranClient() throws UnknownHostException {
        if (transportClient == null) {
            Settings settings = Settings.settingsBuilder()
                    .put("client.transport.sniff", true)//开启嗅探功能
                    .put("cluster.name", StringUtils.isEmpty(clusterName) ? "jkzl" : clusterName)//默认集群名字是jkzl
                    .build();
            transportClient = TransportClient.builder().settings(settings).build()
                    .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(esHost), Integer.valueOf(tPort)));
        }
    }
}

+ 52 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/es/ElastricSearchSave.java

@ -0,0 +1,52 @@
package com.yihu.wlyy.config.es;
import io.searchbox.client.JestClient;
import io.searchbox.core.Bulk;
import io.searchbox.core.BulkResult;
import io.searchbox.core.Index;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
;
/**
 * Created by chenweida on 2017/6/2.
 */
@Component
@Scope("prototype")
public class ElastricSearchSave {
    private Logger logger = LoggerFactory.getLogger(ElastricSearchSave.class);
    @Autowired
    private ElasticFactory elasticFactory;
    public Boolean save(List  sms,String esIndex,String esType) {
        try {
            //得到链接
            JestClient jestClient = elasticFactory.getJestClient();
            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
            for (Object obj : sms) {
                Index index = new Index.Builder(obj).build();
                bulk.addAction(index);
            }
            BulkResult br = jestClient.execute(bulk.build());
            logger.info("save data count:" + sms.size());
            logger.info("save flag:" + br.isSucceeded());
            return br.isSucceeded();
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(" save error :" + e.getMessage());
        }
        return null;
    }
}

+ 1 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/HealthEduArticleService.java

@ -249,6 +249,7 @@ public class HealthEduArticleService extends BaseService {
                "  where" +
                "    a.article = b.code " +
                "    and a.doctor = d.code " +
                "   and ( a.send_type =1 or a.send_type is null or a.send_type = '') "+  //添加类型判断是集美的推送还是三师原来的推送
                "    and a.patient = ?" +
                "    and a.admin_team_code = ?" +
                "  order by a.czrq desc limit " + page*pageSize + "," + pageSize;

+ 5 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -4040,11 +4040,13 @@ public class FamilyContractService extends BaseService {
                "  wlyy_sign_family a ," +
                "  wlyy_patient p ," +
                "WHERE " +
                "  a.admin_team_code =? " +
                " AND a.patient=p.`code` " +
                "  a.patient=p.`code` " +
                " AND a.`status` IN (1, 2) ");
        List params = new ArrayList<>();
        params.add(teamCode);
        if (teamCode!=null&&teamCode>0) {
            sb.append(" AND a.admin_team_code =?  ");
            params.add(teamCode);
        }
        if (!org.springframework.util.StringUtils.isEmpty(patientName)) {
            sb.append(" AND a.`name` LIKE ? ");
            params.add("%" + patientName + "%");

+ 3 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcDoctorController.java

@ -121,7 +121,7 @@ public class GcDoctorController extends BaseController {
    @RequestMapping(value = "/signPatientsByName", method = RequestMethod.GET)
    @ApiOperation("查找医生所属团队下的某个居民")
    public ResultPageListModel<PatientModel> signPatientsByName(
            @ApiParam(name = "teamCode", value = "所属团队", required = true) @RequestParam(value = "teamCode", required = true) Long teamCode,
            @ApiParam(name = "teamCode", value = "所属团队", required = false) @RequestParam(value = "teamCode", required = false) Long teamCode,
            @ApiParam(name = "patientName", value = "患者名称", required = false) @RequestParam(value = "patientName", required = false) String patientName,
            @ApiParam(name = "page", value = "当前页(1开始)", required = true) @RequestParam(value = "page", required = true, defaultValue = "1") Integer page,
            @ApiParam(name = "pageSize", value = "每页大小", required = true) @RequestParam(value = "pageSize", required = true, defaultValue = "10") Integer pageSize
@ -136,8 +136,8 @@ public class GcDoctorController extends BaseController {
                    patientModels.add(patientModel);
                });
            }
           Integer count= familyContractService.signPatientsByNameCount(teamCode, patientName);
            return new ResultPageListModel(page,pageSize,count,patientModels);
            Integer count = familyContractService.signPatientsByNameCount(teamCode, patientName);
            return new ResultPageListModel(page, pageSize, count, patientModels);
        } catch (Exception e) {
            return new ResultPageListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());
        }

+ 34 - 15
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcEduArticleController.java

@ -1,10 +1,9 @@
package com.yihu.wlyy.web.third.gateway.controller.doctor;
import com.yihu.wlyy.entity.education.HealthEduArticlePatient;
import com.yihu.wlyy.config.es.ElastricSearchSave;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.app.health.HealthEduArticleService;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
@ -23,6 +22,7 @@ import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@ -58,7 +58,6 @@ public class GcEduArticleController extends WeixinBaseController {
    @Autowired
    private GcEduArticleService gcEduArticleService;
    /**
     *
     * @param doctorCode
@ -83,6 +82,24 @@ public class GcEduArticleController extends WeixinBaseController {
            return write(-1, "查询失败!");
        }
    }
    /**
     *
     * @param articleCodes
     * @return
     */
    @RequestMapping(value = "articleSendNums", method = RequestMethod.POST)
    @ApiOperation("文章的推送次数 ")
    @ResponseBody
    public String articleSendNums(
            @ApiParam(name = "articleCodes", value = "文章codes 多个逗号分割", required = false) @RequestParam(value = "articleCodes", required = false) String articleCodes) {
        try {
            //List<Map<String, Object>> result = gcEduArticleService.findByDoctor(doctorCode, page, pagesize);
            return write(200, "查询成功!", "list", "");
        } catch (Exception e) {
            return write(-1, "查询失败!");
        }
    }
    /**
     * 参考原来的教育文章推送
@ -103,18 +120,19 @@ public class GcEduArticleController extends WeixinBaseController {
    @RequestMapping(value = "send", method = RequestMethod.POST)
    @ApiOperation("文章推送")
    public BaseResultModel send(
            @ApiParam(name = "sendType", value = "发送类型 1医生发送 2卫纪委发送", required = true) @RequestParam(value = "sendType", required = true) String sendType,
            @ApiParam(name = "sendType", value = "发送类型 1医生发送 2卫纪委发送", required = true) @RequestParam(value = "sendType", required = true) Integer sendType,
            @ApiParam(name = "sendCode", value = "发送人code", required = true) @RequestParam(value = "sendCode", required = true) String sendCode,
            @ApiParam(name = "sendName", value = "发送人名", required = true) @RequestParam(value = "sendName", required = true) String sendName,
            @ApiParam(name = "sendMessage", value = "发送人信息", required = false) @RequestParam(value = "sendMessage", required = false) String sendMessage,
            @ApiParam(name = "teamId", value = "发送人是医生的时候,医生所属的团队", required = true) @RequestParam(value = "teamId", required = true) Long teamId,
            @ApiParam(name = "teamId", value = "发送人是医生的时候,医生所属的团队", required = false) @RequestParam(value = "teamId", required = false) Long teamId,
            @ApiParam(name = "labelCode", value = "所选群组,多个用逗号分隔", required = true) @RequestParam(value = "labelCode", required = false, defaultValue = "") String labelCode,
            @ApiParam(name = "labelType", value = "标签类型  1:服务类型(卫计委分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = true) @RequestParam(value = "labelType", required = false, defaultValue = "") String labelType,
            @ApiParam(name = "receiveCodes", value = "接收人code,多个逗号分割", required = false) @RequestParam(value = "receiveCodes", required = false, defaultValue = "") String receiveCodes,
            @ApiParam(name = "unReceiveCodes", value = "不接收人code,多个逗号分割(如果同时存在receiveCodes和unReceiveCodes,也不会发送)", required = false) @RequestParam(value = "unReceiveCodes", required = false, defaultValue = "") String unReceiveCodes,
            @ApiParam(name = "articleIds", value = "文章ID,多个逗号分割", required = true) @RequestParam(value = "articleIds", required = true) String articleIds,
            @ApiParam(name = "articlePics", value = "文章封面,多个逗号分割", required = true) @RequestParam(value = "articlePics", required = true) String articlePics,
            @ApiParam(name = "articleTitles", value = "文章标题,多个逗号分割", required = true) @RequestParam(value = "articleTitles", required = true) String articleTitles
            @ApiParam(name = "articleTitles", value = "文章标题,多个逗号分割", required = true) @RequestParam(value = "articleTitles", required = true) String articleTitles,
            @ApiParam(name = "articleContents", value = "文章内容,多个逗号分割", required = true) @RequestParam(value = "articleTitles", required = true) String articleContents
    ) {
        try {
            String[] patients = receiveCodes.split(",");//接收人的code
@ -123,13 +141,14 @@ public class GcEduArticleController extends WeixinBaseController {
            String[] articleIdArr = articleIds.split(",");
            String[] articlePicArr = articlePics.split(",");
            String[] articleTitleArr = articleTitles.split(",");
            String[] articleContentArr=articleContents.split(",");
            if ((articleIdArr.length != articlePicArr.length) || (articleIdArr.length != articleTitleArr.length) || (articlePicArr.length != articleTitleArr.length)) {
                return new ResultBatchModel(BaseResultModel.statusEm.opera_error.getCode(), BaseResultModel.statusEm.opera_error.getMessage() + ":文章参数长度错误");
            }
            //得到需要发送的患者
            gcEduArticleService.initPatient(patientSet, patients, unPatients, labelType, labelCode, teamId);
            //保存发送记录
            List<HealthEduArticlePatient> healthEduArticlePatients = gcEduArticleService.saveArticle(patientSet, sendCode, sendName, sendMessage, teamId, articleIdArr, articlePicArr, articleTitleArr);
            List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = gcEduArticleService.saveArticle(patientSet, sendCode, sendName, sendType,sendMessage, teamId, articleIdArr, articlePicArr, articleTitleArr,articleContentArr);
            //推送微信模板消息和发送im消息
            sendWxTemplateAndIM(healthEduArticlePatients, sendType);
@ -141,29 +160,29 @@ public class GcEduArticleController extends WeixinBaseController {
        }
    }
    private void sendWxTemplateAndIM(List<HealthEduArticlePatient> healthEduArticlePatients, String sendType) throws Exception {
    private void sendWxTemplateAndIM(List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients, Integer sendType) throws Exception {
        String endMsg = "";//"为了您的健康," + doctor.getName() + "医生给您发送了一篇患教文章,请仔细查阅,如有问题,可随时咨询医生。";
        healthEduArticlePatients.stream().forEach(one -> {
            Patient patient = patientService.findByCode(one.getPatient());
            //卫纪委发送不推IM
            if ("1".equals(sendType)) {
                consultService.sendMucMessageBySingnType(one.getDoctor(), one.getDoctorName(), patient.getCode(), "{\"title\":\"" + one.getAttachedTitle() + "\",\"type\":0,\"id\":\"" + one.getId() + "\",\"img\":\"" + one.getAttachedPic() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patient.getName());
                if (StringUtils.isNotBlank(one.getAttachedContent())) {
            if (1==sendType) {
                consultService.sendMucMessageBySingnType(one.getSendCode(), one.getSendName(), patient.getCode(), "{\"title\":\"" + one.getAttachedTitle() + "\",\"type\":0,\"id\":\"" + one.getId() + "\",\"img\":\"" + one.getAttachedPic() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patient.getName());
                if (StringUtils.isNotBlank(one.getAttachedMessage())) {
                    //发送备注
                    consultService.sendMucMessageBySingnType(one.getDoctor(), one.getDoctorName(), patient.getCode(), one.getAttachedContent(), ImUtill.CONTENT_TYPE_TEXT, patient.getName());
                    consultService.sendMucMessageBySingnType(one.getSendCode(), one.getSendName(), patient.getCode(), one.getAttachedMessage(), ImUtill.CONTENT_TYPE_TEXT, patient.getName());
                }
            }
            // 推送消息给微信端
            JSONObject json = new JSONObject();
            json.put("first", patient.getName() + ",您好!\n" + one.getDoctorName() + "医生给您发来了一篇患教文章");
            json.put("first", patient.getName() + ",您好!\n" + one.getSendName() + "医生给您发来了一篇患教文章");
            json.put("toUser", patient.getCode());
            json.put("article", one.getId() + "");
            json.put("title", one.getAttachedTitle());
            json.put("doctorName", one.getDoctorName());
            json.put("doctorName", one.getSendName());
            json.put("represented", patient.getCode());//被代理人
            json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate()));
            json.put("remark", org.springframework.util.StringUtils.isEmpty(one.getAttachedContent()) ? "  " : one.getAttachedContent());
            json.put("remark", org.springframework.util.StringUtils.isEmpty(one.getAttachedMessage()) ? "  " : one.getAttachedMessage());
            if (StringUtils.isNotBlank(patient.getOpenid())) {
                pushMsgTask.putWxMsg(getAccessToken(), 9,

+ 34 - 28
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/service/GcEduArticleService.java

@ -1,12 +1,16 @@
package com.yihu.wlyy.web.third.gateway.service;
import com.yihu.wlyy.config.es.ElastricSearchSave;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.education.HealthEduArticleOpHistory;
import com.yihu.wlyy.entity.education.HealthEduArticlePatient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.education.HealthEduArticlePatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.health.HealthEduArticleOpHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -26,7 +30,16 @@ public class GcEduArticleService {
    private HealthEduArticleOpHistoryService healthEduArticleOpHistoryService;
    @Autowired
    private HealthEduArticlePatientDao healthEduArticlePatientDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private ElastricSearchSave elastricSearchSave;
    @Value("${es.type.HealthEduArticlePatient}")
    private String esType;
    @Value("${es.index.HealthEduArticlePatient}")
    private String esIndex;
    /**
     * 初始化需要发送的患者
     *
@ -104,9 +117,10 @@ public class GcEduArticleService {
     * @param articleTitles 文章主题
     */
    @Transactional
    public List<HealthEduArticlePatient> saveArticle(Set<String> patientSet, String sendCode, String sendName, String sendMessage, Long teamId, String[] articleIds, String[] articlePics, String[] articleTitles) {
        List<HealthEduArticlePatient> healthEduArticlePatients = new ArrayList<>();
    public List<com.yihu.es.entity.HealthEduArticlePatient> saveArticle(Set<String> patientSet, String sendCode, String sendName,Integer sendType, String sendMessage, Long teamId, String[] articleIds, String[] articlePics, String[] articleTitles,String[] articleContentArr) {
        List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = new ArrayList<>();
        Doctor doctor=doctorDao.findByCode(sendCode);
        String batchNo = UUID.randomUUID().toString();
        Date createTime = new Date();
        for (String patient : patientSet) {
@ -115,41 +129,33 @@ public class GcEduArticleService {
                continue;
            }
            for (int i = 0; i < articleIds.length; i++) {
                HealthEduArticlePatient healthEduArticlePatient = new HealthEduArticlePatient();
                // 设置文章标识
                healthEduArticlePatient.setArticle(articleIds[i]);
                // 设置医生标识
                healthEduArticlePatient.setDoctor(sendCode);
                // 设置医生姓名
                healthEduArticlePatient.setDoctorName(sendName);
                // 设置患者标识
                com.yihu.es.entity.HealthEduArticlePatient healthEduArticlePatient = new com.yihu.es.entity.HealthEduArticlePatient();
                healthEduArticlePatient.setSendCode(sendCode);
                healthEduArticlePatient.setSendName(sendName);
                healthEduArticlePatient.setSendType(sendType);
                healthEduArticlePatient.setPatient(patient);
                // 设置为示读
                healthEduArticlePatient.setRead(1);
                // 签约类型
                healthEduArticlePatient.setSignType(2);
                // 行政团队
                healthEduArticlePatient.setPatientName(signFamily.getName());
                healthEduArticlePatient.setAdminTeamCode(teamId);
                //附加内容
                healthEduArticlePatient.setAttachedContent(sendMessage);
                //批次号记录发送批次
                if(doctor!=null){
                    healthEduArticlePatient.setHospital(doctor.getHospital());
                    healthEduArticlePatient.setHospitalName(doctor.getHospitalName());
                    healthEduArticlePatient.setTown(doctor.getTown());
                    healthEduArticlePatient.setTownName(doctor.getTownName());
                }
                healthEduArticlePatient.setBatchNo(batchNo);
                //创建时间
                healthEduArticlePatient.setCzrq(createTime);
                healthEduArticlePatient.setSignCode(signFamily.getCode());
                healthEduArticlePatient.setSendType(2);
                healthEduArticlePatient.setCreateTime(createTime);
                healthEduArticlePatient.setArticleId(articleIds[i]);
                healthEduArticlePatient.setAttachedTitle(articleTitles[i]);
                healthEduArticlePatient.setAttachedPic(articlePics[i]);
                healthEduArticlePatient.setAttachedContent(articleContentArr[i]);
                healthEduArticlePatient.setAttachedMessage(sendMessage);
                healthEduArticlePatients.add(healthEduArticlePatient);
            }
        }
        healthEduArticlePatientDao.save(healthEduArticlePatients);
        //记录转发量
        for (HealthEduArticlePatient healthEduArticlePatient : healthEduArticlePatients) {
            healthEduArticleOpHistoryService.saveByStatus(HealthEduArticleOpHistory.REPEAT_STATUS, healthEduArticlePatient.getArticle(), healthEduArticlePatient.getTitle(), healthEduArticlePatient.getDoctor());
        }
        //保存到ES中
        elastricSearchSave.save(healthEduArticlePatients,esIndex,esType);
        return healthEduArticlePatients;
    }
}

+ 45 - 1
patient-co/patient-co-wlyy/src/main/resources/application.yml

@ -184,6 +184,16 @@ express:
  sf_code: SDDF
  sf_check_word: ttzlgGyOQu4L
es:
  index:
    HealthEduArticlePatient: health_edu_article_patient_test
  type:
    health_edu_article_patient: health_edu_article_patient_test
  host: 172.19.103.68
  port: 9200
  tPort: 9300
  clusterName: jkzl
---
##正式的配置
@ -281,6 +291,18 @@ express:
  sf_code: sddf
  sf_check_word: PqFN0ADkTwnvXArMhqGxVduag44vyDQ7
es:
  index:
    HealthEduArticlePatient: health_edu_article_patient_prod
  type:
    HealthEduArticlePatient: health_edu_article_patient_prod
  host: 172.19.103.68
  port: 9200
  tPort: 9300
  clusterName: jkzl
---
##开发的配置
spring:
@ -378,6 +400,17 @@ express:
  sf_code: SDDF
  sf_check_word: ttzlgGyOQu4L
es:
  index:
    HealthEduArticlePatient: health_edu_article_patient_dev
  type:
    HealthEduArticlePatient: health_edu_article_patient_dev
  host: 172.19.103.68
  port: 9200
  tPort: 9300
  clusterName: jkzl
---
##开发连测试用这个版本的配置
spring:
@ -465,4 +498,15 @@ express:
  sf_url: http://218.17.248.244:11080/bsp-oisp/sfexpressService
#  sf_url: https://bsp-ois.sit.sf-express.com:9443/bsp-ois/sfexpressServic
  sf_code: SDDF
  sf_check_word: ttzlgGyOQu4L
  sf_check_word: ttzlgGyOQu4L
es:
  index:
    HealthEduArticlePatient: health_edu_article_patient_test
  type:
    HealthEduArticlePatient: health_edu_article_patient_test
  host: 172.19.103.68
  port: 9200
  tPort: 9300
  clusterName: jkzl

+ 1 - 1
pom.xml

@ -57,7 +57,7 @@
        <jackson.version>2.6.6</jackson.version>
        <slf4j.version>1.7.7</slf4j.version>
        <commons-lang3.version>3.3.2</commons-lang3.version>
        <guava.version>17.0</guava.version>
        <guava.version>18.0</guava.version>
        <assertj.version>1.6.1</assertj.version>
        <mockito.version>1.9.5</mockito.version>
        <selenium.version>2.42.2</selenium.version>