add retrospect chaincode error info

parent 7900ce74
......@@ -2,13 +2,10 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="de83b181-e854-4be8-81f5-73a2fdb02762" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/bean" beforeDir="false" afterPath="$PROJECT_DIR$/src/bean" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/bean/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/bean/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/bean/bean.go" beforeDir="false" afterPath="$PROJECT_DIR$/src/bean/supply_chain.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/bean/bean_test.go" beforeDir="false" afterPath="$PROJECT_DIR$/src/bean/supply_chain_test.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/medical_chain/medical.go" beforeDir="false" afterPath="$PROJECT_DIR$/src/medical_chain/medical.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/retrospect_chain/restropect_test.go" beforeDir="false" afterPath="$PROJECT_DIR$/src/retrospect_chain/restropect_test.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/retrospect_chain/retrospect.go" beforeDir="false" afterPath="$PROJECT_DIR$/src/retrospect_chain/retrospect.go" afterDir="false" />
</list>
......@@ -21,46 +18,49 @@
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/bean/supply_chain.go">
<entry file="file://$PROJECT_DIR$/src/retrospect_chain/restropect_test.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="968">
<caret line="50" selection-start-line="50" selection-end-line="50" />
<state relative-caret-position="924">
<caret line="47" column="1" lean-forward="true" selection-start-line="44" selection-start-column="13" selection-end-line="47" selection-end-column="1" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/retrospect_chain/restropect_test.go">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/retrospect_chain/retrospect.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="176">
<caret line="13" column="11" selection-start-line="13" selection-start-column="11" selection-end-line="13" selection-end-column="11" />
<state relative-caret-position="873">
<caret line="404" column="57" lean-forward="true" selection-start-line="404" selection-start-column="57" selection-end-line="404" selection-end-column="57" />
<folding>
<element signature="e#14#170#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/testcc/testcc.go">
<entry file="file://$PROJECT_DIR$/../fabric/core/chaincode/shim/interfaces.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="682">
<caret line="35" column="5" selection-start-line="35" selection-start-column="5" selection-end-line="35" selection-end-column="5" />
<state relative-caret-position="346">
<caret line="152" column="4" selection-start-line="152" selection-start-column="4" selection-end-line="152" selection-end-column="4" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/testcc/testcc_test.go">
<entry file="file://$PROJECT_DIR$/../fabric/core/chaincode/shim/response.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="352">
<caret line="20" selection-start-line="20" selection-end-line="20" />
<state relative-caret-position="775">
<caret line="40" column="5" selection-start-line="40" selection-start-column="5" selection-end-line="40" selection-end-column="5" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/retrospect_chain/retrospect.go">
<file pinned="false" current-in-tab="false">
<entry file="file:///usr/local/go/src/strconv/atoi.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="22">
<caret line="1306" column="50" lean-forward="true" selection-start-line="1306" selection-start-column="50" selection-end-line="1306" selection-end-column="50" />
<state relative-caret-position="346">
<caret line="178" selection-start-line="178" selection-end-line="178" />
</state>
</provider>
</entry>
......@@ -124,7 +124,6 @@
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>stub.PutState</find>
<find>authorityCheck</find>
<find>GetStateByRangeWithPagination</find>
<find>switch</find>
......@@ -154,6 +153,7 @@
<find>alinkman</find>
<find>schemaCache.Get err</find>
<find>Println</find>
<find>extract RespectShow</find>
</findStrings>
</component>
<component name="GOROOT" path="/usr/local/go" />
......@@ -218,6 +218,7 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
......@@ -242,17 +243,10 @@
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="retrospect_chain" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="chaincode" type="b2602c69:ProjectViewProjectNode" />
<item name="chaincode" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="testcc" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
......@@ -329,34 +323,34 @@
</recent_temporary>
</component>
<component name="TestHistory">
<history-entry file="TestFieldCheck_in_github_com_hyperledger_chaincode_src_github_com_gongxianghui_framework - 2020.04.03 at 16h 32m 30s.xml">
<configuration name="TestFieldCheck in github.com/hyperledger/chaincode/src/github.com/gongxianghui_framework" configurationId="GoTestRunConfiguration" />
<history-entry file="TestAddActivityInfo_in_github_com_hyperledger_chaincode_src_retrospect_chain - 2021.03.08 at 14h 27m 21s.xml">
<configuration name="TestAddActivityInfo in github.com/hyperledger/chaincode/src/retrospect_chain" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestFieldCheck_in_github_com_hyperledger_chaincode_src_github_com_gongxianghui_framework - 2020.04.03 at 16h 33m 07s.xml">
<configuration name="TestFieldCheck in github.com/hyperledger/chaincode/src/github.com/gongxianghui_framework" configurationId="GoTestRunConfiguration" />
<history-entry file="TestAddActivityInfo_in_github_com_hyperledger_chaincode_src_retrospect_chain - 2021.03.09 at 18h 09m 47s.xml">
<configuration name="TestAddActivityInfo in github.com/hyperledger/chaincode/src/retrospect_chain" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestFieldCheck_in_github_com_hyperledger_chaincode_src_github_com_gongxianghui_framework - 2020.04.03 at 16h 34m 49s.xml">
<configuration name="TestFieldCheck in github.com/hyperledger/chaincode/src/github.com/gongxianghui_framework" configurationId="GoTestRunConfiguration" />
<history-entry file="TestAddActivityInfo_in_github_com_hyperledger_chaincode_src_retrospect_chain - 2021.03.09 at 18h 15m 04s.xml">
<configuration name="TestAddActivityInfo in github.com/hyperledger/chaincode/src/retrospect_chain" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestFieldCheck_in_github_com_hyperledger_chaincode_src_github_com_gongxianghui_framework - 2020.04.03 at 16h 36m 16s.xml">
<configuration name="TestFieldCheck in github.com/hyperledger/chaincode/src/github.com/gongxianghui_framework" configurationId="GoTestRunConfiguration" />
<history-entry file="TestAddActivityInfo_in_github_com_hyperledger_chaincode_src_retrospect_chain - 2021.03.09 at 18h 18m 15s.xml">
<configuration name="TestAddActivityInfo in github.com/hyperledger/chaincode/src/retrospect_chain" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestFieldCheck_in_github_com_hyperledger_chaincode_src_github_com_gongxianghui_framework - 2020.04.03 at 16h 36m 22s.xml">
<configuration name="TestFieldCheck in github.com/hyperledger/chaincode/src/github.com/gongxianghui_framework" configurationId="GoTestRunConfiguration" />
<history-entry file="TestAddActivityInfo_in_github_com_hyperledger_chaincode_src_retrospect_chain - 2021.03.09 at 18h 24m 15s.xml">
<configuration name="TestAddActivityInfo in github.com/hyperledger/chaincode/src/retrospect_chain" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestAddActivityInfo_in_github_com_hyperledger_chaincode_src_retrospect_chain - 2020.12.03 at 10h 23m 01s.xml">
<history-entry file="TestAddActivityInfo_in_github_com_hyperledger_chaincode_src_retrospect_chain - 2021.03.09 at 18h 24m 44s.xml">
<configuration name="TestAddActivityInfo in github.com/hyperledger/chaincode/src/retrospect_chain" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestBeanChainCode_Invoke_in_github_com_hyperledger_chaincode_src_bean - 2020.12.08 at 10h 39m 15s.xml">
<configuration name="TestBeanChainCode_Invoke in github.com/hyperledger/chaincode/src/bean" configurationId="GoTestRunConfiguration" />
<history-entry file="TestAddActivityInfo_in_github_com_hyperledger_chaincode_src_retrospect_chain - 2021.03.09 at 18h 26m 57s.xml">
<configuration name="TestAddActivityInfo in github.com/hyperledger/chaincode/src/retrospect_chain" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestBeanChainCode_Invoke_in_github_com_hyperledger_chaincode_src_testcc - 2021.03.02 at 11h 52m 38s.xml">
<configuration name="TestBeanChainCode_Invoke in github.com/hyperledger/chaincode/src/testcc" configurationId="GoTestRunConfiguration" />
<history-entry file="TestAddActivityInfo_in_github_com_hyperledger_chaincode_src_retrospect_chain - 2021.03.09 at 18h 27m 19s.xml">
<configuration name="TestAddActivityInfo in github.com/hyperledger/chaincode/src/retrospect_chain" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestBeanChainCode_Invoke_in_github_com_hyperledger_chaincode_src_testcc - 2021.03.02 at 11h 54m 23s.xml">
<configuration name="TestBeanChainCode_Invoke in github.com/hyperledger/chaincode/src/testcc" configurationId="GoTestRunConfiguration" />
<history-entry file="TestAddActivityInfo_in_github_com_hyperledger_chaincode_src_retrospect_chain - 2021.03.09 at 18h 40m 00s.xml">
<configuration name="TestAddActivityInfo in github.com/hyperledger/chaincode/src/retrospect_chain" configurationId="GoTestRunConfiguration" />
</history-entry>
<history-entry file="TestAddActivityInfo_in_github_com_hyperledger_chaincode_src_retrospect_chain - 2021.03.08 at 14h 27m 21s.xml">
<history-entry file="TestAddActivityInfo_in_github_com_hyperledger_chaincode_src_retrospect_chain - 2021.03.09 at 18h 53m 00s.xml">
<configuration name="TestAddActivityInfo in github.com/hyperledger/chaincode/src/retrospect_chain" configurationId="GoTestRunConfiguration" />
</history-entry>
</component>
......@@ -373,13 +367,13 @@
<frame x="71" y="31" width="1885" height="1937" extended-state="4" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.12192455" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.12356479" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info active="true" anchor="bottom" id="Find" order="1" visible="true" weight="0.32903588" />
<window_info anchor="bottom" id="Run" order="2" weight="0.39742154" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.39865622" />
<window_info anchor="bottom" id="Run" order="2" visible="true" weight="0.39742154" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.3985426" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" weight="0.3294849" />
......@@ -387,7 +381,7 @@
<window_info anchor="bottom" id="Version Control" order="8" weight="0.3294849" />
<window_info anchor="bottom" id="Database Changes" order="9" />
<window_info anchor="bottom" id="Statistic" order="10" weight="0.3294849" />
<window_info anchor="bottom" id="Terminal" order="11" weight="0.29283315" />
<window_info anchor="bottom" id="Terminal" order="11" weight="0.2926009" />
<window_info anchor="bottom" id="Event Log" order="12" side_tool="true" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
......@@ -417,11 +411,22 @@
<line>15</line>
<option name="timeStamp" value="10" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/src/retrospect_chain/retrospect.go</url>
<line>1306</line>
<properties />
<option name="timeStamp" value="12" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/src/retrospect_chain/retrospect.go</url>
<line>992</line>
<properties />
<option name="timeStamp" value="13" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/../fabric/protos/peer/proposal.pb.go" />
<entry file="file://$PROJECT_DIR$/../fabric/core/endorser/mocks/support.go" />
<entry file="file://$PROJECT_DIR$/../fabric/core/endorser/endorser.go">
<provider selected="true" editor-type-id="text-editor">
......@@ -653,20 +658,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../fabric/core/chaincode/shim/interfaces.go">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret line="92" column="4" selection-start-line="92" selection-start-column="4" selection-end-line="92" selection-end-column="4" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../fabric/core/chaincode/shim/response.go">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret line="34" column="18" selection-start-line="34" selection-start-column="14" selection-end-line="34" selection-end-column="22" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../fabric/protos/peer/proposal_response.pb.go">
<provider selected="true" editor-type-id="text-editor">
<state>
......@@ -740,17 +731,41 @@
</state>
</provider>
</entry>
<entry file="file:///usr/local/go/src/strconv/atoi.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="346">
<caret line="178" selection-start-line="178" selection-end-line="178" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../fabric/core/chaincode/shim/response.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="775">
<caret line="40" column="5" selection-start-line="40" selection-start-column="5" selection-end-line="40" selection-end-column="5" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../fabric/core/chaincode/shim/interfaces.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="346">
<caret line="152" column="4" selection-start-line="152" selection-start-column="4" selection-end-line="152" selection-end-column="4" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/retrospect_chain/restropect_test.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="176">
<caret line="13" column="11" selection-start-line="13" selection-start-column="11" selection-end-line="13" selection-end-column="11" />
<state relative-caret-position="924">
<caret line="47" column="1" lean-forward="true" selection-start-line="44" selection-start-column="13" selection-end-line="47" selection-end-column="1" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/retrospect_chain/retrospect.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="22">
<caret line="1306" column="50" lean-forward="true" selection-start-line="1306" selection-start-column="50" selection-end-line="1306" selection-end-column="50" />
<state relative-caret-position="873">
<caret line="404" column="57" lean-forward="true" selection-start-line="404" selection-start-column="57" selection-end-line="404" selection-end-column="57" />
<folding>
<element signature="e#14#170#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
......
......@@ -42,7 +42,7 @@ var(
qualityTesting =`{"qtId":"1101","qtOrgName":"qtOrgName","qtMethod":"qtOrgName","qtDate":"qtOrgName","qtResult":"qtOrgName","qtUser":"qtUser","qtReport":"qtUser","waterReport":["speciesDesc","speciesDesc"],"landReport":["speciesDesc","speciesDesc"],"airReport":["speciesDesc","speciesDesc"]}`
packagingInfo =`{"packid":"1101","cid":"1101","baseId":"baseId","plotId":"plotId","sid":"1101","bno":"1102","packInfo":"packInfo","bizType":"bizType","pno":"bizType","packCount":0,"packUnit":"packUnit","packDate":"packUnit","packPics":["speciesDesc","speciesDesc"],"principalId":"packUnit","principal":"packUnit"}`
salesInfo =`{"id":"1101","cid":"1101","baseId":"baseId","plotId":"plotId","sid":"sid","bno":"1101","saleInfo":"saleInfo","bizType":"bizType","sno":"1101","customer":"customer","saleCount":0,"packingSize":"customer","saleDate":"saleDate","salePics":"salePics","trackingNo":"trackingNo","logisticsName":"logisticsName","did":0,"principalId":"principalId","principal":"principalId","commissionRatio":0}`
qrcode =`{"p_no":"1102","start_number":0,"count":100,"product_show":{"product_name":true,"pick_date":true,"expiration_date":10,"product_type":true,"product_no":true,"stoage_mode":"低温保存","product_des":true,"product_files":["speciesDesc","speciesDesc"]},"retrospect_show":{"base_name":"1101","polt_name":"1101","species_name":"1101","plant_activity":"1101","plant_test":"1101","plant_pick":"1101",
qrcode =`{"p_no":"1102","start_number":100,"count":100,"product_show":{"product_name":true,"pick_date":true,"expiration_date":10,"product_type":true,"product_no":true,"stoage_mode":"低温保存","product_des":true,"product_files":["speciesDesc","speciesDesc"]},"retrospect_show":{"base_name":"1101","polt_name":"1101","species_name":"1101","plant_activity":"1101","plant_test":"1101","plant_pick":"1101",
"quality_test":"1101","packaging":"1101","sale_info":"1101","logistics_info":false,"base_files":["speciesDesc","speciesDesc"]},"quality_test_show":{"qtId":"1101","detection":false,"detection_mode":false,"detection_tiem":false,"detection_result":false,"detection_people":false,"detection_paper":false,"land_detection_paper":false,"write_detection_paper":false,"air_detection_paper":false},"company_show":
{"cid":"1101","principal":false,"principal_phone":false,"company_name":false,"company_person":false,"company_address":false,"company_intro":false,"business_license":false}}`
)
......@@ -201,7 +201,7 @@ func TestAddActivityInfo(t *testing.T) {
}else if print{
fmt.Println(string(resSearch.Payload))
}
resSearch1 := stub.MockInvoke("invoke1",[][]byte{[]byte("searchRespectInfo"),[]byte("1102"),[]byte("89")})
resSearch1 := stub.MockInvoke("invoke1",[][]byte{[]byte("searchRespectInfo"),[]byte("1102"),[]byte("109")})
if resSearch1.Status != 200{
//testResult = false
t.Error(resSearch1.Message)
......
......@@ -546,7 +546,11 @@ func TestCheck(args []string, stub shim.ChaincodeStubInterface) pb.Response {
if len(args) == 0 {
return shim.Success([]byte("参数内容为空"))
}
return shim.Success([]byte(args[0]))
str :=""
for _,arg :=range args{
str+=arg
}
return shim.Success([]byte(str))
}
/*
......@@ -1057,10 +1061,9 @@ func SearchRespectInfo(args []string, stub shim.ChaincodeStubInterface) pb.Respo
showByte, err := getStateByte(showKey, stub)
qr := &SearchQrCode{}
if showByte != nil{
err = json.Unmarshal(showByte,qr)
if err !=nil{
return shim.Error(err.Error())
return shim.Error("unmarshal happen error" +err.Error())
}
qr.Count+=1
}else{
......@@ -1119,19 +1122,19 @@ func extractRespectShowInfo(qrcode *QrCode, stub shim.ChaincodeStubInterface)(qr
companyKey := CompanyInfoKey + "_" + qrcode.CompanyShow.Cid
compResult,err := getStateByte(companyKey,stub)
if err != nil{
return nil,err
return nil,errors.New("get company "+companyKey+" happen err"+err.Error())
}
company:= &CompanyInfo{}
err = json.Unmarshal(compResult,company)
if err != nil{
return nil,err
return nil,errors.New("unmarshal company "+companyKey+" happen err"+err.Error())
}
sqrcode.CompanyShow = company
//step 2: 查询质检信息
qualityKey := QualityTestInfoKey + "_" + qrcode.QualityTestShow.QtId
qualityResult,err := getStateByte(qualityKey,stub)
if err != nil{
return nil,err
return nil,errors.New("get qualityTest "+qualityKey+" happen err"+err.Error())
}
quality:= &QualityTesting{}
err = json.Unmarshal(qualityResult,quality)
......@@ -1153,7 +1156,7 @@ func extractRespectShowInfo(qrcode *QrCode, stub shim.ChaincodeStubInterface)(qr
baseKey := BaseInfoKey + "_" + qrcode.RetrospectShow.BaseName
baseResult,err := getStateByte(baseKey,stub)
if err != nil{
return nil,err
return nil,errors.New("get baseInfo "+baseKey+" happen err"+err.Error())
}
base:= &BaseInfo{}
err = json.Unmarshal(baseResult,base)
......@@ -1166,7 +1169,7 @@ func extractRespectShowInfo(qrcode *QrCode, stub shim.ChaincodeStubInterface)(qr
plotKey := PlotInfoKey + "_" + qrcode.RetrospectShow.PlotName
plotResult,err := getStateByte(plotKey,stub)
if err != nil{
return nil,err
return nil,errors.New("get plotInfo "+plotKey+" happen err"+err.Error())
}
plot:= &PlotInfo{}
err = json.Unmarshal(plotResult,plot)
......@@ -1180,7 +1183,7 @@ func extractRespectShowInfo(qrcode *QrCode, stub shim.ChaincodeStubInterface)(qr
speciesKey := PeciesInfoKey + "_" + qrcode.RetrospectShow.SpeciesName
speciesResult,err := getStateByte(speciesKey,stub)
if err != nil{
return nil,err
return nil,errors.New("get peciesInfo "+speciesKey+" happen err"+err.Error())
}
pecies:= &Pecies{}
err = json.Unmarshal(speciesResult,pecies)
......@@ -1195,7 +1198,7 @@ func extractRespectShowInfo(qrcode *QrCode, stub shim.ChaincodeStubInterface)(qr
planttestKey := QuarantineInfoKey + "_" + qrcode.RetrospectShow.PlantTest
planttestResult,err := getStateByte(planttestKey,stub)
if err != nil{
return nil,err
return nil,errors.New("get quarantineInfo "+planttestKey+" happen err"+err.Error())
}
quar:= &QuarantineInfo{}
err = json.Unmarshal(planttestResult,quar)
......@@ -1208,7 +1211,7 @@ func extractRespectShowInfo(qrcode *QrCode, stub shim.ChaincodeStubInterface)(qr
pickKey := PlantingHarvesInfoKey + "_" + qrcode.RetrospectShow.PlantPick
planttestResult,err := getStateByte(pickKey,stub)
if err != nil{
return nil,err
return nil,errors.New("get plantingHarvesInfo "+pickKey+" happen err"+err.Error())
}
harves:= &Harvesinfo{}
err = json.Unmarshal(planttestResult,harves)
......@@ -1225,7 +1228,7 @@ func extractRespectShowInfo(qrcode *QrCode, stub shim.ChaincodeStubInterface)(qr
packKey := PackingInfoKey + "_" + qrcode.RetrospectShow.Packaging
packResult,err := getStateByte(packKey,stub)
if err != nil{
return nil,err
return nil,errors.New("get packingInfo "+packKey+" happen err"+err.Error())
}
packing:= &PackagingInfo{}
err = json.Unmarshal(packResult,packing)
......@@ -1269,7 +1272,7 @@ func getActivitys(objectType string,activityKey []string,stub shim.ChaincodeStub
activitys:= make([]*ActivityInfo,1)
queryIterator,err := stub.GetStateByPartialCompositeKey(objectType,activityKey)
if err!= nil{
return nil,err
return nil,errors.New("get activitys happen err"+err.Error())
}
if queryIterator.HasNext(){
kv,err := queryIterator.Next()
......@@ -1283,7 +1286,7 @@ func getActivitys(objectType string,activityKey []string,stub shim.ChaincodeStub
}
activitys = append(activitys,activity)
}
return activitys,err
return activitys,nil
}
func getQrcode(args []string, stub shim.ChaincodeStubInterface)(qrCode *QrCode ,err error) {
......@@ -1306,7 +1309,7 @@ func getQrcode(args []string, stub shim.ChaincodeStubInterface)(qrCode *QrCode ,
}
result := SearchQrKey(startNum,qr.StartNumber)
if result == -1{
return nil, errors.New(fmt.Sprintf("Unmarshal QrKey fail,err %s ", err))
return nil, errors.New(fmt.Sprintf("invalid start-number,please redo " ))
}
numKey := strconv.FormatInt(result,10)
qrcodeyKey, err := stub.CreateCompositeKey(ReprospectInfoKey, []string{args[0], numKey})
......@@ -1332,6 +1335,9 @@ func SearchQrKey(startNum int64,s []int64)int64{
return -1
}
if len(s) == 1{
if startNum < s[0]{
return -1
}
return s[0] //最接近starNum 并且小于它
}
middle := len(s)/2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment