Browse Source

优化代码

wuxw 3 years ago
parent
commit
9fc6c6db5a

+ 11 - 0
java110-bean/src/main/java/com/java110/dto/communitySpaceOpenTime/CommunitySpaceOpenTimeDto.java

@@ -28,6 +28,9 @@ public class CommunitySpaceOpenTimeDto extends PageDto implements Serializable {
     private String statusCd = "0";
 
 
+    private String appointmentTime;
+
+
     public String getSpaceId() {
         return spaceId;
     }
@@ -92,4 +95,12 @@ public class CommunitySpaceOpenTimeDto extends PageDto implements Serializable {
     public void setSpaceIds(String[] spaceIds) {
         this.spaceIds = spaceIds;
     }
+
+    public String getAppointmentTime() {
+        return appointmentTime;
+    }
+
+    public void setAppointmentTime(String appointmentTime) {
+        this.appointmentTime = appointmentTime;
+    }
 }

+ 7 - 0
java110-db/src/main/resources/mapper/community/CommunitySpaceOpenTimeV1ServiceDaoImplMapper.xml

@@ -31,7 +31,14 @@
         select t.space_id,t.space_id spaceId,t.hours,t.is_open,t.is_open isOpen,t.time_id,t.time_id
         timeId,t.status_cd,t.status_cd statusCd,t.community_id,t.community_id communityId
         from community_space_open_time t
+        <if test="appointmentTime !=null and appointmentTime != ''">
+        left join community_space_person_time cspt on t.space_id = cspt.space_id and cspt.status_cd = '0' and cspt.hours = t.hours
+        left join community_space_person csp on cspt.csp_id = csp.csp_id and csp.status_cd = '0' and csp.appointment_time = #{appointmentTime}
+        </if>
         where 1 =1
+        <if test="appointmentTime !=null and appointmentTime != ''">
+        and cspt.csp_id is null
+        </if>
         <if test="spaceId !=null and spaceId != ''">
             and t.space_id= #{spaceId}
         </if>

+ 82 - 0
service-community/src/main/java/com/java110/community/cmd/communitySpace/ListCommunitySpaceOpenTimeCmd.java

@@ -0,0 +1,82 @@
+package com.java110.community.cmd.communitySpace;
+
+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.core.log.LoggerFactory;
+import com.java110.doc.annotation.*;
+import com.java110.dto.communitySpaceOpenTime.CommunitySpaceOpenTimeDto;
+import com.java110.intf.community.ICommunitySpaceOpenTimeV1InnerServiceSMO;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.Assert;
+import com.java110.vo.ResultVo;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+import java.text.ParseException;
+import java.util.List;
+
+@Java110CmdDoc(title = "查询可预约时间场地",
+        description = "查询系统中的查询可预约时间场地",
+        httpMethod = "get",
+        url = "http://{ip}:{port}/app/communitySpace.listCommunitySpaceOpenTime",
+        resource = "communityDoc",
+        author = "吴学文",
+        serviceCode = "communitySpace.listCommunitySpaceOpenTime"
+)
+
+@Java110ParamsDoc(params = {
+        @Java110ParamDoc(name = "spaceId", length = 30, remark = "场地ID"),
+        @Java110ParamDoc(name = "communityId", length = 30, remark = "小区ID"),
+        @Java110ParamDoc(name = "appointmentTime", length = 30, remark = "预约日期 YYYY-MM-DD"),
+})
+
+@Java110ResponseDoc(
+        params = {
+                @Java110ParamDoc(name = "code", type = "int", length = 11, defaultValue = "0", remark = "返回编号,0 成功 其他失败"),
+                @Java110ParamDoc(name = "msg", type = "String", length = 250, defaultValue = "成功", remark = "描述"),
+                @Java110ParamDoc(name = "data", type = "Array", remark = "有效数据"),
+                @Java110ParamDoc(parentNodeName = "data", name = "hours", type = "String", remark = "小时"),
+        }
+)
+
+@Java110ExampleDoc(
+        reqBody = "http://{ip}:{port}/app/communitySpace.listCommunitySpaceOpenTime?spaceId=123&appointmentTime=2022-01-01&communityId=2022081539020475",
+        resBody = "{\"code\":0,\"data\":[{\"hours\":1,\"hours\":2}],\"msg\":\"成功\",\"page\":0,\"records\":1,\"rows\":0,\"total\":2}"
+)
+@Java110Cmd(serviceCode = "communitySpace.listCommunitySpaceOpenTime")
+public class ListCommunitySpaceOpenTimeCmd extends Cmd{
+
+    private static Logger logger = LoggerFactory.getLogger(ListCommunitySpacePersonCmd.class);
+
+
+    @Autowired
+    private ICommunitySpaceOpenTimeV1InnerServiceSMO communitySpaceOpenTimeV1InnerServiceSMOImpl;
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+
+        Assert.hasKeyAndValue(reqJson,"spaceId","场地ID");
+        Assert.hasKeyAndValue(reqJson,"appointmentTime","预约时间");
+        Assert.hasKeyAndValue(reqJson,"communityId","小区ID");
+    }
+
+    @Override
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+
+        CommunitySpaceOpenTimeDto communitySpaceOpenTimeDto = new CommunitySpaceOpenTimeDto();
+        communitySpaceOpenTimeDto.setSpaceId(reqJson.getString("spaceId"));
+        communitySpaceOpenTimeDto.setAppointmentTime(reqJson.getString("appointmentTime"));
+        List<CommunitySpaceOpenTimeDto> communitySpaceOpenTimeDtos = communitySpaceOpenTimeV1InnerServiceSMOImpl.queryCommunitySpaceOpenTimes(communitySpaceOpenTimeDto);
+
+        ResultVo resultVo = new ResultVo(1, communitySpaceOpenTimeDtos.size(), communitySpaceOpenTimeDtos);
+
+        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
+
+        context.setResponseEntity(responseEntity);
+    }
+}

+ 3 - 0
service-community/src/main/java/com/java110/community/cmd/communitySpace/SaveCommunitySpacePersonCmd.java

@@ -61,6 +61,9 @@ import org.springframework.beans.factory.annotation.Autowired;
         @Java110ParamDoc(name = "receivableAmount", length = 30, remark = "应收金额"),
         @Java110ParamDoc(name = "receivedAmount", length = 30, remark = "实收金额"),
         @Java110ParamDoc(name = "spaceId", length = 30, remark = "场地ID"),
+        @Java110ParamDoc(name = "openTimes",type="Array", length = 30, remark = "场地ID"),
+        @Java110ParamDoc(parentNodeName = "openTimes",name = "hours", length = 30, remark = "预约时间"),
+
 })
 
 @Java110ResponseDoc(