| | |
| | | package com.example.erp.service.sd; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.TypeReference; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.example.erp.common.Constants; |
| | | import com.example.erp.dto.sd.OrderDTO; |
| | | import com.example.erp.entity.sd.*; |
| | | import com.example.erp.entity.userInfo.SysError; |
| | | import com.example.erp.exception.ServiceException; |
| | | import com.example.erp.mapper.sd.*; |
| | | import com.example.erp.service.userInfo.SysErrorService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | |
| | | |
| | | //插入其他副表数据,被其他方法引用 |
| | | public void insertOtherDetail(String orderId,List<OrderDetail> OrderDetails,List<OrderOtherMoney> orderOtherMoneyList) { |
| | | //先把其他金额副表的金额与数量置0 |
| | | orderOtherMoneyList.forEach(orderOtherMoney -> { |
| | | orderOtherMoney.setQuantity(0.0); |
| | | }); |
| | | |
| | | //循环给订单明细表字段添加序号和周长 |
| | | for (int i = 0; i < OrderDetails.size(); i++) { |
| | | OrderDetails.get(i).setOrderNumber(i+1); |
| | | OrderDetails.get(i).setOrderId(orderId); |
| | | OrderDetails.get(i).setPerimeter(OrderDetails.get(i).getWidth()*OrderDetails.get(i).getHeight()*2/1000); |
| | | OrderDetails.get(i).setWeight(1.0); |
| | | Map<String,Double> otherColumns = JSON.parseObject(OrderDetails.get(i).getOtherColumns(), new TypeReference<Map<String, Double>>(){}); |
| | | int finalI = i; |
| | | |
| | | |
| | | if(otherColumns!=null){ |
| | | otherColumns.forEach((key, value) ->{ |
| | | if(value!=null) { |
| | | orderOtherMoneyList.forEach(orderOtherMoney -> { |
| | | if (orderOtherMoney.getColumn().equals(key)) { |
| | | orderOtherMoney.setQuantity(orderOtherMoney.getQuantity()+(value * OrderDetails.get(finalI).getQuantity())); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | }); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //往明细表插数据 |
| | | orderDetailMapper.insertBatch(OrderDetails); |
| | | //修改订单主表面积与周长以及重量 |
| | | orderMapper.updateOrderParameter(orderId); |
| | | //往小片表传入产品数据 |
| | | orderGlassDetailMapper.insertOrderGlassDetail(orderId); |
| | | //往订单其他金额副表传入数据 |
| | |
| | | } |
| | | orderOtherMoneyMapper.insert(orderOtherMoney); |
| | | }); |
| | | //修改订单主表面积与周长以及重量 |
| | | orderMapper.updateOrderParameter(orderId); |
| | | |
| | | //查询订单小片表获取工艺传入小片工艺表 |
| | | //List<OrderGlassDetail> orderGlassDetails = orderGlassDetailMapper.selectOrderGlassDetail(orderId); |
| | |
| | | |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("data",orderDetailMapper.getOrderReport(offset, pageSize, startDate, endDate, orderDetail)); |
| | | map.put("total",orderDetailMapper.getOrderReportTotal(offset, pageSize, startDate, endDate, orderDetail)); |
| | | map.put("total",orderDetailMapper.getOrderReportTotal(offset, pageSize, startDate, endDate, orderDetail,"order")); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | |
| | | return map; |
| | | } |
| | | |
| | | public List<Order> exportOrderReport() { |
| | | return orderDetailMapper.exportOrderReport(); |
| | | public List<OrderDTO> exportOrderReport(List<LocalDate> dates) { |
| | | return orderDetailMapper.exportOrderReport(dates); |
| | | } |
| | | |
| | | public Map<String,Object> getOrderProductSummary(Integer pageNum, Integer pageSize, List<String> selectDate, OrderDetail orderDetail) { |
| | | Integer offset = (pageNum-1)*pageSize; |
| | | String endDate = LocalDate.now().toString(); |
| | | String startDate = LocalDate.now().minusDays(15).toString(); |
| | | if(selectDate !=null && selectDate.size()==2){ |
| | | if(!selectDate.get(0).isEmpty()){ |
| | | startDate = selectDate.get(0); |
| | | } |
| | | if(!selectDate.get(1).isEmpty()){ |
| | | endDate = selectDate.get(1); |
| | | } |
| | | } |
| | | |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("data",orderDetailMapper.getOrderProductSummary(offset, pageSize, startDate, endDate, orderDetail)); |
| | | map.put("total",orderDetailMapper.getOrderProductSummaryTotal(offset, pageSize, startDate, endDate, orderDetail, "product")); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | | map.put("selectDate",list); |
| | | // map.put("total",orderMapper.getPageTotal(offset, pageSize, startDate, endDate, orderDetail)); |
| | | return map; |
| | | } |
| | | |
| | | public List<OrderDTO> exportOrderProductSummary(List<LocalDate> dates) { |
| | | return orderDetailMapper.exportOrderProductSummary(dates); |
| | | } |
| | | } |