From 4cd34dd9a8806c679b7aed7457baf3a832124066 Mon Sep 17 00:00:00 2001 From: xyiege Date: Mon, 25 Jul 2022 22:06:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B5=84=E6=BA=90=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E7=A9=BA=E7=99=BD=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../szwh/service/impl/GoodsServiceImpl.java | 8 +- .../service/impl/GoodsSourceServiceImpl.java | 84 ++++++++++++------- .../szwh/mapper/GoodsSourceMapperTest.java | 3 + 3 files changed, 59 insertions(+), 36 deletions(-) diff --git a/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java b/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java index 5e315b0..2a83110 100644 --- a/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java +++ b/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java @@ -23,10 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; @Service public class GoodsServiceImpl implements GoodsService { @@ -211,7 +208,8 @@ public class GoodsServiceImpl implements GoodsService { retmap.put("user_isli",gdv.getUser_islicode()); // 商品资源 - List gatherarr=new ArrayList(); + //List gatherarr=new ArrayList(); + Set gatherarr=new HashSet(); List oneSource=new ArrayList(); List goodsSourceList = goodsSourceMapper.getGoodsSourceByIsli(gdv.getGoods_islicode()); //if(goodsSourceList!=null){ //not null diff --git a/src/main/java/cn/chjyj/szwh/service/impl/GoodsSourceServiceImpl.java b/src/main/java/cn/chjyj/szwh/service/impl/GoodsSourceServiceImpl.java index 39d61a2..53ed27d 100644 --- a/src/main/java/cn/chjyj/szwh/service/impl/GoodsSourceServiceImpl.java +++ b/src/main/java/cn/chjyj/szwh/service/impl/GoodsSourceServiceImpl.java @@ -9,6 +9,8 @@ import cn.chjyj.szwh.utils.SzFileUtils; import com.alibaba.fastjson.JSONObject; import com.fasterxml.jackson.databind.json.JsonMapper; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -16,11 +18,20 @@ import java.util.*; @Service public class GoodsSourceServiceImpl implements GoodsSourceService { + private Log log = LogFactory.getLog(GoodsSourceServiceImpl.class); + @Autowired private GoodsSourceMapper goodsSourceMapper; @Autowired private OrderGoodsDetailMapper orderGoodsDetailMapper; + /** + * 商品来源详情 + * @param isli + * @param islicode + * @param batchcode + * @return + */ @Override public Map getGoodsSourceDetail(String isli, String islicode, String batchcode) { Map query = new HashMap<>(); @@ -28,49 +39,58 @@ public class GoodsSourceServiceImpl implements GoodsSourceService { if (StringUtils.isNotBlank(batchcode)) { query.put("batchcode", batchcode); } + // 商品资源列表 List gslist = goodsSourceMapper.getGoodsSourceByMap(query, 0, 10); //返回map Map retmap = new HashMap<>(); - // + //文化资源数据-基本信息 Map info = new HashMap(); + // gslist其中一条用来当做详情基本信息 + GoodsSource tmpgs = gslist.get(0); + // 资源json串 + JSONObject jssdata = JSONObject.parseObject(tmpgs.getSourceData()); + // 填充info + info.put("source_name", tmpgs.getSourceName()); + String otherIndFiler = jssdata.getString("otherIdentifiers"); + info.put("otherIdentifiers", StringUtils.isNotBlank(otherIndFiler) ? otherIndFiler : "-"); + info.put("identifier", jssdata.getString("identifier")); + info.put("collectionType", jssdata.getString("collectionType")); + info.put("serviceType", jssdata.getString("serviceType")); + info.put("classification", jssdata.getString("classification")); + info.put("contributors", jssdata.getString("contributors")); + info.put("copyrightOwner" ,jssdata.getString("copyrightOwner")); + info.put("carrier" ,jssdata.getString("carrier")); + info.put("registrant" ,jssdata.getString("registrant")); + info.put("registerDate" ,jssdata.getString("registerDate")); + info.put("repositoryName",jssdata.getString("repositoryName")); + String dimen = jssdata.getString("dimensions"); + info.put("dimensions" ,StringUtils.isNotBlank(dimen)?dimen:"-"); + info.put("quantity" ,jssdata.getString("quantity")); + info.put("label" ,jssdata.getString("label")); + info.put("description",jssdata.getString("description")); + info.put("md5Val" ,jssdata.getString("md5Val")); + info.put("databaseId" ,jssdata.getString("databaseId")); + info.put("edition" ,jssdata.getString("edition")); + info.put("collectionCondition" ,jssdata.getString("collectionCondition")); + info.put("cover" ,jssdata.getString("cover")); + // 封装到返回map中 + retmap.put("info",info); + + //资源数据集合 list List gatherList = new ArrayList(); //遍历 int ind = 0; for (GoodsSource gs : gslist) { - JSONObject jssdata = JSONObject.parseObject(gs.getSourceData()); + //目标json 字符串 JSONObject tgdata = JSONObject.parseObject(gs.getTargetData()); - if (ind < 1) { - info.put("source_name", gs.getSourceName()); - String otherIndFiler = jssdata.getString("otherIdentifiers"); - info.put("otherIdentifiers", StringUtils.isNotBlank(otherIndFiler) ? otherIndFiler : "-"); - info.put("identifier", jssdata.getString("identifier")); - info.put("collectionType", jssdata.getString("collectionType")); - info.put("serviceType", jssdata.getString("serviceType")); - info.put("classification", jssdata.getString("classification")); - info.put("contributors", jssdata.getString("contributors")); - info.put("copyrightOwner" ,jssdata.getString("copyrightOwner")); - info.put("carrier" ,jssdata.getString("carrier")); - info.put("registrant" ,jssdata.getString("registrant")); - info.put("registerDate" ,jssdata.getString("registerDate")); - info.put("repositoryName",jssdata.getString("repositoryName")); - String dimen = jssdata.getString("dimensions"); - info.put("dimensions" ,StringUtils.isNotBlank(dimen)?dimen:"-"); - info.put("quantity" ,jssdata.getString("quantity")); - info.put("label" ,jssdata.getString("label")); - info.put("description",jssdata.getString("description")); - info.put("md5Val" ,jssdata.getString("md5Val")); - info.put("databaseId" ,jssdata.getString("databaseId")); - info.put("edition" ,jssdata.getString("edition")); - info.put("collectionCondition" ,jssdata.getString("collectionCondition")); - info.put("cover" ,jssdata.getString("cover")); - // 索引增加 - ind++; - } + //log.info("target data: "+tgdata); // 标的信息 Long filesize =tgdata.getLongValue("metadataFileSize"); // 格式化文件大小 String formatFileSize = SzFileUtils.fileSizeFormat(filesize); + + List nglist = new ArrayList(); // Map gather = new HashMap(); gather.put("target_name",gs.getTargetName()); @@ -91,15 +111,17 @@ public class GoodsSourceServiceImpl implements GoodsSourceService { } } + nglist.add(gather); + String serviceType = tgdata.getString("serviceType"); Map stmap = new HashMap(); - stmap.put("source",gather); + stmap.put("source",nglist); stmap.put("serviceType",serviceType); + // add to list gatherList.add(stmap); } - retmap.put("info",info); retmap.put("gather_arr",gatherList); return retmap; } diff --git a/src/test/java/cn/chjyj/szwh/mapper/GoodsSourceMapperTest.java b/src/test/java/cn/chjyj/szwh/mapper/GoodsSourceMapperTest.java index f753c19..d7c261a 100644 --- a/src/test/java/cn/chjyj/szwh/mapper/GoodsSourceMapperTest.java +++ b/src/test/java/cn/chjyj/szwh/mapper/GoodsSourceMapperTest.java @@ -48,6 +48,9 @@ class GoodsSourceMapperTest { Map map =new HashMap(); map.put("sourceIdentify","010005-000000000000013279999999-7"); List goodsSource = goodsSourceMapper.getGoodsSourceByMap(map,0,10); + for(GoodsSource gs:goodsSource){ + + } System.out.println(goodsSource.size()); } } \ No newline at end of file