Просмотр исходного кода

Merge remote-tracking branch 'origin/dev' into dev

xucaiqin 2 лет назад
Родитель
Сommit
c2d1de0e78
27 измененных файлов с 637 добавлено и 124 удалено
  1. 1 4
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/aspect/DaoAspect.java
  2. 56 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/common/enums/enums/FileDisposeLayoutEnum.java
  3. 14 13
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/filter/RequestCheckFilter.java
  4. 158 10
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/FileUtils.java
  5. 38 37
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/LocUtils.java
  6. 1 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/web/constant/HttpStatus.java
  7. 2 0
      sckw-modules/sckw-file/src/main/java/com/sckw/file/config/FileListConfig.java
  8. 34 0
      sckw-modules/sckw-file/src/main/java/com/sckw/file/config/FileOssConfig.java
  9. 33 0
      sckw-modules/sckw-file/src/main/java/com/sckw/file/controller/FileApiController.java
  10. 20 0
      sckw-modules/sckw-file/src/main/java/com/sckw/file/dao/KwsFileEncryptDao.java
  11. 40 0
      sckw-modules/sckw-file/src/main/java/com/sckw/file/model/kwfFileEncrypt.java
  12. 5 0
      sckw-modules/sckw-file/src/main/java/com/sckw/file/model/kwfFileInfo.java
  13. 99 7
      sckw-modules/sckw-file/src/main/java/com/sckw/file/service/FileService.java
  14. 22 0
      sckw-modules/sckw-file/src/main/resources/mapper/KwsFileEncryptDao.xml
  15. 5 1
      sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfTruckService.java
  16. 2 2
      sckw-modules/sckw-fleet/src/main/resources/bootstrap.yml
  17. 49 21
      sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwTransportService.java
  18. 3 2
      sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsEnterpriseController.java
  19. 28 6
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsEnterpriseService.java
  20. 0 1
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsUserService.java
  21. 1 1
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dubbo/TransportDubboServiceImpl.java
  22. 7 3
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/WaybillOrderDriverVo.java
  23. 13 10
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/CommonService.java
  24. 2 2
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ConsignOrderService.java
  25. 1 1
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ManagementWaybillOrderService.java
  26. 1 1
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/TransportCommonService.java
  27. 2 2
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/WaybillManagementService.java

+ 1 - 4
sckw-common/sckw-common-core/src/main/java/com/sckw/core/aspect/DaoAspect.java

