Browse Source

宝霆后台代码处理

oyq28 2 years ago
parent
commit
585795c784

+ 55 - 18
imcs-bt-be/imcs-authority-server/src/main/java/com/github/zuihou/api/OpsAppApi.java

@@ -1,18 +1,28 @@
 package com.github.zuihou.api;
 package com.github.zuihou.api;
 
 
+import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.zuihou.base.R;
 import com.github.zuihou.base.R;
+import com.github.zuihou.base.request.PageParams;
 import com.github.zuihou.business.barrel.entity.EquBarrel;
 import com.github.zuihou.business.barrel.entity.EquBarrel;
 import com.github.zuihou.business.barrel.service.EquBarrelService;
 import com.github.zuihou.business.barrel.service.EquBarrelService;
 import com.github.zuihou.business.order.entity.Order;
 import com.github.zuihou.business.order.entity.Order;
 import com.github.zuihou.business.order.service.OrderService;
 import com.github.zuihou.business.order.service.OrderService;
+import com.github.zuihou.business.productionresource.dto.ProductionResourcePageDTO;
 import com.github.zuihou.business.productionresource.dto.ReloadMtrDto;
 import com.github.zuihou.business.productionresource.dto.ReloadMtrDto;
 import com.github.zuihou.business.productionresource.entity.ProductionResource;
 import com.github.zuihou.business.productionresource.entity.ProductionResource;
 import com.github.zuihou.business.productionresource.service.ProductionTenantResourceService;
 import com.github.zuihou.business.productionresource.service.ProductionTenantResourceService;
+import com.github.zuihou.business.util.CommonUtil;
 import com.github.zuihou.context.BaseContextHandler;
 import com.github.zuihou.context.BaseContextHandler;
+import com.github.zuihou.database.mybatis.conditions.Wraps;
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
 import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
