Browse Source

订单及权限修改

zhuhao 2 years ago
parent
commit
1d54b00344

+ 13 - 9
imcs-bt-be/imcs-authority-biz/src/main/java/com/github/zuihou/authority/service/auth/impl/RoleAuthorityServiceImpl.java

@@ -15,6 +15,7 @@ import com.github.zuihou.common.constant.CacheKey;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
 import lombok.extern.slf4j.Slf4j;
 import net.oschina.j2cache.CacheChannel;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -74,13 +75,14 @@ public class RoleAuthorityServiceImpl extends SuperServiceImpl<RoleAuthorityMapp
         super.remove(Wraps.<RoleAuthority>lbQ().eq(RoleAuthority::getRoleId, dto.getRoleId()));
 
         List<RoleAuthority> list = new ArrayList<>();
-        if (dto.getResourceIdList() != null && !dto.getResourceIdList().isEmpty()) {
-            List<Long> menuIdList = resourceService.findMenuIdByResourceId(dto.getResourceIdList());
-            if (dto.getMenuIdList() == null || dto.getMenuIdList().isEmpty()) {
-                dto.setMenuIdList(menuIdList);
-            } else {
-                dto.getMenuIdList().addAll(menuIdList);
-            }
+        //if (dto.getResourceIdList() != null && !dto.getResourceIdList().isEmpty()) {
+        if (!CollectionUtils.isEmpty(dto.getResourceIdList())) {
+//            List<Long> menuIdList = resourceService.findMenuIdByResourceId(dto.getResourceIdList());
+//            if (dto.getMenuIdList() == null || dto.getMenuIdList().isEmpty()) {
+//                dto.setMenuIdList(menuIdList);
+//            } else {
+//                dto.getMenuIdList().addAll(menuIdList);
+//            }
 
             //保存授予的资源
             List<RoleAuthority> resourceList = new HashSet<>(dto.getResourceIdList())
@@ -93,7 +95,7 @@ public class RoleAuthorityServiceImpl extends SuperServiceImpl<RoleAuthorityMapp
                     .collect(Collectors.toList());
             list.addAll(resourceList);
         }
-        if (dto.getMenuIdList() != null && !dto.getMenuIdList().isEmpty()) {
+        if (!CollectionUtils.isEmpty(dto.getMenuIdList())) {
             //保存授予的菜单
             List<RoleAuthority> menuList = new HashSet<>(dto.getMenuIdList())
                     .stream()
@@ -108,7 +110,9 @@ public class RoleAuthorityServiceImpl extends SuperServiceImpl<RoleAuthorityMapp
         super.saveBatch(list);
 
         // 清理
-        List<Long> userIdList = userRoleService.listObjs(Wraps.<UserRole>lbQ().select(UserRole::getUserId).eq(UserRole::getRoleId, dto.getRoleId()),
+        List<Long> userIdList =
+                userRoleService.listObjs(Wraps.<UserRole>lbQ().select(UserRole::getUserId).eq(UserRole::getRoleId,
+                                dto.getRoleId()),
                 (userId) -> Convert.toLong(userId, 0L));
         userIdList.stream().collect(Collectors.toSet()).forEach((userId) -> {
             log.info("清理了 {} 的菜单/资源", userId);

+ 34 - 31
imcs-bt-be/imcs-business-biz/src/main/resources/mapper_business/base/member/MemberMapper.xml

@@ -38,37 +38,40 @@
     </select>
 
     <select id="getStatisticMap" parameterType="hashMap" resultType="java.util.Map">
-        select sum(num1) as totalNum,
-               sum(num2) as yesterdayNum,
-               sum(num3) as sevenNum,
-               sum(num4) as todayNum
-        from (
-            select count(1) as num1 ,0 as num2,0 as num3,0 as num4 from bt_member m
-            union
-            select 0 as num1 , count(1) as num2,0 as num3,0 as num4 from bt_member m
-            where 1 = 1
-            <if test="yesterday != null">
-                and m.create_time >= #{yesterday, jdbcType=TIMESTAMP}
-            </if>
-            <if test="now != null">
-                and m.create_time <![CDATA[ <= ]]> #{now, jdbcType=TIMESTAMP}
-            </if>
-            union
-            select 0 as num1 , count(1) as num2,0 as num3,0 as num4 from bt_member m
-            where 1 = 1
-            <if test="now != null">
-                and m.create_time >= #{now, jdbcType=TIMESTAMP}
-            </if>
-            <if test="now != null">
-                and m.create_time <![CDATA[ <= ]]> #{now, jdbcType=TIMESTAMP}
-            </if>
-            union
-            select 0 as num1 , count(1) as num2,0 as num3,0 as num4 from bt_member m
-                where 1 = 1
-            <if test="now != null">
-                and m.create_time >= #{now, jdbcType=TIMESTAMP}
-            </if>
-         )f
+        SELECT
+            SUM(1) AS totalNum,
+            SUM(
+                    CASE
+                        WHEN create_time >= date_format(CURRENT_DATE(), '%Y-%m-%d') THEN
+                            1
+                        ELSE
+                            0
+                        END
+                ) AS todayNum,
+            SUM(
+                    CASE
+                        WHEN create_time >= date_format(
+                                            CURRENT_DATE () - 1,
+                                            '%Y-%m-%d'
+                            ) THEN
+                            1
+                        ELSE
+                            0
+                        END
+                ) AS yesterdayNum,
+            SUM(
+                    CASE
+                        WHEN create_time >= date_format(
+                                            CURRENT_DATE () - 7,
+                                            '%Y-%m-%d'
+                            ) THEN
+                            1
+                        ELSE
+                            0
+                        END
+                ) AS sevenNum
+        FROM
+            bt_member
     </select>
 
 </mapper>

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

@@ -107,7 +107,9 @@
                g.goods_pic        AS goodsPic,
                m.member_name      AS memberName,
                p.NAME             AS equName,
-               r.label            AS equComName
+               r.label            AS equComName,
+               o.order_specs      AS specId,
+               s.spec_name        AS specName
         FROM bt_order o
                  LEFT JOIN bt_spe s ON o.order_specs = s.id
                  LEFT JOIN bt_goods g ON o.order_goods_id = g.id
@@ -118,154 +120,67 @@
     </select>
 
     <select id="getStatisticMap" parameterType="hashMap" resultType="java.util.Map">
-        select sum(num1) as todayNum,
-        sum(num2) as exceptNum,
-        sum(num3) as errMsgNum,
-        sum(num4) as todayAmount,
-        sum(num5) as sevenNum,
-        sum(num6) as sevenAmount,
-        sum(num7) as deviceNum,
-        sum(num8) as yesterdayAmount,
-        sum(num9) as lackDevice
-        from (
-        select count(1) as num1 ,0 as num2,0 as num3,0 as num4,0 as num5,0 as num6, 0 as num7, 0 as num8, 0 as num9 from bt_order o
-        <if test="orgIds != null and orgIds != ''">
-            left join imcs_tenant_productionresource p on o.order_equ_id = p.id
-            where p.org_id in (${orgIds})
-        </if>
-        <if test="orgIds==null ">
-            where 1 = 1
-        </if>
-        <if test="now != null">
-            and o.create_time >= #{now, jdbcType=TIMESTAMP}
-        </if>
-        <if test="nextDay != null">
-            and o.create_time <![CDATA[ <= ]]> #{nextDay, jdbcType=TIMESTAMP}
-        </if>
-        <if test="id != null">
-            and o.order_equ_id = #{id}
-        </if>
-        union
-        select 0 as num1, count(1) as num2 ,0 as num3,0 as num4,0 as num5,0 as num6, 0 as num7, 0 as num8, 0 as num9 from bt_order
-        o
-        <if test="orgIds != null and orgIds != ''">
-            left join imcs_tenant_productionresource p on o.order_equ_id = p.id
-            where p.org_id in (${orgIds})
-        </if>
-        <if test="orgIds == null ">
-            where 1 = 1
-        </if>
-        <if test="id != null">
-            and o.order_equ_id = #{id}
-        </if>
-        and o.order_status='4'
-        union
-        select 0 as num1,0 as num2,count(1) as num3,0 as num4,0 as num5,0 as num6, 0 as num7, 0 as num8, 0 as num9 from bt_order o
-        <if test="orgIds != null and orgIds != ''">
-            left join imcs_tenant_productionresource p on o.order_equ_id = p.id
-            where p.org_id in (${orgIds})
-        </if>
-        <if test="orgIds == null ">
-            where 1 = 1
-        </if>
-        <if test="id != null">
-            and o.order_equ_id = #{id}
-        </if>
-        and o.order_status='4'
-        union
-        select 0 as num1,0 as num2,0 as num3,sum(o.order_amount) as num4,0 as num5,0 as num6, 0 as num7, 0 as num8, 0 as num9 from
-        bt_order o
-        <if test="orgIds != null and orgIds != ''">
-            left join imcs_tenant_productionresource p on o.order_equ_id = p.id
-            where p.org_id in (${orgIds})
-        </if>
-        <if test="orgIds == null ">
-            where 1 = 1
-        </if>
-        <if test="now != null">
-            and o.create_time >= #{now, jdbcType=TIMESTAMP}
-        </if>
-        <if test="nextDay != null">
-            and o.create_time <![CDATA[ <= ]]> #{nextDay, jdbcType=TIMESTAMP}
-        </if>
-        <if test="id != null">
-            and o.order_equ_id = #{id}
-        </if>
-        and o.order_status='6'
-        union
-        select 0,0,0,0,count(1) as num5,0, 0, 0, 0 from bt_order o
-        <if test="orgIds != null and orgIds != ''">
-            left join imcs_tenant_productionresource p on o.order_equ_id = p.id
-            where p.org_id in (${orgIds})
-        </if>
-        <if test="orgIds == null ">
-            where 1 = 1
-        </if>
-        <if test="sevenAgo != null">
-            and o.create_time >= #{sevenAgo, jdbcType=TIMESTAMP}
-        </if>
-        <if test="now != null">
-            and o.create_time <![CDATA[ <= ]]> #{now, jdbcType=TIMESTAMP}
-        </if>
-        <if test="id != null">
-            and o.order_equ_id = #{id}
-        </if>
-        and o.order_status='1'
-        union
-        select 0,0,0,0,0,sum(o.order_amount) as num6, 0, 0, 0 from bt_order o
-        <if test="orgIds != null and orgIds != ''">
-            left join imcs_tenant_productionresource p on o.order_equ_id = p.id
-            where p.org_id in (${orgIds})
-        </if>
-        <if test="orgIds == null ">
-            where 1 = 1
-        </if>
-        <if test="sevenAgo != null">
-            and o.create_time >= #{sevenAgo, jdbcType=TIMESTAMP}
-        </if>
-        <if test="now != null">
-            and o.create_time <![CDATA[ <= ]]> #{now, jdbcType=TIMESTAMP}
-        </if>
-        <if test="id != null">
-            and o.order_equ_id = #{id}
-        </if>
-        and o.order_status = '6'
-        union
-        select 0,0,0,0,0,0, count(p.id) as num7, 0, 0 from imcs_tenant_productionresource p where p.status = '1'
-        <if test="id != null">
-            and p.id = #{id}
-        </if>
-        <if test="orgIds != null and orgIds != ''">
-            and p.org_id in (${orgIds})
-        </if>
-        union
-        select 0,0,0,0,0,0, 0, sum(o.order_amount) as num8 , 0 from bt_order o
-        <if test="orgIds != null and orgIds != ''">
-            left join imcs_tenant_productionresource p on o.order_equ_id = p.id
-            where p.org_id in (${orgIds})
-        </if>
-        <if test="orgIds == null ">
-            where 1 = 1
-        </if>
-        <if test="yesterday != null">
-            and o.create_time >= #{yesterday, jdbcType=TIMESTAMP}
-        </if>
-        <if test="now != null">
-            and o.create_time <![CDATA[ <= ]]> #{now, jdbcType=TIMESTAMP}
-        </if>
-        <if test="id != null">
-            and o.order_equ_id = #{id}
-        </if>
-        and o.order_status = '6'
-        union
-        select 0,0,0,0,0,0, 0, 0, count(distinct p.id) from imcs_tenant_productionresource p left join bt_equ_barrel b on b.equ_id = p.id
-        where p.status = '1' and b.residue_warn>=b.mtr_residue
-        <if test="id != null">
-            and p.id = #{id}
-        </if>
-        <if test="orgIds != null and orgIds != ''">
-            and p.org_id in (${orgIds})
-        </if>
-        ) f
+
+        SELECT
+        SUM(
+        CASE
+        WHEN create_time >= date_format(current_date(),'%Y-%m-%d') THEN
+        1
+        ELSE
+        0
+        END
+        ) AS todayNum,
+        SUM(
+        CASE
+        WHEN create_time >= date_format(current_date(),'%Y-%m-%d') THEN
+        order_amount
+        ELSE
+        0
+        END
+        ) AS todayAmount,
+        SUM(
+        CASE
+        WHEN create_time >= date_format(current_date()-7,'%Y-%m-%d') THEN
+        1
+        ELSE
+        0
+        END
+        ) AS sevenNum,
+        SUM(
+        CASE
+        WHEN create_time >= date_format(current_date()-7,'%Y-%m-%d') THEN
+        order_amount
+        ELSE
+        0
+        END
+        ) AS sevenAmount,
+        SUM(
+        CASE
+        WHEN order_status='4' THEN
+        1
+        ELSE
+        0
+        END
+        ) AS exceptNum,
+        SUM(
+        CASE
+        WHEN order_status='4' THEN
+        1
+        ELSE
+        0
+        END
+        ) AS errMsgNum,
+        SUM(
+        CASE
+        WHEN create_time >= date_format(current_date()-1,'%Y-%m-%d') THEN
+        order_amount
+        ELSE
+        0
+        END
+        ) AS yesterdayAmount,
+        (SELECT COUNT(1) FROM imcs_tenant_productionresource p where p.status = '1') AS deviceNum,
+        0 AS lackDevice
+        FROM
+        bt_order;
     </select>
 </mapper>

+ 3 - 3
imcs-bt-be/imcs-business-controller/pom.xml

@@ -16,19 +16,19 @@
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-context</artifactId>
-            <version>RELEASE</version>
+            <version>5.2.8.RELEASE</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-web</artifactId>
-            <version>RELEASE</version>
+            <version>5.2.8.RELEASE</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-context</artifactId>
-            <version>RELEASE</version>
+            <version>5.2.8.RELEASE</version>
             <scope>compile</scope>
         </dependency>
         <dependency>

+ 20 - 20
imcs-bt-be/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/productionresource/ProductionResourceController.java

@@ -58,7 +58,8 @@ import java.util.stream.Collectors;
 @RequestMapping("/productionResource")
 @Api(value = "ProductionResource", tags = "生产资源")
 @PreAuth(replace = "productionResource:")
-public class ProductionResourceController extends SuperController<ProductionTenantResourceService, Long, ProductionResource, ProductionResourcePageDTO, ProductionResourceSaveDTO, ProductionResourceUpdateDTO> {
+public class ProductionResourceController extends SuperController<ProductionTenantResourceService, Long,
+        ProductionResource, ProductionResourcePageDTO, ProductionResourceSaveDTO, ProductionResourceUpdateDTO> {
     @Autowired
     private SpeService speService;
     @Autowired
@@ -88,10 +89,11 @@ public class ProductionResourceController extends SuperController<ProductionTena
         ProductionResource model = BeanUtil.toBean(data, ProductionResource.class);
         QueryWrap<ProductionResource> wrap = this.handlerWrapper(null, params);
         LbqWrapper<ProductionResource> wrapper = wrap.lambda();
-        wrapper.like(ProductionResource::getName, model.getName()).like(ProductionResource::getStatus, model.getStatus()).eq(ProductionResource::getPlaceId, model.getPlaceId())
+        wrapper.like(ProductionResource::getName, model.getName()).like(ProductionResource::getStatus,
+                        model.getStatus()).eq(ProductionResource::getPlaceId, model.getPlaceId())
                 .eq(ProductionResource::getAreaId, model.getAreaId())
                 .orderByDesc(ProductionResource::getCreateTime);
-        if(StringUtils.isNotEmpty(model.getOnlineStatus())){
+        if (StringUtils.isNotEmpty(model.getOnlineStatus())) {
             //获取特定状态下的设备Id
             List<String> ids = baseService.getEquStatusIds(model.getOnlineStatus());
             wrapper.in(ProductionResource::getId, ids);
@@ -99,9 +101,11 @@ public class ProductionResourceController extends SuperController<ProductionTena
         IPage<ProductionResource> iPage = baseService.pageList(page, wrapper);
 
         String date = DateUtil.dateToString(new Date());
-        iPage.getRecords().forEach(item->{
+        iPage.getRecords().forEach(item -> {
             QueryWrap<Order> orderQueryWrap = new QueryWrap<Order>();
-            orderQueryWrap.select("ifnull(sum(order_amount), 0.0) as orderSum").eq("order_equ_id", item.getId()).eq("order_status","1") .geHeader("create_time", DateUtils.getStartTime(date)).leFooter("create_time", DateUtils.getEndTime(date));
+            orderQueryWrap.select("ifnull(sum(order_amount), 0.0) as orderSum").eq("order_equ_id", item.getId()).eq(
+                    "order_status", "1").geHeader("create_time", DateUtils.getStartTime(date)).leFooter("create_time"
+                    , DateUtils.getEndTime(date));
             Order sumOrder = orderService.getOne(orderQueryWrap);
             Float incomeToday = sumOrder.getOrderSum().floatValue();
             item.setIncomeToday(incomeToday);
@@ -182,9 +186,9 @@ public class ProductionResourceController extends SuperController<ProductionTena
 
     @ApiOperation(value = "获取设备状态统计", notes = "获取设备状态统计")
     @PostMapping("/equStatistics")
-    public R<Map<String, Integer>> equStatistics(){
+    public R<Map<String, Integer>> equStatistics() {
 
-        Map<String, Integer> map = new HashMap<String, Integer>(){
+        Map<String, Integer> map = new HashMap<String, Integer>() {
             {
                 put("onLineCount", 0);
                 put("offlineCount", 0);
@@ -192,27 +196,23 @@ public class ProductionResourceController extends SuperController<ProductionTena
             }
         };
         LbqWrapper<ProductionResource> lbqWrapper = Wraps.<ProductionResource>lbQ();
-        if(CommonUtil.getOrgIdsArr().size()>0) {
+        if (CommonUtil.getOrgIdsArr().size() > 0) {
             lbqWrapper.in(ProductionResource::getOrgId, CommonUtil.getOrgIdsArr());
         }
         List<ProductionResource> list = baseService.list(lbqWrapper);
-        list.stream().forEach(item->{
+        list.stream().forEach(item -> {
             Map<String, String> resultMap = baseService.getEquRunInfo(item.getId());
-            String equStatus =  resultMap.get("equStatus");
-            if(equStatus.equals("0")){
-                map.put("offlineCount", map.get("offlineCount")+1);
-            }else if(equStatus.equals("1")){
-                map.put("onLineCount", map.get("onLineCount")+1);
-            }else{
-                map.put("exceptCount", map.get("exceptCount")+1);
+            String equStatus = resultMap.get("equStatus");
+            if (equStatus.equals("0")) {
+                map.put("offlineCount", map.get("offlineCount") + 1);
+            } else if (equStatus.equals("1")) {
+                map.put("onLineCount", map.get("onLineCount") + 1);
+            } else {
+                map.put("exceptCount", map.get("exceptCount") + 1);
             }
         });
         return R.success(map);
     }
 
 
-
-
-
-
 }

+ 1 - 0
imcs-bt-be/imcs-jobs/imcs-jobs-core/pom.xml

@@ -45,6 +45,7 @@
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-context</artifactId>
+            <version>5.2.8.RELEASE</version>
             <scope>provided</scope>
         </dependency>