Selaa lähdekoodia

库存预警 登录

userName 1 vuosi sitten
vanhempi
commit
8c6b93ee8a

+ 8 - 0
xingyun-api/pom.xml

@@ -41,6 +41,14 @@
41 41
             <groupId>com.lframework</groupId>
42 42
             <artifactId>xingyun-template</artifactId>
43 43
         </dependency>
44
+
45
+
46
+<!--        <dependency>-->
47
+<!--            <groupId>com.google.code.gson</groupId>-->
48
+<!--            <artifactId>gson</artifactId>-->
49
+<!--            <version>2.8.6</version> &lt;!&ndash; 请使用最新的版本号 &ndash;&gt;-->
50
+<!--        </dependency>-->
51
+
44 52
     </dependencies>
45 53
 
46 54
     <build>

+ 35 - 0
xingyun-sc/src/main/java/com/lframework/xingyun/sc/controller/stock/ProductStockController.java

@@ -7,6 +7,7 @@ import com.lframework.starter.web.controller.DefaultBaseController;
7 7
 import com.lframework.starter.web.resp.InvokeResult;
8 8
 import com.lframework.starter.web.resp.InvokeResultBuilder;
9 9
 import com.lframework.starter.web.resp.PageResult;
10
+import com.lframework.starter.web.service.SysParameterService;
10 11
 import com.lframework.starter.web.utils.ExcelUtil;
11 12
 import com.lframework.starter.web.utils.PageResultUtil;
12 13
 import com.lframework.xingyun.sc.bo.stock.product.QueryProductStockBo;
@@ -19,6 +20,9 @@ import io.swagger.annotations.ApiOperation;
19 20
 import java.util.List;
20 21
 import java.util.stream.Collectors;
21 22
 import javax.validation.Valid;
23
+
24
+import org.codehaus.groovy.tools.StringHelper;
25
+import org.hamcrest.text.IsEmptyString;
22 26
 import org.springframework.beans.factory.annotation.Autowired;
23 27
 import org.springframework.validation.annotation.Validated;
24 28
 import org.springframework.web.bind.annotation.GetMapping;
@@ -38,6 +42,37 @@ public class ProductStockController extends DefaultBaseController {
38 42
 
39 43
   @Autowired
40 44
   private ProductStockService productStockService;
45
+  @Autowired
46
+  private SysParameterService sysParameterService;
47
+
48
+  /**
49
+   * 查询商品库存
50
+   */
51
+  @ApiOperation("查询库存yujing ")
52
+  @HasPermission({"stock:product:query"})
53
+  @GetMapping("/warn")
54
+  public InvokeResult<PageResult<QueryProductStockBo>> warn(@Valid QueryProductStockVo vo) {
55
+    String value= sysParameterService.findByKey("kcinfo") ;
56
+    try {
57
+      vo.setProductCount(Long.parseLong(value));
58
+    } catch(Exception e)  {
59
+      vo.setProductCount(10L) ;
60
+    }
61
+
62
+    PageResult<ProductStock> pageResult = productStockService.query(getPageIndex(vo),
63
+            getPageSize(vo), vo);
64
+    List<QueryProductStockBo> results = null;
65
+
66
+    List<ProductStock> datas = pageResult.getDatas();
67
+    if (!CollectionUtil.isEmpty(datas)) {
68
+      results = datas.stream().map(QueryProductStockBo::new).collect(Collectors.toList());
69
+    }
70
+
71
+    return InvokeResultBuilder.success(PageResultUtil.rebuild(pageResult, results));
72
+  }
73
+
74
+
75
+
41 76
 
42 77
   /**
43 78
    * 查询商品库存

+ 7 - 0
xingyun-sc/src/main/java/com/lframework/xingyun/sc/vo/stock/QueryProductStockVo.java

@@ -36,4 +36,11 @@ public class QueryProductStockVo extends SortPageVo {
36 36
    */
37 37
   @ApiModelProperty("商品品牌ID")
38 38
   private String brandId;
39
+
40
+  /**
41
+   * 商品品牌ID
42
+   */
43
+  @ApiModelProperty("商品数量")
44
+  private Long productCount;
45
+  
39 46
 }

+ 6 - 0
xingyun-sc/src/main/resources/mappers/stock/ProductStockMapper.xml

@@ -60,9 +60,15 @@
60 60
         LEFT JOIN recursion_mapping AS rm ON rm.node_id = g.category_id and rm.node_type = 2
61 61
         <where>
62 62
             <if test="vo != null">
63
+                <if test="vo.productCount != null and vo.productCount >0">
64
+                    AND gs.stock_num <![CDATA[<=]]>  #{vo.productCount}
65
+                </if>
66
+
63 67
                 <if test="vo.scId != null and vo.scId != ''">
64 68
                     AND gs.sc_id = #{vo.scId}
65 69
                 </if>
70
+
71
+
66 72
                 <if test="vo.productCode != null and vo.productCode != ''">
67 73
                     AND g.code = #{vo.productCode}
68 74
                 </if>

+ 48 - 0
xingyun-template/src/main/java/com/lframework/xingyun/template/inner/controller/AuthController.java

@@ -572,4 +572,52 @@ public class AuthController extends DefaultBaseController {
572 572
 
573 573
     StpUtil.getSession().set(SecurityConstants.DATA_PERMISSION_SQL_VAR, dataPermissionVar);
574 574
   }
575
+
576
+
577
+  @ApiOperation("小程序登录")
578
+  @OpenApi
579
+  @PostMapping("/auth/loginwx")
580
+  public InvokeResult<LoginBo> loginwx(@Valid LoginVo vo) {
581
+
582
+    String username = vo.getUsername();
583
+    String password = vo.getPassword();
584
+    String tenantId = null;
585
+    if (TenantUtil.enableTenant()) {
586
+      String[] tmpArr = username.split("@");
587
+      if (tmpArr.length <= 1) {
588
+        throw new DefaultClientException("用户名或密码错误!");
589
+      }
590
+
591
+      tenantId = tmpArr[0];
592
+      username = tmpArr[1];
593
+
594
+      // 检查租户是否存在
595
+      Tenant tenant = tenantService.getById(tenantId);
596
+      if (tenant == null) {
597
+        throw new DefaultClientException("用户名或密码错误!");
598
+      }
599
+
600
+      if (!tenant.getAvailable()) {
601
+        throw new DefaultClientException("用户已停用,无法登录!");
602
+      }
603
+
604
+      TenantContextHolder.setTenantId(tenant.getId());
605
+    }
606
+
607
+    log.info("用户 {} {} 开始登录", tenantId, username);
608
+
609
+   // String sn = vo.getSn();
610
+    //String captcha = vo.getCaptcha();
611
+   //captchaValidator.validate(sn, captcha);
612
+
613
+    this.checkUserLogin(tenantId == null ? null : Integer.valueOf(tenantId), username, password);
614
+
615
+    AbstractUserDetails user = userDetailsService.loadUserByUsername(username);
616
+
617
+    LoginDto dto = this.doLogin(user);
618
+
619
+    this.addAttributesToSession(user);
620
+
621
+    return InvokeResultBuilder.success(new LoginBo(dto));
622
+  }
575 623
 }