wenhongquan 10 месяцев назад
Родитель
Сommit
e0e440ddd4

+ 1 - 1
ruoyi-admin/src/main/resources/application-dev.yml

@@ -12,7 +12,7 @@ spring.boot.admin.client:
 powerjob:
   worker:
     # 如何开启调度中心请查看文档教程
-    enabled: false
+    enabled: true
     # 需要先在 powerjob 登录页执行应用注册后才能使用
     app-name: ruoyi-worker
     allow-lazy-connect-server: false

+ 2 - 2
ruoyi-extend/ruoyi-powerjob-server/src/main/resources/application-dev.properties

@@ -2,9 +2,9 @@ oms.env=dev
 
 ####### Database properties(Configure according to the the environment) #######
 spring.datasource.core.driver-class-name=com.mysql.cj.jdbc.Driver
-spring.datasource.core.jdbc-url=jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
+spring.datasource.core.jdbc-url=jdbc:mysql://127.0.0.1:3306/khyznh?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
 spring.datasource.core.username=root
-spring.datasource.core.password=root
+spring.datasource.core.password=123456
 spring.datasource.core.maximum-pool-size=20
 spring.datasource.core.minimum-idle=5
 

+ 4 - 2
ruoyi-modules/ruoyi-dzbc/src/main/java/org/dromara/system/controller/TblDzbcPathSchedulingController.java

@@ -324,7 +324,8 @@ public class TblDzbcPathSchedulingController extends BaseController {
                                 if(xs==null) xs = 0.0;
                                 if(distanceSite1>=min && distanceSite1<=max){
                                     double jg = (p*100)+(((distanceSite1-min)/1000.0)*xs)*100;
-                                    tblDzbcPathSchedulingVo.setPrice((int)Math.round(jg));
+                                    int finalResult = (((int) Math.round(jg) + 5) / 10) * 10;
+                                    tblDzbcPathSchedulingVo.setPrice(finalResult);
                                     break;
                                 }
                             }
