Commit 66526362 authored by cq990612's avatar cq990612

优化代码结构

 Conflicts:
	wisenergy-service/src/main/java/cn/wisenergy/service/impl/WorkTimeOrderServiceImpl.java
parent 500d064a
......@@ -77,4 +77,8 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> {
List<Date> getDaysByDateAndStatus(@Param("firstDayOfMonth") Date firstDayOfMonth,@Param("userId") Integer userId);
List<WorkTimeOrder> getAutoOrder(Integer autoExamine);
int updateAutoExamine(@Param("workIds") List<Integer> workIds);
}
......@@ -16,6 +16,7 @@
<result column="reason" property="reason" />
<result column="type" property="type" />
<result column="is_overtime" property="isOvertime" />
<result column="reject_time" property="rejectTime" />
<result column="create_time" property="createTime" />
<result column="modify_time" property="modifyTime" />
</resultMap>
......@@ -23,10 +24,10 @@
<!-- 通用查询结果列 -->
<sql id="vals">
#{userId},#{projectId},#{deptId},#{workTime},#{workDay},#{status},#{reviewerId},#{des},#{reason},#{type},#{isOvertime},now(),now()
#{userId},#{projectId},#{deptId},#{workTime},#{workDay},#{status},#{reviewerId},#{des},#{reason},#{type},#{isOvertime},#{rejectTime},now(),now()
</sql>
<sql id="cols_exclude_id">
user_id, project_id, dept_id, work_time, work_day, status, reviewer_id, des, reason, type, is_overtime, create_time, modify_time
user_id, project_id, dept_id, work_time, work_day, status, reviewer_id, des, reason, type, is_overtime,reject_time, create_time, modify_time
</sql>
<sql id="criteria">
......@@ -86,8 +87,19 @@
<update id="updateStatusById">
UPDATE
<include refid="table"/>
SET status = 3,reason = #{reason},reviewer_id = #{reviewerId},modify_time=now()
SET status = 3,reason = #{reason},reviewer_id = #{reviewerId},modify_time=now(),reject_time=now()
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>
......@@ -216,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>
</mapper>
......@@ -41,6 +41,9 @@ public class WorkCollect implements Serializable {
@ApiModelProperty(name = "status",value = "状态: 1:已填报 ,2:已审核,3:被驳回")
private Integer status;
@ApiModelProperty(name = "rejectTime",value = "驳回时间")
private Date rejectTime;
@ApiModelProperty(name = "createTime",value = "创建时间")
private Date createTime;
......
......@@ -67,5 +67,7 @@ public class WorkTimeOrder implements Serializable {
@ApiModelProperty(name = "modifyTime", value = "工单修改时间")
private Date modifyTime;
@ApiModelProperty(name = "rejectTime",value = "驳回时间")
private Date rejectTime;
}
......@@ -336,6 +336,7 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
isManager(userId);
WorkUser user = workUserService.getById(userId);
// PC端
return pageExamine(user, projectId, type, page, size, status);
}
......@@ -355,7 +356,6 @@ public class WorkTimeOrderServiceImpl implements WorkTimeOrderService {
if (null == projectId && null == type) {
return null;
}
if (0 != user.getLevel()) {
QueryWrapper<WorkTimeOrder> wrapper = new QueryWrapper<>();
wrapper.in("status", COMPLETED, RE_SUBMIT);
......
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.model.app.WorkSubmitAdopt;
import cn.wisenergy.model.app.WorkTimeOrder;
import cn.wisenergy.model.enums.StatusEnum;
import cn.wisenergy.service.WorkCollectService;
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.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
......@@ -18,9 +17,7 @@ import org.springframework.scheduling.config.TriggerTask;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.ArrayList;
import java.util.List;
......@@ -50,34 +47,21 @@ public class Trigger implements SchedulingConfigurer {
//这里写业务方法
WorkSubmitAdopt workSubmitAdopt = workSubmitAdoptService.getById(1);
Integer autoExamine = workSubmitAdopt.getAutoExamine();
if (null == autoExamine && 0 == autoExamine) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
// 更新work_time_order表
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.setTime(new Date());
c.add(Calendar.DATE, -(autoExamine+1));
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 + "条工单");
List<WorkTimeOrder> workTimeOrders = workTimeOrderMapper.getAutoOrder(autoExamine*24);
List<Integer> projectIds = new ArrayList<>();
workTimeOrders.forEach(wto -> projectIds.add(wto.getWorkId()));
workTimeOrderMapper.updateAutoExamine(projectIds);
// 更新work_collect表
workCollectService.updateByWorkTimeOrder(workTimeOrders);
}
, triggerContext -> {
Integer autoAdopt = workSubmitAdoptService.getById(1).getAutoAdopt();
String time = "0 30 17 */" + autoAdopt + " * ?";
String time = "0 0 0 */" + autoAdopt + " * ?";
//返回执行的周期
return new CronTrigger(time).nextExecutionTime(triggerContext);
});
......
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