Showing
3 changed files
with
28 additions
and
11 deletions
| ... | @@ -32,7 +32,7 @@ public class ChmConsignmentDetail implements Serializable { | ... | @@ -32,7 +32,7 @@ public class ChmConsignmentDetail implements Serializable { |
| 32 | * 运单 | 32 | * 运单 |
| 33 | */ | 33 | */ |
| 34 | @ManyToOne(targetEntity = ChmConsignment.class) | 34 | @ManyToOne(targetEntity = ChmConsignment.class) |
| 35 | - @JoinColumn(name = "CONSIGNMENT_ID",updatable = false) | 35 | + @JoinColumn(name = "CONSIGNMENT_ID") |
| 36 | private ChmConsignment chmConsignment; | 36 | private ChmConsignment chmConsignment; |
| 37 | 37 | ||
| 38 | 38 | ... | ... |
| ... | @@ -150,4 +150,9 @@ public class ChmConsignmentDetailService { | ... | @@ -150,4 +150,9 @@ public class ChmConsignmentDetailService { |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | 152 | ||
| 153 | + public void deleteChmConsignmentDetailBatch(List<Long> idList){ | ||
| 154 | + chmConsignmentDetailRepository.deleteChmConsignmentDetailByChnConIdList(idList); | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + | ||
| 153 | } | 158 | } | ... | ... |
| ... | @@ -176,7 +176,7 @@ public class ChmConsignmentService { | ... | @@ -176,7 +176,7 @@ public class ChmConsignmentService { |
| 176 | result.setConsStatusDic(transferWaybillStatusDictionaryEntries); | 176 | result.setConsStatusDic(transferWaybillStatusDictionaryEntries); |
| 177 | result.setConsStatus(transferWaybillStatusDictionaryEntries.getChineseName()); | 177 | result.setConsStatus(transferWaybillStatusDictionaryEntries.getChineseName()); |
| 178 | //推送时间作为创建时间,可以用来校验数据的有序性,如果新的推送时间小于已有的创建时间,就不更新数据 | 178 | //推送时间作为创建时间,可以用来校验数据的有序性,如果新的推送时间小于已有的创建时间,就不更新数据 |
| 179 | - result.setCreateTime(pushTime); | 179 | + result.setCreateTime(new Date()); |
| 180 | result.setUpdateTime(pushTime); | 180 | result.setUpdateTime(pushTime); |
| 181 | 181 | ||
| 182 | 182 | ||
| ... | @@ -280,22 +280,34 @@ public class ChmConsignmentService { | ... | @@ -280,22 +280,34 @@ public class ChmConsignmentService { |
| 280 | //TODO 更新数据 | 280 | //TODO 更新数据 |
| 281 | log.info("更新主单"+ mawb.getBillNo()); | 281 | log.info("更新主单"+ mawb.getBillNo()); |
| 282 | 282 | ||
| 283 | - for(ChmConsignmentDetail newDetail:chmConsignment.getChmConsignmentDetailList()){ | 283 | + |
| 284 | - for(ChmConsignmentDetail oldDetail: chmConsignmentDB.getChmConsignmentDetailList()){ | 284 | + //由于订单明细中,无法确定唯一一条数据,所以无法做到update,只能先删除在插入 |
| 285 | - if(Objects.equals(newDetail.getSkuCode(),oldDetail.getSkuCode())){ | 285 | +// for(ChmConsignmentDetail newDetail:chmConsignment.getChmConsignmentDetailList()){ |
| 286 | - //newDetail.setChmConsignment(chmConsignmentDB); | 286 | +// for(ChmConsignmentDetail oldDetail: chmConsignmentDB.getChmConsignmentDetailList()){ |
| 287 | - newDetail.setId(oldDetail.getId()); | 287 | +// if(Objects.equals(newDetail.getSkuCode(),oldDetail.getSkuCode())){ |
| 288 | - } | 288 | +// //newDetail.setChmConsignment(chmConsignmentDB); |
| 289 | - } | 289 | +// newDetail.setId(oldDetail.getId()); |
| 290 | +// } | ||
| 291 | +// } | ||
| 292 | +// } | ||
| 293 | + List<Long> detailIdList = new ArrayList(); | ||
| 294 | + chmConsignmentDB.getChmConsignmentDetailList().forEach(detail->{ | ||
| 295 | + detailIdList.add(detail.getId()); | ||
| 296 | + }); | ||
| 297 | + if(detailIdList.size()>0){ | ||
| 298 | + chmConsignmentDetailService.deleteChmConsignmentDetailBatch(detailIdList); | ||
| 299 | + chmConsignmentDB.setChmConsignmentDetailList(null); | ||
| 290 | } | 300 | } |
| 291 | 301 | ||
| 302 | + | ||
| 303 | + | ||
| 292 | chmConsignment.setId(chmConsignmentDB.getId()); | 304 | chmConsignment.setId(chmConsignmentDB.getId()); |
| 293 | chmConsignment.setUpdateTime(pushTime); | 305 | chmConsignment.setUpdateTime(pushTime); |
| 294 | ChmConsignment updateResult = this.saveChmConsignment(chmConsignment); | 306 | ChmConsignment updateResult = this.saveChmConsignment(chmConsignment); |
| 295 | if(!Objects.equals(updateResult,null)){ | 307 | if(!Objects.equals(updateResult,null)){ |
| 296 | - log.info("主单"+ mawb.getBillNo()+" 保存成功,chmConsignmentId:"+updateResult.getId()); | 308 | + log.info("主单"+ mawb.getBillNo()+" 更新成功,chmConsignmentId:"+updateResult.getId()); |
| 297 | }else{ | 309 | }else{ |
| 298 | - log.info("主单"+ mawb.getBillNo()+" 保存失败"); | 310 | + log.info("主单"+ mawb.getBillNo()+" 更新失败"); |
| 299 | } | 311 | } |
| 300 | 312 | ||
| 301 | } | 313 | } | ... | ... |
-
Please register or login to post a comment