Преглед изворни кода

上下料站非每个工控机一个扫码抢,改成扫码登录前先让用户选择那个上下料站,后续将上下料站进行排产分配

yejian016332 пре 4 година
родитељ
комит
52f70a1efb
16 измењених фајлова са 322 додато и 4 уклоњено
  1. 18 0
      imcs-admin-boot/imcs-authority-biz/src/main/java/com/github/zuihou/authority/dao/auth/StationUserLoginInfoMapper.java
  2. 19 0
      imcs-admin-boot/imcs-authority-biz/src/main/java/com/github/zuihou/authority/service/auth/StationUserLoginInfoService.java
  3. 25 0
      imcs-admin-boot/imcs-authority-biz/src/main/java/com/github/zuihou/authority/service/auth/impl/StationUserLoginInfoServiceImpl.java
  4. 19 0
      imcs-admin-boot/imcs-authority-biz/src/main/resources/mapper_authority/base/auth/StationUserLoginInfoMapper.xml
  5. 7 1
      imcs-admin-boot/imcs-authority-entity/src/main/java/com/github/zuihou/authority/dto/auth/LoginParamDTO.java
  6. 40 0
      imcs-admin-boot/imcs-authority-entity/src/main/java/com/github/zuihou/authority/dto/auth/StationUserLoginInfoDTO.java
  7. 40 0
      imcs-admin-boot/imcs-authority-entity/src/main/java/com/github/zuihou/authority/dto/auth/StationUserLoginInfoSaveDTO.java
  8. 48 0
      imcs-admin-boot/imcs-authority-entity/src/main/java/com/github/zuihou/authority/dto/auth/StationUserLoginInfoUpdateDTO.java
  9. 44 0
      imcs-admin-boot/imcs-authority-entity/src/main/java/com/github/zuihou/authority/entity/auth/StationUserLoginInfo.java
  10. 3 3
      imcs-admin-boot/imcs-common/src/main/java/com/github/zuihou/common/properties/IgnoreTokenProperties.java
  11. 42 0
      imcs-admin-boot/imcs-oauth-controller/src/main/java/com/github/zuihou/oauth/controller/OauthController.java
  12. 1 0
      imcs-admin-boot/imcs-tenant-biz/src/main/java/com/github/zuihou/tenant/dao/ProductionresourceMapper.java
  13. 1 0
      imcs-admin-boot/imcs-tenant-biz/src/main/java/com/github/zuihou/tenant/service/ProductionresourceService.java
  14. 6 0
      imcs-admin-boot/imcs-tenant-biz/src/main/java/com/github/zuihou/tenant/service/impl/ProductionresourceServiceImpl.java
  15. 3 0
      imcs-admin-boot/imcs-tenant-biz/src/main/resources/mapper_tenant/base/defaults/ProductionresourceMapper.xml
  16. 6 0
      imcs-admin-boot/imcs-tenant-controller/src/main/java/com/github/zuihou/tenant/controller/ProductionresourceController.java

+ 18 - 0
imcs-admin-boot/imcs-authority-biz/src/main/java/com/github/zuihou/authority/dao/auth/StationUserLoginInfoMapper.java

@@ -0,0 +1,18 @@
+package com.github.zuihou.authority.dao.auth;
+
+import com.github.zuihou.authority.entity.auth.StationUserLoginInfo;
+import com.github.zuihou.base.mapper.SuperMapper;
+import org.springframework.stereotype.Repository;
+
+/**
+ * <p>
+ * Mapper 接口
+ * 区域管理
+ * </p>
+ *
+ * @author imcs
+ * @date 2020-11-24
+ */
+@Repository
+public interface StationUserLoginInfoMapper extends SuperMapper<StationUserLoginInfo> {
+}

+ 19 - 0
imcs-admin-boot/imcs-authority-biz/src/main/java/com/github/zuihou/authority/service/auth/StationUserLoginInfoService.java

@@ -0,0 +1,19 @@
+package com.github.zuihou.authority.service.auth;
+
+import com.github.zuihou.authority.entity.auth.StationUserLoginInfo;
+import com.github.zuihou.base.service.SuperService;
+
+/**
+ * <p>
+ * 业务接口
+ * 人工上下料站操作工人登录
+ * </p>
+ *
+ * @author imcs
+ * @date 2020-11-24
+ */
+public interface StationUserLoginInfoService extends SuperService<StationUserLoginInfo> {
+
+
+
+}

+ 25 - 0
imcs-admin-boot/imcs-authority-biz/src/main/java/com/github/zuihou/authority/service/auth/impl/StationUserLoginInfoServiceImpl.java

