zyw hai 1 ano
pai
achega
146d2a5ea9

+ 2 - 0
src/main/java/com/zhaoliangsz/grainsearch/basic/exception/ExceptionDefinition.java

@@ -18,4 +18,6 @@ public class ExceptionDefinition {
             new ServiceExceptionDefinition(400001, "用户名密码错误");
     public static  ServiceExceptionDefinition NOT_YESTERDAY_INVENTORY =
             new ServiceExceptionDefinition(10005, "没有前一天的库存数据");
+    public static  ServiceExceptionDefinition PASSWORD_ERROR=
+            new ServiceExceptionDefinition(10006, "密码错误,提交失败!");
 }

+ 5 - 0
src/main/java/com/zhaoliangsz/grainsearch/domain/entity/TestTable.java

@@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.zhaoliangsz.grainsearch.basic.constants.DateConstants;
+
+import java.beans.Transient;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.Date;
@@ -106,6 +108,9 @@ public class TestTable extends BaseDO<TestTable> {
     @TableField("in_num")
     private Double inNum;
 
+    @TableField(exist = false)
+    private String password;
+
     @TableField("create_by")
     private String createBy;
     @TableField("create_time")

+ 89 - 84
src/main/java/com/zhaoliangsz/grainsearch/service/impl/TestTableServiceImpl.java

@@ -57,108 +57,113 @@ public class TestTableServiceImpl extends ServiceImpl<TestTableMapper, TestTable
     @Override
     @Transactional(rollbackFor = Exception.class)
     public String addTestTable(TestTable addTestTable) throws ServiceException {
-        //查询相同条件是否已添加过
-        TestTable testTable=testTableMapper.selectOne(new QueryWrapper<TestTable>()
-                 .eq("type",addTestTable.getType())
-                 .eq("banci",addTestTable.getBanci())
-                 .eq("banzu",addTestTable.getBanzu())
-                 .eq("date",addTestTable.getDate()));
-        boolean flag;
-        InventoryTable inventoryTable=inventoryTableMapper.selectOne(new QueryWrapper<InventoryTable>()
-                .eq("date",addTestTable.getDate()));
-        //编辑
-        if (testTable!=null){
-            addTestTable.setUpdateTime(new Date());
-            addTestTable.setId(testTable.getId());
-            LocalDate today = addTestTable.getDate();
-            //入库
-            if ("入库".equals(addTestTable.getType())){
-                inventoryTable.setInNum(addTestTable.getInNum());
-                //库存=当天库存减原入库加新入库
-                inventoryTable.setInventory(inventoryTable.getInventory()-testTable.getInNum()+addTestTable.getInNum());
-            }
-            //出库
-            else{
-                //出库量先减原出库量再进行累加
-                inventoryTable.setOutNum(inventoryTable.getOutNum()-testTable.getTotal()+addTestTable.getTotal());
-                //库存=当天库存加原出库减新出库
-                inventoryTable.setInventory(inventoryTable.getInventory()+testTable.getTotal()-addTestTable.getTotal());
-            }
-            inventoryTable.setUpdateTime(new Date());
-            inventoryTableMapper.updateById(inventoryTable);
-            flag= this.updateById(addTestTable);
+        if (!"zlty".equals(addTestTable.getPassword())){
+            throw new ServiceException(ExceptionDefinition.PASSWORD_ERROR);
         }
-        //新增
         else {
-            addTestTable.setCreateTime(new Date());
-            addTestTable.setUpdateTime(new Date());
-            //获取本条数据日期
-            LocalDate today = addTestTable.getDate();
-            //获取前一天日期  查询前一天库存
-            LocalDate yesterday = today.minusDays(1);
-            InventoryTable inventoryTable1=inventoryTableMapper.selectOne(new QueryWrapper<InventoryTable>()
-                    .eq("date",yesterday));
-            //入库
-            if ("入库".equals(addTestTable.getType())){
-                if (inventoryTable!=null){
+            //查询相同条件是否已添加过
+            TestTable testTable=testTableMapper.selectOne(new QueryWrapper<TestTable>()
+                    .eq("type",addTestTable.getType())
+                    .eq("banci",addTestTable.getBanci())
+                    .eq("banzu",addTestTable.getBanzu())
+                    .eq("date",addTestTable.getDate()));
+            boolean flag;
+            InventoryTable inventoryTable=inventoryTableMapper.selectOne(new QueryWrapper<InventoryTable>()
+                    .eq("date",addTestTable.getDate()));
+            //编辑
+            if (testTable!=null){
+                addTestTable.setUpdateTime(new Date());
+                addTestTable.setId(testTable.getId());
+                LocalDate today = addTestTable.getDate();
+                //入库
+                if ("入库".equals(addTestTable.getType())){
                     inventoryTable.setInNum(addTestTable.getInNum());
-                    //库存=当天库存加入库
-                    inventoryTable.setInventory(inventoryTable.getInventory()+addTestTable.getInNum());
-                    inventoryTable.setUpdateTime(new Date());
-                    inventoryTableMapper.updateById(inventoryTable);
+                    //库存=当天库存减原入库加新入库
+                    inventoryTable.setInventory(inventoryTable.getInventory()-testTable.getInNum()+addTestTable.getInNum());
                 }
+                //出库
                 else{
-                    InventoryTable inventoryTable2=new InventoryTable();
-                    inventoryTable2.setCreateTime(new Date());
-                    inventoryTable2.setUpdateTime(new Date());
-                    inventoryTable2.setDate(addTestTable.getDate());
-                    inventoryTable2.setInNum(addTestTable.getInNum());
-                    //库存=前一天库存加入库
-                    if (inventoryTable1!=null){
-                        inventoryTable2.setInventory(inventoryTable1.getInventory()+addTestTable.getInNum());
+                    //出库量先减原出库量再进行累加
+                    inventoryTable.setOutNum(inventoryTable.getOutNum()-testTable.getTotal()+addTestTable.getTotal());
+                    //库存=当天库存加原出库减新出库
+                    inventoryTable.setInventory(inventoryTable.getInventory()+testTable.getTotal()-addTestTable.getTotal());
+                }
+                inventoryTable.setUpdateTime(new Date());
+                inventoryTableMapper.updateById(inventoryTable);
+                flag= this.updateById(addTestTable);
+            }
+            //新增
+            else {
+                addTestTable.setCreateTime(new Date());
+                addTestTable.setUpdateTime(new Date());
+                //获取本条数据日期
+                LocalDate today = addTestTable.getDate();
+                //获取前一天日期  查询前一天库存
+                LocalDate yesterday = today.minusDays(1);
+                InventoryTable inventoryTable1=inventoryTableMapper.selectOne(new QueryWrapper<InventoryTable>()
+                        .eq("date",yesterday));
+                //入库
+                if ("入库".equals(addTestTable.getType())){
+                    if (inventoryTable!=null){
+                        inventoryTable.setInNum(addTestTable.getInNum());
+                        //库存=当天库存加入库
+                        inventoryTable.setInventory(inventoryTable.getInventory()+addTestTable.getInNum());
+                        inventoryTable.setUpdateTime(new Date());
+                        inventoryTableMapper.updateById(inventoryTable);
                     }
                     else{
-                        throw new ServiceException(ExceptionDefinition.NOT_YESTERDAY_INVENTORY);
+                        InventoryTable inventoryTable2=new InventoryTable();
+                        inventoryTable2.setCreateTime(new Date());
+                        inventoryTable2.setUpdateTime(new Date());
+                        inventoryTable2.setDate(addTestTable.getDate());
+                        inventoryTable2.setInNum(addTestTable.getInNum());
+                        //库存=前一天库存加入库
+                        if (inventoryTable1!=null){
+                            inventoryTable2.setInventory(inventoryTable1.getInventory()+addTestTable.getInNum());
+                        }
+                        else{
+                            throw new ServiceException(ExceptionDefinition.NOT_YESTERDAY_INVENTORY);
 
+                        }
+                        inventoryTableMapper.insert(inventoryTable2);
                     }
-                    inventoryTableMapper.insert(inventoryTable2);
-                }
-            }
-            //出库
-            else{
-                if (inventoryTable!=null){
-                    //出库量累加
-                    inventoryTable.setOutNum(inventoryTable.getOutNum()+addTestTable.getTotal());
-                    //库存=当天库存减出库
-                    inventoryTable.setInventory(inventoryTable.getInventory()-addTestTable.getTotal());
-                    inventoryTable.setUpdateTime(new Date());
-                    inventoryTableMapper.updateById(inventoryTable);
                 }
+                //出库
                 else{
-                    InventoryTable inventoryTable2=new InventoryTable();
-                    inventoryTable2.setCreateTime(new Date());
-                    inventoryTable2.setUpdateTime(new Date());
-                    inventoryTable2.setDate(addTestTable.getDate());
-                    inventoryTable2.setOutNum(addTestTable.getTotal());
-                    //库存=前一天库存减出库
-                    if (inventoryTable1!=null){
-                        inventoryTable2.setInventory(inventoryTable1.getInventory()-addTestTable.getTotal());
+                    if (inventoryTable!=null){
+                        //出库量累加
+                        inventoryTable.setOutNum(inventoryTable.getOutNum()+addTestTable.getTotal());
+                        //库存=当天库存减出库
+                        inventoryTable.setInventory(inventoryTable.getInventory()-addTestTable.getTotal());
+                        inventoryTable.setUpdateTime(new Date());
+                        inventoryTableMapper.updateById(inventoryTable);
                     }
                     else{
-                        throw new ServiceException(ExceptionDefinition.NOT_YESTERDAY_INVENTORY);
+                        InventoryTable inventoryTable2=new InventoryTable();
+                        inventoryTable2.setCreateTime(new Date());
+                        inventoryTable2.setUpdateTime(new Date());
+                        inventoryTable2.setDate(addTestTable.getDate());
+                        inventoryTable2.setOutNum(addTestTable.getTotal());
+                        //库存=前一天库存减出库
+                        if (inventoryTable1!=null){
+                            inventoryTable2.setInventory(inventoryTable1.getInventory()-addTestTable.getTotal());
+                        }
+                        else{
+                            throw new ServiceException(ExceptionDefinition.NOT_YESTERDAY_INVENTORY);
 
+                        }
+                        inventoryTableMapper.insert(inventoryTable2);
                     }
-                    inventoryTableMapper.insert(inventoryTable2);
                 }
+                flag= this.save(addTestTable);
             }
-            flag= this.save(addTestTable);
-        }
 
-        if(flag){
-            return "ok";
-        }
-        else{
-            throw new ServiceException(ExceptionDefinition.ADD_DATA_EXCEPTION);
+            if(flag){
+                return "ok";
+            }
+            else{
+                throw new ServiceException(ExceptionDefinition.ADD_DATA_EXCEPTION);
+            }
         }
     }
 

+ 3 - 3
src/main/resources/application-dev.yml

@@ -1,8 +1,8 @@
 spring:
  datasource:
-    url: jdbc:mysql://10.23.250.88:3306/h5?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=Asia/Shanghai
-    username: admin
-    password: 14789632
+    url: jdbc:mysql://10.23.250.220:3306/h5?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=Asia/Shanghai
+    username: root
+    password: Tang@123
     driver-class-name: com.mysql.cj.jdbc.Driver
  data:
    redis:

+ 1 - 1
src/main/resources/application-prod.yml

@@ -2,7 +2,7 @@ spring:
   datasource:
     url: jdbc:mysql://127.0.0.1:3306/zl_global_view?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=Asia/Shanghai
     username: root
-    password: 123456
+    password: Tang@123
     driver-class-name: com.mysql.cj.jdbc.Driver
   data:
     redis:

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

@@ -16,7 +16,7 @@ spring:
       max-request-size: 20MB
 # 端口号
 server:
-  port: 8888
+  port: 18087
 
 flag : web
 # mybatis-plus配置