Browse Source

材料出库单

chenc 2 năm trước cách đây
mục cha
commit
30741fb17a

+ 2 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/config/InterfaceConnUtils.java

@@ -15,12 +15,13 @@ import org.apache.http.client.config.RequestConfig.Builder;
 import javax.xml.bind.DatatypeConverter;
 import java.io.UnsupportedEncodingException;
 
+//U8第三方接口调用
 public class InterfaceConnUtils {
     public static JSONArray doPost(JSONArray json, String url) {
         //定义测试返回JSON
         JSONArray onejb = new JSONArray();
         HttpClient httpClient = new DefaultHttpClient();
-        HttpPost httpPost=new HttpPost(url);
+        HttpPost httpPost=new HttpPost("http://192.168.1.103:8087/api/U8Server/"+url);
         httpPost.setHeader("Content-Type", "application/json");
         String tokenCode = "sap:Cwa1QJrhfhtXbzSGZi94ydBPNQCPbmz7";
         //使用base64进行加密

+ 106 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/controller/PurchaseWarehousingController.java

@@ -9,9 +9,11 @@ import javax.servlet.http.HttpServletResponse;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.lang.StringUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.system.vo.DictModel;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.config.transactional.DbTxConstants;
 import org.jeecg.config.transactional.MultiTransactional;
@@ -22,6 +24,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.modules.system.service.ISysDictService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -50,6 +53,9 @@ import io.swagger.annotations.ApiOperation;
 public class PurchaseWarehousingController extends JeecgController<PurchaseWarehousing, IPurchaseWarehousingService> {
 	@Autowired
 	private IPurchaseWarehousingService purchaseWarehousingService;
+
+	@Autowired
+	private ISysDictService sysDictService;
 	
 	/**
 	 * 分页列表查询
@@ -195,13 +201,28 @@ public class PurchaseWarehousingController extends JeecgController<PurchaseWareh
                   }
               }
               if(mapListOne.size()>0){
-                  purchaseWarehousingService.savaOne(mapListOne);
+				  //获取账套
+				  String caccId=sysDictService.queryDictTextByKey("cAccID", "1");
+				  if(StringUtils.isNotBlank(caccId)){
+					  result.error500("未获取到账套");
+				  }
+                  purchaseWarehousingService.savaOne(mapListOne,caccId);
               }
               if(mapListTwo.size()>0){
-                  purchaseWarehousingService.savaTwo(mapListTwo);
+				  //获取账套
+				  String caccId=sysDictService.queryDictTextByKey("cAccID", "2");
+				  if(StringUtils.isNotBlank(caccId)){
+					  result.error500("未获取到账套");
+				  }
+                  purchaseWarehousingService.savaTwo(mapListTwo,caccId);
               }
               if(mapListThree.size()>0){
-                  purchaseWarehousingService.savaThree(mapListThree);
+				  //获取账套
+				  String caccId=sysDictService.queryDictTextByKey("cAccID", "3");
+				  if(StringUtils.isNotBlank(caccId)){
+					  result.error500("未获取到账套");
+				  }
+                  purchaseWarehousingService.savaThree(mapListThree,caccId);
               }
               result.success("操作成功");
           }else{
@@ -228,4 +249,86 @@ public class PurchaseWarehousingController extends JeecgController<PurchaseWareh
 	  return data;
   }
 
+  @PostMapping(value = "/saveMaterialIssueDoc")
+  public Result saveMaterialIssueDoc(@RequestBody JSONArray json){
+	  Result result=new Result();
+
+	  try {
+		  if(json!=null&&json.size()>0){
+			  //账套1
+			  List<Map<String,Object>> mapListOne=new ArrayList<>();
+			  //账套2
+			  List<Map<String,Object>> mapListTwo=new ArrayList<>();
+			  //账套3
+			  List<Map<String,Object>> mapListThree=new ArrayList<>();
+			  for(int i=0;i<json.size();i++){
+				  //获取对象
+				  JSONObject jsonObject=json.getJSONObject(i);
+				  //获取账套
+				  String cAccId=jsonObject.get("cAccId").toString();
+				  //转map
+				  Map<String,Object> map=updateMap(jsonObject);
+				  if(cAccId.equals("101")){
+					  mapListOne.add(map);
+				  }else if(cAccId.equals("102")){
+					  mapListTwo.add(map);
+				  }else if(cAccId.equals("103")){
+					  mapListThree.add(map);
+				  }
+			  }
+			  //查询字典配置-获取U8错误信息验证配置
+			  List<DictModel> ls = sysDictService.getDictItems("pda_setting");
+			  String isMaterialIssueDoc="";//是否启用U8错误验证返回成功结果集
+			  if (ls !=null && ls.size()>0) {
+				  for(DictModel d:ls){
+					  if(d.getText().equals("saveMaterialIssueDoc")){
+						  isMaterialIssueDoc=d.getValue();
+					  }
+				  }
+			  }else{
+				  throw new RuntimeException("字典Code格式不正确!");
+			  }
+			  String message="";//错误信息
+			  if(mapListOne.size()>0){
+			  		//获取账套
+				  String caccId=sysDictService.queryDictTextByKey("cAccID", "1");
+				  if(StringUtils.isNotBlank(caccId)){
+					  result.error500("未获取到账套");
+				  }
+				  message=message+purchaseWarehousingService.saveMaterialIssueDocOne(mapListOne,caccId,isMaterialIssueDoc);
+			  }
+			  if(mapListTwo.size()>0){
+				  //获取账套
+				  String caccId=sysDictService.queryDictTextByKey("cAccID", "2");
+				  if(StringUtils.isNotBlank(caccId)){
+					  result.error500("未获取到账套");
+				  }
+				  message=message+purchaseWarehousingService.saveMaterialIssueDocTwo(mapListTwo,caccId,isMaterialIssueDoc);
+			  }
+			  if(mapListThree.size()>0){
+				  //获取账套
+				  String caccId=sysDictService.queryDictTextByKey("cAccID", "3");
+				  if(StringUtils.isNotBlank(caccId)){
+					  result.error500("未获取到账套");
+				  }
+				  message=message+purchaseWarehousingService.saveMaterialIssueDocThree(mapListThree,caccId,isMaterialIssueDoc);
+			  }
+			  result.setSuccess(true);
+			  if(StringUtils.isNotBlank(message)){
+				  result.setMessage("错误信息:"+message);
+			  }else{
+				  result.setMessage("操作成功");
+			  }
+
+		  }else{
+			  result.error500("未获取到正确的json");
+		  }
+	  } catch (Exception e) {
+		  e.printStackTrace();
+		  result.error500("操作失败:"+e.getMessage());
+	  }
+
+	  return result;
+  }
+
 }

+ 16 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/mapper/PurchaseWarehousingMapper.java

@@ -67,13 +67,21 @@ public interface PurchaseWarehousingMapper extends BaseMapper<PurchaseWarehousin
 
     /**
      * @Author chenchuang
-     * @Description //TODO 根据供应商编码查询成品仓和原材料仓库
+     * @Description //TODO 根据云工厂编码查询成品仓和原材料仓库
      * @Date 2022/4/14 16:35
      * @Param [cVenCode]
      * @return java.util.Map<java.lang.String,java.lang.Object>
      */
     Map<String,Object> getWhCodeByVenCode(@Param("cVenCode")String cVenCode);
 
+    /**
+     * @Author chenchuang
+     * @Description //TODO 根据供应商编码查询成品仓和原材料仓库
+     * @Date 2022/4/14 16:35
+     * @Param [cVenCode]
+     * @return java.util.Map<java.lang.String,java.lang.Object>
+     */
+    Map<String,Object> getVenCode(@Param("cVenCode")String cVenCode);
     /**
      * @Author chenchuang
      * @Description //TODO 新增调拨单主表
@@ -283,6 +291,13 @@ public interface PurchaseWarehousingMapper extends BaseMapper<PurchaseWarehousin
      */
     List<Map<String,Object>> getOM_MOMaterials(@Param("map")Map<String,Object> map);
 
+    /**
+     * 根据存货编码与母件id获取委外订单子件数据
+     * @param map
+     * @return
+     */
+    List<Map<String,Object>> getOM_MOMaterialsByMoIdAndCinvcode(@Param("map")Map<String,Object> map);
+
     /**
      * 回写调拨数量到委外子件
      */

+ 10 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/mapper/xml/PurchaseWarehousingMapper.xml

@@ -329,6 +329,10 @@
         select cVenCode,cVenDefine1,cVenDefine2,cVenAbbName,cVenDefine3 from Vendor where cVenDefine3=#{cVenCode}
     </select>
 
+    <select id="getVenCode" parameterType="java.lang.String" resultType="java.util.HashMap">
+        select cVenCode,cVenDefine1,cVenDefine2,cVenAbbName,cVenDefine3 from Vendor where cVenCode=#{cVenCode}
+    </select>
+
     <select id="getRdrecords01WriteQuantity" resultType="java.math.BigDecimal" parameterType="java.lang.String">
         SELECT SUM
                    ( rs.iQuantity ) - SUM ( rs.iSumBillQuantity ) as iQuantity
@@ -1002,6 +1006,12 @@
            AND isnull(cFree10,'') = #{map.cFree10}
     </select>
 
+    <select id="getOM_MOMaterialsByMoIdAndCinvcode" resultType="java.util.HashMap" parameterType="java.util.HashMap">
+        select * from OM_MOMaterials where
+        MoDetailsID = #{map.MoDetailsID}
+        and cInvCode = #{map.cInvCode}
+    </select>
+
     <update id="updateOM_MOMaterialsfTransQty" parameterType="java.util.HashMap">
         update OM_MOMaterials set fTransQty=#{map.fTransQty} where MOMaterialsID=#{map.MOMaterialsID}
     </update>

+ 30 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/service/IPurchaseWarehousingService.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.openApi.service;
 
+import com.alibaba.fastjson.JSONArray;
 import org.jeecg.modules.openApi.entity.PurchaseWarehousing;
 import com.baomidou.mybatisplus.extension.service.IService;
 
@@ -14,15 +15,41 @@ import java.util.Map;
  */
 public interface IPurchaseWarehousingService extends IService<PurchaseWarehousing> {
 
-    void savaOne(List<Map<String,Object>> mapList);
+    void savaOne(List<Map<String,Object>> mapList,String caccId);
 
-    void savaTwo(List<Map<String,Object>> mapList);
+    void savaTwo(List<Map<String,Object>> mapList,String caccId);
 
-    void savaThree(List<Map<String,Object>> mapList);
+    void savaThree(List<Map<String,Object>> mapList,String caccId);
 
 
     String getMaxId(String id,String tableName);
 
+    /**
+    * @Author chenchuang
+    * @Description //TODO 新增材料出库单(账套1)
+    * @Date 2022/6/8 15:51
+    * @Param [mapList]
+    * @return void
+    */
+    String saveMaterialIssueDocOne(List<Map<String,Object>> mapList,String caccId,String isMaterialIssueDoc);
+
+    /**
+    * @Author chenchuang
+    * @Description //TODO 新增材料出库单(账套2)
+    * @Date 2022/6/8 15:51
+    * @Param [mapList]
+    * @return void
+    */
+    String saveMaterialIssueDocTwo(List<Map<String,Object>> mapList,String caccId,String isMaterialIssueDoc);
+
+    /**
+    * @Author chenchuang
+    * @Description //TODO 新增材料出库单(账套3)
+    * @Date 2022/6/8 15:51
+    * @Param [mapList]
+    * @return void
+    */
+    String saveMaterialIssueDocThree(List<Map<String,Object>> mapList,String caccId,String isMaterialIssueDoc);
 
 
 }

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

@@ -4,12 +4,14 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import org.apache.commons.lang.StringUtils;
+import org.jeecg.common.system.vo.DictModel;
 import org.jeecg.config.InterfaceConnUtils;
 import org.jeecg.modules.openApi.entity.PurchaseWarehousing;
 import org.jeecg.modules.openApi.mapper.PurchaseWarehousingMapper;
 import org.jeecg.modules.openApi.mapper.SubcontractingOrderMapper;
 import org.jeecg.modules.openApi.service.IPurchaseWarehousingService;
 import org.jeecg.modules.system.entity.SysUser;
+import org.jeecg.modules.system.service.ISysDictService;
 import org.jeecg.modules.system.service.ISysUserService;
 import org.jeecg.modules.system.util.oConvertUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -41,22 +43,25 @@ public class PurchaseWarehousingServiceImpl extends ServiceImpl<PurchaseWarehous
     @Autowired
     private SubcontractingOrderMapper subcontractingOrderMapper;
 
+    @Autowired
+    private ISysDictService sysDictService;
+
     @DS("multi-one")
     @Override
-    public void savaOne(List<Map<String, Object>> mapList) {
-        save(mapList,"901");
+    public void savaOne(List<Map<String, Object>> mapList,String caccId) {
+        save(mapList,caccId);
     }
 
     @DS("multi-two")
     @Override
-    public void savaTwo(List<Map<String, Object>> mapList) {
-        save(mapList,"902");
+    public void savaTwo(List<Map<String, Object>> mapList,String caccId) {
+        save(mapList,caccId);
     }
 
     @DS("multi-three")
     @Override
-    public void savaThree(List<Map<String, Object>> mapList) {
-        save(mapList,"903");
+    public void savaThree(List<Map<String, Object>> mapList,String caccId) {
+        save(mapList,caccId);
     }
 
     //获取最大表id
@@ -372,7 +377,7 @@ public class PurchaseWarehousingServiceImpl extends ServiceImpl<PurchaseWarehous
 //                this.baseMapper.saveRdRecord01One(map); //主表新增
 
                 //由于前期是自己插入U8数据库 后前改变方式先择调用第三方插入接口 所以需要把字段名整体转换成第三方的
-                JSONArray resturn =InterfaceConnUtils.doPost(saveRdRecord01JSON(map,itemList,accID),"http://192.168.1.103:8087/api/U8Server/purchaseinlist_batch_get");
+                JSONArray resturn =InterfaceConnUtils.doPost(saveRdRecord01JSON(map,itemList,accID),"purchaseinlist_batch_get");
                 if(resturn.getJSONObject(0).get("Result").equals("T")){
                     //成功
                     //调拨单
@@ -458,9 +463,15 @@ public class PurchaseWarehousingServiceImpl extends ServiceImpl<PurchaseWarehous
         saveItemJson.put("CFREE8",m.get("cFree8"));
         saveItemJson.put("CFREE9",m.get("cFree9"));
         saveItemJson.put("CFREE10",m.get("cFree10"));
-        saveItemJson.put("CBATCHPROPERTY2",m.get("cBatchProperty2"));
-        saveItemJson.put("CBATCHPROPERTY8",m.get("cBatchProperty8"));
-        saveItemJson.put("CBATCHPROPERTY9",m.get("cBatchProperty9"));
+        if(m.get("cBatchProperty1")!=null){
+            saveItemJson.put("CBATCHPROPERTY1",m.get("cBatchProperty1"));
+        }
+        if(m.get("cBatchProperty2")!=null){
+            saveItemJson.put("CBATCHPROPERTY2",m.get("cBatchProperty2"));
+        }
+        if(m.get("cBatchProperty3")!=null){
+            saveItemJson.put("CBATCHPROPERTY9",m.get("cBatchProperty9"));
+        }
     }
 
     //回写现存量
@@ -517,24 +528,32 @@ public class PurchaseWarehousingServiceImpl extends ServiceImpl<PurchaseWarehous
         BigDecimal iTaxPrice=getDecimalNew(String.valueOf(mapOMMODetails.get("iTaxPrice")));//原币含税单价
         BigDecimal iExchRate=getDecimalNew(String.valueOf(map.get("iExchRate")));//汇率
         BigDecimal unitPriceIncludingTax=iTaxPrice.multiply(iExchRate);//含税单价
-        itemMap.put("cBatchProperty2",unitPriceIncludingTax.doubleValue());//含税单价
-        itemMap.put("cBatchProperty8",map.get("cOrderCode"));//订单号
-        itemMap.put("cBatchProperty9",map.get("cVenAbbName"));//供应商
-        List<Map<String,Object>> listmap=this.baseMapper.getAA_BatchPropertyCount(itemMap);
-        //判断是否查询到数据
-        if(listmap!=null&&listmap.size()>0){
-            //修改
-            if(listmap.size()==1){
-                itemMap.put("cBatchPropertyGUID",listmap.get(0).get("cBatchPropertyGUID"));//ID
-                this.baseMapper.updateAA_BatchPropertyByID(itemMap);
-            }else{
-                message=message+"存货:"+itemMap.get("cInvCode").toString()+"在AA_BatchProperty找到了多条记录";
-            }
+//        itemMap.put("cBatchProperty2",unitPriceIncludingTax.doubleValue());//含税单价
+//        itemMap.put("cBatchProperty8",map.get("cOrderCode"));//订单号
+//        itemMap.put("cBatchProperty9",map.get("cVenAbbName"));//供应商
+        itemMap.put("cBatchProperty1",unitPriceIncludingTax.doubleValue());//含税单价
+        if(itemMap.get("cFree4")!=null&&String.valueOf(itemMap.get("cFree4")).equals("/")){
+            itemMap.put("cBatchProperty2",itemMap.get("cDefine23"));//门幅
         }else{
-            //新增
-            itemMap.put("cBatchPropertyGUID",UUID.randomUUID().toString());//ID
-            this.baseMapper.saveAA_BatchProperty(itemMap);
+            itemMap.put("cBatchProperty2",itemMap.get("cFree4"));//门幅
         }
+
+        itemMap.put("cBatchProperty9",map.get("cVenAbbName")+":"+map.get("cOrderCode"));//供应商
+        List<Map<String,Object>> listmap=this.baseMapper.getAA_BatchPropertyCount(itemMap);
+        //判断是否查询到数据
+//        if(listmap!=null&&listmap.size()>0){
+//            //修改
+//            if(listmap.size()==1){
+//                itemMap.put("cBatchPropertyGUID",listmap.get(0).get("cBatchPropertyGUID"));//ID
+//                this.baseMapper.updateAA_BatchPropertyByID(itemMap);
+//            }else{
+//                message=message+"存货:"+itemMap.get("cInvCode").toString()+"在AA_BatchProperty找到了多条记录";
+//            }
+//        }else{
+//            //新增
+//            itemMap.put("cBatchPropertyGUID",UUID.randomUUID().toString());//ID
+//            this.baseMapper.saveAA_BatchProperty(itemMap);
+//        }
         return message;
     }
 
@@ -588,9 +607,12 @@ public class PurchaseWarehousingServiceImpl extends ServiceImpl<PurchaseWarehous
 
     //获取批次属性赋值
     public void getcBatchProperty(Map<String,Object> itemMap,Map<String,Object> map){
-        itemMap.put("cBatchProperty2",map.get("cBatchProperty2"));//含税单价
-        itemMap.put("cBatchProperty8",map.get("cBatchProperty8"));//订单号
-        itemMap.put("cBatchProperty9",map.get("cBatchProperty9"));//供应商
+//        itemMap.put("cBatchProperty2",map.get("cBatchProperty2"));//含税单价
+//        itemMap.put("cBatchProperty8",map.get("cBatchProperty8"));//订单号
+//        itemMap.put("cBatchProperty9",map.get("cBatchProperty9"));//供应商
+        itemMap.put("cBatchProperty1",map.get("cBatchProperty1"));//采购单价/含税单价
+        itemMap.put("cBatchProperty2",map.get("cBatchProperty2"));//门幅
+        itemMap.put("cBatchProperty9",map.get("cBatchProperty9"));//供应商:订单号
     }
 
     public Object setNull(Object o){
@@ -781,7 +803,7 @@ public class PurchaseWarehousingServiceImpl extends ServiceImpl<PurchaseWarehous
 
         }
         //由于前期是自己插入U8数据库 后前改变方式先择调用第三方插入接口 所以需要把字段名整体转换成第三方的
-        JSONArray resturn =InterfaceConnUtils.doPost(saveTransVouchJSON(transVouchMao,transVouchsList,accID),"http://192.168.1.103:8087/api/U8Server/transvouch_import");
+        JSONArray resturn =InterfaceConnUtils.doPost(saveTransVouchJSON(transVouchMao,transVouchsList,accID),"transvouch_import");
         if(resturn.getJSONObject(0).get("Result").equals("T")){
             //成功
 //            String tvCode=resturn.getJSONObject(0).get("U8ReceiptNo")+"";//调拨单号
@@ -940,6 +962,156 @@ public class PurchaseWarehousingServiceImpl extends ServiceImpl<PurchaseWarehous
         return maxId;
     }
 
+    @DS("multi-one")
+    @Override
+    public String saveMaterialIssueDocOne(List<Map<String,Object>> mapList,String caccId,String isMaterialIssueDoc) {
+        return saveMaterialIssueDoc(mapList,caccId,isMaterialIssueDoc);
+    }
+
+    @DS("multi-two")
+    @Override
+    public String saveMaterialIssueDocTwo(List<Map<String,Object>> mapList,String caccId,String isMaterialIssueDoc) {
+        return saveMaterialIssueDoc(mapList,caccId,isMaterialIssueDoc);
+    }
+
+    @DS("multi-three")
+    @Override
+    public String saveMaterialIssueDocThree(List<Map<String,Object>> mapList,String caccId,String isMaterialIssueDoc) {
+        return saveMaterialIssueDoc(mapList,caccId,isMaterialIssueDoc);
+    }
+
+
+    //插入材料出库单
+    public String saveMaterialIssueDoc(List<Map<String,Object>> mapList,String accId,String isMaterialIssueDoc){
+        String message="";
+        if(mapList!=null&&mapList.size()>0){
+            for(Map<String,Object> map:mapList){
+                map.put("CACCID",accId);//账套
+                map.put("CVOUCHCODE",map.get("CORDERCODE"));//单号
+                //获取汇率、币种
+                //根据订单号获取委外订单
+                Map<String,Object> OM_MOmainMap=this.baseMapper.getOM_MOmainBycCode(String.valueOf(map.get("CORDERCODE")));
+                if(OM_MOmainMap!=null){
+                    map.put("CPERSONCODE",OM_MOmainMap.get("cPersonCode"));//业务员编码
+                    map.put("IEXCHRATE",getDecimalNew(String.valueOf(OM_MOmainMap.get("nflat"))).doubleValue());//汇率
+                    map.put("CEXCH_NAME",OM_MOmainMap.get("cexch_name"));//币种名称
+                    map.put("CDEPCODE",OM_MOmainMap.get("cDepCode"));//部门编码
+                    //根据供应商获取原材料仓库
+                    String cVenCode=String.valueOf(OM_MOmainMap.get("cVenCode"));//供应商编码
+                    if(StringUtils.isNotBlank(cVenCode)){
+                        Map<String,Object> whCodeMap= this.baseMapper.getVenCode(cVenCode);
+                        if(whCodeMap!=null){
+                            //获取供应商简称
+//                            map.put("cVenAbbName",whCodeMap.get("cVenAbbName"));
+                            //获取原材料仓
+                            if(whCodeMap.get("cVenDefine1")!=null){
+                                String cWhCode=String.valueOf(whCodeMap.get("cVenDefine1"));//原材料仓
+                                map.put("CWHCODE",cWhCode);
+                            }else{
+                                throw new RuntimeException("未找到供应商的原材料仓库");
+                            }
+                        }else{
+                            throw new RuntimeException("未找到供应商");
+                        }
+
+                    }else{
+                        throw new RuntimeException("未找到订单的供应商");
+                    }
+                    map.put("CMEMO",OM_MOmainMap.get("cMemo"));//备注
+                    map.put("CMAKER","陈创");
+                    map.put("CHANDLER","陈创");
+                }else{
+                    throw new RuntimeException("委外订单没有匹配的订单号");
+                }
+                //子表
+                List<Map<String,Object>> itemMapList=(List<Map<String,Object>>)map.get("DETAILList");
+                if(itemMapList!=null&&itemMapList.size()>0){
+                    Integer rowId=1;
+                    for(Map<String,Object> itemMap:itemMapList){
+//                            String moDetailId=String.valueOf(itemMap.get("moDetailId"));//委外订单明细id
+                            //获取子件行
+                            List<Map<String,Object>> OM_MOMaterialsList= this.baseMapper.getOM_MOMaterials(itemMap);
+                            if(OM_MOMaterialsList!=null&&OM_MOMaterialsList.size()>0){
+                                if(OM_MOMaterialsList.size()==1){
+                                    //获取订单的自定义数据
+                                    getcFree(itemMap, OM_MOMaterialsList.get(0));
+                                    itemMap.put("AUTOID_PO",OM_MOMaterialsList.get(0).get("MOMaterialsID"));//委外订单自件id
+                                    itemMap.put("ALLCAUTOIDCOL","MOMaterialsID");//子件id字段名
+                                }else{
+                                    throw new RuntimeException("第"+rowId+"行找到多个对应委外订单子件行");
+                                }
+                            }else{
+                                throw new RuntimeException("第"+rowId+"行未找到对应委外订单子件行");
+                            }
+                        rowId++;
+                    }
+                }
+
+            }
+
+            //处理第三方json
+            JSONArray resturn =InterfaceConnUtils.doPost(saveMaterialIssueDocJSON(mapList,accId),"materialout_import");
+            if(resturn.getJSONObject(0).get("Result").equals("T")){
+                //成功
+            }else{//失败
+                //判断是否起启用逻辑
+                if(StringUtils.isNotBlank(isMaterialIssueDoc)&&isMaterialIssueDoc.equals("1")){
+                    //如果启用则返回错误信息,接口返回成功结果
+                    message=message+resturn.getJSONObject(0).get("Description");
+                }else{//如果未启用正常报错,返回错误信息,接口返回失败结果
+                    //失败
+                    throw new RuntimeException(resturn.getJSONObject(0).get("Description")+"");
+                }
+            }
+        }
+        return message;
+    }
+
+    //处理第三方接口要的json
+    public JSONArray saveMaterialIssueDocJSON(List<Map<String,Object>> mapList,String accID){
+        JSONArray jsonArraySave=new JSONArray();
+        if(mapList!=null&&mapList.size()>0){
+            for(Map<String,Object> map:mapList){
+                //主表
+                JSONObject saveJson=new JSONObject();
+                saveJson.put("CACCID",accID);
+                saveJson.put("CVOUCHCODE",map.get("CVOUCHCODE"));
+                saveJson.put("CBUSTYPE",map.get("CBUSTYPE"));
+                saveJson.put("DDATE",map.get("DDATE"));
+                saveJson.put("CPERSONCODE",map.get("CPERSONCODE"));
+                saveJson.put("CEXCH_NAME",map.get("CEXCH_NAME"));
+                saveJson.put("CDEPCODE",map.get("CDEPCODE"));
+                saveJson.put("CWHCODE",map.get("CWHCODE"));
+                saveJson.put("CRDCODE",map.get("CRDCODE"));
+                saveJson.put("IEXCHRATE",map.get("IEXCHRATE"));
+                saveJson.put("CMEMO",map.get("CMEMO"));
+                saveJson.put("CMAKER",map.get("CMAKER"));
+                saveJson.put("CHANDLER",map.get("CHANDLER"));
+                List<Map<String,Object>> itemMapList=(List<Map<String,Object>>)map.get("DETAILList");
+                //子表
+                if(itemMapList!=null&&itemMapList.size()>0){
+                    JSONArray itemJsonArray=new JSONArray();
+                    for(Map<String,Object> m:itemMapList){
+                        JSONObject saveItemJson=new JSONObject();
+                        saveItemJson.put("CINVCODE",m.get("CINVCODE"));
+                        saveItemJson.put("IQUNTITY",m.get("IQUNTITY"));
+                        saveItemJson.put("CBATCH",m.get("CBATCH"));
+                        saveItemJson.put("AUTOID_PO",m.get("AUTOID_PO"));
+                        saveItemJson.put("ALLCAUTOIDCOL",m.get("ALLCAUTOIDCOL"));
+                        //获取自定义项 自由项 批次项
+                        getCDEFINEJson(saveItemJson,m);
+                        itemJsonArray.add(saveItemJson);
+                    }
+                    saveJson.put("DETAILList",itemJsonArray);
+                }
+                jsonArraySave.add(saveJson);
+            }
+        }
+        System.out.println("材料出库单json:"+jsonArraySave.toString());
+        return jsonArraySave;
+
+    }
+
 
 //    public void save(List<Map<String, Object>> mapList,String accID){
 //        if(mapList!=null&&mapList.size()>0){