Browse Source

完善商品明细

master
xiaoyue 4 years ago
parent
commit
0ba3729863
  1. 11
      src/main/java/cn/chjyj/szwh/mapper/GoodsSourceMapper.java
  2. 44
      src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java
  3. 11
      src/main/resources/mapper/szwh/GoodsSourceMapper.xml
  4. 7
      src/test/java/cn/chjyj/szwh/mapper/GoodsSourceMapperTest.java

11
src/main/java/cn/chjyj/szwh/mapper/GoodsSourceMapper.java

@ -1,6 +1,7 @@
package cn.chjyj.szwh.mapper; package cn.chjyj.szwh.mapper;
import cn.chjyj.szwh.bean.GoodsSource; import cn.chjyj.szwh.bean.GoodsSource;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
@ -16,4 +17,14 @@ public interface GoodsSourceMapper {
* @return * @return
*/ */
List<GoodsSource> getGoodsSourceByIsli(String goodsIsli); List<GoodsSource> getGoodsSourceByIsli(String goodsIsli);
/**
* 统计某关键词类型的数量
* @param goodsIsli
* @param type
* @param sourceIdentify
* @return
*/
int countGoodSource(@Param("goodsIsli") String goodsIsli,@Param("dataype") int type,
@Param("sourceIdentify")String sourceIdentify);
} }

44
src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java

@ -2,10 +2,12 @@ package cn.chjyj.szwh.service.impl;
import cn.chjyj.szwh.bean.Goods; import cn.chjyj.szwh.bean.Goods;
import cn.chjyj.szwh.bean.GoodsDetail; import cn.chjyj.szwh.bean.GoodsDetail;
import cn.chjyj.szwh.bean.GoodsSource;
import cn.chjyj.szwh.constant.ChConstant; import cn.chjyj.szwh.constant.ChConstant;
import cn.chjyj.szwh.exception.ChException; import cn.chjyj.szwh.exception.ChException;
import cn.chjyj.szwh.mapper.GoodsDetailMapper; import cn.chjyj.szwh.mapper.GoodsDetailMapper;
import cn.chjyj.szwh.mapper.GoodsMapper; import cn.chjyj.szwh.mapper.GoodsMapper;
import cn.chjyj.szwh.mapper.GoodsSourceMapper;
import cn.chjyj.szwh.service.GoodsService; import cn.chjyj.szwh.service.GoodsService;
import cn.chjyj.szwh.utils.ProperUtils; import cn.chjyj.szwh.utils.ProperUtils;
import cn.chjyj.szwh.utils.RequestUtils; import cn.chjyj.szwh.utils.RequestUtils;
@ -32,6 +34,8 @@ public class GoodsServiceImpl implements GoodsService {
private GoodsMapper goodsMapper; private GoodsMapper goodsMapper;
@Autowired @Autowired
private GoodsDetailMapper goodsDetailMapper; private GoodsDetailMapper goodsDetailMapper;
@Autowired
private GoodsSourceMapper goodsSourceMapper;
@Override @Override
public List<Goods> getGoodsList(int page) { public List<Goods> getGoodsList(int page) {
@ -184,6 +188,8 @@ public class GoodsServiceImpl implements GoodsService {
@Override @Override
public Map<String, Object> getGoodsDetail(String islicode) { public Map<String, Object> getGoodsDetail(String islicode) {
//时间格式化
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Map retmap= new HashMap(); Map retmap= new HashMap();
/** /**
* 联合查询的结果 * 联合查询的结果
@ -198,12 +204,42 @@ public class GoodsServiceImpl implements GoodsService {
// 返回后远程获取用户信息 userinfo // 返回后远程获取用户信息 userinfo
retmap.put("user_isli",gdv.getUser_islicode()); retmap.put("user_isli",gdv.getUser_islicode());
// 商品来源 // 商品资源
List gatherarr=new ArrayList();
List oneSource=new ArrayList();
List<GoodsSource> goodsSourceList = goodsSourceMapper.getGoodsSourceByIsli(gdv.getGoods_islicode());
if(goodsSourceList!=null){ //not null
for(GoodsSource gs:goodsSourceList){
// 解析json
JSONObject sdjson = JSONObject.parseObject(gs.getSourceData());
Integer datatype=sdjson.getInteger("datatype");
Map info = new HashMap();
if(datatype==1){ //机构数据
info.put("name",gs.getSourceName());
info.put("class",gs.getSourceType());
// 从json data 中获取
info.put("registerDate",sdf.format(sdjson.getString("registerDate")));
info.put("identifier",sdjson.getString("identifier"));
//符合条件的数量
int count = goodsSourceMapper.countGoodSource(gdv.getGoods_islicode(),1,gs.getSourceidentify());
info.put("count",count);
gatherarr.add(info);
}else{
Long filesize= sdjson.getLongValue("metadataFileSize");
info.put("name",gs.getSourceName());
info.put("class",gs.getSourceType());
info.put("registerDate",sdf.format(sdjson.getString("registerDate")));
info.put("filesize",filesize);
info.put("metadataFileFormat",sdjson.getString("metadataFileFormat"));
oneSource.add(info);
}
}
}
// //
retmap.put("gather_arr",""); retmap.put("gather_arr",gatherarr);
retmap.put("oneSource",""); retmap.put("oneSource",oneSource);
return retmap; return retmap;
} }

11
src/main/resources/mapper/szwh/GoodsSourceMapper.xml

@ -23,11 +23,14 @@
AND is_deleted=0 AND is_deleted=0
</select> </select>
<!--根据uid查询用户--> <!--统计 -->
<select id="getUserByUid" parameterType="java.lang.Integer" resultType="cn.chjyj.szwh.bean.Goods"> <select id="countGoodSource" resultType="java.lang.Integer">
select <include refid="column"/> select count(*)
from <include refid="tbName"/> from <include refid="tbName"/>
where uid=#{uid} where goods_isli_code=#{goodsIsli}
AND datatype=#{dataype}
AND is_deleted=0
AND sourceIdentify like concat("%",#{sourceIdentify},"%");
</select> </select>
<!--查询用户名,加上密码--> <!--查询用户名,加上密码-->

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

@ -33,4 +33,11 @@ class GoodsSourceMapperTest {
System.out.println(gs.getRegistrant()); System.out.println(gs.getRegistrant());
} }
} }
@Test
public void counttest(){
String gisl="010007-00000000187199999999-4";
int cc = goodsSourceMapper.countGoodSource(gisl,1,"ISLI01");
System.out.println(cc);
}
} }
Loading…
Cancel
Save