zengtx hace 2 años
padre
commit
ef2207f661

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/seclarationElements/entity/SyDeclarationElements.java

@@ -98,4 +98,7 @@ public class SyDeclarationElements {
 	/**子表集合*/
 	@TableField(exist = false)
 	List<SyDeclarationElementsItem> syDeclarationElementsItemList;
+	/**发运明细子表ID*/
+	@TableField(exist = false)
+	private String syShippingids;
 }

+ 94 - 42
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/seclarationElements/service/impl/SyDeclarationElementsServiceImpl.java

@@ -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;
     }
 }

+ 12 - 11
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/controller/SyShippingDetailsController.java

@@ -651,26 +651,27 @@ public class SyShippingDetailsController extends JeecgController<SyShippingDetai
 	 @AutoLog(value = "查询报关要素")
 	 @ApiOperation(value="查询报关要素", notes="查询报关要素")
 	 @GetMapping(value = "/queryDeclarationElements")
-  public Result<SyDeclarationElements> queryDeclarationElements(String inventoryName,String itemNumber,String account,
+  public Result<SyDeclarationElements> queryDeclarationElements(String id,String syShippingids,
 																HttpServletRequest request, HttpServletResponse response){
 
   	Result<SyDeclarationElements> result = new Result<SyDeclarationElements>();
 
-  	if(oConvertUtils.isEmpty(inventoryName) || oConvertUtils.isEmpty(itemNumber)) {
-		result.setMessage("存货名称、款号!未传值");
-		result.setSuccess(false);
-		return result;
-	}
-
   	     //查询报关要素主表
 		 QueryWrapper<SyDeclarationElements> queryWrapper = new QueryWrapper<SyDeclarationElements>();
-  	     queryWrapper.eq("inventory_name",inventoryName).eq("ac_set_no",account).eq("item_number",itemNumber).eq("del_flag",0);
+  	     queryWrapper.eq("id",id);
   	     List<SyDeclarationElements> syDeclarationElements = syDeclarationElementsService.list(queryWrapper);
 		 if(syDeclarationElements.size()==0){
+		 	 //查询发运明细获取款号,物料,账套
+			 String str[] = syShippingids.split(",");
+			 QueryWrapper<SyShippingDetailsItem> shiItemQuery = new QueryWrapper<>();
+			 shiItemQuery.eq("id", str[0]);
+			 List<SyShippingDetailsItem> shList = syShippingDetailsItemService.list(shiItemQuery);
+			 //获取第一条数据
+			 SyShippingDetailsItem zero = shList.get(0);
 			 SyDeclarationElements syDeclarationElementsEntityNull = new SyDeclarationElements();
-			 syDeclarationElementsEntityNull.setAcSetNo(account);
-			 syDeclarationElementsEntityNull.setItemNumber(itemNumber);
-			 syDeclarationElementsEntityNull.setInventoryName(inventoryName);
+			 syDeclarationElementsEntityNull.setAcSetNo(zero.getAccount());
+			 syDeclarationElementsEntityNull.setItemNumber(zero.getItemNumber());
+			 syDeclarationElementsEntityNull.setInventoryName(zero.getInventoryName());
 //			 syDeclarationElementsEntityNull.setEnglishProductName(entity.getEnglishProductName());
 //			 syDeclarationElementsEntityNull.setDeclarationName(entity.getDeclarationName());
 

+ 4 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/entity/SyShippingDetailsItem.java

@@ -338,4 +338,8 @@ public class SyShippingDetailsItem {
 	@Excel(name = "区分成衣跟面辅料", width = 15)
 	@ApiModelProperty(value = "区分成衣跟面辅料")
 	private String inventoryCcode;
+	/**报关要素主表ID*/
+	@Excel(name = "报关要素主表ID", width = 15)
+	@ApiModelProperty(value = "报关要素主表ID")
+	private String elementsId;
 }

+ 2 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/entity/VO/SyShippingDetailsVo.java

@@ -267,5 +267,6 @@ public class SyShippingDetailsVo {
 
     //0-面辅料/1-成衣
     private String flourOrGarment;
-
+    //报关要素主表ID
+    private String elementsId;
 }

+ 4 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/mapper/SyShippingDetailsMapper.java

@@ -47,5 +47,9 @@ public interface SyShippingDetailsMapper extends BaseMapper<SyShippingDetails> {
     //导出
     public IPage<SyShippingDetailsVo> exCelQuery(IPage<SyShippingDetailsVo> page, @Param("ew") QueryWrapper<SyShippingDetailsVo> queryWrapper);
 
+    //修改报关要素ID字段
+    public void updateElenmentId(@Param("elementsId") String elementsId,@Param("id") String id);
 
+    //回写报关要素ID字段
+    public void writeBackElenmentId(@Param("elementsId") String elementsId,@Param("id") List<String> id);
 }

+ 25 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/mapper/xml/SyShippingDetailsMapper.xml

@@ -63,7 +63,7 @@
     b.order_remarks as orderRemarks,b.price_remarks as priceRemarks,b.order_change_description as orderChangeDescription,b.pre_completion_date as preCompletionDate,
     b.sales_type_text as salesTypeText,b.customer_name as customerName,b.exchange_rate as exchangeRate,a.whole_order_total as wholeOrderTotal,
     b.declaration_elements as declarationElements,b.number_of_sets as numberOfSets,a.chinese_name as chineseName,a.account as account,
-    a.english_product_name as englishProductName,b.garment_factory as garmentFactory from sy_shipping_details a
+    a.english_product_name as englishProductName,b.garment_factory as garmentFactory,b.elements_id as elementsId from sy_shipping_details a
 left join sy_shipping_details_item b
 on a.id = b.shipping_details_id and b.del_flag = 0
 where a.del_flag = 0
@@ -91,11 +91,15 @@ ${ew.customSqlSegment}
     b.order_remarks as orderRemarks,b.price_remarks as priceRemarks,b.order_change_description as orderChangeDescription,b.pre_completion_date as preCompletionDate,
     b.sales_type_text as salesTypeText,b.customer_name as customerName,b.exchange_rate as exchangeRate,a.whole_order_total as wholeOrderTotal,
     b.declaration_elements as declarationElements,b.number_of_sets as numberOfSets,a.chinese_name as chineseName,a.account as account,
-    a.english_product_name as englishProductName,b.garment_factory as garmentFactory from sy_shipping_details a
+    a.english_product_name as englishProductName,b.garment_factory as garmentFactory,b.elements_id as elementsId from sy_shipping_details a
 left join sy_shipping_details_item b
 on a.id = b.shipping_details_id and b.del_flag = 0
 where a.del_flag = 0
   AND b.inventory_ccode not like '19%'
+GROUP BY a.document_no,
+b.order_number,b.customer_abbreviation,b.sales_department,b.salesman,a.account,b.pre_delivery_date,b.order_remarks,
+			  b.item_number,b.small_po,b.inventory_name,b.colour,b.distribution_point,b.pack_id,b.coding_rules
+
  order by a.document_no desc) as t
 ${ew.customSqlSegment}
 
@@ -189,4 +193,23 @@ where a.del_flag = 0  order by a.document_no desc) as t
 ${ew.customSqlSegment}
     </select>
 
+
+    <update id="updateElenmentId">
+        update sy_shipping_details_item b
+        left  join sy_shipping_details a
+        on b.shipping_details_id = a.id
+        set b.elements_id = #{elementsId}
+        where b.elements_id = #{id} and a.push_state = '0'
+    </update>
+
+    <update id="writeBackElenmentId">
+        update sy_shipping_details_item
+        set elements_id = #{elementsId}
+        where id in
+        <foreach collection="id" item="item"  open="(" separator="," close=")">
+            #{item}
+        </foreach>
+
+    </update>
+
 </mapper>

+ 4 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/service/ISyShippingDetailsService.java

@@ -56,5 +56,9 @@ public interface ISyShippingDetailsService extends IService<SyShippingDetails> {
     //额外维护款号、物料成分、是否做TC证书
     public int updateByTcNumberMaterial(String ids,String itemNumber,String materialComposition,String tc);
 
+    //修改报关要素ID字段
+    public void updateElenmentId(String elementsId,String id);
 
+    //回写报关要素ID字段
+    public void writeBackElenmentId(String elementsId,List<String> id);
 }

+ 41 - 33
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/service/impl/SyShippingDetailsServiceImpl.java

@@ -7,6 +7,8 @@ import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.documents.orderData.entity.SyOrderData;
 import org.jeecg.modules.documents.orderData.entity.SyOrderDataItem;
 import org.jeecg.modules.documents.orderData.service.impl.SyOrderDataItemServiceImpl;
+import org.jeecg.modules.documents.seclarationElements.entity.SyDeclarationElements;
+import org.jeecg.modules.documents.seclarationElements.service.ISyDeclarationElementsService;
 import org.jeecg.modules.documents.shippingDetails.entity.SyShippingDetails;
 import org.jeecg.modules.documents.shippingDetails.entity.SyShippingDetailsItem;
 import org.jeecg.modules.documents.shippingDetails.entity.VO.OrderDataVo;
@@ -45,6 +47,8 @@ public class SyShippingDetailsServiceImpl extends ServiceImpl<SyShippingDetailsM
     private SyShippingDetailsItemServiceImpl syShippingDetailsItemService;
     @Autowired
     private SyOrderDataItemServiceImpl syOrderDataItemService;
+    @Autowired
+    private ISyDeclarationElementsService syDeclarationElementsService;
 
 
     /**
@@ -98,12 +102,29 @@ public class SyShippingDetailsServiceImpl extends ServiceImpl<SyShippingDetailsM
                      orderDataItem.setSurplusNum(suerBox);
                      syOrderDataItemService.updateById(orderDataItem);
                  }
+
+                 //获取报关要素ID
+                 //根据条件查询报关要素信息
+              QueryWrapper<SyDeclarationElements> elementsQueryWrapper = new QueryWrapper<>();
+                 elementsQueryWrapper.eq("inventory_name",li.getInventoryName()).eq("ac_set_no",li.getAccount()).eq("item_number",li.getItemNumber()).eq("del_flag",0);
+                 elementsQueryWrapper.orderByDesc("create_time");
+                 List<SyDeclarationElements> elementsList = syDeclarationElementsService.list(elementsQueryWrapper);
+                 if(elementsList.size() != 0){
+                     //获取最新一条ID
+                     String elementId = elementsList.get(0).getId();
+                     li.setElementsId(elementId);
+                 }
+
              }
              if(syShippingDetailsItemList.size()!=0){
                  syShippingDetailsItemService.saveBatch(syShippingDetailsItemList);
              }
          }
 
+
+
+
+
         boolean ok = save(syShippingDetails);
         if(ok){
             return syShippingDetails;
@@ -138,39 +159,6 @@ public class SyShippingDetailsServiceImpl extends ServiceImpl<SyShippingDetailsM
         }
         //获取子表信息
         List<SyShippingDetailsItem> list = entity.getSyShippingDetailsItemList();
-//        //查询原数据子表信息
-//        QueryWrapper<SyShippingDetailsItem> queryWrapper = new QueryWrapper<>();
-//        queryWrapper.eq("shipping_details_id",id).eq("del_flag",0);
-//        List<SyShippingDetailsItem> itemList = syShippingDetailsItemService.list(queryWrapper);
-//        if(itemList.size()!=0){
-//            //把修改的数据赋值给原来的数据
-//            for (SyShippingDetailsItem item :itemList){
-//                for(SyShippingDetailsItem li :list){
-//                    if(item.getId().equals(li.getId())){
-//
-//                    }
-//                }
-//
-//            }
-//            //重新给子表集合赋值
-//            entity.setSyShippingDetailsItemList(itemList);
-//        }
-//        //回写销售订单剩余数量
-//        for (SyShippingDetailsItem li:list) {
-//            SyOrderDataItem orderDataItem = syOrderDataItemService.getById(li.getSyOrderDataItemId());
-//            if (oConvertUtils.isNotEmpty(orderDataItem)) {
-//                BigDecimal suerBox = orderDataItem.getSurplusNum().subtract(li.getShipmentQuantity());
-//                orderDataItem.setSurplusNum(suerBox);
-//                syOrderDataItemService.updateById(orderDataItem);
-//            }
-//        }
-//        //删除子表
-//        syShippingDetailsMapper.syshippingDetailsItemUpdate(id);
-//        //删除主表
-//        syShippingDetailsEntity.setDelFlag("1");
-//        updateById(syShippingDetailsEntity);
-//        //新增
-//        syShippingDetailsAdd(entity);
 
         for(SyShippingDetailsItem li :list){
             //查询订单子表信息
@@ -324,4 +312,24 @@ public class SyShippingDetailsServiceImpl extends ServiceImpl<SyShippingDetailsM
         return i;
     }
 
+    /**
+     * 修改报关要素ID字段
+     * @param elementsId
+     * @param id
+     */
+    @Override
+    public void updateElenmentId(String elementsId, String id) {
+        syShippingDetailsMapper.updateElenmentId(elementsId, id);
+    }
+
+    /**
+     * 回写报关要素ID字段
+     * @param elementsId
+     * @param id
+     */
+    @Override
+    public void writeBackElenmentId(String elementsId, List<String> id) {
+        syShippingDetailsMapper.writeBackElenmentId(elementsId, id);
+    }
+
 }

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/service/impl/PurchaseWarehousingServiceImpl.java

@@ -202,6 +202,7 @@ public class PurchaseWarehousingServiceImpl extends ServiceImpl<PurchaseWarehous
                             if(map.get("cMaker")==null||map.get("cMaker").equals("")){
                                 throw new RuntimeException("缺少制单人字段");
                             }
+                            map.put("cMaker","云工厂管理员");
                             map.put("cHandler",map.get("cMaker"));
                         }
                     }else{
@@ -212,6 +213,7 @@ public class PurchaseWarehousingServiceImpl extends ServiceImpl<PurchaseWarehous
                     if(map.get("cMaker")==null||map.get("cMaker").equals("")){
                         throw new RuntimeException("缺少制单人字段");
                     }
+                    map.put("cMaker","云工厂管理员");
                     map.put("cHandler",map.get("cMaker"));
                 }