|
|
@@ -1,15 +1,22 @@
|
|
|
package thyyxxk.webserver.controller.api.medicallaboratory;
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import thyyxxk.webserver.config.auth.PassToken;
|
|
|
+import thyyxxk.webserver.config.exception.BizException;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
+import thyyxxk.webserver.controller.api.medicallaboratory.model.Category;
|
|
|
import thyyxxk.webserver.controller.api.medicallaboratory.model.State;
|
|
|
import thyyxxk.webserver.dao.his.api.MedicalLaboratoryDao;
|
|
|
import thyyxxk.webserver.entity.ResultVo;
|
|
|
+import thyyxxk.webserver.service.externalhttp.WxServer;
|
|
|
+import thyyxxk.webserver.utils.DateUtil;
|
|
|
import thyyxxk.webserver.utils.ResultVoUtil;
|
|
|
import thyyxxk.webserver.utils.StringUtil;
|
|
|
|
|
|
@@ -19,10 +26,12 @@ import java.util.Date;
|
|
|
@RequestMapping("/medicalLaboratory")
|
|
|
public class MedicalLaboratoryController {
|
|
|
private final MedicalLaboratoryDao dao;
|
|
|
+ private final WxServer wxServer;
|
|
|
|
|
|
@Autowired
|
|
|
- public MedicalLaboratoryController(MedicalLaboratoryDao dao) {
|
|
|
+ public MedicalLaboratoryController(MedicalLaboratoryDao dao, WxServer wxServer) {
|
|
|
this.dao = dao;
|
|
|
+ this.wxServer = wxServer;
|
|
|
}
|
|
|
|
|
|
@PassToken
|
|
|
@@ -67,6 +76,7 @@ public class MedicalLaboratoryController {
|
|
|
if (null == body.getPublishTime()) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "报告状态为[发布]时,发布时间不能为空。");
|
|
|
}
|
|
|
+ pushWxMessage(body);
|
|
|
}
|
|
|
MedicalLaboratoryState existOne = dao.selectById(body.getReqNo());
|
|
|
if (null == existOne) {
|
|
|
@@ -77,4 +87,56 @@ public class MedicalLaboratoryController {
|
|
|
dao.updateById(body);
|
|
|
return ResultVoUtil.success(body.getReqNo());
|
|
|
}
|
|
|
+
|
|
|
+ private void pushWxMessage(MedicalLaboratoryState body) {
|
|
|
+ String xmLabel = getLabel(body.getCategory());
|
|
|
+ String firstData = StrUtil.format("您之前进行的{}项目已生成{}报告,详情如下:", xmLabel, xmLabel);
|
|
|
+ String pbtime = DateUtil.formatDate(body.getPublishTime());
|
|
|
+ String redirect = "https://staticweb.hnthyy.cn/wxserver/redirect/pathEntry?path=" + getPath(body);
|
|
|
+ String msgContent = "{\"touser\":\"\",\"data\":" +
|
|
|
+ "{" +
|
|
|
+ "\"first\":{\"color\":\"#FF0000\",\"value\":\"" + firstData + "\"}," +
|
|
|
+ "\"keyword1\":{\"color\":\"#173177\",\"value\":\"长沙泰和医院\"}," +
|
|
|
+ "\"keyword2\":{\"color\":\"#173177\",\"value\":\"" + body.getPatName() + "\"}," +
|
|
|
+ "\"keyword3\":{\"color\":\"#173177\",\"value\":\"" + body.getReportTitle() + "\"}," +
|
|
|
+ "\"keyword4\":{\"color\":\"#173177\",\"value\":\"" + pbtime + "\"}," +
|
|
|
+ "\"remark\":{\"color\":\"#FF0000\",\"value\":\"感谢您的使用,祝您健康!\"}," +
|
|
|
+ "}," +
|
|
|
+ "\"template_id\":\"5lfTTP5Iwx4dEwTB9ihhCDWm0PTkMDTzOUQVsyNaM50\"," +
|
|
|
+ "\"url\":\"" + redirect + "\"}";
|
|
|
+
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+ obj.put("cardNo", body.getPatNo());
|
|
|
+ obj.put("msgContext", JSON.parseObject(msgContent));
|
|
|
+ wxServer.pushWxMessage(obj);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getLabel(Category category) {
|
|
|
+ switch (category) {
|
|
|
+ case JY:
|
|
|
+ return "检验";
|
|
|
+ case JC:
|
|
|
+ return "检查";
|
|
|
+ case XD:
|
|
|
+ return "心电";
|
|
|
+ case BL:
|
|
|
+ return "病理";
|
|
|
+ }
|
|
|
+ throw new BizException("不合法的项目类型!");
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getPath(MedicalLaboratoryState body) {
|
|
|
+ String suffix = "_" + body.getPatNo();
|
|
|
+ switch (body.getCategory()) {
|
|
|
+ case JY:
|
|
|
+ return "checkExamIndex" + suffix;
|
|
|
+ case JC:
|
|
|
+ return "checkTestIndex" + suffix;
|
|
|
+ case XD:
|
|
|
+ return "checkElectroIndex" + suffix;
|
|
|
+ case BL:
|
|
|
+ return "checkPathologyIndex" + suffix;
|
|
|
+ }
|
|
|
+ throw new BizException("不合法的项目类型!");
|
|
|
+ }
|
|
|
}
|