| | |
| | | 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).setWeight(1.0); |
| | | Map<String,Double> otherColumns = JSON.parseObject(OrderDetails.get(i).getOtherColumns(), new TypeReference<Map<String, Double>>(){}); |
| | | int finalI = i; |
| | | otherColumns.forEach((key, value) ->{ |
| | | orderOtherMoneyList.forEach(orderOtherMoney ->{ |
| | | if(orderOtherMoney.getColumn().equals(key)){ |
| | | orderOtherMoney.setQuantity (orderOtherMoney.getQuantity()==null?0:orderOtherMoney.getQuantity()); |
| | | orderOtherMoney.setQuantity(((value==null?0:value)*OrderDetails.get(finalI).getQuantity())); |
| | | } |
| | | }); |
| | | |
| | | }); |
| | | |
| | | 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())); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | }); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | |
| | | 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); |
| | | } |
| | | } |