|  | @@ -7,6 +7,9 @@ import org.jeecg.modules.documents.seclarationElements.entity.SyDeclarationEleme
 | 
	
		
			
				|  |  |  import org.jeecg.modules.documents.seclarationElements.mapper.SyDeclarationElementsMapper;
 | 
	
		
			
				|  |  |  import org.jeecg.modules.documents.seclarationElements.service.ISyDeclarationElementsItemService;
 | 
	
		
			
				|  |  |  import org.jeecg.modules.documents.seclarationElements.service.ISyDeclarationElementsService;
 | 
	
		
			
				|  |  | +import org.jeecg.modules.documents.shippingDetails.entity.SyShippingDetailsItem;
 | 
	
		
			
				|  |  | +import org.jeecg.modules.documents.shippingDetails.service.ISyShippingDetailsItemService;
 | 
	
		
			
				|  |  | +import org.jeecg.modules.documents.shippingDetails.service.ISyShippingDetailsService;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -27,6 +30,10 @@ public class SyDeclarationElementsServiceImpl extends ServiceImpl<SyDeclarationE
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private ISyDeclarationElementsItemService syDeclarationElementsItemService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private ISyShippingDetailsItemService syShippingDetailsItemService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private ISyShippingDetailsService syShippingDetailsService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 新增(发运明细调用)
 | 
	
	
		
			
				|  | @@ -35,55 +42,100 @@ public class SyDeclarationElementsServiceImpl extends ServiceImpl<SyDeclarationE
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public SyDeclarationElements syDeclarationElementsAdd(SyDeclarationElements syDeclarationElements) {
 | 
	
		
			
				|  |  | -        //用于修改新增的集合
 | 
	
		
			
				|  |  | -        List<SyDeclarationElementsItem> syDeclarationElementsItemListUpdate = new ArrayList<SyDeclarationElementsItem>();
 | 
	
		
			
				|  |  | -        //查询是否有数据
 | 
	
		
			
				|  |  | -        String ids = syDeclarationElements.getId();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        if(oConvertUtils.isEmpty(ids)){ //新增
 | 
	
		
			
				|  |  | -                String id = oConvertUtils.id();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                List<SyDeclarationElementsItem> syDeclarationElementsItemList = new ArrayList<SyDeclarationElementsItem>();
 | 
	
		
			
				|  |  | -                //设置ID
 | 
	
		
			
				|  |  | -                syDeclarationElements.setId(id);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                List<SyDeclarationElementsItem> list = syDeclarationElements.getSyDeclarationElementsItemList();
 | 
	
		
			
				|  |  | -                for (SyDeclarationElementsItem item:list){
 | 
	
		
			
				|  |  | -                    item.setId(oConvertUtils.id());
 | 
	
		
			
				|  |  | -                    item.setSyDeclarationElementsId(id);
 | 
	
		
			
				|  |  | -                    syDeclarationElementsItemList.add(item);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                if(syDeclarationElementsItemList.size()!=0){
 | 
	
		
			
				|  |  | -                    syDeclarationElementsItemService.saveBatch(syDeclarationElementsItemList);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                boolean ok = save(syDeclarationElements);
 | 
	
		
			
				|  |  | -                if(ok){
 | 
	
		
			
				|  |  | -                    return syDeclarationElements;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            }else{ //修改
 | 
	
		
			
				|  |  | +        //子表集合
 | 
	
		
			
				|  |  | +        List<SyDeclarationElementsItem> syDeclarationElementsItemList = new ArrayList<SyDeclarationElementsItem>();
 | 
	
		
			
				|  |  | +//        //用于修改新增的集合
 | 
	
		
			
				|  |  | +//        List<SyDeclarationElementsItem> syDeclarationElementsItemListUpdate = new ArrayList<SyDeclarationElementsItem>();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -             //删除子表
 | 
	
		
			
				|  |  | -            QueryWrapper<SyDeclarationElementsItem> queryWrapperItem = new QueryWrapper<SyDeclarationElementsItem>();
 | 
	
		
			
				|  |  | -            queryWrapperItem.eq("sy_declaration_elements_id", ids).eq("del_flag", 0);
 | 
	
		
			
				|  |  | -            List<SyDeclarationElementsItem> syDeclarationElementsItemsList = syDeclarationElementsItemService.list(queryWrapperItem);
 | 
	
		
			
				|  |  | -            for(SyDeclarationElementsItem li:syDeclarationElementsItemsList){
 | 
	
		
			
				|  |  | -                li.setDelFlag("1");
 | 
	
		
			
				|  |  | +            //获取发运明细子表ID
 | 
	
		
			
				|  |  | +            String ids = syDeclarationElements.getSyShippingids();
 | 
	
		
			
				|  |  | +            String elementid = syDeclarationElements.getId();
 | 
	
		
			
				|  |  | +            List<String> shippingList = new ArrayList<>();
 | 
	
		
			
				|  |  | +            String shSplit[] = ids.split(",");
 | 
	
		
			
				|  |  | +            for (String s : shSplit) {
 | 
	
		
			
				|  |  | +                shippingList.add(s);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            syDeclarationElementsItemService.updateBatchById(syDeclarationElementsItemsList);
 | 
	
		
			
				|  |  | +            String id = oConvertUtils.id();
 | 
	
		
			
				|  |  | +            //查询发运明细
 | 
	
		
			
				|  |  | +            QueryWrapper<SyShippingDetailsItem> shiItemQuery = new QueryWrapper<>();
 | 
	
		
			
				|  |  | +            shiItemQuery.in("id", shippingList);
 | 
	
		
			
				|  |  | +            List<SyShippingDetailsItem> shList = syShippingDetailsItemService.list(shiItemQuery);
 | 
	
		
			
				|  |  | +            //获取第一条数据
 | 
	
		
			
				|  |  | +            SyShippingDetailsItem zero = shList.get(0);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            syDeclarationElements.setId(id);
 | 
	
		
			
				|  |  | +            syDeclarationElements.setInventoryCode(zero.getInventoryCode());
 | 
	
		
			
				|  |  | +            syDeclarationElements.setAcSetNo(zero.getAccount());
 | 
	
		
			
				|  |  | +            syDeclarationElements.setItemNumber(zero.getItemNumber());
 | 
	
		
			
				|  |  | +            syDeclarationElements.setInventoryName(zero.getInventoryName());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            //新增
 | 
	
		
			
				|  |  |              List<SyDeclarationElementsItem> list = syDeclarationElements.getSyDeclarationElementsItemList();
 | 
	
		
			
				|  |  | -            for (SyDeclarationElementsItem item:list){
 | 
	
		
			
				|  |  | +            for (SyDeclarationElementsItem item : list) {
 | 
	
		
			
				|  |  |                  item.setId(oConvertUtils.id());
 | 
	
		
			
				|  |  | -                item.setSyDeclarationElementsId(syDeclarationElements.getId());
 | 
	
		
			
				|  |  | -                syDeclarationElementsItemListUpdate.add(item);
 | 
	
		
			
				|  |  | +                item.setSyDeclarationElementsId(id);
 | 
	
		
			
				|  |  | +                syDeclarationElementsItemList.add(item);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (syDeclarationElementsItemList.size() != 0) {
 | 
	
		
			
				|  |  | +                syDeclarationElementsItemService.saveBatch(syDeclarationElementsItemList);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            if(syDeclarationElementsItemListUpdate.size()!=0){
 | 
	
		
			
				|  |  | -                syDeclarationElementsItemService.saveBatch(syDeclarationElementsItemListUpdate);
 | 
	
		
			
				|  |  | +            //修改发运明细报关要素ID
 | 
	
		
			
				|  |  | +            if(oConvertUtils.isNotEmpty(elementid)){
 | 
	
		
			
				|  |  | +                syShippingDetailsService.updateElenmentId(id,elementid);
 | 
	
		
			
				|  |  | +            }else{
 | 
	
		
			
				|  |  | +                syShippingDetailsService.writeBackElenmentId(id,shippingList);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            boolean ok = save(syDeclarationElements);
 | 
	
		
			
				|  |  | +            if (ok) {
 | 
	
		
			
				|  |  | +                return syDeclarationElements;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +//        if(oConvertUtils.isEmpty(elemengid)){ //新增
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//                //设置ID
 | 
	
		
			
				|  |  | +//                syDeclarationElements.setId(id);
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//                List<SyDeclarationElementsItem> list = syDeclarationElements.getSyDeclarationElementsItemList();
 | 
	
		
			
				|  |  | +//                for (SyDeclarationElementsItem item:list){
 | 
	
		
			
				|  |  | +//                    item.setId(oConvertUtils.id());
 | 
	
		
			
				|  |  | +//                    item.setSyDeclarationElementsId(id);
 | 
	
		
			
				|  |  | +//                    syDeclarationElementsItemList.add(item);
 | 
	
		
			
				|  |  | +//                }
 | 
	
		
			
				|  |  | +//                if(syDeclarationElementsItemList.size()!=0){
 | 
	
		
			
				|  |  | +//                    syDeclarationElementsItemService.saveBatch(syDeclarationElementsItemList);
 | 
	
		
			
				|  |  | +//                }
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//                boolean ok = save(syDeclarationElements);
 | 
	
		
			
				|  |  | +//                if(ok){
 | 
	
		
			
				|  |  | +//                    return syDeclarationElements;
 | 
	
		
			
				|  |  | +//                }
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//            }else{ //修改
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//             //删除子表
 | 
	
		
			
				|  |  | +//            QueryWrapper<SyDeclarationElementsItem> queryWrapperItem = new QueryWrapper<SyDeclarationElementsItem>();
 | 
	
		
			
				|  |  | +//            queryWrapperItem.eq("sy_declaration_elements_id", ids).eq("del_flag", 0);
 | 
	
		
			
				|  |  | +//            List<SyDeclarationElementsItem> syDeclarationElementsItemsList = syDeclarationElementsItemService.list(queryWrapperItem);
 | 
	
		
			
				|  |  | +//            for(SyDeclarationElementsItem li:syDeclarationElementsItemsList){
 | 
	
		
			
				|  |  | +//                li.setDelFlag("1");
 | 
	
		
			
				|  |  | +//            }
 | 
	
		
			
				|  |  | +//            syDeclarationElementsItemService.updateBatchById(syDeclarationElementsItemsList);
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//            //新增
 | 
	
		
			
				|  |  | +//            List<SyDeclarationElementsItem> list = syDeclarationElements.getSyDeclarationElementsItemList();
 | 
	
		
			
				|  |  | +//            for (SyDeclarationElementsItem item:list){
 | 
	
		
			
				|  |  | +//                item.setId(oConvertUtils.id());
 | 
	
		
			
				|  |  | +//                item.setSyDeclarationElementsId(syDeclarationElements.getId());
 | 
	
		
			
				|  |  | +//                syDeclarationElementsItemListUpdate.add(item);
 | 
	
		
			
				|  |  | +//            }
 | 
	
		
			
				|  |  | +//            if(syDeclarationElementsItemListUpdate.size()!=0){
 | 
	
		
			
				|  |  | +//                syDeclarationElementsItemService.saveBatch(syDeclarationElementsItemListUpdate);
 | 
	
		
			
				|  |  | +//            }
 | 
	
		
			
				|  |  | +//        }
 | 
	
		
			
				|  |  |          return syDeclarationElements;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 |