@@ -343,8 +344,9 @@ public class TblDzbcPathSchedulingController extends BaseController {
                     if(price1==null) return R.fail("路线价格未设置");
                     //单价 根据区域-区域 单价及站点-站点 计算价格
                     double price = price1*(distanceSite/distanceArea);
+                    int finalResult = (((int)Math.round(price+tblDzbcPathSchedulingVo.getPprice()) + 5) / 10) * 10;
                     //计算加价
-                    tblDzbcPathSchedulingVo.setPrice((int)Math.round(price+tblDzbcPathSchedulingVo.getPprice()));
+                    tblDzbcPathSchedulingVo.setPrice(finalResult);
                 }
             } catch (Exception e) {
                 return  R.fail("站点信息错误");

+ 4 - 2
ruoyi-modules/ruoyi-dzbc/src/main/java/org/dromara/system/service/impl/TblDzbcOrderServiceImpl.java

@@ -214,7 +214,8 @@ public class TblDzbcOrderServiceImpl implements ITblDzbcOrderService {
                         if (xs == null) xs = 0.0;
                         if (distanceSite1 >= min && distanceSite1 <= max) {
                             double jg = (p * 100) + (((distanceSite1-min)/1000.0) * xs)*100;
-                            add.setPrice((int) Math.round(jg));
+                            int finalResult = (((int) Math.round(jg) + 5) / 10) * 10;
+                            add.setPrice(finalResult);
                             break;
                         }
                     }
@@ -229,7 +230,8 @@ public class TblDzbcOrderServiceImpl implements ITblDzbcOrderService {
             //单价 根据区域-区域 单价及站点-站点 计算价格
             double price = price1*(distanceSite/distanceArea);
             //计算加价
-            add.setPrice((int)Math.round(price+scheduling.getPprice()));
+            int finalResult = (((int)Math.round(price+scheduling.getPprice()) + 5) / 10) * 10;
+            add.setPrice(finalResult);
         }
 //
 //        //单价 根据区域-区域 单价及站点-站点 计算价格

+ 6 - 1
ruoyi-modules/ruoyi-khy/pom.xml

@@ -185,7 +185,12 @@
             <groupId>org.dromara</groupId>
             <artifactId>ruoyi-system</artifactId>
         </dependency>
-
+        <dependency>
+            <groupId>tech.powerjob</groupId>
+            <artifactId>powerjob-worker</artifactId>
+            <version>4.3.6</version>
+            <scope>compile</scope>
+        </dependency>
 
 
     </dependencies>

+ 78 - 1
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/system/controller/TblBagController.java

@@ -1,11 +1,25 @@
 package org.dromara.system.controller;
 
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.json.JSONArray;
+import cn.hutool.json.JSONObject;
+import cn.hutool.json.JSONUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.RequiredArgsConstructor;
 import jakarta.servlet.http.HttpServletResponse;
 import jakarta.validation.constraints.*;
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import org.dromara.common.core.utils.SpringUtils;
+import org.dromara.system.domain.bo.SysDictDataBo;
+import org.dromara.system.domain.vo.SysDictDataVo;
+import org.dromara.system.service.ISysDictDataService;
+import org.dromara.util.SPlatUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.validation.annotation.Validated;
 import org.dromara.common.idempotent.annotation.RepeatSubmit;
@@ -31,7 +45,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
 @Validated
 @RequiredArgsConstructor
 @RestController
-@RequestMapping("/system/bag")
+@RequestMapping("/upsystem/bag")
 public class TblBagController extends BaseController {
 
     private final ITblBagService tblBagService;
@@ -80,4 +94,67 @@ public class TblBagController extends BaseController {
                           @PathVariable Long[] ids) {
         return toAjax(tblBagService.deleteWithValidByIds(List.of(ids), true));
     }
+
+
+    @PostMapping("/sysc/{ids}")
+    public R<Void> sysc(@NotEmpty(message = "主键不能为空")
+                            @PathVariable Long[] ids) {
+        Map<String, JSONObject> cabinetMap2 = new HashMap<>();
+        //获取所有快递柜的快递信息
+        Map<String, JSONObject> cabinetMap = new HashMap<>();
+        SysDictDataBo bo =new SysDictDataBo();
+        bo.setDictType("tbl_sites");
+        List<SysDictDataVo> list = SpringUtils.getBean(ISysDictDataService.class).selectDictDataList(bo);
+        try {
+            list.forEach(item->{
+                if(StrUtil.isNotEmpty(item.getRemark())){
+                    JSONArray jsonArray = JSONUtil.parseArray(item.getRemark());
+                    jsonArray.forEach(item2->{
+                        if(((JSONObject)item2).getStr("type").equals("cabinet")){
+                            ((JSONObject) item2).put("location",item.getDictValue());
+                            cabinetMap.put( item.getDictLabel(),(JSONObject)item2);
+                            cabinetMap2.put(((JSONObject) item2).getStr("cabinetType"),(JSONObject)item2);
+                        }
+                    });
+                }
+            });
+        }catch (Exception e){
+
+        }
+        TblBagBo bo1 =new TblBagBo();
+        bo1.getParams().put("remark","");
+
+        QueryWrapper queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("remark","");
+        queryWrapper.in("id", ids);
+        List<TblBagVo> bagList =  tblBagService.queryList(queryWrapper);
+        List<JSONObject> jsonObjectList1 = new ArrayList<>();
+        List<TblBagVo> sysd = new ArrayList<>();
+        if(bagList!=null && bagList.size()>0) {
+            bagList.forEach(item->{
+                if(cabinetMap2.containsKey(item.getDeviceId().toString())){
+                    JSONObject json = new JSONObject();
+                    json.put("deviceId",item.getDeviceId());
+                    json.put("cpCode",item.getCpCode());
+                    json.put("waybillNo",item.getWaybillNo());
+                    json.put("scTime",item.getScTime());
+                    json.put("scType",item.getScType());
+                    jsonObjectList1.add(json);
+                    sysd.add(item);
+                }
+
+            });
+
+            SPlatUtils.pushExpressInfo(jsonObjectList1);
+            if(sysd!=null && sysd.size()>0) {
+                sysd.forEach(item -> {
+                    item.setRemark("已同步");
+                    TblBagBo item1 = new TblBagBo();
+                    BeanUtils.copyProperties(item, item1);
+                    SpringUtils.getBean(ITblBagService.class).updateByBo(item1);
+                });
+            }
+        }
+        return R.ok();
+    }
 }

+ 3 - 0
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/system/service/ITblBagService.java

@@ -1,5 +1,6 @@
 package org.dromara.system.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import org.dromara.system.domain.TblBag;
 import org.dromara.system.domain.vo.TblBagVo;
 import org.dromara.system.domain.bo.TblBagBo;
@@ -32,6 +33,8 @@ public interface ITblBagService {
      */
     List<TblBagVo> queryList(TblBagBo bo);
 
+    List<TblBagVo> queryList(QueryWrapper qWrapper);
+
     /**
      * 新增【请填写功能名称】
      */

+ 11 - 0
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/system/service/impl/TblBagServiceImpl.java

@@ -1,5 +1,6 @@
 package org.dromara.system.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
@@ -58,6 +59,11 @@ public class TblBagServiceImpl implements ITblBagService {
         return baseMapper.selectVoList(lqw);
     }
 
+    @Override
+    public List<TblBagVo> queryList(QueryWrapper qWrapper) {
+        return baseMapper.selectVoList(qWrapper);
+    }
+
     private LambdaQueryWrapper<TblBag> buildQueryWrapper(TblBagBo bo) {
         Map<String, Object> params = bo.getParams();
         LambdaQueryWrapper<TblBag> lqw = Wrappers.lambdaQuery();
@@ -66,6 +72,11 @@ public class TblBagServiceImpl implements ITblBagService {
         lqw.eq(bo.getScTime() != null, TblBag::getScTime, bo.getScTime());
         lqw.eq(StringUtils.isNotBlank(bo.getCpCode()), TblBag::getCpCode, bo.getCpCode());
         lqw.eq(StringUtils.isNotBlank(bo.getWaybillNo()), TblBag::getWaybillNo, bo.getWaybillNo());
+        if(bo.getParams()!=null && bo.getParams().size()>0){
+            if(bo.getParams().get("remark")!=null){
+                lqw.eq(bo.getParams().get("remark")!=null, TblBag::getRemark, "");
+            }
+        }
         return lqw;
     }
 

+ 72 - 25
ruoyi-modules/ruoyi-khy/src/main/java/org/dromara/util/CabinetUtil.java

@@ -23,14 +23,19 @@ import org.dromara.system.domain.bo.*;
 import org.dromara.system.domain.vo.*;
 import org.dromara.system.service.ISysDictDataService;
 import org.dromara.system.service.ISysUserService;
+import org.dromara.system.service.ITblBagService;
 import org.dromara.system.service.ITblExpressStaticsService;
 import org.dromara.system.service.impl.TblCarInfoServiceImpl;
 import org.dromara.system.service.impl.TblCarScheduleServiceImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
+import tech.powerjob.worker.core.processor.ProcessResult;
+import tech.powerjob.worker.core.processor.TaskContext;
+import tech.powerjob.worker.core.processor.sdk.BasicProcessor;
 
 import javax.crypto.Cipher;
 import java.io.UnsupportedEncodingException;
@@ -41,7 +46,7 @@ import java.time.format.DateTimeFormatter;
 import java.util.*;
 
 @Component
-public class CabinetUtil {
+public class CabinetUtil implements BasicProcessor {
 
     private  final static String appid = "bw_open_express_A8C848769E5C04E0";
     private  final static String appkey = "5AFC6E07CFCF4A359B775D1416A9799A";
@@ -287,10 +292,12 @@ public class CabinetUtil {
     }
 
 
-    @Scheduled(fixedRate = 2*60*60*1000)
+//    @Scheduled(fixedRate = 2*60*60*1000)
     public void getExpressHistory() throws UnsupportedEncodingException {
+        Map<String, JSONObject> cabinetMap2 = new HashMap<>();
         //获取所有快递柜的快递信息
         Map<String, JSONObject> cabinetMap = new HashMap<>();
+
         SysDictDataBo bo =new SysDictDataBo();
         bo.setDictType("tbl_sites");
         List<SysDictDataVo> list = SpringUtils.getBean(ISysDictDataService.class).selectDictDataList(bo);
@@ -302,6 +309,7 @@ public class CabinetUtil {
                         if(((JSONObject)item2).getStr("type").equals("cabinet")){
                             ((JSONObject) item2).put("location",item.getDictValue());
                             cabinetMap.put( item.getDictLabel(),(JSONObject)item2);
+                            cabinetMap2.put(((JSONObject) item2).getStr("cabinetType"),(JSONObject)item2);
                         }
                     });
                 }
@@ -309,28 +317,41 @@ public class CabinetUtil {
         }catch (Exception e){
 
         }
-        if(cabinetMap!=null && cabinetMap.size()>0) {
-            try {
-
-                List<JSONObject> cabinetList = new ArrayList<>();
-                cabinetMap.keySet().forEach(i->{
-                    JSONObject c = cabinetMap.get(i);
-                    if(c.getStr("location")!=null&&c.getStr("wdcode")!=null){
-                        c.put("deviceId", c.getStr("code"));
-                        c.put("stationId", c.getStr("wdcode"));
-                        c.put("deviceType", "cabinet");
-                        cabinetList.add(c);
-                    }
-                } );
+        //获取历史
+        try {
 
-                SPlatUtils.SysDevice(cabinetList);
-            }catch (Exception e){
 
-            }
+//            TblBagBo bo1 =new TblBagBo();
+//            bo1.getParams().put("remark","");
+//            List<TblBagVo> bagList =  SpringUtils.getBean(ITblBagService.class).queryList(bo1);
+//            List<JSONObject> jsonObjectList1 = new ArrayList<>();
+//            List<TblBagVo> sysd = new ArrayList<>();
+//            if(bagList!=null && bagList.size()>0) {
+//                bagList.forEach(item->{
+//                    if(cabinetMap2.containsKey(item.getDeviceId().toString())){
+//                        JSONObject json = new JSONObject();
+//                        json.put("deviceId",item.getDeviceId());
+//                        json.put("cpCode",item.getCpCode());
+//                        json.put("waybillNo",item.getWaybillNo());
+//                        json.put("scTime",item.getScTime());
+//                        json.put("scType",item.getScType());
+//                        jsonObjectList1.add(json);
+//                        sysd.add(item);
+//                    }
+//
+//                });
+//
+//                SPlatUtils.pushExpressInfo(jsonObjectList1);
+//                if(sysd!=null && sysd.size()>0) {
+//                    sysd.forEach(item -> {
+//                        item.setRemark("已同步");
+//                        TblBagBo item1 = new TblBagBo();
+//                        BeanUtils.copyProperties(item, item1);
+//                        SpringUtils.getBean(ITblBagService.class).updateByBo(item1);
+//                    });
+//                }
+//            }
 
-        }
-        //获取历史
-        try {
             Map<String,String> map = new HashMap<>();
             map.put("start_ctime ", DateUtil.format( DateUtil.offsetHour(DateUtil.date(),-2), "yyyy-MM-dd HH:mm:ss"));
             map.put("end_ctime ", DateUtil.format( DateUtil.date(), "yyyy-MM-dd HH:mm:ss"));
@@ -359,10 +380,35 @@ public class CabinetUtil {
             }
             SPlatUtils.pushExpressInfo(jsonObjectList);
 
+
+
+
         }catch (Exception e){
 
         }
 
+        if(cabinetMap!=null && cabinetMap.size()>0) {
+            try {
+
+                List<JSONObject> cabinetList = new ArrayList<>();
+                cabinetMap.keySet().forEach(i->{
+                    JSONObject c = cabinetMap.get(i);
+                    if(c.getStr("location")!=null&&c.getStr("wdcode")!=null){
+                        c.put("deviceId", c.getStr("code"));
+                        c.put("stationId", c.getStr("wdcode"));
+                        c.put("deviceType", "cabinet");
+                        cabinetList.add(c);
+                    }
+                } );
+
+                SPlatUtils.SysDevice(cabinetList);
+            }catch (Exception e){
+
+            }
+
+        }
+
+
 
 
 
@@ -576,8 +622,9 @@ public class CabinetUtil {
     }
 
 
-
-
-
-
+    @Override
+    public ProcessResult process(TaskContext taskContext) throws Exception {
+        getExpressHistory();
+        return new ProcessResult(true, "定时任务执行成功");
+    }
 }