Browse Source

修复资源信息空白的bug

master
xyiege 4 years ago
parent
commit
4cd34dd9a8
  1. 8
      src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java
  2. 84
      src/main/java/cn/chjyj/szwh/service/impl/GoodsSourceServiceImpl.java
  3. 3
      src/test/java/cn/chjyj/szwh/mapper/GoodsSourceMapperTest.java

8
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 org.springframework.stereotype.Service;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service @Service
public class GoodsServiceImpl implements GoodsService { public class GoodsServiceImpl implements GoodsService {
@ -211,7 +208,8 @@ public class GoodsServiceImpl implements GoodsService {
retmap.put("user_isli",gdv.getUser_islicode()); retmap.put("user_isli",gdv.getUser_islicode());
// 商品资源 // 商品资源
List gatherarr=new ArrayList(); //List gatherarr=new ArrayList();
Set gatherarr=new HashSet();
List oneSource=new ArrayList(); List oneSource=new ArrayList();
List<GoodsSource> goodsSourceList = goodsSourceMapper.getGoodsSourceByIsli(gdv.getGoods_islicode()); List<GoodsSource> goodsSourceList = goodsSourceMapper.getGoodsSourceByIsli(gdv.getGoods_islicode());
//if(goodsSourceList!=null){ //not null //if(goodsSourceList!=null){ //not null

84
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.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.json.JsonMapper; import com.fasterxml.jackson.databind.json.JsonMapper;
import org.apache.commons.lang3.StringUtils; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -16,11 +18,20 @@ import java.util.*;
@Service @Service
public class GoodsSourceServiceImpl implements GoodsSourceService { public class GoodsSourceServiceImpl implements GoodsSourceService {
private Log log = LogFactory.getLog(GoodsSourceServiceImpl.class);
@Autowired @Autowired
private GoodsSourceMapper goodsSourceMapper; private GoodsSourceMapper goodsSourceMapper;
@Autowired @Autowired
private OrderGoodsDetailMapper orderGoodsDetailMapper; private OrderGoodsDetailMapper orderGoodsDetailMapper;
/**
* 商品来源详情
* @param isli
* @param islicode
* @param batchcode
* @return
*/
@Override @Override
public Map<String, Object> getGoodsSourceDetail(String isli, String islicode, String batchcode) { public Map<String, Object> getGoodsSourceDetail(String isli, String islicode, String batchcode) {
Map query = new HashMap<>(); Map query = new HashMap<>();
@ -28,49 +39,58 @@ public class GoodsSourceServiceImpl implements GoodsSourceService {
if (StringUtils.isNotBlank(batchcode)) { if (StringUtils.isNotBlank(batchcode)) {
query.put("batchcode", batchcode); query.put("batchcode", batchcode);
} }
// 商品资源列表
List<GoodsSource> gslist = goodsSourceMapper.getGoodsSourceByMap(query, 0, 10); List<GoodsSource> gslist = goodsSourceMapper.getGoodsSourceByMap(query, 0, 10);
//返回map //返回map
Map<String, Object> retmap = new HashMap<>(); Map<String, Object> retmap = new HashMap<>();
// //文化资源数据-基本信息
Map info = 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(); List gatherList = new ArrayList();
//遍历 //遍历
int ind = 0; int ind = 0;
for (GoodsSource gs : gslist) { for (GoodsSource gs : gslist) {
JSONObject jssdata = JSONObject.parseObject(gs.getSourceData()); //目标json 字符串
JSONObject tgdata = JSONObject.parseObject(gs.getTargetData()); JSONObject tgdata = JSONObject.parseObject(gs.getTargetData());
if (ind < 1) { //log.info("target data: "+tgdata);
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++;
}
// 标的信息 // 标的信息
Long filesize =tgdata.getLongValue("metadataFileSize"); Long filesize =tgdata.getLongValue("metadataFileSize");
// 格式化文件大小 // 格式化文件大小
String formatFileSize = SzFileUtils.fileSizeFormat(filesize); String formatFileSize = SzFileUtils.fileSizeFormat(filesize);
List nglist = new ArrayList();
// //
Map gather = new HashMap(); Map gather = new HashMap();
gather.put("target_name",gs.getTargetName()); gather.put("target_name",gs.getTargetName());
@ -91,15 +111,17 @@ public class GoodsSourceServiceImpl implements GoodsSourceService {
} }
} }
nglist.add(gather);
String serviceType = tgdata.getString("serviceType"); String serviceType = tgdata.getString("serviceType");
Map stmap = new HashMap(); Map stmap = new HashMap();
stmap.put("source",gather); stmap.put("source",nglist);
stmap.put("serviceType",serviceType); stmap.put("serviceType",serviceType);
// add to list // add to list
gatherList.add(stmap); gatherList.add(stmap);
} }
retmap.put("info",info);
retmap.put("gather_arr",gatherList); retmap.put("gather_arr",gatherList);
return retmap; return retmap;
} }

3
src/test/java/cn/chjyj/szwh/mapper/GoodsSourceMapperTest.java

@ -48,6 +48,9 @@ class GoodsSourceMapperTest {
Map map =new HashMap(); Map map =new HashMap();
map.put("sourceIdentify","010005-000000000000013279999999-7"); map.put("sourceIdentify","010005-000000000000013279999999-7");
List<GoodsSource> goodsSource = goodsSourceMapper.getGoodsSourceByMap(map,0,10); List<GoodsSource> goodsSource = goodsSourceMapper.getGoodsSourceByMap(map,0,10);
for(GoodsSource gs:goodsSource){
}
System.out.println(goodsSource.size()); System.out.println(goodsSource.size());
} }
} }
Loading…
Cancel
Save