|
@@ -2,30 +2,30 @@ package com.fjhx.service.contract.impl;
|
|
|
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.base.Condition;
|
|
|
import com.fjhx.constants.ConfigConstant;
|
|
|
import com.fjhx.entity.apply.ApplyPurchaseDetails;
|
|
|
import com.fjhx.entity.contract.Contract;
|
|
|
import com.fjhx.entity.contract.ContractDetails;
|
|
|
import com.fjhx.enums.FlowStatusEnum;
|
|
|
+import com.fjhx.enums.MaterialTypeEnum;
|
|
|
import com.fjhx.mapper.contract.ContractMapper;
|
|
|
import com.fjhx.params.apply.ApplyPurchaseVo;
|
|
|
import com.fjhx.params.contract.ContractVo;
|
|
|
import com.fjhx.service.common.CommonConfigService;
|
|
|
import com.fjhx.service.contract.ContractDetailsService;
|
|
|
import com.fjhx.service.contract.ContractService;
|
|
|
-import com.fjhx.utils.WrapperUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
* <p>
|
|
@@ -45,18 +45,6 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
private ContractDetailsService contractDetailsService;
|
|
|
|
|
|
@Override
|
|
|
- public Page<Contract> getPage(Map<String, String> condition) {
|
|
|
-
|
|
|
- QueryWrapper<Contract> wrapper = Wrappers.query();
|
|
|
-
|
|
|
- WrapperUtil.init(condition, wrapper)
|
|
|
- .createTimeDesc();
|
|
|
-
|
|
|
- Page<Contract> page = page(condition, wrapper);
|
|
|
- return page;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
public void add(ContractVo contractVo) {
|
|
|
save(contractVo);
|
|
|
}
|
|
@@ -126,6 +114,75 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<Integer, Map<String, Object>> amountStatistics(Condition condition) {
|
|
|
+
|
|
|
+ Integer flowStatus = condition.getFlowStatus();
|
|
|
+ String keyword = condition.getKeyword();
|
|
|
+
|
|
|
+ QueryWrapper<Object> wrapper = Wrappers.query()
|
|
|
+ .func(flowStatus != null, q -> {
|
|
|
+ if (ObjectUtil.equals(flowStatus, 1)) {
|
|
|
+ q.in("c.flow_status", 0, 1);
|
|
|
+ } else {
|
|
|
+ q.eq("c.flow_status", flowStatus);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .and(q -> q.like("c.code", keyword)
|
|
|
+ .or().like("cd.apply_purchase_code", keyword)
|
|
|
+ .or().like("m.code", keyword)
|
|
|
+ .or().like("m.name", keyword)
|
|
|
+ .or().like("s.name", keyword)
|
|
|
+ )
|
|
|
+ .orderByAsc("m.technology_type")
|
|
|
+ .groupBy("m.technology_type");
|
|
|
+
|
|
|
+ List<Map<String, Object>> list = baseMapper.amountStatistics(wrapper);
|
|
|
+
|
|
|
+ Map<Integer, Map<String, Object>> result = list.stream().collect(Collectors.toMap(
|
|
|
+ item -> Convert.toInt(item.get("type")),
|
|
|
+ item -> item
|
|
|
+ ));
|
|
|
+
|
|
|
+
|
|
|
+ BigDecimal totalAmountMoney = BigDecimal.ZERO;
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
+
|
|
|
+ Map<String, Object> itemMap = result.get(i);
|
|
|
+
|
|
|
+ if (itemMap == null) {
|
|
|
+ itemMap = new HashMap<>();
|
|
|
+ itemMap.put("type", i);
|
|
|
+ itemMap.put("amountMoney", BigDecimal.ZERO);
|
|
|
+ result.put(i, itemMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ itemMap.put("name", MaterialTypeEnum.getName(i));
|
|
|
+
|
|
|
+ totalAmountMoney = totalAmountMoney.add(Convert.toBigDecimal(itemMap.get("amountMoney")));
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> totalMap = new HashMap<>();
|
|
|
+ totalMap.put("amountMoney", totalAmountMoney);
|
|
|
+ totalMap.put("name", "总额");
|
|
|
+ result.put(5, totalMap);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<Map<String, Object>> getPage(Condition condition) {
|
|
|
+ QueryWrapper<Object> wrapper = getWrapper(condition);
|
|
|
+ return baseMapper.getPage(condition.getPage(), wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> getList(Condition condition) {
|
|
|
+ QueryWrapper<Object> wrapper = getWrapper(condition);
|
|
|
+ return baseMapper.getList(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
* 获取当天合同编号前缀
|
|
|
*
|
|
@@ -174,4 +231,26 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
return codePrefix + codeSuffixStr;
|
|
|
}
|
|
|
|
|
|
+ private QueryWrapper<Object> getWrapper(Condition condition) {
|
|
|
+ Integer flowStatus = condition.getFlowStatus();
|
|
|
+ String keyword = condition.getKeyword();
|
|
|
+ Integer type = condition.getType();
|
|
|
+
|
|
|
+ return Wrappers.query()
|
|
|
+ .func(flowStatus != null, q -> {
|
|
|
+ if (ObjectUtil.equals(flowStatus, 1)) {
|
|
|
+ q.in("c.flow_status", 0, 1);
|
|
|
+ } else {
|
|
|
+ q.eq("c.flow_status", flowStatus);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .eq(type != null, "m.technology_type", type)
|
|
|
+ .and(q -> q.like("c.code", keyword)
|
|
|
+ .or().like("cd.apply_purchase_code", keyword)
|
|
|
+ .or().like("m.code", keyword)
|
|
|
+ .or().like("m.name", keyword)
|
|
|
+ .or().like("s.name", keyword)
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
}
|