|
@@ -331,6 +331,7 @@ public class SaleOrderServiceImpl implements ISaleOrderService {
|
|
|
@Transactional
|
|
|
public int updateOrder(SaleOrder saleOrder) {
|
|
|
ProductInvoice productInvoice1 = new ProductInvoice();
|
|
|
+ // 发货单/通知单-》完成状态
|
|
|
productInvoice1.setStatus("2");
|
|
|
productInvoice1.setSaleOrderNo(saleOrder.getSaleNo());
|
|
|
productInvoiceMapper.updateProductInvoiceBySaleNo(productInvoice1);
|
|
@@ -384,19 +385,19 @@ public class SaleOrderServiceImpl implements ISaleOrderService {
|
|
|
public int editOutsourceOrder(SaleOrderVO vo) {
|
|
|
SaleOrder saleOrder = new SaleOrder();
|
|
|
BeanUtils.copyBeanProp(saleOrder, vo);
|
|
|
- if(vo.getSaleProductsList().size() > 0){
|
|
|
+ if (vo.getSaleProductsList().size() > 0) {
|
|
|
//修改销售单货品
|
|
|
LinkedList<SaleProducts> addSaleProductsList = new LinkedList<>();
|
|
|
LinkedList<SaleProducts> editSaleProductsList = new LinkedList<>();
|
|
|
Set<Long> ids = new HashSet<>();
|
|
|
- for (SaleProducts saleProducts : vo.getSaleProductsList()){
|
|
|
- if(saleProducts.getId() != null){
|
|
|
+ for (SaleProducts saleProducts : vo.getSaleProductsList()) {
|
|
|
+ if (saleProducts.getId() != null) {
|
|
|
editSaleProductsList.add(saleProducts);
|
|
|
ids.add(saleProducts.getId());
|
|
|
saleProducts.setUpdateBy(SecurityUtils.getUsername());
|
|
|
saleProducts.setUpdateById(SecurityUtils.getUserId());
|
|
|
saleProducts.setUpdateTime(DateUtils.getNowDate());
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
saleProducts.setCreateBy(SecurityUtils.getUsername());
|
|
|
saleProducts.setCreateById(SecurityUtils.getUserId());
|
|
|
saleProducts.setCreateTime(DateUtils.getNowDate());
|
|
@@ -404,13 +405,13 @@ public class SaleOrderServiceImpl implements ISaleOrderService {
|
|
|
}
|
|
|
Set<Long> allId = saleProductsMapper.selectSaleProductsIdsBySaleNo(vo.getSaleNo());
|
|
|
allId.removeAll(ids);
|
|
|
- if(allId.size() > 0){
|
|
|
+ if (allId.size() > 0) {
|
|
|
saleProductsMapper.deleteSaleProductsByIds(new ArrayList<>(allId));
|
|
|
}
|
|
|
- if(addSaleProductsList.size() > 0){
|
|
|
+ if (addSaleProductsList.size() > 0) {
|
|
|
saleProductsMapper.batchInsertSaleProducts(addSaleProductsList);
|
|
|
}
|
|
|
- if (editSaleProductsList.size() > 0){
|
|
|
+ if (editSaleProductsList.size() > 0) {
|
|
|
editSaleProductsList.forEach(s -> {
|
|
|
saleProductsMapper.updateSaleProducts(s);
|
|
|
});
|
|
@@ -441,21 +442,33 @@ public class SaleOrderServiceImpl implements ISaleOrderService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<SaleProductsVo> printOutsourceOrderList(String saleNo) {
|
|
|
+ public List<SaleProductsVo> printOutsourceOrderList(String saleNo, String batchNumber) {
|
|
|
//根据销售编号获取通知单信息
|
|
|
ProductInvoice productInvoice = productInvoiceMapper.selectProductInvoiceBySaleOrderNo(saleNo);
|
|
|
- if(productInvoice == null){
|
|
|
+ if (productInvoice == null) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
- //获取最后一个批次出库的产品
|
|
|
- List<SaleProductsVo> saleProductsVos = saleOrderMapper.printOutsourceOrderList(productInvoice.getNoticeNumber(),saleNo);
|
|
|
+ // 获取当前订单出库产品信息
|
|
|
+ List<SaleProductsVo> saleProductsVos = saleOrderMapper.printOutsourceOrderList(productInvoice.getNoticeNumber(), saleNo, batchNumber);
|
|
|
return saleProductsVos;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 订单产品新增应收明细
|
|
|
+ * 记录批次
|
|
|
+ *
|
|
|
+ * @param saleAccountsReceivableDetailList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public int printOutsourceOrder(List<SaleAccountsReceivableDetail> saleAccountsReceivableDetailList) {
|
|
|
- // 查询当前批次出库记录
|
|
|
+ public int recordBatch(List<SaleAccountsReceivableDetail> saleAccountsReceivableDetailList) {
|
|
|
+ // // 得到当前订单出库单
|
|
|
+ // ProductInvoice productInvoice = productInvoiceMapper.selectProductInvoiceBySaleOrderNo(saleNo);
|
|
|
+ // // 获取当前订单出库产品信息
|
|
|
+ // List<SaleProductsVo> saleProductsVos = saleOrderMapper.printOutsourceOrderList(productInvoice.getNoticeNumber(), saleNo, "没用");
|
|
|
+ // List<SaleAccountsReceivableDetail> saleAccountsReceivableDetailList = saleOrderMapper.printOutsourceOrder(saleNo);
|
|
|
+ // 查询当前批次出库记录 -- 根据通知单号获取批次号
|
|
|
Long batchNumber = productOutboundRecordBatchMapper.selectBatchNumberByNoticeNumber(saleAccountsReceivableDetailList.get(0).getNoticeNumber());
|
|
|
//根据销售单号查询销售单详情
|
|
|
SaleOrder saleOrder = saleOrderMapper.selectSaleOrderBySaleNo(saleAccountsReceivableDetailList.get(0).getSaleNo());
|
|
@@ -463,29 +476,36 @@ public class SaleOrderServiceImpl implements ISaleOrderService {
|
|
|
Customer customer = customerMapper.selectCustomerByCustomerNo(saleOrder.getSaleCustomNo());
|
|
|
//客户余额
|
|
|
Double amount = customer.getAmount();
|
|
|
-
|
|
|
- for (SaleAccountsReceivableDetail saleAccountsReceivableDetail : saleAccountsReceivableDetailList){
|
|
|
- saleAccountsReceivableDetail.setCustomerId(customer.getId());
|
|
|
+ for (SaleAccountsReceivableDetail item : saleAccountsReceivableDetailList) {
|
|
|
+ item.setCustomerId(customer.getId());
|
|
|
//加后余额
|
|
|
- Double subtractAmount = amount + saleAccountsReceivableDetail.getAmountReceivable();
|
|
|
- amount += saleAccountsReceivableDetail.getAmountReceivable();
|
|
|
- saleAccountsReceivableDetail.setAmounts(handlingWeight(subtractAmount));
|
|
|
- saleAccountsReceivableDetail.setBatchNumber(batchNumber);
|
|
|
- saleAccountsReceivableDetail.setCreateBy(SecurityUtils.getUsername());
|
|
|
- saleAccountsReceivableDetail.setCreateById(SecurityUtils.getUserId());
|
|
|
- saleAccountsReceivableDetail.setCreateTime(DateUtils.getNowDate());
|
|
|
+ Double subtractAmount = amount + item.getAmountReceivable();
|
|
|
+ amount += item.getAmountReceivable();
|
|
|
+ item.setAmounts(handlingWeight(subtractAmount));
|
|
|
+ item.setBatchNumber(batchNumber);
|
|
|
+ item.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ item.setCreateById(SecurityUtils.getUserId());
|
|
|
+ item.setCreateTime(DateUtils.getNowDate());
|
|
|
+ // 当前产品出库记录的唯一标识
|
|
|
+ item.setDataId(item.getId().toString());
|
|
|
}
|
|
|
- if (saleAccountsReceivableDetailList.size() > 0 ){
|
|
|
+ if (saleAccountsReceivableDetailList.size() > 0) {
|
|
|
+ // 新增应收帐明细
|
|
|
saleAccountsReceivableDetailMapper.batchInsertSaleAccountsReceivableDetail(saleAccountsReceivableDetailList);
|
|
|
}
|
|
|
// 记录已发货品信息
|
|
|
List<Long> list = productOutboundRecordMapper.selectOutboundRecordNo(saleAccountsReceivableDetailList.get(0).getNoticeNumber());
|
|
|
- if(list.size() > 0){
|
|
|
+ if (list.size() > 0) {
|
|
|
List<ProductOutboundRecordBatch> productOutboundRecordBatchList = new ArrayList<>();
|
|
|
- for (Long id : list){
|
|
|
+ for (Long id : list) {
|
|
|
ProductOutboundRecordBatch productOutboundRecordBatch = new ProductOutboundRecordBatch();
|
|
|
+ // 当前批次
|
|
|
productOutboundRecordBatch.setBatchNumber(batchNumber);
|
|
|
+ // 销售单编号
|
|
|
+ productOutboundRecordBatch.setSaleNo(saleAccountsReceivableDetailList.get(0).getSaleNo());
|
|
|
+ // 出库单ID
|
|
|
productOutboundRecordBatch.setOutboundRecordId(id);
|
|
|
+ // 通知单编号
|
|
|
productOutboundRecordBatch.setNoticeNumber(saleAccountsReceivableDetailList.get(0).getNoticeNumber());
|
|
|
productOutboundRecordBatch.setCreateBy(SecurityUtils.getUsername());
|
|
|
productOutboundRecordBatch.setCreateById(SecurityUtils.getUserId());
|
|
@@ -495,22 +515,49 @@ public class SaleOrderServiceImpl implements ISaleOrderService {
|
|
|
//新增批次出库记录
|
|
|
productOutboundRecordBatchMapper.batchInsertProductOutboundRecordBatch(productOutboundRecordBatchList);
|
|
|
}
|
|
|
- //修改客户余额
|
|
|
-// customer.setAmount(handlingWeight(amount));
|
|
|
-// return customerMapper.updateCustomer(customer);
|
|
|
+ //修改客户余额 审核通过修改客户余额
|
|
|
+ // customer.setAmount(handlingWeight(amount));
|
|
|
+ // return customerMapper.updateCustomer(customer);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public int againRecordBatch(SaleAccountsReceivableDetail saleAccountsReceivableDetail) {
|
|
|
+ //根据客户Id查询客户信息和余额
|
|
|
+ Customer customer = customerMapper.selectCustomerById(saleAccountsReceivableDetail.getCustomerId());
|
|
|
+ //客户余额
|
|
|
+ Double amount = customer.getAmount();
|
|
|
+ saleAccountsReceivableDetail.setCustomerId(customer.getId());
|
|
|
+ //加后余额
|
|
|
+ Double subtractAmount = amount + saleAccountsReceivableDetail.getAmountReceivable();
|
|
|
+ amount += saleAccountsReceivableDetail.getAmountReceivable();
|
|
|
+ saleAccountsReceivableDetail.setAmounts(handlingWeight(subtractAmount));
|
|
|
+ saleAccountsReceivableDetail.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ saleAccountsReceivableDetail.setCreateById(SecurityUtils.getUserId());
|
|
|
+ saleAccountsReceivableDetail.setCreateTime(DateUtils.getNowDate());
|
|
|
+ // 当前产品出库记录的唯一标识
|
|
|
+ // saleAccountsReceivableDetailList.setDataId(saleAccountsReceivableDetailList.getId().toString());
|
|
|
+ List<SaleAccountsReceivableDetail> list = new ArrayList<>();
|
|
|
+ list.add(saleAccountsReceivableDetail);
|
|
|
+ // 新增应收帐明细
|
|
|
+ saleAccountsReceivableDetailMapper.batchInsertSaleAccountsReceivableDetail(list);
|
|
|
+ // 修改当前订单出库
|
|
|
+ ProductOutboundRecordBatch productOutboundRecordBatch = new ProductOutboundRecordBatch();
|
|
|
+ productOutboundRecordBatch.setId(Long.valueOf(saleAccountsReceivableDetail.getBatchId()));
|
|
|
+ productOutboundRecordBatch.setBatchState('0');
|
|
|
+ productOutboundRecordBatchMapper.updateProductOutboundRecordBatch(productOutboundRecordBatch);
|
|
|
+
|
|
|
+ // 判断修改订单状态
|
|
|
+ if (saleAccountsReceivableDetail.isOrderUpdate()) {
|
|
|
+ SaleOrder saleOrder = new SaleOrder();
|
|
|
+ saleOrder.setSaleNo(saleAccountsReceivableDetail.getSaleNo());
|
|
|
+ saleOrder.setStatus("9"); // 已出库
|
|
|
+ saleOrderMapper.updateSaleOrderBySaleNo(saleOrder);
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -518,34 +565,33 @@ public class SaleOrderServiceImpl implements ISaleOrderService {
|
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
|
//查询下单前10名客户编号
|
|
|
List<String> customerNoList = saleOrderMapper.saleOrderTop10CustomerNoList();
|
|
|
- if(customerNoList.size() > 0){
|
|
|
+ if (customerNoList.size() > 0) {
|
|
|
//查询销售单数量
|
|
|
List<Map<String, Object>> saleOrderList = saleOrderMapper.saleOrderTop10List(customerNoList);
|
|
|
//查询零售单数量
|
|
|
List<Map<String, Object>> retailList = saleOrderMapper.saleRetailOrderTop10List(customerNoList);
|
|
|
|
|
|
- for (Map<String, Object> map : saleOrderList){
|
|
|
+ for (Map<String, Object> map : saleOrderList) {
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
- result.put("customerNo",map.get("customerNo"));
|
|
|
- result.put("customerName",map.get("customerName"));
|
|
|
-// result.put("orderCount",map.get("orderCount"));
|
|
|
+ result.put("customerNo", map.get("customerNo"));
|
|
|
+ result.put("customerName", map.get("customerName"));
|
|
|
+ // result.put("orderCount",map.get("orderCount"));
|
|
|
Long orderCount = (Long) map.get("orderCount");
|
|
|
Double weight = (Double) map.get("weight");
|
|
|
- for (Map<String, Object> retail : retailList){
|
|
|
- if(map.get("customerNo").toString().equals(retail.get("customerNo").toString())){
|
|
|
+ for (Map<String, Object> retail : retailList) {
|
|
|
+ if (map.get("customerNo").toString().equals(retail.get("customerNo").toString())) {
|
|
|
weight = weight + (Double) retail.get("weight");
|
|
|
- map.put("weight",handlingWeight(weight));
|
|
|
+ map.put("weight", handlingWeight(weight));
|
|
|
orderCount += (Long) retail.get("orderCount");
|
|
|
- map.put("orderCount",orderCount);
|
|
|
+ map.put("orderCount", orderCount);
|
|
|
}
|
|
|
}
|
|
|
- result.put("weight",handlingWeight(weight));
|
|
|
- result.put("orderCount",orderCount);
|
|
|
+ result.put("weight", handlingWeight(weight));
|
|
|
+ result.put("orderCount", orderCount);
|
|
|
list.add(result);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
return list;
|
|
|
}
|
|
|
|
|
@@ -553,29 +599,29 @@ public class SaleOrderServiceImpl implements ISaleOrderService {
|
|
|
public Map<String, Object> customerStatistics(Map<String, Object> map) {
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
//销售单数量
|
|
|
- Map<String, Object> saleOrderCount = saleOrderMapper.selectSaleOrderCountByCustomerNo(map.get("customerNo").toString(),map.get("timeType").toString(),map.get("timeParam").toString());
|
|
|
+ Map<String, Object> saleOrderCount = saleOrderMapper.selectSaleOrderCountByCustomerNo(map.get("customerNo").toString(), map.get("timeType").toString(), map.get("timeParam").toString());
|
|
|
//零售单数量
|
|
|
- Map<String, Object> retailOrderCount = saleOrderMapper.selectRetailOrderCountByCustomerNo(map.get("customerNo").toString(),map.get("timeType").toString(),map.get("timeParam").toString());
|
|
|
+ Map<String, Object> retailOrderCount = saleOrderMapper.selectRetailOrderCountByCustomerNo(map.get("customerNo").toString(), map.get("timeType").toString(), map.get("timeParam").toString());
|
|
|
|
|
|
Long saleCount = saleOrderCount.get("orderCount") == null ? 0L : (Long) saleOrderCount.get("orderCount");
|
|
|
Long retailCount = retailOrderCount.get("orderCount") == null ? 0L : (Long) retailOrderCount.get("orderCount");
|
|
|
|
|
|
- result.put("orderCount",saleCount + retailCount);
|
|
|
+ result.put("orderCount", saleCount + retailCount);
|
|
|
|
|
|
|
|
|
// result.put("orderCount",saleOrderCount);
|
|
|
|
|
|
//各个货品重量
|
|
|
//销售单
|
|
|
- List<Map<String, Object>> saleList = saleOrderMapper.selectSaleOrderProductCountByCustomerNo(map.get("customerNo").toString(),map.get("timeType").toString(), map.get("timeParam").toString());
|
|
|
+ List<Map<String, Object>> saleList = saleOrderMapper.selectSaleOrderProductCountByCustomerNo(map.get("customerNo").toString(), map.get("timeType").toString(), map.get("timeParam").toString());
|
|
|
//零售单
|
|
|
- List<Map<String, Object>> retailList = saleOrderMapper.selectRetailOrderProductCountByCustomerNo(map.get("customerNo").toString(),map.get("timeType").toString(), map.get("timeParam").toString());
|
|
|
+ List<Map<String, Object>> retailList = saleOrderMapper.selectRetailOrderProductCountByCustomerNo(map.get("customerNo").toString(), map.get("timeType").toString(), map.get("timeParam").toString());
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> addList = new ArrayList<>();
|
|
|
|
|
|
//筛选出销售单中不存在的零售单货品
|
|
|
- for (Map<String, Object> retailItem : retailList){
|
|
|
+ for (Map<String, Object> retailItem : retailList) {
|
|
|
String saleProductId = retailItem.get("productId").toString();
|
|
|
String saleProductColour = retailItem.get("productColour").toString();
|
|
|
String customerNo = retailItem.get("customerNo").toString();
|
|
@@ -585,36 +631,34 @@ public class SaleOrderServiceImpl implements ISaleOrderService {
|
|
|
saleProductColour.equals(saleItem.get("productColour").toString()) &&
|
|
|
customerNo.equals(saleItem.get("customerNo").toString())
|
|
|
);
|
|
|
- if(!exists){
|
|
|
+ if (!exists) {
|
|
|
addList.add(retailItem);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- for (Map<String, Object> saleItem : saleList){
|
|
|
+ for (Map<String, Object> saleItem : saleList) {
|
|
|
String saleProductId = saleItem.get("productId").toString();
|
|
|
String saleProductColour = saleItem.get("productColour").toString();
|
|
|
String customerNo = saleItem.get("customerNo").toString();
|
|
|
Double weight = (Double) saleItem.get("weight");
|
|
|
|
|
|
- for (Map<String, Object> retailItem : retailList){
|
|
|
- if(retailItem.get("productId").toString().equals(saleProductId) && retailItem.get("productColour").toString().equals(saleProductColour) && customerNo.equals(retailItem.get("customerNo").toString())){
|
|
|
+ for (Map<String, Object> retailItem : retailList) {
|
|
|
+ if (retailItem.get("productId").toString().equals(saleProductId) && retailItem.get("productColour").toString().equals(saleProductColour) && customerNo.equals(retailItem.get("customerNo").toString())) {
|
|
|
Double weight1 = (Double) retailItem.get("weight");
|
|
|
weight += weight1;
|
|
|
- saleItem.put("weight",handlingWeight(weight));
|
|
|
+ saleItem.put("weight", handlingWeight(weight));
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- if(addList.size() > 0){
|
|
|
+ if (addList.size() > 0) {
|
|
|
saleList.addAll(addList);
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- result.put("productInfo",saleList);
|
|
|
+ result.put("productInfo", saleList);
|
|
|
|
|
|
return result;
|
|
|
// return saleOrderCount;
|
|
@@ -733,7 +777,7 @@ public class SaleOrderServiceImpl implements ISaleOrderService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Map<String, Object>> saleOrderCountBySalesman(Map<String, Object> map,Long tenantId) {
|
|
|
+ public List<Map<String, Object>> saleOrderCountBySalesman(Map<String, Object> map, Long tenantId) {
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
//销售单量
|
|
|
List<Map<String, Object>> saleCount = saleOrderMapper.saleOrderCountBySalesman(map.get("timeType").toString(), map.get("timeParam").toString());
|
|
@@ -745,73 +789,73 @@ public class SaleOrderServiceImpl implements ISaleOrderService {
|
|
|
List<Map<String, Object>> retailProductCount = saleOrderMapper.retailOrderProductCountBySalesman(map.get("timeType").toString(), map.get("timeParam").toString());
|
|
|
|
|
|
List<Map<String, Object>> addList = new ArrayList<>();
|
|
|
- for (Map<String, Object> retailItem : retailCount){
|
|
|
+ for (Map<String, Object> retailItem : retailCount) {
|
|
|
String saleSalesman = retailItem.get("saleId").toString();
|
|
|
boolean exists = saleCount.stream()
|
|
|
.anyMatch(saleItem ->
|
|
|
saleSalesman.equals(saleItem.get("saleId").toString())
|
|
|
);
|
|
|
- if(!exists){
|
|
|
+ if (!exists) {
|
|
|
addList.add(retailItem);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- for (Map<String, Object> saleItem : saleCount){
|
|
|
+ for (Map<String, Object> saleItem : saleCount) {
|
|
|
String saleId = saleItem.get("saleId").toString();
|
|
|
Long orderCount = (Long) saleItem.get("orderCount");
|
|
|
|
|
|
- for (Map<String, Object> retailItem : retailCount){
|
|
|
- if(retailItem.get("saleId").toString().equals(saleId)){
|
|
|
+ for (Map<String, Object> retailItem : retailCount) {
|
|
|
+ if (retailItem.get("saleId").toString().equals(saleId)) {
|
|
|
Long orderCount1 = (Long) retailItem.get("orderCount");
|
|
|
orderCount += orderCount1;
|
|
|
- saleItem.put("orderCount",orderCount);
|
|
|
+ saleItem.put("orderCount", orderCount);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- if(addList.size() > 0){
|
|
|
+ if (addList.size() > 0) {
|
|
|
saleCount.addAll(addList);
|
|
|
}
|
|
|
List<Map<String, Object>> addList1 = new ArrayList<>();
|
|
|
- for (Map<String, Object> retailItem : retailProductCount){
|
|
|
+ for (Map<String, Object> retailItem : retailProductCount) {
|
|
|
String saleSalesman = retailItem.get("saleId").toString();
|
|
|
boolean exists = saleProductCount.stream()
|
|
|
.anyMatch(saleItem ->
|
|
|
saleSalesman.equals(saleItem.get("saleId").toString())
|
|
|
);
|
|
|
- if(!exists){
|
|
|
+ if (!exists) {
|
|
|
addList1.add(retailItem);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- for (Map<String, Object> saleItem : saleProductCount){
|
|
|
+ for (Map<String, Object> saleItem : saleProductCount) {
|
|
|
String saleId = saleItem.get("saleId").toString();
|
|
|
Double weight = (Double) saleItem.get("weight");
|
|
|
- for (Map<String, Object> retailItem : retailProductCount){
|
|
|
- if(retailItem.get("saleId").toString().equals(saleId)){
|
|
|
+ for (Map<String, Object> retailItem : retailProductCount) {
|
|
|
+ if (retailItem.get("saleId").toString().equals(saleId)) {
|
|
|
Double weight1 = (Double) retailItem.get("weight");
|
|
|
weight += weight1;
|
|
|
- saleItem.put("weight",handlingWeight(weight));
|
|
|
+ saleItem.put("weight", handlingWeight(weight));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (addList1.size() > 0){
|
|
|
+ if (addList1.size() > 0) {
|
|
|
saleProductCount.addAll(addList1);
|
|
|
}
|
|
|
|
|
|
List<SysUser> salesmanList = iSysUserService.selectUserListByRoleKey("salesman", tenantId);
|
|
|
- for (Map<String, Object> saleItem : saleCount){
|
|
|
+ for (Map<String, Object> saleItem : saleCount) {
|
|
|
String saleId = saleItem.get("saleId").toString();
|
|
|
- for (Map<String, Object> retailItem : saleProductCount){
|
|
|
- if(retailItem.get("saleId").toString().equals(saleId)){
|
|
|
- saleItem.put("weight",retailItem.get("weight"));
|
|
|
+ for (Map<String, Object> retailItem : saleProductCount) {
|
|
|
+ if (retailItem.get("saleId").toString().equals(saleId)) {
|
|
|
+ saleItem.put("weight", retailItem.get("weight"));
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- for (SysUser sysUser : salesmanList){
|
|
|
- if(sysUser.getUserId().toString().equals(saleId)){
|
|
|
- saleItem.put("salesman",sysUser.getNickName());
|
|
|
+ for (SysUser sysUser : salesmanList) {
|
|
|
+ if (sysUser.getUserId().toString().equals(saleId)) {
|
|
|
+ saleItem.put("salesman", sysUser.getNickName());
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -831,28 +875,28 @@ public class SaleOrderServiceImpl implements ISaleOrderService {
|
|
|
|
|
|
List<Map<String, Object>> addList = new ArrayList<>();
|
|
|
|
|
|
- for (Map<String, Object> retailItem : retailWeight){
|
|
|
+ for (Map<String, Object> retailItem : retailWeight) {
|
|
|
String productType = retailItem.get("productType").toString();
|
|
|
boolean exists = saleWeight.stream()
|
|
|
.anyMatch(saleItem ->
|
|
|
productType.equals(saleItem.get("productType").toString())
|
|
|
);
|
|
|
- if(!exists){
|
|
|
+ if (!exists) {
|
|
|
addList.add(retailItem);
|
|
|
}
|
|
|
}
|
|
|
- for (Map<String, Object> saleItem : saleWeight){
|
|
|
+ for (Map<String, Object> saleItem : saleWeight) {
|
|
|
String productType = saleItem.get("productType").toString();
|
|
|
Double weight = (Double) saleItem.get("weight");
|
|
|
- for (Map<String, Object> retailItem : retailWeight){
|
|
|
- if(retailItem.get("productType").toString().equals(productType)){
|
|
|
+ for (Map<String, Object> retailItem : retailWeight) {
|
|
|
+ if (retailItem.get("productType").toString().equals(productType)) {
|
|
|
Double weight1 = (Double) retailItem.get("weight");
|
|
|
weight += weight1;
|
|
|
- saleItem.put("weight",handlingWeight(weight));
|
|
|
+ saleItem.put("weight", handlingWeight(weight));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (addList.size() > 0){
|
|
|
+ if (addList.size() > 0) {
|
|
|
saleWeight.addAll(addList);
|
|
|
}
|
|
|
|
|
@@ -876,18 +920,18 @@ public class SaleOrderServiceImpl implements ISaleOrderService {
|
|
|
@Override
|
|
|
public Map<String, Object> productionMarketingRatio(Map<String, Object> map) {
|
|
|
//销售单销量
|
|
|
- Map<String, Object> saleOrderSaleVolume = saleOrderMapper.saleOrderSaleVolume(map.get("productType").toString(),map.get("timeType").toString(), map.get("timeParam").toString());
|
|
|
+ Map<String, Object> saleOrderSaleVolume = saleOrderMapper.saleOrderSaleVolume(map.get("productType").toString(), map.get("timeType").toString(), map.get("timeParam").toString());
|
|
|
//零售单销量
|
|
|
- Map<String, Object> retailOrderSaleVolume = saleOrderMapper.retailOrderSaleVolume(map.get("productType").toString(),map.get("timeType").toString(), map.get("timeParam").toString());
|
|
|
+ Map<String, Object> retailOrderSaleVolume = saleOrderMapper.retailOrderSaleVolume(map.get("productType").toString(), map.get("timeType").toString(), map.get("timeParam").toString());
|
|
|
//产量
|
|
|
- Map<String, Object> productionVolume = saleOrderMapper.productionVolume(map.get("productType").toString(),map.get("timeType").toString(), map.get("timeParam").toString());
|
|
|
+ Map<String, Object> productionVolume = saleOrderMapper.productionVolume(map.get("productType").toString(), map.get("timeType").toString(), map.get("timeParam").toString());
|
|
|
|
|
|
- Double saleWeight = (Double)saleOrderSaleVolume.get("weight");
|
|
|
+ Double saleWeight = (Double) saleOrderSaleVolume.get("weight");
|
|
|
double sale = saleWeight != null ? saleWeight : 0.0;
|
|
|
- Double retailWeight = (Double)retailOrderSaleVolume.get("weight");
|
|
|
+ Double retailWeight = (Double) retailOrderSaleVolume.get("weight");
|
|
|
double retail = retailWeight != null ? retailWeight : 0.0;
|
|
|
|
|
|
- Double productionWeight = (Double)productionVolume.get("weight");
|
|
|
+ Double productionWeight = (Double) productionVolume.get("weight");
|
|
|
double production = productionWeight != null ? productionWeight : 0.0;
|
|
|
Double totalWeight = sale + retail + production;
|
|
|
|
|
@@ -898,13 +942,13 @@ public class SaleOrderServiceImpl implements ISaleOrderService {
|
|
|
Double productionProportion = (production / totalWeight) * 100;
|
|
|
Double roundedPercentage1 = Math.round(productionProportion * 100.0) / 100.0;
|
|
|
|
|
|
- if(roundedPercentage > 0){
|
|
|
+ if (roundedPercentage > 0) {
|
|
|
|
|
|
}
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
- result.put("salesProportion",roundedPercentage);
|
|
|
- result.put("productionProportion",roundedPercentage1);
|
|
|
+ result.put("salesProportion", roundedPercentage);
|
|
|
+ result.put("productionProportion", roundedPercentage1);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -921,7 +965,7 @@ public class SaleOrderServiceImpl implements ISaleOrderService {
|
|
|
List<Map<String, Object>> saleList = saleOrderMapper.saleFastSellingProduct(map.get("timeType").toString(), map.get("timeParam").toString());
|
|
|
|
|
|
List<Map<String, Object>> addList = new ArrayList<>();
|
|
|
- for (Map<String, Object> retailItem : retailList){
|
|
|
+ for (Map<String, Object> retailItem : retailList) {
|
|
|
String productId = retailItem.get("productId").toString();
|
|
|
String productColour = retailItem.get("productColour").toString();
|
|
|
boolean exists = saleList.stream()
|
|
@@ -929,24 +973,24 @@ public class SaleOrderServiceImpl implements ISaleOrderService {
|
|
|
productId.equals(saleItem.get("productId").toString()) &&
|
|
|
productColour.equals(saleItem.get("productColour").toString())
|
|
|
);
|
|
|
- if(!exists){
|
|
|
+ if (!exists) {
|
|
|
addList.add(retailItem);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- for (Map<String, Object> saleItem : saleList){
|
|
|
+ for (Map<String, Object> saleItem : saleList) {
|
|
|
String productId = saleItem.get("productId").toString();
|
|
|
String productColour = saleItem.get("productColour").toString();
|
|
|
Double weight = (Double) saleItem.get("weight");
|
|
|
- for (Map<String, Object> retailItem : retailList){
|
|
|
- if(retailItem.get("productId").toString().equals(productId) && retailItem.get("productColour").toString().equals(productColour)){
|
|
|
+ for (Map<String, Object> retailItem : retailList) {
|
|
|
+ if (retailItem.get("productId").toString().equals(productId) && retailItem.get("productColour").toString().equals(productColour)) {
|
|
|
Double weight1 = (Double) retailItem.get("weight");
|
|
|
weight += weight1;
|
|
|
- saleItem.put("weight",handlingWeight(weight));
|
|
|
+ saleItem.put("weight", handlingWeight(weight));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (addList.size() > 0){
|
|
|
+ if (addList.size() > 0) {
|
|
|
saleList.addAll(addList);
|
|
|
}
|
|
|
|