@@ -60,7 +60,7 @@ public class DaoAspect {
                 }
                 Long userId = LoginUserHolder.getUserId();
                 objs.forEach(obj -> {
-                    if (isProperty(obj, UPDATE_BY) && userId != null) {
+                    if (isProperty(obj, UPDATE_BY) && !userId.equals(1L)) {
                         BeanUtils.setProperty(obj, UPDATE_BY, userId);
                     }
                     if (isProperty(obj, UPDATE_TIME)) {
@@ -89,9 +89,6 @@ public class DaoAspect {
                 Date date = new Date();
                 objs.forEach(obj -> {
                     Long userId = LoginUserHolder.getUserId();
-                    if (userId == null) {
-                        userId = 1L;
-                    }
                     if (isProperty(obj, CREATE_BY) && Objects.isNull(BeanUtils.getProperty(obj, CREATE_BY))) {
                         BeanUtils.setProperty(obj, CREATE_BY, userId);
                     }

+ 56 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/common/enums/enums/FileDisposeLayoutEnum.java

@@ -0,0 +1,56 @@
+package com.sckw.core.common.enums.enums;
+
+/**
+ * @author lfdc
+ * @description 文件格式布局枚举
+ * @date 2023-10-07 09:10:42
+ */
+public enum FileDisposeLayoutEnum {
+
+    /**
+     * ?x-oss-process=image/resize,m_lfit,h_200,w_200
+     *
+     * 图片格式只能是:JPG、PNG、BMP、GIF、WebP、TIFF。
+     */
+
+    /**
+     * oss裁剪比例大小-左
+     */
+    OSS_ABBREVIATE_LEFT(FileEnum.FILE_STORE_TYPE_OSS.getFileType(), "?x-oss-process=image/resize,m_lfit,h_", "OSS设置文件大小"),
+
+    /**
+     * oss裁剪比例大小-右
+     */
+    OSS_ABBREVIATE_RIGHT(FileEnum.FILE_STORE_TYPE_OSS.getFileType(), ",w_", "OSS设置文件大小"),
+    /**
+     * oss按照比例缩放
+     */
+    OSS_LESSEN(FileEnum.FILE_STORE_TYPE_OSS.getFileType(), "?x-oss-process=image/resize,p_12", "按百分比缩放"),
+    /**
+     * 七牛云缩略图
+     */
+    KODO_ABBREVIATE(FileEnum.FILE_STORE_TYPE_ALIYUN.getFileType(), "-indexthumb", "缩略图"),
+    ;
+
+    private final String type;
+    private final String parameter;
+    private final String description;
+
+    public String getType() {
+        return type;
+    }
+
+    public String getParameter() {
+        return parameter;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    FileDisposeLayoutEnum(String type, String parameter, String description) {
+        this.type = type;
+        this.parameter = parameter;
+        this.description = description;
+    }
+}

+ 14 - 13
sckw-common/sckw-common-core/src/main/java/com/sckw/core/filter/RequestCheckFilter.java

@@ -112,22 +112,12 @@ public class RequestCheckFilter implements Filter {
         String key = Global.getFullUserLoginKey(NumberUtils.parseInt(systemType), userId);
         String userInfoStr = RedissonUtils.getString(key);
         LoginUserInfo loginUserInfo = StringUtils.isNotBlank(userInfoStr) ? JSON.parseObject(userInfoStr, LoginUserInfo.class) : null;
-        if (StringUtils.isBlank(userInfoStr) || loginUserInfo == null) {
+        if (Objects.isNull(loginUserInfo)) {
             ResponseUtil.writer(response, HttpResult.error(HttpStatus.TOKEN_INVALID_CODE, HttpStatus.TOKEN_INVALID_MESSAGE));
             return;
         }
 
 
-        if (loginUserInfo.getIsMain() == Global.YES && Integer.parseInt(systemType) == SystemTypeEnum.MANAGE.getCode()) {
-            LoginUserHolder.set(loginUserInfo);
-            RedissonUtils.putString(Global.getFullUserTokenKey(clientType, userId), token, ClientTypeEnum.expireTime(clientType));
-            RedissonUtils.putString(Global.getFullUserLoginKey(NumberUtils.parseInt(systemType), loginUserInfo.getId()), JSON.toJSONString(loginUserInfo), Global.APP_TOKEN_EXPIRE);
-            RedissonUtils.putString(Global.getFullUserTokenKey(clientType, userId), token, ClientTypeEnum.expireTime(clientType));
-            filterChain.doFilter(servletRequest, servletResponse);
-            LoginUserHolder.remove();
-            return;
-        }
-
         //校验用户账号是否冻结
         if (loginUserInfo.getStatus() == Global.YES) {
             ResponseUtil.writer(response, HttpResult.error(HttpStatus.TOKEN_INVALID_CODE, "您的账号已被冻结,请联系系统管理员!"));
@@ -137,6 +127,18 @@ public class RequestCheckFilter implements Filter {
         /*4、登录中的企业信息*/
         String loginEntStr = RedissonUtils.getString(Global.getFullUserEntKey(loginUserInfo.getEntId()));
         LoginEntInfo loginEntInfo = StringUtils.isNotBlank(loginEntStr) ? JSON.parseObject(loginEntStr, LoginEntInfo.class) : null;
+
+        if (loginUserInfo.getIsMain() == Global.YES && SystemTypeEnum.MANAGE.getCode().equals(Integer.parseInt(systemType))) {
+            LoginUserHolder.set(loginUserInfo);
+            LoginEntHolder.set(loginEntInfo);
+            RedissonUtils.putString(Global.getFullUserTokenKey(clientType, userId), token, ClientTypeEnum.expireTime(clientType));
+            RedissonUtils.putString(Global.getFullUserLoginKey(NumberUtils.parseInt(systemType), loginUserInfo.getId()), JSON.toJSONString(loginUserInfo), Global.APP_TOKEN_EXPIRE);
+            RedissonUtils.putString(Global.getFullUserEntKey(loginEntInfo.getId()), JSON.toJSONString(loginEntInfo), Global.APP_TOKEN_EXPIRE);
+            filterChain.doFilter(servletRequest, servletResponse);
+            LoginUserHolder.remove();
+            return;
+        }
+
         if ((StringUtils.isBlank(loginEntStr) || loginEntInfo == null) && NumberUtils.parseInt(systemType) != SystemTypeEnum.MANAGE.getCode()) {
             ResponseUtil.writer(response, HttpResult.error(HttpStatus.TOKEN_INVALID_CODE, HttpStatus.UN_LOGIN_MESSAGE));
             return;
@@ -175,7 +177,6 @@ public class RequestCheckFilter implements Filter {
 
         LoginUserHolder.set(loginUserInfo);
         LoginEntHolder.set(loginEntInfo);
-        RedissonUtils.putString(Global.getFullUserTokenKey(clientType, userId), token, ClientTypeEnum.expireTime(clientType));
         RedissonUtils.putString(Global.getFullUserLoginKey(NumberUtils.parseInt(systemType), loginUserInfo.getId()), JSON.toJSONString(loginUserInfo), Global.APP_TOKEN_EXPIRE);
         RedissonUtils.putString(Global.getFullUserEntKey(loginEntInfo.getId()), JSON.toJSONString(loginEntInfo), Global.APP_TOKEN_EXPIRE);
         RedissonUtils.putString(Global.getFullUserTokenKey(clientType, userId), token, ClientTypeEnum.expireTime(clientType));
@@ -197,7 +198,7 @@ public class RequestCheckFilter implements Filter {
     }
 
     public static void main(String[] args) {
-        Map<String, Object> tokenMap = EncryUtil.descryV2(Global.PRI_KEY, "dade5058e78847ca5672263c5b821fc09d06083611ab0f6d076af88f082f05384838b3714729e48088c6fc1d1c09763e85e35675a20ac9df50e443b92e1c18e06f9951c7d6a2905a79b889f8617ab143fc97350b5c68f0512f7c18dbf2e49eaf");
+        Map<String, Object> tokenMap = EncryUtil.descryV2(Global.PRI_KEY, "dade5058e78847ca5672263c5b821fc09d06083611ab0f6d076af88f082f0538569486c2369c2aae99f2a8fc7a7de07b57aa7ffadb3c958ef83cb50a10819703d3cb745c501326d65d50ed5aba830326eb64a75b0479f896763a9810e847f430");
         System.out.println(tokenMap);
     }
 }

+ 158 - 10
sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/FileUtils.java

@@ -17,8 +17,12 @@ import org.springframework.context.annotation.Configuration;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.image.BufferedImage;
 import java.io.*;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.net.URL;
 import java.net.URLEncoder;
 import java.text.DecimalFormat;
@@ -68,7 +72,7 @@ public class FileUtils {
     @Value("${aliyun.oss.bucket}")
     public String oss_bucketName;
 
-    private static void defalutOSS() {
+    private static void defaultOss() {
         if (StringUtils.isBlank(endpoint)) {
             endpoint = DEFAULT_ENDPOINT;
         }
@@ -128,7 +132,7 @@ public class FileUtils {
      * @return
      */
     public static String getOSSAddressPrefix() {
-        defalutOSS();
+        defaultOss();
         return StringConstant.HTTPS_STRING
                 + StringConstant.COLON
                 + StringConstant.LEFT_SEPARATORS
@@ -240,7 +244,7 @@ public class FileUtils {
     public static Map<String, String> uploadFileByInfo(MultipartFile file, FileEnum fileEnum) {
         Map<String, String> infoMap = new HashMap<>(NumberConstant.SIXTEEN);
         //创建OSSClient实例
-        defalutOSS();
+        defaultOss();
         OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
         try {
             //容器不存在,就创建
@@ -312,7 +316,7 @@ public class FileUtils {
         conf.setSupportCname(false);
         try {
             //创建OSSClient实例
-            defalutOSS();
+            defaultOss();
             OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
 
             //容器不存在,就创建
@@ -367,7 +371,7 @@ public class FileUtils {
     public static Map<String, String> uploadFileByInfo(InputStream inputStream, String originalFilename, FileEnum fileEnum) {
         Map<String, String> infoMap = new HashMap<>(NumberConstant.SIXTEEN);
         //创建OSSClient实例
-        defalutOSS();
+        defaultOss();
         OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
         try {
             //容器不存在,就创建
@@ -427,7 +431,7 @@ public class FileUtils {
      */
     public static FileInfo uploadFileInfo(MultipartFile file, FileInfo fileInfo, FileEnum fileEnum) {
         //创建OSSClient实例
-        defalutOSS();
+        defaultOss();
         OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
         try {
             //容器不存在,就创建
@@ -536,8 +540,7 @@ public class FileUtils {
             default:
                 throw new RuntimeException("file size error");
         }
-        bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP);
-        return bigDecimal;
+        return bigDecimal.setScale(6, RoundingMode.HALF_UP);
     }
 
     /**
@@ -581,7 +584,7 @@ public class FileUtils {
     public static void downOSSFile(String fileName, HttpServletResponse response) {
         BufferedInputStream input = null;
         OutputStream outputStream = null;
-        defalutOSS();
+        defaultOss();
         OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
 //        OSSObject ossObject = ossClient.getObject(bucketName, folder + fileName);
         OSSObject ossObject = ossClient.getObject(bucketName, fileName);
@@ -628,7 +631,7 @@ public class FileUtils {
      *                 文件全路径 kll/uploads/20230605/146325493677821952598454132.txt 去除“https://kaiwu-saas.oss-cn-chengdu.aliyuncs.com/”
      */
     public static void downloadByFileName(HttpServletResponse response, String fileName) {
-        defalutOSS();
+        defaultOss();
         OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
         OSSObject ossObject = ossClient.getObject(bucketName, fileName);
         boolean exist = ossClient.doesObjectExist(bucketName, fileName);
@@ -1234,6 +1237,151 @@ public class FileUtils {
 
     }
 
+    final static String IMG_FORMAT = "png_jpg_bmp_gif_tif_jpeg_PNG_JPG_BMP_GIF_TIF_JPEG_HEIC_heic";
+    final static String IMG_FORMAT_NUMBER = "8950_ffd8_424d_4749_4d4d_4949_5249";
+
+
+    /**
+     * 针对图片内容的格式效验。
+     * 分别以:
+     * 1:判断后缀名的方式判断是否为图片
+     * 2:以魔术数字进行判断
+     * 3:以imageIO流的方式验证是否为图片
+     *
+     * @param mFile
+     * @return boolean
+     * @author lihao
+     */
+    public static boolean isImage(MultipartFile mFile) {
+        File file = null;
+        InputStream is = null;
+        Image img = null;
+        byte[] bt = new byte[2];
+        try {
+            file = multipartFile2File(mFile);
+            is = new FileInputStream(file);
+            is.read(bt);
+            img = ImageIO.read(file);
+        } catch (IOException e) {
+            return false;
+        }
+
+        //获取文件后缀进行判断
+        String suffix = mFile.getOriginalFilename().substring(mFile.getOriginalFilename().lastIndexOf(".") + 1);
+        if (IMG_FORMAT.indexOf(suffix) == -1) {
+            return false;
+        }
+
+        //以魔术数字进行判断
+        StringBuilder stringBuilder = new StringBuilder();
+        for (int i = 0; i < bt.length; i++) {
+            int v = bt[i] & 0xFF;//byte to int
+            String hv = Integer.toHexString(v);
+            if (hv.length() < 2) {
+                stringBuilder.append(0);
+            }
+            stringBuilder.append(hv);
+        }
+        System.out.println(stringBuilder.toString());
+        if (IMG_FORMAT_NUMBER.indexOf(stringBuilder.toString()) == -1) {
+            return false;
+        }
+
+        //以imageIO流的方式对图片进行格式检查
+        if (img == null || img.getWidth(null) <= 0 || img.getHeight(null) <= 0) {
+            return false;
+        }
+        if (file.exists()) {
+            file.delete();
+        }
+        return true;
+    }
+
+    /**
+     * 给图片添加水印、可设置水印图片旋转角度
+     *
+     * @param logoText 水印文字
+     * @param degree   水印图片旋转角度
+     * @param clarity  透明度(小于1的数)越接近0越透明
+     * @param mFile    被操作的图片
+     */
+    public byte[] waterMarkByText(String logoText,
+                                  Integer degree,
+                                  Float clarity, MultipartFile mFile) {
+        // 图片流
+        InputStream inputStream = null;
+        ByteArrayOutputStream byteStream = null;
+        Image srcImg = null;
+        File file = null;
+        byte[] byteImg = new byte[0];
+
+        //水印添加位置坐标 1像素=1磅*DPI/72 显示屏dpi 大多是72 少数96  这里不对
+        Integer width, height;
+        Integer fontSize = 50;
+        Integer rightButtomOffset = fontSize * 72 / 72 * 6;
+
+        try {
+            file = File.createTempFile("tmp", null);
+            mFile.transferTo(file);
+            srcImg = ImageIO.read(file);
+            width = srcImg.getWidth(null) - rightButtomOffset;
+            height = srcImg.getHeight(null);
+            BufferedImage buffImg = new BufferedImage(srcImg.getWidth(null),
+                    srcImg.getHeight(null), BufferedImage.TYPE_INT_RGB);
+            // 得到画笔对象
+            Graphics2D g = buffImg.createGraphics();
+            // 设置对线段的锯齿状边缘处理
+            g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
+                    RenderingHints.VALUE_INTERPOLATION_BILINEAR);
+            g.drawImage(
+                    srcImg.getScaledInstance(srcImg.getWidth(null),
+                            srcImg.getHeight(null), Image.SCALE_SMOOTH), 0, 0,
+                    null);
+            if (null != degree) {
+                // 设置水印旋转
+                g.rotate(Math.toRadians(degree),
+                        (double) buffImg.getWidth() / 2,
+                        (double) buffImg.getHeight() / 2);
+            }
+            // 设置颜色
+            g.setColor(Color.red);
+            // 设置 Font
+            g.setFont(new Font("宋体", Font.BOLD, fontSize));
+            float alpha = clarity;
+            g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP,
+                    alpha));
+            // 第一参数->设置的内容,后面两个参数->文字在图片上的坐标位置(x,y) .
+            g.drawString(logoText, width, height);
+            g.dispose();
+            // 生成图片
+            ImageIO.write(buffImg, "JPG", file);
+            inputStream = new FileInputStream(file);
+            byteStream = new ByteArrayOutputStream();
+            int ch;
+            while ((ch = inputStream.read()) != -1) {
+                byteStream.write(ch);
+            }
+            byteImg = byteStream.toByteArray();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (null != inputStream) {
+                    inputStream.close();
+                }
+                if (null != byteStream) {
+                    byteStream.close();
+                }
+                if (file.exists()) {
+                    file.delete();
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return byteImg;
+    }
+
     // 测试
     public static void main(String[] args) throws FileNotFoundException {
         //阿里云OSS账号自行到阿里云官网申请

+ 38 - 37
sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/LocUtils.java

@@ -1,57 +1,58 @@
 package com.sckw.core.utils;
 
-import java.net.URL;
-import java.util.StringJoiner;
+import java.io.IOException;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.sckw.core.model.constant.Global;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
 
 public class LocUtils {
 
-    public static String getAddressName(String point) {
-        // 返回数据
-        String res = "";
-        if (point == null || point.equals("0.0,0.0")) {
-            return res;
+    static String GD_KEY = "739ace2ede6fe1e2f4ae3bcba890833c";
+
+    /**
+     * @param lng 经度
+     * @param lat 纬度
+     * @desc 通过gps查询位置信息-高德
+     * @author zk
+     * @date 2023/10/7
+     **/
+    public static String regeo(String lng, String lat) {
+        if (StringUtils.isBlank(lng) || StringUtils.isBlank(lat)) {
+            return null;
         }
-        // 请求头
-        String urlHead = "http://restapi.amap.com/v3/geocode/regeo?key=8325164e247e15eea68b59e89200988b&s=rsv3&location=";
-        // 请求参数
-        String urlParam = "&radius=2800&callback=jsonp_452865_&platform=JS&logversion=2.0&sdkversion=1.3&appname=http%3A%2F%2Flbs.amap.com%2Fconsole%2Fshow%2Fpicker&csid=49851531-2AE3-4A3B-A8C8-675A69BCA316";
-        StringJoiner sj = new StringJoiner("");
-        // 完整请求地址
-        String requestUrl = sj.add(urlHead).add(point).add(urlParam).toString();
+        StringBuilder requestUrl = new StringBuilder();
+        requestUrl.append("https://restapi.amap.com/v3/geocode/regeo?output=json&location="+ lng + Global.COMMA + lat);
+        requestUrl.append("&key="+GD_KEY);
+        requestUrl.append("&radius=1000&extensions=base");
 
-        String methodStr = "GET";
-        String codeType = "UTF-8";
         try {
-            URL url = new URL(requestUrl);
-            java.net.HttpURLConnection conn = (java.net.HttpURLConnection) url.openConnection();
-            conn.setDoOutput(true);
-            conn.setRequestMethod(methodStr);
-            java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(conn.getInputStream(), codeType));
-            String line;
-            while ((line = in.readLine()) != null) {
-                res += line + "\n";
+            HttpClient httpClient = HttpClients.createDefault();
+            HttpGet httpGet = new HttpGet(requestUrl.toString());
+            HttpResponse response = httpClient.execute(httpGet);
+            HttpEntity entity = response.getEntity();
+            String responseStr = EntityUtils.toString(entity, "UTF-8");
+            JSONObject resultJson = responseStr != null ? JSON.parseObject(responseStr) : null;
+            Integer status = resultJson != null ? resultJson.getInteger("status") : null;
+            if (status != null && status == Global.NUMERICAL_ONE) {
+                JSONObject regeocode = resultJson.getJSONObject("regeocode");
+                return regeocode != null ? regeocode.getString("formatted_address") : null;
             }
-            in.close();
 
-            if (!"".equalsIgnoreCase(res)) {
-                String regeoKey = "regeocode";
-                String addressKey = "formatted_address";
-                String strAddrs = res.substring(res.indexOf("(") + 1, res.lastIndexOf(")"));
-                JSONObject addJson = JSON.parseObject(strAddrs);
-                JSONObject regeocodeObject = (null != addJson ? addJson.getJSONObject(regeoKey) : null);
-                res = (null != regeocodeObject ? regeocodeObject.getString(addressKey) : "");
-            }
-        } catch (Exception e) {
+            return null;
+        } catch (IOException e) {
             e.printStackTrace();
-            return res;
         }
-        return res;
+        return null;
     }
 
     public static void main(String[] args) {
-        String res = getAddressName("118.879289,38.052237");
+        String res = regeo("118.879289", "38.052237");
         System.out.println(res);
     }
 }

+ 1 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/web/constant/HttpStatus.java

@@ -193,5 +193,6 @@ public class HttpStatus {
     public static final String ACCOUNT_EXISTS = "用户账号已存在!";
     public static final String DICTTYPE_EXISTS = "字典类型已存在,不可重复!";
     public static final String DICT_EXISTS = "字典键值已存在,不可重复!";
+    public static final String PL34 = "3PL和4PL不能同时注册!";
 
 }

+ 2 - 0
sckw-modules/sckw-file/src/main/java/com/sckw/file/config/FileListConfig.java

@@ -3,6 +3,7 @@ package com.sckw.file.config;
 import lombok.Getter;
 import lombok.Setter;
 import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.stereotype.Component;
 
 import java.util.List;
@@ -15,6 +16,7 @@ import java.util.List;
 @Getter
 @Setter
 @Component
+@RefreshScope
 @ConfigurationProperties(prefix = "file.list")
 public class FileListConfig {
     List<String> oss;

+ 34 - 0
sckw-modules/sckw-file/src/main/java/com/sckw/file/config/FileOssConfig.java

@@ -0,0 +1,34 @@
+package com.sckw.file.config;
+
+import lombok.Data;
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author lfdc
+ * @description 文件上传获取配置yml信息
+ * @date 2023-08-10 09:08:41
+ */
+@Getter
+@Setter
+@Component
+@RefreshScope
+@ConfigurationProperties(prefix = "aliyun.oss")
+public class FileOssConfig {
+    private OssData oss;
+
+    @Data
+    public static class OssData {
+
+        private String endpoint;
+
+        private String accessKeyId;
+
+        private String secret;
+
+        public String bucket;
+    }
+}

+ 33 - 0
sckw-modules/sckw-file/src/main/java/com/sckw/file/controller/FileApiController.java

@@ -11,6 +11,7 @@ import io.seata.spring.annotation.GlobalTransactional;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletResponse;
 import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -148,6 +149,38 @@ public class FileApiController {
         }
     }
 
+    /**
+     * 前端调用接口获取oss信息-加密
+     *
+     * @param file
+     * @return
+     */
+    @RequestMapping(value = "/uploadFileEncrypt", method = RequestMethod.POST)
+    public HttpResult uploadFileEncrypt(@NotNull @RequestParam("file") MultipartFile file) {
+        try {
+            return fileService.uploadFileEncrypt(file);
+        } catch (Exception e) {
+            log.info("上传文件失败:{}",e.getMessage(),e);
+            return HttpResult.error("上传文件失败:" + e.getMessage());
+        }
+    }
+
+    /**
+     * app-前端调用接口获取oss信息-加密
+     *
+     * @param file
+     * @return
+     */
+    @RequestMapping(value = "/appUploadFileEncrypt", method = RequestMethod.POST,produces = "application/json")
+    public HttpResult appUploadFileEncrypt(@RequestParam("file") MultipartFile file) {
+        try {
+            return fileService.appUploadFileEncrypt(file);
+        } catch (Exception e) {
+            log.info("上传文件失败:{}",e.getMessage(),e);
+            return HttpResult.error(Status.FAILURE.getCode(),"上传文件失败:" + e.getMessage());
+        }
+    }
+
     /**
      * dubbo接收文件信息保存至数据库
      *

+ 20 - 0
sckw-modules/sckw-file/src/main/java/com/sckw/file/dao/KwsFileEncryptDao.java

@@ -0,0 +1,20 @@
+package com.sckw.file.dao;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.sckw.file.model.kwfFileEncrypt;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @author lfdc
+ * @version 1.0
+ * @className KwsFileEncryptDao
+ * @description
+ * @company sckw
+ * @date 2023-10-07 17:06:00
+ */
+@Mapper
+public interface KwsFileEncryptDao extends BaseMapper<kwfFileEncrypt> {
+
+
+}

+ 40 - 0
sckw-modules/sckw-file/src/main/java/com/sckw/file/model/kwfFileEncrypt.java

@@ -0,0 +1,40 @@
+package com.sckw.file.model;
+
+import com.sckw.core.model.base.BaseModel;
+import lombok.Data;
+
+/**
+ * @author lfdc
+ * @version 1.0
+ * @className kwfFileEncrypt
+ * @description 文件加密参数do
+ * @company sckw
+ * @date 2023-06-08 15:06:24
+ */
+
+@Data
+public class kwfFileEncrypt extends BaseModel {
+
+    private static final long serialVersionUID = 8295075842951977226L;
+
+    /**
+     * 文件存储方式(OSS)
+     */
+    private String type;
+
+    /**
+     * 文件加密key
+     */
+    private String encryptKey;
+
+    /**
+     * 文件相对地址
+     */
+    private String filePath;
+
+    /**
+     * 文件参数
+     */
+    private String fileParameter;
+
+}

+ 5 - 0
sckw-modules/sckw-file/src/main/java/com/sckw/file/model/kwfFileInfo.java

@@ -52,4 +52,9 @@ public class kwfFileInfo extends BaseModel {
      * 文件服务器存储相对路径
      */
     private String filePath;
+
+    /**
+     * 文件参数
+     */
+    private String fileParameter;
 }

+ 99 - 7
sckw-modules/sckw-file/src/main/java/com/sckw/file/service/FileService.java

@@ -4,6 +4,7 @@ package com.sckw.file.service;
 import com.aliyun.oss.model.OSSObject;
 import com.sckw.core.common.enums.NumberConstant;
 import com.sckw.core.common.enums.StringConstant;
+import com.sckw.core.common.enums.enums.FileDisposeLayoutEnum;
 import com.sckw.core.common.enums.enums.FileEnum;
 import com.sckw.core.model.file.FileInfo;
 import com.sckw.core.model.vo.FileInfoVO;
@@ -16,7 +17,9 @@ import com.sckw.core.web.response.HttpResult;
 import com.sckw.core.web.response.result.Status;
 import com.sckw.file.api.dto.FileInfoDTO;
 import com.sckw.file.config.FileListConfig;
+import com.sckw.file.dao.KwsFileEncryptDao;
 import com.sckw.file.dao.KwsFileInfoDao;
+import com.sckw.file.model.kwfFileEncrypt;
 import com.sckw.file.model.kwfFileInfo;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletResponse;
@@ -35,7 +38,6 @@ import org.springframework.web.multipart.MultipartFile;
 import java.io.*;
 import java.math.BigDecimal;
 import java.net.URLEncoder;
-import java.text.ParseException;
 import java.util.*;
 import java.util.zip.Adler32;
 import java.util.zip.CheckedOutputStream;
@@ -58,6 +60,9 @@ public class FileService {
     @Autowired
     KwsFileInfoDao fileInfoDao;
 
+    @Autowired
+    KwsFileEncryptDao fileEncryptDao;
+
     @Autowired
     private FileListConfig fileListConfig;
 
@@ -249,7 +254,7 @@ public class FileService {
         return null;
     }
 
-    public HttpResult uploadFileInfo(MultipartFile file) throws ParseException {
+    public HttpResult uploadFileInfo(MultipartFile file){
         boolean flag = checkFileFormat(file);
         if (!flag) {
             throw new RuntimeException("上传文件格式错误!");
@@ -259,11 +264,12 @@ public class FileService {
         FileInfo returnFileInfo = FileUtils.uploadFileInfo(file, fileInfo, FileEnum.FILE_STORE_TYPE_OSS);
         FileInfoVO fileInfoVO = new FileInfoVO();
         BeanUtils.copyProperties(returnFileInfo, fileInfoVO);
-        insertFile(returnFileInfo);
+        boolean isImage = FileUtils.isImage(file);
+        insertFile(returnFileInfo, isImage);
         return HttpResult.ok(fileInfoVO);
     }
 
-    private void insertFile(FileInfo fileInfo){
+    private void insertFile(FileInfo fileInfo, boolean isImage) {
         kwfFileInfo kwfFileInfo = new kwfFileInfo();
         kwfFileInfo.setOriginalName(fileInfo.getFileOriginalName());
         kwfFileInfo.setFileSuffix(FilenameUtils.getExtension(fileInfo.getFileOriginalName()));
@@ -279,12 +285,18 @@ public class FileService {
         kwfFileInfo.setDelFlag(0);
         kwfFileInfo.setCreateBy(LoginUserHolder.getUserId());
         kwfFileInfo.setUpdateBy(LoginUserHolder.getUserId());
+        if (FileEnum.FILE_STORE_TYPE_OSS.getFileType().equals(fileInfo.getType())) {
+            if (isImage) {
+                kwfFileInfo.setFileParameter(FileDisposeLayoutEnum.OSS_ABBREVIATE_LEFT.getParameter() + "200"
+                        + FileDisposeLayoutEnum.OSS_ABBREVIATE_RIGHT.getParameter() + "200");
+            }
+        }
         fileInfoDao.insert(kwfFileInfo);
     }
 
 
     @Transactional
-    public HttpResult appUploadFileInfo(MultipartFile file){
+    public HttpResult appUploadFileInfo(MultipartFile file) {
         boolean flag = checkFileFormat(file);
         if (!flag) {
             return HttpResult.error(Status.FAILURE.getCode(), "上传文件格式错误!");
@@ -294,8 +306,9 @@ public class FileService {
         FileInfo returnFileInfo = FileUtils.uploadFileInfo(file, fileInfo, FileEnum.FILE_STORE_TYPE_OSS);
         FileInfoVO fileInfoVO = new FileInfoVO();
         BeanUtils.copyProperties(returnFileInfo, fileInfoVO);
-        insertFile(returnFileInfo);
-        return HttpResult.ok(Status.SUCCESS.getCode(),"", fileInfoVO);
+        boolean isImage = FileUtils.isImage(file);
+        insertFile(returnFileInfo, isImage);
+        return HttpResult.ok(Status.SUCCESS.getCode(), "", fileInfoVO);
     }
 
     /**
@@ -318,4 +331,83 @@ public class FileService {
         Map<String, String> map = FileUtils.uploadFileByInfo(inputStream, fileInfo.getOriginalName(), FileEnum.Local_Address);
         return HttpResult.ok(map);
     }
+
+
+    @Transactional(rollbackFor = Exception.class)
+    public HttpResult uploadFileEncrypt(MultipartFile file) {
+        boolean flag = checkFileFormat(file);
+        if (!flag) {
+            throw new RuntimeException("上传文件格式错误!");
+        }
+        FileInfo fileInfo = FileUtils.getFileDataList(file);
+        String fileType = FileEnum.FILE_STORE_TYPE_OSS.getFileType();
+        fileInfo.setType(fileType);
+        /**上传文件*/
+        FileInfo returnFileInfo = FileUtils.uploadFileInfo(file, fileInfo, FileEnum.FILE_STORE_TYPE_OSS);
+        boolean isImage = FileUtils.isImage(file);
+        /**存储文件到数据库*/
+        insertFile(returnFileInfo, isImage);
+        /**存储到加密属性文件信息*/
+        String fileMd5 = returnFileInfo.getFileMd5();
+        String filePath = returnFileInfo.getFilePath();
+        FileInfoVO vo = new FileInfoVO();
+        vo.setFileMd5(fileMd5);
+        vo.setFilePath(filePath);
+//        insertFileEncrypt(fileMd5, filePath, FileEnum.FILE_STORE_TYPE_OSS, isImage);
+        return HttpResult.ok(vo);
+    }
+
+    /**
+     * 文件加密存储
+     *
+     * @param fileMd5  md5加密key
+     * @param filePath 文件相对路径
+     * @param fileEnum 文件类型
+     * @param isImage  是否是图片
+     */
+    public void insertFileEncrypt(String fileMd5, String filePath, FileEnum fileEnum, boolean isImage) {
+        Date date = new Date();
+        kwfFileEncrypt encrypt = new kwfFileEncrypt();
+        if (FileEnum.FILE_STORE_TYPE_OSS.getFileType().equals(fileEnum.getFileType())) {
+            if (isImage) {
+                encrypt.setFileParameter(FileDisposeLayoutEnum.OSS_ABBREVIATE_LEFT.getParameter() + "200"
+                        + FileDisposeLayoutEnum.OSS_ABBREVIATE_RIGHT.getParameter() + "200");
+            }
+        }
+        encrypt.setType(fileEnum.getFileType());
+        encrypt.setStatus(NumberConstant.ZERO);
+        encrypt.setCreateBy(LoginUserHolder.getUserId());
+        encrypt.setCreateTime(date);
+        encrypt.setUpdateBy(LoginUserHolder.getUserId());
+        encrypt.setUpdateTime(date);
+        encrypt.setDelFlag(NumberConstant.ZERO);
+        encrypt.setId(new IdWorker(NumberConstant.ONE).nextId());
+        encrypt.setEncryptKey(fileMd5);
+        encrypt.setFilePath(filePath);
+        fileEncryptDao.insert(encrypt);
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public HttpResult appUploadFileEncrypt(MultipartFile file) {
+        boolean flag = checkFileFormat(file);
+        if (!flag) {
+            throw new RuntimeException("上传文件格式错误!");
+        }
+        FileInfo fileInfo = FileUtils.getFileDataList(file);
+        String fileType = FileEnum.FILE_STORE_TYPE_OSS.getFileType();
+        fileInfo.setType(fileType);
+        /**上传文件*/
+        FileInfo returnFileInfo = FileUtils.uploadFileInfo(file, fileInfo, FileEnum.FILE_STORE_TYPE_OSS);
+        boolean isImage = FileUtils.isImage(file);
+        /**存储文件到数据库*/
+        insertFile(returnFileInfo, isImage);
+        /**存储到加密属性文件信息*/
+        String fileMd5 = returnFileInfo.getFileMd5();
+        String filePath = returnFileInfo.getFilePath();
+//        insertFileEncrypt(fileMd5, filePath, FileEnum.FILE_STORE_TYPE_OSS, isImage);
+        FileInfoVO vo = new FileInfoVO();
+        vo.setFileMd5(fileMd5);
+        vo.setFilePath(filePath);
+        return HttpResult.ok(Status.SUCCESS.getCode(), "", vo);
+    }
 }

+ 22 - 0
sckw-modules/sckw-file/src/main/resources/mapper/KwsFileEncryptDao.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sckw.file.dao.KwsFileEncryptDao">
+    <resultMap id="BaseResultMap" type="com.sckw.file.model.kwfFileEncrypt">
+        <id column="id" jdbcType="BIGINT" property="id" />
+        <result column="type" jdbcType="VARCHAR" property="type" />
+        <result column="file_path" jdbcType="INTEGER" property="filePath" />
+        <result column="remark" jdbcType="INTEGER" property="remark" />
+        <result column="status" jdbcType="INTEGER" property="status" />
+        <result column="create_by" jdbcType="VARCHAR" property="createBy" />
+        <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+        <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
+        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
+        <result column="del_flag" jdbcType="INTEGER" property="delFlag" />
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id, type, file_path, remark, status,
+    create_by, create_time, update_by, update_time, del_flag
+    </sql>
+
+</mapper>

+ 5 - 1
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/service/KwfTruckService.java

@@ -769,11 +769,15 @@ public class KwfTruckService {
                 firmName = ent != null ? ent.getFirmName() : null;
             }
         }
+        //详细地址
+        String detailAddress = truckGps != null
+                ? StringUtils.isNotBlank(truckGps.getDetailAddress()) ? truckGps.getDetailAddress() : LocUtils.regeo(truckGps.getLng(), truckGps.getLat())
+                : null;
 
         Map<String, Object> detail = new HashMap<>(Global.NUMERICAL_SIXTEEN);
         detail.put("truckNo", truckNo);
         detail.put("firmName", firmName);
-        detail.put("detailAddress", truckGps != null ? truckGps.getDetailAddress() : null);
+        detail.put("detailAddress", detailAddress);
         detail.put("speed", truckGps != null ? truckGps.getSpeed() : null);
         detail.put("gpsTime", truckGps != null ? truckGps.getGpsTime() : null);
         detail.put("driverName", waybillOrder != null ? waybillOrder.getDriverName() : null);

+ 2 - 2
sckw-modules/sckw-fleet/src/main/resources/bootstrap.yml

@@ -5,8 +5,8 @@ spring:
   application:
     name: sckw-fleet
   profiles:
-#    active: dev
-    active: ${DEPLOY_MODE:dev}
+    #    active: ${DEPLOY_MODE:dev}
+    active: @profiles.active@
   main:
     allow-bean-definition-overriding: true
     allow-circular-references: true

+ 49 - 21
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwTransportService.java

@@ -2,9 +2,11 @@ package com.sckw.report.service;
 
 import com.sckw.core.common.enums.NumberConstant;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
+import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.enums.CarWaybillEnum;
 import com.sckw.core.model.enums.CarWaybillQueryEnum;
 import com.sckw.core.model.enums.LogisticsOrderEnum;
+import com.sckw.core.model.enums.TaxRateTypeEnum;
 import com.sckw.core.model.page.PageResult;
 import com.sckw.core.utils.BeanUtils;
 import com.sckw.core.utils.CollectionUtils;
@@ -550,28 +552,13 @@ public class KwTransportService {
                     BigDecimal.valueOf(0) : waybillOrder.getDeficitAmount();
             vo.setDeficitAmount(String.valueOf(deficitAmount));
             // 存在装卸货差时 计算扣亏量
-            BigDecimal lossAmount = BigDecimal.valueOf(0);
-            BigDecimal loss = waybillOrder.getLoss() == null ? new BigDecimal("0.00") : waybillOrder.getLoss();
-            if (deficitAmount.compareTo(new BigDecimal("0.00")) > 0 && loss.compareTo(new BigDecimal("0.00")) > 0) {
-                String lossUnit = waybillOrder.getLossUnit();
-                Map<String, SysDictResDto> LossUnitType = remoteSystemService.queryDictMapByType(DictTypeEnum.TAX_RATE_TYPE.getType());
-                SysDictResDto sysDictRes = LossUnitType.get(lossUnit);
-                if (sysDictRes != null) {
-                if (sysDictRes.getLabel().equals("%")) {
-                    // 百分比
-                    lossAmount = loss.multiply(waybillOrder.getLoadAmount()).divide(BigDecimal.valueOf(100));
-                } else {
-                    // 千分比
-                    lossAmount = loss.multiply(waybillOrder.getLoadAmount()).divide(BigDecimal.valueOf(1000));
-                }
-                }
-                lossAmount = deficitAmount.subtract(lossAmount);
-                if (lossAmount.compareTo(new BigDecimal("0.00")) < 0) {
-                    lossAmount = new BigDecimal("0.00");
-                }
-            }
+            BigDecimal deficitLossAmount = deficitLossAmount(
+                    waybillOrder.getLoadAmount(),
+                    waybillOrder.getDeficitAmount(),
+                    waybillOrder.getLoss(),
+                    waybillOrder.getLossUnit());
             // 实际扣亏量
-            vo.setDeficitRealAmount(lossAmount.setScale(2, RoundingMode.HALF_UP).toString());
+            vo.setDeficitRealAmount(deficitLossAmount.setScale(2, RoundingMode.HALF_UP).toString());
             vo.setGoodsPriceUnit(waybillOrder.getGoodsPriceUnit() == null ?
                     null : String.valueOf(waybillOrder.getGoodsPriceUnit()));
             returnList.add(vo);
@@ -782,4 +769,45 @@ public class KwTransportService {
         });
         return list;
     }
+
+    /**
+     * @param loadAmount    装货量
+     * @param deficitAmount 亏吨量
+     * @param loss          合理损耗
+     * @desc 计算扣亏量
+     * @author zk
+     * @date 2023/7/27
+     **/
+    public BigDecimal deficitLossAmount(BigDecimal loadAmount, BigDecimal deficitAmount, BigDecimal loss, String lossUnit) {
+        if (loadAmount == null || deficitAmount == null) {
+            return new BigDecimal(Global.AMOUNT);
+        }
+        //亏吨<=0
+        if (deficitAmount.compareTo(new BigDecimal(Global.AMOUNT)) <= 0) {
+            return new BigDecimal(Global.AMOUNT);
+        }
+        if (StringUtils.isBlank(lossUnit)) {
+            lossUnit = String.valueOf(NumberConstant.ZERO);
+        }
+        //承运订单亏吨扣款=(承运订单亏吨量 -(承运订单装货量 * 承运订单合理损耗))* 扣亏货值
+        loss = loss == null ? new BigDecimal(Global.AMOUNT) : loss;
+        if (loss.doubleValue() > 0 && StringUtils.isNotBlank(lossUnit)) {
+            if (lossUnit.equals(String.valueOf(TaxRateTypeEnum.PERCENT.getCode()))) {
+                loss = loss.divide(new BigDecimal(TaxRateTypeEnum.PERCENT.getValue()));
+            }
+            if (lossUnit.equals(String.valueOf(TaxRateTypeEnum.MILLIMETER.getCode()))) {
+                loss = loss.divide(new BigDecimal(TaxRateTypeEnum.MILLIMETER.getValue()));
+            }
+        }
+        //扣亏量=亏吨量【合理损耗占比为空或为0】
+        if (loss.doubleValue() == Global.NUMERICAL_ZERO) {
+            return deficitAmount;
+        }
+        //扣亏量=亏吨量-合理损耗值【要求大于0,如果小于0则扣亏货量取0】
+        BigDecimal deficitLossAmount = deficitAmount.subtract(loadAmount.multiply(loss).setScale(2, RoundingMode.HALF_UP));
+        if (deficitLossAmount.doubleValue() <= 0) {
+            return new BigDecimal(Global.AMOUNT);
+        }
+        return deficitLossAmount;
+    }
 }

+ 3 - 2
sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsEnterpriseController.java

@@ -33,8 +33,9 @@ public class KwsEnterpriseController {
      * @date 2023/06/02
      **/
     @GetMapping("/detail")
-    public HttpResult detail(@RequestParam Long id) {
-        return HttpResult.ok(kwsEntService.detail(id));
+    public HttpResult detail(@RequestParam Long id,
+                             @RequestParam (value = "isAll", required = false)Boolean isAll) {
+        return HttpResult.ok(kwsEntService.detail(id, isAll));
     }
 
     /**

+ 28 - 6
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsEnterpriseService.java

@@ -336,14 +336,22 @@ public class KwsEnterpriseService {
         if (CollectionUtils.isNotEmpty(listByEntId)) {
             currentTypeList.addAll(listByEntId.stream().map(KwsEntType::getType).toList());
         }
-        List<String> typeList = Arrays.stream(reqVo.getEntTypes().split(",")).toList();
-        for (String item : typeList) {
-            if (currentTypeList.contains(Integer.parseInt(item))) {
+        List<Integer> typeList = Arrays.stream(reqVo.getEntTypes().split(Global.COMMA)).map(Integer::parseInt).toList();
+        if (currentTypeList.contains(EntTypeEnum.LOGISTICS3.getCode()) && typeList.contains(EntTypeEnum.LOGISTICS4.getCode())) {
+            throw new SystemException(HttpStatus.CODE_10301, HttpStatus.PL34);
+        }
+
+        if (currentTypeList.contains(EntTypeEnum.LOGISTICS4.getCode()) && typeList.contains(EntTypeEnum.LOGISTICS3.getCode())) {
+            throw new SystemException(HttpStatus.CODE_10301, HttpStatus.PL34);
+        }
+
+        for (Integer item : typeList) {
+            if (currentTypeList.contains(item)) {
                 continue;
             }
             KwsEntType kwsEntType = new KwsEntType();
             kwsEntType.setEntId(entId);
-            kwsEntType.setType(Integer.parseInt(item));
+            kwsEntType.setType(item);
             kwsEntType.setId(new IdWorker(1).nextId());
             kwsEntType.setStatus(ApprovalEnum.PROCESS.getCode());
             kwsEntType.setCreateBy(userId);
@@ -880,7 +888,7 @@ public class KwsEnterpriseService {
      * @author: czh
      * @date: 2023/7/26
      */
-    public EntDetailResVo detail(Long id) {
+    public EntDetailResVo detail(Long id, Boolean isAll) {
         KwsEnterprise kwsEnterprise = selectByKey(id);
         if (Objects.isNull(kwsEnterprise)) {
             throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ENT_NOT_EXISTS);
@@ -891,11 +899,25 @@ public class KwsEnterpriseService {
         if (Objects.nonNull(manageInfoByEntId)) {
             entDetailResVo.setContactsId(manageInfoByEntId.getUserId());
         }
+
         List<KwsEntType> listByEntIds = kwsEntTypeDao.findListByEntIds(Collections.singletonList(kwsEnterprise.getId()));
+        List<Integer> types = new ArrayList<>();
         if (CollectionUtils.isNotEmpty(listByEntIds)) {
-            entDetailResVo.setEntTypes(String.join(Global.COMMA, listByEntIds.stream().map(KwsEntType::getType).map(String::valueOf).distinct().toList()));
+            types.addAll(listByEntIds.stream().map(KwsEntType::getType).toList());
         }
 
+        if (Objects.nonNull(isAll) && isAll) {
+            List<KwsEntType> approvalByEntId = kwsEntTypeDao.findApprovalByEntId(kwsEnterprise.getId());
+            if (CollectionUtils.isNotEmpty(approvalByEntId)) {
+                types.addAll(approvalByEntId.stream().map(KwsEntType::getType).toList());
+            }
+        }
+
+        if (CollectionUtils.isNotEmpty(types)) {
+            entDetailResVo.setEntTypes(String.join(Global.COMMA, types.stream().map(String::valueOf).distinct().toList()));
+        }
+
+
         List<KwsEntCheckTrack> list = kwsEntCheckTrackDao.findList(id);
         if (CollectionUtils.isNotEmpty(list)) {
             entDetailResVo.setValid(list.stream().anyMatch(item -> item.getStatus().equals(Global.NO)));

+ 0 - 1
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsUserService.java

@@ -617,7 +617,6 @@ public class KwsUserService {
 
     public List<AreaTreeFrontResDto> test(List<Integer> list) {
         Integer integer = transportStatisticsService.statisticsLogistics(123L);
-
         List<Long> longs = LoginUserHolder.getAuthUserIdList();
 
         return null;

+ 1 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dubbo/TransportDubboServiceImpl.java

@@ -215,7 +215,7 @@ public class TransportDubboServiceImpl implements TransportDubboService {
                 BigDecimal lossAmount = loadAmount.multiply(logisticsOrderDTO.getLoss() == null ? new BigDecimal("0.00") : logisticsOrderDTO.getLoss());
                 //扣亏量
 //                BigDecimal deductWeighNumber = defectiveWeighNumber.subtract(lossAmount);
-                BigDecimal deductWeighNumber = commonService.deficitPrice(loadAmount, defectiveWeighNumber, loss, logisticsOrderDTO.getLossUnit());
+                BigDecimal deductWeighNumber = commonService.deficitLossAmount(loadAmount, defectiveWeighNumber, loss, logisticsOrderDTO.getLossUnit());
                 if (deductWeighNumber.compareTo(new BigDecimal("0")) < 0) {
                     deductWeighNumber = new BigDecimal("0.00");
                 }

+ 7 - 3
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/WaybillOrderDriverVo.java

@@ -239,11 +239,15 @@ public class WaybillOrderDriverVo {
                 loss = loss.divide(new BigDecimal(TaxRateTypeEnum.MILLIMETER.getValue()));
             }
         }
+        //扣亏量=亏吨量【合理损耗占比为空或为0】
+        if (loss.doubleValue() == Global.NUMERICAL_ZERO) {
+            return deficitAmount;
+        }
         //扣亏量=亏吨量-合理损耗值【要求大于0,如果小于0则扣亏货量取0】
-        BigDecimal deficitPrice = deficitAmount.subtract(loadAmount.multiply(loss).setScale(2, RoundingMode.HALF_UP));
-        if (deficitPrice.doubleValue() <= 0) {
+        BigDecimal deficitLossAmount = deficitAmount.subtract(loadAmount.multiply(loss).setScale(2, RoundingMode.HALF_UP));
+        if (deficitLossAmount.doubleValue() <= 0) {
             return new BigDecimal(Global.AMOUNT);
         }
-        return deficitPrice;
+        return deficitLossAmount;
     }
 }

+ 13 - 10
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/CommonService.java

@@ -788,7 +788,7 @@ public class CommonService {
             return new BigDecimal(Global.AMOUNT);
         }
         //合理损耗
-        loss = loss == null ? new BigDecimal("0.00") : loss;
+        loss = loss == null ? new BigDecimal(Global.AMOUNT) : loss;
         if (loss.doubleValue() > 0 && StringUtils.isNotBlank(lossUnit)) {
             if (lossUnit.equals(String.valueOf(TaxRateTypeEnum.PERCENT.getCode()))) {
                 loss = loss.divide(new BigDecimal(TaxRateTypeEnum.PERCENT.getValue()));
@@ -809,15 +809,15 @@ public class CommonService {
          * 2、按卸货量:总运价=实卸量*运价-罚款值
          * 3、按趟次:总运价=运价*趟次【后期加】
          */
-        loadAmount = loadAmount == null ? new BigDecimal("0.00") : loadAmount;
+        loadAmount = loadAmount == null ? new BigDecimal(Global.AMOUNT) : loadAmount;
         //已委托量
-        entrustAmount = entrustAmount == null ? new BigDecimal("0.00") : entrustAmount;
+        entrustAmount = entrustAmount == null ? new BigDecimal(Global.AMOUNT) : entrustAmount;
         //合理损耗值
         BigDecimal multiply = loadAmount.multiply(loss.divide(BigDecimal.valueOf(1000L)));
         //亏吨量
-        deficitAmount = deficitAmount == null ? new BigDecimal("0.00") : deficitAmount;
+        deficitAmount = deficitAmount == null ? new BigDecimal(Global.AMOUNT) : deficitAmount;
         //扣亏量/吨
-        deficitAmount = deficitAmount.compareTo(new BigDecimal("0.00")) == 0 ? new BigDecimal("0.00") : deficitAmount.subtract(multiply);
+        deficitAmount = deficitAmount.compareTo(new BigDecimal(Global.AMOUNT)) == 0 ? new BigDecimal(Global.AMOUNT) : deficitAmount.subtract(multiply);
         return deficitAmount;
     }
 
@@ -829,7 +829,7 @@ public class CommonService {
      * @author zk
      * @date 2023/7/27
      **/
-    public BigDecimal deficitPrice(BigDecimal loadAmount, BigDecimal deficitAmount, BigDecimal loss, String lossUnit) {
+    public BigDecimal deficitLossAmount(BigDecimal loadAmount, BigDecimal deficitAmount, BigDecimal loss, String lossUnit) {
         //亏吨<=0
 //        if (deficitAmount.compareTo(new BigDecimal(Global.AMOUNT)) <= 0) {
 //            return new BigDecimal(Global.AMOUNT);
@@ -865,12 +865,15 @@ public class CommonService {
                 loss = loss.divide(new BigDecimal(TaxRateTypeEnum.MILLIMETER.getValue()));
             }
         }
+        //扣亏量=亏吨量【合理损耗占比为空或为0】
+        if (loss.doubleValue() == Global.NUMERICAL_ZERO) {
+            return deficitAmount;
+        }
         //扣亏量=亏吨量-合理损耗值【要求大于0,如果小于0则扣亏货量取0】
-        BigDecimal deficitPrice = deficitAmount.subtract(loadAmount.multiply(loss).setScale(2, RoundingMode.HALF_UP));
-//        log.error("[ddd] {}", deficitPrice);
-        if (deficitPrice.doubleValue() <= 0) {
+        BigDecimal deficitLossAmount = deficitAmount.subtract(loadAmount.multiply(loss).setScale(2, RoundingMode.HALF_UP));
+        if (deficitLossAmount.doubleValue() <= 0) {
             return new BigDecimal(Global.AMOUNT);
         }
-        return deficitPrice;
+        return deficitLossAmount;
     }
 }

+ 2 - 2
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ConsignOrderService.java

@@ -380,7 +380,7 @@ public class ConsignOrderService {
                     BigDecimal defectiveWeigh = kwtWaybillOrder.getDeficitAmount() == null ? new BigDecimal("0.00") : kwtWaybillOrder.getDeficitAmount();
                     //扣亏量/吨
 //                    BigDecimal deduct = defectiveWeigh.compareTo(new BigDecimal("0.00")) == 0 ? new BigDecimal("0.00") : defectiveWeigh.subtract(multiply);
-                    BigDecimal deduct = commonService.deficitPrice(loadAmount, defectiveWeigh, loss, order.getLossUnit());
+                    BigDecimal deduct = commonService.deficitLossAmount(loadAmount, defectiveWeigh, loss, order.getLossUnit());
                     carWaybillVo.setLOrderId(String.valueOf(kwtWaybillOrder.getLOrderId()));
                     carWaybillVo.setLOrderNo(order.getLOrderNo());
                     carWaybillVo.setWOrderId(String.valueOf(kwtWaybillOrder.getId()));
@@ -657,7 +657,7 @@ public class ConsignOrderService {
                     //扣亏量/吨
 //                    BigDecimal deduct = defectiveWeigh.compareTo(new BigDecimal("0.00")) == 0 ? new BigDecimal("0.00") : defectiveWeigh.subtract(multiply);
 //                    BigDecimal decimal = commonService.deficitAmount();
-                    BigDecimal deduct = commonService.deficitPrice(loadAmount, defectiveWeigh, loss, order.getLossUnit());
+                    BigDecimal deduct = commonService.deficitLossAmount(loadAmount, defectiveWeigh, loss, order.getLossUnit());
                     carWaybillVo.setWOrderId(String.valueOf(kwtWaybillOrder.getId()));
                     carWaybillVo.setWOrderNo(kwtWaybillOrder.getWOrderNo());
                     carWaybillVo.setTruckNo(kwtWaybillOrder.getTruckNo());

+ 1 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ManagementWaybillOrderService.java

@@ -212,7 +212,7 @@ public class ManagementWaybillOrderService {
                 // 计算扣亏量
                 BigDecimal loadAmount = waybillOrder.getLoadAmount() == null ? new BigDecimal("0.00") : waybillOrder.getLoadAmount();
                 BigDecimal unloadAmount = waybillOrder.getUnloadAmount() == null ? new BigDecimal("0.00") : waybillOrder.getUnloadAmount();
-                BigDecimal deficitRealAmount = commonService.deficitPrice(
+                BigDecimal deficitRealAmount = commonService.deficitLossAmount(
                         waybillOrder.getLoadAmount(),
                         loadAmount.subtract(unloadAmount),
                         waybillOrder.getLoss(),

+ 1 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/TransportCommonService.java

@@ -631,7 +631,7 @@ public class TransportCommonService {
 //                if (deductWeighNumber.compareTo(new BigDecimal("0")) < 0) {
 //                    deductWeighNumber = new BigDecimal("0.00");
 //                }
-                BigDecimal deductWeighNumber = commonService.deficitPrice(loadAmount, defectiveWeighNumber, loss, logisticsOrderDTO.getLossUnit());
+                BigDecimal deductWeighNumber = commonService.deficitLossAmount(loadAmount, defectiveWeighNumber, loss, logisticsOrderDTO.getLossUnit());
                 //罚款值
                 BigDecimal fineValue = (logisticsOrderDTO.getGoodsPrice() == null ? new BigDecimal("0.00") : logisticsOrderDTO.getGoodsPrice()).multiply(deductWeighNumber);
                 /**

+ 2 - 2
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/WaybillManagementService.java

@@ -189,7 +189,7 @@ public class WaybillManagementService {
             BigDecimal deficitLoss = info.getLoss() == null ? BigDecimal.valueOf(0) : info.getLoss();
             BigDecimal loadAmount = info.getLoadAmount() == null ? new BigDecimal("0.00") : info.getLoadAmount();
             BigDecimal unloadAmount = info.getUnloadAmount() == null ? new BigDecimal("0.00") : info.getUnloadAmount();
-            BigDecimal deficitRealAmount = commonService.deficitPrice(
+            BigDecimal deficitRealAmount = commonService.deficitLossAmount(
                     info.getLoadAmount(),
                     loadAmount.subtract(unloadAmount),
                     deficitLoss,
@@ -899,7 +899,7 @@ public class WaybillManagementService {
                         && wOrder.getUnloadAmount() != null
                         && wOrder.getDeficitAmount() != null
                 ) {
-                    BigDecimal realDeficitAMount = commonService.deficitPrice(
+                    BigDecimal realDeficitAMount = commonService.deficitLossAmount(
                             wOrder.getLoadAmount(),
                             wOrder.getDeficitAmount(),
                             wOrder.getLoss(),