Переглянути джерело

Merge branch 'master' of http://git.homecommunity.cn/supervip/MicroCommunity

Your Name 3 роки тому
батько
коміт
8193cb5152
19 змінених файлів з 633 додано та 151 видалено
  1. 52 0
      java110-bean/src/main/java/com/java110/dto/questionAnswer/QuestionAnswerDto.java
  2. 40 0
      java110-bean/src/main/java/com/java110/dto/questionTitleValue/QuestionTitleValueDto.java
  3. 53 27
      java110-bean/src/main/java/com/java110/po/questionAnswer/QuestionAnswerPo.java
  4. 3 5
      java110-db/src/main/resources/mapper/community/RoomV1ServiceDaoImplMapper.xml
  5. 2 2
      java110-db/src/main/resources/mapper/user/QuestionAnswerServiceDaoImplMapper.xml
  6. 113 104
      java110-db/src/main/resources/mapper/user/QuestionAnswerV1ServiceDaoImplMapper.xml
  7. 26 0
      java110-db/src/main/resources/mapper/user/QuestionTitleValueV1ServiceDaoImplMapper.xml
  8. 4 3
      java110-db/src/main/resources/mapper/user/UserQuestionAnswerV1ServiceDaoImplMapper.xml
  9. 3 0
      java110-interface/src/main/java/com/java110/intf/user/IQuestionTitleValueV1InnerServiceSMO.java
  10. 2 2
      service-fee/src/main/java/com/java110/fee/feeMonth/PayFeeMonthHelp.java
  11. 2 1
      service-user/src/main/java/com/java110/user/bmo/question/IQuestionAnswerBMO.java
  12. 5 5
      service-user/src/main/java/com/java110/user/bmo/question/impl/QuestionAnswerBMOImpl.java
  13. 57 1
      service-user/src/main/java/com/java110/user/cmd/question/DeleteQuestionAnswerCmd.java
  14. 106 0
      service-user/src/main/java/com/java110/user/cmd/question/ListOwnerVoteCmd.java
  15. 4 1
      service-user/src/main/java/com/java110/user/cmd/question/SaveOwnerVoteCmd.java
  16. 144 0
      service-user/src/main/java/com/java110/user/cmd/question/UpdateOwnerVoteCmd.java
  17. 1 0
      service-user/src/main/java/com/java110/user/dao/IQuestionTitleValueV1ServiceDao.java
  18. 9 0
      service-user/src/main/java/com/java110/user/dao/impl/QuestionTitleValueV1ServiceDaoImpl.java
  19. 7 0
      service-user/src/main/java/com/java110/user/smo/impl/QuestionTitleValueV1InnerServiceSMOImpl.java

+ 52 - 0
java110-bean/src/main/java/com/java110/dto/questionAnswer/QuestionAnswerDto.java

@@ -1,9 +1,11 @@
 package com.java110.dto.questionAnswer;
 
 import com.java110.dto.PageDto;
