Explorar o código

出入记录,客户管理

lzm %!s(int64=3) %!d(string=hai) anos
pai
achega
002d0d9df0

+ 50 - 0
sp-server/src/main/java/com/pj/api/bo/InOutRecordBO.java

@@ -0,0 +1,50 @@
+package com.pj.api.bo;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @Auther: lzm
+ * @Date: 2022/01/19/18:15
+ * @Description:
+ */
+@Data
+@Accessors(chain = true)
+public class InOutRecordBO {
+
+    private String businessId;
+
+    /**
+     * 客户名称
+     */
+    private String customerName;
+
+    private String customerContact;
+
+    private String dutyPeople;
+
+    /**
+     * 车牌号
+     */
+    private String cardNo;
+
+    /**
+     * 实际进境时间
+     */
+    private Date realInTime;
+
+    /**
+     * 离境时间
+     */
+    private Date outDayTime;
+
+    /**
+     * 状态(1=未入场, 2=已入场, 3=已出场)
+     */
+    private int status;
+
+}

+ 42 - 2
sp-server/src/main/java/com/pj/api/h5/ApiController.java

@@ -1,19 +1,25 @@
 package com.pj.api.h5;
 
 
+import com.pj.api.bo.InOutRecordBO;
+import com.pj.api.service.ApiService;
+import com.pj.constants.UserTypeEnum;
+import com.pj.current.satoken.StpUserUtil;
+import com.pj.project.tb_business.TbBusinessService;
 import com.pj.project.tb_costomer.TbCostomer;
 import com.pj.project.tb_costomer.TbCostomerService;
 import com.pj.project4sp.admin4login.SpAccAdminService;
 import com.pj.utils.sg.AjaxJson;
 import com.pj.utils.sg.NbUtil;
+import com.pj.utils.so.SoMap;
 import lombok.extern.slf4j.Slf4j;
-import org.aspectj.weaver.loadtime.Aj;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
 
 @RequestMapping(value = "/api")
 @RestController
@@ -21,9 +27,14 @@ import javax.annotation.Resource;
 public class ApiController {
 
     @Resource
+    ApiService apiService;
+    @Resource
     SpAccAdminService spAccAdminService;
     @Resource
     TbCostomerService tbCostomerService;
+    @Resource
+    TbBusinessService tbBusinessService;
+
     /** 账号、密码登录  */
     @RequestMapping("doLogin")
     AjaxJson doLogin(String key, String password) {
@@ -39,4 +50,33 @@ public class ApiController {
         tbCostomerService.register(costomer);
         return AjaxJson.getSuccess();
     }
+
+    @RequestMapping(value = "getInOutRecord")
+    public AjaxJson getInOutRecord(){
+        SoMap so = SoMap.getRequestSoMap();
+        String currentCustomerId = StpUserUtil.getCustomerId();
+        if (!currentCustomerId.equals(UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
+            so.put("customerId",currentCustomerId);
+        }
+        List<InOutRecordBO> recordList = apiService.getInOutRecord(so);
+        return AjaxJson.getSuccessData(recordList);
+    }
+
+    @RequestMapping(value = "getCustomerList")
+    public AjaxJson getCustomerList(){
+        SoMap so = SoMap.getRequestSoMap();
+        String currentCustomerId = StpUserUtil.getCustomerId();
+        if (!currentCustomerId.equals(UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
+            so.put("id",currentCustomerId);
+        }
+        List<TbCostomer> list = apiService.getCustomerList(so);
+        return AjaxJson.getSuccessData(list);
+    }
+
+    @PostMapping(value = "confirmCustomer")
+    public AjaxJson confirmCustomer(Long customerId){
+        apiService.confirmCustomer(customerId);
+        return AjaxJson.getSuccess();
+    }
+
 }

+ 76 - 0
sp-server/src/main/java/com/pj/api/service/ApiService.java

@@ -0,0 +1,76 @@
+package com.pj.api.service;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.pj.api.bo.InOutRecordBO;
+import com.pj.project.tb_business.TbBusiness;
+import com.pj.project.tb_business.TbBusinessService;
+import com.pj.project.tb_costomer.TbCostomer;
+import com.pj.project.tb_costomer.TbCostomerService;
+import com.pj.utils.so.SoMap;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ */
+
+@Service
+@Transactional(rollbackFor = Exception.class)
+@Slf4j
+public class ApiService {
+
+    @Resource
+    TbCostomerService tbCostomerService;
+    @Resource
+    TbBusinessService tbBusinessService;
+
+    public List<InOutRecordBO> getInOutRecord(SoMap so){
+        int current = so.getInt("current");
+        List<TbBusiness> businessList = tbBusinessService.getList(so);
+        List<InOutRecordBO> recordList = new ArrayList<>();
+        for (TbBusiness business : businessList) {
+            InOutRecordBO record = new InOutRecordBO();
+            BeanUtil.copyProperties(business, record);
+            TbCostomer costomer = tbCostomerService.getById(business.getCustomerId());
+            record.setBusinessId(business.getId()).setCustomerContact(costomer.getPhone()).setDutyPeople(costomer.getDutyPeople());
+            if(record.getRealInTime() != null && record.getOutDayTime() != null){
+                record.setStatus(3);//已出场
+            }else if(record.getRealInTime() != null && record.getOutDayTime() == null){
+                record.setStatus(2);//已入场
+            }else{
+                record.setStatus(1);//未入场
+            }
+            if(current == 0){
+                recordList.add(record);
+            }else if(current == record.getStatus()) {
+                recordList.add(record);
+            }
+        }
+        return recordList;
+    }
+
+    public List<TbCostomer> getCustomerList(SoMap so) {
+        int current = so.getInt("current");
+        List<TbCostomer> costomerList = new ArrayList<>();
+        List<TbCostomer> list = tbCostomerService.getList(so);
+        for (TbCostomer costomer : list) {
+            if(current == 0){
+                costomerList.add(costomer);
+            }else if(current == costomer.getJudgeStatus()){
+                costomerList.add(costomer);
+            }
+        }
+        return costomerList;
+    }
+
+    public void confirmCustomer(Long customerId) {
+        TbCostomer costomer = tbCostomerService.getById(customerId);
+        if(costomer != null && costomer.getJudgeStatus() == 1){
+            tbCostomerService.judge(customerId + "", 2, "H5端审核");
+        }
+    }
+}

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

@@ -133,7 +133,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
     /**
      * 查集合 - 根据条件(参数为空时代表忽略指定条件)
      */
-    List<TbBusiness> getList(SoMap so) {
+    public List<TbBusiness> getList(SoMap so) {
         return tbBusinessMapper.getList(so);
     }
 

+ 1 - 1
sp-server/src/main/java/com/pj/project/tb_costomer/TbCostomerService.java

@@ -98,7 +98,7 @@ public class TbCostomerService extends ServiceImpl<TbCostomerMapper, TbCostomer>
     /**
      * 查集合 - 根据条件(参数为空时代表忽略指定条件)
      */
-    List<TbCostomer> getList(SoMap so) {
+    public List<TbCostomer> getList(SoMap so) {
         return tbCostomerMapper.getList(so);
     }