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

- 观光车申请进入交管区域(待完成);

Gizmo-PC 3 лет назад
Родитель
Сommit
220dd4a65f

+ 7 - 0
src/main/java/com/warewms/service/BasTrafficControlService.java

@@ -1,6 +1,13 @@
 package com.warewms.service;
 
+import com.fdd.protobuf.InfoProto;
 import com.warewms.model.BasTrafficControl;
 
 public interface BasTrafficControlService extends BaseService<BasTrafficControl> {
+
+    /**
+     * 观光车申请进入交管区域
+     * @param imu 观光车定义套接字转换实体
+     */
+    void applyBossPermission(InfoProto.imu imu);
 }

+ 76 - 0
src/main/java/com/warewms/service/BaseService.java

@@ -0,0 +1,76 @@
+package com.warewms.service;
+
+import com.jfinal.plugin.activerecord.Model;
+import com.jfinal.plugin.activerecord.Page;
+import com.jfinal.plugin.activerecord.SqlPara;
+import com.warewms.common.entity.Filter;
+import com.warewms.common.entity.Order;
+import com.warewms.common.utils.PageUtils;
+
+import java.util.List;
+import java.util.Map;
+
+public interface BaseService<M extends Model<M>> {
+
+    List<M> findAll();
+
+    M findById(Object... id);
+
+    List<M> findByModel(M model);
+
+    List<M> findByModelOrderBy(M model, String orderBy);
+
+    M findFirstByModel(M model);
+
+    M findFirstByModelOrderBy(M model, String orderBy);
+
+    List<M> find(SqlPara sqlPara);
+
+    M findFirst(SqlPara sqlPara);
+
+    boolean deleteBatch(Object[]... ids);
+
+    boolean deleteBatch(String[] columns, Object[]... ids);
+
+    boolean deleteByModel(M model);
+
+    Page<M> paginate(Integer pageNum, Integer pageSize, List<Filter> filters, Order order);
+
+    Page<M> paginate(Integer pageNum, Integer pageSize, List<Filter> filters);
+
+    Page<M> paginate(Integer pageNum, Integer pageSize);
+
+    Page<M> paginate(Integer pageNum, Integer pageSize, List<Filter> filters, List<Order> orders);
+
+    Page<M> paginate(Integer pageNum, Integer pageSize, Filter filter, List<Order> orders);
+
+    Page<M> paginate(Integer pageNum, Integer pageSize, Filter filter, Order order);
+
+    PageUtils queryPage(Map<String, Object> params);
+
+    M insert(M model);
+
+    List<M> findByFilter(Filter filter);
+
+    List<M> findByFilters(List<Filter> filter);
+
+    List<M> findByFilters(List<Filter> filter, List<Order> orders);
+
+    M findFirstByFilters(List<Filter> filter, List<Order> orders);
+
+    boolean update(M model);
+
+    boolean delete(M model);
+
+    /**
+     * 查询list
+     * @param first 分页起始(不分页传null)
+     * @param count 每页行数(不分页传null)
+     * @param filters
+     * @param orders
+     * @return
+     */
+    List<M> findList(Integer first, Integer count, List<Filter> filters, List<Order> orders);
+
+
+}

+ 6 - 0
src/main/java/com/warewms/service/impl/BasTrafficControlServiceImpl.java

@@ -1,5 +1,6 @@
 package com.warewms.service.impl;
 
+import com.fdd.protobuf.InfoProto;
 import com.warewms.dao.BasTrafficControlDao;
 import com.warewms.model.BasTrafficControl;
 import com.warewms.service.BasTrafficControlService;
@@ -7,4 +8,9 @@ import org.springframework.stereotype.Service;
 
 @Service
 public class BasTrafficControlServiceImpl extends BaseServiceImpl<BasTrafficControlDao, BasTrafficControl> implements BasTrafficControlService {
+
+    @Override
+    public void applyBossPermission(InfoProto.imu imu) {
+
+    }
 }

+ 162 - 0
src/main/java/com/warewms/service/impl/BaseServiceImpl.java