@@ -0,0 +1,25 @@
+package com.github.zuihou.authority.service.auth.impl;
+
+import com.github.zuihou.authority.dao.auth.StationUserLoginInfoMapper;
+import com.github.zuihou.authority.entity.auth.StationUserLoginInfo;
+import com.github.zuihou.authority.service.auth.StationUserLoginInfoService;
+import com.github.zuihou.base.service.SuperServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 业务实现类
+ * 区域管理
+ * </p>
+ *
+ * @author imcs
+ * @date 2020-11-24
+ */
+@Slf4j
+@Service
+public class StationUserLoginInfoServiceImpl extends SuperServiceImpl<StationUserLoginInfoMapper, StationUserLoginInfo> implements StationUserLoginInfoService {
+    @Autowired
+    private StationUserLoginInfoService stationUserLoginInfoService;
+}

+ 19 - 0
imcs-admin-boot/imcs-authority-biz/src/main/resources/mapper_authority/base/auth/StationUserLoginInfoMapper.xml

@@ -0,0 +1,19 @@
+<?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.github.zuihou.authority.dao.auth.StationUserLoginInfoMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.github.zuihou.authority.entity.auth.StationUserLoginInfo">
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="station_id" jdbcType="BIGINT" property="stationId"/>
+        <result column="user_id" jdbcType="BIGINT" property="userId"/>
+        <result column="current_login_time" jdbcType="TIMESTAMP" property="currentLoginTime"/>
+
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id,station_id,user_id,current_login_time
+    </sql>
+
+</mapper>

+ 7 - 1
imcs-admin-boot/imcs-authority-entity/src/main/java/com/github/zuihou/authority/dto/auth/LoginParamDTO.java

@@ -50,8 +50,14 @@ public class LoginParamDTO {
     private String refreshToken;
 
     /**
-     * 前端界面点击清空缓存时调用
+     * 扫码登录的用户信息
      */
     @ApiModelProperty(value = "qcode扫码登录信息")
     private String qcodeUser;
+
+    /**
+     * 扫码登录选中的上下料站
+     */
+    @ApiModelProperty(value = "扫码登录选中的上下料站")
+    private Long stationResourceId;
 }

+ 40 - 0
imcs-admin-boot/imcs-authority-entity/src/main/java/com/github/zuihou/authority/dto/auth/StationUserLoginInfoDTO.java

@@ -0,0 +1,40 @@
+package com.github.zuihou.authority.dto.auth;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.*;
+import lombok.experimental.Accessors;
+
+import java.time.LocalDateTime;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Accessors(chain = true)
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = false)
+@Builder
+@ApiModel(value = "StationUserPageDTO", description = "上下料站用户管理")
+public class StationUserLoginInfoDTO {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 上下料站人员Id
+     */
+    @ApiModelProperty(value = "上下料站人员Id")
+    private Long userId;
+
+    /**
+     * 上下料站ID
+     */
+    @ApiModelProperty(value = "上下料站ID")
+    private Long stationId;
+
+    /**
+     * 上下料站ID
+     */
+    @ApiModelProperty(value = "上下料站工人登录时间")
+    private LocalDateTime currentLoginTime;
+
+}

+ 40 - 0
imcs-admin-boot/imcs-authority-entity/src/main/java/com/github/zuihou/authority/dto/auth/StationUserLoginInfoSaveDTO.java

@@ -0,0 +1,40 @@
+package com.github.zuihou.authority.dto.auth;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.*;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Accessors(chain = true)
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = false)
+@Builder
+@ApiModel(value = "StationUserSaveDTO", description = "上下料站用户管理")
+public class StationUserLoginInfoSaveDTO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+    /**
+     * 上下料站人员Id
+     */
+    @ApiModelProperty(value = "上下料站人员Id")
+    private Long userId;
+
+    /**
+     * 上下料站ID
+     */
+    @ApiModelProperty(value = "上下料站ID")
+    private Long stationId;
+
+    /**
+     * 上下料站ID
+     */
+    @ApiModelProperty(value = "上下料站工人登录时间")
+    private LocalDateTime currentLoginTime;
+}

+ 48 - 0
imcs-admin-boot/imcs-authority-entity/src/main/java/com/github/zuihou/authority/dto/auth/StationUserLoginInfoUpdateDTO.java

