浏览代码

对外接口

qzyReal 3 年之前
父节点
当前提交
b199aeaf5c

+ 4 - 2
app/utils/request.js

@@ -1,5 +1,7 @@
-// const server = 'http://192.168.3.217:8099/pro';
-const server = 'http://47.101.143.145/pro';
+// const server = 'http://127.0.0.1:8099/pro';
+// const server = 'http://47.101.143.145/pro';
+ const server = 'http://jkwly.btintlog.com:8099/pro';
+
 import common from '../common/js/common.js';
 
 function get(url, data) {

+ 1 - 1
sp-server/app.pid

@@ -1 +1 @@
-21520
+9100

+ 2 - 2
sp-server/src/main/java/com/pj/api/open/OpenFilter.java

@@ -9,8 +9,8 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 
-@Slf4j
-@WebFilter(filterName = "openFilter", urlPatterns = "/open/*")
+//@Slf4j
+//@WebFilter(filterName = "openFilter", urlPatterns = "/open/*")
 public class OpenFilter implements Filter {
     @Override
     public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {

+ 41 - 2
sp-server/src/main/java/com/pj/api/open/bo/CheckCarNumberBO.java

@@ -1,13 +1,13 @@
 package com.pj.api.open.bo;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
 import com.sun.scenario.effect.ImageData;
 import lombok.Data;
 import lombok.experimental.Accessors;
 
 import java.io.Serializable;
 
-@Data
-@Accessors(chain = true)
+
 public class CheckCarNumberBO implements Serializable {
     /**
      * 当前设别车牌的通道名称
@@ -23,5 +23,44 @@ public class CheckCarNumberBO implements Serializable {
      * 操作员
      */
     private String OperationUserName;
+    @JsonProperty("ChannelName")
+    public String getChannelName() {
+        return ChannelName;
+    }
+
+    public void setChannelName(String channelName) {
+        ChannelName = channelName;
+    }
+    @JsonProperty("CarNumber")
+    public String getCarNumber() {
+        return CarNumber;
+    }
+
+    public void setCarNumber(String carNumber) {
+        CarNumber = carNumber;
+    }
+    @JsonProperty("InOrOut")
+    public int getInOrOut() {
+        return InOrOut;
+    }
+
+    public void setInOrOut(int inOrOut) {
+        InOrOut = inOrOut;
+    }
+    @JsonProperty("ImageData")
+    public String getImageData() {
+        return ImageData;
+    }
+
+    public void setImageData(String imageData) {
+        ImageData = imageData;
+    }
+
+    public String getOperationUserName() {
+        return OperationUserName;
+    }
 
+    public void setOperationUserName(String operationUserName) {
+        OperationUserName = operationUserName;
+    }
 }

+ 45 - 55
sp-server/src/main/java/com/pj/api/open/service/OpenService.java

@@ -1,23 +1,16 @@
 package com.pj.api.open.service;
 
-import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.StrUtil;
 import com.pj.api.open.ResultJson;
 import com.pj.api.open.bo.CheckCarNumberBO;
-import com.pj.current.config.PartConfig;
 import com.pj.project.tb_business.TbBusiness;
 import com.pj.project.tb_business.TbBusinessService;
-import com.pj.project.tb_car.TbCar;
-import com.pj.project.tb_car.TbCarService;
-import com.pj.project.tb_costomer.TbCostomer;
-import com.pj.project.tb_costomer.TbCostomerService;
+
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 
-import java.math.BigDecimal;
-import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -26,10 +19,7 @@ import java.util.List;
 public class OpenService {
     @Resource
     private TbBusinessService tbBusinessService;
-    @Resource
-    private TbCostomerService tbCostomerService;
-    @Resource
-    private TbCarService tbCarService;
+
     private final List<String> CAR_LIST = StrUtil.splitTrim("浙,粤,京,津,冀,晋,蒙,辽,黑,沪,吉,苏,皖,赣,鲁,豫,鄂,湘,桂,琼,渝,川,贵,云,藏, 陕, 甘, 青, 宁", ",");
 
 
@@ -45,70 +35,70 @@ public class OpenService {
     }
 
     private ResultJson handlerOutCar(CheckCarNumberBO checkCarNumberBO) {
+        int inOrOut = checkCarNumberBO.getInOrOut();
         String carNo = checkCarNumberBO.getCarNumber();
-        TbBusiness tbBusiness = tbBusinessService.findCarTheNewRecord(carNo);
+        TbBusiness tbBusiness = tbBusinessService.findCarTheNewRecord(carNo,inOrOut);
         if (tbBusiness == null) {
             return ResultJson.error("无业务登记记录");
         }
-        Date outTime=tbBusiness.getOutDayTime();
         Date now=new Date();
-        if (outTime!=null&&Math.abs(outTime.getHours()-now.getHours())>10) {
-            return ResultJson.error("无业务登记记录");
-        }
-        if (tbBusiness.getAdminConfirmPay() ==0) {
-            return ResultJson.error("账单未支付");
-        }
-        int inOrOut = checkCarNumberBO.getInOrOut();
-        TbCar car = tbCarService.findByCardNo(carNo);
-        if (inOrOut == 1) {
-            if (tbBusiness.getRealInDay() == null) {
-                //入场
-                tbBusiness.setRealInTime(now)
-                        .setInChannel(checkCarNumberBO.getChannelName());
-                car.setLastInTime(now);
-                tbBusinessService.updateById(tbBusiness);
-                return ResultJson.success();
-            } else {
-                return ResultJson.error("车辆已入场");
+        String channel=checkCarNumberBO.getChannelName();
+        if (inOrOut==1){
+            tbBusiness.setRealInTime(now).setInChannel(channel);
+            if (StrUtil.isNotEmpty(tbBusiness.getChinaCarInChannel())||tbBusiness.getChinaCarInTime()!=null){
+                tbBusiness.setAdminConfirmIn(1);
             }
-        } else {
-            if (tbBusiness.getOutDayTime() == null) {
-                TbCostomer tbCostomer = tbCostomerService.getById(tbBusiness.getCustomerId());
-                car.setLastOutTime(now);
-                tbCarService.updateById(car);
-                tbBusiness.setOutChannel(checkCarNumberBO.getChannelName());
-                handlerOut(tbBusiness);
-                if (tbCostomer.getPayType() == 2) {
-                    return ResultJson.success();
-                } else {
-                    if (tbBusiness.getPayStatus() != 3) {
-                        return ResultJson.error("车辆未缴费");
-                    }
-                }
-                return ResultJson.success();
-            } else {
-                return ResultJson.error("车辆已离场");
+            tbBusinessService.updateById(tbBusiness);
+            return ResultJson.success();
+        }else {
+            if (tbBusiness.getAdminConfirmPay() ==0&&tbBusiness.getCustomerType()==1) {
+                return ResultJson.error("账单未确认支付");
             }
+            if (tbBusiness.getConfirmInput()==0&&tbBusiness.getCustomerType()==2){
+                return ResultJson.error("账单未确认");
+            }
+            tbBusiness.setOutDayTime(now).setOutChannel(channel);
+            if (StrUtil.isNotEmpty(tbBusiness.getChinaCarOutChannel())){
+                tbBusiness.setAdminConfirmOut(1);
+            }
+            tbBusinessService.calculationPartMoney("越南车", tbBusiness);
+            tbBusinessService.updateById(tbBusiness);
+            return ResultJson.success();
         }
-
     }
 
     private ResultJson handlerChinaCar(CheckCarNumberBO checkCarNumberBO) {
         String carNo = checkCarNumberBO.getCarNumber();
-        TbBusiness cb = tbBusinessService.findByChinaCarNo(carNo);
+        int inOrOut=checkCarNumberBO.getInOrOut();
+        TbBusiness cb = tbBusinessService.findByChinaCarNo(carNo,inOrOut);
+        if (cb==null){
+            return ResultJson.error("未查询到相应业务");
+        }
         Date now = new Date();
         String channel = checkCarNumberBO.getChannelName();
-        if (checkCarNumberBO.getInOrOut() == 1 && cb.getRealInTime() == null) {
+        if (checkCarNumberBO.getInOrOut() == 1) {
             cb.setChinaCarInTime(now).setChinaCarInChannel(channel);
+            if (StrUtil.isNotEmpty(cb.getInChannel())||cb.getRealInTime()!=null){
+                cb.setAdminConfirmIn(1);
+            }
             tbBusinessService.updateById(cb);
             return ResultJson.success();
-        }
-        if (checkCarNumberBO.getInOrOut() == 2) {
+        }else  {
+            //现结
+            if (cb.getCustomerType()==1&&cb.getAdminConfirmPay()==0){
+                return ResultJson.error("账单未确认支付");
+            }
+            if (cb.getConfirmInput()==0&&cb.getCustomerType()==2){
+                return ResultJson.error("账单未确认");
+            }
             cb.setChinaCarOutTime(now).setChinaCarOutChannel(channel);
+            if (StrUtil.isNotEmpty(cb.getOutChannel())){
+                cb.setAdminConfirmOut(1);
+            }
             tbBusinessService.calculationPartMoney("中国车", cb);
+            tbBusinessService.updateById(cb);
             return ResultJson.success();
         }
-        return null;
     }
 
     private void handlerOut(TbBusiness tbBusiness) {

+ 18 - 7
sp-server/src/main/java/com/pj/api/open/web/OpenController.java

@@ -1,15 +1,22 @@
 package com.pj.api.open.web;
 
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.json.JSONUtil;
 import com.pj.api.open.ResultJson;
 import com.pj.api.open.bo.CheckCarNumberBO;
 import com.pj.api.open.service.OpenService;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpRequest;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+import java.util.Map;
 
 @RequestMapping(value = "open")
 @RestController
@@ -19,13 +26,17 @@ public class OpenController {
     OpenService openService;
 
     @PostMapping(value = "req")
-    public ResultJson req() {
-        return ResultJson.success();
+    public ResultJson req(@RequestBody Map<String, Object> params, HttpServletRequest request, HttpServletResponse response) {
+        String dataType = request.getHeader("DataType");
+        if ("CheckCarNumber".equals(dataType)) {
+            CheckCarNumberBO checkCarNumberBO = BeanUtil.toBean(params, CheckCarNumberBO.class);
+            return checkCarNumber(checkCarNumberBO);
+        }
+        return ResultJson.error("未知异常");
     }
-    @PostMapping(value = "CheckCarNumber")
-    public ResultJson checkPass(@RequestBody CheckCarNumberBO checkCarNumberBO) {
-        log.info("check car number");
-        openService.checkCarNumber(checkCarNumberBO);
-        return ResultJson.success();
+
+    private ResultJson checkCarNumber(CheckCarNumberBO checkCarNumberBO) {
+        log.info("check car number:{}", JSONUtil.toJsonStr(checkCarNumberBO));
+        return openService.checkCarNumber(checkCarNumberBO);
     }
 }

+ 10 - 0
sp-server/src/main/java/com/pj/project/tb_business/TbBusiness.java

@@ -187,6 +187,7 @@ public class TbBusiness extends Model<TbBusiness> implements Serializable {
     private Date adminConfirmPayTime;
     private String adminConfirmPayBy;
     private int adminConfirmOut=0;
+    private int adminConfirmIn=0;
     //结账方式(1=现结,2=月结)[j]
     private int customerType;
     private String chinaCarNo;
@@ -204,4 +205,13 @@ public class TbBusiness extends Model<TbBusiness> implements Serializable {
     private List<TbBusinessItem> items = new ArrayList<>();
 
 
+
+    public void setCardNo(String cardNo) {
+        this.cardNo = cardNo.toUpperCase().trim();
+    }
+
+
+    public void setChinaCarNo(String chinaCarNo) {
+        this.chinaCarNo = chinaCarNo.toUpperCase().trim();
+    }
 }

+ 1 - 1
sp-server/src/main/java/com/pj/project/tb_business/TbBusinessController.java

@@ -191,7 +191,7 @@ public class TbBusinessController {
         Date inTime = so.getDateTime("realInTime");
         Date chinaCarInTime = so.getDateTime("chinaCarInTime");
         TbBusiness tbBusiness = tbBusinessService.getById(id);
-        tbBusiness.setChinaCarInTime(chinaCarInTime).setRealInTime(inTime);
+        tbBusiness.setChinaCarInTime(chinaCarInTime).setRealInTime(inTime).setAdminConfirmIn(1);
         tbBusinessService.updateById(tbBusiness);
 
         //更新境外车入场记录

+ 27 - 13
sp-server/src/main/java/com/pj/project/tb_business/TbBusinessService.java

@@ -92,7 +92,8 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
 
     public TbBusiness checkCarNo(String carNo) {
         QueryWrapper<TbBusiness> ew = new QueryWrapper<>();
-        ew.eq("card_no", carNo).isNotNull("out_day_time");
+        ew.eq("card_no", carNo)
+                .eq("admin_confirm_out",0);
         return this.getOne(ew);
     }
 
@@ -103,11 +104,11 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         if (checkCarNo(t.getCardNo()) != null&&StrUtil.isEmpty(t.getId())) {
             return AjaxJson.getError("该车辆【" + t.getCardNo() + "】有未完成业务");
         }
+        if (checkCarNo(t.getChinaCarNo()) != null&&StrUtil.isEmpty(t.getId())) {
+            return AjaxJson.getError("该车辆【" + t.getChinaCarNo() + "】有未完成业务");
+        }
         t.setCreateBy(StpUserUtil.getAdmin().getName());
-        createCar(t);
         createCarUnit(t);
-        TbDriver tbDriver = createDriver(t);
-        t.setDriverId(tbDriver.getId());
         String customerId = t.getCustomerId();
         TbCostomer tbCostomer = tbCostomerService.getById(customerId);
         t.setCustomerName(tbCostomer.getName()).setCustomerType(tbCostomer.getPayType());
@@ -124,7 +125,6 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
             t.setCreateTime(new Date());
         }
         saveOrUpdate(t);
-
         createBusinessPeople(t);
         tbBusinessItemService.removeByBusinessId(t.getId());
         BigDecimal price = new BigDecimal(0);
@@ -237,12 +237,15 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         });
     }
 
-    public TbBusiness findCarTheNewRecord(String carNo) {
+    public TbBusiness findCarTheNewRecord(String carNo,int inOrOut) {
         QueryWrapper<TbBusiness> ew = new QueryWrapper<>();
         ew.eq("card_no", carNo);
-        ew.orderByDesc("id");
-        List<TbBusiness> list = this.list(ew);
-        return list.isEmpty() ? null : list.get(0);
+        if (inOrOut==1){
+            ew.eq("admin_confirm_in",0).isNull("in_channel");
+        }else {
+            ew.eq("admin_confirm_out",0).isNull("out_channel").isNotNull("real_in_time");
+        }
+        return getOne(ew);
     }
 
     public void adminConfirmIn(String id, String inChannel) {
@@ -305,12 +308,23 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         tbBusiness.setTotalMoney(tbBusiness.getItemPrice().add(tbBusiness.getChinaPartMoney()).add(tbBusiness.getPartMoney()));
     }
 
-    public TbBusiness findByChinaCarNo(String carNo) {
+    /**
+     *
+     * @param carNo
+     * @param inOrOut 1入 2出
+     * @return
+     */
+    public TbBusiness findByChinaCarNo(String carNo,int inOrOut) {
         QueryWrapper<TbBusiness> ew = new QueryWrapper<>();
         ew.eq("china_car_no", carNo);
-        ew.orderByDesc("id");
-        List<TbBusiness> list = this.list(ew);
-        return list.isEmpty() ? null : list.get(0);
+        if (inOrOut==1){
+            ew.eq("admin_confirm_in",0).isNull("china_car_in_channel");
+        }else {
+            ew.eq("admin_confirm_out",0)
+                    .isNull("china_car_out_channel")
+                    .isNotNull("china_car_in_time");
+        }
+      return this.getOne(ew);
     }
 
 

+ 1 - 1
sp-server/src/main/resources/application.yml

@@ -59,7 +59,7 @@ mybatis-plus:
     # 一些配置
     configuration: 
         # 控制打印sql 
-        # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+        log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
         # 是否开启下划线转驼峰 
         map-underscore-to-camel-case: true
         # 即使属性为null, 也要映射