+import com.java110.dto.questionTitleValue.QuestionTitleValueDto;
 
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 
 /**
  * @ClassName FloorDto
@@ -16,6 +18,8 @@ import java.util.Date;
 public class QuestionAnswerDto extends PageDto implements Serializable {
 
     public static final String QA_TYPE_VOTE = "3003";// 业主投票
+    public static final String STATE_WAIT = "W"; // 待发布
+    public static final String STATE_COMPLETE = "C"; //发布完成
 
     private String qaName;
     private String qaType;
@@ -26,11 +30,19 @@ public class QuestionAnswerDto extends PageDto implements Serializable {
     private String content;
     private String qaId;
 
+    private String titleType;
 
     private Date createTime;
 
     private String statusCd = "0";
 
+    private long voteCount; // 总投票人数
+
+    private long votedCount; // 已投票人数
+
+    private List<QuestionTitleValueDto> titleValues;
+
+    private String state;
 
     public String getQaName() {
         return qaName;
@@ -112,4 +124,44 @@ public class QuestionAnswerDto extends PageDto implements Serializable {
     public void setStatusCd(String statusCd) {
         this.statusCd = statusCd;
     }
+
+    public List<QuestionTitleValueDto> getTitleValues() {
+        return titleValues;
+    }
+
+    public void setTitleValues(List<QuestionTitleValueDto> titleValues) {
+        this.titleValues = titleValues;
+    }
+
+    public long getVoteCount() {
+        return voteCount;
+    }
+
+    public void setVoteCount(long voteCount) {
+        this.voteCount = voteCount;
+    }
+
+    public long getVotedCount() {
+        return votedCount;
+    }
+
+    public void setVotedCount(long votedCount) {
+        this.votedCount = votedCount;
+    }
+
+    public String getTitleType() {
+        return titleType;
+    }
+
+    public void setTitleType(String titleType) {
+        this.titleType = titleType;
+    }
+
+    public String getState() {
+        return state;
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
 }

+ 40 - 0
java110-bean/src/main/java/com/java110/dto/questionTitleValue/QuestionTitleValueDto.java

@@ -4,6 +4,7 @@ import com.java110.dto.PageDto;
 
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 
 /**
  * @ClassName FloorDto
@@ -23,6 +24,7 @@ public class QuestionTitleValueDto extends PageDto implements Serializable {
 
     private String communityId;
     private String qaValue;
+    private String titleType;
     private String seq;
 
 
@@ -30,6 +32,12 @@ public class QuestionTitleValueDto extends PageDto implements Serializable {
 
     private String statusCd = "0";
 
+    private String qaId;
+    private String[] qaIds;
+
+    private int personCount;
+
+
 
     public String getScore() {
         return score;
@@ -103,4 +111,36 @@ public class QuestionTitleValueDto extends PageDto implements Serializable {
     public void setTitleIds(String[] titleIds) {
         this.titleIds = titleIds;
     }
+
+    public String getQaId() {
+        return qaId;
+    }
+
+    public void setQaId(String qaId) {
+        this.qaId = qaId;
+    }
+
+    public int getPersonCount() {
+        return personCount;
+    }
+
+    public void setPersonCount(int personCount) {
+        this.personCount = personCount;
+    }
+
+    public String[] getQaIds() {
+        return qaIds;
+    }
+
+    public void setQaIds(String[] qaIds) {
+        this.qaIds = qaIds;
+    }
+
+    public String getTitleType() {
+        return titleType;
+    }
+
+    public void setTitleType(String titleType) {
+        this.titleType = titleType;
+    }
 }

+ 53 - 27
java110-bean/src/main/java/com/java110/po/questionAnswer/QuestionAnswerPo.java

@@ -17,6 +17,7 @@ package com.java110.po.questionAnswer;
 
 import java.io.Serializable;
 import java.util.Date;
+
 /**
  * 类表述: Po 数据模型实体对象 基本保持与数据库模型一直 用于 增加修改删除 等时的数据载体
  * add by 吴学文 at 2023-07-13 00:03:56 mail: 928255095@qq.com
@@ -28,69 +29,94 @@ import java.util.Date;
 public class QuestionAnswerPo implements Serializable {
 
     private String qaName;
-private String qaType;
-private String startTime;
-private String remark;
-private String statusCd = "0";
-private String endTime;
-private String communityId;
-private String content;
-private String qaId;
-public String getQaName() {
+    private String qaType;
+    private String startTime;
+    private String remark;
+    private String statusCd = "0";
+    private String endTime;
+    private String communityId;
+    private String content;
+    private String qaId;
+
+    private String state;
+
+    public String getQaName() {
         return qaName;
     }
-public void setQaName(String qaName) {
+
+    public void setQaName(String qaName) {
         this.qaName = qaName;
     }
-public String getQaType() {
+
+    public String getQaType() {
         return qaType;
     }
-public void setQaType(String qaType) {
+
+    public void setQaType(String qaType) {
         this.qaType = qaType;
     }
-public String getStartTime() {
+
+    public String getStartTime() {
         return startTime;
     }
-public void setStartTime(String startTime) {
+
+    public void setStartTime(String startTime) {
         this.startTime = startTime;
     }
-public String getRemark() {
+
+    public String getRemark() {
         return remark;
     }
-public void setRemark(String remark) {
+
+    public void setRemark(String remark) {
         this.remark = remark;
     }
-public String getStatusCd() {
+
+    public String getStatusCd() {
         return statusCd;
     }
-public void setStatusCd(String statusCd) {
+
+    public void setStatusCd(String statusCd) {
         this.statusCd = statusCd;
     }
-public String getEndTime() {
+
+    public String getEndTime() {
         return endTime;
     }
-public void setEndTime(String endTime) {
+
+    public void setEndTime(String endTime) {
         this.endTime = endTime;
     }
-public String getCommunityId() {
+
+    public String getCommunityId() {
         return communityId;
     }
-public void setCommunityId(String communityId) {
+
+    public void setCommunityId(String communityId) {
         this.communityId = communityId;
     }
-public String getContent() {
+
+    public String getContent() {
         return content;
     }
-public void setContent(String content) {
+
+    public void setContent(String content) {
         this.content = content;
     }
-public String getQaId() {
+
+    public String getQaId() {
         return qaId;
     }
-public void setQaId(String qaId) {
+
+    public void setQaId(String qaId) {
         this.qaId = qaId;
     }
 
+    public String getState() {
+        return state;
+    }
 
-
+    public void setState(String state) {
+        this.state = state;
+    }
 }

+ 3 - 5
java110-db/src/main/resources/mapper/community/RoomV1ServiceDaoImplMapper.xml

@@ -60,8 +60,8 @@
         <if test="roomArea !=null and roomArea != ''">
             and t.room_area= #{roomArea}
         </if>
-        <if test="userId !=null and userId != ''">
-            and t.user_id= #{userId}
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
         </if>
         <if test="roomId !=null and roomId != ''">
             and t.room_id= #{roomId}
@@ -93,9 +93,7 @@
         <if test="state !=null and state != ''">
             and t.state= #{state}
         </if>
-        <if test="communityId !=null and communityId != ''">
-            and t.community_id= #{communityId}
-        </if>
+
         <if test="apartment !=null and apartment != ''">
             and t.apartment= #{apartment}
         </if>

+ 2 - 2
java110-db/src/main/resources/mapper/user/QuestionAnswerServiceDaoImplMapper.xml

@@ -5,8 +5,8 @@
 
     <!-- 保存答卷信息 add by wuxw 2018-07-03 -->
     <insert id="saveQuestionAnswerInfo" parameterType="Map">
-        insert into question_answer(qa_name, qa_type, start_time, end_time, remark, obj_type, obj_id, qa_id, content)
-        values (#{qaName}, #{qaType}, #{startTime}, #{endTime}, #{remark}, #{objType}, #{objId}, #{qaId}, #{content})
+        insert into question_answer(qa_name, qa_type, start_time, end_time, remark,  obj_id, qa_id, content)
+        values (#{qaName}, #{qaType}, #{startTime}, #{endTime}, #{remark}, #{objType}, #{qaId}, #{content})
     </insert>
 
     <!-- 查询答卷信息 add by wuxw 2018-07-03 -->

+ 113 - 104
java110-db/src/main/resources/mapper/user/QuestionAnswerV1ServiceDaoImplMapper.xml

@@ -5,129 +5,138 @@
 <mapper namespace="questionAnswerV1ServiceDaoImpl">
 
 
-
-
-
     <!-- 保存问卷投票信息 add by wuxw 2018-07-03 -->
     <insert id="saveQuestionAnswerInfo" parameterType="Map">
         insert into question_answer(
-qa_name,qa_type,start_time,remark,end_time,community_id,content,qa_id
-) values (
-#{qaName},#{qaType},#{startTime},#{remark},#{endTime},#{communityId},#{content},#{qaId}
-)
+        qa_name,qa_type,start_time,remark,end_time,community_id,content,qa_id,state
+        ) values (
+        #{qaName},#{qaType},#{startTime},#{remark},#{endTime},#{communityId},#{content},#{qaId},#{state}
+        )
     </insert>
 
 
-
     <!-- 查询问卷投票信息 add by wuxw 2018-07-03 -->
     <select id="getQuestionAnswerInfo" parameterType="Map" resultType="Map">
-        select  t.qa_name,t.qa_name qaName,t.qa_type,t.qa_type qaType,t.start_time,t.start_time startTime,t.remark,t.status_cd,t.status_cd statusCd,t.end_time,t.end_time endTime,t.community_id,t.community_id communityId,t.content,t.qa_id,t.qa_id qaId 
-from question_answer t 
-where 1 =1 
-<if test="qaName !=null and qaName != ''">
-   and t.qa_name= #{qaName}
-</if> 
-<if test="qaType !=null and qaType != ''">
-   and t.qa_type= #{qaType}
-</if> 
-<if test="startTime !=null and startTime != ''">
-   and t.start_time= #{startTime}
-</if> 
-<if test="remark !=null and remark != ''">
-   and t.remark= #{remark}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="endTime !=null and endTime != ''">
-   and t.end_time= #{endTime}
-</if> 
-<if test="communityId !=null and communityId != ''">
-   and t.community_id= #{communityId}
-</if> 
-<if test="content !=null and content != ''">
-   and t.content= #{content}
-</if> 
-<if test="qaId !=null and qaId != ''">
-   and t.qa_id= #{qaId}
-</if> 
-order by t.create_time desc
-<if test="page != -1 and page != null ">
-   limit #{page}, #{row}
-</if> 
+        select t.qa_name,t.qa_name qaName,t.qa_type,t.qa_type qaType,t.start_time,t.start_time
+        startTime,t.remark,t.status_cd,t.status_cd statusCd,t.end_time,t.end_time endTime,t.community_id,t.community_id
+        communityId,t.content,t.qa_id,t.qa_id qaId,t.create_time createTime,t.state,count(uqa1.user_qa_id) voteCount,count(uqa2.user_qa_id) votedCount
+        from question_answer t
+        left join user_question_answer uqa1 on t.qa_id = uqa1.qa_id and uqa1.status_cd = '0'
+        left join user_question_answer uqa2 on t.qa_id = uqa2.qa_id and uqa2.status_cd = '0' and uqa2.state = '1202'
+        where 1 =1
+        <if test="qaName !=null and qaName != ''">
+            and t.qa_name= #{qaName}
+        </if>
+        <if test="qaType !=null and qaType != ''">
+            and t.qa_type= #{qaType}
+        </if>
+        <if test="startTime !=null and startTime != ''">
+            and t.start_time= #{startTime}
+        </if>
+        <if test="remark !=null and remark != ''">
+            and t.remark= #{remark}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="endTime !=null and endTime != ''">
+            and t.end_time= #{endTime}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="content !=null and content != ''">
+            and t.content= #{content}
+        </if>
+        <if test="qaId !=null and qaId != ''">
+            and t.qa_id= #{qaId}
+        </if>
+        <if test="state !=null and state != ''">
+            and t.state= #{state}
+        </if>
+        group by t.qa_name,t.qa_type,t.start_time,t.remark,t.status_cd,t.end_time,t.community_id,t.content,t.qa_id,t.create_time,t.state
+        order by t.create_time desc
+        <if test="page != -1 and page != null ">
+            limit #{page}, #{row}
+        </if>
 
     </select>
 
 
-
-
     <!-- 修改问卷投票信息 add by wuxw 2018-07-03 -->
     <update id="updateQuestionAnswerInfo" parameterType="Map">
-        update  question_answer t set t.status_cd = #{statusCd}
-<if test="newBId != null and newBId != ''">
-,t.b_id = #{newBId}
-</if> 
-<if test="qaName !=null and qaName != ''">
-, t.qa_name= #{qaName}
-</if> 
-<if test="qaType !=null and qaType != ''">
-, t.qa_type= #{qaType}
-</if> 
-<if test="startTime !=null and startTime != ''">
-, t.start_time= #{startTime}
-</if> 
-<if test="remark !=null and remark != ''">
-, t.remark= #{remark}
-</if> 
-<if test="endTime !=null and endTime != ''">
-, t.end_time= #{endTime}
-</if> 
-<if test="communityId !=null and communityId != ''">
-, t.community_id= #{communityId}
-</if> 
-<if test="content !=null and content != ''">
-, t.content= #{content}
-</if> 
- where 1=1 <if test="qaId !=null and qaId != ''">
-and t.qa_id= #{qaId}
-</if> 
+        update question_answer t set t.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,t.b_id = #{newBId}
+        </if>
+        <if test="qaName !=null and qaName != ''">
+            , t.qa_name= #{qaName}
+        </if>
+        <if test="qaType !=null and qaType != ''">
+            , t.qa_type= #{qaType}
+        </if>
+        <if test="startTime !=null and startTime != ''">
+            , t.start_time= #{startTime}
+        </if>
+        <if test="remark !=null and remark != ''">
+            , t.remark= #{remark}
+        </if>
+        <if test="endTime !=null and endTime != ''">
+            , t.end_time= #{endTime}
+        </if>
+        <if test="state !=null and state != ''">
+            , t.state= #{state}
+        </if>
+        <if test="content !=null and content != ''">
+            , t.content= #{content}
+        </if>
+        where 1=1
+        <if test="qaId !=null and qaId != ''">
+            and t.qa_id= #{qaId}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
 
     </update>
 
     <!-- 查询问卷投票数量 add by wuxw 2018-07-03 -->
-     <select id="queryQuestionAnswersCount" parameterType="Map" resultType="Map">
-        select  count(1) count 
-from question_answer t 
-where 1 =1 
-<if test="qaName !=null and qaName != ''">
-   and t.qa_name= #{qaName}
-</if> 
-<if test="qaType !=null and qaType != ''">
-   and t.qa_type= #{qaType}
-</if> 
-<if test="startTime !=null and startTime != ''">
-   and t.start_time= #{startTime}
-</if> 
-<if test="remark !=null and remark != ''">
-   and t.remark= #{remark}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="endTime !=null and endTime != ''">
-   and t.end_time= #{endTime}
-</if> 
-<if test="communityId !=null and communityId != ''">
-   and t.community_id= #{communityId}
-</if> 
-<if test="content !=null and content != ''">
-   and t.content= #{content}
-</if> 
-<if test="qaId !=null and qaId != ''">
-   and t.qa_id= #{qaId}
-</if> 
+    <select id="queryQuestionAnswersCount" parameterType="Map" resultType="Map">
+        select count(1) count
+        from question_answer t
+        where 1 =1
+        <if test="qaName !=null and qaName != ''">
+            and t.qa_name= #{qaName}
+        </if>
+        <if test="qaType !=null and qaType != ''">
+            and t.qa_type= #{qaType}
+        </if>
+        <if test="startTime !=null and startTime != ''">
+            and t.start_time= #{startTime}
+        </if>
+        <if test="remark !=null and remark != ''">
+            and t.remark= #{remark}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="endTime !=null and endTime != ''">
+            and t.end_time= #{endTime}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="content !=null and content != ''">
+            and t.content= #{content}
+        </if>
+        <if test="qaId !=null and qaId != ''">
+            and t.qa_id= #{qaId}
+        </if>
+        <if test="state !=null and state != ''">
+            and t.state= #{state}
+        </if>
 
 
-     </select>
+    </select>
 
 </mapper>

+ 26 - 0
java110-db/src/main/resources/mapper/user/QuestionTitleValueV1ServiceDaoImplMapper.xml

@@ -114,4 +114,30 @@
 
     </select>
 
+    <select id="queryQuestionOwnerTitleValues" parameterType="Map" resultType="Map">
+        select qt.title_type titleType,qa.qa_id qaId,t.qa_value qaValue,t.seq,count(uqav.user_qa_id) personCount
+        from question_title_value t
+        inner join question_title qt on t.title_id = qt.title_id and qt.status_cd = '0'
+        inner join question_answer_title_rel qatr on t.title_id = qatr.title_id and qatr.status_cd = '0'
+        inner join question_answer qa on qatr.qa_id = qa.qa_id and qa.status_cd = '0'
+        left join user_question_answer_value uqav on qa.qa_id = uqav.qa_id and t.value_id = uqav.value_id and t.title_id = uqav.title_id and uqav.status_cd = '0'
+        where 1=1
+        and t.community_id = #{communityId}
+        <if test="titleId !=null and titleId != ''">
+            and t.title_id= #{titleId}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="qaIds !=null">
+            and qa.qa_id in
+            <foreach collection="qaIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        group by qt.title_type,qa.qa_id,t.qa_value,t.seq
+        order by t.seq
+
+
+    </select>
 </mapper>

+ 4 - 3
java110-db/src/main/resources/mapper/user/UserQuestionAnswerV1ServiceDaoImplMapper.xml

@@ -106,13 +106,14 @@
         <if test="roomName !=null and roomName != ''">
             , t.room_name= #{roomName}
         </if>
-        <if test="qaId !=null and qaId != ''">
-            , t.qa_id= #{qaId}
-        </if>
+
         where 1=1
         <if test="userQaId !=null and userQaId != ''">
             and t.user_qa_id= #{userQaId}
         </if>
+        <if test="qaId !=null and qaId != ''">
+            and t.qa_id= #{qaId}
+        </if>
 
     </update>
 

+ 3 - 0
java110-interface/src/main/java/com/java110/intf/user/IQuestionTitleValueV1InnerServiceSMO.java

@@ -65,4 +65,7 @@ public interface IQuestionTitleValueV1InnerServiceSMO {
      */
     @RequestMapping(value = "/queryQuestionTitleValuesCount", method = RequestMethod.POST)
     int queryQuestionTitleValuesCount(@RequestBody QuestionTitleValueDto questionTitleValueDto);
