فهرست منبع

update 月保费用改成300

周箭河 4 سال پیش
والد
کامیت
a3f0cc6362

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentInstrumentDao.java

@@ -8,5 +8,16 @@ import java.util.List;
 
 public interface StudentInstrumentDao extends BaseDAO<Long, StudentInstrument> {
 
+    /**
+     * 批量添加
+     * @param studentInstruments
+     * @return
+     */
     int batchAdd(@Param("studentInstruments") List<StudentInstrument> studentInstruments);
+
+    /**
+     * 批量修改
+     * @return
+     */
+    int batchUpdate();
 }

+ 149 - 133
mec-biz/src/main/resources/config/mybatis/StudentInstrumentMapper.xml

@@ -1,144 +1,160 @@
 <?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">
 <mapper namespace="com.ym.mec.biz.dal.dao.StudentInstrumentDao">
-  <resultMap id="StudentInstrument" type="com.ym.mec.biz.dal.entity.StudentInstrument">
-    <!--@mbg.generated-->
-    <!--@Table student_instrument-->
-    <id column="id_" property="id" />
-    <result column="student_id_" property="studentId" />
-    <result column="organ_id_" property="organId" />
-    <result column="goods_id_" property="goodsId" />
-    <result column="goods_category_id_" property="goodsCategoryId" />
-    <result column="goods_category_name_" property="goodsCategoryName" />
-    <result column="status_" property="status" />
-    <result column="start_time_" property="startTime" />
-    <result column="end_time_" property="endTime" />
-    <result column="create_time_" property="createTime" />
-    <result column="update_time" property="updateTime" />
-    <result column="goods_name_" property="goodsName" />
-    <result column="specification_" property="specification" />
-    <result column="goods_brand_" property="goodsBrand" />
-    <result column="goods_img_" property="goodsImg" />
-  </resultMap>
+    <resultMap id="StudentInstrument" type="com.ym.mec.biz.dal.entity.StudentInstrument">
+        <!--@mbg.generated-->
+        <!--@Table student_instrument-->
+        <id column="id_" property="id"/>
+        <result column="student_id_" property="studentId"/>
+        <result column="organ_id_" property="organId"/>
+        <result column="goods_id_" property="goodsId"/>
+        <result column="goods_category_id_" property="goodsCategoryId"/>
+        <result column="goods_category_name_" property="goodsCategoryName"/>
+        <result column="status_" property="status"/>
+        <result column="start_time_" property="startTime"/>
+        <result column="end_time_" property="endTime"/>
+        <result column="create_time_" property="createTime"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="goods_name_" property="goodsName"/>
+        <result column="specification_" property="specification"/>
+        <result column="goods_brand_" property="goodsBrand"/>
+        <result column="goods_img_" property="goodsImg"/>
+    </resultMap>
 
-  <select id="get" parameterType="java.lang.Integer" resultMap="StudentInstrument">
-    <!--@mbg.generated-->
-    SELECT * FROM student_instrument
-    where id_ = #{id}
-  </select>
-  <delete id="delete" parameterType="java.lang.Integer">
-    <!--@mbg.generated-->
-    delete from student_instrument
-    where id_ = #{id}
-  </delete>
-  
-  <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.StudentInstrument" useGeneratedKeys="true">
-    <!--@mbg.generated-->
-    insert into student_instrument (student_id_,organ_id_,goods_id_,goods_category_id_,goods_category_name_,goods_name_,goods_brand_,specification_,goods_img_, status_, start_time_, end_time_, create_time_, update_time
-      )
-    values (#{studentId},#{organId},#{goodsId},#{goodsCategoryId},#{goodsCategoryName},#{goodsName},#{goodsBrand},#{specification},#{goodsImg}, #{status}, #{startTime}, #{endTime}, NOW(), NOW()
-      )
-  </insert>
-  <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentInstrument">
-    <!--@mbg.generated-->
-    update student_instrument
-    <set>
-      <if test="studentId != null">
-        student_id_ = #{studentId},
-      </if>
-      <if test="organId != null">
-        organ_id_ = #{organId},
-      </if>
-      <if test="goodsId != null">
-        goods_id_ = #{goodsId},
-      </if>
-      <if test="goodsName != null">
-        goods_name_ = #{goodsName},
-      </if>
-      <if test="goodsBrand != null">
-        goods_brand_ = #{goodsBrand},
-      </if>
-      <if test="specification != null">
-        specification_ = #{specification},
-      </if>
-      <if test="goodsImg != null">
-        goods_img_ = #{goodsImg},
-      </if>
-      <if test="status != null">
-        status_ = #{status},
-      </if>
-      <if test="startTime != null">
-        start_time_ = #{startTime},
-      </if>
-      <if test="endTime != null">
-        end_time_ = #{endTime},
-      </if>
-      <if test="createTime != null">
-        create_time_ = #{createTime},
-      </if>
-      <if test="updateTime != null">
-        update_time = #{updateTime},
-      </if>
-    </set>
-    where id_ = #{id}
-  </update>
+    <select id="get" parameterType="java.lang.Integer" resultMap="StudentInstrument">
+        <!--@mbg.generated-->
+        SELECT * FROM student_instrument
+        where id_ = #{id}
+    </select>
+    <delete id="delete" parameterType="java.lang.Integer">
+        <!--@mbg.generated-->
+        delete from student_instrument
+        where id_ = #{id}
+    </delete>
 