@@ -0,0 +1,48 @@
+package com.github.zuihou.authority.dto.auth;
+
+import com.github.zuihou.base.entity.SuperEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.*;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Accessors(chain = true)
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = false)
+@Builder
+@ApiModel(value = "StationUserUpdateDTO", description = "上下料站用户管理")
+public class StationUserLoginInfoUpdateDTO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "主键")
+    @NotNull(message = "id不能为空", groups = SuperEntity.Update.class)
+    private Long id;
+
+    /**
+     * 上下料站人员Id
+     */
+    @ApiModelProperty(value = "上下料站人员Id")
+    private Long userId;
+
+    /**
+     * 上下料站ID
+     */
+    @ApiModelProperty(value = "上下料站ID")
+    @NotNull(message = "上下料站ID不能为空")
+    private Long stationId;
+
+    /**
+     * 上下料站ID
+     */
+    @ApiModelProperty(value = "上下料站工人登录时间")
+    private LocalDateTime currentLoginTime;
+}

+ 44 - 0
imcs-admin-boot/imcs-authority-entity/src/main/java/com/github/zuihou/authority/entity/auth/StationUserLoginInfo.java

@@ -0,0 +1,44 @@
+package com.github.zuihou.authority.entity.auth;
+
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.github.zuihou.base.entity.Entity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.*;
+import lombok.experimental.Accessors;
+
+import java.time.LocalDateTime;
+
+@Data
+@NoArgsConstructor
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = true)
+@Accessors(chain = true)
+@TableName("imcs_station_user_login")
+@ApiModel(value = "StationUser", description = "上下料站操作用户")
+@Builder
+@AllArgsConstructor
+public class StationUserLoginInfo extends Entity<Long> {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 用户ID
+     */
+    @ApiModelProperty(value = "管理人员ID")
+    @TableField("user_id")
+    private Long userId;
+
+    /**
+     * 上下料站ID
+     */
+    @ApiModelProperty(value = "上下料站ID")
+    @TableField("station_id")
+    private Long stationId;
+
+
+    @ApiModelProperty(value = "当前上下料登录人")
+    @TableField("current_login_time")
+    private LocalDateTime currentLoginTime;
+}

+ 3 - 3
imcs-admin-boot/imcs-common/src/main/java/com/github/zuihou/common/properties/IgnoreTokenProperties.java

