公司-->保存时验证数据是否保存重复

js内容:

//提交校验,如果article,工段,部门一致则不能进行保存
function checkSave(){
	var primaryId=$("#primaryId").val();
	var articleId=$("#hidden_articleId").val();
	var sectionId=$("#sectionId").val();
	var departmentId=$("#departmentId").val();
	var isok=true;
	$.ajax({
		type : "post",
		url : contentPath + "/ajax/checkSpecialProductionPHSetArticleAndSectionAndDepartmentExist.do",
		data : {
			articleId : articleId,
			sectionId : sectionId,
			departmentId : departmentId,
			primaryId : primaryId
		},
		async : false,
		success : function(data) {
			if (data == 'true') {
				alertE('当前已经存在相同的Article,工段,部门的记录,不能保存,请检查.');
				isok = false;
			}
		}
	});
	return isok;
}


action内容:

package gts.erp.action.ajax;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.oletech.triangle.component.FormBean;

import gts.erp.action.base.ERPProxyAction;

public class CheckSpecialProductionPHSetArticleAndSectionAndDepartmentExistAction extends ERPProxyAction {

	@Override
	protected ActionForward doExecute(FormBean parameterFB, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		FormBean formBean = this.getERPServiceDelegation().getMasterProductionScheduleService().checkSpecialProductionPHSetArticleAndSectionAndDepartmentExist(parameterFB);
		
		String isExist = formBean.getCellBeanValue("isExist");
		
		PrintWriter pw = response.getWriter();
		pw.print(isExist);
		pw.flush();
		return null;
	}

}


impl内容:

/** 
	 * 判断article,工段,部门是否重复添加 
	 * @author zhuyz 
	 * @date 2016年11月19日17:48:16
	 * @param dataBean
	 * 			FormBean => key : "parameterFB"
	 *          	 CellBean key : primaryId,articleId,sectionId,departmentId
	 * @return FormBean
	 *          TableBean => key : "TN_PMC_PH_SETUP"
	 *         		        CellBean key : CN_ID,CR_ARTICLE_ID, CR_SECTION_ID, CN_LEADTIME, CN_PMC_PH_QTY,CR_DEPARTMENT_ID......
	 */
	public FormBean checkSpecialProductionPHSetArticleAndSectionAndDepartmentExist(FormBean formBean) {
		FormBean returnFB = new FormBean();
		String primaryId = formBean.getCellBeanValue("primaryId");
		String articleId = formBean.getCellBeanValue("articleId");
		String sectionId = formBean.getCellBeanValue("sectionId");
		String departmentId = formBean.getCellBeanValue("departmentId");
		String isExist = "false";
		try {
			if (StringUtils.isNotBlank(articleId) && StringUtils.isNotBlank(sectionId) && StringUtils.isNotBlank(departmentId)) {
				//查询数据库,如果存在三个条件都相同的数据,禁止添加
				CondSetBean csbPhSetup = new CondSetBeanJustAnd();
				csbPhSetup.addCondBean(new CondBeanEqual("CR_ARTICLE_ID", articleId));
				csbPhSetup.addCondBean(new CondBeanEqual("CR_SECTION_ID", sectionId));
				csbPhSetup.addCondBean(new CondBeanEqual("CR_DEPARTMENT_ID", departmentId));
				if (StringUtils.isNotEmpty(primaryId)) {
					csbPhSetup.addCondBean(new CondBeanNotEqual(TriangleDefinition.COLUMN_NAME_CN_ID, primaryId));
				}
				TableBean pmcPhSetupTB = this.baseDAO.queryForTableBean(new ClassPOJO("TN_PMC_PH_SETUP"), csbPhSetup);
				if (pmcPhSetupTB.size() > 0) {
					isExist = "true";
				}
			}
			returnFB.addCellBean(new CellBean("isExist", isExist));
		} catch (Exception e) {
			TriangleBLHelper.printExceptionLog(log, e);
			e.printStackTrace();
			throw new RuntimeException("**** Run time Exception!****");
		}
		return returnFB;
	}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值