-  <!-- 全查询 -->
-  <select id="findAll" resultMap="StudentInstrument">
-    SELECT *
-    FROM student
-  </select>
+    <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.StudentInstrument"
+            useGeneratedKeys="true">
+        <!--@mbg.generated-->
+        insert into student_instrument
+        (student_id_,organ_id_,goods_id_,goods_category_id_,goods_category_name_,goods_name_,goods_brand_,specification_,goods_img_,
+        status_, start_time_, end_time_, create_time_, update_time
+        )
+        values
+        (#{studentId},#{organId},#{goodsId},#{goodsCategoryId},#{goodsCategoryName},#{goodsName},#{goodsBrand},#{specification},#{goodsImg},
+        #{status}, #{startTime}, #{endTime}, NOW(), NOW()
+        )
+    </insert>
+    <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentInstrument">
+        <!--@mbg.generated-->
+        update student_instrument
+        <set>
+            <if test="studentId != null">
+                student_id_ = #{studentId},
+            </if>
+            <if test="organId != null">
+                organ_id_ = #{organId},
+            </if>
+            <if test="goodsId != null">
+                goods_id_ = #{goodsId},
+            </if>
+            <if test="goodsName != null">
+                goods_name_ = #{goodsName},
+            </if>
+            <if test="goodsBrand != null">
+                goods_brand_ = #{goodsBrand},
+            </if>
+            <if test="specification != null">
+                specification_ = #{specification},
+            </if>
+            <if test="goodsImg != null">
+                goods_img_ = #{goodsImg},
+            </if>
+            <if test="status != null">
+                status_ = #{status},
+            </if>
+            <if test="startTime != null">
+                start_time_ = #{startTime},
+            </if>
+            <if test="endTime != null">
+                end_time_ = #{endTime},
+            </if>
+            <if test="createTime != null">
+                create_time_ = #{createTime},
+            </if>
+            <if test="updateTime != null">
+                update_time = #{updateTime},
+            </if>
+        </set>
+        where id_ = #{id}
+    </update>
 
-  <!-- 分页查询 -->
-  <select id="queryPage" resultMap="StudentInstrument" parameterType="map">
-    SELECT si.*,su.username_ studentName,su.phone_ phone,o.name_ organName FROM student_instrument si
-    LEFT JOIN sys_user su ON su.id_ = si.student_id_
-    LEFT JOIN organization o ON o.id_ = si.organ_id_
-    <include refid="queryPageSql"/>
-    <include refid="global.limit"/>
-  </select>
+    <!-- 全查询 -->
+    <select id="findAll" resultMap="StudentInstrument">
+        SELECT *
+        FROM student
+    </select>
 
-  <!-- 查询当前表的总记录数 -->
-  <select id="queryCount" resultType="int">
-    SELECT COUNT(*)
-    FROM student_instrument si
-    LEFT JOIN sys_user su ON su.id_ = si.student_id_
-    <include refid="queryPageSql"/>
-  </select>
+    <!-- 分页查询 -->
+    <select id="queryPage" resultMap="StudentInstrument" parameterType="map">
+        SELECT si.*,su.username_ studentName,su.phone_ phone,o.name_ organName FROM student_instrument si
+        LEFT JOIN sys_user su ON su.id_ = si.student_id_
+        LEFT JOIN organization o ON o.id_ = si.organ_id_
+        <include refid="queryPageSql"/>
+        <include refid="global.limit"/>
+    </select>
 
