本文共 16235 字,大约阅读时间需要 54 分钟。
DAO层代码:
package mobi.yoggy.erp.dao;
import java.sql.SQLException;
import java.util.List; import java.util.Map;import mobi.yoggy.erp.beans.AccountTitleMasterBean;
public interface AccountTitleMasterDAO {
/** select AccountTitleMaster's information by condition */
String SELECT_ACCOUNT_TITLE_MASTER_INFORMATION_BY_CONDITION = "select_account_title_master_information_by_condition";/** select count of AccountTitleMaster's list by condition */
String SELECT_COUNT_OF_ACCOUNT_TITLE_INFORMATION = "select_count_of_account_title_information";/** insert new records of AccountTitleMaster by condition */
String INSERT_ACCOUNT_TITLE_MASTER_BY_CONDITION = "insert_account_title_master_by_condition";/** update AccountTitleMaster's information by condition */
String UPDATE_ACCOUNT_TITLE_MASTER_INFORMATION_BY_CONDITION = "update_account_title_master_information_by_condition";/**
* 科目情報リスト取得SQL */ String SELECT_ACCOUNT_TITLE_LIST_BY_CONDITION = "select_account_title_list_by_condition"; /** * select AccountTitleMaster's List information by condition * * @param map * @return AccountTitleMasterBean * @throws SQLException */ public List<AccountTitleMasterBean> selectAccountTilteMasterListByCondition( Map<String, Object> map) throws SQLException;/**
* select count of AccountTitleMaster's list * * @param map * @return Long : count of AccountTitleMaster's list * @throws SQLException */ public Long selectAccountTitleMasterListCountByCondition() throws SQLException;/**
* select AccountTitleMaster's information by condition * * @param map * @return AccountTitleMasterBean * @throws SQLException */ public AccountTitleMasterBean selectAccountTitleMasterInformationById( Map<String, Object> map) throws SQLException;/**
* insert a new record of AccountTitleMaster by condition * * @param accountTitleMasterBean * @throws SQLException */ public void insertAccountTitleMasterByCondition( AccountTitleMasterBean accountTitleMasterBean) throws SQLException;/**
* update AccountTitleMaster's information by condition * * @param accountTitleMasterBean * @return Integer:更新の数 * @throws SQLException */ public Integer updateAccountTitleMasterInformationByConditon( AccountTitleMasterBean accountTitleMasterBean) throws SQLException;/**
* 科目情報リストを取得する. * * @param map 検索条件 * @return AccountTitleMasterBean 科目情報リスト * @throws SQLException DB例外 */ public List<AccountTitleMasterBean> selectAccountTilteListByCondition( Map<String, Object> map) throws SQLException; }#####################################
DAO层实现:
package mobi.yoggy.erp.dao.impl;
import java.sql.SQLException;
import java.util.List; import java.util.Map;import mobi.yoggy.erp.base.dao.AbstractBaseDAO;
import mobi.yoggy.erp.beans.AccountTitleMasterBean; import mobi.yoggy.erp.dao.AccountTitleMasterDAO;public class AccountTitleMasterDAOImpl extends AbstractBaseDAO implements
AccountTitleMasterDAO {public void insertAccountTitleMasterByCondition(
AccountTitleMasterBean accountTitleMasterBean) throws SQLException { getSqlMapClient().insert(INSERT_ACCOUNT_TITLE_MASTER_BY_CONDITION, accountTitleMasterBean); }@SuppressWarnings("unchecked")
public List<AccountTitleMasterBean> selectAccountTilteMasterListByCondition( Map<String, Object> map) throws SQLException {return (List<AccountTitleMasterBean>) getSqlMapClient().queryForList(
SELECT_ACCOUNT_TITLE_MASTER_INFORMATION_BY_CONDITION, map); } @SuppressWarnings("unchecked") public List<AccountTitleMasterBean> selectAccountTilteListByCondition( Map<String, Object> map) throws SQLException {return (List<AccountTitleMasterBean>) getSqlMapClient().queryForList(
SELECT_ACCOUNT_TITLE_LIST_BY_CONDITION, map); } public AccountTitleMasterBean selectAccountTitleMasterInformationById( Map<String, Object> map) throws SQLException {return (AccountTitleMasterBean) getSqlMapClient().queryForObject(
SELECT_ACCOUNT_TITLE_MASTER_INFORMATION_BY_CONDITION, map); }public Long selectAccountTitleMasterListCountByCondition()
throws SQLException {return (Long) getSqlMapClient().queryForObject(
SELECT_COUNT_OF_ACCOUNT_TITLE_INFORMATION); }public Integer updateAccountTitleMasterInformationByConditon(
AccountTitleMasterBean accountTitleMasterBean) throws SQLException {return getSqlMapClient().update(
UPDATE_ACCOUNT_TITLE_MASTER_INFORMATION_BY_CONDITION, accountTitleMasterBean); }}
#################################################
3.service层代码:
package mobi.yoggy.erp.service.master;
import java.util.List;
import java.util.Map;import mobi.yoggy.erp.base.service.ServiceException;
import mobi.yoggy.erp.beans.AccountTitleMasterBean;public interface AccountTitleMasterService {
/**
* select AccountTitleMaster's List information by condition * * @param map * @return AccountTitleMasterBean * @throws ServiceException */ public List<AccountTitleMasterBean> getAccountTilteMasterListByCondition( Map<String, Object> map) throws ServiceException;/**
* select count of AccountTitleMaster's list by condition * * @return Long : count of AccountTitleMaster's list * @throws ServiceException */ public Long getAccountTitleMasterListCountByCondition() throws ServiceException;/**
* select AccountTitleMaster's information by condition * * @param String :accountTitleId * @return AccountTitleMasterBean * @throws ServiceException */ public AccountTitleMasterBean getAccountTitleMasterInformationById( String accountTitleId) throws ServiceException;/**
* insert new records of AccountTitleMaster by condition * * @param List<AccountTitleMasterBean> * @throws ServiceException */ public void insertAccountTitleMasterByCondition( List<AccountTitleMasterBean> list) throws ServiceException;/**
* update AccountTitleMaster's information by condition * * @param accountTitleMasterBean * @return Integer:更新の数 * @throws ServiceException */ public Integer updateAccountTitleMasterInformationByConditon( AccountTitleMasterBean accountTitleMasterBean) throws ServiceException;}
###########################################
4.service层代码实现:
package mobi.yoggy.erp.service.impl.master;
import java.util.HashMap;
import java.util.List; import java.util.Map;import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;import mobi.yoggy.erp.base.service.ServiceException;
import mobi.yoggy.erp.beans.AccountTitleMasterBean; import mobi.yoggy.erp.dao.AccountTitleMasterDAO; import mobi.yoggy.erp.service.master.AccountTitleMasterService;public class AccountTitleMasterServiceImpl implements AccountTitleMasterService {
private static final Log LOG = LogFactory
.getLog(AccountTitleMasterService.class);private AccountTitleMasterDAO accountTitleMasterDAO;
public void insertAccountTitleMasterByCondition(
List<AccountTitleMasterBean> list) throws ServiceException { try {for (AccountTitleMasterBean accountTitleMasterBean : list) {
accountTitleMasterDAO .insertAccountTitleMasterByCondition(accountTitleMasterBean); }} catch (Exception e) {
LOG.error(this, e); throw new ServiceException(e); }}
public List<AccountTitleMasterBean> getAccountTilteMasterListByCondition(
Map<String, Object> map) throws ServiceException { try { return accountTitleMasterDAO .selectAccountTilteMasterListByCondition(map); } catch (Exception e) { LOG.error(this, e); throw new ServiceException(e); } }public AccountTitleMasterBean getAccountTitleMasterInformationById(
String accountTitleId) throws ServiceException { try {Map<String, Object> map = new HashMap<String, Object>();
map.put("accountTitleId", accountTitleId);return accountTitleMasterDAO
.selectAccountTitleMasterInformationById(map); } catch (Exception e) { LOG.error(this, e); throw new ServiceException(e); } }public Long getAccountTitleMasterListCountByCondition()
throws ServiceException { try { return accountTitleMasterDAO .selectAccountTitleMasterListCountByCondition(); } catch (Exception e) { LOG.error(this, e); throw new ServiceException(e); } }public Integer updateAccountTitleMasterInformationByConditon(
AccountTitleMasterBean accountTitleMasterBean) throws ServiceException { try { return accountTitleMasterDAO .updateAccountTitleMasterInformationByConditon(accountTitleMasterBean); } catch (Exception e) { LOG.error(this, e); throw new ServiceException(e); } }public AccountTitleMasterDAO getAccountTitleMasterDAO() {
return accountTitleMasterDAO; }public void setAccountTitleMasterDAO(
AccountTitleMasterDAO accountTitleMasterDAO) { this.accountTitleMasterDAO = accountTitleMasterDAO; }}
####################################
bean的状态值(constant.status):
package mobi.yoggy.erp.constant.status;
/** * 科目マスタENUM定義 * * */ public interface AccountTitleMaster { /** * 貸借区分 */ enum LoanDiv { // 0:借方 LOAN_DIV_DEBIT("借方", "0"), // 1:貸方 LOAN_DIV_CREDIT("貸方", "1");private String displayName, value;
private LoanDiv(String displayName, String value) {
this.displayName = displayName; this.value = value; }public String getValue() {
return value; }public String getDisplayName() {
return displayName; } } /** * 小口現金フラグ */ enum PettyCash { // 0:無効; PETTY_CASH_ENABLE("無効", "0"), // 1:有効(小口現金で扱う科目) PETTY_CASH_DISABLE("有効", "1");private String displayName, value;
private PettyCash(String displayName, String value) {
this.displayName = displayName; this.value = value; }public String getValue() {
return value; }public String getDisplayName() {
return displayName; } } }#######################################
action层:
package mobi.yoggy.erp.apps.action.master.account.title;
import java.util.List;
import mobi.yoggy.erp.apps.action.ErpBaseAction;
import mobi.yoggy.erp.beans.AccountTitleMasterBean; import mobi.yoggy.erp.service.master.AccountTitleMasterService;public class AccountTitleMasterBaseAction extends ErpBaseAction {
private static final long serialVersionUID = 90081025402348836L;
protected List<AccountTitleMasterBean> accountTitleList;
protected AccountTitleMasterBean accountTitleMasterBean;
/**科目ID*/
protected String accountTitleId;/**科目名*/
protected String accountTitleName;/**貸借区分*/
protected String loanDiv;/**小口現金区分*/
protected String pettyCash;/**削除FLG */
protected String delFlg;/**
* getAccountTitleMasterService * * @return AccountTitleMasterService * @throws Exception */ protected AccountTitleMasterService getAccountTitleMasterService() throws Exception {return super.getErpServiceProvider().getAccountTitleMasterService();
}
protected AccountTitleMasterBean packAccountTitleMasterBean()
throws Exception {accountTitleMasterBean = new AccountTitleMasterBean();
accountTitleMasterBean.setAccountTitleId(accountTitleId); accountTitleMasterBean.setAccountTitleName(accountTitleName); accountTitleMasterBean.setLoanDiv(Integer.valueOf(loanDiv)); accountTitleMasterBean.setPettyCash(Integer.valueOf(pettyCash));return accountTitleMasterBean;
}protected void unpackAccountTitleMasterBean(
AccountTitleMasterBean accountTitleMasterBean) throws Exception {accountTitleId = accountTitleMasterBean.getAccountTitleId();
accountTitleName = accountTitleMasterBean.getAccountTitleName(); loanDiv = accountTitleMasterBean.getLoanDiv().toString(); pettyCash = accountTitleMasterBean.getPettyCash().toString();}
protected AccountTitleMasterBean getAccountTitleInformationById(
String accountTitleId) throws Exception { accountTitleMasterBean = this.getAccountTitleMasterService() .getAccountTitleMasterInformationById(accountTitleId); return accountTitleMasterBean; }public List<AccountTitleMasterBean> getAccountTitleList() {
return accountTitleList; }public void setAccountTitleList(
List<AccountTitleMasterBean> accountTitleList) { this.accountTitleList = accountTitleList; }public AccountTitleMasterBean getAccountTitleMasterBean() {
return accountTitleMasterBean; }public void setAccountTitleMasterBean(
AccountTitleMasterBean accountTitleMasterBean) { this.accountTitleMasterBean = accountTitleMasterBean; }public String getAccountTitleId() {
return accountTitleId; }public void setAccountTitleId(String accountTitleId) {
this.accountTitleId = accountTitleId; }public String getAccountTitleName() {
return accountTitleName; }public void setAccountTitleName(String accountTitleName) {
this.accountTitleName = accountTitleName; }public String getLoanDiv() {
return loanDiv; }public void setLoanDiv(String loanDiv) {
this.loanDiv = loanDiv; }public String getPettyCash() {
return pettyCash; }public void setPettyCash(String pettyCash) {
this.pettyCash = pettyCash; }public String getDelFlg() {
return delFlg; }public void setDelFlg(String delFlg) {
this.delFlg = delFlg; }public static long getSerialversionuid() {
return serialVersionUID; }}
################################
package mobi.yoggy.erp.apps.action.master.campaign;
import java.util.Collections;
import java.util.Iterator;import mobi.yoggy.erp.base.util.collection.CollectionUtil;
import mobi.yoggy.erp.base.util.string.StringUtil; import mobi.yoggy.erp.beans.CampaignDtlBean; import mobi.yoggy.erp.beans.CampaignStudioBean; import mobi.yoggy.erp.beans.StudioBean; import mobi.yoggy.erp.constant.status.CampaignMaster;@SuppressWarnings("serial")
public class CampaignMasterAddAction extends CampaignMasterBaseAction {public String add() throws Exception {
mode = EditStatus.ADD;
super.prepareSelectList();
// for addConfirm -> add
campaignStudioList = CollectionUtil.removeNull(campaignStudioList); campaignDtlList1 = CollectionUtil.removeNull(campaignDtlList1); campaignDtlList2 = CollectionUtil.removeNull(campaignDtlList2); campaignDtlList3 = CollectionUtil.removeNull(campaignDtlList3);initProductList(campaignDtlList1);
convertStr2Primitives(campaignDtlList1, campaignDtlList2,
campaignDtlList3); return SUCCESS; }public String ticketGroupCdChange() throws Exception {
ticketGroupMasterList = super.getErpServiceProvider()
.getTicketGroupMasterService().getTicketNameInDailySoldDetail( ticketGroupCd);return SUCCESS;
}@SuppressWarnings("unchecked")
public String addConfirm() throws Exception {mode = EditStatus.ADD;
// キャンペーン
if (null == campaignMaster) { return ERROR; }super.prepareSelectList();
// 対象スタジオ
campaignStudioList = CollectionUtil.removeNull(campaignStudioList);for (CampaignStudioBean campaignStudio : campaignStudioList) {
for (StudioBean studio : studioList) { if (studio.getCode().equalsIgnoreCase( campaignStudio.getStudioCd())) { campaignStudio.setStudioName(studio.getName()); break; } } } // 分類明細 campaignDtlList1 = CollectionUtil.removeNull(campaignDtlList1);Iterator<CampaignDtlBean> iterList1 = campaignDtlList1.iterator();
while (iterList1.hasNext()) {
CampaignDtlBean dtl = iterList1.next(); if (dtl == null) { iterList1.remove(); } else { if (StringUtil.isBlank(dtl.getLargeProductGroupCd()) && StringUtil.isBlank(dtl.getTargetUser())) { if (CampaignMaster.DiscountDiv.DISCOUNT_RATE.getValue().equals( dtl.getDiscountDivStr())) { if (StringUtil.isBlank(dtl.getDiscountRateStr())) { iterList1.remove(); } } else { if (StringUtil.isBlank(dtl.getDiscountPriceStr())) { iterList1.remove(); } } } } }// 商品明細
campaignDtlList2 = CollectionUtil.removeNull(campaignDtlList2); // 券種明細 campaignDtlList3 = CollectionUtil.removeNull(campaignDtlList3);for (CampaignDtlBean c : campaignDtlList1) {
// 中カテゴリis blank if (c.getMidiumProductGroupList() == null) { c.setMidiumProductGroupList(Collections.EMPTY_LIST); } // 小カテゴリis blank if (c.getSmallProductGroupList() == null) { c.setSmallProductGroupList(Collections.EMPTY_LIST); } }convertStr2Primitives(campaignDtlList1, campaignDtlList2,
campaignDtlList3); convertMemberType2Name(campaignDtlList1); convertMemberType2Name(campaignDtlList2); convertMemberType2Name(campaignDtlList3); // data_validation if (!super.validateParamsAdd()) { return INPUT; } return SUCCESS; }public String addCommit() throws Exception {
mode = EditStatus.ADD;
// judge the value of the hitFlg
super.checkHitFlg();// 対象スタジオ
campaignStudioList = CollectionUtil.removeNull(campaignStudioList); // 分類明細 campaignDtlList1 = CollectionUtil.removeNull(campaignDtlList1); // 商品明細 campaignDtlList2 = CollectionUtil.removeNull(campaignDtlList2); // 券種明細 campaignDtlList3 = CollectionUtil.removeNull(campaignDtlList3);// insert into the dataBase
super.getErpServiceProvider().getCampaignMasterService() .insertCampaignMasterByCondition(modifyCampaignMaster(true), campaignStudioList, campaignDtlList1, campaignDtlList2, campaignDtlList3);return SUCCESS;
}
}
######################################
转载地址:http://hjebi.baihongyu.com/