📄 businessaction.java~78~
字号:
package com.jbaptech.accp.netbar.server.action;
import java.util.ArrayList;
import com.jbaptech.accp.netbar.client.ComsumeDisplayData;
import com.jbaptech.accp.netbar.server.entity.Card;
import com.jbaptech.accp.netbar.server.dao.CardDAO;
import com.jbaptech.accp.netbar.server.entity.Computer;
import com.jbaptech.accp.netbar.server.dao.RecordDAO;
import com.jbaptech.accp.netbar.server.entity.Record;
import com.jbaptech.accp.netbar.server.dao.ComputerDAO;
/**
* BusinessAction Description here.
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2005</p>
*
* <p>Company: 北京阿博泰克北大青鸟信息技术有限公司</p>
*
* @author luohao
* @version 1.0
*/
public class BusinessAction {
static final int FOUR = 4;
static final int FIVE = 5;
static final int SERVERN = 7;
static final int EIGHIT = 8;
static final int TEN = 10;
static final int ELEVEN = 11;
static final int THIRTEEN = 13;
static final int FOURTEEN = 14;
static final int SIXTEEN = 16;
static final int ONE_YEAR_DAYS =365;
/**
* check the card and password that is valid or not.
* @param card Card
* @return boolean
*/
public static boolean cardIsValid(final Card card) {
CardDAO dao = new CardDAO();
return dao.cardIsValid(card);
}
/**
* judge the card has balance or not.
* @param card Card
* @return boolean
*/
public static boolean cardHaveBalance(final Card card) {
CardDAO dao = new CardDAO();
return dao.cardIsHaveBalance(card);
}
/**
* do check in operator business.
* @param record Record
* @param computer Computer
*/
public static void doStartUseComputerBusiness(final Record record,
final Computer computer) {
RecordDAO dao = new RecordDAO();
dao.doStartUseComputerBusiness(record, computer);
}
/**
* get not used computer list.
* @return ArrayList
*/
public static ArrayList getNotUsedComputeList() {
ComputerDAO dao = new ComputerDAO();
return dao.getNoUsedComputerList();
}
/**
* get a list about the computers using.
* @return ArrayList
*/
public static ArrayList getNotStopComputer() {
RecordDAO dao = new RecordDAO();
return dao.getNotStopComputer();
}
/**
* do check out business.
* @param rec Record
* @return ComsumeDisplayData
*/
public static ComsumeDisplayData doStopUseComputerBusiness(final Record rec) {
RecordDAO dao = new RecordDAO();
ComsumeDisplayData result = dao.getStopCompouterRelationInfo(rec);
Record record = result.getRecord();
Card card = result.getCard();
//计算本次上机的钱
int fee = calFee(record.getBeginTime(), record.getEndTime());
record.setFee(fee);
int balance = card.getBalance() - fee;
card.setId(record.getCardId());
card.setBalance(balance);
//do databasechange
RecordDAO dao2 = new RecordDAO();
dao2.doDatabaseChangeAboutEndPlay(record, card);
result.setRecord(record);
result.setCard(card);
return result;
}
/**
* calculate fee.
* @param beginTime String
* @param endTime String
* @return int
*/
private static int calFee(final String beginTime, final String endTime) {
int fee = 0;
int beginYear = Integer.parseInt(beginTime.substring(0, FOUR));
int beginMonth = Integer.parseInt(beginTime.substring(FIVE, SERVERN));
int beginDay = Integer.parseInt(beginTime.substring(EIGHIT, TEN));
int beginHour = Integer.parseInt(beginTime.substring(ELEVEN, THIRTEEN));
int beiginMinute = Integer.parseInt(beginTime.substring(FOURTEEN, SIXTEEN));
int endYear = Integer.parseInt(endTime.substring(0, FOUR));
int endMonth = Integer.parseInt(endTime.substring(FIVE, SERVERN));
int endDay = Integer.parseInt(endTime.substring(EIGHIT, TEN));
int endHour = Integer.parseInt(endTime.substring(ELEVEN, THIRTEEN));
int endMinute = Integer.parseInt(endTime.substring(FOURTEEN, SIXTEEN));
int playMinutes = 0;
playMinutes = ((endYear - beginYear) * 365 * 24 * 60
+ (endMonth - beginMonth) * 30 * 24 * 60
+ (endDay - beginDay) * 24 * 60
+ (endHour - beginHour) * 60 + (endMinute - beiginMinute));
int modNum = playMinutes % 60;
int playHours = 0;
playHours = playMinutes / 60;
if (playHours == 0 || (modNum >FIVE && playHours > 0)) {
playHours++;
}
fee = playHours * 2;
return fee;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -