package com.changhong.epc.parsing.service.asset;
|
|
import com.changhong.epc.bean.admin.AssetDepreciation;
|
import com.changhong.epc.constter.parsing.asset.AssetMsg;
|
import com.changhong.epc.constter.parsing.asset.AssetStatic;
|
import com.changhong.epc.constter.system.businesscode.BudgetBusinessMeaningCode;
|
import com.iemsoft.framework.cloud.core.tools.DateTool;
|
import com.iemsoft.framework.cloud.core.tools.StringUtil;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.Calendar;
|
|
/**
|
* 固定资产处理
|
*/
|
public interface AssetHandle extends BudgetBusinessMeaningCode, AssetStatic, AssetMsg {
|
|
/**
|
* 验证是否可以执行
|
* @param assetDepreciation
|
* @return
|
*/
|
boolean validate(AssetDepreciation assetDepreciation);
|
|
@Transactional
|
default void doHandle(AssetDepreciation assetDepreciation){
|
validate(assetDepreciation);
|
handle(assetDepreciation);
|
}
|
|
/**
|
* 执行
|
* @param assetDepreciation
|
*/
|
void handle(AssetDepreciation assetDepreciation);
|
|
/**
|
* 获得相隔多少月
|
* @param begin
|
* @param end
|
* @return
|
*/
|
default int getMonthSize(String begin, String end) {
|
Calendar bef = Calendar.getInstance();
|
Calendar aft = Calendar.getInstance();
|
bef.setTime(DateTool.stringToDate(begin , (StringUtil.length(begin) >= 7 ? "yyyy-MM" : DateTool.DATE_PATTERN)));
|
aft.setTime(DateTool.stringToDate(end , (StringUtil.length(end) >= 7 ? "yyyy-MM" : DateTool.DATE_PATTERN)));
|
int result = aft.get(Calendar.MONTH) - bef.get(Calendar.MONTH);
|
int month = (aft.get(Calendar.YEAR) - bef.get(Calendar.YEAR)) * 12;
|
return month + result;
|
}
|
|
/**
|
* 改变月份
|
* @param date
|
* @param monthSize
|
* @return
|
*/
|
default String updateMonth(String date, int monthSize){
|
if(monthSize == 0){
|
return date;
|
}
|
Calendar bef = Calendar.getInstance();
|
bef.setTime(DateTool.stringToDate(date , (StringUtil.length(date) >= 7 ? "yyyy-MM" : DateTool.DATE_PATTERN)));
|
bef.add(Calendar.MONTH, monthSize);
|
return DateTool.dateToString(bef.getTime(), "yyyy-MM");
|
}
|
}
|