Browse Source

三院积分活动

wangzhinan 1 year ago
parent
commit
0ab40aa777

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

@ -4,8 +4,11 @@ import com.yihu.jw.entity.hospital.article.KnowledgeArticleDictDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDoctorDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.Transient;
import java.util.List;
@ -19,4 +22,15 @@ public interface KnowledgeArticleDoctorDao extends JpaRepository<KnowledgeArticl
    @Query("select a from KnowledgeArticleDoctorDO a where a.relationCode=?1 and a.type=?2 and a.user=?3 order by a.createTime desc")
    List<KnowledgeArticleDoctorDO> findByRelationCodeAndTypeAndUser(String relationCode,Integer type,String user);//根据业务code获取医生文章/医生关系
    @Query("select a from KnowledgeArticleDoctorDO a where a.relationCode=?1 and a.type=?2 and a.user=?3 and a.baseArticleDoctorId=?4 order by a.createTime desc")
    List<KnowledgeArticleDoctorDO> findByBaseArticleDoctorIdAndRelationCodeAndTypeAndUser(String relationCode,Integer type,String user,String baseArticleDoctorId);//根据业务code获取医生文章/医生关系
    @Modifying
    @Query("delete from KnowledgeArticleDoctorDO  where baseArticleDoctorId=?1 and user=?2 and type=?3")
    void deletByBaseArticleDoctorIdAndType(String baseArticleDoctorId,String user,Integer type);
    @Modifying
    @Query("delete from KnowledgeArticleDoctorDO  where relationCode=?1 and user=?2 and type=?3 ")
    void deletByRelationCodeAndType(String relationCode,String user,Integer type);
}

+ 27 - 1
business/base-service/src/main/java/com/yihu/jw/article/service/BaseMenuManageService.java

