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;
}