| 
														
															@@ -5,18 +5,18 @@ import cn.hnthyy.thmz.entity.jy.ResultVo; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import cn.hnthyy.thmz.entity.yb.DrugTracCodg; 
														 | 
														
														 | 
														
															 import cn.hnthyy.thmz.entity.yb.DrugTracCodg; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import cn.hnthyy.thmz.entity.yb.SelinfoSold; 
														 | 
														
														 | 
														
															 import cn.hnthyy.thmz.entity.yb.SelinfoSold; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import cn.hnthyy.thmz.entity.yb.SelinfoReturn; 
														 | 
														
														 | 
														
															 import cn.hnthyy.thmz.entity.yb.SelinfoReturn; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import cn.hnthyy.thmz.mapper.his.yb.SelinfoSoldMapper; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import cn.hnthyy.thmz.service.taobao.TaobaoService; 
														 | 
														
														 | 
														
															 import cn.hnthyy.thmz.service.taobao.TaobaoService; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.alibaba.fastjson.JSONArray; 
														 | 
														
														 | 
														
															 import com.alibaba.fastjson.JSONArray; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.alibaba.fastjson.JSONObject; 
														 | 
														
														 | 
														
															 import com.alibaba.fastjson.JSONObject; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import com.alibaba.fastjson.serializer.SerializerFeature; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import lombok.extern.slf4j.Slf4j; 
														 | 
														
														 | 
														
															 import lombok.extern.slf4j.Slf4j; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.beans.factory.annotation.Autowired; 
														 | 
														
														 | 
														
															 import org.springframework.beans.factory.annotation.Autowired; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.beans.factory.annotation.Value; 
														 | 
														
														 | 
														
															 import org.springframework.beans.factory.annotation.Value; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.stereotype.Service; 
														 | 
														
														 | 
														
															 import org.springframework.stereotype.Service; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import java.text.SimpleDateFormat; 
														 | 
														
														 | 
														
															 import java.text.SimpleDateFormat; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-import java.util.Date; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-import java.util.List; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-import java.util.Random; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import java.util.*; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 @Slf4j 
														 | 
														
														 | 
														
															 @Slf4j 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 @Service 
														 | 
														
														 | 
														
															 @Service 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -28,15 +28,19 @@ public class YbService { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     @Autowired 
														 | 
														
														 | 
														
															     @Autowired 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     private TaobaoService taobaoService; 
														 | 
														
														 | 
														
															     private TaobaoService taobaoService; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    @Autowired 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    private SelinfoSoldMapper selinfoSoldMapper; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     public ResultVo saleGoodsItem(SelinfoSold selInfo) { 
														 | 
														
														 | 
														
															     public ResultVo saleGoodsItem(SelinfoSold selInfo) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         ResultVo response = null; 
														 | 
														
														 | 
														
															         ResultVo response = null; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        selInfo.setMdtrtSn("MDTRT_ID"); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         List<DrugTracCodg> drugTracCodgList = selInfo.getDrugtracinfo(); 
														 | 
														
														 | 
														
															         List<DrugTracCodg> drugTracCodgList = selInfo.getDrugtracinfo(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         if(drugTracCodgList == null || drugTracCodgList.isEmpty()) { 
														 | 
														
														 | 
														
															         if(drugTracCodgList == null || drugTracCodgList.isEmpty()) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             response = new ResultVo(-1, "追溯码不能为空"); 
														 | 
														
														 | 
														
															             response = new ResultVo(-1, "追溯码不能为空"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             return response; 
														 | 
														
														 | 
														
															             return response; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        String result = taobaoService.sendGet("/queryCodeDetail?codes=" + drugTracCodgList.get(0)); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        String drugTracCodg = drugTracCodgList.get(0).getDrugTracCodg(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        String result = taobaoService.sendGet("/queryCodeDetail?codes=" + drugTracCodg); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         JSONObject resultJson = JSONObject.parseObject(result); 
														 | 
														
														 | 
														
															         JSONObject resultJson = JSONObject.parseObject(result); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         Integer code = resultJson.getInteger("code"); 
														 | 
														
														 | 
														
															         Integer code = resultJson.getInteger("code"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         if (code == 200) { 
														 | 
														
														 | 
														
															         if (code == 200) { 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -57,18 +61,22 @@ public class YbService { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         int randomNumber = new Random().nextInt(90) + 10; 
														 | 
														
														 | 
														
															         int randomNumber = new Random().nextInt(90) + 10; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         String rtalDocno = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); 
														 | 
														
														 | 
														
															         String rtalDocno = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if("1".equals(selInfo.getMdtrtSetlType())) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            selInfo.setMdtrtSn("MDTRT_ID"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            selInfo.setMdtrtSn(rtalDocno + randomNumber); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         selInfo.setRtalDocno(rtalDocno + randomNumber); 
														 | 
														
														 | 
														
															         selInfo.setRtalDocno(rtalDocno + randomNumber); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         selInfo.setFixmedinsBchno(rtalDocno + randomNumber); 
														 | 
														
														 | 
														
															         selInfo.setFixmedinsBchno(rtalDocno + randomNumber); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         selInfo.setSelRetnCnt(drugTracCodgList.size()); 
														 | 
														
														 | 
														
															         selInfo.setSelRetnCnt(drugTracCodgList.size()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         String now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); 
														 | 
														
														 | 
														
															         String now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         selInfo.setSelRetnTime(now); 
														 | 
														
														 | 
														
															         selInfo.setSelRetnTime(now); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        selInfo.setSelRetnOpterName(""); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        selInfo.setMdtrtSetlType("1"); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         String realUrl = siInventoryServiceUrl + "/saleGoodsItem"; 
														 | 
														
														 | 
														
															         String realUrl = siInventoryServiceUrl + "/saleGoodsItem"; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         try { 
														 | 
														
														 | 
														
															         try { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            String ybResult = HttpUtil.sendHttpPost(realUrl, JSONObject.toJSONString(selInfo), 8000); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            String jsonString = JSONObject.toJSONString(selInfo, SerializerFeature.WriteNonStringKeyAsString); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            String ybResult = HttpUtil.sendHttpPost(realUrl, jsonString, 8000); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             JSONObject ybResultJson = JSONObject.parseObject(ybResult); 
														 | 
														
														 | 
														
															             JSONObject ybResultJson = JSONObject.parseObject(ybResult); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             int responseCode = 0; 
														 | 
														
														 | 
														
															             int responseCode = 0; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             if(ybResultJson.getInteger("code") != 200) { 
														 | 
														
														 | 
														
															             if(ybResultJson.getInteger("code") != 200) { 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -79,13 +87,43 @@ public class YbService { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             e.printStackTrace(); 
														 | 
														
														 | 
														
															             e.printStackTrace(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             response = new ResultVo(-1, "商品销售失败"); 
														 | 
														
														 | 
														
															             response = new ResultVo(-1, "商品销售失败"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        String id = UUID.randomUUID().toString().replaceAll("-", ""); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        selInfo.setId(id); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        int insertSelinfo = selinfoSoldMapper.insert(selInfo); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if(insertSelinfo > 0) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            for(DrugTracCodg codg : drugTracCodgList) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                String itemId = UUID.randomUUID().toString().replaceAll("-", ""); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                selinfoSoldMapper.insertSelinfoSoldDrugtrac(itemId, id, codg.getDrugTracCodg()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         return response; 
														 | 
														
														 | 
														
															         return response; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     public ResultVo returnGoodsItem(SelinfoReturn selinfoReturn) { 
														 | 
														
														 | 
														
															     public ResultVo returnGoodsItem(SelinfoReturn selinfoReturn) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         ResultVo response = null; 
														 | 
														
														 | 
														
															         ResultVo response = null; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        List<DrugTracCodg> drugTracCodgList = selinfoReturn.getDrugtracinfo(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        selinfoReturn.setSelRetnCnt(drugTracCodgList.size()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        String now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        selinfoReturn.setSelRetnTime(now); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         selinfoReturn.setMdtrtSn("MDTRT_ID"); 
														 | 
														
														 | 
														
															         selinfoReturn.setMdtrtSn("MDTRT_ID"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        String realUrl = siInventoryServiceUrl + "/returnGoodsItem"; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        try { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            String jsonString = JSONObject.toJSONString(selinfoReturn, SerializerFeature.WriteNonStringKeyAsString); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            String ybResult = HttpUtil.sendHttpPost(realUrl, jsonString, 8000); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            JSONObject ybResultJson = JSONObject.parseObject(ybResult); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            int responseCode = 0; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if(ybResultJson.getInteger("code") != 200) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                responseCode = ybResultJson.getInteger("code"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            response = new ResultVo(responseCode, ybResultJson.getString("message")); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } catch (Exception e) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            e.printStackTrace(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            response = new ResultVo(-1, "商品销售撤销失败"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         return response; 
														 | 
														
														 | 
														
															         return response; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 |