Browse Source

问卷 新闻 消息推送

shuzhan 2 years ago
parent
commit
fefa4cb6ea

+ 19 - 0
common/src/main/java/com/jpsoft/campus/modules/base/dao/CollectDAO.java

@@ -0,0 +1,19 @@
+package com.jpsoft.campus.modules.base.dao;
+
+import java.util.List;
+import org.springframework.stereotype.Repository;
+import com.jpsoft.campus.modules.base.entity.Collect;
+import java.util.Map;
+import com.jpsoft.campus.modules.common.dto.Sort;
+
+@Repository
+public interface CollectDAO {
+	int insert(Collect entity);
+	int update(Collect entity);
+	int exist(String id);
+	Collect get(String id);
+	int delete(String id);
+	List<Collect> list();
+	List<Collect> search(Map<String,Object> searchParams,List<Sort> sortList);
+	Collect findByPersonId(String personId);
+}

+ 51 - 0
common/src/main/java/com/jpsoft/campus/modules/base/entity/Collect.java

@@ -0,0 +1,51 @@
+package com.jpsoft.campus.modules.base.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.text.SimpleDateFormat;
+import java.math.BigDecimal;
+import org.springframework.format.annotation.DateTimeFormat;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+/**
+  描述:base_collect的实体类
+ */
+@Data
+@ApiModel(value = "base_collect的实体类")
+public class Collect {
+        @ApiModelProperty(value = "")
+    private String id;
+        @ApiModelProperty(value = "学生ID")
+    private String studentId;
+        @ApiModelProperty(value = "注册用户(家长)ID")
+    private String personId;
+        @ApiModelProperty(value = "类型1是否参与")
+    private Boolean bit1;
+        @ApiModelProperty(value = "")
+    private String text1;
+        @ApiModelProperty(value = "类型2参与家长姓名")
+    private String text2;
+        @ApiModelProperty(value = "类型3电话")
+    private String text3;
+        @ApiModelProperty(value = "类型4关系")
+    private String text4;
+        @ApiModelProperty(value = "类型5")
+    private String text5;
+        @ApiModelProperty(value = "删除标示")
+    private Boolean delFlag;
+        @ApiModelProperty(value = "创建人")
+    private String createBy;
+        @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
+	    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+        @ApiModelProperty(value = "更新人")
+    private String updateBy;
+        @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
+	    @ApiModelProperty(value = "更新时间")
+    private Date updateTime;
+}

+ 19 - 0
common/src/main/java/com/jpsoft/campus/modules/base/service/CollectService.java

@@ -0,0 +1,19 @@
+package com.jpsoft.campus.modules.base.service;
+
+import java.util.List;
+import java.util.Map;
+import com.jpsoft.campus.modules.base.entity.Collect;
+import com.github.pagehelper.Page;
+import com.jpsoft.campus.modules.common.dto.Sort;
+
+public interface CollectService {
+	Collect get(String id);
+	boolean exist(String id);
+	int insert(Collect model);
+	int update(Collect model);
+	int delete(String id);
+	List<Collect> list();
+	Page<Collect> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
+
+	Collect findByPersonId(String personId);
+}

+ 77 - 0
common/src/main/java/com/jpsoft/campus/modules/base/service/impl/CollectServiceImpl.java

