|
@@ -5,6 +5,7 @@ import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
|
|
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
|
|
import cn.com.crbank.ommo.bean.ResultMessage;
|
|
|
import cn.com.crbank.ommo.esclient.ElasticsearchRunner;
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -16,6 +17,7 @@ import com.szwl.constant.ResponseCodesEnum;
|
|
|
import com.szwl.feign.SzwlFeign;
|
|
|
import com.szwl.model.bean.ChartColumn;
|
|
|
import com.szwl.model.bean.OrderDaoChuDTO;
|
|
|
+import com.szwl.model.bean.OrderDetailsVo;
|
|
|
import com.szwl.model.bean.OrderVo;
|
|
|
import com.szwl.model.bo.JsonMessage;
|
|
|
import com.szwl.model.bo.R;
|
|
@@ -29,10 +31,7 @@ import com.szwl.model.query.*;
|
|
|
import com.szwl.model.utils.DateUtils;
|
|
|
import com.szwl.model.utils.FgObjectUtil;
|
|
|
import com.szwl.model.utils.JsonUtils;
|
|
|
-import com.szwl.service.TAreaService;
|
|
|
-import com.szwl.service.TCoinOrderService;
|
|
|
-import com.szwl.service.TEquipmentService;
|
|
|
-import com.szwl.service.TOrderService;
|
|
|
+import com.szwl.service.*;
|
|
|
import com.szwl.service.es.EsTEquipmentService;
|
|
|
import com.szwl.service.es.EsTOrderService;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -78,7 +77,8 @@ public class TOrderController {
|
|
|
TCoinOrderService coinOrderService;
|
|
|
@Autowired
|
|
|
SzwlFeign szwlFeign;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ TOrderDetailsService orderDetailsService;
|
|
|
@GetMapping("/pageOrder")
|
|
|
public ResponseModel<IPage<?>> pageOrder(String equipmentId, String adminId, String adminType,
|
|
|
String type, String sn, String status, String userName,
|
|
@@ -283,32 +283,117 @@ public class TOrderController {
|
|
|
query.orderByDesc(TOrder::getCreateDate);
|
|
|
Page<TOrder> page = new Page<>(current, size, true);
|
|
|
IPage<TOrder> iPage = orderService.page(page, query);
|
|
|
+ IPage<OrderDetailsVo> pageList = new Page<>();
|
|
|
//显示订单所属机器的设备名称
|
|
|
- if (admin.getType() != null && admin.getType() < 2) {
|
|
|
- //公司人员
|
|
|
- List<TOrder> orderList = iPage.getRecords();
|
|
|
- if (orderList.size() > 0) {
|
|
|
- for (TOrder order : orderList) {
|
|
|
- TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(order.getClientId()));
|
|
|
- order.setEs(equipment.getName());
|
|
|
- }
|
|
|
- iPage.setRecords(orderList);
|
|
|
+// if(admin.getType()!=null&&admin.getType()<2){
|
|
|
+// //公司人员
|
|
|
+// List<TOrder> orderList = iPage.getRecords();
|
|
|
+// if(orderList.size()>0){
|
|
|
+// List<String> clientIds = new ArrayList<>();
|
|
|
+// for (TOrder order : orderList) {
|
|
|
+// clientIds.add(order.getClientId());
|
|
|
+// }
|
|
|
+// Map<String, String> equipmentMap = new HashMap<>();
|
|
|
+// List<TEquipment> equipmentList = R.getDataIfSuccess(szwlFeign.findEquipmentByClientIds(clientIds));
|
|
|
+// for (TEquipment equipment : equipmentList) {
|
|
|
+// equipmentMap.put(equipment.getClientId(), equipment.getName());
|
|
|
+// }
|
|
|
+// // 设置设备信息到订单中
|
|
|
+// for (TOrder order : orderList) {
|
|
|
+// String name = equipmentMap.get(order.getClientId());
|
|
|
+// if (StringUtils.isNotEmpty(name)) {
|
|
|
+// order.setEs(name);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//// for(TOrder order:orderList){
|
|
|
+//// TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(order.getClientId()));
|
|
|
+//// order.setEs(equipment.getName());
|
|
|
+//// }
|
|
|
+// iPage.setRecords(orderList);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if(admin.getType()!=null&&admin.getType()>1){
|
|
|
+// //商家
|
|
|
+// List<TOrder> orderList = iPage.getRecords();
|
|
|
+// if(orderList.size()>0){
|
|
|
+//// for(TOrder order:orderList){
|
|
|
+//// TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(order.getClientId()));
|
|
|
+//// order.setEs(equipment.getName());
|
|
|
+//// }
|
|
|
+// // 设备编号集合
|
|
|
+// List<String> clientIds = new ArrayList<>();
|
|
|
+// for (TOrder order : orderList) {
|
|
|
+// clientIds.add(order.getClientId());
|
|
|
+// }
|
|
|
+// // 设备编号名称集合
|
|
|
+// Map<String, String> equipmentMap = new HashMap<>();
|
|
|
+// // 设备编号名称集合
|
|
|
+// List<TEquipment> equipmentList = R.getDataIfSuccess(szwlFeign.findEquipmentByClientIds(clientIds));
|
|
|
+// for (TEquipment equipment : equipmentList) {
|
|
|
+// equipmentMap.put(equipment.getClientId(), equipment.getName());
|
|
|
+// }
|
|
|
+// LambdaQueryWrapper<TOrderDetails> wrapper = new LambdaQueryWrapper<>();
|
|
|
+//
|
|
|
+// // 设置设备信息到订单中
|
|
|
+// for (TOrder order : orderList) {
|
|
|
+// String name = equipmentMap.get(order.getClientId());
|
|
|
+// if (StringUtils.isNotEmpty(name)) {
|
|
|
+// order.setEs(name);
|
|
|
+// }
|
|
|
+// wrapper.in(TOrderDetails::getOrderSn,order.getSn());
|
|
|
+// List<TOrderDetails> orderDetailsList = orderDetailsService.list(wrapper);
|
|
|
+// if(orderDetailsList != null) {
|
|
|
+// order.setOrderDetails(orderDetailsList);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// iPage.setRecords(orderList);
|
|
|
+// }
|
|
|
+ List<TOrder> orderList = iPage.getRecords();
|
|
|
+ List<OrderDetailsVo> orderDetailsVos = new ArrayList<>();
|
|
|
+ if(orderList.size()>0){
|
|
|
+// for(TOrder order:orderList){
|
|
|
+// TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(order.getClientId()));
|
|
|
+// order.setEs(equipment.getName());
|
|
|
+// }
|
|
|
+ // 设备编号集合
|
|
|
+ List<String> clientIds = new ArrayList<>();
|
|
|
+ for (TOrder order : orderList) {
|
|
|
+ clientIds.add(order.getClientId());
|
|
|
}
|
|
|
- }
|
|
|
- if (admin.getType() != null && admin.getType() > 1) {
|
|
|
- //商家
|
|
|
- List<TOrder> orderList = iPage.getRecords();
|
|
|
- if (orderList.size() > 0) {
|
|
|
-// TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(orderList.get(0).getClientId()));
|
|
|
- for (TOrder order : orderList) {
|
|
|
- TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(order.getClientId()));
|
|
|
- order.setEs(equipment.getName());
|
|
|
+ // 设备编号名称集合
|
|
|
+ Map<String, String> equipmentMap = new HashMap<>();
|
|
|
+ // 设备编号名称集合
|
|
|
+ List<TEquipment> equipmentList = R.getDataIfSuccess(szwlFeign.findEquipmentByClientIds(clientIds));
|
|
|
+ for (TEquipment equipment : equipmentList) {
|
|
|
+ equipmentMap.put(equipment.getClientId(), equipment.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 设置设备信息到订单中
|
|
|
+ for (TOrder order : orderList) {
|
|
|
+ String name = equipmentMap.get(order.getClientId());
|
|
|
+ if (StringUtils.isNotEmpty(name)) {
|
|
|
+ order.setEs(name);
|
|
|
}
|
|
|
+ OrderDetailsVo orderDetailsVo = new OrderDetailsVo();
|
|
|
+ BeanUtil.copyProperties(order, orderDetailsVo);
|
|
|
+ LambdaQueryWrapper<TOrderDetails> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(TOrderDetails::getOrderSn, order.getSn());
|
|
|
+ List<TOrderDetails> orderDetailsList = orderDetailsService.list(queryWrapper);
|
|
|
+ if(orderDetailsList != null) {
|
|
|
+ orderDetailsVo.setOrderDetails(orderDetailsList);
|
|
|
+ }
|
|
|
+ orderDetailsVos.add(orderDetailsVo);
|
|
|
}
|
|
|
- iPage.setRecords(orderList);
|
|
|
}
|
|
|
- return R.ok(iPage);
|
|
|
- }
|
|
|
+ pageList.setRecords(orderDetailsVos);
|
|
|
+ pageList.setPages(iPage.getPages());
|
|
|
+ pageList.setCurrent(iPage.getCurrent());
|
|
|
+ pageList.setTotal(iPage.getTotal());
|
|
|
+ pageList.setSize(iPage.getSize());
|
|
|
+ return R.ok(pageList);
|
|
|
+ };
|
|
|
|
|
|
//1,线下
|
|
|
if (type.equals("1")) {
|