@ -18,6 +18,7 @@ import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
@ -32,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.*;
@Service
@Transactional
public class BaseMenuManageService {
    @Autowired
    private BaseMenuDictDao baseMenuDictDao;
@ -1077,6 +1079,18 @@ public class BaseMenuManageService {
        return knowledgeArticleDoctorDao.save(articleDoctorDO);
    }
    /**
     * 取消点赞和收藏
     */
    public void deleteArticleDoctorById(String baseArticleDoctorId,String relationCode,Integer type,String user){
        if (StringUtils.isNoneBlank(baseArticleDoctorId)){
            knowledgeArticleDoctorDao.deletByBaseArticleDoctorIdAndType(baseArticleDoctorId,user,type);
        }else {
            knowledgeArticleDoctorDao.deletByRelationCodeAndType(relationCode,user,type);
        }
    }
    /**
     * 查询医生关联文章回复数据
     * @param id
@ -1085,7 +1099,7 @@ public class BaseMenuManageService {
     * @param size
     * @return
     */
    public MixEnvelop selectArticleDoctorById(String id,Integer type,Integer page,Integer size){
    public MixEnvelop selectArticleDoctorById(String user,String id,Integer type,Integer page,Integer size){
        String orderBy = "  order by create_time desc  ";
        String condition = " ";
        String sql = "SELECT\n" +
@ -1096,6 +1110,10 @@ public class BaseMenuManageService {
                "\tuser,\n" +
                "\tuser_name AS userName,\n" +
                "\ttype,\n" +
                "\tdate_format(\n" +
                "\t\tcreate_time,\n" +
                "\t\t'%Y-%m-%d %H:%i:%S'\n" +
                "\t) AS createTime,\n" +
                "\tcontent\n" +
                "FROM\n" +
                "\tbase_knowledge_article_doctor\n" +
@ -1109,10 +1127,18 @@ public class BaseMenuManageService {
        }
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql+condition+orderBy, page, size);
        for (Map<String,Object> map:list){
            BaseDoctorDO doctorDO = doctorDao.findById(map.get("user").toString()).get();
            map.put("doctor",doctorDO);
            List<KnowledgeArticleDoctorDO> knowledgeArticleDoctorDOS = knowledgeArticleDoctorDao.findByBaseArticleDoctorIdAndType(map.get("id").toString(),1);//获取评论列表
            map.put("replyList",knowledgeArticleDoctorDOS);//获取评论列表
            List<KnowledgeArticleDoctorDO> knowledgeArticleDoctorDOList = knowledgeArticleDoctorDao.findByBaseArticleDoctorIdAndType(map.get("id").toString(),2);//获取评论的点赞
            map.put("replyApoint",knowledgeArticleDoctorDOList.size());//获取评论的点赞
            List<KnowledgeArticleDoctorDO> knowledgeArticleDoctorDOList1 = knowledgeArticleDoctorDao.findByBaseArticleDoctorIdAndRelationCodeAndTypeAndUser(map.get("relationCode").toString(),2,user,map.get("id").toString());
            if (knowledgeArticleDoctorDOList1!=null&&knowledgeArticleDoctorDOList1.size()>0) {
                map.put("appointFlag", 1);//1已点赞
            }else {
                map.put("appointFlag", 0);//0未点赞
            }
        }
        String sqlCount ="select COUNT(1) as total from base_knowledge_article_doctor where base_article_doctor_id IS NULL ";
        List<Map<String, Object>> rstotal = hibenateUtils.createSQLQuery(sqlCount+condition+orderBy);

+ 9 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/integrate/dao/BaseHospitalUserIntegrateDao.java

@ -1,14 +1,23 @@
package com.yihu.jw.hospital.integrate.dao;
import com.yihu.jw.entity.hospital.integrate.BaseHospitalActivityDO;
import com.yihu.jw.entity.hospital.integrate.BaseHospitalUserIntegrateDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.util.Date;
import java.util.List;
/**
 * wangzhinan 20230523
 */
public interface BaseHospitalUserIntegrateDao extends JpaRepository<BaseHospitalUserIntegrateDO, String>, JpaSpecificationExecutor<BaseHospitalUserIntegrateDO> {
    @Query("from BaseHospitalUserIntegrateDO p where p.user = ?1 and p.relaitonCode=?2 ")
    List<BaseHospitalUserIntegrateDO> selectByUserAndRelationCode(String user, String relationCode);
    @Query("from BaseHospitalUserIntegrateDO p where p.user = ?1 and p.relaitonCode=?2 and p.createTime>=?3 and p.createTime<=?4 ")
    List<BaseHospitalUserIntegrateDO> selectByUserAndRelationCodeAndCreateTime(String user, String relationCode, Date startDate,Date endDate);
}

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/integrate/service/BaseHospitalActivityService.java

@ -87,6 +87,8 @@ public class BaseHospitalActivityService extends BaseJpaService<BaseHospitalActi
                "\tparticipants_area AS participantsArea,\n" +
                "\tparticipants_code AS participantsCode,\n" +
                "\tsort,\n" +
                "\tmanager as manager,\n" +
                "\tmanager_name as managerName,\n" +
                "\tdate_format(\n" +
                "\t\tstart_time,\n" +
                "\t\t'%Y-%m-%d %H:%i:%S'\n" +

+ 119 - 36
business/base-service/src/main/java/com/yihu/jw/hospital/integrate/service/BaseHospitalIntegrateService.java

@ -1,16 +1,23 @@
package com.yihu.jw.hospital.integrate.service;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.hospital.integrate.BaseHospitalIntegrateDO;
import com.yihu.jw.entity.hospital.integrate.BaseHospitalMedalDO;
import com.yihu.jw.entity.hospital.integrate.BaseHospitalUserIntegrateDO;
import com.yihu.jw.hospital.integrate.dao.BaseHospitalIntegrateDao;
import com.yihu.jw.hospital.integrate.dao.BaseHospitalUserIntegrateDao;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -24,6 +31,8 @@ public class BaseHospitalIntegrateService extends BaseJpaService<BaseHospitalInt
    private BaseHospitalIntegrateDao hospitalIntegrateDao;
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private BaseDoctorDao doctorDao;
    /**
     * 新增或者修改积分配置
@ -122,53 +131,127 @@ public class BaseHospitalIntegrateService extends BaseJpaService<BaseHospitalInt
    }
 /*   public JSONObject selectIntegrateByUser(String user,Integer page,Integer size){
    public JSONObject selectIntegrateByUser(String user,Integer page,Integer size){
        JSONObject object = new JSONObject();
        String orderBy = "  order by create_time desc  ";
        String condition = " ";
        String sql = "SELECT\n" +
                "\tid,\n" +
                "\ttype,\n" +
                "\ttype_name AS typeName,\n" +
                "\tname,\n" +
                "\titem,\n" +
                "\titem_name AS itemName,\n" +
                "\tbelong,\n" +
                "\tstatus,\n" +
                "\tflag,\n" +
                "\tconditions,\n" +
                "\tcontinuity_flag AS continuityFlag,\n" +
                "\tdays,\n" +
                "\tuser,\n" +
                "\tintegrate,\n" +
                "\tdaily_limit AS dailyLimit,\n" +
                "\tvalidity,\n" +
                "\tdate_format(\n" +
                "\t\tstart_validity,\n" +
                "\t\t'%Y-%m-%d %H:%i:%S'\n" +
                "\t) AS startValidity,\n" +
                "\tdate_format(\n" +
                "\t\tend_validity,\n" +
                "\t\t'%Y-%m-%d %H:%i:%S'\n" +
                "\t) AS endValidity,\n" +
                "\tdate_format(\n" +
                "\t\tcreate_time,\n" +
                "\t\t'%Y-%m-%d %H:%i:%S'\n" +
                "\t) AS createTime,\n" +
                "\tdescription\n" +
                "\tintegrate_type AS integrateType,\n" +
                "\trelation_type AS relationType,\n" +
                "\trelation_code AS relationCode,\n" +
                "\trelation_item as relationItem,\n" +
                "\tstatus,\n" +
                "\tdate_format(create_time,'%Y-%m-%d %H:%i:%S') as createTime\n" +
                "FROM\n" +
                "\tbase_hospital_integrate\n" +
                "WHERE\n" +
                "\t1 = 1  ";
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql+condition+orderBy, page, size);
        String sqlCount ="select COUNT(1) as total from base_hospital_integrate where 1=1 ";
        List<Map<String, Object>> rstotal = hibenateUtils.createSQLQuery(sqlCount+condition+orderBy);
                "\tbase_hospital_user_integrate where 1=1 and user ='"+user+"' ";
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql+orderBy, page, size);
        String sqlCount ="select COUNT(1) as total from base_hospital_user_integrate where 1=1 and user ='"+user+"' ";
        List<Map<String, Object>> rstotal = hibenateUtils.createSQLQuery(sqlCount+orderBy);
        Long count = 0L;
        if (rstotal != null && rstotal.size() > 0) {
            count = Long.parseLong(rstotal.get(0).get("total").toString());
        }
    }*/
        JSONObject data=  new JSONObject();
        data.put("list",list);
        data.put("page",page);
        data.put("size",size);
        data.put("total",count);
        object.put("data",data);//积分明细
        //剩余积分
        String integrateSql ="SELECT\n" +
                "\tIFNULL(SUM(integrate),0) AS total\n" +
                "FROM\n" +
                "\tbase_hospital_user_integrate\n" +
                "WHERE\n" +
                "\t1 = 1 and user='"+user+"' ";
        List<Map<String, Object>> integrateRstotal = hibenateUtils.createSQLQuery(integrateSql);
        Double integrateTotal  = 0.0;
        if (integrateRstotal != null && integrateRstotal.size() > 0) {
            integrateTotal = Double.parseDouble(integrateRstotal.get(0).get("total").toString());
        }
        object.put("integrateTotal",integrateTotal);
        return object;
    }
  /*  public BaseHospitalUserIntegrateDO insertIntegrate(String user,String userName,String integrateId){
        Date startDate= DateUtil.strToDateLong(DateUtil.getStringDateShort()+" 00:00:00");
        Date endDate= DateUtil.strToDateLong(DateUtil.getStringDateShort()+" 23:59:59");
        BaseHospitalIntegrateDO hospitalIntegrateDO = hospitalIntegrateDao.findById(integrateId).get();
        List<BaseHospitalUserIntegrateDO> hospitalUserIntegrateDOS = hospitalUserIntegrateDao.selectByUserAndRelationCode(user,integrateId);//获取用户领取积分情况
        List<BaseHospitalUserIntegrateDO> hospitalUserIntegrateDOList = hospitalUserIntegrateDao.selectByUserAndRelationCodeAndCreateTime(user,integrateId,startDate,endDate);//获取当天是否领取
        if (hospitalIntegrateDO.getItem().equals("wanshan")){
            if (hospitalIntegrateDO.getFlag()==1){
                if (hospitalUserIntegrateDOS==null||hospitalUserIntegrateDOS.size()==0){
                    BaseDoctorDO doctorDO = doctorDao.findById(user).get();
                    if (StringUtils.isNoneBlank(doctorDO.getPhoto())&StringUtils.isNoneBlank(doctorDO.getName())
                            &doctorDO.getSex()!=null&StringUtils.isNoneBlank(doctorDO.getIntroduce())
                            &StringUtils.isNoneBlank(doctorDO.getExpertise())&StringUtils.isNoneBlank(doctorDO.getLearning())
                            &StringUtils.isNoneBlank(doctorDO.getVisitHospital())&StringUtils.isNoneBlank(doctorDO.getImg())){
                        BaseHospitalUserIntegrateDO userIntegrateDO = new BaseHospitalUserIntegrateDO();
                        userIntegrateDO.setIntegrate(hospitalIntegrateDO.getIntegrate());
                        userIntegrateDO.setUser(user);
                        userIntegrateDO.setName(userName);
                        userIntegrateDO.setIntegrateType(1);
                        userIntegrateDO.setRelationType(hospitalIntegrateDO.getType()+"");
                        userIntegrateDO.setRelationTypeName(hospitalIntegrateDO.getTypeName());
                        userIntegrateDO.setRelationItem(hospitalIntegrateDO.getItem());
                        userIntegrateDO.setRelationItemName(hospitalIntegrateDO.getItemName());
                        userIntegrateDO.setRelaitonCode(hospitalIntegrateDO.getId());
                        userIntegrateDO.setRelationName(hospitalIntegrateDO.getName());
                        userIntegrateDO.setStatus(1);
                        userIntegrateDO.setCreateTime(new Date());
                        userIntegrateDO.setUpdateTime(new Date());
                        hospitalUserIntegrateDao.save(userIntegrateDO);
                    }
                }
            }
        }else if (hospitalIntegrateDO.getItem().equals("doctor")){
            String sql = "";
            if (hospitalIntegrateDO.getFlag()==2){
                if (hospitalUserIntegrateDOList==null&&hospitalUserIntegrateDOList.size()==0){
                }
            }
        }
    }
*/
    /**
     * 需要手动点击签到的情况
     * @param signInDates
     * @return
     */
    private static int persistentDay(List<Date> signInDates) {
        //定义一个变量表示连续签到天数,从1开始
        int continuousDays = 0;
        if (signInDates!=null&&signInDates.size()!=0){
            continuousDays=1;
        }
/*
    public insertIntegrate(String user){
    }*/
        /**
         * 2. 从最大的时间开始往前比较,因为我们是要拿连续签到的时间,这样才有意义,减少无谓的比较
         */
        Calendar later = Calendar.getInstance();
        Calendar before = Calendar.getInstance();
        for (int i = signInDates.size() - 1; i > 0; i--) {
            later.setTime(signInDates.get(i));
            before.setTime(signInDates.get(i - 1));
            //前一天 + 1天 = 后一天,则视为连续签到
            before.add(Calendar.DAY_OF_MONTH, 1);
            if (later.get(Calendar.YEAR) == before.get(Calendar.YEAR)
                    && later.get(Calendar.MONTH) == before.get(Calendar.MONTH)
                    && later.get(Calendar.DAY_OF_YEAR) == before.get(Calendar.DAY_OF_YEAR)) {
                continuousDays++;
            } else {
                //只要遇到不连续的就不用再往前比较了
                break;
            }
        }
        return continuousDays;
    }
}

+ 18 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/integrate/BaseHospitalActivityDO.java

@ -32,6 +32,22 @@ public class BaseHospitalActivityDO extends UuidIdentityEntityWithOperator {
    private String participantsArea;//参与对象区域0全院1部分科室
    private String participantsCode;//参与对象code 多个逗号隔开
    private Integer sort;//排序
    private String manager;//活动负责人code逗号隔开
    private String managerName;//活动负责人名称逗号隔开
    public String getManager() {
        return manager;
    }
    public void setManager(String manager) {
        this.manager = manager;
    }
    public String getManagerName() {
        return managerName;
    }
    public void setManagerName(String managerName) {
        this.managerName = managerName;
    }
    public Integer getSort() {
        return sort;
@ -138,7 +154,7 @@ public class BaseHospitalActivityDO extends UuidIdentityEntityWithOperator {
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "start_time", nullable = false, length = 0,updatable = false)
    @Column(name = "start_time")
    public Date getStartTime() {
        return startTime;
    }
@ -148,7 +164,7 @@ public class BaseHospitalActivityDO extends UuidIdentityEntityWithOperator {
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "end_time", nullable = false, length = 0,updatable = false)
    @Column(name = "end_time")
    public Date getEndTime() {
        return endTime;
    }

+ 2 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/integrate/BaseHospitalIntegrateDO.java

@ -151,7 +151,7 @@ public class BaseHospitalIntegrateDO extends UuidIdentityEntityWithOperator {
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "start_validity", nullable = false, length = 0,updatable = false)
    @Column(name = "start_validity")
    public Date getStartValidity() {
        return startValidity;
    }
@ -161,7 +161,7 @@ public class BaseHospitalIntegrateDO extends UuidIdentityEntityWithOperator {
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "end_validity", nullable = false, length = 0,updatable = false)
    @Column(name = "end_validity")
    public Date getEndValidity() {
        return endValidity;
    }

+ 18 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/integrate/BaseHospitalUserIntegrateDO.java

@ -18,7 +18,9 @@ public class BaseHospitalUserIntegrateDO extends UuidIdentityEntityWithOperator
    private Double integrate;//获取积分
    private Integer integrateType;//1增加2兑换
    private String relationType;//积分类型对应积分配置的类型
    private String relationTypeName;//积分类型对应积分配置的类型名称
    private String relationItem;//积分类型对应积分配置的事项
    private String relationItemName;//积分类型对应积分配置的事项名称
    private String relaitonCode;//积分code
    private String relationName;//积分配置名称
    private Integer status;//0失效1生效
@ -102,5 +104,21 @@ public class BaseHospitalUserIntegrateDO extends UuidIdentityEntityWithOperator
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getRelationTypeName() {
        return relationTypeName;
    }
    public void setRelationTypeName(String relationTypeName) {
        this.relationTypeName = relationTypeName;
    }
    public String getRelationItemName() {
        return relationItemName;
    }
    public void setRelationItemName(String relationItemName) {
        this.relationItemName = relationItemName;
    }
}

+ 2 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -1245,6 +1245,8 @@ public class BaseHospitalRequestMapping {
        public static final String selectArticleDoctorById= "/selectArticleDoctorById";
        public static final String selectArticleDoctorByArticleIdAndUser= "/selectArticleDoctorByArticleIdAndUser";
        public static final String deleteArticleDoctorById= "/deleteArticleDoctorById";
    }
    /**

+ 23 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/article/BaseMenuManageEndpoint.java

@ -228,9 +228,30 @@ public class BaseMenuManageEndpoint extends EnvelopRestEndpoint {
        }
    }
    @PostMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.deleteArticleDoctorById)
    @ApiOperation(value = "取消点赞/收藏")
    public Envelop deleteArticleDoctorById(@ApiParam(name = "baseArticleDoctorId", value = "评论id")
                                            @RequestParam(value = "baseArticleDoctorId",required = false)String baseArticleDoctorId,
                                           @ApiParam(name = "relationCode", value = "文章id")
                                           @RequestParam(value = "relationCode",required = false)String relationCode,
                                           @ApiParam(name = "type", value = "类型2点赞3收藏")
                                               @RequestParam(value = "type",required = false)Integer type,
                                           @ApiParam(name = "user", value = "用户编码")
                                               @RequestParam(value = "user",required = false)String user)throws Exception {
        try {
            menuService.deleteArticleDoctorById(baseArticleDoctorId,relationCode,type,user);
            return success();
        }catch (Exception e){
            return failedException(e);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.KnowledgeArticle.selectArticleDoctorById)
    @ApiOperation(value = "查询医生关联文章回复数据")
    public Envelop selectArticleDoctorById(@ApiParam(name = "id", value = "文章id")
    public Envelop selectArticleDoctorById(@ApiParam(name = "user", value = "用户id")
                                               @RequestParam(value = "user",required = false)String user,
                                           @ApiParam(name = "id", value = "文章id")
                                           @RequestParam(value = "id",required = false)String id,
                                           @ApiParam(name = "page", value = "当前页")
                                           @RequestParam(value = "page",required = false)Integer page,
@ -238,7 +259,7 @@ public class BaseMenuManageEndpoint extends EnvelopRestEndpoint {
                                           @RequestParam(value = "size",required = false)Integer size)throws Exception {
        try {
            return success(menuService.selectArticleDoctorById(id,1,page,size));
            return success(menuService.selectArticleDoctorById(user,id,1,page,size));
        }catch (Exception e){
            return failedException(e);
        }