博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
一对多关联的两张表,确定关联属性
阅读量:7102 次
发布时间:2019-06-28

本文共 1405 字,大约阅读时间需要 4 分钟。

hot3.png

 

说明:对于一对多关联的两张表(a --> b 是1 --> n),根据b表的某个属性来确定a表的相关属性

示例:header --> details(1 --> n),根据detailsLineStatus来确定headerStatus 

public void updateHeaderStatus(Header header) {         //查询明细        DetailsSearch search = new DetailsSearch();        search.setHeaderNo(header.getHeaderNo());        List
list = detailsMapper.find(search); //数量临时变量 int countMax = 0;//最大状态的单据行的个数 int countAll = list.size();//单据行数 String statusMax = Consts.ASN_STATUS_00;//初始化最大状态 //遍历所有明细 for (Details d : list) { //统计状态个数 String detailsLineStatus = d.getDetailsLineStatus(); if (statusMax.compareTo(detailsLineStatus) == 0) { countMax++; } if (statusMax.compareTo(detailsLineStatus) < 0) { statusMax = detailsLineStatus; countMax = 1; } } //计算头状态 String headerStatus = null; if (countAll == countMax) {//所有明细相同状态 headerStatus = statusMax; } else {//明细状态各不相同 if (v1.equals(statusMax)) {//明细某一完全状态 asnStatus = 'v1降一级';//设置头部为某一非完全状态 } else {//其他状态 headerStatus = statusMax; } } header.setHeaderStatus(headerStatus); headerMapper.updateByPrimaryKeySelective(header);}

 

转载于:https://my.oschina.net/u/3496297/blog/1590407

你可能感兴趣的文章
MyEclipse6.5GA
查看>>
SMO未来的营销市场在哪?
查看>>
谈谈自己对技术的看法
查看>>
tomcat7中配置c3p0数据库连接池
查看>>
我的友情链接
查看>>
Hibernate的二级缓存
查看>>
ElasticSearch中文分词插件安装
查看>>
centos 不能使用scp命令 解决方法
查看>>
没有Wscript.shell组件提权我们该怎么办呢
查看>>
【技术帖】Apache Kylin 高级设置:联合维度(Joint Dimension)原理解析
查看>>
centos 最小化安装静态IP设置
查看>>
MUI-页面传值2种形式
查看>>
Exchange 2007 的邮件监控器
查看>>
通过TFTP恢复路由器IOS
查看>>
多设备适配
查看>>
read/readline/readlines的用法简介
查看>>
直方图增强 车辆检测
查看>>
SQL学习之分离与附加数据库
查看>>
正则表达式之原始字符串
查看>>
设计模式 博客
查看>>