@@ -0,0 +1,77 @@
+package com.jpsoft.campus.modules.base.service.impl;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import javax.annotation.Resource;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+import com.jpsoft.campus.modules.base.dao.CollectDAO;
+import com.jpsoft.campus.modules.base.entity.Collect;
+import com.jpsoft.campus.modules.base.service.CollectService;
+import com.github.pagehelper.Page;
+import com.jpsoft.campus.modules.common.dto.Sort;
+import com.github.pagehelper.PageHelper;
+
+@Transactional
+@Component(value="collectService")
+public class CollectServiceImpl implements CollectService {
+	@Resource(name="collectDAO")
+	private CollectDAO collectDAO;
+
+	@Override
+	public Collect get(String id) {
+		// TODO Auto-generated method stub
+		return collectDAO.get(id);
+	}
+
+	@Override
+	public int insert(Collect model) {
+		// TODO Auto-generated method stub
+		//model.setId(UUID.randomUUID().toString());
+		
+		return collectDAO.insert(model);
+	}
+
+	@Override
+	public int update(Collect model) {
+		// TODO Auto-generated method stub
+		return collectDAO.update(model);		
+	}
+
+	@Override
+	public int delete(String id) {
+		// TODO Auto-generated method stub
+		return collectDAO.delete(id);
+	}
+
+	@Override
+	public boolean exist(String id) {
+		// TODO Auto-generated method stub
+		int count = collectDAO.exist(id);
+		
+		return count > 0 ? true : false;
+	}
+	
+	@Override
+	public List<Collect> list() {
+		// TODO Auto-generated method stub
+		return collectDAO.list();
+	}
+		
+	@Override
+	public Page<Collect> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
+        Page<Collect> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
+            collectDAO.search(searchParams,sortList);
+        });
+        
+        return page;
+	}
+
+	@Override
+	public Collect findByPersonId(String personId) {
+		// TODO Auto-generated method stub
+		return collectDAO.findByPersonId(personId);
+	}
+
+}

+ 38 - 0
common/src/main/java/com/jpsoft/campus/modules/common/utils/WechatMessageUtil.java

@@ -189,6 +189,44 @@ public class WechatMessageUtil {
         return ret;
         return ret;
     }
     }
 
 
