|
|
|
@ -14,7 +14,10 @@ import org.springframework.test.context.CacheAwareContextLoaderDelegate; |
|
|
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
|
|
|
import org.springframework.test.context.junit4.SpringRunner; |
|
|
|
|
|
|
|
import java.sql.Timestamp; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.Calendar; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
@ -58,6 +61,57 @@ public class ApiTest { |
|
|
|
//System.out.println(json);
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 测试一次性托管产品的时间获取问题 |
|
|
|
* cover字段用其他代替 |
|
|
|
*/ |
|
|
|
@Test |
|
|
|
public void onceTest(){ |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
String tmpstr ="{\"resultCode\":\"00000000\",\"resultMsg\":\"SUCCESS\",\"data\":[{\"isliCode\":\"010007-00000000302400000001-7\",\"status\":\"1\",\"createTime\":\"2022-10-18T02:14:32.000+00:00\",\"exStatus\":\"0\",\"timeStamp\":1666059280000,\"sourceData\":{\"contractIsLiCode\":\"010007-00000000302400000001-7\",\"register\":\"北京玖扬博文文化发展有限公司\",\"entityName\":null,\"isliCode\":\"010007-00000000302499999999-6\",\"serviceCode\":\"010007\",\"titleName\":\"1018-一次\",\"releaseTime\":\"2022-10-18 10:14:03\",\"identifier\":\"010007-00000000302499999999-6\",\"identifiers\":\"000002-100000000192058-1\",\"systemIdentity\":\"ee6510c19fb643aabf336bbe9e014a82\",\"transactionType\":\"授权\",\"collectionType\":\"文化资源数据\"," + |
|
|
|
"\"transactionKind\":\"权属\",\"otherIdentifiers\":\" \",\"contractualPeriod\":\"一次性委托\",\"contractualCycle\":\"40\",\"price\":\"RMB 0.01\"," + |
|
|
|
"\"rights\":\"展览权\",\"contractMoney\":\"交易全额的30%\",\"contractualPeriodStart\":\"2022-10-18\",\"contractualPeriodEnd\":null," + |
|
|
|
"\"contractStatus\":\"1\",\"cover\":\"http://tmp/xx_demo.png\"}," + |
|
|
|
"\"targetData\":{\"contractIsliCode\":\"010007-00000000302400000001-7\",\"register\":\"伏羲云\",\"entityName\":null,\"isliCode\":\"899998-000000001161-2\",\"identifier\":\"899998-000000001161-2\",\"serviceCode\":\"899998\",\"titleName\":\"北京玖扬博文文化发展有限公司\",\"releaseTime\":null,\"otherIdentifiers\":\"91110108597748619P\",\"entityType\":\"组织\",\"certificate\":\"http://172.16.3.21:11000/file/cncbox/userself/7/16073304715399411.png\",\"date\":\"2022-08-05 15:17:24\",\"place\":\"中国\",\"description\":\"\",\"electronicSignature\":\"\",\"participants\":\"卖方\"}}]}"; |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(tmpstr); |
|
|
|
//提取数组
|
|
|
|
JSONArray jsonArray = jsonObject.getJSONArray("data"); |
|
|
|
JSONObject sdjson = (JSONObject) jsonArray.get(0); |
|
|
|
// 抽取source data
|
|
|
|
String nsdstr = sdjson.getString("sourceData"); |
|
|
|
JSONObject nsdjson = JSONObject.parseObject(nsdstr); |
|
|
|
//提取和处理,委托周期
|
|
|
|
String contractualPeriod = nsdjson.getString("contractualPeriod"); |
|
|
|
// 判断委托类型,一次性委托(永久委托)\阶段性委托
|
|
|
|
int iperiod = ApiGoodsUtils.convertProid(contractualPeriod); |
|
|
|
//商品起止时间
|
|
|
|
String cstart = nsdjson.getString("contractualPeriodStart"); |
|
|
|
String curTime = new SimpleDateFormat("HH:mm:ss").format(new Date()); |
|
|
|
String ncstart = cstart + " " + curTime; |
|
|
|
// 委托周期
|
|
|
|
Integer day = nsdjson.getInteger("contractualCycle"); |
|
|
|
//转换为date
|
|
|
|
String cend = nsdjson.getString("contractualPeriodEnd"); |
|
|
|
//委托开始时间,取当前时间
|
|
|
|
Timestamp ncst=new Timestamp(System.currentTimeMillis()); |
|
|
|
//委托结束时间 default value 2099-12-31 23:59:59
|
|
|
|
Timestamp ncet=new Timestamp(4102415999000l); |
|
|
|
try { |
|
|
|
// 委托开始时间 匹配时间格式,防止转码出错
|
|
|
|
Date wtStart = sdf.parse(ncstart); |
|
|
|
ncst = new Timestamp(wtStart.getTime()); |
|
|
|
// 委托终止时间
|
|
|
|
Date wtEnd=WorkDayUtil.getWorkDay(wtStart,day); |
|
|
|
Date fwtEnd = wtEnd; |
|
|
|
SimpleDateFormat ysdf =new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
cend = ysdf.format(fwtEnd)+" 23:59:59"; |
|
|
|
ncet=new Timestamp(sdf.parse(cend).getTime()); |
|
|
|
System.out.println(day+"工作日后的日期:"+ncet); |
|
|
|
} catch (Exception ex) { |
|
|
|
ex.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void syncOrder(){ |
|
|
|
System.out.println("同步订单信息"); |
|
|
|
|