@@ -42,9 +42,9 @@ public class IgnoreTokenProperties {
             "/tray/**",
             "/mToolClamp/**",
             "/wms/**",
-            "/manual/**"
-
-    );
+            "/wms/**",
+            "/productionresource/getStations"
+            );
 
     public boolean isIgnoreToken(String path) {
         return getUrl().stream().anyMatch((url) -> path.startsWith(url) || ANT_PATH_MATCHER.match(url, path));

+ 42 - 0
imcs-admin-boot/imcs-oauth-controller/src/main/java/com/github/zuihou/oauth/controller/OauthController.java

@@ -1,10 +1,14 @@
 package com.github.zuihou.oauth.controller;
 
 import cn.hutool.core.util.StrUtil;
+import com.github.zuihou.authority.dao.auth.StationUserLoginInfoMapper;
+import com.github.zuihou.authority.dao.core.StationMapper;
 import com.github.zuihou.authority.dto.auth.LoginParamDTO;
+import com.github.zuihou.authority.entity.auth.StationUserLoginInfo;
 import com.github.zuihou.base.R;
 import com.github.zuihou.common.constant.BizConstant;
 import com.github.zuihou.context.BaseContextHandler;
+import com.github.zuihou.database.mybatis.conditions.Wraps;
 import com.github.zuihou.exception.BizException;
 import com.github.zuihou.jwt.TokenUtil;
 import com.github.zuihou.jwt.model.AuthInfo;
@@ -13,6 +17,7 @@ import com.github.zuihou.oauth.granter.TokenGranter;
 import com.github.zuihou.oauth.granter.TokenGranterBuilder;
 import com.github.zuihou.oauth.service.AdminUiService;
 import com.github.zuihou.oauth.service.ValidateCodeService;
+import com.github.zuihou.tenant.entity.Productionresource;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
@@ -24,6 +29,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.time.LocalDateTime;
 
 import static com.github.zuihou.utils.BizAssert.isFalse;
 
@@ -48,6 +54,8 @@ public class OauthController {
     private AdminUiService authManager;
     @Autowired
     private TokenUtil tokenUtil;
+    @Autowired
+    private StationUserLoginInfoMapper stationUserLoginInfoMapper;
 
     /**
      * 租户登录 zuihou-ui 系统
@@ -67,6 +75,8 @@ public class OauthController {
         TokenGranter granter = tokenGranterBuilder.getGranter(login.getGrantType());
         R<AuthInfo> userInfo = granter.grant(login);
 
+        // 账号密码登录绑定当前登录用户和上下料站的绑定关系
+        stationLoginInfo(login, userInfo);
         return userInfo;
     }
 
@@ -146,6 +156,38 @@ public class OauthController {
         TokenGranter granter = tokenGranterBuilder.getGranter(login.getGrantType());
         R<AuthInfo> userInfo = granter.grant(login);
 
+        // 二维码登录绑定当前登录用户和上下料站的绑定关系
+        // 先判断上下料站是否之前有人登录过,如果已经有人登录,更新登录信息
+        stationLoginInfo(login, userInfo);
         return userInfo;
     }
+
+    private void stationLoginInfo(@RequestBody @Validated LoginParamDTO login, R<AuthInfo> userInfo) {
+        Long userId = userInfo.getData().getUserId();
+        StationUserLoginInfo hisUserLoginInfo = stationUserLoginInfoMapper.selectOne(Wraps.<StationUserLoginInfo>lbQ().eq(StationUserLoginInfo::getUserId, userId));
+        if(null != hisUserLoginInfo){
+            hisUserLoginInfo.setUserId(null);
+            hisUserLoginInfo.setCurrentLoginTime(null);
+            stationUserLoginInfoMapper.updateAllById(hisUserLoginInfo);
+        }
+
+
+        StationUserLoginInfo hisStationUserLoginInfo = stationUserLoginInfoMapper.selectOne(Wraps.<StationUserLoginInfo>lbQ().eq(StationUserLoginInfo::getStationId, login.getStationResourceId()));
+        if(null != hisStationUserLoginInfo){
+            hisStationUserLoginInfo.setUserId(userInfo.getData().getUserId());
+            hisStationUserLoginInfo.setCurrentLoginTime(LocalDateTime.now());
+            hisStationUserLoginInfo.setUpdateUser(userId);
+            stationUserLoginInfoMapper.updateAllById(hisStationUserLoginInfo);
+        }else{
+            StationUserLoginInfo stationUserLoginInfo = new StationUserLoginInfo();
+            stationUserLoginInfo.setUserId(userId);
+            stationUserLoginInfo.setStationId(login.getStationResourceId());
+            stationUserLoginInfo.setCurrentLoginTime(LocalDateTime.now());
+            stationUserLoginInfo.setCreateUser(userId);
+            stationUserLoginInfo.setUpdateUser(userId);
+            stationUserLoginInfoMapper.insert(stationUserLoginInfo);
+        }
+
+
+    }
 }

+ 1 - 0
imcs-admin-boot/imcs-tenant-biz/src/main/java/com/github/zuihou/tenant/dao/ProductionresourceMapper.java

@@ -67,4 +67,5 @@ public interface ProductionresourceMapper extends SuperMapper<Productionresource
 
     List<Map>getList(Map map);
 
+    List<Map> getStations(Map params);
 }

+ 1 - 0
imcs-admin-boot/imcs-tenant-biz/src/main/java/com/github/zuihou/tenant/service/ProductionresourceService.java

@@ -111,4 +111,5 @@ public interface ProductionresourceService extends SuperCacheService<Productionr
 
     public String getGatherSQL();
 
+    List<Map> getStations(Map params);
 }

+ 6 - 0
imcs-admin-boot/imcs-tenant-biz/src/main/java/com/github/zuihou/tenant/service/impl/ProductionresourceServiceImpl.java

@@ -1017,4 +1017,10 @@ public class ProductionresourceServiceImpl extends SuperCacheServiceImpl<Product
             return null;
         }
     }
+
+    @Override
+    public List<Map> getStations(Map params){
+        params.put("name","保障中心_上下料站");
+        return baseMapper.getStations(params);
+    }
 }

+ 3 - 0
imcs-admin-boot/imcs-tenant-biz/src/main/resources/mapper_tenant/base/defaults/ProductionresourceMapper.xml

@@ -76,6 +76,9 @@
     <select id="selectSql" parameterType="String" resultType="map">
           ${sql}
     </select>
+    <select id="getStations" resultType="java.util.Map">
+        select a.name,a.id as 'value' from imcs_tenant_productionresource a where a.name like concat('%', #{name}, '%')
+    </select>
 
 
 </mapper>

+ 6 - 0
imcs-admin-boot/imcs-tenant-controller/src/main/java/com/github/zuihou/tenant/controller/ProductionresourceController.java

@@ -78,6 +78,12 @@ public class ProductionresourceController extends SuperCacheController<Productio
         return success(baseService.pageList(map));
     }
 
+    @ApiOperation(value = "租户端上下料站查询", notes = "租户端上下料站查询")
+    @PostMapping("/getStations")
+    public R<List<Map>> getStations( @RequestBody(required = false) Map params) {
+        return (R<List<Map>>) success(baseService.getStations(params));
+    }
+
     /**
      * 设备展示图
      * @return