+    public static boolean sendCollectTemplate(String userName,String content,
+                                              String sendRemark,
+                                              String sendDate,
+                                              String openId, String templateId,String tokenUrl, String appId, String appSecret) {
+        JSONObject sendData = new JSONObject();
+
+        JSONObject first = new JSONObject();
+        first.put("value", "尊敬的家长,您好,根据经开区2022年秋季招生入学工作方案,即将进行C1类生随机派位流程。");
+        first.put("color", "#FF0000");
+
+        JSONObject keyword1 = new JSONObject();
+        keyword1.put("value", "实验中学东校区C1类生随机派位");
+        keyword1.put("color", "#173177");
+
+        JSONObject keyword2 = new JSONObject();
+        keyword2.put("value", content);
+        keyword2.put("color", "#173177");
+
+//        JSONObject keyword3 = new JSONObject();
+//        keyword3.put("value", sendDate);
+//        keyword3.put("color", "#173177");
+//
+        JSONObject remark = new JSONObject();
+        remark.put("value", sendRemark);
+        remark.put("color", "#173177");
+
+        sendData.put("first", first);
+        sendData.put("keyword1", keyword1);
+        sendData.put("keyword2", keyword2);
+        //sendData.put("keyword3", keyword3);
+        sendData.put("remark", remark);
+
+        //w8Zk_VQMFIEVSIBPZid7zSrvHmBdrgnqF76u8PLCZEs cs
+        boolean ret = sendTemplate(sendData,tokenUrl, appId, appSecret, templateId, openId, "http://wsbm.xiaoxinda.com/#/other/quest");
+
+        return ret;
+    }
+
 
 
     public static void main(String[] args) {
     public static void main(String[] args) {
 		/*AccessToken at = WeixinUtil.getCommonAccessToken(APP_ID, APP_SECRET,"061iw9gy1sZ1dg09dqhy1ae3gy1iw9gq");
 		/*AccessToken at = WeixinUtil.getCommonAccessToken(APP_ID, APP_SECRET,"061iw9gy1sZ1dg09dqhy1ae3gy1iw9gq");

+ 126 - 0
common/src/main/resources/mapper/base/Collect.xml

@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!-- namespace必须指向DAO接口 -->
+<mapper namespace="com.jpsoft.campus.modules.base.dao.CollectDAO">
+	<resultMap id="CollectMap" type="com.jpsoft.campus.modules.base.entity.Collect">
+		<id property="id" column="id_" />
+			<result property="studentId" column="student_id" />
+			<result property="personId" column="person_id" />
+			<result property="bit1" column="bit_1" />
+			<result property="text1" column="text_1" />
+			<result property="text2" column="text_2" />
+			<result property="text3" column="text_3" />
+			<result property="text4" column="text_4" />
+			<result property="text5" column="text_5" />
+			<result property="delFlag" column="del_flag" />
+			<result property="createBy" column="create_by" />
+			<result property="createTime" column="create_time" />
+			<result property="updateBy" column="update_by" />
+			<result property="updateTime" column="update_time" />
+			</resultMap>
+	<insert id="insert" parameterType="com.jpsoft.campus.modules.base.entity.Collect">
+	<!--
+	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
+		select sys_guid() from dual
+	</selectKey>
+	-->
+	<![CDATA[
+		insert into base_collect
+	    (id_,student_id,person_id,bit_1,text_1,text_2,text_3,text_4,text_5,del_flag,create_by,create_time,update_by,update_time)
+		values
+		(
+#{id,jdbcType=VARCHAR}
+,#{studentId,jdbcType=VARCHAR}
+,#{personId,jdbcType=VARCHAR}
+,#{bit1,jdbcType= NUMERIC }
+,#{text1,jdbcType=VARCHAR}
+,#{text2,jdbcType=VARCHAR}
+,#{text3,jdbcType=VARCHAR}
+,#{text4,jdbcType=VARCHAR}
+,#{text5,jdbcType=VARCHAR}
+,#{delFlag,jdbcType= NUMERIC }
+,#{createBy,jdbcType=VARCHAR}
+,#{createTime,jdbcType= TIMESTAMP }
+,#{updateBy,jdbcType=VARCHAR}
+,#{updateTime,jdbcType= TIMESTAMP }
+		)
+	]]>
+	</insert>
+	<delete id="delete" parameterType="string">
+		delete from base_collect where id_=#{id,jdbcType=VARCHAR}
+	</delete>
+	<update id="update" parameterType="com.jpsoft.campus.modules.base.entity.Collect">
+		update base_collect
+		<set>
+				<if test="studentId!=null">
+		student_id=#{studentId,jdbcType=VARCHAR},
+		</if>
+				<if test="personId!=null">
+		person_id=#{personId,jdbcType=VARCHAR},
+		</if>
+				<if test="bit1!=null">
+		bit_1=#{bit1,jdbcType= NUMERIC },
+		</if>
+				<if test="text1!=null">
+		text_1=#{text1,jdbcType=VARCHAR},
+		</if>
+				<if test="text2!=null">
+		text_2=#{text2,jdbcType=VARCHAR},
+		</if>
+				<if test="text3!=null">
+		text_3=#{text3,jdbcType=VARCHAR},
+		</if>
+				<if test="text4!=null">
+		text_4=#{text4,jdbcType=VARCHAR},
+		</if>
+				<if test="text5!=null">
+		text_5=#{text5,jdbcType=VARCHAR},
+		</if>
+				<if test="delFlag!=null">
+		del_flag=#{delFlag,jdbcType= NUMERIC },
+		</if>
+				<if test="createBy!=null">
+		create_by=#{createBy,jdbcType=VARCHAR},
+		</if>
+				<if test="createTime!=null">
+		create_time=#{createTime,jdbcType= TIMESTAMP },
+		</if>
+				<if test="updateBy!=null">
+		update_by=#{updateBy,jdbcType=VARCHAR},
+		</if>
+				<if test="updateTime!=null">
+		update_time=#{updateTime,jdbcType= TIMESTAMP },
+		</if>
+		</set>
+	where id_=#{id}
+	</update>
+	<select id="get" parameterType="string" resultMap="CollectMap">
+		select * from base_collect where id_=#{0}
+	</select>
+	<select id="exist" parameterType="string" resultType="int">
+		select count(*) from base_collect where id_=#{0}
+	</select>
+	<select id="list" resultMap="CollectMap">
+		select * from base_collect
+	</select>
+	<select id="search" parameterType="hashmap" resultMap="CollectMap">
+		<![CDATA[
+			select * from base_collect
+		]]>
+		<where>
+			<if test="searchParams.id != null">
+				and ID_ like #{searchParams.id}
+			</if>
+		</where>
+		<foreach item="sort" collection="sortList"  open="order by" separator=",">
+	        ${sort.name} ${sort.order}
+	 	</foreach>
+	</select>
+	<select id="findByPersonId" resultMap="CollectMap">
+		select * from base_collect
+		where person_id = #{personId}
+		and del_flag = 0
+		limit 1
+	</select>
+</mapper>

+ 51 - 3
web/src/main/java/com/jpsoft/campus/modules/base/controller/ApplicationPrimaryController.java

@@ -2114,9 +2114,10 @@ public class ApplicationPrimaryController {
             g.drawString(personName,410,600);
             g.drawString(personName,410,600);
             g.drawString(userName,830,680);
             g.drawString(userName,830,680);
             g.drawString(startMD,660,940);
             g.drawString(startMD,660,940);
-            g.drawString(startD,780,940);
-//            g.drawString(endMD,890,940);
-//            g.drawString(endD,970,940);
+            g.drawString(startD,780,940);//单日期 显示
+//            g.drawString(startD,730,940);//多日期显示
+//            g.drawString(endMD,890,940);//多日期显示
+//            g.drawString(endD,970,940);//多日期显示
             g.drawString(schoolName,480,1015);
             g.drawString(schoolName,480,1015);
             g.drawString(mothh+"",1000,1590);
             g.drawString(mothh+"",1000,1590);
             g.drawString(DateUtil.thisDayOfMonth()+"",1060,1590);
             g.drawString(DateUtil.thisDayOfMonth()+"",1060,1590);
@@ -2588,4 +2589,51 @@ public class ApplicationPrimaryController {
 
 
         return msgResult;
         return msgResult;
     }
     }
+
+
+    @ApiOperation(value="发送微信消息")
+    @RequestMapping(value = "sendCollect",method = RequestMethod.POST)
+    public MessageResult<Integer> sendCollect(
+            String idList,
+            String message,
+            @RequestAttribute String subject){
+        //当前用户ID
+        System.out.println(subject);
+        MessageResult<Integer> msgResult = new MessageResult<>();
+        User user = userService.get(subject);
+        try {
+            String appId = wechatConfig.getAppId();
+            String appSecret = wechatConfig.getAppSecret();
+            String []ids = idList.split(",");
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            String sendDate = sdf.format(new Date());
+            int messageNum = 0;
+            for(String id: ids){
+                ApplicationPrimary applicationPrimary = applicationPrimaryService.get(id);
+                PersonInfo personInfo = personInfoService.get(applicationPrimary.getPersonId());
+                boolean messageResult = WechatMessageUtil.sendCollectTemplate(
+                        user.getUserName(),message,
+                        "",sendDate,personInfo.getOpenId(),
+                        "EzbbiwH6AiAtZG7HBeC3ASBiHr_VOcJFWCWgu-s_B9Q",
+                        wechatConfig.getTokenUrl(),
+                        appId,appSecret);
+                if(messageResult){
+                    applicationPrimary.setIsSend(true);
+                    applicationPrimary.setSendTime(new Date());
+                    applicationPrimaryService.update(applicationPrimary);
+                    messageNum ++ ;
+                }
+            }
+
+            msgResult.setResult(true);
+            msgResult.setData(messageNum);
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+        return msgResult;
+    }
 }
 }

+ 226 - 0
web/src/main/java/com/jpsoft/campus/modules/base/controller/CollectController.java

@@ -0,0 +1,226 @@
+package com.jpsoft.campus.modules.base.controller;
+
+import com.github.pagehelper.Page;
+import com.jpsoft.campus.modules.base.entity.Collect;
+import com.jpsoft.campus.modules.base.service.CollectService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import com.jpsoft.campus.modules.common.dto.Sort;
+import com.jpsoft.campus.modules.common.dto.MessageResult;
+import com.jpsoft.campus.modules.common.utils.PojoUtils;
+
+import javax.servlet.http.HttpServletRequest;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@RestController
+@RequestMapping("/collect")
+@Api(description = "collect")
+public class CollectController {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private CollectService collectService;
+
+    @ApiOperation(value="创建空记录")
+    @GetMapping("create")
+    public MessageResult<Collect> create(){
+        MessageResult<Collect> msgResult = new MessageResult<>();
+
+        Collect collect = new Collect();
+
+        msgResult.setData(collect);
+        msgResult.setResult(true);
+
+        return msgResult;
+    }
+    
+    @ApiOperation(value="添加信息")
+    @PostMapping("add")
+    public MessageResult<Collect> add(@RequestBody Collect collect,@RequestAttribute String subject){
+        MessageResult<Collect> msgResult = new MessageResult<>();
+
+        try {
+            collect.setId(UUID.randomUUID().toString());
+            collect.setDelFlag(false);
+            collect.setCreateBy(subject);
+            collect.setCreateTime(new Date());
+            
+            int affectCount = collectService.insert(collect);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(collect);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库添加失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="获取信息")
+    @GetMapping("edit/{id}")
+    public MessageResult<Collect> edit(@PathVariable("id") String id){
+        MessageResult<Collect> msgResult = new MessageResult<>();
+
+        try {
+            Collect collect = collectService.get(id);
+
+            if (collect != null) {
+                msgResult.setResult(true);
+                msgResult.setData(collect);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库不存在该记录!");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="更新用户")
+    @PostMapping("update")
+    public MessageResult<Collect> update(@RequestBody Collect collect,@RequestAttribute String subject){
+        MessageResult<Collect> msgResult = new MessageResult<>();
+
+        try {
+            collect.setUpdateBy(subject);
+            collect.setUpdateTime(new Date());
+            
+            int affectCount = collectService.update(collect);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(collect);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库更新失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+	@ApiOperation(value="删除")
+    @PostMapping("delete/{id}")
+    public MessageResult<Integer> delete(@PathVariable("id") String id,@RequestAttribute String subject){
+        MessageResult<Integer> msgResult = new MessageResult<>();
+
+        try {
+            Collect collect = collectService.get(id);
+            collect.setDelFlag(true);
+            collect.setUpdateBy(subject);
+            collect.setUpdateTime(new Date());
+
+            int affectCount = collectService.update(collect);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(affectCount);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("删除失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+
+    @ApiOperation(value="批量删除")
+    @PostMapping("batchDelete")
+    public MessageResult<Integer> batchDelete(@RequestBody List<String> idList,@RequestAttribute String subject){
+        MessageResult<Integer> msgResult = new MessageResult<>();
+
+        try {
+            int affectCount = 0;
+
+            for (String id : idList) {
+                Collect collect = collectService.get(id);
+                collect.setDelFlag(true);
+                collect.setUpdateBy(subject);
+                collect.setUpdateTime(new Date());
+
+                affectCount += collectService.update(collect);
+            }
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(affectCount);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("删除失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="列表")
+    @RequestMapping(value = "pageList",method = RequestMethod.POST)
+    public MessageResult<Map> pageList(
+            String id,
+            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="pageSize",defaultValue="20") int pageSize,
+            @RequestAttribute String subject){
+
+        //当前用户ID
+        System.out.println(subject);
+
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        Map<String,Object> searchParams = new HashMap<>();
+
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("id_","asc"));
+
+        if (StringUtils.isNotEmpty(id)) {
+            searchParams.put("id","%" + id + "%");
+        }
+
+        Page<Collect> page = collectService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+
+        msgResult.setResult(true);
+        msgResult.setData(PojoUtils.pageWrapper(page));
+
+        return msgResult;
+    }
+}

+ 160 - 0
web/src/main/java/com/jpsoft/campus/modules/mobile/controller/CollectApiController.java

@@ -0,0 +1,160 @@
+package com.jpsoft.campus.modules.mobile.controller;
+
+import com.github.pagehelper.Page;
+import com.jpsoft.campus.modules.base.entity.*;
+import com.jpsoft.campus.modules.base.service.*;
+import com.jpsoft.campus.modules.common.dto.MessageResult;
+import com.jpsoft.campus.modules.common.dto.Sort;
+import com.jpsoft.campus.modules.common.utils.PojoUtils;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.*;
+
+/**
+ * 问卷保存
+ *
+ */
+@Slf4j
+@RestController
+@RequestMapping("/mobile/collectApi")
+public class CollectApiController {
+
+    @Autowired
+    private CollectService collectService;
+    @Autowired
+    private ApplicationPrimaryService applicationPrimaryService;
+    @Autowired
+    private StudentInfoService studentInfoService;
+    @Autowired
+    private PersonInfoService personInfoService;
+    @Autowired
+    private PersonStudentService personStudentService;
+
+
+    @PostMapping("findCollect")
+    @ApiOperation(value = "查询是否有填写问卷")
+    public MessageResult<Map> findCollect(@RequestAttribute String subject){
+        MessageResult<Map> messageResult = new MessageResult<>();
+        try {
+            PersonInfo personInfo = personInfoService.get(subject);
+            if(personInfo == null){
+                throw new Exception("未找到用户");
+            }
+
+            List<ApplicationPrimary> APlist = applicationPrimaryService.findByPersonId(personInfo.getId());
+            List<StudentInfo> studentInfos = new ArrayList<>();
+            if(APlist.size() > 0) {
+                for(ApplicationPrimary ap : APlist){
+                    StudentInfo studentInfo = studentInfoService.get(ap.getStudentId());
+                    if(studentInfo != null){
+                        studentInfos.add(studentInfo);
+                    }
+                }
+            }
+
+            //是否已填写
+            Boolean isWirte = false;
+
+            Collect collect = collectService.findByPersonId(personInfo.getId());
+            if(collect != null){
+                isWirte = true;
+            }
+
+            HashMap map = new HashMap();
+            map.put("isWirte",isWirte);
+            map.put("studentInfos",studentInfos);
+
+            messageResult.setCode(200);
+            messageResult.setData(map);
+            messageResult.setResult(true);
+        }
+        catch (Exception ex){
+            log.error(ex.getMessage(),ex);
+
+            messageResult.setCode(500);
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+    @PostMapping("saveCollect")
+    @ApiOperation(value = "保存问卷")
+    public MessageResult<Map> saveCollect(
+            String studentId,
+            Boolean bit1,
+            String text1,
+            String text2,
+            String text3,
+            String text4,
+            String text5,
+            @RequestAttribute String subject){
+        MessageResult<Map> messageResult = new MessageResult<>();
+
+        try {
+            PersonInfo personInfo = personInfoService.get(subject);
+            if(personInfo == null){
+                throw new Exception("未找到用户");
+            }
+
+            List<ApplicationPrimary> APlist = applicationPrimaryService.findByPersonId(personInfo.getId());
+            List<String> studentIds = new ArrayList<>();
+            if(APlist.size() > 0) {
+                for(ApplicationPrimary ap : APlist){
+                    StudentInfo studentInfo = studentInfoService.get(ap.getStudentId());
+                    if(studentInfo != null){
+                        studentIds.add(studentInfo.getId());
+                    }
+                }
+            }
+
+            Collect collect = collectService.findByPersonId(personInfo.getId());
+            if(collect == null){
+                collect = new Collect();
+                collect.setId(UUID.randomUUID().toString());
+                collect.setCreateBy(subject);
+                collect.setCreateTime(new Date());
+                collect.setDelFlag(false);
+                collect.setBit1(bit1);
+                collect.setText1(text1);
+                collect.setText2(text2);
+                collect.setText3(text3);
+                collect.setText4(text4);
+                collect.setText5(text5);
+                collect.setPersonId(subject);
+                collect.setStudentId(studentId);
+                collectService.insert(collect);
+            }else{
+                collect.setUpdateBy(subject);
+                collect.setUpdateTime(new Date());
+                collect.setBit1(bit1);
+                collect.setText1(text1);
+                collect.setText2(text2);
+                collect.setText3(text3);
+                collect.setText4(text4);
+                collect.setText5(text5);
+                collect.setPersonId(subject);
+                collect.setStudentId(studentId);
+                collectService.update(collect);
+            }
+
+            messageResult.setCode(200);
+            messageResult.setResult(true);
+        }
+        catch (Exception ex){
+            log.error(ex.getMessage(),ex);
+
+            messageResult.setCode(500);
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+}