+import com.github.zuihou.utils.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
+import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.LocalTime;
@@ -40,14 +50,13 @@ public class OpsAppApi {
      * @return
      * @return
      */
      */
     @PostMapping("/getEquList")
     @PostMapping("/getEquList")
-    public R<List<ProductionResource>> getEquList() {
-        Long userId = BaseContextHandler.getUserId();
-
-        QueryWrap<ProductionResource> queryWrap = new QueryWrap<>();
-
-        queryWrap.eq("ops_user_id", userId);
-
-        List<ProductionResource> list = productionTenantResourceService.list(queryWrap);
+    public R<IPage<ProductionResource>> getEquList(@RequestBody PageParams<ProductionResource> params) {
+        BaseContextHandler.setTenant("0000");
+        IPage<ProductionResource> page = params.buildPage();
+        LbqWrapper<ProductionResource> queryWrap = Wraps.lbQ();
+        ProductionResource productionResource = BeanUtil.toBean(params, ProductionResource.class);
+        queryWrap.eq(ProductionResource::getStatus,"1").orderByDesc(ProductionResource::getCreateTime);
+        IPage<ProductionResource> list = productionTenantResourceService.pageList(page, queryWrap);
         return R.success(list);
         return R.success(list);
     }
     }
 
 
@@ -58,10 +67,13 @@ public class OpsAppApi {
      */
      */
     @GetMapping("/getEquByName")
     @GetMapping("/getEquByName")
     public R<List<ProductionResource>> getEquList(@RequestParam("name") String name) {
     public R<List<ProductionResource>> getEquList(@RequestParam("name") String name) {
-        Long userId = BaseContextHandler.getUserId();
-//        String name = equQueryDto.getName();
-        QueryWrap<ProductionResource> queryWrap = new QueryWrap<>();
-        queryWrap.eq("ops_user_id", userId).like("name", name);
+        BaseContextHandler.setTenant("0000");
+        LbqWrapper<ProductionResource> queryWrap = Wraps.lbQ();
+        queryWrap.like(ProductionResource::getName, name).orderByDesc(ProductionResource::getCreateTime);
+        List<Long> orgIds = CommonUtil.getOrgIdsArr();
+        if(orgIds.size()>0){
+            queryWrap.in(ProductionResource::getOrgId, orgIds);
+        }
         List<ProductionResource> list = productionTenantResourceService.list(queryWrap);
         List<ProductionResource> list = productionTenantResourceService.list(queryWrap);
         return R.success(list);
         return R.success(list);
     }
     }
@@ -77,8 +89,12 @@ public class OpsAppApi {
      */
      */
     @GetMapping("/equDetails")
     @GetMapping("/equDetails")
     public R<ProductionResource> equDetails(@RequestParam("equId") Long equId) {
     public R<ProductionResource> equDetails(@RequestParam("equId") Long equId) {
-        ProductionResource productionResource = productionTenantResourceService.getById(equId);
-        return R.success(productionResource);
+        BaseContextHandler.setTenant("0000");
+        LbqWrapper<ProductionResource> queryWrap = Wraps.lbQ();
+        queryWrap.eq(ProductionResource::getId, equId);
+        Page<ProductionResource> page = new Page<>(1L,1);
+        IPage<ProductionResource> productionResourceList = productionTenantResourceService.pageList(page, queryWrap);
+        return R.success(productionResourceList.getRecords().size()>0? productionResourceList.getRecords().get(0) : ProductionResource.builder().build());
     }
     }
 
 
 
 
@@ -87,11 +103,29 @@ public class OpsAppApi {
      *
      *
      * @return
      * @return
      */
      */
-    @GetMapping("/equOrders")
-    public R<List<Order>> equOrders(@RequestParam("equId") Long equId) {
+    @PostMapping("/equOrders")
+    public R<IPage<Order>> equOrders(@RequestBody PageParams<Order> params) {
+        BaseContextHandler.setTenant("0000");
+        IPage<Order> page = params.buildPage();
         QueryWrap<Order> orderQueryWrap = new QueryWrap<>();
         QueryWrap<Order> orderQueryWrap = new QueryWrap<>();
-        orderQueryWrap.eq("order_equ_id", equId);
-        List<Order> list = orderService.list(orderQueryWrap);
+        Order order = BeanUtil.toBean(params, Order.class);
+        if(params.getMap().containsKey("createTime_st")){
+            LocalDateTime startTime = DateUtils.getStartTime(params.getMap().get("createTime_st").toString());
+            orderQueryWrap.geHeader("create_time", startTime);
+        }
+        if(params.getMap().containsKey("createTime_ed")){
+            LocalDateTime endTime = DateUtils.getEndTime(params.getMap().get("createTime_ed").toString());
+            orderQueryWrap.leFooter("create_time", endTime);
+        }
+        orderQueryWrap.eq("order_status","SUCCESS").eq("order_equ_id", order.getOrderEquId()).orderByDesc("create_time");
+        IPage<Order> list = orderService.pageList(page, orderQueryWrap);
+
+        orderQueryWrap.select("sum(order_amount) as orderSum");
+        Order sumOrder = orderService.getOne(orderQueryWrap);
+        if (sumOrder== null){
+            sumOrder = Order.builder().build().setOrderSum(BigDecimal.ZERO);
+        }
+        list.getRecords().add(0, sumOrder);
         return R.success(list);
         return R.success(list);
     }
     }
 
 
@@ -103,6 +137,7 @@ public class OpsAppApi {
      */
      */
     @GetMapping("/todayOrders")
     @GetMapping("/todayOrders")
     public R<List<Order>> todayOrders(@RequestParam("equId") Long equId) {
     public R<List<Order>> todayOrders(@RequestParam("equId") Long equId) {
+        BaseContextHandler.setTenant("0000");
         QueryWrap<Order> orderQueryWrap = new QueryWrap<>();
         QueryWrap<Order> orderQueryWrap = new QueryWrap<>();
         orderQueryWrap.eq("order_equ_id", equId);
         orderQueryWrap.eq("order_equ_id", equId);
 
 
@@ -122,6 +157,7 @@ public class OpsAppApi {
      */
      */
     @GetMapping("/sevenDaysOrders")
     @GetMapping("/sevenDaysOrders")
     public R<List<Order>> sevenDaysOrders(@RequestParam("equId") Long equId) {
     public R<List<Order>> sevenDaysOrders(@RequestParam("equId") Long equId) {
+        BaseContextHandler.setTenant("0000");
         QueryWrap<Order> orderQueryWrap = new QueryWrap<>();
         QueryWrap<Order> orderQueryWrap = new QueryWrap<>();
         orderQueryWrap.eq("order_equ_id", equId);
         orderQueryWrap.eq("order_equ_id", equId);
         LocalDateTime now = LocalDateTime.now();
         LocalDateTime now = LocalDateTime.now();
@@ -138,6 +174,7 @@ public class OpsAppApi {
      */
      */
     @GetMapping("/barrelList")
     @GetMapping("/barrelList")
     public R<List<EquBarrel>> barrelList(@RequestParam("equId") Long equId) {
     public R<List<EquBarrel>> barrelList(@RequestParam("equId") Long equId) {
+        BaseContextHandler.setTenant("0000");
         QueryWrap<EquBarrel> equBarrelQueryWrap = new QueryWrap<>();
         QueryWrap<EquBarrel> equBarrelQueryWrap = new QueryWrap<>();
         equBarrelQueryWrap.eq("equ_id",equId);
         equBarrelQueryWrap.eq("equ_id",equId);
         List<EquBarrel> list = equBarrelService.list(equBarrelQueryWrap);
         List<EquBarrel> list = equBarrelService.list(equBarrelQueryWrap);

+ 31 - 0
imcs-bt-be/imcs-business-biz/src/main/java/com/github/zuihou/business/util/CommonUtil.java

@@ -1,6 +1,11 @@
 package com.github.zuihou.business.util;
 package com.github.zuihou.business.util;
 
 
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
+import com.github.zuihou.authority.service.auth.UserService;
+import com.github.zuihou.context.BaseContextHandler;
+import com.github.zuihou.utils.SpringUtils;
+import com.google.common.collect.Lists;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashMap;
@@ -30,4 +35,30 @@ public class CommonUtil {
         }
         }
         return titleList;
         return titleList;
     }
     }
+
+    /**
+     * 获取当前用户部门ID范围(数组格式)
+     * @param
+     * @return
+     */
+    public static List<Long> getOrgIdsArr(){
+        //机构部门数据权限判断验证
+        BaseContextHandler.setTenant("0000");
+        Long userId = BaseContextHandler.getUserId();
+        UserService userService = (UserService)SpringUtils.getBean(UserService.class);
+        //获取用户权限访问机构
+        Map<String, Object> orgMap = userService.getDataScopeById(userId);
+        List<Long> orgIds = orgMap.containsKey("orgIds")? (List)orgMap.get("orgIds") : Lists.newArrayList();
+        return orgIds;
+    }
+
+    /**
+     * 获取当前用户部门ID范围(字符串格式)
+     * @param
+     * @return
+     */
+    public static String getOrgIdsStr(){
+        List<Long> orgIds = getOrgIdsArr();
+        return CollectionUtil.isNotEmpty(orgIds)? CollectionUtil.join(orgIds, ",") : "";
+    }
 }
 }

+ 3 - 3
imcs-bt-be/imcs-business-biz/src/main/resources/mapper_business/base/order/OrderMapper.xml

@@ -22,8 +22,7 @@
 
 
     <!-- 通用查询结果列 -->
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
     <sql id="Base_Column_List">
-        id
-        ,orderMemberName, orderGoodsName,orderGoodsPic,orderSpecsName,
+        id,orderMemberName, orderGoodsName,orderGoodsPic,orderSpecsName,deviceName,
         order_member_id, order_goods_id, order_company_id, order_specs, order_amount, order_unit_price, order_goods_amount, order_status, create_time, update_time, order_pay_time, order_end_time, order_close_time,org_id
         order_member_id, order_goods_id, order_company_id, order_specs, order_amount, order_unit_price, order_goods_amount, order_status, create_time, update_time, order_pay_time, order_end_time, order_close_time,org_id
     </sql>
     </sql>
 
 
@@ -32,11 +31,12 @@
         <include refid="Base_Column_List"/>
         <include refid="Base_Column_List"/>
         from (
         from (
         select o.*, o.order_company_id as org_id, g.goods_name as orderGoodsName, g.goods_pic as orderGoodsPic,
         select o.*, o.order_company_id as org_id, g.goods_name as orderGoodsName, g.goods_pic as orderGoodsPic,
-        s.spec_name as orderSpecsName, m.member_name as orderMemberName
+        s.spec_name  as orderSpecsName,  m.member_name as orderMemberName, p.name as deviceName
         from bt_order o
         from bt_order o
         left join bt_goods g on o.order_goods_id = g.id
         left join bt_goods g on o.order_goods_id = g.id
         left join bt_spe s on o.order_specs = s.id
         left join bt_spe s on o.order_specs = s.id
         left join bt_member m on o.order_member_id = m.id
         left join bt_member m on o.order_member_id = m.id
+        left join imcs_tenant_productionresource p on o.order_equ_id = p.id
         ) f ${ew.customSqlSegment}
         ) f ${ew.customSqlSegment}
     </select>
     </select>
 
 

+ 2 - 4
imcs-bt-be/imcs-business-biz/src/main/resources/mapper_business/base/productionresource/ProductionresourceMapper.xml

@@ -46,11 +46,11 @@
 
 
     <select id="pageList" resultMap="BaseResultMap">
     <select id="pageList" resultMap="BaseResultMap">
         select
         select
-        <include refid="Base_Column_List"/>, longtitude,latitude,areaIds,tenantDesc,pic, category
+        <include refid="Base_Column_List"/>, longtitude,latitude,areaIds,tenantDesc,pic, category,address
         from (
         from (
         SELECT
         SELECT
         a.*,b.label as lineDesc,v.longtitude,v.latitude,v.pic,v.category,v.tenantDesc,
         a.*,b.label as lineDesc,v.longtitude,v.latitude,v.pic,v.category,v.tenantDesc,
-        v.areaIds,v.placeName from imcs_tenant_productionresource a
+        v.areaIds,v.placeName,v.address from imcs_tenant_productionresource a
         left join c_core_org b on a.org_id = b.id
         left join c_core_org b on a.org_id = b.id
         left join view_productionresource v on a.id = v.id
         left join view_productionresource v on a.id = v.id
         ) s ${ew.customSqlSegment}
         ) s ${ew.customSqlSegment}
@@ -105,8 +105,6 @@
                  left join bt_goods_cate gc on g.goods_cate_id = gc.id
                  left join bt_goods_cate gc on g.goods_cate_id = gc.id
                  left join bt_spe s on s.goods_id = g.id
                  left join bt_spe s on s.goods_id = g.id
         where eg.equ_id = #{equId}
         where eg.equ_id = #{equId}
-
-
     </select>
     </select>
 
 
 </mapper>
 </mapper>

+ 7 - 1
imcs-bt-be/imcs-business-entity/src/main/java/com/github/zuihou/business/order/entity/Order.java

@@ -167,7 +167,9 @@ public class Order extends Entity<Long> {
     private String orderPrepayId;
     private String orderPrepayId;
 
 
 
 
-
+    @ApiModelProperty(value = "订单总金额")
+    @TableField(exist = false)
+    private BigDecimal orderSum;
 
 
     /**
     /**
      * 订单创建时间
      * 订单创建时间
@@ -209,6 +211,10 @@ public class Order extends Entity<Long> {
     @Excel(name = "交易关闭时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
     @Excel(name = "交易关闭时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
     private LocalDateTime orderCloseTime;
     private LocalDateTime orderCloseTime;
 
 
+    @ApiModelProperty(value = "订单设备名称")
+    @TableField(exist = false)
+    private String deviceName;
+
     @Builder
     @Builder
     public Order(Long id,
     public Order(Long id,
                  Long orderMemberId, Long orderGoodsId, Long orderCompanyId, Long orderSpecs, BigDecimal orderAmount,
                  Long orderMemberId, Long orderGoodsId, Long orderCompanyId, Long orderSpecs, BigDecimal orderAmount,

+ 14 - 1
imcs-bt-be/imcs-business-entity/src/main/java/com/github/zuihou/business/productionresource/entity/ProductionResource.java

@@ -274,6 +274,14 @@ public class ProductionResource extends Entity<Long> {
     @Excel(name = "场地ID")
     @Excel(name = "场地ID")
     private Long placeId;
     private Long placeId;
 
 
+    /**
+     * 运维人员
+     */
+    @ApiModelProperty(value = "企业ID")
+    @TableField(value = "org_id", condition = EQUAL)
+    @Excel(name = "企业ID")
+    private Long orgId;
+
     /**
     /**
      * 运维人员
      * 运维人员
      */
      */
@@ -302,13 +310,17 @@ public class ProductionResource extends Entity<Long> {
     @TableField(exist=false)
     @TableField(exist=false)
     private String pic;
     private String pic;
 
 
+    @ApiModelProperty(value = "场景地址")
+    @TableField(exist=false)
+    private String address;
+
     @Builder
     @Builder
     public ProductionResource(Long id, LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser,
     public ProductionResource(Long id, LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser,
                     Long compnayId, String moduleId, String areaId, String name, String resourcesCategory, 
                     Long compnayId, String moduleId, String areaId, String name, String resourcesCategory, 
                     String code, String status, String onlineStatus, String remark, String ip, String port, 
                     String code, String status, String onlineStatus, String remark, String ip, String port, 
                     Integer gatherTaskId, Float incomeToday, Integer exceptionOrderNum, Integer cacheStorgeNum, Integer maxSpeed, String capitalNo, 
                     Integer gatherTaskId, Float incomeToday, Integer exceptionOrderNum, Integer cacheStorgeNum, Integer maxSpeed, String capitalNo, 
                     String capitalName, String capitalType, String modeSpecification, String capitalPrice, String productionDate, String productionNo, 
                     String capitalName, String capitalType, String modeSpecification, String capitalPrice, String productionDate, String productionNo, 
-                    String manufacturer, Integer programNum) {
+                    String manufacturer, Integer programNum, Long orgId) {
         this.id = id;
         this.id = id;
         this.createTime = createTime;
         this.createTime = createTime;
         this.createUser = createUser;
         this.createUser = createUser;
@@ -339,6 +351,7 @@ public class ProductionResource extends Entity<Long> {
         this.productionNo = productionNo;
         this.productionNo = productionNo;
         this.manufacturer = manufacturer;
         this.manufacturer = manufacturer;
         this.programNum = programNum;
         this.programNum = programNum;
+        this.orgId = orgId;
     }
     }
 
 
 }
 }