|
@@ -1,8 +1,8 @@
|
|
|
package com.fjhx.service.supplier.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -12,6 +12,7 @@ import com.fjhx.entity.supplier.Supplier;
|
|
|
import com.fjhx.entity.supplier.SupplierBank;
|
|
|
import com.fjhx.entity.supplier.SupplierContacts;
|
|
|
import com.fjhx.entity.supplier.SupplierKeep;
|
|
|
+import com.fjhx.enums.MaterialTypeEnum;
|
|
|
import com.fjhx.mapper.supplier.SupplierMapper;
|
|
|
import com.fjhx.params.supplier.SupplierKeepVo;
|
|
|
import com.fjhx.params.supplier.SupplierVo;
|
|
@@ -20,11 +21,12 @@ import com.fjhx.service.supplier.SupplierBankService;
|
|
|
import com.fjhx.service.supplier.SupplierContactsService;
|
|
|
import com.fjhx.service.supplier.SupplierKeepService;
|
|
|
import com.fjhx.service.supplier.SupplierService;
|
|
|
-import com.fjhx.utils.WrapperUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -52,16 +54,11 @@ public class SupplierServiceImpl extends ServiceImpl<SupplierMapper, Supplier> i
|
|
|
@Autowired
|
|
|
private CommonFileService commonFileService;
|
|
|
|
|
|
- @Override
|
|
|
- public Page<Supplier> getPage(Map<String, String> condition) {
|
|
|
-
|
|
|
- QueryWrapper<Supplier> wrapper = Wrappers.query();
|
|
|
-
|
|
|
- WrapperUtil.init(condition, wrapper)
|
|
|
- .createTimeDesc();
|
|
|
+ private static final Object obj = new Object();
|
|
|
|
|
|
- Page<Supplier> page = page(condition, wrapper);
|
|
|
- return page;
|
|
|
+ @Override
|
|
|
+ public Page<Map<String, Object>> getPage(Map<String, String> condition) {
|
|
|
+ return baseMapper.getPage(createPage(condition), condition);
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -70,7 +67,11 @@ public class SupplierServiceImpl extends ServiceImpl<SupplierMapper, Supplier> i
|
|
|
|
|
|
// TODO 创建供应商账号
|
|
|
|
|
|
- save(supplierVo);
|
|
|
+ synchronized (obj) {
|
|
|
+ String supplierCode = getSupplierCode();
|
|
|
+ supplierVo.setCode(supplierCode);
|
|
|
+ save(supplierVo);
|
|
|
+ }
|
|
|
|
|
|
Long id = supplierVo.getId();
|
|
|
|
|
@@ -180,23 +181,83 @@ public class SupplierServiceImpl extends ServiceImpl<SupplierMapper, Supplier> i
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Map<String, Object>> getSafetyWarnDayList() {
|
|
|
- List<Map<String, Object>> safetyWarnDayList = baseMapper.getSafetyWarnDayList();
|
|
|
+ public List<Map<String, Object>> getSafetyWarnDay() {
|
|
|
+ List<Map<String, Object>> safetyWarnDayList = baseMapper.getSafetyWarnDay();
|
|
|
|
|
|
safetyWarnDayList.forEach(item -> {
|
|
|
- Integer value = (Integer) item.get("value");
|
|
|
+ Integer value = Convert.toInt(item.get("value"));
|
|
|
+ Integer count = Convert.toInt(item.get("count"));
|
|
|
String label;
|
|
|
|
|
|
-// switch (value) {
|
|
|
-// case 1:
|
|
|
-// }
|
|
|
+ switch (value) {
|
|
|
+ case 1:
|
|
|
+ label = getLabel("0~5天", count);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ label = getLabel("6~15天", count);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ label = getLabel("16~30天", count);
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ label = getLabel("31~45天", count);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ label = getLabel("45天以上", count);
|
|
|
+ }
|
|
|
+ item.put("label", label);
|
|
|
+ });
|
|
|
|
|
|
-// item.put("label", label);
|
|
|
+ return safetyWarnDayList;
|
|
|
+ }
|
|
|
|
|
|
- });
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> getStatistics(Map<String, String> condition) {
|
|
|
|
|
|
+ List<Map<String, Object>> result = new ArrayList<>();
|
|
|
|
|
|
- return safetyWarnDayList;
|
|
|
+ // 统计全部数量
|
|
|
+ HashMap<String, Object> allMap = new HashMap<>();
|
|
|
+ Integer count = baseMapper.allCount(condition);
|
|
|
+ allMap.put("label", "全部(" + count + ")");
|
|
|
+ result.add(allMap);
|
|
|
+
|
|
|
+
|
|
|
+ List<Map<String, Object>> list = baseMapper.getStatistics(condition);
|
|
|
+
|
|
|
+ Map<Integer, Integer> map = list.stream().collect(Collectors.toMap(
|
|
|
+ item -> Convert.toInt(item.get("type")),
|
|
|
+ item -> Convert.toInt(item.get("count"))));
|
|
|
+
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
+ Map<String, Object> item = new HashMap<>();
|
|
|
+ Integer itemCount = map.get(i);
|
|
|
+ item.put("label", MaterialTypeEnum.getName(i) + "(" + (itemCount == null ? 0 : itemCount) + ")");
|
|
|
+ item.put("value", i);
|
|
|
+ result.add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成label
|
|
|
+ */
|
|
|
+ private String getLabel(String str, Integer count) {
|
|
|
+ return String.format("%s(%s)", str, count);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成供应商编号
|
|
|
+ */
|
|
|
+ private String getSupplierCode() {
|
|
|
+ Supplier supplier = getOne(Wrappers.<Supplier>lambdaQuery()
|
|
|
+ .likeRight(Supplier::getCode, "C")
|
|
|
+ .orderByDesc(Supplier::getCode).last("limit 1"));
|
|
|
+ if (supplier == null) {
|
|
|
+ return "C0001";
|
|
|
+ }
|
|
|
+ return "C" + (Convert.toInt(supplier.getCode().replace("C", "")) + 1);
|
|
|
}
|
|
|
|
|
|
}
|