mybatis 的动态脚本实现循环更新

  • 我今天介绍一种循环更新的方式:从前端到后台的一整套流程实现循环更新:
  • 后台更新代码:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    <update id="updateLoopSign" parameterType="java.util.List"> 
    <foreach collection="list" item="item" separator=";" open="begin" close=";end;">
    update HM_YW_TJJCXM A set ZZJB00 = decode((select count(*)
    from HM_YW_JCXMTZ
    where TJH000 = A.TJH000
    and JCID00 = A.JCID00
    and nvl(ZZJB00, '0') != 0),
    0,
    0,
    1),
    TZCMS0 = #{item.tzcms0},
    SZJG00 = '', JCTZC0 = SF_HM_GetTZC(JCID00)
    where TJH000 = ${item.tjh000}
    and JCID00 = ${item.jcid00}
    and not exists (select 1
    from HM_YW_TJFKJC
    where TJH000 = A.TJH000
    and BMBH00 = A.BMBH00
    and KSSH00 = '1')
    </foreach>
    </update>
  • 中间层我就不赘述了,没啥太大价值的代码

  • 主要好玩的就是前端利用js获取表格的每一行数据,并且封装成list的实体类传给后台,这个过程需要对数据格式化,并且后台数据的参数需要加上@RequestBody的注解,我在这个过程中踩了很多的坑
  • 我觉的最好玩的就是通过数组来后台转化为好玩的list集合
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
var pphysicalExamNo = $("#tjh000").val();
var deptNo=$("#dqks").find("option:selected").val();
var littleConclution = $("#xj").val();
//遍历检查结果 和 检查id
var trs = $('#sqtable tbody').find('tr');
//获取值
var hmywtjjcxms =new Array();
trs.each(function(){

var hmywtjjcxm ={};
//获取每行的id值
hmywtjjcxm.tzcms0=$(this).find("input[type='text']").val();
hmywtjjcxm.jcid00=$(this).find("input[type='text']").attr('jcid00');
hmywtjjcxm.tjh000=$("#tjh000").val();
hmywtjjcxms.push(hmywtjjcxm);

});
var result=JSON.stringify(hmywtjjcxms);
$.ajax(
{
type:'POST',
url:'${ctx}departmentExaminationController/checkIt',
async: false,
dataType:'json',
contentType:'application/json',
data:result,
success: function(data){
//更新 小结
var ksxj00 = $("#xj").val();
var ksys00=$("#ys").attr("ysid");
var lrzid0 =getEmployeeId();
var bmbh00=$("#dqks").find("option:selected").val();
var pphysicalExamNo = $("#tjh000").val();
$.post("${ctx}departmentExaminationController/checkIt1",
{"ksxj00":ksxj00,"bmbh00":deptNo,"tjh000":pphysicalExamNo,"ksys00":ksys00},
function(data){
var writeIn=$("#lry").attr("lryid");
var doctor=$("#ys").attr("ysid");
var bmbh00=$("#dqks").find("option:selected").val();
var tjh000=$("#tjh000").val();
//执行审核
$.post(
"${ctx}departmentExaminationController/checkIt2",
{"PTJH000":tjh000,"PLRZID0":writeIn,"PKSYS00":doctor,"PBMBH00":bmbh00,"POPFLAG":1},
function(data){
$("#control").val(1);
$("#control").prop("disabled",true);
$(".edit-tzcms0").prop("disabled",true);
$("#xj").prop("disabled",true);
getConclution(tjh000,bmbh00);
//$("#shsh").val(new data());
alert(data.msg);

}
);
}
);
}


}
);
  • 通过验证发现 springmvc对于传递json的对象转换过程仅仅可以传递对象类型仅为json格式的数据,其他的数据是不可以传递进去的
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
@PostMapping("/saveResult")
@ResponseBody
public ResultMsg saveResult(@RequestBody List<HmYwTjjcxm> list) {
// System.out.println(list);
// List<HmYwTjjcxm> subList = list.subList(0, 2);
for (HmYwTjjcxm hmYwTjjcxm : list) {
String tzcms0 = hmYwTjjcxm.getTzcms0();
if ("".equals(tzcms0)) {
continue;
}
boolean numeric = isNumeric(tzcms0);
if (numeric) {
BigDecimal bd = new BigDecimal(tzcms0);
hmYwTjjcxm.setSzjg00(bd);

}


}

des.updateLoopSign(list);
return ResultMsg.ok();




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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值