Commit 0c5c6240 authored by cq990612's avatar cq990612

Merge branch 'chenqi'

parents b523aff7 2d939f83
...@@ -77,4 +77,8 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> { ...@@ -77,4 +77,8 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> {
List<Date> getDaysByDateAndStatus(@Param("firstDayOfMonth") Date firstDayOfMonth,@Param("userId") Integer userId); List<Date> getDaysByDateAndStatus(@Param("firstDayOfMonth") Date firstDayOfMonth,@Param("userId") Integer userId);
List<WorkTimeOrder> getAutoOrder(Integer autoExamine);
int updateAutoExamine(@Param("workIds") List<Integer> workIds);
} }
...@@ -89,6 +89,17 @@ ...@@ -89,6 +89,17 @@
<include refid="table"/> <include refid="table"/>
SET status = 3,reason = #{reason},reviewer_id = #{reviewerId},modify_time=now(),reject_time=now() SET status = 3,reason = #{reason},reviewer_id = #{reviewerId},modify_time=now(),reject_time=now()
WHERE work_id = #{id} WHERE work_id = #{id}
</update>
<update id="updateAutoExamine">
UPDATE
<include refid="table"/>
SET status = 5,modify_time=now()
<where> work_id IN
<foreach collection="workIds" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</where>
</update> </update>
...@@ -217,5 +228,17 @@ ...@@ -217,5 +228,17 @@
</select>
<select id="getAutoOrder" resultType="cn.wisenergy.model.app.WorkTimeOrder">
select
<include refid="Base_Column_List"/>
FROM
<include refid="table"/>
<where>
status IN (1,4)
AND DAY( timediff( now(), modify_time) ) > #{autoExamine}
</where>
</select> </select>
</mapper> </mapper>
package cn.wisenergy.web.config.auto; package cn.wisenergy.web.config.auto;
import cn.wisenergy.common.utils.DateUtil; import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM;
import cn.wisenergy.common.utils.exception.BaseCustomException;
import cn.wisenergy.mapper.WorkTimeOrderMapper; import cn.wisenergy.mapper.WorkTimeOrderMapper;
import cn.wisenergy.model.app.WorkSubmitAdopt; import cn.wisenergy.model.app.WorkSubmitAdopt;
import cn.wisenergy.model.app.WorkTimeOrder; import cn.wisenergy.model.app.WorkTimeOrder;
import cn.wisenergy.model.enums.StatusEnum; import cn.wisenergy.model.enums.StatusEnum;
import cn.wisenergy.service.WorkCollectService; import cn.wisenergy.service.WorkCollectService;
import cn.wisenergy.service.WorkSubmitAdoptService; import cn.wisenergy.service.WorkSubmitAdoptService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
...@@ -18,9 +17,7 @@ import org.springframework.scheduling.config.TriggerTask; ...@@ -18,9 +17,7 @@ import org.springframework.scheduling.config.TriggerTask;
import org.springframework.scheduling.support.CronTrigger; import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List; import java.util.List;
...@@ -50,27 +47,14 @@ public class Trigger implements SchedulingConfigurer { ...@@ -50,27 +47,14 @@ public class Trigger implements SchedulingConfigurer {
//这里写业务方法 //这里写业务方法
WorkSubmitAdopt workSubmitAdopt = workSubmitAdoptService.getById(1); WorkSubmitAdopt workSubmitAdopt = workSubmitAdoptService.getById(1);
Integer autoExamine = workSubmitAdopt.getAutoExamine(); Integer autoExamine = workSubmitAdopt.getAutoExamine();
if (null == autoExamine && 0 == autoExamine) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
// 更新work_time_order表 // 更新work_time_order表
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); List<WorkTimeOrder> workTimeOrders = workTimeOrderMapper.getAutoOrder(autoExamine*24);
Calendar c = Calendar.getInstance(); List<Integer> projectIds = new ArrayList<>();
c.setTime(new Date()); workTimeOrders.forEach(wto -> projectIds.add(wto.getWorkId()));
c.add(Calendar.DATE, -(autoExamine+1)); workTimeOrderMapper.updateAutoExamine(projectIds);
Date start = c.getTime();
String qyt= format.format(start);
Date yesterdayDate = DateUtil.convertStrToDate(qyt, "yyyy-MM-dd");
Date now = DateUtil.getToday();
QueryWrapper<WorkTimeOrder> wrapper = new QueryWrapper<>();
wrapper.in("status", COMPLETED,RE_SUBMIT);
wrapper.le("work_day", yesterdayDate);
List<WorkTimeOrder> workTimeOrders = workTimeOrderMapper.selectList(wrapper);
UpdateWrapper<WorkTimeOrder> wtoWrapper = new UpdateWrapper<>();
wtoWrapper.in("status", COMPLETED,RE_SUBMIT);
wtoWrapper.le("work_day", yesterdayDate);
WorkTimeOrder workTimeOrder1 = new WorkTimeOrder();
workTimeOrder1.setStatus(AUTOMATIC_AUDIT);
workTimeOrder1.setModifyTime(now);
int wtoRow = workTimeOrderMapper.update(workTimeOrder1, wtoWrapper);
System.out.println("一共审核:" + wtoRow + "条工单");
// 更新work_collect表 // 更新work_collect表
workCollectService.updateByWorkTimeOrder(workTimeOrders); workCollectService.updateByWorkTimeOrder(workTimeOrders);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment