Jelajahi Sumber

Merge branch 'dev' of yeshijie/wlyy2.0 into dev

叶仕杰 4 tahun lalu
induk
melakukan
a252994dd0

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

@ -867,6 +867,49 @@ CREATE TABLE `base_course_sales_order_record` (
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='课程销售订单记录表';
DROP TABLE IF EXISTS `base_patient_course_record`;
CREATE TABLE `base_patient_course_record` (
  `id` varchar(50) NOT NULL,
  `nursery_log_id` varchar(50) DEFAULT NULL COMMENT '托育日志id',
  `patient` varchar(50) DEFAULT NULL,
  `content` varchar(2000) DEFAULT NULL COMMENT '课程记录内容',
  `enclosure` varchar(2000) DEFAULT NULL COMMENT '附件',
  `record_date` varchar(20) DEFAULT NULL COMMENT '记录日期',
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='居民课程记录';
DROP TABLE IF EXISTS `base_patient_diet_record`;
CREATE TABLE `base_patient_diet_record` (
  `id` varchar(50) NOT NULL,
  `nursery_log_id` varchar(50) DEFAULT NULL COMMENT '托育日志id',
  `patient` varchar(50) DEFAULT NULL,
  `eat_food` varchar(1000) DEFAULT NULL COMMENT '食用食物json格式',
  `eat_type` varchar(255) DEFAULT NULL COMMENT '食用方式 1喂食 2自主进食',
  `intake` varchar(1) DEFAULT NULL COMMENT '摄入量 全部吃完 吃了1/3 吃了1/2 几乎没吃',
  `additional_notes` varchar(1000) DEFAULT NULL COMMENT '附加说明',
  `enclosure` varchar(2000) DEFAULT NULL COMMENT '附件',
  `record_date` varchar(20) DEFAULT NULL COMMENT '记录日期',
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='居民饮食记录';
DROP TABLE IF EXISTS `base_nursery_log`;
CREATE TABLE `base_nursery_log` (
  `id` varchar(50) NOT NULL,
  `patient` varchar(50) DEFAULT NULL,
  `patient_name` varchar(50) DEFAULT NULL,
  `doctor` varchar(50) DEFAULT NULL,
  `doctor_name` varchar(50) DEFAULT NULL,
  `org_code` varchar(50) DEFAULT NULL,
  `org_name` varchar(50) DEFAULT NULL,
  `record_date` varchar(20) DEFAULT NULL COMMENT '记录日期',
  `status` varchar(1) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique1` (`patient`,`record_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='托育日志记录';
-- 2021-05-18
create table base_org_notice(
	id varchar(50) not null,

+ 23 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/course/PatientCourseRecordDO.java

@ -17,6 +17,7 @@ import javax.persistence.Table;
@Table(name="base_patient_course_record")
public class PatientCourseRecordDO extends UuidIdentityEntityWithCreateTime{
    private String patient;
    /**
     * '托育日志id'
     */
@ -29,6 +30,19 @@ public class PatientCourseRecordDO extends UuidIdentityEntityWithCreateTime{
     * '附件'
     */
    private String enclosure;
    /**
     * '记录日期'
     */
    private String recordDate;
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "nursery_log_id")
    public String getNurseryLogId() {
@ -56,4 +70,13 @@ public class PatientCourseRecordDO extends UuidIdentityEntityWithCreateTime{
    public void setEnclosure(String enclosure) {
        this.enclosure = enclosure;
    }
    @Column(name = "record_date")
    public String getRecordDate() {
        return recordDate;
    }
    public void setRecordDate(String recordDate) {
        this.recordDate = recordDate;
    }
}

+ 23 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/course/PatientDietRecordDO.java

@ -17,6 +17,7 @@ import javax.persistence.Table;
@Table(name="base_patient_diet_record")
public class PatientDietRecordDO extends UuidIdentityEntityWithCreateTime{
    private String patient;
    /**
     * '托育日志id'
     */
@ -41,6 +42,19 @@ public class PatientDietRecordDO extends UuidIdentityEntityWithCreateTime{
     *'附件'
     */
    private String enclosure;
    /**
     * '记录日期'
     */
    private String recordDate;
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "nursery_log_id")
    public String getNurseryLogId() {
@ -95,4 +109,13 @@ public class PatientDietRecordDO extends UuidIdentityEntityWithCreateTime{
    public void setEnclosure(String enclosure) {
        this.enclosure = enclosure;
    }
    @Column(name = "record_date")
    public String getRecordDate() {
        return recordDate;
    }
    public void setRecordDate(String recordDate) {
        this.recordDate = recordDate;
    }
}

+ 49 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/course/NurseryLogEndpoint.java

@ -106,8 +106,8 @@ public class NurseryLogEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "id", value = "托育日志id") @RequestParam(value = "id", required = true) String id,
            @ApiParam(name = "eatFood", value = "食用食物") @RequestParam(value = "eatFood", required = true) String eatFood,
            @ApiParam(name = "eatType", value = "进食方式") @RequestParam(value = "eatType", required = true) String eatType,
            @ApiParam(name = "enclosure", value = "附件") @RequestParam(value = "enclosure", required = true) String enclosure,
            @ApiParam(name = "intake", value = "摄入量") @RequestParam(value = "intake", required = false) String intake,
            @ApiParam(name = "enclosure", value = "附件") @RequestParam(value = "enclosure", required = false) String enclosure,
            @ApiParam(name = "intake", value = "摄入量") @RequestParam(value = "intake", required = true) String intake,
            @ApiParam(name = "additionalNotes", value = "附加说明") @RequestParam(value = "additionalNotes", required = false) String additionalNotes) {
        try {
            return success("新增成功",nurseryLogService.addDietRecord(id, eatFood, eatType, enclosure, intake, additionalNotes));
@ -127,9 +127,19 @@ public class NurseryLogEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "findDictDiet")
    @ApiOperation("查找饮食字典")
    public Envelop findDictDiet(){
        try {
            return ObjEnvelop.getSuccess("操作成功!",nurseryLogService.findDictDiet());
        }catch (Exception e){
            return  failedException(e);
        }
    }
    @GetMapping(value = "findRecordByNurseryLogId")
    @ApiOperation("根据托育日志id查找")
    public Envelop findRecordByNurseryLogId(@ApiParam(name = "id", value = "id")
    public Envelop findRecordByNurseryLogId(@ApiParam(name = "id", value = "托育日志id")
                                                   @RequestParam(value = "id", required = true) String id,
                                               @ApiParam(name = "type", value = "类型 diet饮食记录 course课程记录")
                                               @RequestParam(value = "type", required = true) String type){
@ -140,4 +150,40 @@ public class NurseryLogEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "findDietRecord")
    @ApiOperation("查找饮食记录")
    public Envelop findDietRecord(@ApiParam(name = "id", value = "id")
                                            @RequestParam(value = "id", required = true) String id){
        try {
            return nurseryLogService.findDietRecord(id);
        }catch (Exception e){
            return  failedException(e);
        }
    }
    @GetMapping(value = "findCourseRecord")
    @ApiOperation("查找课程记录记录")
    public Envelop findCourseRecord(@ApiParam(name = "id", value = "id")
                                            @RequestParam(value = "id", required = true) String id){
        try {
            return nurseryLogService.findCourseRecord(id);
        }catch (Exception e){
            return  failedException(e);
        }
    }
    @GetMapping(value = "findNurseryLogByPatient")
    @ApiOperation("获取托育日志按月日历形式 - 居民端")
    public Envelop findNurseryLogByPatient(@ApiParam(name = "patient", value = "居民")
                                         @RequestParam(value = "patient", required = true) String patient,
                                         @ApiParam(value = "开始时间,格式(yyyy-MM-dd)", name = "startDate",required = false)
                                         @RequestParam(value = "startDate", required = false) String startDate,
                                         @ApiParam(value = "结束时间,格式(yyyy-MM-dd)", name = "endDate",required = false)
                                         @RequestParam(value = "endDate", required = false) String endDate){
        try {
            return ObjEnvelop.getSuccess("操作成功!",nurseryLogService.findNurseryLogByPatient(patient,startDate,endDate));
        }catch (Exception e){
            return  failedException(e);
        }
    }
}

+ 91 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/course/NurseryLogService.java

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.course.NurseryLogDao;
import com.yihu.jw.care.dao.course.PatientCourseRecordDao;
import com.yihu.jw.care.dao.course.PatientDietRecordDao;
import com.yihu.jw.entity.care.common.DictDietDO;
import com.yihu.jw.entity.care.course.NurseryLogDO;
import com.yihu.jw.entity.care.course.PatientCourseRecordDO;
import com.yihu.jw.entity.care.course.PatientDietRecordDO;
@ -41,6 +42,16 @@ public class NurseryLogService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 查找饮食字典
     * @return
     */
    public List<DictDietDO> findDictDiet(){
        String sql = "select * from dict_diet ";
        List<DictDietDO> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(DictDietDO.class));
        return list;
    }
    /**
     * 根据托育日志id查找
     * @param id
@ -50,17 +61,37 @@ public class NurseryLogService {
        if("diet".equals(type)){
            List<PatientDietRecordDO> dietRecordDOs = patientDietRecordDao.findByNurseryLogId(id);
            if(dietRecordDOs.size()>0){
                return ObjEnvelop.getSuccess("",dietRecordDOs.get(0));
                return ObjEnvelop.getSuccess("查找成功",dietRecordDOs.get(0));
            }
        }else if("course".equals(type)){
            List<PatientCourseRecordDO> courseRecordDOs = patientCourseRecordDao.findByNurseryLogId(id);
            if(courseRecordDOs.size()>0){
                return ObjEnvelop.getSuccess("",courseRecordDOs.get(0));
                return ObjEnvelop.getSuccess("查找成功",courseRecordDOs.get(0));
            }
        }
        return ObjEnvelop.getError("未找到记录");
    }
    /**
     * 查找饮食记录
     * @param id
     * @return
     */
    public ObjEnvelop findDietRecord(String id){
        PatientDietRecordDO dietRecordDO = patientDietRecordDao.findOne(id);
        return ObjEnvelop.getSuccess("查找成功",dietRecordDO);
    }
    /**
     * 查找课程记录记录
     * @param id
     * @return
     */
    public ObjEnvelop findCourseRecord(String id){
        PatientCourseRecordDO courseRecordDO = patientCourseRecordDao.findOne(id);
        return ObjEnvelop.getSuccess("查找成功",courseRecordDO);
    }
    /**
     * 获取课程记录详情
     * @param id
@ -113,6 +144,8 @@ public class NurseryLogService {
        recordDO.setContent(content);
        recordDO.setEnclosure(enclosure);
        recordDO.setNurseryLogId(id);
        NurseryLogDO nurseryLogDO = nurseryLogDao.findOne(id);
        recordDO.setRecordDate(nurseryLogDO.getRecordDate());
        patientCourseRecordDao.save(recordDO);
        return recordDO;
    }
@ -130,6 +163,8 @@ public class NurseryLogService {
        recordDO.setEatType(eatType);
        recordDO.setIntake(intake);
        recordDO.setAdditionalNotes(additionalNotes);
        NurseryLogDO nurseryLogDO = nurseryLogDao.findOne(id);
        recordDO.setRecordDate(nurseryLogDO.getRecordDate());
        patientDietRecordDao.save(recordDO);
        return recordDO;
    }
@ -282,4 +317,58 @@ public class NurseryLogService {
        return mapFollow;
    }
    /**
     *获取托育日志按月日历形式 - 居民端
     * @param patient
     * @param startTime
     * @param endTime
     * @return
     * @throws Exception
     */
    public Map<String,Object> findNurseryLogByPatient(String patient, String startTime, String endTime)throws Exception{
        String filter = " where patient = '"+patient+"'";
        if(!StringUtil.isEmpty(startTime)){
            filter+=" and record_date >='"+startTime+"'";
        }
        if(!StringUtil.isEmpty(endTime)){
            filter+=" and record_date <='"+endTime+"'";
        }
        String sql = "select * from (SELECT nursery_log_id nurseryLogId,record_date recordDate,patient,'diet' type  from base_patient_diet_record " +filter+
                " union all " +
                " SELECT nursery_log_id nurseryLogId,record_date recordDate,patient,'course' type from base_patient_course_record "+filter +" ) a";
        sql+=" order by recordDate desc";
        List<Map<String,Object>> nurseryLogDOs = jdbcTemplate.queryForList(sql);
        //按时间分组
        Map<String,Object> date = sortNurseryByDate(nurseryLogDOs);
        return date;
    }
    public Map<String,Object> sortNurseryByDate(List<Map<String,Object>> nurseryLogDOs){
        //按时间分组
        Map<String,Object> date = new HashedMap();
        if(nurseryLogDOs!=null&&nurseryLogDOs.size()>0){
            Iterator it = nurseryLogDOs.iterator();
            while (it.hasNext()){
                Map<String,Object> nurseryLogDO = (Map<String,Object>)it.next();
                //1.获取日期分组
                Map<String,Object> dateNurserys = (Map<String,Object>)date.get(String.valueOf(nurseryLogDO.get("recordDate")));
                //判断随访时间是否已经创建分组
                if(dateNurserys!=null&&dateNurserys.size()>0){
                    //同一天时间已经有分组则加入list
                    List<Map<String,Object>> list = (List<Map<String,Object>>)dateNurserys.get("nurserys");
                    list.add(nurseryLogDO);
                }else{
                    //同一天的时间没有该分组则创建这天的随访计划List
                    Map<String,Object> newdateNursery = new HashedMap();
                    List<Map<String,Object>> dateNurseryLogs = new ArrayList<>();
                    dateNurseryLogs.add(nurseryLogDO);
                    newdateNursery.put("nurserys",dateNurseryLogs);
                    date.put(String.valueOf(nurseryLogDO.get("recordDate")),newdateNursery);
                }
            }
        }
        return date;
    }
}