您的位置:首页 > 其它

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

2016-11-25 11:13 197 查看
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() >
4000
; 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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