Browse Source

优化代码

wuxw 3 years ago
parent
commit
73a360d613

+ 12 - 0
java110-bean/src/main/java/com/java110/dto/scheduleClassesDay/ScheduleClassesDayDto.java

@@ -1,9 +1,11 @@
 package com.java110.dto.scheduleClassesDay;
 
 import com.java110.dto.PageDto;
+import com.java110.dto.scheduleClassesTime.ScheduleClassesTimeDto;
 
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 
 /**
  * @ClassName FloorDto
@@ -23,6 +25,8 @@ public class ScheduleClassesDayDto extends PageDto implements Serializable {
     private String scheduleId;
     private String weekFlag;
 
+    private List<ScheduleClassesTimeDto> times;
+
 
     private Date createTime;
 
@@ -85,4 +89,12 @@ public class ScheduleClassesDayDto extends PageDto implements Serializable {
     public void setStatusCd(String statusCd) {
         this.statusCd = statusCd;
     }
+
+    public List<ScheduleClassesTimeDto> getTimes() {
+        return times;
+    }
+
+    public void setTimes(List<ScheduleClassesTimeDto> times) {
+        this.times = times;
+    }
 }

+ 32 - 13
java110-bean/src/main/java/com/java110/dto/scheduleClassesTime/ScheduleClassesTimeDto.java

@@ -1,6 +1,7 @@
 package com.java110.dto.scheduleClassesTime;
 
 import com.java110.dto.PageDto;
+
 import java.io.Serializable;
 import java.util.Date;
 
@@ -15,10 +16,11 @@ import java.util.Date;
 public class ScheduleClassesTimeDto extends PageDto implements Serializable {
 
     private String timeId;
-private String dayId;
-private String startTime;
-private String endTime;
-private String scheduleId;
+    private String dayId;
+    private String[] dayIds;
+    private String startTime;
+    private String endTime;
+    private String scheduleId;
 
 
     private Date createTime;
@@ -29,31 +31,40 @@ private String scheduleId;
     public String getTimeId() {
         return timeId;
     }
-public void setTimeId(String timeId) {
+
+    public void setTimeId(String timeId) {
         this.timeId = timeId;
     }
-public String getDayId() {
+
+    public String getDayId() {
         return dayId;
     }
-public void setDayId(String dayId) {
+
+    public void setDayId(String dayId) {
         this.dayId = dayId;
     }
-public String getStartTime() {
+
+    public String getStartTime() {
         return startTime;
     }
-public void setStartTime(String startTime) {
+
+    public void setStartTime(String startTime) {
         this.startTime = startTime;
     }
-public String getEndTime() {
+
+    public String getEndTime() {
         return endTime;
     }
-public void setEndTime(String endTime) {
+
+    public void setEndTime(String endTime) {
         this.endTime = endTime;
     }
-public String getScheduleId() {
+
+    public String getScheduleId() {
         return scheduleId;
     }
-public void setScheduleId(String scheduleId) {
+
+    public void setScheduleId(String scheduleId) {
         this.scheduleId = scheduleId;
     }
 
@@ -73,4 +84,12 @@ public void setScheduleId(String scheduleId) {
     public void setStatusCd(String statusCd) {
         this.statusCd = statusCd;
     }
+
+    public String[] getDayIds() {
+        return dayIds;
+    }
+
+    public void setDayIds(String[] dayIds) {
+        this.dayIds = dayIds;
+    }
 }

+ 73 - 78
java110-db/src/main/resources/mapper/store/ScheduleClassesDayV1ServiceDaoImplMapper.xml

@@ -5,102 +5,97 @@
 <mapper namespace="scheduleClassesDayV1ServiceDaoImpl">
 
 
-
-
-
     <!-- 保存排班天信息 add by wuxw 2018-07-03 -->
     <insert id="saveScheduleClassesDayInfo" parameterType="Map">
         insert into schedule_classes_day(
-workday,day_id,day,schedule_id,week_flag
-) values (
-#{workday},#{dayId},#{day},#{scheduleId},#{weekFlag}
-)
+        workday,day_id,day,schedule_id,week_flag
+        ) values (
+        #{workday},#{dayId},#{day},#{scheduleId},#{weekFlag}
+        )
     </insert>
 
 
-
     <!-- 查询排班天信息 add by wuxw 2018-07-03 -->
     <select id="getScheduleClassesDayInfo" parameterType="Map" resultType="Map">
-        select  t.workday,t.day_id,t.day_id dayId,t.status_cd,t.status_cd statusCd,t.day,t.schedule_id,t.schedule_id scheduleId,t.week_flag,t.week_flag weekFlag 
-from schedule_classes_day t 
-where 1 =1 
-<if test="workday !=null and workday != ''">
-   and t.workday= #{workday}
-</if> 
-<if test="dayId !=null and dayId != ''">
-   and t.day_id= #{dayId}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="day !=null and day != ''">
-   and t.day= #{day}
-</if> 
-<if test="scheduleId !=null and scheduleId != ''">
-   and t.schedule_id= #{scheduleId}
-</if> 
-<if test="weekFlag !=null and weekFlag != ''">
-   and t.week_flag= #{weekFlag}
-</if> 
-order by t.create_time desc
-<if test="page != -1 and page != null ">
-   limit #{page}, #{row}
-</if> 
+        select t.workday,t.day_id,t.day_id dayId,t.status_cd,t.status_cd statusCd,t.day,t.schedule_id,t.schedule_id
+        scheduleId,t.week_flag,t.week_flag weekFlag
+        from schedule_classes_day t
+        where 1 =1
+        <if test="workday !=null and workday != ''">
+            and t.workday= #{workday}
+        </if>
+        <if test="dayId !=null and dayId != ''">
+            and t.day_id= #{dayId}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="day !=null and day != ''">
+            and t.day= #{day}
+        </if>
+        <if test="scheduleId !=null and scheduleId != ''">
+            and t.schedule_id= #{scheduleId}
+        </if>
+        <if test="weekFlag !=null and weekFlag != ''">
+            and t.week_flag= #{weekFlag}
+        </if>
+        order by t.day
+        <if test="page != -1 and page != null ">
+            limit #{page}, #{row}
+        </if>
 
     </select>
 
 
-
-
     <!-- 修改排班天信息 add by wuxw 2018-07-03 -->
     <update id="updateScheduleClassesDayInfo" parameterType="Map">
-        update  schedule_classes_day t set t.status_cd = #{statusCd}
-<if test="newBId != null and newBId != ''">
-,t.b_id = #{newBId}
-</if> 
-<if test="workday !=null and workday != ''">
-, t.workday= #{workday}
-</if> 
-<if test="dayId !=null and dayId != ''">
-, t.day_id= #{dayId}
-</if> 
-<if test="day !=null and day != ''">
-, t.day= #{day}
-</if> 
-<if test="scheduleId !=null and scheduleId != ''">
-, t.schedule_id= #{scheduleId}
-</if> 
-<if test="weekFlag !=null and weekFlag != ''">
-, t.week_flag= #{weekFlag}
-</if> 
- where 1=1 
+        update schedule_classes_day t set t.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,t.b_id = #{newBId}
+        </if>
+        <if test="workday !=null and workday != ''">
+            , t.workday= #{workday}
+        </if>
+        <if test="dayId !=null and dayId != ''">
+            , t.day_id= #{dayId}
+        </if>
+        <if test="day !=null and day != ''">
+            , t.day= #{day}
+        </if>
+        <if test="scheduleId !=null and scheduleId != ''">
+            , t.schedule_id= #{scheduleId}
+        </if>
+        <if test="weekFlag !=null and weekFlag != ''">
+            , t.week_flag= #{weekFlag}
+        </if>
+        where 1=1
     </update>
 
     <!-- 查询排班天数量 add by wuxw 2018-07-03 -->
-     <select id="queryScheduleClassesDaysCount" parameterType="Map" resultType="Map">
-        select  count(1) count 
-from schedule_classes_day t 
-where 1 =1 
-<if test="workday !=null and workday != ''">
-   and t.workday= #{workday}
-</if> 
-<if test="dayId !=null and dayId != ''">
-   and t.day_id= #{dayId}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="day !=null and day != ''">
-   and t.day= #{day}
-</if> 
-<if test="scheduleId !=null and scheduleId != ''">
-   and t.schedule_id= #{scheduleId}
-</if> 
-<if test="weekFlag !=null and weekFlag != ''">
-   and t.week_flag= #{weekFlag}
-</if> 
+    <select id="queryScheduleClassesDaysCount" parameterType="Map" resultType="Map">
+        select count(1) count
+        from schedule_classes_day t
+        where 1 =1
+        <if test="workday !=null and workday != ''">
+            and t.workday= #{workday}
+        </if>
+        <if test="dayId !=null and dayId != ''">
+            and t.day_id= #{dayId}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="day !=null and day != ''">
+            and t.day= #{day}
+        </if>
+        <if test="scheduleId !=null and scheduleId != ''">
+            and t.schedule_id= #{scheduleId}
+        </if>
+        <if test="weekFlag !=null and weekFlag != ''">
+            and t.week_flag= #{weekFlag}
+        </if>
 
 
-     </select>
+    </select>
 
 </mapper>

+ 13 - 1
java110-db/src/main/resources/mapper/store/ScheduleClassesTimeV1ServiceDaoImplMapper.xml

@@ -27,6 +27,12 @@
         <if test="dayId !=null and dayId != ''">
             and t.day_id= #{dayId}
         </if>
+        <if test="dayIds !=null">
+            and t.day_id in
+            <foreach collection="dayIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
         <if test="startTime !=null and startTime != ''">
             and t.start_time= #{startTime}
         </if>
@@ -39,7 +45,7 @@
         <if test="scheduleId !=null and scheduleId != ''">
             and t.schedule_id= #{scheduleId}
         </if>
-        order by t.create_time desc
+        order by t.start_time
         <if test="page != -1 and page != null ">
             limit #{page}, #{row}
         </if>
@@ -83,6 +89,12 @@
         <if test="dayId !=null and dayId != ''">
             and t.day_id= #{dayId}
         </if>
+        <if test="dayIds !=null">
+            and t.day_id in
+            <foreach collection="dayIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
         <if test="startTime !=null and startTime != ''">
             and t.start_time= #{startTime}
         </if>

+ 30 - 0
service-store/src/main/java/com/java110/store/smo/impl/ScheduleClassesDayV1InnerServiceSMOImpl.java

@@ -16,6 +16,9 @@
 package com.java110.store.smo.impl;
 
 
+import com.java110.dto.scheduleClassesTime.ScheduleClassesTimeDto;
+import com.java110.intf.store.IScheduleClassesTimeV1InnerServiceSMO;
+import com.java110.po.scheduleClassesTime.ScheduleClassesTimePo;
 import com.java110.store.dao.IScheduleClassesDayV1ServiceDao;
 import com.java110.intf.store.IScheduleClassesDayV1InnerServiceSMO;
 import com.java110.dto.scheduleClassesDay.ScheduleClassesDayDto;
@@ -45,6 +48,9 @@ public class ScheduleClassesDayV1InnerServiceSMOImpl extends BaseServiceSMO impl
     @Autowired
     private IScheduleClassesDayV1ServiceDao scheduleClassesDayV1ServiceDaoImpl;
 
+    @Autowired
+    private IScheduleClassesTimeV1InnerServiceSMO scheduleClassesTimeV1InnerServiceSMOImpl;
+
 
     @Override
     public int saveScheduleClassesDay(@RequestBody  ScheduleClassesDayPo scheduleClassesDayPo) {
@@ -78,6 +84,30 @@ public class ScheduleClassesDayV1InnerServiceSMOImpl extends BaseServiceSMO impl
 
         List<ScheduleClassesDayDto> scheduleClassesDays = BeanConvertUtil.covertBeanList(scheduleClassesDayV1ServiceDaoImpl.getScheduleClassesDayInfo(BeanConvertUtil.beanCovertMap(scheduleClassesDayDto)), ScheduleClassesDayDto.class);
 
+        if(scheduleClassesDays == null || scheduleClassesDays.size() <1){
+            return scheduleClassesDays;
+        }
+
+        List<String> dayIds = new ArrayList<>();
+        for(ScheduleClassesDayDto scheduleClassesDayDto1 : scheduleClassesDays){
+            dayIds.add(scheduleClassesDayDto1.getDayId());
+        }
+
+        ScheduleClassesTimeDto scheduleClassesTimeDto =  new ScheduleClassesTimeDto();
+        scheduleClassesTimeDto.setDayIds(dayIds.toArray(new String[dayIds.size()]));
+        List<ScheduleClassesTimeDto> scheduleClassesTimeDtos = scheduleClassesTimeV1InnerServiceSMOImpl.queryScheduleClassesTimes(scheduleClassesTimeDto);
+        List<ScheduleClassesTimeDto> scheduleClassesTimeDtos1 =  null;
+        for(ScheduleClassesDayDto scheduleClassesDayDto1 : scheduleClassesDays){
+            scheduleClassesTimeDtos1 = new ArrayList<>();
+            for(ScheduleClassesTimeDto scheduleClassesTimeDto1 : scheduleClassesTimeDtos){
+                if(scheduleClassesDayDto1.getDayId().equals(scheduleClassesTimeDto1.getDayId())) {
+                    scheduleClassesTimeDtos1.add(scheduleClassesTimeDto1);
+                }
+            }
+            scheduleClassesDayDto1.setTimes(scheduleClassesTimeDtos1);
+        }
+
+
         return scheduleClassesDays;
     }