2020-05-27 16:42
@JFinal 代码有点多。。。贴上来了,就是前端页面点击一个提交按钮就传数据过来,然后下面这个方法去执行,现在问题就是当前端页面有很多人一起点击提交数据执行下面这个方法的时候会有些人的提交数据没有保存。想问下有没有什么办法出来这种并发问题。
public void savexspj() {
try {
float df=0F;
String pjcs = getPara("pjcs");
String [] jxpjxDm=getPara("gpjxDm").split(",");
String text1 = getPara("text1");
String text2 = getPara("text2");
// System.out.println(text1);
String rydm = getPara("rydm");
String cprylbdm = getPara("cprylbdm");
String [] pddjdm = getPara("pddjdm").split(",");
Date date = new Date();
DateFormat df2 = DateFormat.getDateTimeInstance();//可以精确到时分秒
Record xl =Db.use("szxy").findFirst("select * from t_dm_gy_xl where zf_bj='0' and KS_SJ<'"+df2.format(date)+"' and JS_SJ>'"+df2.format(date)+"'");
Record ry = (Record)getSession().getAttribute("CurUser");
Record list1=Db.use("szxy").findFirst("select * from t_pj_jxpjx where zf_bj='0' and JXPJX_DM='"+jxpjxDm[0]+"'");
for(int i=0;i Record r = Db.use("szxy").findFirst("select * from t_pj_gpjzb where zf_bj=0 and XL_DM='"+xl.getStr("XL_DM")+"' and JXPJX_DM='"+jxpjxDm[i]+"' and RY_DM='"+rydm+"' and LRR='"+ry.getStr("RY_DM")+"' and CPRYLB_DM='"+cprylbdm+"'and PJCS='"+pjcs+"'");
Record qzlist =Db.use("szxy").findFirst("select * from t_pj_xkjxpj where zf_bj='0' and JXPJX_DM='"+jxpjxDm[i]+"'");
Record fzlist =Db.use("szxy").findFirst("select * from t_pj_djxpj where zf_bj='0' and JXPJX_DM='"+list1.getStr("JXPJFJD_DM")+"' and PDDJ_DM='"+pddjdm[i]+"' ");
Float qz = qzlist.getFloat("QZ");
Float fz = fzlist.getFloat("FZ");
df+=fz*qz;
if (r==null) {
getModel(PjGpjzb.class,"item").set("GPJZB_DM", UUIDUtil.getUUID()).set("XL_DM", xl.get("XL_DM")).set("PJCS", pjcs)
.set("JXPJX_DM", jxpjxDm[i]).set("RY_DM", rydm).set("PDDJ_DM", pddjdm[i]).set("CPRYLB_DM", cprylbdm)
.set("CJ_SJ", new Date()).set("ZF_BJ", "0").set("XG_SJ", new Date())
.set("LRR", ry != null ? ry.get("RY_DM") : "").save();;
}else {
String str = r.getStr("GPJZB_DM");
Db.use("szxy").update("update t_pj_gpjzb set PDDJ_DM='"+pddjdm[i]+"' where GPJZB_DM='"+str+"' and zf_bj=0 and XL_DM='"+xl.get("XL_DM")+"'");
}
}
Record pjdf = Db.use("szxy").findFirst("SELECT * from t_pj_pjdf where JXPJX_DM='"+list1.getStr("JXPJFJD_DM")+"' and ZF_BJ='0' and XL_DM='"+xl.get("XL_DM")+"' and BPJRY_DM='"+rydm+"' and PJRY_DM='"+ry.getStr("RY_DM")+"' and CPRYLB_DM='"+cprylbdm+"'and PJCS='"+pjcs+"'");
if (pjdf==null) {
if(text1==null){
new PjPjdf().set("JXPJX_DM", list1.getStr("JXPJFJD_DM")).set("BPJRY_DM", rydm).set("PJCS", pjcs)
.set("DF", df).set("XL_DM", xl.get("XL_DM")).set("CPRYLB_DM", cprylbdm)
.set("PJDF_DM", UUIDUtil.getUUID()).set("CJ_SJ", new Date())
.set("ZF_BJ", "0").set("XG_SJ", new Date()).set("PJRY_DM", ry.get("RY_DM")).save();
}else{
new PjPjdf().set("JXPJX_DM", list1.getStr("JXPJFJD_DM")).set("BPJRY_DM", rydm).set("PJCS", pjcs)
.set("DF", df).set("XL_DM", xl.get("XL_DM")).set("CPRYLB_DM", cprylbdm)
.set("JXBZ", text1).set("JXJY", text2)
.set("PJDF_DM", UUIDUtil.getUUID()).set("CJ_SJ", new Date())
.set("ZF_BJ", "0").set("XG_SJ", new Date()).set("PJRY_DM", ry.get("RY_DM")).save();
}
}else {
String pjdfdm = pjdf.getStr("PJDF_DM");
if(text1==null){
Db.use("szxy").update("update t_pj_pjdf set DF='"+df+"' where PJDF_DM='"+pjdfdm+"' and XL_DM='"+xl.get("XL_DM")+"'");
}else{
Db.use("szxy").update("update t_pj_pjdf set DF='"+df+"',JXBZ='"+text1+"',JXJY='"+text2+"' where PJDF_DM='"+pjdfdm+"' and XL_DM='"+xl.get("XL_DM")+"'");
}
}
} catch (Exception e) {
e.printStackTrace();
renderText("error");
}
renderText("success");
} 删除 回复