+
+    @RequestMapping(value = "/queryQuestionOwnerTitleValues", method = RequestMethod.POST)
+    List<QuestionTitleValueDto> queryQuestionOwnerTitleValues(@RequestBody QuestionTitleValueDto questionTitleValueDto);
 }

+ 2 - 2
service-fee/src/main/java/com/java110/fee/feeMonth/PayFeeMonthHelp.java

@@ -228,8 +228,8 @@ public class PayFeeMonthHelp implements IPayFeeMonthHelp {
         BigDecimal receivableAmount = new BigDecimal(Double.parseDouble(feeDetailDto.getReceivableAmount()));
         BigDecimal receivedAmount = new BigDecimal(Double.parseDouble(feeDetailDto.getReceivedAmount()));
 
-        BigDecimal dayReceivableAmount = receivableAmount.divide(new BigDecimal(day), 4, BigDecimal.ROUND_HALF_UP);// 日 应收
-        BigDecimal dayReceivedAmount = receivedAmount.divide(new BigDecimal(day), 4, BigDecimal.ROUND_HALF_UP);// 日 实收
+        BigDecimal dayReceivableAmount = receivableAmount.divide(new BigDecimal(day), 8, BigDecimal.ROUND_HALF_UP);// 日 应收
+        BigDecimal dayReceivedAmount = receivedAmount.divide(new BigDecimal(day), 8, BigDecimal.ROUND_HALF_UP);// 日 实收
 
         // todo 寻找第一个自然月 一日
         Calendar firstMonthDayCal = Calendar.getInstance();

+ 2 - 1
service-user/src/main/java/com/java110/user/bmo/question/IQuestionAnswerBMO.java

@@ -1,6 +1,7 @@
 package com.java110.user.bmo.question;
 
 
+import com.alibaba.fastjson.JSONArray;
 import com.java110.po.questionAnswer.QuestionAnswerPo;
 
 public interface IQuestionAnswerBMO {
@@ -9,5 +10,5 @@ public interface IQuestionAnswerBMO {
      * @param questionAnswerPo
      * @param roomIds
      */
-    void saveUserQuestionAnswer(QuestionAnswerPo questionAnswerPo,String roomIds);
+    void saveUserQuestionAnswer(QuestionAnswerPo questionAnswerPo, JSONArray roomIds);
 }

+ 5 - 5
service-user/src/main/java/com/java110/user/bmo/question/impl/QuestionAnswerBMOImpl.java

@@ -1,5 +1,6 @@
 package com.java110.user.bmo.question.impl;
 
+import com.alibaba.fastjson.JSONArray;
 import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.dto.owner.OwnerRoomRelDto;
 import com.java110.dto.room.RoomDto;
@@ -33,17 +34,16 @@ public class QuestionAnswerBMOImpl implements IQuestionAnswerBMO {
 
     @Async
     @Override
-    public void saveUserQuestionAnswer(QuestionAnswerPo questionAnswerPo, String roomId) {
+    public void saveUserQuestionAnswer(QuestionAnswerPo questionAnswerPo, JSONArray roomIds) {
 
-        String[] roomIds = roomId.split(",");
-        if (roomIds == null || roomIds.length < 1) {
+        if (roomIds == null || roomIds.size() < 1) {
             return;
         }
 
         List<String> roomIdStrs = new ArrayList<>();
 
-        for (int roomIndex = 0; roomIndex < roomIds.length; roomIndex++) {
-            roomIdStrs.add(roomIds[roomIndex]);
+        for (int roomIndex = 0; roomIndex < roomIds.size(); roomIndex++) {
+            roomIdStrs.add(roomIds.getString(roomIndex));
             if (roomIdStrs.size() == MAX_LENGTH) {
                 doData(roomIdStrs, questionAnswerPo);
                 roomIdStrs = new ArrayList<>();

+ 57 - 1
service-user/src/main/java/com/java110/user/cmd/question/DeleteQuestionAnswerCmd.java

@@ -21,8 +21,14 @@ import com.java110.core.annotation.Java110Transactional;
 import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
-import com.java110.intf.user.IQuestionAnswerV1InnerServiceSMO;
+import com.java110.dto.questionAnswerTitleRel.QuestionAnswerTitleRelDto;
+import com.java110.intf.user.*;
 import com.java110.po.questionAnswer.QuestionAnswerPo;
+import com.java110.po.questionAnswer.QuestionAnswerTitlePo;
+import com.java110.po.questionAnswerTitleRel.QuestionAnswerTitleRelPo;
+import com.java110.po.questionTitle.QuestionTitlePo;
+import com.java110.po.questionTitleValue.QuestionTitleValuePo;
+import com.java110.po.user.UserQuestionAnswerPo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
@@ -31,6 +37,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.List;
+
 /**
  * 类表述:删除
  * 服务编码:questionAnswer.deleteQuestionAnswer
@@ -48,6 +56,18 @@ public class DeleteQuestionAnswerCmd extends Cmd {
     @Autowired
     private IQuestionAnswerV1InnerServiceSMO questionAnswerV1InnerServiceSMOImpl;
 
+    @Autowired
+    private IQuestionAnswerTitleRelV1InnerServiceSMO questionAnswerTitleRelV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IQuestionTitleV1InnerServiceSMO questionTitleV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IQuestionTitleValueV1InnerServiceSMO questionTitleValueV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IUserQuestionAnswerV1InnerServiceSMO userQuestionAnswerV1InnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         Assert.hasKeyAndValue(reqJson, "qaId", "qaId不能为空");
@@ -66,6 +86,42 @@ public class DeleteQuestionAnswerCmd extends Cmd {
             throw new CmdException("删除数据失败");
         }
 
+
+        //todo 删除 题目
+        QuestionAnswerTitleRelDto questionAnswerTitleRelDto = new QuestionAnswerTitleRelDto();
+        questionAnswerTitleRelDto.setQaId(reqJson.getString("qaId"));
+        questionAnswerTitleRelDto.setCommunityId(reqJson.getString("communityId"));
+        List<QuestionAnswerTitleRelDto> questionAnswerTitleRelDtos = questionAnswerTitleRelV1InnerServiceSMOImpl.queryQuestionAnswerTitleRels(questionAnswerTitleRelDto);
+        if (questionAnswerTitleRelDtos == null || questionAnswerTitleRelDtos.size() < 1) {
+            return;
+        }
+
+        QuestionAnswerTitleRelPo questionAnswerTitleRelPo = new QuestionAnswerTitleRelPo();
+        questionAnswerTitleRelPo.setQatrId(questionAnswerTitleRelDtos.get(0).getQatrId());
+        questionAnswerTitleRelPo.setCommunityId(reqJson.getString("communityId"));
+        questionAnswerTitleRelV1InnerServiceSMOImpl.deleteQuestionAnswerTitleRel(questionAnswerTitleRelPo);
+
+        //todo 删除题目
+        QuestionTitlePo questionTitlePo = new QuestionTitlePo();
+        questionTitlePo.setTitleId(questionAnswerTitleRelDtos.get(0).getTitleId());
+        questionTitlePo.setCommunityId(reqJson.getString("communityId"));
+        questionTitleV1InnerServiceSMOImpl.deleteQuestionTitle(questionTitlePo);
+
+        //todo 删除选项
+        QuestionTitleValuePo questionTitleValuePo = new QuestionTitleValuePo();
+        questionTitleValuePo.setTitleId(questionAnswerTitleRelDtos.get(0).getTitleId());
+        questionTitleValuePo.setCommunityId(reqJson.getString("communityId"));
+        questionTitleValueV1InnerServiceSMOImpl.deleteQuestionTitleValue(questionTitleValuePo);
+
+        //todo 删除用户投票
+        UserQuestionAnswerPo userQuestionAnswerPo = new UserQuestionAnswerPo();
+        userQuestionAnswerPo.setQaId(reqJson.getString("qaId"));
+        userQuestionAnswerPo.setCommunityId(reqJson.getString("communityId"));
+        userQuestionAnswerV1InnerServiceSMOImpl.deleteUserQuestionAnswer(userQuestionAnswerPo);
+
+        //todo 删除用户投票值
+
+
         cmdDataFlowContext.setResponseEntity(ResultVo.success());
     }
 }

+ 106 - 0
service-user/src/main/java/com/java110/user/cmd/question/ListOwnerVoteCmd.java

@@ -0,0 +1,106 @@
+package com.java110.user.cmd.question;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.context.ICmdDataFlowContext;
+import com.java110.core.event.cmd.Cmd;
+import com.java110.core.event.cmd.CmdEvent;
+import com.java110.dto.questionAnswer.QuestionAnswerDto;
+import com.java110.dto.questionTitleValue.QuestionTitleValueDto;
+import com.java110.intf.user.IQuestionAnswerV1InnerServiceSMO;
+import com.java110.intf.user.IQuestionTitleV1InnerServiceSMO;
+import com.java110.intf.user.IQuestionTitleValueV1InnerServiceSMO;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
+import com.java110.vo.ResultVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 查询业主投票
+ */
+@Java110Cmd(serviceCode = "question.listOwnerVote")
+public class ListOwnerVoteCmd extends Cmd {
+
+    @Autowired
+    private IQuestionAnswerV1InnerServiceSMO questionAnswerV1InnerServiceSMOImpl;
+
+
+    @Autowired
+    private IQuestionTitleV1InnerServiceSMO questionTitleV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IQuestionTitleValueV1InnerServiceSMO questionTitleValueV1InnerServiceSMOImpl;
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+        Assert.hasKeyAndValue(reqJson, "communityId", "未包含小区信息");
+    }
+
+    @Override
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+
+        QuestionAnswerDto questionAnswerDto = BeanConvertUtil.covertBean(reqJson, QuestionAnswerDto.class);
+        questionAnswerDto.setQaType(QuestionAnswerDto.QA_TYPE_VOTE);
+        int count = questionAnswerV1InnerServiceSMOImpl.queryQuestionAnswersCount(questionAnswerDto);
+
+        List<QuestionAnswerDto> questionAnswerDtos = null;
+
+        if (count > 0) {
+            questionAnswerDtos = questionAnswerV1InnerServiceSMOImpl.queryQuestionAnswers(questionAnswerDto);
+        } else {
+            questionAnswerDtos = new ArrayList<>();
+        }
+
+        //todo 刷入选项,并且计算投票人数
+        computeQuestionAnswerValue(questionAnswerDtos);
+
+        ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, questionAnswerDtos);
+
+        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
+
+        context.setResponseEntity(responseEntity);
+    }
+
+    /**
+     * 计算 投票选项 投票情况
+     *
+     * @param questionAnswerDtos
+     */
+    private void computeQuestionAnswerValue(List<QuestionAnswerDto> questionAnswerDtos) {
+        if (questionAnswerDtos == null || questionAnswerDtos.size() < 1) {
+            return;
+        }
+
+        List<String> qaId = new ArrayList<>();
+        for (QuestionAnswerDto tmpQuestionAnswerDto : questionAnswerDtos) {
+            qaId.add(tmpQuestionAnswerDto.getQaId());
+        }
+
+        QuestionTitleValueDto questionTitleValueDto = new QuestionTitleValueDto();
+        questionTitleValueDto.setQaIds(qaId.toArray(new String[qaId.size()]));
+        questionTitleValueDto.setCommunityId(questionAnswerDtos.get(0).getCommunityId());
+        List<QuestionTitleValueDto> questionTitleValueDtos = questionTitleValueV1InnerServiceSMOImpl.queryQuestionOwnerTitleValues(questionTitleValueDto);
+        if (questionTitleValueDtos == null || questionTitleValueDtos.size() < 1) {
+            return;
+        }
+        List<QuestionTitleValueDto> values = null;
+        for (QuestionAnswerDto tmpQuestionAnswerDto : questionAnswerDtos) {
+            values = new ArrayList<>();
+            for (QuestionTitleValueDto tmpQuestionTitleValueDto : questionTitleValueDtos) {
+                if (!tmpQuestionTitleValueDto.getQaId().equals(tmpQuestionAnswerDto.getQaId())) {
+                    continue;
+                }
+                values.add(tmpQuestionTitleValueDto);
+                tmpQuestionAnswerDto.setTitleType(tmpQuestionTitleValueDto.getTitleType());
+            }
+            tmpQuestionAnswerDto.setTitleValues(values);
+        }
+    }
+}

+ 4 - 1
service-user/src/main/java/com/java110/user/cmd/question/SaveOwnerVoteCmd.java

@@ -3,6 +3,7 @@ package com.java110.user.cmd.question;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.annotation.Java110Transactional;
 import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
@@ -71,6 +72,7 @@ public class SaveOwnerVoteCmd extends Cmd {
     }
 
     @Override
+    @Java110Transactional
     public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
 
         //todo 写入题目信息
@@ -113,6 +115,7 @@ public class SaveOwnerVoteCmd extends Cmd {
         questionAnswerPo.setQaName(reqJson.getString("qaName"));
         questionAnswerPo.setCommunityId(reqJson.getString("communityId"));
         questionAnswerPo.setQaType(QuestionAnswerDto.QA_TYPE_VOTE);
+        questionAnswerPo.setState(QuestionAnswerDto.STATE_WAIT);
         questionAnswerV1InnerServiceSMOImpl.saveQuestionAnswer(questionAnswerPo);
 
         QuestionAnswerTitleRelPo questionAnswerTitleRelPo = new QuestionAnswerTitleRelPo();
@@ -124,6 +127,6 @@ public class SaveOwnerVoteCmd extends Cmd {
         questionAnswerTitleRelPo.setQatrId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
         questionAnswerTitleRelV1InnerServiceSMOImpl.saveQuestionAnswerTitleRel(questionAnswerTitleRelPo);
 
-        questionAnswerBMOImpl.saveUserQuestionAnswer(questionAnswerPo,reqJson.getString("roomIds"));
+        questionAnswerBMOImpl.saveUserQuestionAnswer(questionAnswerPo,reqJson.getJSONArray("roomIds"));
     }
 }

+ 144 - 0
service-user/src/main/java/com/java110/user/cmd/question/UpdateOwnerVoteCmd.java

@@ -0,0 +1,144 @@
+package com.java110.user.cmd.question;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.annotation.Java110Transactional;
+import com.java110.core.context.ICmdDataFlowContext;
+import com.java110.core.event.cmd.Cmd;
+import com.java110.core.event.cmd.CmdEvent;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.dto.questionAnswer.QuestionAnswerDto;
+import com.java110.dto.questionAnswerTitleRel.QuestionAnswerTitleRelDto;
+import com.java110.dto.questionTitle.QuestionTitleDto;
+import com.java110.intf.user.*;
+import com.java110.po.questionAnswer.QuestionAnswerPo;
+import com.java110.po.questionAnswerTitleRel.QuestionAnswerTitleRelPo;
+import com.java110.po.questionTitle.QuestionTitlePo;
+import com.java110.po.questionTitleValue.QuestionTitleValuePo;
+import com.java110.po.user.UserQuestionAnswerPo;
+import com.java110.user.bmo.question.IQuestionAnswerBMO;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.Assert;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.text.ParseException;
+import java.util.List;
+
+/**
+ * 修改业主投票功能
+ * add by wuxw 2023-07-12
+ */
+
+@Java110Cmd(serviceCode = "question.updateOwnerVote")
+public class UpdateOwnerVoteCmd extends Cmd {
+
+    public static final String CODE_PREFIX_ID = "10";
+
+    @Autowired
+    private IQuestionTitleV1InnerServiceSMO questionTitleV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IQuestionTitleValueV1InnerServiceSMO questionTitleValueV1InnerServiceSMOImpl;
+    @Autowired
+    private IQuestionAnswerV1InnerServiceSMO questionAnswerV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IQuestionAnswerTitleRelV1InnerServiceSMO questionAnswerTitleRelV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IUserQuestionAnswerV1InnerServiceSMO userQuestionAnswerV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IQuestionAnswerBMO questionAnswerBMOImpl;
+
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+
+        Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId");
+        Assert.hasKeyAndValue(reqJson, "qaName", "请求报文中未包含投票名称");
+        Assert.hasKeyAndValue(reqJson, "qaId", "请求报文中未包含投票名称");
+        Assert.hasKeyAndValue(reqJson, "startTime", "未包含开始时间");
+        Assert.hasKeyAndValue(reqJson, "endTime", "未包含结束时间");
+        Assert.hasKeyAndValue(reqJson, "titleType", "未包含题目类型");
+        Assert.hasKeyAndValue(reqJson, "content", "未包含说明");
+        JSONArray titleValues = null;
+        if (!QuestionTitleDto.TITLE_TYPE_QUESTIONS.equals(reqJson.getString("titleType"))) {
+            titleValues = reqJson.getJSONArray("titleValues");
+            if (titleValues.size() < 1) {
+                throw new IllegalArgumentException("未包含选项");
+            }
+        }
+    }
+
+    @Override
+    @Java110Transactional
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+
+        QuestionAnswerTitleRelDto questionAnswerTitleRelDto = new QuestionAnswerTitleRelDto();
+        questionAnswerTitleRelDto.setQaId(reqJson.getString("qaId"));
+        questionAnswerTitleRelDto.setCommunityId(reqJson.getString("communityId"));
+        List<QuestionAnswerTitleRelDto> questionAnswerTitleRelDtos = questionAnswerTitleRelV1InnerServiceSMOImpl.queryQuestionAnswerTitleRels(questionAnswerTitleRelDto);
+        Assert.listOnlyOne(questionAnswerTitleRelDtos, "投票没有题目");
+
+
+        //todo 写入题目信息
+        QuestionTitlePo questionTitlePo = new QuestionTitlePo();
+        questionTitlePo.setTitleId(questionAnswerTitleRelDtos.get(0).getTitleId());
+        questionTitlePo.setCommunityId(reqJson.getString("communityId"));
+        questionTitlePo.setQaTitle(reqJson.getString("qaName"));
+        questionTitlePo.setTitleType(reqJson.getString("titleType"));
+        int flag = questionTitleV1InnerServiceSMOImpl.updateQuestionTitle(questionTitlePo);
+
+        if (flag < 1) {
+            throw new CmdException("修改数据失败");
+        }
+
+        //todo 删除 题目选项
+        QuestionTitleValuePo questionTitleValuePo = new QuestionTitleValuePo();
+        questionTitleValuePo.setTitleId(questionAnswerTitleRelDtos.get(0).getTitleId());
+        questionTitleValuePo.setCommunityId(reqJson.getString("communityId"));
+        questionTitleValueV1InnerServiceSMOImpl.deleteQuestionTitleValue(questionTitleValuePo);
+        JSONArray titleValues = reqJson.getJSONArray("titleValues");
+        JSONObject valueObj = null;
+        for (int titleValueIndex = 0; titleValueIndex < titleValues.size(); titleValueIndex++) {
+            valueObj = titleValues.getJSONObject(titleValueIndex);
+            questionTitleValuePo = new QuestionTitleValuePo();
+            questionTitleValuePo.setQaValue(valueObj.getString("qaValue"));
+            questionTitleValuePo.setSeq((titleValueIndex + 1) + "");
+            if (valueObj.containsKey("score")) {
+                questionTitleValuePo.setScore(valueObj.getString("score"));
+            } else {
+                questionTitleValuePo.setScore("0");
+            }
+            questionTitleValuePo.setTitleId(questionTitlePo.getTitleId());
+            questionTitleValuePo.setValueId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_valueId));
+            questionTitleValuePo.setCommunityId(questionTitlePo.getCommunityId());
+            questionTitleValueV1InnerServiceSMOImpl.saveQuestionTitleValue(questionTitleValuePo);
+        }
+
+        //todo 写入投票信息
+        QuestionAnswerPo questionAnswerPo = new QuestionAnswerPo();
+        questionAnswerPo.setContent(reqJson.getString("content"));
+        questionAnswerPo.setEndTime(reqJson.getString("endTime"));
+        questionAnswerPo.setStartTime(reqJson.getString("startTime"));
+        questionAnswerPo.setQaId(reqJson.getString("qaId"));
+        questionAnswerPo.setQaName(reqJson.getString("qaName"));
+        questionAnswerPo.setCommunityId(reqJson.getString("communityId"));
+        questionAnswerPo.setQaType(QuestionAnswerDto.QA_TYPE_VOTE);
+        questionAnswerV1InnerServiceSMOImpl.updateQuestionAnswer(questionAnswerPo);
+
+        JSONArray roomIds = reqJson.getJSONArray("roomIds");
+        if(roomIds == null || roomIds.size() < 1){
+            return ;
+        }
+        UserQuestionAnswerPo userQuestionAnswerPo = new UserQuestionAnswerPo();
+        userQuestionAnswerPo.setQaId(reqJson.getString("qaId"));
+        userQuestionAnswerPo.setCommunityId(reqJson.getString("communityId"));
+        userQuestionAnswerV1InnerServiceSMOImpl.deleteUserQuestionAnswer(userQuestionAnswerPo);
+
+
+        questionAnswerBMOImpl.saveUserQuestionAnswer(questionAnswerPo,roomIds);
+    }
+}

+ 1 - 0
service-user/src/main/java/com/java110/user/dao/IQuestionTitleValueV1ServiceDao.java

@@ -70,4 +70,5 @@ public interface IQuestionTitleValueV1ServiceDao {
      */
     int queryQuestionTitleValuesCount(Map info);
 
+    List<Map> queryQuestionOwnerTitleValues(Map info);
 }

+ 9 - 0
service-user/src/main/java/com/java110/user/dao/impl/QuestionTitleValueV1ServiceDaoImpl.java

@@ -108,5 +108,14 @@ public class QuestionTitleValueV1ServiceDaoImpl extends BaseServiceDao implement
         return Integer.parseInt(businessQuestionTitleValueInfos.get(0).get("count").toString());
     }
 
+    @Override
+    public List<Map> queryQuestionOwnerTitleValues(Map info) {
+        logger.debug("查询 queryQuestionOwnerTitleValues 入参 info : {}",info);
+
+        List<Map> infos = sqlSessionTemplate.selectList("questionTitleValueV1ServiceDaoImpl.queryQuestionOwnerTitleValues",info);
+
+        return infos;
+    }
+
 
 }

+ 7 - 0
service-user/src/main/java/com/java110/user/smo/impl/QuestionTitleValueV1InnerServiceSMOImpl.java

@@ -86,4 +86,11 @@ public class QuestionTitleValueV1InnerServiceSMOImpl extends BaseServiceSMO impl
     public int queryQuestionTitleValuesCount(@RequestBody QuestionTitleValueDto questionTitleValueDto) {
         return questionTitleValueV1ServiceDaoImpl.queryQuestionTitleValuesCount(BeanConvertUtil.beanCovertMap(questionTitleValueDto));    }
 
+    @Override
+    public List<QuestionTitleValueDto> queryQuestionOwnerTitleValues(@RequestBody QuestionTitleValueDto questionTitleValueDto) {
+        List<QuestionTitleValueDto> questionTitleValues = BeanConvertUtil.covertBeanList(questionTitleValueV1ServiceDaoImpl.queryQuestionOwnerTitleValues(BeanConvertUtil.beanCovertMap(questionTitleValueDto)), QuestionTitleValueDto.class);
+
+        return questionTitleValues;
+    }
+
 }