Browse Source

修改sql语句

huang 4 weeks ago
parent
commit
8461fdf890

+ 54 - 0
docs/new_sql.sql

@@ -116,3 +116,57 @@ CREATE TABLE `apk_version` (
 ALTER TABLE jsh_depot_head
 ADD COLUMN depot_id bigint DEFAULT NULL COMMENT '仓库id',
 ADD COLUMN oper_id bigint DEFAULT NULL COMMENT '操作人';
+
+-- 单据子表  新增创建时间
+ALTER TABLE jsh_depot_item
+ADD COLUMN create_time DATETIME DEFAULT NULL COMMENT '创建时间';
+
+-- 单据主表 修改文件,凭证,价格,数量图片类型
+ALTER TABLE jsh_depot_head
+  MODIFY file_name TEXT,
+  MODIFY voucher_picture TEXT,
+  MODIFY change_amount DECIMAL(24,2),
+  MODIFY back_amount DECIMAL(24,2),
+  MODIFY total_price DECIMAL(24,2),
+  MODIFY discount_money DECIMAL(24,2),
+  MODIFY discount_last_money DECIMAL(24,2),
+  MODIFY other_money DECIMAL(24,2),
+  MODIFY deposit DECIMAL(24,2);
+
+-- 单据子表  修改数量、价格类型
+ALTER TABLE jsh_depot_item
+  MODIFY oper_number DECIMAL(24,0),
+  MODIFY basic_number DECIMAL(24,0),
+  MODIFY unit_price DECIMAL(24,2),
+  MODIFY purchase_unit_price DECIMAL(24,2),
+  MODIFY tax_unit_price DECIMAL(24,2),
+  MODIFY all_price DECIMAL(24,2),
+  MODIFY tax_money DECIMAL(24,2),
+  MODIFY tax_last_money DECIMAL(24,2),
+  MODIFY actual_quantity_in_storage DECIMAL(10,0),
+  MODIFY warehousing_variance DECIMAL(10,0);
+
+-- 商品主表 修改商品图片、重量类型
+ALTER TABLE jsh_material
+  MODIFY img_name TEXT,
+  MODIFY weight DECIMAL(24,2);
+
+-- 商品子表 修改价格,库存类型
+ALTER TABLE jsh_material_extend
+  MODIFY purchase_decimal DECIMAL(24,2),
+  MODIFY commodity_decimal DECIMAL(24,2),
+  MODIFY wholesale_decimal DECIMAL(24,2),
+  MODIFY low_decimal DECIMAL(24,2),
+  MODIFY inventory DECIMAL(10,0);
+
+-- 初始库存表 修改库存类型
+ALTER TABLE jsh_material_initial_stock
+  MODIFY number DECIMAL(24,0),
+  MODIFY low_safe_stock DECIMAL(24,0),
+  MODIFY high_safe_stock DECIMAL(24,0);
+
+-- 当前库存表 修改价格、库存类型
+ALTER TABLE jsh_material_current_stock
+  MODIFY current_number DECIMAL(24,0),
+  MODIFY current_unit_price DECIMAL(24,2);
+

+ 15 - 11
src/main/java/com/jsh/erp/service/impl/DepotHeadServiceImpl.java

@@ -1198,8 +1198,9 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
             Long headId = list.get(0).getId();
             /**入库和出库处理单据子表信息*/
             depotItemService.saveDetials(rows,headId, "add",request);
-            if (!list.get(0).getSubType().equals("其它") || !list.get(0).getSubType().equals("零售"))
-            updateTotalPriceById(list.get(0));
+            if (list.get(0).getSubType().equals("采购") || !list.get(0).getSubType().equals("销售")){
+                updateTotalPriceById(list.get(0));
+            }
         }
         logService.insertLog("单据",
                 new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(depotHead.getNumber()).toString(),
@@ -2045,6 +2046,7 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
             depotItemService.updateCurrentUnitPrice(depotItem);
             //修改商品生产日期
             materialExtendService.update(new UpdateWrapper<MaterialExtend>().set("production_date",materialMap.get(batchNumber).getProductionDate()).eq("id", materialExtend.getId()));
+            //修改订单总额
             updateTotalPriceById(depotHead);
         }
         //修改采购订单状态完成
@@ -2057,16 +2059,18 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
      */
     private void updateTotalPriceById(DepotHead depotHead) throws Exception {
         BigDecimal sum = BigDecimal.ZERO;
-        //获取单据子表
-        List<DepotItem> list = depotItemService.getListByHeaderId(depotHead.getId());
-        for (DepotItem depotItem : list) {
-            sum = sum.add(depotItem.getTaxLastMoney());
-        }
-        BigDecimal totalPrice = sum;
-        if (depotHead.getTotalPrice().compareTo(BigDecimal.ZERO) < 0){
-            totalPrice = totalPrice.negate();
+        if (depotHead.getSubType().equals("采购") || depotHead.getSubType().equals("销售") ){
+            //获取单据子表
+            List<DepotItem> list = depotItemService.getListByHeaderId(depotHead.getId());
+            for (DepotItem depotItem : list) {
+                sum = sum.add(depotItem.getTaxLastMoney());
+            }
+            BigDecimal totalPrice = sum;
+            if (depotHead.getTotalPrice().compareTo(BigDecimal.ZERO) < 0){
+                totalPrice = totalPrice.negate();
+            }
+            update(new UpdateWrapper<DepotHead>().set("total_price",totalPrice).set("change_amount",totalPrice).set("discount_last_money",sum).eq("id",list.get(0).getId()));
         }
-        update(new UpdateWrapper<DepotHead>().set("total_price",totalPrice).set("change_amount",totalPrice).set("discount_last_money",sum).eq("id",list.get(0).getId()));
     }
 
 }

+ 2 - 2
src/main/resources/mapper_xml/DepotItemMapperEx.xml

@@ -322,7 +322,7 @@
         select di.*,m.name MName,m.model MModel,m.color MColor,m.unit_id,m.standard MStandard,m.weight, m.img_name,
         m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,m.enable_serial_number, m.enable_batch_number,
         m.brand, dp1.name DepotName,dp2.name AnotherDepotName, me.purchase_decimal,
-        me.production_date, me.expiry_num, me.supplier_id, me.bar_code, me.batch_number, me.position,s.supplier supplierName,u.name unit_name
+        me.production_date, me.expiry_num, me.supplier_id, me.bar_code, me.batch_number, me.position,s.supplier supplierName,u.name unit_name,me.inventory
         from jsh_depot_item di
         left join jsh_material m on di.material_id=m.id  and ifnull(m.delete_flag,'0') !='1'
         left join jsh_material_extend me on me.id=di.material_extend_id  and ifnull(me.delete_Flag,'0') !='1'
@@ -339,7 +339,7 @@
         select di.*,m.name MName,m.model MModel,m.color MColor,m.unit_id,m.standard MStandard,m.weight, m.img_name,
         m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,m.enable_serial_number, m.enable_batch_number,
         m.brand, dp1.name DepotName,dp2.name AnotherDepotName, me.purchase_decimal,
-        me.production_date, me.expiry_num, me.supplier_id, me.bar_code, me.batch_number, me.position,s.supplier supplierName
+        me.production_date, me.expiry_num, me.supplier_id, me.bar_code, me.batch_number, me.position,s.supplier supplierName,me.inventory
         from jsh_depot_item di
         left join jsh_material m on di.material_id=m.id  and ifnull(m.delete_flag,'0') !='1'
         left join jsh_material_extend me on me.id=di.material_extend_id  and ifnull(me.delete_Flag,'0') !='1'