|
@@ -181,7 +181,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
//将部门id转为字符串(帮助解决前端问题)
|
|
|
json.put("deptId", json.getString("deptId"));
|
|
|
|
|
|
- record.setVictoriatouristJson(JSONObject.toJSONString(json,JSONWriter.Feature.WriteLongAsString));
|
|
|
+ record.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
|
|
|
}
|
|
|
|
|
|
return page;
|
|
@@ -239,7 +239,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
ProductInfoEhsdJson productInfoEhsdJson = JSONObject.parseObject(record.getEhsdJson(), ProductInfoEhsdJson.class);
|
|
|
String customerName = customerMap.get(Long.parseLong(productInfoEhsdJson.getCustomerId()));
|
|
|
productInfoEhsdJson.setCustomerName(customerName);
|
|
|
- record.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson,JSONWriter.Feature.WriteLongAsString));
|
|
|
+ record.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson, JSONWriter.Feature.WriteLongAsString));
|
|
|
}
|
|
|
}
|
|
|
//赋值创建人名称
|
|
@@ -260,27 +260,27 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
//赋值维多利亚组合产品信息
|
|
|
JSONObject json = JSONObject.parseObject(result.getVictoriatouristJson());
|
|
|
List<Long> ids = new ArrayList<>();
|
|
|
- if(ObjectUtil.isNotEmpty(json) && ObjectUtil.isNotEmpty(json.getJSONArray("productCombinationList"))){
|
|
|
+ if (ObjectUtil.isNotEmpty(json) && ObjectUtil.isNotEmpty(json.getJSONArray("productCombinationList"))) {
|
|
|
JSONArray productCombinationList = json.getJSONArray("productCombinationList");
|
|
|
- for (int i=0;i<productCombinationList.size();i++) {
|
|
|
+ for (int i = 0; i < productCombinationList.size(); i++) {
|
|
|
JSONObject item = productCombinationList.getJSONObject(i);
|
|
|
ids.add(item.getLong("linkProductId"));
|
|
|
}
|
|
|
- if(ObjectUtil.isNotEmpty(ids)){
|
|
|
+ if (ObjectUtil.isNotEmpty(ids)) {
|
|
|
List<ProductInfo> productInfoList = this.listByIds(ids);
|
|
|
Map<Long, ProductInfo> productInfoMap = productInfoList.stream().collect(Collectors.toMap(ProductInfo::getId, Function.identity()));
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
- for (int i=0;i<productCombinationList.size();i++) {
|
|
|
+ for (int i = 0; i < productCombinationList.size(); i++) {
|
|
|
JSONObject item = productCombinationList.getJSONObject(i);
|
|
|
ProductInfo productInfo1 = productInfoMap.get(item.getLong("linkProductId"));
|
|
|
- if(ObjectUtil.isNotEmpty(productInfo1)) {
|
|
|
- item.put("code",productInfo1.getCode());
|
|
|
- item.put("customCode",productInfo1.getCustomCode());
|
|
|
- item.put("name",productInfo1.getName());
|
|
|
+ if (ObjectUtil.isNotEmpty(productInfo1)) {
|
|
|
+ item.put("code", productInfo1.getCode());
|
|
|
+ item.put("customCode", productInfo1.getCustomCode());
|
|
|
+ item.put("name", productInfo1.getName());
|
|
|
}
|
|
|
jsonArray.add(item);
|
|
|
}
|
|
|
- json.put("productCombinationList",jsonArray);
|
|
|
+ json.put("productCombinationList", jsonArray);
|
|
|
result.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
|
|
|
}
|
|
|
}
|
|
@@ -326,7 +326,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
productInfoEhsdJson.setCustomerId("0");
|
|
|
productInfoEhsdJson.setType("1");//默认公司产品
|
|
|
}
|
|
|
- productInfoDto.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson,JSONWriter.Feature.WriteLongAsString));
|
|
|
+ productInfoDto.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson, JSONWriter.Feature.WriteLongAsString));
|
|
|
|
|
|
// 赋值产品编号
|
|
|
productInfoDto.setCode(CodeEnum.PRODUCT.getCode());
|
|
@@ -351,7 +351,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
productInfoEhsdJson.setCostPrice(newProductInfoEhsdJson.getCostPrice());//成本价
|
|
|
productInfoEhsdJson.setNetWeight(newProductInfoEhsdJson.getNetWeight());//净重
|
|
|
productInfo.setRemark(productInfoDto.getRemark());//备注
|
|
|
- productInfo.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson,JSONWriter.Feature.WriteLongAsString));
|
|
|
+ productInfo.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson, JSONWriter.Feature.WriteLongAsString));
|
|
|
this.updateById(productInfo);
|
|
|
//修改图片
|
|
|
ObsFileUtil.editFile(productInfoDto.getFileList(), productInfoDto.getId());
|
|
@@ -369,7 +369,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
Customer customer = customerService.getById(productInfoEhsdJson.getCustomerId());
|
|
|
if (ObjectUtil.isNotEmpty(customer)) {
|
|
|
productInfoEhsdJson.setCustomerName(customer.getName());
|
|
|
- result.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson,JSONWriter.Feature.WriteLongAsString));
|
|
|
+ result.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson, JSONWriter.Feature.WriteLongAsString));
|
|
|
}
|
|
|
}
|
|
|
//赋值创建人名称
|
|
@@ -440,7 +440,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
}
|
|
|
productInfoEhsdJson.setOuterPackMethod(String.join(",", split));
|
|
|
}
|
|
|
- productInfo.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson,JSONWriter.Feature.WriteLongAsString));
|
|
|
+ productInfo.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson, JSONWriter.Feature.WriteLongAsString));
|
|
|
productInfoList.add(productInfo);
|
|
|
}
|
|
|
saveBatch(productInfoList);
|
|
@@ -454,7 +454,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
if (ObjectUtil.isNotEmpty(victoriatouristJson)) {
|
|
|
JSONObject json = JSONObject.parseObject(victoriatouristJson);
|
|
|
json.put("deptId", SecurityUtils.getDeptId());
|
|
|
- productInfoDto.setVictoriatouristJson(JSONObject.toJSONString(json,JSONWriter.Feature.WriteLongAsString));
|
|
|
+ productInfoDto.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
|
|
|
}
|
|
|
add(productInfoDto);
|
|
|
}
|
|
@@ -510,8 +510,8 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<ProductInfoVo> getListByProductType(Integer productType, Integer definition,String productName,String productCode) {
|
|
|
- return baseMapper.getListByProductType(productType, definition,productName,productCode);
|
|
|
+ public List<ProductInfoVo> getListByProductType(Integer productType, Integer definition, String productName, String productCode) {
|
|
|
+ return baseMapper.getListByProductType(productType, definition, productName, productCode);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -525,7 +525,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
String victoriatouristJson = productInfo.getVictoriatouristJson();
|
|
|
JSONObject json = ObjectUtil.isNotEmpty(victoriatouristJson) ? JSONObject.parseObject(victoriatouristJson) : new JSONObject();
|
|
|
json.put("deptId", productInfoDto.getDeptId());
|
|
|
- productInfo.setVictoriatouristJson(JSONObject.toJSONString(json,JSONWriter.Feature.WriteLongAsString));
|
|
|
+ productInfo.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
|
|
|
updateById(productInfo);
|
|
|
}
|
|
|
|
|
@@ -706,6 +706,63 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 产品分类排行(数据看板-产品分析页面)
|
|
|
+ *
|
|
|
+ * @param productInfoDto
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> productClassifyRanking(ProductInfoSelectDto productInfoDto) {
|
|
|
+ //存放产品类型排行数据
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
+
|
|
|
+ QueryWrapper<Object> query = Wrappers.query();
|
|
|
+ String beginTime = DateUtil.format(productInfoDto.getBeginTime(), "yyyy-MM-dd");
|
|
|
+ String endTime = DateUtil.format(productInfoDto.getEndTime(), "yyyy-MM-dd");
|
|
|
+ query.ge("DATE_FORMAT(pc.create_time,'%Y-%m-%d')", beginTime);
|
|
|
+ query.le("DATE_FORMAT(pc.create_time,'%Y-%m-%d')", endTime);
|
|
|
+ query.eq(ObjectUtil.isNotEmpty(productInfoDto.getCountryId()), "bc.buy_country_id", productInfoDto.getCountryId());
|
|
|
+ query.groupBy("pi.id");
|
|
|
+ //查询产品类型排行数据
|
|
|
+ List<ProductInfoVo> productInfoVos = baseMapper.productTypeRanking(query);
|
|
|
+ if (productInfoVos.size() == 0) {
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取所有产品分类
|
|
|
+ List<ProductClassify> productClassifyList = productClassifyService.list();
|
|
|
+ //获取顶级分类
|
|
|
+ List<ProductClassify> topProductClassifyList = productClassifyList.stream().filter(item -> item.getParentId() == 0).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //赋值
|
|
|
+ for (ProductClassify productClassify : topProductClassifyList) {
|
|
|
+ //初始化
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("name", productClassify.getName());
|
|
|
+ map.put("contractAmount", new BigDecimal(0));
|
|
|
+ map.put("contractQuantity", new BigDecimal(0));
|
|
|
+ map.put("purchaseAmount", new BigDecimal(0));
|
|
|
+ map.put("purchaseQuantity", new BigDecimal(0));
|
|
|
+ //赋值
|
|
|
+ List<ProductInfoVo> productInfoVos1 = productInfoVos.stream().filter(item ->
|
|
|
+ item.getProductClassifyId().equals(productClassify.getId())
|
|
|
+ || (ObjectUtil.isEmpty(item.getParentIdSet()) ? "0" : item.getParentIdSet()).contains(productClassify.getId().toString())
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+ if (ObjectUtil.isNotEmpty(productInfoVos1)) {
|
|
|
+ map.put("contractAmount", productInfoVos1.get(0).getContractAmount());
|
|
|
+ map.put("contractQuantity", productInfoVos1.get(0).getContractQuantity());
|
|
|
+ map.put("purchaseAmount", productInfoVos1.get(0).getPurchaseAmount());
|
|
|
+ map.put("purchaseQuantity", productInfoVos1.get(0).getPurchaseQuantity());
|
|
|
+ }
|
|
|
+ list.add(map);
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(list)) {
|
|
|
+ //排序
|
|
|
+ list = typeSort(list, productInfoDto);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 产品排行(数据看板-产品分析页面)
|
|
@@ -728,6 +785,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
|
|
|
/**
|
|
|
* 产品统计
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
@@ -739,9 +797,9 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
* 产品库统计(根据产品库类型进行分类统计)
|
|
|
*/
|
|
|
@Override
|
|
|
- public Map<String,Object> productInfoStatistics(ProductInfoSelectDto dto) {
|
|
|
+ public Map<String, Object> productInfoStatistics(ProductInfoSelectDto dto) {
|
|
|
//存放产品库统计数据
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
|
|
//存放产品分类统计数据
|
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
@@ -754,30 +812,30 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
//计算统计合计
|
|
|
Integer amount = productInfos.stream().map(productInfo -> productInfo.getCount()).reduce(Integer::sum).orElse(0);
|
|
|
|
|
|
- map.put("amount",amount);
|
|
|
+ map.put("amount", amount);
|
|
|
//获取产品类型统计数据
|
|
|
DynamicDataSourceContextHolder.push(SourceConstant.BASE);
|
|
|
List<DictTenantDataVo> dictTenantDataVoList = getDict("product_type");
|
|
|
DynamicDataSourceContextHolder.poll();
|
|
|
- if (dictTenantDataVoList.size()==0){
|
|
|
+ if (dictTenantDataVoList.size() == 0) {
|
|
|
throw new ServiceException("数据异常:产品没有设置产品类型字典,请先添加");
|
|
|
}
|
|
|
|
|
|
for (DictTenantDataVo dictTenantDataVo : dictTenantDataVoList) {
|
|
|
Map typeMap = new HashMap();
|
|
|
//设置初始值
|
|
|
- typeMap.put("type",dictTenantDataVo.getDictValue());
|
|
|
- typeMap.put("count",0);
|
|
|
+ typeMap.put("type", dictTenantDataVo.getDictValue());
|
|
|
+ typeMap.put("count", 0);
|
|
|
|
|
|
//赋值
|
|
|
List<ProductInfo> productInfoList = productInfoMap.get(dictTenantDataVo.getDictKey());
|
|
|
- if (CollectionUtils.isNotEmpty(productInfoList)){
|
|
|
- typeMap.put("count",productInfoList.get(0).getCount());
|
|
|
+ if (CollectionUtils.isNotEmpty(productInfoList)) {
|
|
|
+ typeMap.put("count", productInfoList.get(0).getCount());
|
|
|
}
|
|
|
list.add(typeMap);
|
|
|
|
|
|
}
|
|
|
- map.put("typeList",list);
|
|
|
+ map.put("typeList", list);
|
|
|
return map;
|
|
|
}
|
|
|
|