Commit 063c97f5 authored by Mccoy Z Xia's avatar Mccoy Z Xia

trigger 触发相关功能

parent 14c2058e
......@@ -2,6 +2,11 @@ package pwc.taxtech.atms.constant.enums;
public enum CalendarEnum {
TRIGGER_UNIT_CALENDAR_DAY("CalendarDay", "1", ""),
TRIGGER_UNIT_WEEK_DAY("WeekDay", "2", ""),
TRIGGER_UNIT_MONTH("Month", "3", ""),
TRIGGER_UNIT_YEAR("Year", "4", ""),
CALENDAR_EVENT_COMPLETED("已完成", "1", ""),
CALENDAR_EVENT_NOT_COMPLETED("未完成", "0", ""),
......
package pwc.taxtech.atms.service.impl;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import pwc.taxtech.atms.calendar.dao.CalendarActionJurisdictionRelationshipMapper;
import pwc.taxtech.atms.calendar.dao.CalendarActionMapper;
import pwc.taxtech.atms.calendar.dao.CalendarJurisdictionMapper;
import pwc.taxtech.atms.calendar.dao.ext.CalendarActionTMapper;
import pwc.taxtech.atms.calendar.dao.ext.CalendarExtMapper;
import pwc.taxtech.atms.calendar.dao.ext.CalendarJurisdictionTMapper;
import pwc.taxtech.atms.calendar.dto.CalendarActionByAreaDto;
import pwc.taxtech.atms.calendar.dto.CalendarActionDto;
import pwc.taxtech.atms.calendar.dto.CalendarJurisdictionDto;
import pwc.taxtech.atms.calendar.entity.*;
import pwc.taxtech.atms.constant.enums.CalendarEnum;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.service.ICalendarActionService;
......@@ -22,6 +24,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* <p> @Description </p>
*
......@@ -60,7 +63,7 @@ public class CalendarActionServiceImpl extends BaseService implements ICalendarA
if (dto.getId() == null) {
result = insertAction(dto);
} else {
result =updateAction(dto);
result = updateAction(dto);
}
return new OperationResultDto(result);
......@@ -163,4 +166,45 @@ public class CalendarActionServiceImpl extends BaseService implements ICalendarA
return OperationResultDto.success(actionDtoList);
}
public boolean addTriggerEvent(Long entityId, Long triggerId, Integer areaId) {
//获取对应trigger和area的action list
List<CalendarActionByAreaDto> actionList = getActionListByTriggerAndArea(triggerId, areaId);
//查询是否有对应actionId的未完成状态的event
//存在 update
//不存在 insert
//计算dueDate时间
//update/insert
Date effectiveDate = new Date();
Integer logicNum = null, logicUnitId = null;
Date dueDate = calculateDueDate(effectiveDate, logicNum, logicUnitId);
return true;
}
private Date calculateDueDate(Date effectiveDate, Integer logicNum, Integer logicUnitId) {
if(Integer.parseInt(CalendarEnum.TRIGGER_UNIT_CALENDAR_DAY.getCode()) == logicUnitId) {
return DateUtils.addDays(effectiveDate, logicNum);
} else if(Integer.parseInt(CalendarEnum.TRIGGER_UNIT_WEEK_DAY.getCode()) == logicUnitId){
return DateUtils.addWeeks(effectiveDate, logicNum);
} else if(Integer.parseInt(CalendarEnum.TRIGGER_UNIT_MONTH.getCode()) == logicUnitId){
return DateUtils.addMonths(effectiveDate, logicNum);
} else if(Integer.parseInt(CalendarEnum.TRIGGER_UNIT_YEAR.getCode()) == logicUnitId){
return DateUtils.addYears(effectiveDate, logicNum);
}
return null;
}
private List<CalendarActionByAreaDto> getActionListByTriggerAndArea(Long triggerId, Integer areaId) {
return null;
}
}
package pwc.taxtech.atms.calendar.dto;
/**
* <p> @Description </p>
*
* @Author: Mccoy Z Xia (Xia zhixin)
* @Date: 2019-07-29 18:08
* @Version: 1.0
**/
public class CalendarActionByAreaDto {
private Long actionId;
private String actionName;
private Long taskTypeId;
private String description;
private Integer logicNum;
private Integer logicUnitId;
public Long getActionId() {
return actionId;
}
public void setActionId(Long actionId) {
this.actionId = actionId;
}
public String getActionName() {
return actionName;
}
public void setActionName(String actionName) {
this.actionName = actionName;
}
public Long getTaskTypeId() {
return taskTypeId;
}
public void setTaskTypeId(Long taskTypeId) {
this.taskTypeId = taskTypeId;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getLogicNum() {
return logicNum;
}
public void setLogicNum(Integer logicNum) {
this.logicNum = logicNum;
}
public Integer getLogicUnitId() {
return logicUnitId;
}
public void setLogicUnitId(Integer logicUnitId) {
this.logicUnitId = logicUnitId;
}
}
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