@@ -0,0 +1,162 @@
+package com.warewms.service.impl;
+
+import com.jfinal.plugin.activerecord.Model;
+import com.jfinal.plugin.activerecord.Page;
+import com.jfinal.plugin.activerecord.SqlPara;
+import com.warewms.common.entity.Filter;
+import com.warewms.common.entity.Order;
+import com.warewms.common.utils.PageUtils;
+import com.warewms.common.utils.Query;
+import com.warewms.dao.BaseDao;
+import com.warewms.service.BaseService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class BaseServiceImpl<T extends BaseDao<M>, M extends Model<M>> implements BaseService<M> {
+
+    @Autowired
+    public T dao;
+
+    @Override
+    public List<M> findAll() {
+        return dao.findAll();
+    }
+
+    @Override
+    public M findById(Object... id) {
+        return dao.findById(id);
+    }
+
+    @Override
+    public List<M> findByModel(M model) {
+        return dao.findByModel(model);
+    }
+
+    @Override
+    public List<M> findByModelOrderBy(M model, String orderBy) {
+        return dao.findByModelOrderBy(model,orderBy);
+    }
+
+    @Override
+    public M findFirstByModel(M model) {
+        return dao.findFirstByModel(model);
+    }
+
+    @Override
+    public M findFirstByModelOrderBy(M model, String orderBy) {
+        return dao.findFirstByModelOrderBy(model,orderBy);
+    }
+
+    @Override
+    public List<M> find(SqlPara sqlPara) {
+        return dao.find(sqlPara);
+    }
+
+    @Override
+    public M findFirst(SqlPara sqlPara) {
+        return dao.findFirst(sqlPara);
+    }
+
+    @Override
+    public boolean deleteBatch(Object[]... ids) {
+        return dao.deleteBatch(ids);
+    }
+
+    @Override
+    public boolean deleteBatch(String[] columns, Object[]... ids) {
+        return dao.deleteBatch(columns, ids);
+    }
+
+    @Override
+    public boolean deleteByModel(M model) {
+        return dao.deleteByModel(model);
+    }
+
+    @Override
+    public Page<M> paginate(Integer pageNum, Integer pageSize, List<Filter> filters, Order order) {
+        return this.dao.paginate(pageNum, pageSize, filters, order);
+    }
+
+    @Override
+    public Page<M> paginate(Integer pageNum, Integer pageSize, List<Filter> filters) {
+        return this.dao.paginate(pageNum, pageSize, filters);
+    }
+
+    @Override
+    public Page<M> paginate(Integer pageNum, Integer pageSize) {
+        return this.dao.paginate(pageNum, pageSize);
+    }
+
+    @Override
+    public Page<M> paginate(Integer pageNum, Integer pageSize, List<Filter> filters, List<Order> orders) {
+        return this.dao.paginate(pageNum, pageSize, filters, orders);
+    }
+
+    @Override
+    public Page<M> paginate(Integer pageNum, Integer pageSize, Filter filter, List<Order> orders) {
+        return this.dao.paginate(pageNum, pageSize, filter, orders);
+    }
+
+    @Override
+    public Page<M> paginate(Integer pageNum, Integer pageSize, Filter filter, Order order) {
+        List<Order> orderList = new ArrayList<>();
+        orderList.add(order);
+        return this.dao.paginate(pageNum, pageSize, filter, orderList);
+    }
+
+    @Override
+    public PageUtils queryPage(Map<String, Object> params) {
+        Query<M> query = new Query<>(params);
+        Page<M> pr = this.paginate(query.getCurrPage(), query.getLimit());
+        return new PageUtils(pr);
+    }
+
+    @Override
+    public M insert(M model) {
+        Boolean flag =  model.save();
+        if (flag){
+
+            return model;
+        }else{
+            return  null;
+        }
+    }
+
+    @Override
+    public List<M> findByFilter(Filter filter) {
+        return this.dao.findByFilter(filter);
+    }
+
+    @Override
+    public List<M> findByFilters(List<Filter> filter) {
+        return this.dao.findByFilters(filter);
+    }
+
+    @Override
+    public List<M> findByFilters(List<Filter> filter, List<Order> orders) {
+        return this.dao.findByFiltersOrders(filter,orders);
+    }
+
+    @Override
+    public M findFirstByFilters(List<Filter> filter, List<Order> orders) {
+        return this.dao.findFirstByFiltersOrders(filter,orders);
+    }
+
+    @Override
+    public boolean update(M model) {
+        return model.update();
+    }
+
+    @Override
+    public boolean delete(M model) {
+        return model.delete();
+    }
+
+    @Override
+    public List<M> findList(Integer first, Integer count, List<Filter> filters, List<Order> orders) {
+        return dao.findList(first, count, filters, orders);
+    }
+}

+ 5 - 13
src/main/java/com/warewms/socket/SocketServerClientHandler.java

@@ -30,22 +30,14 @@ public class SocketServerClientHandler extends Thread {
                 //读取长度
                 int lenData = dis.readInt();
 
-                InfoProto.carinfo carInfo = InfoProto.carinfo.parseFrom(ByteString.readFrom(is));
-                if (null != carInfo) {
-                    System.out.println("server received data:\n" + carInfo.toString());
+                InfoProto.imu imu = InfoProto.imu.parseFrom(ByteString.readFrom(is));
+                if (null != imu) {
+                    System.out.println("server received data:\n" + imu.toString());
 
-                    carInfo = InfoProto.carinfo.newBuilder().setTimestampUs(1000).setVid(999).setUsr("Gizmo").setPsw("123456").setCarId("V01").build();
-                    os.write(carInfo.toByteArray());
+                    imu = InfoProto.imu.newBuilder().setTimestampUs(1000).setVid(999) .build();
+                    os.write(imu.toByteArray());
                     os.flush();
                 }
-
-//                while ((len = is.read(data)) != -1) {
-//
-//                    String message = new String(data, 0, len);
-//                    System.out.println("客户端传来消息: " + message);
-//                    os.write(data);
-////                    os.flush();
-//                }
             }
 
         } catch (Exception e) {