-  <sql id="queryPageSql">
-    <where>
-      <if test="studentId != null">
-        AND si.student_id_ = #{studentId}
-      </if>
-      <if test="organId != null">
-        AND FIND_IN_SET(si.organ_id_,#{organId})
-      </if>
-      <if test="goodsId != null">
-        AND si.goods_id_ = #{goodsId}
-      </if>
-      <if test="goodsCategoryId != null">
-        AND si.goods_category_id_ = #{goodsCategoryId}
-      </if>
-      <if test="goodsBrand != null">
-        AND si.goods_brand_ LIKE CONCAT('%',#{goodsBrand},'%')
-      </if>
-      <if test="specification != null">
-        AND si.specification_ LIKE CONCAT('%',#{specification},'%')
-      </if>
-      <if test="search != null">
-        AND (si.student_id_ = #{search} OR su.phone_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%'))
-      </if>
-    </where>
-  </sql>
+    <!-- 查询当前表的总记录数 -->
+    <select id="queryCount" resultType="int">
+        SELECT COUNT(*)
+        FROM student_instrument si
+        LEFT JOIN sys_user su ON su.id_ = si.student_id_
+        <include refid="queryPageSql"/>
+    </select>
 
-  <insert id="batchAdd" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-    insert into student_instrument (student_id_,organ_id_,goods_id_,goods_category_id_,goods_category_name_,goods_name_,goods_brand_,specification_,goods_img_, status_, start_time_, end_time_, create_time_, update_time)
-    VALUE
-    <foreach collection="studentInstruments" item="item" separator=",">
-      (#{item.studentId},#{item.organId},#{item.goodsId},#{item.goodsCategoryId},#{item.goodsCategoryName},#{item.goodsName},#{item.goodsBrand},#{item.specification},#{item.goodsImg}, #{item.status}, #{item.startTime},
-      #{item.endTime}, NOW(), NOW())
-    </foreach>
-  </insert>
+    <sql id="queryPageSql">
+        <where>
+            <if test="studentId != null">
+                AND si.student_id_ = #{studentId}
+            </if>
+            <if test="organId != null">
+                AND FIND_IN_SET(si.organ_id_,#{organId})
+            </if>
+            <if test="goodsId != null">
+                AND si.goods_id_ = #{goodsId}
+            </if>
+            <if test="goodsCategoryId != null">
+                AND si.goods_category_id_ = #{goodsCategoryId}
+            </if>
+            <if test="goodsBrand != null">
+                AND si.goods_brand_ LIKE CONCAT('%',#{goodsBrand},'%')
+            </if>
+            <if test="specification != null">
+                AND si.specification_ LIKE CONCAT('%',#{specification},'%')
+            </if>
+            <if test="search != null">
+                AND (si.student_id_ = #{search} OR su.phone_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%'))
+            </if>
+        </where>
+    </sql>
+
+    <insert id="batchAdd" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+        insert into student_instrument
+        (student_id_,organ_id_,goods_id_,goods_category_id_,goods_category_name_,goods_name_,goods_brand_,specification_,goods_img_,
+        status_, start_time_, end_time_, create_time_, update_time)
+        VALUE
+        <foreach collection="studentInstruments" item="item" separator=",">
+            (#{item.studentId},#{item.organId},#{item.goodsId},#{item.goodsCategoryId},#{item.goodsCategoryName},#{item.goodsName},#{item.goodsBrand},#{item.specification},#{item.goodsImg},
+            #{item.status}, #{item.startTime},
+            #{item.endTime}, NOW(), NOW())
+        </foreach>
+    </insert>
+
+    <update id="batchUpdate">
+   <![CDATA[
+        UPDATE student_instrument
+        SET status_ = 0
+        WHERE end_time_ <= NOW()
+        ]]>
+    </update>
 
 </mapper>

+ 4 - 1
mec-student/src/main/java/com/ym/mec/student/controller/StudentInstrumentController.java

@@ -3,6 +3,7 @@ package com.ym.mec.student.controller;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dao.StudentInstrumentDao;
 import com.ym.mec.biz.dal.dto.MaintenancePayDto;
 import com.ym.mec.biz.dal.dto.RegisterPayDto;
 import com.ym.mec.biz.dal.entity.StudentInstrument;
@@ -31,7 +32,8 @@ public class StudentInstrumentController extends BaseController {
     private StudentInstrumentService studentInstrumentService;
     @Autowired
     private SysUserFeignService sysUserFeignService;
-
+    @Autowired
+    private StudentInstrumentDao studentInstrumentDao;
 
     @ApiOperation(value = "获取乐器与乐保列表")
     @GetMapping("/getList")
@@ -41,6 +43,7 @@ public class StudentInstrumentController extends BaseController {
             return failed(HttpStatus.FORBIDDEN, "请登录");
         }
         queryInfo.setStudentId(user.getId());
+        studentInstrumentDao.batchUpdate();
         return succeed(studentInstrumentService.queryPage(queryInfo));
     }
 

+ 4 - 0
mec-web/src/main/java/com/ym/mec/web/controller/StudentInstrumentController.java

@@ -5,6 +5,7 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
 import com.ym.mec.biz.dal.dao.StudentDao;
+import com.ym.mec.biz.dal.dao.StudentInstrumentDao;
 import com.ym.mec.biz.dal.entity.Employee;
 import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.StudentInstrument;
@@ -40,6 +41,8 @@ public class StudentInstrumentController extends BaseController {
     private SysUserFeignService sysUserFeignService;
     @Autowired
     private EmployeeDao employeeDao;
+    @Autowired
+    private StudentInstrumentDao studentInstrumentDao;
 
 
     @ApiOperation(value = "乐器保养列表")
@@ -61,6 +64,7 @@ public class StudentInstrumentController extends BaseController {
                 return failed("非法请求");
             }
         }
+        studentInstrumentDao.batchUpdate();
         return succeed(studentInstrumentService.queryPage(queryInfo));
     }