85 Commits 950100bd14 ... ccdbbc436e

Author SHA1 Message Date
  huang ccdbbc436e Merge branch 'master' of http://121.40.253.172:3000/pengyue/jsh_erp into master_huangjunjie 11 months ago
  huang 6be3284e4a 仓库删除限制,商品库存修改,pda版本更新接口放开 11 months ago
  13660505945 138b68d0f3 Merge remote-tracking branch 'origin/dev_ml' 11 months ago
  13660505945 3f6e97a0ea Merge remote-tracking branch 'origin/master_huangjunjie' 11 months ago
  maliang 01d6bf5bfb fix:商品信息库存数量 11 months ago
  liushuang 9ffaa58711 Merge branch 'master_liushuang' of pengyue/jsh_erp into master 11 months ago
  ms-blue aa5d2f4c5a 角色管理-分配功能回显问题 11 months ago
  huang 11dcf62a78 商品库存修改 11 months ago
  huang 2fe7d8d8c5 Merge branch 'master' of http://121.40.253.172:3000/pengyue/jsh_erp into master_huangjunjie 11 months ago
  huang 0616ea42f9 pda库存修改 11 months ago
  廖泽勇 59e2f94fc7 Merge branch 'master' of http://121.40.253.172:3000/pengyue/jsh_erp into master_liaozeyong 11 months ago
  廖泽勇 8db63574a6 bug调整 11 months ago
  13660505945 1fdc2db4a7 Merge remote-tracking branch 'origin/dev_ml' 11 months ago
  maliang ae31062341 fix:商品信息模版、列设置 11 months ago
  huang 96007c7c5e 订单实际入库数量为空处理 11 months ago
  huang e9c0f10022 Merge branch 'master' of http://121.40.253.172:3000/pengyue/jsh_erp into master_huangjunjie 11 months ago
  huang ec513b3968 pda订单数量0bug修改,付款金额由实际入库数量计算 11 months ago
  huang 37d68d748b Merge branch 'xq' of http://121.40.253.172:3000/pengyue/jsh_erp into master_huangjunjie 11 months ago
  13660505945 3baa0de39a Merge remote-tracking branch 'origin/xq' 11 months ago
  13660505945 a8554487c3 Merge remote-tracking branch 'origin/xq' 11 months ago
  13660505945 fe17ec51b5 Merge remote-tracking branch 'origin/master_huangjunjie' 11 months ago
  huang e6f6b2c3d9 订单查看图片问题修复 11 months ago
  13660505945 91b7130776 Merge remote-tracking branch 'origin/xq' 11 months ago
  13660505945 73435c0f4e Merge remote-tracking branch 'origin/master_huangjunjie' 11 months ago
  huang db7155e1bd Merge branch 'master_liaozeyong' of http://121.40.253.172:3000/pengyue/jsh_erp into master_huangjunjie 11 months ago
  13660505945 cd8f2b5bec Merge remote-tracking branch 'origin/master_huangjunjie' 11 months ago
  huang 9cbb6e29b5 Merge branch 'xq' of http://121.40.253.172:3000/pengyue/jsh_erp into master_huangjunjie 11 months ago
  huang 8e0b34b315 入口时间bug修改 11 months ago
  廖泽勇 25ed97aa10 bug调整 11 months ago
  廖泽勇 effe59ae30 新增订单bug调整 11 months ago
  13660505945 6b684e2332 Merge remote-tracking branch 'origin/master_liushuang' 11 months ago
  13660505945 c4f99f6cfd Merge remote-tracking branch 'origin/master_liaozeyong' 11 months ago
  huang d990d4829a Merge branch 'master' of http://121.40.253.172:3000/pengyue/jsh_erp into master_huangjunjie 11 months ago
  huang 1a3cdde780 商品编辑子商品空白bug修改 11 months ago
  ms-blue a009f8cefc Merge remote-tracking branch 'origin/xq' into master_liushuang 11 months ago
  廖泽勇 3d62371e84 字段调整 11 months ago
  廖泽勇 79c1cc83ae Merge branch 'master' of http://121.40.253.172:3000/pengyue/jsh_erp into master_liaozeyong 11 months ago
  liushuang 578a7b0608 Merge branch 'master_liushuang' of pengyue/jsh_erp into master 11 months ago
  廖泽勇 74040c50f0 Merge branch 'master_huangjunjie' of http://121.40.253.172:3000/pengyue/jsh_erp into master_liaozeyong 11 months ago
  ms-blue 39ebcef6ab 配置文件,新增配置文件是否同步集采商城 11 months ago
  廖泽勇 d06cb17b76 仓库下拉框调整 11 months ago
  13660505945 998708ea29 Merge remote-tracking branch 'origin/master_liushuang' 11 months ago
  13660505945 ec12e87232 Merge remote-tracking branch 'origin/master_huangjunjie' 11 months ago
  ms-blue 9fe783a6c6 新增接口 检查手机号码和类型是否存在 11 months ago
  huang dda459c901 修改订单入库时间问题 11 months ago
  liushuang 009be5c861 Merge branch 'master_liushuang' of pengyue/jsh_erp into master 11 months ago
  ms-blue 82b3a4d394 11 11 months ago
  ms-blue e4cce594e5 配置文件更新 11 months ago
  13660505945 54c28d0b01 Merge remote-tracking branch 'origin/master_huangjunjie' 11 months ago
  13660505945 50db7eebf0 Merge remote-tracking branch 'origin/master_liaozeyong' 11 months ago
  廖泽勇 4b59e5796e 排序调整 11 months ago
  廖泽勇 04534bcec4 Merge branch 'master' of http://121.40.253.172:3000/pengyue/jsh_erp into master_liaozeyong 11 months ago
  廖泽勇 96ab2c6da9 pda图片处理 11 months ago
  huang 7a2d28eaa8 Merge branch 'master' of http://121.40.253.172:3000/pengyue/jsh_erp into master_huangjunjie 11 months ago
  huang 6b10fac5b9 pda存货查询,pc端设置菜单bug修改 11 months ago
  13660505945 ea49fdebac Merge remote-tracking branch 'origin/xq' 11 months ago
  13660505945 1c0ef9dfb9 Merge remote-tracking branch 'origin/master_liaozeyong' 11 months ago
  13660505945 8f002c84e2 Merge remote-tracking branch 'origin/master_liushuang' 11 months ago
  ms-blue b9ffd05859 解决冲突 11 months ago
  13660505945 7d0519fdae Merge remote-tracking branch 'origin/master_liushuang' 11 months ago
  廖泽勇 d514a35b1a pda 盘点筛选,盘点详情修改 11 months ago
  ms-blue 4fdab7ede6 Merge remote-tracking branch 'origin/master' into master_liushuang 11 months ago
  13660505945 7417437c21 Merge remote-tracking branch 'origin/master_liaozeyong' 11 months ago
  廖泽勇 e03131db16 盘点任务筛选bug调整 11 months ago
  廖泽勇 8fb3439c8e Merge branch 'master_huangjunjie' of http://121.40.253.172:3000/pengyue/jsh_erp into master_liaozeyong 11 months ago
  廖泽勇 3aed9da6e9 盘点详情-任务明细bug调整 11 months ago
  huang 2a0707c0e5 Merge branch 'master' of http://121.40.253.172:3000/pengyue/jsh_erp into master_huangjunjie 11 months ago
  huang dde4cc03eb Merge branch 'master_liaozeyong' of http://121.40.253.172:3000/pengyue/jsh_erp into master_huangjunjie 11 months ago
  huang 2e3a4db5c2 修改库存,pda库存查询 11 months ago
  廖泽勇 b96451a696 版本更新添加 11 months ago
  ms-blue 1f10f29de4 Merge remote-tracking branch 'origin/xq' into master_liushuang 11 months ago
  ms-blue 65275ab780 集采订单同步销售订单、同步库存、同步销售价格 11 months ago
  13660505945 849e44df28 Merge remote-tracking branch 'origin/xq' 11 months ago
  13660505945 5bdb86ca39 Merge remote-tracking branch 'origin/xq' 11 months ago
  ms-blue 5b8b3b915a 集采订单同步销售订单、同步库存、同步销售价格 11 months ago
  ms-blue ee599ac7b6 集采订单同步销售订单、同步库存、同步销售价格 11 months ago
  13660505945 fd1ab012cb Merge remote-tracking branch 'origin/xq' 11 months ago
  huang c8f14228c1 Merge branch 'master' of http://121.40.253.172:3000/pengyue/jsh_erp into master_huangjunjie 11 months ago
  huang a287820b51 pda库存查询bug修改 11 months ago
  huang bd0c8d6838 Merge branch 'master_liaozeyong' of http://121.40.253.172:3000/pengyue/jsh_erp into master_huangjunjie 11 months ago
  huang 086f5091c0 pda订单提交,修改库存 11 months ago
  廖泽勇 b7f510d53a Merge branch 'master_huangjunjie' of http://121.40.253.172:3000/pengyue/jsh_erp into master_liaozeyong 11 months ago
  廖泽勇 1ddffebafd 后台生成二维码去除 11 months ago
  廖泽勇 b58bee9da4 盘点接口调整 11 months ago
  廖泽勇 d40030de13 盘点接口 11 months ago
100 changed files with 2802 additions and 918 deletions
  1. 34 1
      docs/new_sql.sql
  2. BIN
      jshERP-web/public/doc/goods_template.xls
  3. 2 2
      jshERP-web/src/views/bill/modules/AssembleModal.vue
  4. 2 2
      jshERP-web/src/views/bill/modules/DisassembleModal.vue
  5. 2 2
      jshERP-web/src/views/bill/modules/SaleOrderModal.vue
  6. 3 3
      jshERP-web/src/views/material/MaterialList.vue
  7. 5 4
      jshERP-web/src/views/material/modules/MaterialModal.vue
  8. 1 1
      jshERP-web/src/views/system/UserList.vue
  9. 3 3
      jshERP-web/src/views/system/modules/RoleFunctionModal.vue
  10. 5 0
      src/main/java/com/jsh/erp/controller/DepotController.java
  11. 1 0
      src/main/java/com/jsh/erp/controller/DepotItemController.java
  12. 1 0
      src/main/java/com/jsh/erp/controller/MaterialCategoryController.java
  13. 1 0
      src/main/java/com/jsh/erp/controller/MaterialController.java
  14. 2 1
      src/main/java/com/jsh/erp/controller/MaterialExtendController.java
  15. 11 0
      src/main/java/com/jsh/erp/controller/OpenController.java
  16. 16 0
      src/main/java/com/jsh/erp/controller/SupplierController.java
  17. 4 2
      src/main/java/com/jsh/erp/controller/SystemConfigController.java
  18. 50 0
      src/main/java/com/jsh/erp/controller/apkVersion/apkVersionController.java
  19. 180 17
      src/main/java/com/jsh/erp/controller/pda/PdaController.java
  20. 65 9
      src/main/java/com/jsh/erp/controller/stocktaking/StocktakingController.java
  21. 30 0
      src/main/java/com/jsh/erp/datasource/dto/TaskStocktakingItemQueryDTO.java
  22. 24 0
      src/main/java/com/jsh/erp/datasource/dto/TaskStocktakingQueryDTO.java
  23. 29 0
      src/main/java/com/jsh/erp/datasource/entities/ApkVersion.java
  24. 14 0
      src/main/java/com/jsh/erp/datasource/entities/DepotHead.java
  25. 5 1
      src/main/java/com/jsh/erp/datasource/entities/DepotItem.java
  26. 2 0
      src/main/java/com/jsh/erp/datasource/entities/DepotItemVo4WithInfoEx.java
  27. 43 0
      src/main/java/com/jsh/erp/datasource/entities/InventoryLog.java
  28. 2 0
      src/main/java/com/jsh/erp/datasource/entities/MaterialCategory.java
  29. 2 0
      src/main/java/com/jsh/erp/datasource/entities/MaterialCurrentStock.java
  30. 5 0
      src/main/java/com/jsh/erp/datasource/entities/MaterialExtend.java
  31. 5 5
      src/main/java/com/jsh/erp/datasource/entities/MaterialVo4Unit.java
  32. 2 2
      src/main/java/com/jsh/erp/datasource/entities/TaskStocktaking.java
  33. 3 0
      src/main/java/com/jsh/erp/datasource/entities/TaskStocktakingItem.java
  34. 9 0
      src/main/java/com/jsh/erp/datasource/mappers/ApkVersionMapper.java
  35. 7 0
      src/main/java/com/jsh/erp/datasource/mappers/DepotHeadMapper.java
  36. 1 1
      src/main/java/com/jsh/erp/datasource/mappers/DepotItemMapper.java
  37. 10 1
      src/main/java/com/jsh/erp/datasource/mappers/DepotMapper.java
  38. 9 0
      src/main/java/com/jsh/erp/datasource/mappers/InventoryLogMapper.java
  39. 2 1
      src/main/java/com/jsh/erp/datasource/mappers/MaterialCategoryMapper.java
  40. 3 0
      src/main/java/com/jsh/erp/datasource/mappers/MaterialCurrentStockMapperEx.java
  41. 2 0
      src/main/java/com/jsh/erp/datasource/mappers/MaterialExtendMapper.java
  42. 7 0
      src/main/java/com/jsh/erp/datasource/mappers/MaterialExtendMapperEx.java
  43. 9 0
      src/main/java/com/jsh/erp/datasource/mappers/MaterialMapperEx.java
  44. 7 2
      src/main/java/com/jsh/erp/datasource/mappers/TaskStocktakingItemMapper.java
  45. 2 1
      src/main/java/com/jsh/erp/datasource/mappers/TaskStocktakingMapper.java
  46. 30 0
      src/main/java/com/jsh/erp/datasource/pda/dto/PDAInventoryDTO.java
  47. 9 0
      src/main/java/com/jsh/erp/datasource/pda/dto/PDATaskStocktakingDTO.java
  48. 31 0
      src/main/java/com/jsh/erp/datasource/pda/dto/PDATaskStocktakingItemDTO.java
  49. 4 0
      src/main/java/com/jsh/erp/datasource/pda/vo/PDADepotHeadVO.java
  50. 9 0
      src/main/java/com/jsh/erp/datasource/pda/vo/PDADepotItemVO.java
  51. 14 0
      src/main/java/com/jsh/erp/datasource/pda/vo/PDATaskStocktakingItemVO.java
  52. 7 1
      src/main/java/com/jsh/erp/datasource/pda/vo/PDATaskStocktakingVO.java
  53. 30 0
      src/main/java/com/jsh/erp/datasource/pda/vo/PDATypeTree.java
  54. 143 0
      src/main/java/com/jsh/erp/datasource/vo/MaterialCurrentStock4SystemSku.java
  55. 16 0
      src/main/java/com/jsh/erp/datasource/vo/MaterialExcelVo.java
  56. 2 0
      src/main/java/com/jsh/erp/datasource/vo/MaterialExtendVo4List.java
  57. 24 0
      src/main/java/com/jsh/erp/datasource/vo/TaskStocktakingItemVO.java
  58. 3 0
      src/main/java/com/jsh/erp/datasource/vo/TaskStocktakingVO.java
  59. 4 3
      src/main/java/com/jsh/erp/filter/LogCostFilter.java
  60. 8 0
      src/main/java/com/jsh/erp/service/ApkVersionService.java
  61. 7 0
      src/main/java/com/jsh/erp/service/DepotHeadService.java
  62. 5 0
      src/main/java/com/jsh/erp/service/DepotItemService.java
  63. 36 334
      src/main/java/com/jsh/erp/service/DepotService.java
  64. 8 0
      src/main/java/com/jsh/erp/service/InventoryLogService.java
  65. 28 266
      src/main/java/com/jsh/erp/service/MaterialCategoryService.java
  66. 9 0
      src/main/java/com/jsh/erp/service/MaterialExtendService.java
  67. 27 1
      src/main/java/com/jsh/erp/service/MaterialService.java
  68. 2 0
      src/main/java/com/jsh/erp/service/SupplierService.java
  69. 139 4
      src/main/java/com/jsh/erp/service/SyncTescoSystemService.java
  70. 5 0
      src/main/java/com/jsh/erp/service/TaskStocktakingItemService.java
  71. 7 4
      src/main/java/com/jsh/erp/service/TaskStocktakingService.java
  72. 1 0
      src/main/java/com/jsh/erp/service/UserBusinessService.java
  73. 17 0
      src/main/java/com/jsh/erp/service/impl/ApkVersionServiceImpl.java
  74. 70 3
      src/main/java/com/jsh/erp/service/impl/DepotHeadServiceImpl.java
  75. 89 24
      src/main/java/com/jsh/erp/service/impl/DepotItemServiceImpl.java
  76. 407 0
      src/main/java/com/jsh/erp/service/impl/DepotServiceImpl.java
  77. 12 0
      src/main/java/com/jsh/erp/service/impl/InventoryLogServiceImpl.java
  78. 316 0
      src/main/java/com/jsh/erp/service/impl/MaterialCategoryServiceImpl.java
  79. 36 14
      src/main/java/com/jsh/erp/service/impl/MaterialExtendServiceImpl.java
  80. 169 128
      src/main/java/com/jsh/erp/service/impl/MaterialServiceImpl.java
  81. 14 0
      src/main/java/com/jsh/erp/service/impl/SupplierServiceImpl.java
  82. 14 0
      src/main/java/com/jsh/erp/service/impl/TaskStocktakingItemServiceImpl.java
  83. 38 22
      src/main/java/com/jsh/erp/service/impl/TaskStocktakingServiceImpl.java
  84. 31 0
      src/main/java/com/jsh/erp/utils/FileUtils.java
  85. 4 0
      src/main/resources/application-dev.yml
  86. 5 0
      src/main/resources/application-pro.yml
  87. 5 0
      src/main/resources/application-test.yml
  88. 80 11
      src/main/resources/mapper_xml/DepotHeadMapper.xml
  89. 19 6
      src/main/resources/mapper_xml/DepotItemMapper.xml
  90. 2 1
      src/main/resources/mapper_xml/DepotItemMapperEx.xml
  91. 10 0
      src/main/resources/mapper_xml/DepotMapper.xml
  92. 5 0
      src/main/resources/mapper_xml/InventoryLogMapper.xml
  93. 5 6
      src/main/resources/mapper_xml/MaterialCategoryMapper.xml
  94. 3 1
      src/main/resources/mapper_xml/MaterialCategoryMapperEx.xml
  95. 20 0
      src/main/resources/mapper_xml/MaterialCurrentStockMapperEx.xml
  96. 4 3
      src/main/resources/mapper_xml/MaterialExtendMapper.xml
  97. 10 0
      src/main/resources/mapper_xml/MaterialExtendMapperEx.xml
  98. 64 2
      src/main/resources/mapper_xml/MaterialMapperEx.xml
  99. 101 18
      src/main/resources/mapper_xml/TaskStocktakingItemMapper.xml
  100. 22 5
      src/main/resources/mapper_xml/TaskStocktakingMapper.xml

+ 34 - 1
docs/new_sql.sql

@@ -57,10 +57,13 @@ CREATE TABLE `task_stocktaking` (
     `task_type` varchar(255) DEFAULT NULL COMMENT '任务类型',
     `depot_id` bigint DEFAULT NULL COMMENT '仓库ID',
     `number` varchar(255) DEFAULT NULL COMMENT '任务单号',
+    `category_count` int DEFAULT NULL COMMENT '种类数',
     `material_count` int DEFAULT NULL COMMENT '商品数',
     `task_status` int DEFAULT NULL COMMENT '任务状态',
     `position_range` varchar(255) DEFAULT NULL COMMENT '库位范围',
     `delete_flag` tinyint DEFAULT NULL COMMENT '删除标志(0:否,1是)',
+    `oper_time` datetime DEFAULT NULL COMMENT '盘点时间',
+    `oper_by` bigint DEFAULT NULL COMMENT '盘点人',
     PRIMARY KEY (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='盘点任务表';
 
@@ -78,8 +81,38 @@ CREATE TABLE `task_stocktaking_item` (
     `new_position` varchar(255) DEFAULT NULL COMMENT '新仓位货架',
     `new_inventory` decimal(24,6) DEFAULT NULL COMMENT '新库存数',
     `difference_count` int DEFAULT NULL COMMENT '差异数量',
-    `difference_reasion` varchar(255) DEFAULT NULL COMMENT '差异原因',
+    `difference_reason` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT '差异原因',
     `delete_flag` varchar(1) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT '0' COMMENT '删除标记,0未删除,1删除',
     `oper_time` datetime DEFAULT NULL COMMENT '操作时间',
+    `status` int DEFAULT '1' COMMENT '盘点状态(1.未盘,2.盘盈,3.盘亏 4.无差异)',
     PRIMARY KEY (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='盘点任务关联商品表';
+
+-- 库存修改日志表
+DROP TABLE IF EXISTS `jsh_inventory_log`;
+CREATE TABLE `jsh_inventory_log` (
+  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
+  `type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '商品修改' COMMENT '操作类型',
+  `item_id` bigint DEFAULT NULL COMMENT '单据、盘点子表id',
+  `material_id` bigint DEFAULT NULL COMMENT '商品id',
+  `material_extend_id` bigint DEFAULT NULL COMMENT '商品子表id',
+  `original_stock` int DEFAULT NULL COMMENT '原始库存',
+  `current_stock` int DEFAULT NULL COMMENT '当前库存',
+  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
+  `update_user` bigint DEFAULT NULL COMMENT '更新用户',
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='库存修改日志表';
+
+CREATE TABLE `apk_version` (
+    `id` bigint NOT NULL COMMENT '主键ID',
+    `url` varchar(255) DEFAULT NULL COMMENT '下载地址',
+    `version` varchar(255) DEFAULT NULL COMMENT '版本号',
+    `name` varchar(255) DEFAULT NULL COMMENT '名称',
+    `create_time` datetime DEFAULT NULL COMMENT '创建时间',
+    `delete_flag` tinyint DEFAULT NULL COMMENT '是否删除',
+    PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
+
+ALTER TABLE jsh_depot_head
+ADD COLUMN depot_id bigint DEFAULT NULL COMMENT '仓库id',
+ADD COLUMN oper_id bigint DEFAULT NULL COMMENT '操作人';

BIN
jshERP-web/public/doc/goods_template.xls


+ 2 - 2
jshERP-web/src/views/bill/modules/AssembleModal.vue

@@ -171,8 +171,8 @@ export default {
             validateRules: [{ required: true, message: '${title}不能为空' }],
           },
           {
-            title: '条码',
-            key: 'barCode',
+            title: '批次号',
+            key: 'batchNumber',
             width: '12%',
             type: FormTypes.popupJsh,
             kind: 'material',

+ 2 - 2
jshERP-web/src/views/bill/modules/DisassembleModal.vue

@@ -171,8 +171,8 @@ export default {
             validateRules: [{ required: true, message: '${title}不能为空' }],
           },
           {
-            title: '条码',
-            key: 'barCode',
+            title: '批次号',
+            key: 'batchNumber',
             width: '12%',
             type: FormTypes.popupJsh,
             kind: 'material',

+ 2 - 2
jshERP-web/src/views/bill/modules/SaleOrderModal.vue

@@ -425,8 +425,8 @@ export default {
           { title: '序列号', key: 'snList', width: '12%', type: FormTypes.popupJsh, kind: 'sn', multi: true },
           { title: '有效期', key: 'expirationDate', width: '7%', type: FormTypes.input, readonly: true },
           { title: '多属性', key: 'sku', width: '9%', type: FormTypes.normal },
-          { title: '原数量', key: 'preNumber', width: '4%', type: FormTypes.normal },
-          { title: '已出库', key: 'finishNumber', width: '4%', type: FormTypes.normal },
+          // { title: '原数量', key: 'preNumber', width: '4%', type: FormTypes.normal },
+          // { title: '已出库', key: 'finishNumber', width: '4%', type: FormTypes.normal },
           {
             title: '出库数量',
             key: 'operNumber',

+ 3 - 3
jshERP-web/src/views/material/MaterialList.vue

@@ -367,8 +367,8 @@ export default {
           },
         },
         { title: '基础重量', dataIndex: 'weight', width: 80 },
-        { title: '保质期', dataIndex: 'expiryNum', width: 60 },
-        { title: '制造商', dataIndex: 'mfrs', width: 120, ellipsis: true },
+        // { title: '保质期', dataIndex: 'expiryNum', width: 60 },
+        // { title: '制造商', dataIndex: 'mfrs', width: 120, ellipsis: true },
         {
           title: '初始库存',
           dataIndex: 'initialStock',
@@ -380,7 +380,7 @@ export default {
         { title: '零售价', dataIndex: 'commodityDecimal', width: 80 },
         { title: '销售价', dataIndex: 'wholesaleDecimal', width: 80 },
         { title: '最低售价', dataIndex: 'lowDecimal', width: 80 },
-        { title: '仓位货架', dataIndex: 'position', width: 80 },
+        // { title: '仓位货架', dataIndex: 'position', width: 80 },
         { title: '备注', dataIndex: 'remark', width: 80 },
         {
           title: '状态',

+ 5 - 4
jshERP-web/src/views/material/modules/MaterialModal.vue

@@ -540,8 +540,8 @@
               :actionButton="false"
             >
               <template #buttonAfter>
-                <a-button style="margin: 0px 0px 8px 0px" @click="batchSetStock('initStock')">期初库存-批量</a-button>
-                <a-button style="margin-left: 8px" @click="batchSetStock('lowSafeStock')">最低安全库存-批量</a-button>
+                <!-- <a-button style="margin: 0px 0px 8px 0px" @click="batchSetStock('initStock')">期初库存-批量</a-button> -->
+                <a-button style="margin: 0px 0px 8px 0px" @click="batchSetStock('lowSafeStock')">最低安全库存-批量</a-button>
                 <a-button style="margin-left: 8px" @click="batchSetStock('highSafeStock')">最高安全库存-批量</a-button>
               </template>
             </j-editable-table>
@@ -811,11 +811,12 @@ export default {
             type: FormTypes.normal,
           },
           {
-            title: '期初库存数量',
-            key: 'initStock',
+            title: '库存数量',
+            key: 'currentStock',
             width: '15%',
             type: FormTypes.inputNumber,
             defaultValue: '',
+            disabled: true,
             placeholder: '请输入${title}',
           },
           {

+ 1 - 1
jshERP-web/src/views/system/UserList.vue

@@ -54,7 +54,7 @@
                 >分配客户</a
               >
               <a-divider v-if="btnEnableList.indexOf(1) > -1 && depotFlag === '1'" type="vertical" />
-              <a v-if="btnEnableList.indexOf(1) > -1 && customerFlag === '1'" @click="btnSetSupplier(record)"
+              <a v-if="btnEnableList.indexOf(1) > -1 && customerFlag === '1' && record.roleName === '供应商'" @click="btnSetSupplier(record)"
                 >分配供应商</a
               >
               <a-divider v-if="btnEnableList.indexOf(1) > -1 && customerFlag === '1'" type="vertical" />

+ 3 - 3
jshERP-web/src/views/system/modules/RoleFunctionModal.vue

@@ -171,10 +171,10 @@ export default {
     },
     setThisExpandedKeys(node) {
       if (node.checked == true) {
-        this.checkedKeys.push(Number(node.key))
+        this.checkedKeys.push(node.key)
       }
       if (node.children && node.children.length > 0) {
-        this.iExpandedKeys.push(Number(node.key))
+        this.iExpandedKeys.push(node.key)
         for (let a = 0; a < node.children.length; a++) {
           this.setThisExpandedKeys(node.children[a])
         }
@@ -182,7 +182,7 @@ export default {
     },
     getAllKeys(node) {
       // console.log('node',node);
-      this.allTreeKeys.push(Number(node.key))
+      this.allTreeKeys.push(node.key)
       if (node.children && node.children.length > 0) {
         for (let a = 0; a < node.children.length; a++) {
           this.getAllKeys(node.children[a])

+ 5 - 0
src/main/java/com/jsh/erp/controller/DepotController.java

@@ -8,6 +8,7 @@ import com.jsh.erp.datasource.entities.Depot;
 import com.jsh.erp.datasource.entities.DepotEx;
 import com.jsh.erp.datasource.entities.MaterialInitialStock;
 import com.jsh.erp.service.DepotService;
+import com.jsh.erp.service.MaterialExtendService;
 import com.jsh.erp.service.MaterialService;
 import com.jsh.erp.service.UserBusinessService;
 import com.jsh.erp.utils.BaseResponseInfo;
@@ -49,6 +50,9 @@ public class DepotController extends BaseController {
     @Resource
     private MaterialService materialService;
 
+    @Resource
+    private MaterialExtendService materialExtendService;
+
     @GetMapping(value = "/info")
     @ApiOperation(value = "根据id获取信息")
     public String getList(@RequestParam("id") Long id,
@@ -93,6 +97,7 @@ public class DepotController extends BaseController {
     @DeleteMapping(value = "/delete")
     @ApiOperation(value = "删除")
     public String deleteResource(@RequestParam("id") Long id, HttpServletRequest request)throws Exception {
+
         Map<String, Object> objectMap = new HashMap<>();
         int delete = depotService.deleteDepot(id, request);
         return returnStr(objectMap, delete);

+ 1 - 0
src/main/java/com/jsh/erp/controller/DepotItemController.java

@@ -281,6 +281,7 @@ public class DepotItemController {
                     item.put("supplierName",diEx.getSupplierName());
                     item.put("unitId",diEx.getUnitId());
                     item.put("unitList",diEx.getUnitId() == null ? null : unitService.getUnitListByID(diEx.getUnitId()));
+                    item.put("unitName", diEx.getUnitName());
                     item.put("actualQuantityInStorage",diEx.getActualQuantityInStorage());
                     item.put("warehousingVariance",diEx.getWarehousingVariance());
                     item.put("reasonOfDifference",diEx.getReasonOfDifference());

+ 1 - 0
src/main/java/com/jsh/erp/controller/MaterialCategoryController.java

@@ -8,6 +8,7 @@ import com.jsh.erp.base.TableDataInfo;
 import com.jsh.erp.datasource.entities.MaterialCategory;
 import com.jsh.erp.datasource.vo.TreeNode;
 import com.jsh.erp.service.MaterialCategoryService;
+
 import com.jsh.erp.utils.BaseResponseInfo;
 import com.jsh.erp.utils.Constants;
 import com.jsh.erp.utils.ErpInfo;

+ 1 - 0
src/main/java/com/jsh/erp/controller/MaterialController.java

@@ -365,6 +365,7 @@ public class MaterialController extends BaseController {
                     item.put("depotId",material.getDepotId());
                     item.put("depotName",material.getDepotName());
                     item.put("unitId",material.getUnitId());
+                    item.put("inventory",material.getInventory());
                     BigDecimal stock;
                     if(StringUtil.isNotEmpty(material.getSku())){
                         stock = depotItemService.getSkuStockByParam(depotId,material.getMeId(),null,null);

+ 2 - 1
src/main/java/com/jsh/erp/controller/MaterialExtendController.java

@@ -6,6 +6,7 @@ import com.jsh.erp.datasource.entities.MaterialExtend;
 import com.jsh.erp.datasource.vo.MaterialExtendVo4List;
 import com.jsh.erp.service.MaterialExtendService;
 import com.jsh.erp.utils.BaseResponseInfo;
+import com.jsh.erp.utils.DateUtils;
 import com.jsh.erp.utils.ErpInfo;
 import com.jsh.erp.utils.StringUtil;
 import io.swagger.annotations.Api;
@@ -108,7 +109,7 @@ public class MaterialExtendController {
                     item.put("commodityDecimal", md.getCommodityDecimal());
                     item.put("wholesaleDecimal", md.getWholesaleDecimal());
                     item.put("lowDecimal", md.getLowDecimal());
-                    item.put("productionDate",md.getProductionDate());
+                    item.put("productionDate", md.getProductionDate() == null ? "": DateUtils.dateTime(md.getProductionDate()));
                     item.put("expiryNum",md.getExpiryNum());
                     item.put("supplierId",md.getSupplierId());
                     item.put("barCode",md.getBarCode());

+ 11 - 0
src/main/java/com/jsh/erp/controller/OpenController.java

@@ -51,6 +51,17 @@ public class OpenController {
         return syncTescoSystemService.syncOrder(param);
     }
 
+    @ApiOperation(value = "同步集采库存")
+    @PostMapping(value = "/sync-tesco-stock")
+    public String sycnTescoStock(@RequestBody List<Long> mIdList){
+        return syncTescoSystemService.sycnTescoStock(mIdList);
+    }
+
+    @PostMapping(value = "/sync-tesco-saleprice")
+    public String sycnTescoSalePrice(@RequestBody List<Long> mIdList){
+        return syncTescoSystemService.sycnTescoSalePrice(mIdList);
+    }
+
 
 
 }

+ 16 - 0
src/main/java/com/jsh/erp/controller/SupplierController.java

@@ -137,6 +137,22 @@ public class SupplierController extends BaseController {
         return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
     }
 
+    @GetMapping(value = "/checkIsTelephoneAndTypeExist")
+    @ApiOperation(value = "检查手机号码和类型是否存在")
+    public String checkIsTelephoneAndTypeExist(@RequestParam Long id,
+                                          @RequestParam(value ="telephone", required = false) String telephone,
+                                          @RequestParam(value ="type") String type,
+                                          HttpServletRequest request){
+        Map<String, Object> objectMap = new HashMap<>();
+        int exist = supplierService.checkIsTelephoneAndTypeExist(id, telephone, type);
+        if (exist > 0) {
+            objectMap.put("status", true);
+        } else {
+            objectMap.put("status", false);
+        }
+        return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
+    }
+
     /**
      * 查找客户信息-下拉框
      * @param request

+ 4 - 2
src/main/java/com/jsh/erp/controller/SystemConfigController.java

@@ -230,6 +230,7 @@ public class SystemConfigController extends BaseController {
     public void view(HttpServletRequest request, HttpServletResponse response) {
         // ISO-8859-1 ==> UTF-8 进行编码转换
         String imgPath = extractPathFromPattern(request);
+        imgPath = imgPath.replace("https:/","https://");
         if(StringUtil.isEmpty(imgPath) || imgPath=="null"){
             return;
         }
@@ -246,7 +247,8 @@ public class SystemConfigController extends BaseController {
                 fileUrl = systemConfigService.getFileUrlLocal(imgPath);
                 inputStream = new BufferedInputStream(new FileInputStream(fileUrl));
             } else if(fileUploadType == 2) {
-                fileUrl = systemConfigService.getFileUrlAliOss(imgPath);
+                //fileUrl = systemConfigService.getFileUrlAliOss(imgPath);
+                fileUrl = imgPath;
                 URL url = new URL(fileUrl);
                 HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                 conn.setRequestMethod("GET");
@@ -365,6 +367,6 @@ public class SystemConfigController extends BaseController {
     private static String extractPathFromPattern(final HttpServletRequest request) {
         String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
         String bestMatchPattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
-        return new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path);
+        return new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path).substring(6);
     }
 }

+ 50 - 0
src/main/java/com/jsh/erp/controller/apkVersion/apkVersionController.java

@@ -0,0 +1,50 @@
+package com.jsh.erp.controller.apkVersion;
+
+
+import com.jsh.erp.base.AjaxResult;
+import com.jsh.erp.base.BaseController;
+import com.jsh.erp.base.TableDataInfo;
+import com.jsh.erp.datasource.dto.TaskStocktakingDTO;
+import com.jsh.erp.datasource.dto.TaskStocktakingQueryDTO;
+import com.jsh.erp.datasource.entities.ApkVersion;
+import com.jsh.erp.datasource.vo.TaskStocktakingVO;
+import com.jsh.erp.service.ApkVersionService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.List;
+
+@RestController
+@RequestMapping(value = "/apkVersion")
+@Api(tags = {"apk版本管理接口"})
+public class apkVersionController extends BaseController {
+
+    @Resource
+    private ApkVersionService apkVersionService;
+
+    @ApiOperation("apk版本列表")
+    @PostMapping("/list")
+    public TableDataInfo list(){
+        startPage();
+        List<ApkVersion> list = apkVersionService.list();
+        return getDataTable(list);
+    }
+
+    @ApiOperation("新增apk版本")
+    @PostMapping("/add")
+    public AjaxResult add(@RequestBody ApkVersion apkVersion) {
+        apkVersion.setCreateTime(new Date());
+        boolean b = apkVersionService.save(apkVersion);
+        if (!b){
+            return AjaxResult.error("创建失败,请联系系统管理员");
+        }
+        return AjaxResult.success();
+    }
+
+}

+ 180 - 17
src/main/java/com/jsh/erp/controller/pda/PdaController.java

@@ -1,29 +1,45 @@
 package com.jsh.erp.controller.pda;
 
 import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.jsh.erp.base.AjaxResult;
 import com.jsh.erp.base.BaseController;
 import com.jsh.erp.base.TableDataInfo;
 import com.jsh.erp.datasource.entities.DepotHead;
 import com.jsh.erp.datasource.entities.Supplier;
-import com.jsh.erp.datasource.entities.TaskStocktakingItem;
-import com.jsh.erp.datasource.entities.User;
+import com.jsh.erp.datasource.entities.*;
 import com.jsh.erp.datasource.pda.dto.PDADepotHeadDTO;
+import com.jsh.erp.datasource.pda.dto.PDAInventoryDTO;
 import com.jsh.erp.datasource.pda.dto.PDATaskStocktakingDTO;
+import com.jsh.erp.datasource.pda.dto.PDATaskStocktakingItemDTO;
 import com.jsh.erp.datasource.pda.vo.PDADepotHeadVO;
 import com.jsh.erp.datasource.pda.vo.PDADepotItemVO;
 import com.jsh.erp.datasource.pda.vo.PDATaskStocktakingItemVO;
 import com.jsh.erp.datasource.pda.vo.PDATaskStocktakingVO;
+import com.jsh.erp.datasource.vo.SpinnerVO;
 import com.jsh.erp.datasource.vo.TaskStocktakingVO;
+import com.jsh.erp.datasource.vo.TreeNode;
 import com.jsh.erp.query.LambdaQueryWrapperX;
 import com.jsh.erp.service.*;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.math.BigDecimal;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.Date;
 import java.util.List;
 
@@ -42,6 +58,9 @@ public class PdaController extends BaseController {
     private SupplierService supplierService;
 
     @Resource
+    private MaterialService materialService;
+
+    @Resource
     private TaskStocktakingService taskStocktakingService;
 
     @Resource
@@ -50,6 +69,18 @@ public class PdaController extends BaseController {
     @Resource
     private UserService userService;
 
+    @Resource
+    private MaterialCategoryService materialCategoryService;
+
+    @Resource
+    private MaterialExtendService materialExtendService;
+
+    @Resource
+    private ApkVersionService apkVersionService;
+
+    @Resource
+    private DepotService depotService;
+
     /**
      * 采购入库
      * @return
@@ -76,7 +107,15 @@ public class PdaController extends BaseController {
     @GetMapping("/orderInfo/{id}")
     public AjaxResult orderInfo(@PathVariable("id") Long id){
         DepotHead depotHead = depotHeadService.getOne(new LambdaQueryWrapperX<DepotHead>().eq(DepotHead::getId, id));
-        depotHead.setSupplierName(supplierService.getOne(new LambdaQueryWrapperX<Supplier>().eq(Supplier::getId, depotHead.getOrganId())).getSupplier());
+        if (depotHead.getOrganId() != null) {
+            depotHead.setSupplierName(supplierService.getOne(new LambdaQueryWrapperX<Supplier>().eq(Supplier::getId, depotHead.getOrganId())).getSupplier());
+        }
+        if (depotHead.getCreator() != null) {
+            depotHead.setCreateName(userService.getOne(new LambdaQueryWrapperX<User>().eq(User::getId, depotHead.getCreator())).getUsername());
+        }
+        if (depotHead.getOperId() != null) {
+            depotHead.setOperName(userService.getOne(new LambdaQueryWrapperX<User>().eq(User::getId, depotHead.getOperId())).getUsername());
+        }
         return AjaxResult.success(depotHead);
     }
 
@@ -110,7 +149,7 @@ public class PdaController extends BaseController {
         } else {
             type = "出库";
         }
-        List<PDADepotItemVO> list = depotItemService.materialDepotDetail(type , materialId);
+        List<PDADepotItemVO> list = depotItemService.materialDepotDetail(type, materialId);
         return getDataTable(list);
     }
 
@@ -123,10 +162,10 @@ public class PdaController extends BaseController {
     }
 
     @ApiOperation(value = "盘点任务详情-商品列表")
-    @GetMapping("/taskStocktakingItemList/{taskId}")
-    public TableDataInfo taskStocktakingItemList(@PathVariable("taskId") Long taskId){
+    @PostMapping("/taskStocktakingItemList")
+    public TableDataInfo taskStocktakingItemList(@RequestBody PDATaskStocktakingItemDTO pdaTaskStocktakingItemDTO){
         startPage();
-        List<PDATaskStocktakingItemVO> list = taskStocktakingService.pdaItemList(taskId);
+        List<PDATaskStocktakingItemVO> list = taskStocktakingService.pdaItemList(pdaTaskStocktakingItemDTO);
         return getDataTable(list);
     }
 
@@ -137,16 +176,70 @@ public class PdaController extends BaseController {
         return AjaxResult.success(taskStocktakingVO);
     }
 
+    /**
+     * 获取商品类别树数据
+     * @Param:
+     * @return com.alibaba.fastjson.JSONArray
+     */
+    @ApiOperation(value = "获取商品类别树数据")
+    @GetMapping(value = "/getMaterialCategoryTree")
+    public JSONArray getMaterialCategoryTree(@RequestParam("id") Long id) throws Exception{
+        JSONArray arr=new JSONArray();
+        List<TreeNode> materialCategoryTree = materialCategoryService.getMaterialCategoryTree(id);
+        if(materialCategoryTree!=null&&materialCategoryTree.size()>0){
+            for(TreeNode node:materialCategoryTree){
+                String str= JSON.toJSONString(node);
+                JSONObject obj=JSON.parseObject(str);
+                arr.add(obj) ;
+            }
+        }
+        return arr;
+    }
+
+    @ApiOperation("开始任务")
+    @GetMapping("/startTask/{id}")
+    public AjaxResult startTask(@PathVariable("id") Long id){
+        taskStocktakingService.update(new UpdateWrapper<TaskStocktaking>()
+                .set("task_status", 2)
+                .eq("id", id));
+        return AjaxResult.success();
+    }
+
+    @ApiOperation("任务完成")
+    @GetMapping("/taskComplete/{id}")
+    public AjaxResult taskComplete(@PathVariable("id") Long id) throws Exception {
+        User currentUser = userService.getCurrentUser();
+        taskStocktakingService.update(new UpdateWrapper<TaskStocktaking>().set("task_status", 3)
+                .set("oper_time", new Date())
+                .set("oper_by", currentUser.getId())
+                .eq("id", id));
+        return AjaxResult.success();
+    }
+
     @ApiOperation("盘点")
     @PostMapping("/stocktaking")
     public AjaxResult stocktaking(@RequestBody TaskStocktakingItem taskStocktakingItem) throws Exception{
         User currentUser = userService.getCurrentUser();
+        MaterialExtend materialExtend = materialExtendService.getMaterialExtend(taskStocktakingItem.getMaterialItemId());
+        if (materialExtend == null) {
+            return AjaxResult.error("商品信息不存在");
+        }
         UpdateWrapper<TaskStocktakingItem> updateWrapper = new UpdateWrapper<>();
         updateWrapper.eq("id", taskStocktakingItem.getId())
                 .set("creator", currentUser.getId())
                 .set("oper_time", new Date());
         if (ObjectUtil.isNotEmpty(taskStocktakingItem.getNewInventory())) {
             updateWrapper.set("new_inventory", taskStocktakingItem.getNewInventory());
+            BigDecimal subtract = taskStocktakingItem.getNewInventory().subtract(materialExtend.getInventory());
+            updateWrapper.set("difference_count", subtract);
+            //差异数量,设置盘点状态为1.未盘,2.盘盈,3.盘亏 4.无差异
+            if (subtract.compareTo(BigDecimal.ZERO) > 0) {
+                updateWrapper.set("status", 2);
+            } else if (subtract.compareTo(BigDecimal.ZERO) < 0) {
+                updateWrapper.set("status", 3);
+            } else {
+                updateWrapper.set("status", 4);
+            }
         }
         if (ObjectUtil.isNotEmpty(taskStocktakingItem.getNewPosition())) {
             updateWrapper.set("new_position", taskStocktakingItem.getNewPosition());
@@ -161,16 +254,11 @@ public class PdaController extends BaseController {
         return AjaxResult.success();
     }
 
-    @ApiOperation("订单-用于返回字段说明")
-    @GetMapping("test")
-    public AjaxResult test(PDADepotItemVO pdaDepotItemVO) {
-        return AjaxResult.success();
-    }
-
-    @ApiOperation("盘点-用于字段返回说明")
-    @GetMapping("taskTest")
-    public AjaxResult taskTest(PDATaskStocktakingVO pdaTaskStocktakingVO){
-        return AjaxResult.success();
+    @ApiOperation("负责人下拉列表")
+    @GetMapping("/creatorSpinnerList/{taskId}")
+    public AjaxResult creatorSpinnerList(@PathVariable("taskId") Long taskId) {
+        List<SpinnerVO> spinnerVOList = taskStocktakingItemService.creatorSpinnerList(taskId);
+        return AjaxResult.success(spinnerVOList);
     }
 
     /**
@@ -188,4 +276,79 @@ public class PdaController extends BaseController {
         return AjaxResult.success();
     }
 
+    @PostMapping("/inventoryInquiry")
+    @ApiOperation("存货查询-商品存货查询")
+    public TableDataInfo inventoryInquiry(@RequestBody PDAInventoryDTO pdaInventoryDTO) throws Exception {
+        startPage();
+        List<PDADepotItemVO> list = materialService.inventoryInquiry(pdaInventoryDTO);
+        return getDataTable(list);
+    }
+
+    @ApiOperation("存货查询-库位树查询")
+    @GetMapping("/inventoryPositionTree")
+    public AjaxResult inventoryPositionTree() throws Exception {
+        return AjaxResult.success(materialService.selectPosition());
+    }
+
+    @ApiOperation("存货查询-类型树查询")
+    @GetMapping("/inventoryTypeTree")
+    public AjaxResult inventoryTypeTree() throws Exception {
+        return AjaxResult.success(materialCategoryService.getMaterialCategoryTree(null));
+    }
+
+    @ApiOperation("仓库下拉框")
+    @GetMapping("/depotSpinnerList")
+    public AjaxResult depotSpinnerList() {
+        return AjaxResult.success(depotService.depotSpinnerList());
+    }
+
+    @ApiOperation("下载安装包")
+    @PostMapping("/downloadApk")
+    public ResponseEntity downloadApk(@RequestBody ApkVersion apkVersion, HttpServletRequest request, HttpServletResponse response) throws Exception {
+        // 将文件路径转换为 Path 对象
+        Path path = Paths.get(apkVersion.getUrl()).toAbsolutePath().normalize();
+        File file = path.toFile();
+        String fileUrl = apkVersion.getUrl();
+        long size = Files.size(path);
+        response.setHeader("Content-Length",size+"");
+        // 检查文件是否存在
+        if (!file.exists() || !file.isFile()) {
+            return null;
+        }
+        InputStream inputStream = null;
+        OutputStream outputStream = null;
+        inputStream = new BufferedInputStream(new FileInputStream(fileUrl));
+        outputStream = response.getOutputStream();
+        byte[] buf = new byte[1024];
+        int len;
+        while ((len = inputStream.read(buf)) > 0) {
+            outputStream.write(buf, 0, len);
+        }
+        response.flushBuffer();
+        if (inputStream != null) {
+            try {
+                inputStream.close();
+            } catch (IOException e) {
+                logger.error(e.getMessage(), e);
+            }
+        }
+        if (outputStream != null) {
+            try {
+                outputStream.close();
+            } catch (IOException e) {
+                logger.error(e.getMessage(), e);
+            }
+        }
+        HttpHeaders headers = new HttpHeaders();
+        headers.setContentLength(size); // 手动设置Content-Length为13字节
+        return new ResponseEntity<>(null, headers, HttpStatus.OK);
+    }
+
+    @ApiOperation("查询版本信息")
+    @GetMapping("/selectVersion")
+    public AjaxResult selectVersion() {
+        ApkVersion apkVersion = apkVersionService.getOne(new LambdaQueryWrapperX<ApkVersion>().orderByDesc(ApkVersion::getId).last("limit 1"));
+        return AjaxResult.success(apkVersion);
+    }
+
 }

+ 65 - 9
src/main/java/com/jsh/erp/controller/stocktaking/StocktakingController.java

@@ -1,27 +1,33 @@
 package com.jsh.erp.controller.stocktaking;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.jsh.erp.base.AjaxResult;
 import com.jsh.erp.base.BaseController;
 import com.jsh.erp.base.TableDataInfo;
 import com.jsh.erp.datasource.dto.TaskStocktakingDTO;
 import com.jsh.erp.datasource.dto.TaskStocktakingItemDTO;
+import com.jsh.erp.datasource.dto.TaskStocktakingItemQueryDTO;
+import com.jsh.erp.datasource.dto.TaskStocktakingQueryDTO;
+import com.jsh.erp.datasource.entities.MaterialExtend;
 import com.jsh.erp.datasource.entities.TaskStocktaking;
 import com.jsh.erp.datasource.entities.TaskStocktakingItem;
 import com.jsh.erp.datasource.entities.User;
 import com.jsh.erp.datasource.vo.SpinnerVO;
 import com.jsh.erp.datasource.vo.TaskStocktakingVO;
+import com.jsh.erp.query.LambdaQueryWrapperX;
+import com.jsh.erp.service.MaterialExtendService;
 import com.jsh.erp.service.TaskStocktakingItemService;
 import com.jsh.erp.service.TaskStocktakingService;
 import com.jsh.erp.service.UserService;
 import com.jsh.erp.utils.DateUtils;
 import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
 
 @RestController
@@ -38,11 +44,14 @@ public class StocktakingController extends BaseController {
     @Resource
     private TaskStocktakingItemService taskStocktakingItemService;
 
+    @Resource
+    private MaterialExtendService materialExtendService;
+
     @ApiOperation("盘点任务列表")
     @PostMapping("/list")
-    public TableDataInfo list(){
+    public TableDataInfo list(@RequestBody TaskStocktakingQueryDTO taskStocktakingQueryDTO){
         startPage();
-        List<TaskStocktakingVO> list = taskStocktakingService.listBy();
+        List<TaskStocktakingVO> list = taskStocktakingService.listBy(taskStocktakingQueryDTO);
         return getDataTable(list);
     }
 
@@ -76,13 +85,16 @@ public class StocktakingController extends BaseController {
 
     /**
      * 任务详情-商品列表
-     * @param taskStocktakingId 任务ID
+     * @param taskStocktakingItemQueryDTO 筛选数据
      * @return
      */
     @ApiOperation("任务详情-商品列表")
-    @GetMapping("/detailByItemList/{taskStocktakingId}")
-    public AjaxResult detailByItemList(@PathVariable("taskStocktakingId") Long taskStocktakingId) {
-        return AjaxResult.success(taskStocktakingService.listByTaskStocktakingId(taskStocktakingId));
+    @PostMapping("/detailByItemList")
+    public AjaxResult detailByItemList(@RequestBody TaskStocktakingItemQueryDTO taskStocktakingItemQueryDTO) {
+        if (ObjectUtil.isEmpty(taskStocktakingItemQueryDTO.getTaskStocktakingId())) {
+            return AjaxResult.error("请选择盘点任务");
+        }
+        return AjaxResult.success(taskStocktakingService.listByTaskStocktakingId(taskStocktakingItemQueryDTO));
     }
 
     @ApiOperation("任务详情-修改")
@@ -99,7 +111,7 @@ public class StocktakingController extends BaseController {
      * 任务详情-商品列表-编辑
      * @return
      */
-    @ApiModelProperty("任务详情-商品-编辑")
+    @ApiOperation("任务详情-商品-编辑")
     @PostMapping("/itemUpdate")
     public AjaxResult itemUpdate(@RequestBody TaskStocktakingItemDTO taskStocktakingItemDTO) throws Exception {
         User currentUser = userService.getCurrentUser();
@@ -119,7 +131,7 @@ public class StocktakingController extends BaseController {
      * @param id 商品ID
      * @return
      */
-    @ApiModelProperty("任务详情-商品-删除")
+    @ApiOperation("任务详情-商品-删除")
     @GetMapping("/itemDelete/{id}")
     public AjaxResult itemDelete(@PathVariable("id") Long id) {
         taskStocktakingItemService.update(new UpdateWrapper<TaskStocktakingItem>().set("delete_flag", true).eq("id", id));
@@ -135,4 +147,48 @@ public class StocktakingController extends BaseController {
         return AjaxResult.success();
     }
 
+    @ApiOperation("删除任务")
+    @GetMapping("/taskDelete/{ids}")
+    public AjaxResult taskDelete(@PathVariable("ids") Long[] ids) {
+        Arrays.asList(ids).forEach(id -> {
+            taskStocktakingService.update(new UpdateWrapper<TaskStocktaking>().eq("id", id).set("delete_flag", true));
+        });
+        return AjaxResult.success();
+    }
+
+    @ApiOperation("开始任务")
+    @GetMapping("/startTask/{id}")
+    public AjaxResult startTask(@PathVariable("id") Long id) {
+        taskStocktakingService.update(new UpdateWrapper<TaskStocktaking>().set("task_status", 2).eq("id", id));
+        return AjaxResult.success();
+    }
+
+    @ApiOperation("完成任务")
+    @GetMapping("/taskComplete/{id}")
+    public AjaxResult taskComplete(@PathVariable("id") Long id) throws Exception {
+        User currentUser = userService.getCurrentUser();
+        taskStocktakingService.update(new UpdateWrapper<TaskStocktaking>().set("task_status", 3)
+                .set("oper_time", new Date())
+                .set("oper_by", currentUser.getId())
+                .eq("id", id));
+        return AjaxResult.success();
+    }
+
+    @ApiOperation("任务更新库存")
+    @GetMapping("/taskUpdateStock/{ids}")
+    public AjaxResult updateStock(@PathVariable("ids") Long[] ids) throws Exception {
+        for (Long id : ids) {
+            taskStocktakingService.update(new UpdateWrapper<TaskStocktaking>().set("task_status", 5).eq("id", id));
+            List<TaskStocktakingItem> list = taskStocktakingItemService.list(new LambdaQueryWrapperX<TaskStocktakingItem>().eq(TaskStocktakingItem::getTaskStocktakingId,id));
+            for (TaskStocktakingItem taskStocktakingItem : list) {
+                MaterialExtend materialExtend = materialExtendService.getMaterialExtend(taskStocktakingItem.getMaterialItemId());
+                materialExtend.setInventory(taskStocktakingItem.getNewInventory());
+                materialExtend.setPosition(taskStocktakingItem.getNewPosition());
+                materialExtendService.updateInventory("盘点",taskStocktakingItem.getId(),materialExtend);
+            }
+        }
+        return AjaxResult.success();
+    }
+
+
 }

+ 30 - 0
src/main/java/com/jsh/erp/datasource/dto/TaskStocktakingItemQueryDTO.java

@@ -0,0 +1,30 @@
+package com.jsh.erp.datasource.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+@Data
+@Accessors(chain = true)
+public class TaskStocktakingItemQueryDTO {
+
+    @ApiModelProperty("盘点任务ID")
+    private Long taskStocktakingId;
+
+    @ApiModelProperty("商品类别ID")
+    private Long categoryId;
+
+    @ApiModelProperty("商品名称")
+    private Integer materialName;
+
+    @ApiModelProperty("批次号")
+    private String batchNumber;
+
+    @ApiModelProperty("仓库货架")
+    private String position;
+
+    @ApiModelProperty("是否存在差异 1:是,2:否,其他是全部")
+    private String isDifference;
+
+
+}

+ 24 - 0
src/main/java/com/jsh/erp/datasource/dto/TaskStocktakingQueryDTO.java

@@ -0,0 +1,24 @@
+package com.jsh.erp.datasource.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+@Data
+@Accessors(chain = true)
+public class TaskStocktakingQueryDTO {
+
+    @ApiModelProperty("任务状态 1.未开始,2.进行中,3.已完成,4.已取消")
+    private Integer taskStatus;
+
+    @ApiModelProperty("任务单号")
+    private String number;
+
+    @ApiModelProperty("盘点仓库ID")
+    private Long depotId;
+
+    @ApiModelProperty("创建人")
+    private Long createBy;
+
+
+}

+ 29 - 0
src/main/java/com/jsh/erp/datasource/entities/ApkVersion.java

@@ -0,0 +1,29 @@
+package com.jsh.erp.datasource.entities;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class ApkVersion {
+
+    @ApiModelProperty(value = "主键id")
+    private Long id;
+
+    @ApiModelProperty(value = "版本号")
+    private String version;
+
+    @ApiModelProperty(value = "下载地址")
+    private String url;
+
+    @ApiModelProperty(value = "版本名称")
+    private String name;
+
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+
+    @ApiModelProperty(value = "是否删除")
+    private boolean deleteFlag;
+
+}

+ 14 - 0
src/main/java/com/jsh/erp/datasource/entities/DepotHead.java

@@ -127,6 +127,14 @@ public class DepotHead {
     @ApiModelProperty("供应商名称")
     private String supplierName;
 
+    @TableField(exist = false)
+    @ApiModelProperty("供应商名称")
+    private String operName;
+
+    @TableField(exist = false)
+    @ApiModelProperty("供应商名称")
+    private String createName;
+
     @ApiModelProperty("集采订单编号")
     private String linkTesco;
 
@@ -139,6 +147,12 @@ public class DepotHead {
     @ApiModelProperty("收货人地址")
     private String receiverAddress;
 
+    @ApiModelProperty("仓库id")
+    private Long depotId;
+
+    @ApiModelProperty("操作人")
+    private Long operId;
+
 
     public Long getId() {
         return id;

+ 5 - 1
src/main/java/com/jsh/erp/datasource/entities/DepotItem.java

@@ -1,6 +1,7 @@
 package com.jsh.erp.datasource.entities;
 
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -102,7 +103,10 @@ public class DepotItem {
     private Long warehousingUser;
 
     @ApiModelProperty("出入库时间")
-    private Date warehousingTime;
+    private String warehousingTime;
+
+    @ApiModelProperty("创建时间")
+    private Date createTime;
 
     public Long getId() {
         return id;

+ 2 - 0
src/main/java/com/jsh/erp/datasource/entities/DepotItemVo4WithInfoEx.java

@@ -297,4 +297,6 @@ public class DepotItemVo4WithInfoEx extends DepotItem{
     public void setBrand(String brand) {
         this.brand = brand;
     }
+
+
 }

+ 43 - 0
src/main/java/com/jsh/erp/datasource/entities/InventoryLog.java

@@ -0,0 +1,43 @@
+package com.jsh.erp.datasource.entities;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 商品库存修改日志表实体类
+ */
+@Data
+@TableName("jsh_inventory_log")
+public class InventoryLog {
+
+    @ApiModelProperty("主键id")
+    private Long id;
+
+    @ApiModelProperty("操作类型")
+    private String type;
+
+    @ApiModelProperty("单据、盘点子表id")
+    private Long itemId;
+
+    @ApiModelProperty("商品id")
+    private Long materialId;
+
+    @ApiModelProperty("商品子表id")
+    private Long materialExtendId;
+
+    @ApiModelProperty("原始库存")
+    private Integer originalStock;
+
+    @ApiModelProperty("当前库存")
+    private Integer currentStock;
+
+    @ApiModelProperty("更新时间")
+    private Date updateTime;
+
+    @ApiModelProperty("更新用户")
+    private Long updateUser;
+
+}

+ 2 - 0
src/main/java/com/jsh/erp/datasource/entities/MaterialCategory.java

@@ -1,5 +1,6 @@
 package com.jsh.erp.datasource.entities;
 
+import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 import lombok.experimental.Accessors;
 
@@ -10,6 +11,7 @@ import java.util.Date;
  */
 @Data
 @Accessors(chain = true)
+@TableName("jsh_material_category")
 public class MaterialCategory {
 
     private Long id;

+ 2 - 0
src/main/java/com/jsh/erp/datasource/entities/MaterialCurrentStock.java

@@ -1,5 +1,6 @@
 package com.jsh.erp.datasource.entities;
 
+import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 import lombok.experimental.Accessors;
 
@@ -10,6 +11,7 @@ import java.math.BigDecimal;
  */
 @Data
 @Accessors(chain = true)
+@TableName("jsh_material_current_stock")
 public class MaterialCurrentStock {
     private Long id;
 

+ 5 - 0
src/main/java/com/jsh/erp/datasource/entities/MaterialExtend.java

@@ -1,8 +1,10 @@
 package com.jsh.erp.datasource.entities;
 
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import lombok.experimental.Accessors;
 
 import java.math.BigDecimal;
 import java.util.Date;
@@ -12,6 +14,7 @@ import java.util.Date;
  */
 @Data
 @TableName("jsh_material_extend")
+@Accessors
 public class MaterialExtend {
 
     @ApiModelProperty("主键id")
@@ -42,6 +45,7 @@ public class MaterialExtend {
     private String defaultFlag;
 
     @ApiModelProperty("创建日期")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date createTime;
 
     @ApiModelProperty("创建人编码")
@@ -60,6 +64,7 @@ public class MaterialExtend {
     private String deleteFlag;
 
     @ApiModelProperty("生产日期")
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private Date productionDate;
 
     @ApiModelProperty("保质期天数")

+ 5 - 5
src/main/java/com/jsh/erp/datasource/entities/MaterialVo4Unit.java

@@ -102,19 +102,19 @@ public class MaterialVo4Unit extends Material{
     private String depotName;
 
     @ApiModelProperty("实际出入库数量")
-    private BigDecimal actualQuantityInStorage;
+    private String actualQuantityInStorage = "";
 
     @ApiModelProperty("出入库差异")
-    private BigDecimal warehousingVariance;
+    private String warehousingVariance = "";
 
     @ApiModelProperty("出入库差异原因")
-    private String reasonOfDifference;
+    private String reasonOfDifference = "";
 
     @ApiModelProperty("出入库用户")
-    private Long warehousingUser;
+    private String warehousingUser = "";
 
     @ApiModelProperty("出入库时间")
-    private Date warehousingTime;
+    private String warehousingTime = "";
 
     @ApiModelProperty("多单位集合")
     private List<UnitListVo> unitList;

+ 2 - 2
src/main/java/com/jsh/erp/datasource/entities/TaskStocktaking.java

@@ -43,9 +43,9 @@ public class TaskStocktaking {
     private Integer categoryCount;
 
     @ApiModelProperty("商品数")
-    private int materialCount;
+    private Integer materialCount;
 
-    @ApiModelProperty("任务状态 1.未开始,2.进行中,3.已完成,4.已取消")
+    @ApiModelProperty("任务状态 1.未开始,2.进行中,3.已完成,4.已取消,5.已更新")
     private Integer taskStatus;
 
     @ApiModelProperty("盘点范围")

+ 3 - 0
src/main/java/com/jsh/erp/datasource/entities/TaskStocktakingItem.java

@@ -41,6 +41,9 @@ public class TaskStocktakingItem {
     @ApiModelProperty("差异原因")
     private String differenceReason;
 
+    @ApiModelProperty("盘点状态:1.未盘,2.盘盈,3.盘亏 4.无差异 其余为全部")
+    private Integer status;
+
     @ApiModelProperty("删除标记,0.未删除,1.已删除")
     private boolean deleteFlag;
 

+ 9 - 0
src/main/java/com/jsh/erp/datasource/mappers/ApkVersionMapper.java

@@ -0,0 +1,9 @@
+package com.jsh.erp.datasource.mappers;
+
+
+import com.jsh.erp.datasource.entities.ApkVersion;
+
+public interface ApkVersionMapper extends BaseMapperX<ApkVersion> {
+
+
+}

+ 7 - 0
src/main/java/com/jsh/erp/datasource/mappers/DepotHeadMapper.java

@@ -17,6 +17,13 @@ public interface DepotHeadMapper extends BaseMapperX<DepotHead> {
      */
     List<PDADepotHeadVO> pdaList(PDADepotHeadDTO pdaDepotHeadDTO);
 
+    /**
+     * PDA查询订单详情
+     * @param id 订单id
+     * @return
+     */
+    PDADepotHeadVO pdaDetail(@Param("id")Long id);
+
     long countByExample(DepotHeadExample example);
 
     int deleteByExample(DepotHeadExample example);

+ 1 - 1
src/main/java/com/jsh/erp/datasource/mappers/DepotItemMapper.java

@@ -29,7 +29,7 @@ public interface DepotItemMapper  extends BaseMapperX<DepotItem>{
      * @param materialId 商品ID
      * @return
      */
-    List<PDADepotItemVO> materialDepotDetail(@Param("type")String type , @Param("materialId") Long materialId);
+    List<PDADepotItemVO> materialDepotDetail(@Param("type")String type, @Param("materialId") Long materialId);
 
     long countByExample(DepotItemExample example);
 

+ 10 - 1
src/main/java/com/jsh/erp/datasource/mappers/DepotMapper.java

@@ -3,9 +3,18 @@ package com.jsh.erp.datasource.mappers;
 import com.jsh.erp.datasource.entities.Depot;
 import com.jsh.erp.datasource.entities.DepotExample;
 import java.util.List;
+
+import com.jsh.erp.datasource.vo.SpinnerVO;
 import org.apache.ibatis.annotations.Param;
 
-public interface DepotMapper {
+public interface DepotMapper extends BaseMapperX<Depot> {
+
+    /**
+     * 仓库下拉框
+     * @return
+     */
+    List<SpinnerVO> depotSpinnerList();
+
     long countByExample(DepotExample example);
 
     int deleteByExample(DepotExample example);

+ 9 - 0
src/main/java/com/jsh/erp/datasource/mappers/InventoryLogMapper.java

@@ -0,0 +1,9 @@
+package com.jsh.erp.datasource.mappers;
+
+import com.jsh.erp.datasource.entities.InventoryLog;
+
+public interface InventoryLogMapper extends BaseMapperX<InventoryLog> {
+
+
+
+}

+ 2 - 1
src/main/java/com/jsh/erp/datasource/mappers/MaterialCategoryMapper.java

@@ -1,11 +1,12 @@
 package com.jsh.erp.datasource.mappers;
 
+import com.jsh.erp.datasource.entities.DepotHead;
 import com.jsh.erp.datasource.entities.MaterialCategory;
 import com.jsh.erp.datasource.entities.MaterialCategoryExample;
 import java.util.List;
 import org.apache.ibatis.annotations.Param;
 
-public interface MaterialCategoryMapper {
+public interface MaterialCategoryMapper extends BaseMapperX<MaterialCategory> {
     long countByExample(MaterialCategoryExample example);
 
     int deleteByExample(MaterialCategoryExample example);

+ 3 - 0
src/main/java/com/jsh/erp/datasource/mappers/MaterialCurrentStockMapperEx.java

@@ -1,6 +1,7 @@
 package com.jsh.erp.datasource.mappers;
 
 import com.jsh.erp.datasource.entities.MaterialCurrentStock;
+import com.jsh.erp.datasource.vo.MaterialCurrentStock4SystemSku;
 import org.apache.ibatis.annotations.Param;
 
 import java.math.BigDecimal;
@@ -20,4 +21,6 @@ public interface MaterialCurrentStockMapperEx {
     BigDecimal getCurrentUnitPriceByMId(@Param("materialId") Long materialId);
 
     void batchDeleteByDepots(@Param("ids") String ids[]);
+
+    List<MaterialCurrentStock4SystemSku> getCurrentStockMapByMdIdList(@Param("materialIdList") List<Long> materialIdList);
 }

+ 2 - 0
src/main/java/com/jsh/erp/datasource/mappers/MaterialExtendMapper.java

@@ -52,4 +52,6 @@ public interface MaterialExtendMapper extends BaseMapperX<MaterialExtend>{
     BigDecimal getInventorySumByDepotAndMid(@Param("depotList") List<Long> depotList,
                                             @Param("mid") long mid);
 
+    List<String> selectPosition();
+
 }

+ 7 - 0
src/main/java/com/jsh/erp/datasource/mappers/MaterialExtendMapperEx.java

@@ -1,5 +1,6 @@
 package com.jsh.erp.datasource.mappers;
 
+import com.jsh.erp.datasource.entities.DepotItem;
 import com.jsh.erp.datasource.entities.MaterialExtend;
 import com.jsh.erp.datasource.vo.MaterialExtendVo4List;
 import org.apache.ibatis.annotations.Param;
@@ -34,4 +35,10 @@ public interface MaterialExtendMapperEx {
     int specialUpdatePrice(MaterialExtend record);
 
     List<MaterialExtend> getBasicInfoByMid(@Param("materialId") Long materialId);
+
+    /**
+     * 根据仓库id查询子表数量
+     * 仓库删除校验
+     */
+    int getMaterialExtendCountByDepotIds(@Param("depotIds") String[] depotIds);
 }

+ 9 - 0
src/main/java/com/jsh/erp/datasource/mappers/MaterialMapperEx.java

@@ -1,6 +1,9 @@
 package com.jsh.erp.datasource.mappers;
 
 import com.jsh.erp.datasource.entities.*;
+import com.jsh.erp.datasource.pda.dto.PDAInventoryDTO;
+import com.jsh.erp.datasource.pda.vo.PDADepotItemVO;
+import com.jsh.erp.datasource.vo.MaterialCurrentStock4SystemSku;
 import com.jsh.erp.datasource.vo.MaterialVoSearch;
 import org.apache.ibatis.annotations.Param;
 
@@ -162,4 +165,10 @@ public interface MaterialMapperEx {
     List<MaterialVo4Unit> getMaterialByBatchNumber(@Param("batchNumberArray") String [] batchNumberArray);
 
     List<MaterialVo4Unit> getMaterialBySystemSku(@Param("systemSkuArray") String [] systemSkuArray);
+
+    List<MaterialCurrentStock4SystemSku> getMaterialCurrentPriceByIdList(@Param("idList") List<Long> idList);
+
+    List<PDADepotItemVO> inventoryInquiry(PDAInventoryDTO pdaInventoryDTO);
+
+
 }

+ 7 - 2
src/main/java/com/jsh/erp/datasource/mappers/TaskStocktakingItemMapper.java

@@ -1,7 +1,10 @@
 package com.jsh.erp.datasource.mappers;
 
+import com.jsh.erp.datasource.dto.TaskStocktakingItemQueryDTO;
 import com.jsh.erp.datasource.entities.TaskStocktakingItem;
+import com.jsh.erp.datasource.pda.dto.PDATaskStocktakingItemDTO;
 import com.jsh.erp.datasource.pda.vo.PDATaskStocktakingItemVO;
+import com.jsh.erp.datasource.vo.SpinnerVO;
 import com.jsh.erp.datasource.vo.TaskStocktakingItemVO;
 import org.apache.ibatis.annotations.Param;
 
@@ -9,8 +12,10 @@ import java.util.List;
 
 public interface TaskStocktakingItemMapper extends BaseMapperX<TaskStocktakingItem> {
 
-    List<TaskStocktakingItemVO> listByTaskStocktakingId(@Param("taskStocktakingId") Long taskStocktakingId);
+    List<TaskStocktakingItemVO> listByTaskStocktakingId(TaskStocktakingItemQueryDTO taskStocktakingItemQueryDTO);
 
-    List<PDATaskStocktakingItemVO> pdaList(@Param("taskId") Long taskId);
+    List<PDATaskStocktakingItemVO> pdaList(PDATaskStocktakingItemDTO pdaTaskStocktakingItemDTO);
+
+    List<SpinnerVO> creatorSpinnerList(@Param("taskId") Long taskId);
 
 }

+ 2 - 1
src/main/java/com/jsh/erp/datasource/mappers/TaskStocktakingMapper.java

@@ -1,5 +1,6 @@
 package com.jsh.erp.datasource.mappers;
 
+import com.jsh.erp.datasource.dto.TaskStocktakingQueryDTO;
 import com.jsh.erp.datasource.entities.TaskStocktaking;
 import com.jsh.erp.datasource.pda.vo.PDATaskStocktakingVO;
 import com.jsh.erp.datasource.vo.TaskStocktakingVO;
@@ -9,7 +10,7 @@ import java.util.List;
 
 public interface TaskStocktakingMapper extends BaseMapperX<TaskStocktaking> {
 
-    List<TaskStocktakingVO> listBy();
+    List<TaskStocktakingVO> listBy(TaskStocktakingQueryDTO taskStocktakingQueryDTO);
 
     List<PDATaskStocktakingVO> pdaList(@Param("number") String number , @Param("taskStatus") Integer taskStatus);
 }

+ 30 - 0
src/main/java/com/jsh/erp/datasource/pda/dto/PDAInventoryDTO.java

@@ -0,0 +1,30 @@
+package com.jsh.erp.datasource.pda.dto;
+
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 存货查询接口
+ */
+@Data
+public class PDAInventoryDTO {
+
+    @ApiModelProperty("查询类型")
+    private String type;
+
+    @ApiModelProperty("商品种类ID")
+    private Long categoryId;
+
+    @ApiModelProperty("库位")
+    private String position;
+
+    @ApiModelProperty("关键字")
+    private String keyword;
+
+    @ApiModelProperty("商品种类ID数组")
+    private List<Long> categoryIds;
+
+}

+ 9 - 0
src/main/java/com/jsh/erp/datasource/pda/dto/PDATaskStocktakingDTO.java

@@ -12,4 +12,13 @@ public class PDATaskStocktakingDTO {
     @ApiModelProperty("任务单号")
     private String number;
 
+    @ApiModelProperty("用户id")
+    private Long userId;
+
+    @ApiModelProperty("商品种类ID")
+    private Long categoryId;
+
+    @ApiModelProperty("库位")
+    private String position;
+
 }

+ 31 - 0
src/main/java/com/jsh/erp/datasource/pda/dto/PDATaskStocktakingItemDTO.java

@@ -0,0 +1,31 @@
+package com.jsh.erp.datasource.pda.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class PDATaskStocktakingItemDTO {
+
+    @ApiModelProperty("任务ID")
+    private String taskId;
+
+    @ApiModelProperty("库位")
+    private List<String> positionList;
+
+    @ApiModelProperty("盘点人ID")
+    private List<Long> userIdList;
+
+    @ApiModelProperty("商品种类ID")
+    private List<Long> categoryIdList;
+
+    @ApiModelProperty("商品盘点类型:1.未盘,2.盘盈,3.盘亏 4.无差异 其余为全部")
+    private List<String> statusList;
+
+    @ApiModelProperty("任务编号")
+    private String number;
+
+    @ApiModelProperty("库位")
+    private String position;
+}

+ 4 - 0
src/main/java/com/jsh/erp/datasource/pda/vo/PDADepotHeadVO.java

@@ -23,6 +23,10 @@ public class PDADepotHeadVO {
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date createTime;
 
+    @ApiModelProperty("单据时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date operTime;
+
     @ApiModelProperty("商品总数量")
     private int goodsQuantity;
 

+ 9 - 0
src/main/java/com/jsh/erp/datasource/pda/vo/PDADepotItemVO.java

@@ -61,4 +61,13 @@ public class PDADepotItemVO{
 
     @ApiModelProperty("实际出入库数量")
     private String actualQuantityInStorage;
+
+    @ApiModelProperty("图片名称")
+    private String imgName;
+
+    @ApiModelProperty("出入库时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date warehousingTime;
+
+
 }

+ 14 - 0
src/main/java/com/jsh/erp/datasource/pda/vo/PDATaskStocktakingItemVO.java

@@ -1,5 +1,6 @@
 package com.jsh.erp.datasource.pda.vo;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.experimental.Accessors;
@@ -22,6 +23,9 @@ public class PDATaskStocktakingItemVO {
     @ApiModelProperty("商品总类")
     private String categoryName;
 
+    @ApiModelProperty("商品ID")
+    private Long materialItemId;
+
     @ApiModelProperty("商品名称")
     private String materialName;
 
@@ -32,12 +36,22 @@ public class PDATaskStocktakingItemVO {
     private String createName;
 
     @ApiModelProperty("盘点时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date operTime;
 
     @ApiModelProperty("库存数")
     private Integer inventory;
 
+    @ApiModelProperty("商品单位")
+    private String commodityUnit;
+
     @ApiModelProperty("盘点库存数")
     private Integer newInventory;
 
+    @ApiModelProperty("盘点状态:1.未盘,2.盘盈,3.盘亏 4.无差异 其余为全部")
+    private Integer status;
+
+    @ApiModelProperty("图片地址")
+    private String imgName;
+
 }

+ 7 - 1
src/main/java/com/jsh/erp/datasource/pda/vo/PDATaskStocktakingVO.java

@@ -1,5 +1,6 @@
 package com.jsh.erp.datasource.pda.vo;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -21,7 +22,7 @@ public class PDATaskStocktakingVO {
     private String depotName;
 
     @ApiModelProperty("创建人名称")
-    private String createByName;
+    private String createName;
 
     @ApiModelProperty("负责人名称")
     private String creatorName;
@@ -36,12 +37,17 @@ public class PDATaskStocktakingVO {
     private String operName;
 
     @ApiModelProperty("创建时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date createTime;
 
     @ApiModelProperty("盘点时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date operTime;
 
     @ApiModelProperty("任务状态 1.未开始,2.进行中,3.已完成,4.已取消")
     private Integer taskStatus;
 
+    @ApiModelProperty("盘点范围")
+    private String positionRange;
+
 }

+ 30 - 0
src/main/java/com/jsh/erp/datasource/pda/vo/PDATypeTree.java

@@ -0,0 +1,30 @@
+package com.jsh.erp.datasource.pda.vo;
+
+import com.jsh.erp.datasource.vo.TreeNode;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * PDA库位类型树
+ */
+@Data
+public class PDATypeTree {
+
+    private Long id;
+
+    private Long key;
+
+    private String value;
+
+    /**
+     * title显示的文本
+     * */
+    private String label;
+
+    /**
+     * children 子节点
+     * */
+    private List<PDATypeTree> children;
+
+}

+ 143 - 0
src/main/java/com/jsh/erp/datasource/vo/MaterialCurrentStock4SystemSku.java

@@ -0,0 +1,143 @@
+package com.jsh.erp.datasource.vo;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @Description TODO
+ * @Author MS.BLUE
+ * @Date 2025-04-16
+ */
+@Data
+@JsonInclude(JsonInclude.Include.NON_NULL) // 序列化时忽略null
+@JsonIgnoreProperties(ignoreUnknown = true)// 反序列化时忽略未知属性
+public class MaterialCurrentStock4SystemSku {
+
+    /**
+     * 商品id
+     */
+    private Long mId;
+
+    /**
+     * 商品名称
+     */
+    private String mName;
+
+    /**
+     * 商品单位-单个单位
+     */
+    private String unit;
+
+    /**
+     * 多单位商品
+     */
+
+    private Long unitId;
+
+    /**
+     * 是否是多单位商品
+     */
+    private boolean isLargeUnit;
+
+    /**
+     * 系统商品编码
+     */
+    private String systemSku;
+
+    /**
+     * 基础单位
+     */
+    private String basicUnit;
+
+    /**
+     * 其他单位
+     */
+    private String otherUnit;
+
+    /**
+     * 其他单位2
+     */
+    private String otherUnitTwo;
+
+    /**
+     * 其他单位3
+     */
+    private String otherUnitThree;
+
+    /**
+     * 基础单位-总库存
+     */
+    private BigDecimal basicUnitTotalStock;
+
+    /**
+     * 其他单位-总库存
+     * =
+     * {@link #basicUnitTotalStock}
+     * ÷{@link #ratio}
+     */
+    private BigDecimal otherUnitTotalStock;
+
+    /**
+     * 其他单位2-总库存
+     * =
+     * {@link #basicUnitTotalStock}
+     * ÷{@link #ratioTwo}
+     */
+    private BigDecimal otherUnitTwoTotalStock;
+
+    /**
+     * 其他单位3-总库存
+     * =
+     * {@link #basicUnitTotalStock}
+     * ÷{@link #ratioThree}
+     */
+    private BigDecimal otherUnitThreeTotalStock;
+
+    /**
+     * 其他单位-比率
+     */
+    private BigDecimal ratio;
+
+    /**
+     * 其他单位2-比率
+     */
+    private BigDecimal ratioTwo;
+
+    /**
+     * 其他单位3-比率
+     */
+    private BigDecimal ratioThree;
+
+
+    /**
+     * 基础单位-销售价格
+     */
+    private BigDecimal basicUnitSalePrice;
+
+    /**
+     * 其他单位-销售价格
+     * =
+     * {@link #basicUnitSalePrice}
+     * * {@link #ratio}
+     */
+    private BigDecimal otherUnitSalePrice;
+
+    /**
+     * 其他单位2-销售价格
+     * =
+     * {@link #basicUnitSalePrice}
+     * * {@link #ratioTwo}
+     */
+    private BigDecimal otherUnitTwoSalePrice;
+
+    /**
+     * 其他单位3-销售价格
+     * =
+     * {@link #basicUnitSalePrice}
+     * * {@link #ratioThree}
+     */
+    private BigDecimal otherUnitThreeSalePrice;
+}

+ 16 - 0
src/main/java/com/jsh/erp/datasource/vo/MaterialExcelVo.java

@@ -0,0 +1,16 @@
+package com.jsh.erp.datasource.vo;
+
+
+import com.jsh.erp.datasource.entities.Material;
+import com.jsh.erp.datasource.entities.MaterialExtend;
+import lombok.Data;
+
+/**
+ * 商品导入
+ */
+@Data
+public class MaterialExcelVo extends Material{
+
+    private MaterialExtend materialExtend;
+
+}

+ 2 - 0
src/main/java/com/jsh/erp/datasource/vo/MaterialExtendVo4List.java

@@ -1,9 +1,11 @@
 package com.jsh.erp.datasource.vo;
 
 import com.jsh.erp.datasource.entities.MaterialExtend;
+import lombok.Data;
 
 import java.math.BigDecimal;
 
+@Data
 public class MaterialExtendVo4List extends MaterialExtend {
 
     private String supplier;

+ 24 - 0
src/main/java/com/jsh/erp/datasource/vo/TaskStocktakingItemVO.java

@@ -30,6 +30,12 @@ public class TaskStocktakingItemVO {
     @ApiModelProperty("商品单位")
     private String commodityUnit;
 
+    @ApiModelProperty("库位")
+    private String position;
+
+    @ApiModelProperty("批次号")
+    private String batchNumber;
+
     @ApiModelProperty("生产日期")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date productionDate;
@@ -74,4 +80,22 @@ public class TaskStocktakingItemVO {
     @ApiModelProperty("删除标记,0.未删除,1.已删除")
     private boolean deleteFlag;
 
+    @ApiModelProperty("商品规格")
+    private String standard;
+
+    @ApiModelProperty("商品型号")
+    private String model;
+
+    @ApiModelProperty("商品颜色")
+    private String color;
+
+    @ApiModelProperty("商品品牌")
+    private String brand;
+
+    @ApiModelProperty("商品多属性")
+    private String sku;
+
+    @ApiModelProperty("商品保质期天数")
+    private String expiryNum;
+
 }

+ 3 - 0
src/main/java/com/jsh/erp/datasource/vo/TaskStocktakingVO.java

@@ -33,4 +33,7 @@ public class TaskStocktakingVO extends TaskStocktaking {
     @ApiModelProperty("准确率")
     private double accuracyRate;
 
+    @ApiModelProperty("盘点人操作人数")
+    private Long operCount;
+
 }

+ 4 - 3
src/main/java/com/jsh/erp/filter/LogCostFilter.java

@@ -14,7 +14,7 @@ import java.io.IOException;
 @WebFilter(filterName = "LogCostFilter", urlPatterns = {"/*"},
         initParams = {@WebInitParam(name = "filterPath",
                       value = "/user/login#" +
-                              "user/pdaLogin#" +
+                              "/user/pdaLogin#" +
                               "/user/weixinLogin#" +
                               "/user/weixinBind#" +
                               "/user/registerUser#" +
@@ -25,6 +25,8 @@ import java.io.IOException;
                               "/systemConfig/static#" +
                               "/api/plugin/wechat/weChat/share#" +
                               "/api/plugin/general-ledger/pdf/voucher#" +
+                              "/pda/downloadApk#" +
+                              "/pda/selectVersion#" +
                               "/api/plugin/tenant-statistics/tenantClean")})
 public class LogCostFilter implements Filter {
 
@@ -55,8 +57,7 @@ public class LogCostFilter implements Filter {
             return;
         }
         if (requestUrl != null && (requestUrl.contains("/doc.html") ||
-            requestUrl.contains("/user/pdaLogin") ||
-            requestUrl.contains("/user/login") || requestUrl.contains("/user/register") || requestUrl.contains("/user/randomImage")
+            requestUrl.contains("/user/login") || requestUrl.contains("/user/register")
             ||requestUrl.contains("/open-api"))) {
             chain.doFilter(request, response);
             return;

+ 8 - 0
src/main/java/com/jsh/erp/service/ApkVersionService.java

@@ -0,0 +1,8 @@
+package com.jsh.erp.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.jsh.erp.datasource.entities.ApkVersion;
+
+public interface ApkVersionService extends IService<ApkVersion> {
+
+}

+ 7 - 0
src/main/java/com/jsh/erp/service/DepotHeadService.java

@@ -28,6 +28,13 @@ public interface DepotHeadService extends IService<DepotHead> {
      */
     List<PDADepotHeadVO> pdaList(PDADepotHeadDTO pdaDepotHeadDTO);
 
+    /**
+     * PDA查询订单详情
+     * @param id
+     * @return
+     */
+    PDADepotHeadVO pdaDetail(Long id);
+
     DepotHead getDepotHead(long id)throws Exception;
 
     List<DepotHead> getDepotHead()throws Exception;

+ 5 - 0
src/main/java/com/jsh/erp/service/DepotItemService.java

@@ -153,6 +153,11 @@ public interface DepotItemService extends IService<DepotItem> {
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     void updateCurrentUnitPrice(DepotItem depotItem) throws Exception;
 
+    /**
+     * 根据商品id、仓库id更新当前库存
+     * @param mId 商品id
+     * @param dId 仓库id
+     */
     void updateCurrentStockFun(Long mId, Long dId) throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)

+ 36 - 334
src/main/java/com/jsh/erp/service/DepotService.java

@@ -1,370 +1,72 @@
 package com.jsh.erp.service;
 
+
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.jsh.erp.constants.BusinessConstants;
-import com.jsh.erp.constants.ExceptionConstants;
-import com.jsh.erp.datasource.entities.*;
-import com.jsh.erp.datasource.mappers.*;
-import com.jsh.erp.exception.BusinessRunTimeException;
-import com.jsh.erp.exception.JshException;
-import com.jsh.erp.utils.PageUtils;
-import com.jsh.erp.utils.StringUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.jsh.erp.datasource.entities.Depot;
+import com.jsh.erp.datasource.entities.DepotEx;
+import com.jsh.erp.datasource.vo.SpinnerVO;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.context.request.ServletRequestAttributes;
 
-import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
-import java.util.Date;
 import java.util.List;
 
-@Service
-public class DepotService {
-    private Logger logger = LoggerFactory.getLogger(DepotService.class);
+public interface DepotService extends IService<Depot> {
 
-    @Resource
-    private DepotMapper depotMapper;
-    @Resource
-    private DepotMapperEx depotMapperEx;
-    @Resource
-    private UserService userService;
-    @Resource
-    private SystemConfigService systemConfigService;
-    @Resource
-    private UserBusinessService userBusinessService;
-    @Resource
-    private LogService logService;
-    @Resource
-    private DepotItemMapperEx depotItemMapperEx;
-    @Resource
-    private MaterialInitialStockMapperEx materialInitialStockMapperEx;
-    @Resource
-    private MaterialCurrentStockMapperEx materialCurrentStockMapperEx;
+    /**
+     * 获取下拉框
+     * @return
+     */
+    List<SpinnerVO> depotSpinnerList();
 
-    public Depot getDepot(long id)throws Exception {
-        Depot result=null;
-        try{
-            result=depotMapper.selectByPrimaryKey(id);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return result;
-    }
+    Depot getDepot(long id)throws Exception;
 
-    public List<Depot> getDepotListByIds(String ids)throws Exception {
-        List<Long> idList = StringUtil.strToLongList(ids);
-        DepotExample example = new DepotExample();
-        example.createCriteria().andIdIn(idList);
-        return depotMapper.selectByExample(example);
-    }
+    List<Depot> getDepotListByIds(String ids)throws Exception;
 
-    public List<Depot> getDepot()throws Exception {
-        DepotExample example = new DepotExample();
-        example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
-        List<Depot> list=null;
-        try{
-            list=depotMapper.selectByExample(example);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return list;
-    }
+    /**
+     * 获取所有仓库
+     */
+    List<Depot> getDepot()throws Exception;
 
-    public List<Depot> getAllList()throws Exception {
-        DepotExample example = new DepotExample();
-        example.createCriteria().andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
-        example.setOrderByClause("sort asc, id desc");
-        List<Depot> list=null;
-        try{
-            list=depotMapper.selectByExample(example);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return list;
-    }
+    List<Depot> getAllList()throws Exception;
 
-    public List<DepotEx> select(String name, Integer type, String remark)throws Exception {
-        List<DepotEx> list=null;
-        try{
-            PageUtils.startPage();
-            list=depotMapperEx.selectByConditionDepot(name, type, remark);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return list;
-    }
+    List<DepotEx> select(String name, Integer type, String remark)throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int insertDepot(JSONObject obj, HttpServletRequest request)throws Exception {
-        Depot depot = JSONObject.parseObject(obj.toJSONString(), Depot.class);
-        int result=0;
-        try{
-            depot.setType(0);
-            List<Depot> depotList = getDepot();
-            if(depotList.size() == 0) {
-                depot.setIsDefault(true);
-            } else {
-                depot.setIsDefault(false);
-            }
-            depot.setEnabled(true);
-            result=depotMapper.insertSelective(depot);
-            //新增仓库时给当前用户自动授权
-            Long userId = userService.getUserId(request);
-            Long depotId = getIdByName(depot.getName());
-            String ubKey = "[" + depotId + "]";
-            List<UserBusiness> ubList = userBusinessService.getBasicData(userId.toString(), "UserDepot");
-            if(ubList ==null || ubList.size() == 0) {
-                JSONObject ubObj = new JSONObject();
-                ubObj.put("type", "UserDepot");
-                ubObj.put("keyId", userId);
-                ubObj.put("value", ubKey);
-                userBusinessService.insertUserBusiness(ubObj, request);
-            } else {
-                UserBusiness ubInfo = ubList.get(0);
-                JSONObject ubObj = new JSONObject();
-                ubObj.put("id", ubInfo.getId());
-                ubObj.put("type", ubInfo.getType());
-                ubObj.put("keyId", ubInfo.getKeyId());
-                ubObj.put("value", ubInfo.getValue() + ubKey);
-                userBusinessService.updateUserBusiness(ubObj, request);
-            }
-            logService.insertLog("仓库",
-                    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(depot.getName()).toString(), request);
-        }catch(Exception e){
-            JshException.writeFail(logger, e);
-        }
-        return result;
-    }
+    int insertDepot(JSONObject obj, HttpServletRequest request)throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int updateDepot(JSONObject obj, HttpServletRequest request) throws Exception{
-        Depot depot = JSONObject.parseObject(obj.toJSONString(), Depot.class);
-        int result=0;
-        try{
-            result= depotMapper.updateByPrimaryKeySelective(depot);
-            logService.insertLog("仓库",
-                    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(depot.getName()).toString(), request);
-        }catch(Exception e){
-            JshException.writeFail(logger, e);
-        }
-        return result;
-    }
+    int updateDepot(JSONObject obj, HttpServletRequest request) throws Exception;
 
+    /**
+     * 删除仓库
+     * @param id 仓库id
+     */
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int deleteDepot(Long id, HttpServletRequest request)throws Exception {
-        return batchDeleteDepotByIds(id.toString());
-    }
+    int deleteDepot(Long id, HttpServletRequest request)throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int batchDeleteDepot(String ids, HttpServletRequest request) throws Exception{
-        return batchDeleteDepotByIds(ids);
-    }
+    int batchDeleteDepot(String ids, HttpServletRequest request) throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int batchDeleteDepotByIds(String ids)throws Exception {
-        int result=0;
-        String [] idArray=ids.split(",");
-        //校验单据子表	jsh_depot_item
-        List<DepotItem> depotItemList = depotItemMapperEx.getDepotItemListListByDepotIds(idArray);
-        if(depotItemList!=null&&depotItemList.size()>0){
-            logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]",
-                    ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
-            throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
-                    ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
-        }
-        try{
-            //记录日志
-            StringBuffer sb = new StringBuffer();
-            sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE);
-            List<Depot> list = getDepotListByIds(ids);
-            for(Depot depot: list){
-                sb.append("[").append(depot.getName()).append("]");
-            }
-            User userInfo=userService.getCurrentUser();
-            //校验通过执行删除操作
-            //删除仓库关联的商品的初始库存
-            materialInitialStockMapperEx.batchDeleteByDepots(idArray);
-            //删除仓库关联的商品的当前库存
-            materialCurrentStockMapperEx.batchDeleteByDepots(idArray);
-            //删除仓库
-            result = depotMapperEx.batchDeleteDepotByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
-            //记录日志
-            logService.insertLog("仓库", sb.toString(),
-                    ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
-        } catch (Exception e) {
-            JshException.writeFail(logger, e);
-        }
-        return result;
-    }
+    int batchDeleteDepotByIds(String ids)throws Exception;
 
-    public int checkIsNameExist(Long id, String name)throws Exception {
-        DepotExample example = new DepotExample();
-        example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
-        List<Depot> list=null;
-        try{
-            list= depotMapper.selectByExample(example);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return list==null?0:list.size();
-    }
+    int checkIsNameExist(Long id, String name)throws Exception;
 
-    public List<Depot> findUserDepot()throws Exception{
-        DepotExample example = new DepotExample();
-        example.createCriteria().andTypeEqualTo(0).andEnabledEqualTo(true)
-                .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
-        example.setOrderByClause("sort asc, id desc");
-        List<Depot> list=null;
-        try{
-            list= depotMapper.selectByExample(example);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return list;
-    }
+    List<Depot> findUserDepot()throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int updateIsDefault(Long depotId) throws Exception{
-        int result=0;
-        try{
-            //全部取消默认
-            Depot allDepot = new Depot();
-            allDepot.setIsDefault(false);
-            DepotExample allExample = new DepotExample();
-            allExample.createCriteria();
-            depotMapper.updateByExampleSelective(allDepot, allExample);
-            //给指定仓库设为默认
-            Depot depot = new Depot();
-            depot.setIsDefault(true);
-            DepotExample example = new DepotExample();
-            example.createCriteria().andIdEqualTo(depotId);
-            depotMapper.updateByExampleSelective(depot, example);
-            logService.insertLog("仓库",BusinessConstants.LOG_OPERATION_TYPE_EDIT+depotId,
-                    ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
-            result = 1;
-        }catch(Exception e){
-            JshException.writeFail(logger, e);
-        }
-        return result;
-    }
+    int updateIsDefault(Long depotId) throws Exception;
 
-    /**
-     * 根据名称获取id
-     * @param name
-     */
-    public Long getIdByName(String name){
-        Long id = 0L;
-        DepotExample example = new DepotExample();
-        example.createCriteria().andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
-        List<Depot> list = depotMapper.selectByExample(example);
-        if(list!=null && list.size()>0) {
-            id = list.get(0).getId();
-        }
-        return id;
-    }
+    Long getIdByName(String name);
 
+    List<Long> parseDepotList(Long depotId) throws Exception;
 
-    /**
-     * 解析仓库列表
-     * @param depotId 仓库id
-     * @return 仓库id为空,返回当前用户有权限的仓库,不为空返回仓库id的集合
-     */
-    public List<Long> parseDepotList(Long depotId) throws Exception {
-        List<Long> depotList = new ArrayList<>();
-        if(depotId !=null) {
-            depotList.add(depotId);
-        } else {
-            //未选择仓库时默认为当前用户有权限的仓库
-            JSONArray depotArr = findDepotByCurrentUser();
-            for(Object obj: depotArr) {
-                JSONObject object = JSONObject.parseObject(obj.toString());
-                depotList.add(object.getLong("id"));
-            }
-        }
-        return depotList;
-    }
-
-    public JSONArray findDepotByCurrentUser() throws Exception {
-        JSONArray arr = new JSONArray();
-        String type = "UserDepot";
-        Long userId = userService.getCurrentUser().getId();
-        List<Depot> dataList = findUserDepot();
-        //开始拼接json数据
-        if (null != dataList) {
-            boolean depotFlag = systemConfigService.getDepotFlag();
-            if(depotFlag) {
-                List<UserBusiness> list = userBusinessService.getBasicData(userId.toString(), type);
-                if(list!=null && list.size()>0) {
-                    String depotStr = list.get(0).getValue();
-                    if(StringUtil.isNotEmpty(depotStr)){
-                        depotStr = depotStr.replaceAll("\\[", "").replaceAll("]", ",");
-                        String[] depotArr = depotStr.split(",");
-                        for (Depot depot : dataList) {
-                            for(String depotId: depotArr) {
-                                if(depot.getId() == Long.parseLong(depotId)){
-                                    JSONObject item = new JSONObject();
-                                    item.put("id", depot.getId());
-                                    item.put("depotName", depot.getName());
-                                    item.put("isDefault", depot.getIsDefault());
-                                    arr.add(item);
-                                }
-                            }
-                        }
-                    }
-                }
-            } else {
-                for (Depot depot : dataList) {
-                    JSONObject item = new JSONObject();
-                    item.put("id", depot.getId());
-                    item.put("depotName", depot.getName());
-                    item.put("isDefault", depot.getIsDefault());
-                    arr.add(item);
-                }
-            }
-        }
-        return arr;
-    }
+    JSONArray findDepotByCurrentUser() throws Exception;
 
-    /**
-     * 当前用户有权限使用的仓库列表的id,用逗号隔开
-     * @return
-     * @throws Exception
-     */
-    public String findDepotStrByCurrentUser() throws Exception {
-        JSONArray arr =  findDepotByCurrentUser();
-        StringBuffer sb = new StringBuffer();
-        for(Object object: arr) {
-            JSONObject obj = (JSONObject)object;
-            sb.append(obj.getLong("id")).append(",");
-        }
-        String depotStr = sb.toString();
-        if(StringUtil.isNotEmpty(depotStr)){
-            depotStr = depotStr.substring(0, depotStr.length()-1);
-        }
-        return depotStr;
-    }
+    String findDepotStrByCurrentUser() throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int batchSetStatus(Boolean status, String ids)throws Exception {
-        logService.insertLog("仓库",
-                new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ENABLED).toString(),
-                ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
-        List<Long> depotIds = StringUtil.strToLongList(ids);
-        Depot depot = new Depot();
-        depot.setEnabled(status);
-        DepotExample example = new DepotExample();
-        example.createCriteria().andIdIn(depotIds);
-        int result=0;
-        try{
-            result = depotMapper.updateByExampleSelective(depot, example);
-        }catch(Exception e){
-            JshException.writeFail(logger, e);
-        }
-        return result;
-    }
+    int batchSetStatus(Boolean status, String ids)throws Exception;
 }

+ 8 - 0
src/main/java/com/jsh/erp/service/InventoryLogService.java

@@ -0,0 +1,8 @@
+package com.jsh.erp.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.jsh.erp.datasource.entities.InventoryLog;
+
+public interface InventoryLogService extends IService<InventoryLog> {
+
+}

+ 28 - 266
src/main/java/com/jsh/erp/service/MaterialCategoryService.java

@@ -1,301 +1,63 @@
 package com.jsh.erp.service;
 
 import com.alibaba.fastjson.JSONObject;
-import com.jsh.erp.constants.BusinessConstants;
-import com.jsh.erp.constants.ExceptionConstants;
-import com.jsh.erp.datasource.entities.Material;
+import com.baomidou.mybatisplus.extension.service.IService;
 import com.jsh.erp.datasource.entities.MaterialCategory;
-import com.jsh.erp.datasource.entities.MaterialCategoryExample;
-import com.jsh.erp.datasource.entities.User;
-import com.jsh.erp.datasource.mappers.MaterialCategoryMapper;
-import com.jsh.erp.datasource.mappers.MaterialCategoryMapperEx;
-import com.jsh.erp.datasource.mappers.MaterialMapperEx;
 import com.jsh.erp.datasource.vo.TreeNode;
-import com.jsh.erp.exception.BusinessRunTimeException;
-import com.jsh.erp.exception.JshException;
-import com.jsh.erp.utils.PageUtils;
-import com.jsh.erp.utils.StringUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.context.request.ServletRequestAttributes;
 
-import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
-import java.util.Date;
 import java.util.List;
 
-@Service
-public class MaterialCategoryService {
-    private Logger logger = LoggerFactory.getLogger(MaterialCategoryService.class);
+public interface MaterialCategoryService extends IService<MaterialCategory> {
 
-    @Resource
-    private MaterialCategoryMapper materialCategoryMapper;
-    @Resource
-    private MaterialCategoryMapperEx materialCategoryMapperEx;
-    @Resource
-    private UserService userService;
-    @Resource
-    private LogService logService;
-    @Resource
-    private MaterialMapperEx materialMapperEx;
 
-    public MaterialCategory getMaterialCategory(long id)throws Exception {
-        MaterialCategory result=null;
-        try{
-            result=materialCategoryMapper.selectByPrimaryKey(id);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return result;
-    }
+    MaterialCategory getMaterialCategory(long id)throws Exception;
 
-    public List<MaterialCategory> getMaterialCategoryListByIds(String ids)throws Exception {
-        List<Long> idList = StringUtil.strToLongList(ids);
-        List<MaterialCategory> list = new ArrayList<>();
-        try{
-            MaterialCategoryExample example = new MaterialCategoryExample();
-            example.createCriteria().andIdIn(idList);
-            list = materialCategoryMapper.selectByExample(example);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return list;
-    }
+    List<MaterialCategory> getMaterialCategoryListByIds(String ids)throws Exception;
 
-    public List<MaterialCategory> getMaterialCategory()throws Exception {
-        MaterialCategoryExample example = new MaterialCategoryExample();
-        List<MaterialCategory> list=null;
-        try{
-            list=materialCategoryMapper.selectByExample(example);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return list;
-    }
+    List<MaterialCategory> getMaterialCategory()throws Exception;
 
-    public List<MaterialCategory> getAllList(Long parentId)throws Exception {
-        List<MaterialCategory> list=null;
-        try{
-            list = getMCList(parentId);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return list;
-    }
+    List<MaterialCategory> getAllList(Long parentId)throws Exception;
 
-    public List<MaterialCategory> getMCList(Long parentId)throws Exception {
-        List<MaterialCategory> res= new ArrayList<MaterialCategory>();
-        List<MaterialCategory> list=null;
-        MaterialCategoryExample example = new MaterialCategoryExample();
-        example.createCriteria().andParentIdEqualTo(parentId).andIdNotEqualTo(1L);
-        example.setOrderByClause("id");
-        list=materialCategoryMapper.selectByExample(example);
-        if(list!=null && list.size()>0) {
-            res.addAll(list);
-            for(MaterialCategory mc : list) {
-                List<MaterialCategory> mcList = getMCList(mc.getId());
-                if(mcList!=null && mcList.size()>0) {
-                    res.addAll(mcList);
-                }
-            }
-        }
-        return res;
-    }
+    List<MaterialCategory> getMCList(Long parentId)throws Exception;
 
-    public List<MaterialCategory> select(String name, Integer parentId) throws Exception{
-        List<MaterialCategory> list=null;
-        try{
-            PageUtils.startPage();
-            list=materialCategoryMapperEx.selectByConditionMaterialCategory(name, parentId);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return list;
-    }
+    List<MaterialCategory> select(String name, Integer parentId) throws Exception;
 
+    /**
+     * 新增商品类别
+     * @param obj 商品类别数据
+     */
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int insertMaterialCategory(JSONObject obj, HttpServletRequest request)throws Exception {
-        MaterialCategory materialCategory = JSONObject.parseObject(obj.toJSONString(), MaterialCategory.class);
-        materialCategory.setCreateTime(new Date());
-        materialCategory.setUpdateTime(new Date());
-        materialCategory.setSerialNo(materialCategoryMapper.selectMaxId()+10001);
-        int result=0;
-        try{
-            result=materialCategoryMapper.insertSelective(materialCategory);
-            logService.insertLog("商品类型",
-                    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(materialCategory.getName()).toString(), request);
-        }catch(Exception e){
-            JshException.writeFail(logger, e);
-        }
-        return result;
-    }
+    int insertMaterialCategory(JSONObject obj, HttpServletRequest request)throws Exception;
 
+    /**
+     * 修改商品类别
+     * @param obj 商品类别数据
+     */
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int updateMaterialCategory(JSONObject obj, HttpServletRequest request) throws Exception{
-        MaterialCategory materialCategory = JSONObject.parseObject(obj.toJSONString(), MaterialCategory.class);
-        materialCategory.setUpdateTime(new Date());
-        int result=0;
-        try{
-            result=materialCategoryMapperEx.editMaterialCategory(materialCategory);
-            logService.insertLog("商品类型",
-                    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(materialCategory.getName()).toString(), request);
-        }catch(Exception e){
-            JshException.writeFail(logger, e);
-        }
-        return result;
-    }
+    int updateMaterialCategory(JSONObject obj, HttpServletRequest request) throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int deleteMaterialCategory(Long id, HttpServletRequest request)throws Exception {
-        return batchDeleteMaterialCategoryByIds(id.toString());
-    }
+    int deleteMaterialCategory(Long id, HttpServletRequest request)throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int batchDeleteMaterialCategory(String ids, HttpServletRequest request)throws Exception {
-        return batchDeleteMaterialCategoryByIds(ids);
-    }
+    int batchDeleteMaterialCategory(String ids, HttpServletRequest request)throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int batchDeleteMaterialCategoryByIds(String ids) throws Exception {
-        int result=0;
-        String [] idArray=ids.split(",");
-        //校验产品表	jsh_material
-        List<Material> materialList=null;
-        try{
-            materialList= materialMapperEx.getMaterialListByCategoryIds(idArray);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        if(materialList!=null&&materialList.size()>0){
-            logger.error("异常码[{}],异常提示[{}],参数,CategoryIds[{}]",
-                    ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
-            throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
-                    ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
-        }
-        StringBuffer sb = new StringBuffer();
-        sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE);
-        List<MaterialCategory> list = getMaterialCategoryListByIds(ids);
-        for(MaterialCategory materialCategory: list){
-            sb.append("[").append(materialCategory.getName()).append("]");
-        }
-        logService.insertLog("商品类型", sb.toString(),
-                ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
-        //更新时间
-        Date updateDate =new Date();
-        //更新人
-        User userInfo=userService.getCurrentUser();
-        Long updater=userInfo==null?null:userInfo.getId();
-        String strArray[]=ids.split(",");
-        if(strArray.length<1){
-            return 0;
-        }
-        List<MaterialCategory> mcList = materialCategoryMapperEx.getMaterialCategoryListByCategoryIds(idArray);
-        if(mcList!=null && mcList.size()>0) {
-            logger.error("异常码[{}],异常提示[{}]",
-                    ExceptionConstants.MATERIAL_CATEGORY_CHILD_NOT_SUPPORT_DELETE_CODE,ExceptionConstants.MATERIAL_CATEGORY_CHILD_NOT_SUPPORT_DELETE_MSG);
-            throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_CHILD_NOT_SUPPORT_DELETE_CODE,
-                    ExceptionConstants.MATERIAL_CATEGORY_CHILD_NOT_SUPPORT_DELETE_MSG);
-        } else {
-            result=materialCategoryMapperEx.batchDeleteMaterialCategoryByIds(updateDate,updater,strArray);
-        }
-        return result;
-    }
+    int batchDeleteMaterialCategoryByIds(String ids) throws Exception;
 
-    public int checkIsNameExist(Long id, String name)throws Exception {
-        MaterialCategoryExample example = new MaterialCategoryExample();
-        example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
-        List<MaterialCategory> list=null;
-        try{
-            list= materialCategoryMapper.selectByExample(example);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return list==null?0:list.size();
-    }
+    int checkIsNameExist(Long id, String name)throws Exception;
 
-    public List<MaterialCategory> findById(Long id)throws Exception {
-        List<MaterialCategory> list=null;
-        if(id!=null) {
-            MaterialCategoryExample example = new MaterialCategoryExample();
-            example.createCriteria().andIdEqualTo(id);
-            try{
-                list=materialCategoryMapper.selectByExample(example);
-            }catch(Exception e){
-                JshException.readFail(logger, e);
-            }
-        }
-        return list;
-    }
-    /**
-     * description:
-     * 获取商品类别树数据
-     */
-    public List<TreeNode> getMaterialCategoryTree(Long id) throws Exception{
-        List<TreeNode> list=null;
-        try{
-            list=materialCategoryMapperEx.getNodeTree(id);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-       return list;
-    }
-    /**
-     * 根据商品类别编号判断商品类别是否已存在
-     * */
-    public void  checkMaterialCategorySerialNo(MaterialCategory mc)throws Exception {
-        if(mc==null){
-            return;
-        }
-        if( mc.getSerialNo() < 0){
-            return;
-        }
-        //根据商品类别编号查询商品类别
-        List<MaterialCategory> mList=null;
-        try{
-            mList= materialCategoryMapperEx.getMaterialCategoryBySerialNo(mc.getSerialNo(), mc.getId());
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        if(mList==null||mList.size()<1){
-            //未查询到对应数据,编号可用
-            return;
-        }
-        if(mList.size()>1){
-            //查询到的数据条数大于1,编号已存在
-            throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE,
-                    ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG);
-        }
-        if(mc.getId()==null){
-            //新增时,编号已存在
-            throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE,
-                    ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG);
-        }
-        /**
-         * 包装类型用equals来比较
-         * */
-        if(mc.getId().equals(mList.get(0).getId())){
-            //修改时,相同编号,id不同
-            throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE,
-                    ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG);
-        }
-    }
+    List<MaterialCategory> findById(Long id)throws Exception;
+
+    List<TreeNode> getMaterialCategoryTree(Long id) throws Exception;
+
+    void  checkMaterialCategorySerialNo(MaterialCategory mc)throws Exception;
 
     /**
      * 根据名称获取类型
      * @param name
      */
-    public Long getCategoryIdByName(String name){
-        Long categoryId = null;
-        MaterialCategoryExample example = new MaterialCategoryExample();
-        example.createCriteria().andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
-        List<MaterialCategory> list = materialCategoryMapper.selectByExample(example);
-        if(list!=null && list.size()>0) {
-            categoryId = list.get(0).getId();
-        }
-        return categoryId;
-    }
+    Long getCategoryIdByName(String name);
 }

+ 9 - 0
src/main/java/com/jsh/erp/service/MaterialExtendService.java

@@ -20,6 +20,10 @@ public interface MaterialExtendService extends IService<MaterialExtend> {
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     String saveDetials(JSONObject obj, String sortList, Long materialId, String type) throws Exception;
 
+    /**
+     *  添加商品子信息
+     * @param materialExtend 商品子信息
+     */
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     int insertMaterialExtend(MaterialExtend materialExtend)throws Exception;
 
@@ -54,4 +58,9 @@ public interface MaterialExtendService extends IService<MaterialExtend> {
     int getCountByManyBarCodeWithoutUs(String manyBarCode, String barCode);
 
     MaterialExtend getInfoByBatchNumber(String batchNumber)throws Exception;
+
+    /**
+     * 修改子商品库存
+     */
+    void updateInventory(String type, Long id,MaterialExtend materialExtend) throws Exception;
 }

+ 27 - 1
src/main/java/com/jsh/erp/service/MaterialService.java

@@ -5,6 +5,10 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.jsh.erp.datasource.entities.*;
+import com.jsh.erp.datasource.pda.dto.PDAInventoryDTO;
+import com.jsh.erp.datasource.pda.vo.PDADepotItemVO;
+import com.jsh.erp.datasource.vo.MaterialCurrentStock4SystemSku;
+import com.jsh.erp.datasource.pda.vo.PDATypeTree;
 import com.jsh.erp.datasource.vo.MaterialWarnListVo;
 import com.jsh.erp.utils.BaseResponseInfo;
 import org.springframework.transaction.annotation.Transactional;
@@ -36,6 +40,10 @@ public interface MaterialService extends IService<Material> {
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     int insertMaterial(JSONObject obj, HttpServletRequest request)throws Exception;
 
+    /**
+     * 修改商品
+     * @param obj
+     */
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     int updateMaterial(JSONObject obj, HttpServletRequest request) throws Exception;
 
@@ -169,12 +177,30 @@ public interface MaterialService extends IService<Material> {
 
     List<MaterialVo4Unit> getMaterialBySystemSku(List<String> systemSkuList);
 
+    List<MaterialCurrentStock4SystemSku> getMaterialCurrentPriceByIdList(List<Long> idList);
+
     /**
      * 获取商品提醒
      * @return
      */
     MaterialWarnListVo getMaterialWarn();
 
-    //导入表格
+    /**
+     * 导入商品信息
+     * @param file excel表格
+     * @return
+     */
     BaseResponseInfo importExcelTwo(MultipartFile file, HttpServletRequest request) throws Exception;
+
+    /**
+     * PDA库存查询
+     * pdaInventoryDTO
+     * @return
+     */
+    List<PDADepotItemVO> inventoryInquiry(PDAInventoryDTO pdaInventoryDTO) throws Exception;
+
+    /**
+     * 查询库位树
+     */
+    List<PDATypeTree> selectPosition();
 }

+ 2 - 0
src/main/java/com/jsh/erp/service/SupplierService.java

@@ -41,6 +41,8 @@ public interface SupplierService extends IService<Supplier> {
 
     int checkIsNameAndTypeExist(Long id, String name, String type)throws Exception;
 
+    int checkIsTelephoneAndTypeExist(Long id, String telephone, String type);
+
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     void updateAdvanceIn(Long supplierId);
 

+ 139 - 4
src/main/java/com/jsh/erp/service/SyncTescoSystemService.java

@@ -4,34 +4,38 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.jsh.erp.constants.ExceptionConstants;
-import com.jsh.erp.datasource.entities.DepotHeadVo4Body;
 import com.jsh.erp.datasource.entities.MaterialVo4Unit;
 import com.jsh.erp.datasource.entities.Supplier;
 import com.jsh.erp.datasource.entities.Unit;
+import com.jsh.erp.datasource.mappers.MaterialCurrentStockMapperEx;
 import com.jsh.erp.datasource.tesco.request.ErpXsddReqVO;
 import com.jsh.erp.datasource.vo.DepotHeadXsddRequestVO;
 import com.jsh.erp.datasource.vo.DepotItemXsddRequestVO;
 import com.jsh.erp.datasource.vo.Material4UnitPrice;
+import com.jsh.erp.datasource.vo.MaterialCurrentStock4SystemSku;
 import com.jsh.erp.exception.BusinessRunTimeException;
+import com.jsh.erp.utils.HttpClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 /**
- * @Description TODO
  * @Author MS.BLUE
  * @Date 2025-04-12
  */
@@ -52,6 +56,18 @@ public class SyncTescoSystemService {
     @Resource
     private SupplierService supplierService;
 
+    @Resource
+    private MaterialCurrentStockMapperEx materialCurrentStockMapperEx;
+
+    @Value("${tesco.openSycn}")
+    private boolean openSycn;
+    
+    @Value("${tesco.sycnErpMaterialStockUrl}")
+    private String sycnErpMaterialStockUrl;
+
+    @Value("${tesco.sycnErpMaterialPriceUrl}")
+    private String sycnErpMaterialPriceUrl;
+
     public String syncSystemSku(String param) {
         logger.info("获取商品系统sku,返回信息集采系统 param:{}", param);
         JSONObject result = new JSONObject();
@@ -176,6 +192,124 @@ public class SyncTescoSystemService {
         return result.toJSONString();
     }
 
+    public String sycnTescoStock(Long mId){
+        return sycnTescoStock(Arrays.asList(mId));
+    }
+
+    public String sycnTescoStock(List<Long> mIdList) {
+        if (!openSycn) {
+            return "tesco系统同步未开启";
+        }
+        List<MaterialCurrentStock4SystemSku> stockList = materialCurrentStockMapperEx.getCurrentStockMapByMdIdList(mIdList);
+        if (!CollectionUtils.isEmpty(stockList)) {
+            try {
+                for (MaterialCurrentStock4SystemSku stock : stockList) {
+                    Unit unitInfo = new Unit(); // 查询多单位信息
+                    stock.setBasicUnit(stock.getUnit());
+                    stock.setBasicUnitTotalStock(stock.getBasicUnitTotalStock().setScale(0, RoundingMode.DOWN));
+                    if (stock.getUnitId() != null) {
+                        unitInfo = materialService.findUnit(stock.getMId());
+                        stock.setBasicUnit(unitInfo.getBasicUnit());
+                        stock.setLargeUnit(true);
+                        processOtherUnitStock(stock, unitInfo);
+                    }
+                }
+                String jsonParam = new ObjectMapper().writeValueAsString(stockList);
+                logger.info("同步集采库存请求参数:{}", jsonParam);
+                String response = HttpClient.httpPost(sycnErpMaterialStockUrl, jsonParam);
+                logger.info("同步集采库存响应:{}", response);
+                return jsonParam;
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+
+        }
+        return null;
+    }
+
+    private void processOtherUnitStock(MaterialCurrentStock4SystemSku stock, Unit unitInfo) {
+        if (StringUtils.isNotEmpty(unitInfo.getOtherUnit())) {
+            BigDecimal otherUnitTotalStock = stock.getBasicUnitTotalStock().divide(unitInfo.getRatio(), 0, RoundingMode.DOWN);
+            String otherUnitStr = "1" + unitInfo.getOtherUnit() + "=" + unitInfo.getRatio().setScale(0, RoundingMode.DOWN) + unitInfo.getBasicUnit();
+            stock.setOtherUnit(otherUnitStr);
+            stock.setRatio(unitInfo.getRatio().setScale(0, RoundingMode.DOWN));
+            stock.setOtherUnitTotalStock(otherUnitTotalStock);
+
+            if (StringUtils.isNotEmpty(unitInfo.getOtherUnitTwo())) {
+                BigDecimal otherUnitTwoTotalStock = stock.getBasicUnitTotalStock().divide(unitInfo.getRatioTwo(), 0, RoundingMode.DOWN);
+                String otherUnitTwoStr = "1" + unitInfo.getOtherUnitTwo() + "=" + unitInfo.getRatioTwo().setScale(0, RoundingMode.DOWN) + unitInfo.getBasicUnit();
+                stock.setOtherUnitTwo(otherUnitTwoStr);
+                stock.setRatioTwo(unitInfo.getRatioTwo().setScale(0, RoundingMode.DOWN));
+                stock.setOtherUnitTwoTotalStock(otherUnitTwoTotalStock);
+
+                if (StringUtils.isNotEmpty(unitInfo.getOtherUnitThree())) {
+                    BigDecimal otherUnitThreeTotalStock = stock.getBasicUnitTotalStock().divide(unitInfo.getRatioThree(), 0, RoundingMode.DOWN);
+                    String otherUnitThreeStr = "1" + unitInfo.getOtherUnitThree() + "=" + unitInfo.getRatioThree().setScale(0, RoundingMode.DOWN) + unitInfo.getBasicUnit();
+                    stock.setOtherUnitTwo(otherUnitThreeStr);
+                    stock.setRatioThree(unitInfo.getRatioThree().setScale(0, RoundingMode.DOWN));
+                    stock.setOtherUnitThreeTotalStock(otherUnitThreeTotalStock);
+                }
+            }
+        }
+    }
+
+    public String sycnTescoSalePrice(List<Long> mIdList) {
+        if (!openSycn) {
+            return "tesco系统同步未开启";
+        }
+        try {
+            List<MaterialCurrentStock4SystemSku> mList = materialService.getMaterialCurrentPriceByIdList(mIdList);
+            if (!CollectionUtils.isEmpty(mList)) {
+                for (MaterialCurrentStock4SystemSku material : mList){
+                    Unit unitInfo = new Unit(); // 查询多单位信息
+                    material.setBasicUnit(material.getUnit());
+                    if (material.getUnitId() != null) {
+                        unitInfo = materialService.findUnit(material.getMId());
+                        material.setBasicUnit(unitInfo.getBasicUnit());
+                        material.setLargeUnit(true);
+
+                        processOtherUnitSalePrice(material, unitInfo);
+                    }
+                }
+
+                String jsonParam = new ObjectMapper().writeValueAsString(mList);
+                logger.info("同步集采销售价格请求参数:{}", jsonParam);
+                String response = HttpClient.httpPost(sycnErpMaterialPriceUrl, jsonParam);
+                logger.info("同步集采销售价格响应:{}", response);
+                return jsonParam;
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        return null;
+    }
+
+    private void processOtherUnitSalePrice(MaterialCurrentStock4SystemSku stock, Unit unitInfo) {
+        if (StringUtils.isNotEmpty(unitInfo.getOtherUnit())) {
+            BigDecimal otherUnitSalePrice = stock.getBasicUnitSalePrice().multiply(unitInfo.getRatio());
+            String otherUnitStr = "1" + unitInfo.getOtherUnit() + "=" + unitInfo.getRatio().setScale(0, RoundingMode.DOWN) + unitInfo.getBasicUnit();
+            stock.setOtherUnit(otherUnitStr);
+            stock.setRatio(unitInfo.getRatio().setScale(0, RoundingMode.DOWN));
+            stock.setOtherUnitSalePrice(otherUnitSalePrice);
+
+            if (StringUtils.isNotEmpty(unitInfo.getOtherUnitTwo())) {
+                BigDecimal otherUnitTwoSalePrice = stock.getBasicUnitSalePrice().multiply(unitInfo.getRatioTwo());
+                String otherUnitTwoStr = "1" + unitInfo.getOtherUnitTwo() + "=" + unitInfo.getRatioTwo().setScale(0, RoundingMode.DOWN) + unitInfo.getBasicUnit();
+                stock.setOtherUnitTwo(otherUnitTwoStr);
+                stock.setRatioTwo(unitInfo.getRatioTwo().setScale(0, RoundingMode.DOWN));
+                stock.setOtherUnitTwoSalePrice(otherUnitTwoSalePrice);
+
+                if (StringUtils.isNotEmpty(unitInfo.getOtherUnitThree())) {
+                    BigDecimal otherUnitThreeSalePrice = stock.getBasicUnitSalePrice().multiply(unitInfo.getRatioThree());
+                    String otherUnitThreeStr = "1" + unitInfo.getOtherUnitThree() + "=" + unitInfo.getRatioThree().setScale(0, RoundingMode.DOWN) + unitInfo.getBasicUnit();
+                    stock.setOtherUnitTwo(otherUnitThreeStr);
+                    stock.setRatioThree(unitInfo.getRatioThree().setScale(0, RoundingMode.DOWN));
+                    stock.setOtherUnitThreeSalePrice(otherUnitThreeSalePrice);
+                }
+            }
+        }
+    }
+
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     private void buildOrderAndItem(ErpXsddReqVO erpXsddReqVO) throws Exception {
         // 1. 初始化订单基本信息
@@ -200,6 +334,7 @@ public class SyncTescoSystemService {
         if (supplier == null) {
             // 如果客户不存在,创建新客户
             supplier = new Supplier();
+            supplier.setEnabled(true);
             supplier.setSupplier(customer.getName());
             supplier.setTelephone(customer.getAccount());
             supplier.setContacts(customer.getReceiverName());
@@ -469,7 +604,7 @@ public class SyncTescoSystemService {
         item.setUnitPrice(unitPrice);
         item.setTaxRate(BigDecimal.ONE);
         item.setTaxMoney(BigDecimal.ZERO);
-        item.setBatchNumber("");
+        item.setBatchNumber(material.getBatchNumber());
         item.setTaxLastMoney(unitPrice.multiply(operNumber));
         item.setAllPrice(unitPrice.multiply(operNumber));
         return item;

+ 5 - 0
src/main/java/com/jsh/erp/service/TaskStocktakingItemService.java

@@ -2,6 +2,11 @@ package com.jsh.erp.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.jsh.erp.datasource.entities.TaskStocktakingItem;
+import com.jsh.erp.datasource.vo.SpinnerVO;
+
+import java.util.List;
 
 public interface TaskStocktakingItemService extends IService<TaskStocktakingItem> {
+
+    List<SpinnerVO> creatorSpinnerList(Long taskId);
 }

+ 7 - 4
src/main/java/com/jsh/erp/service/TaskStocktakingService.java

@@ -2,7 +2,10 @@ package com.jsh.erp.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.jsh.erp.datasource.dto.TaskStocktakingDTO;
+import com.jsh.erp.datasource.dto.TaskStocktakingItemQueryDTO;
+import com.jsh.erp.datasource.dto.TaskStocktakingQueryDTO;
 import com.jsh.erp.datasource.entities.TaskStocktaking;
+import com.jsh.erp.datasource.pda.dto.PDATaskStocktakingItemDTO;
 import com.jsh.erp.datasource.pda.vo.PDATaskStocktakingItemVO;
 import com.jsh.erp.datasource.pda.vo.PDATaskStocktakingVO;
 import com.jsh.erp.datasource.vo.TaskStocktakingItemVO;
@@ -16,7 +19,7 @@ public interface TaskStocktakingService extends IService<TaskStocktaking> {
      *
      * @return
      */
-    List<TaskStocktakingVO> listBy();
+    List<TaskStocktakingVO> listBy(TaskStocktakingQueryDTO taskStocktakingQueryDTO);
 
     /**
      * 新增任务
@@ -40,10 +43,10 @@ public interface TaskStocktakingService extends IService<TaskStocktaking> {
 
     /**
      * 任务详情-商品明细
-     * @param taskStocktakingId 盘点任务ID
+     * @param taskStocktakingItemQueryDTO 筛选参数
      * @return
      */
-    List<TaskStocktakingItemVO> listByTaskStocktakingId(Long taskStocktakingId);
+    List<TaskStocktakingItemVO> listByTaskStocktakingId(TaskStocktakingItemQueryDTO taskStocktakingItemQueryDTO);
 
     /**
      * PDA-盘点任务列表
@@ -61,7 +64,7 @@ public interface TaskStocktakingService extends IService<TaskStocktaking> {
      */
     TaskStocktakingVO pdaDetail(Long id) throws Exception;
 
-    List<PDATaskStocktakingItemVO> pdaItemList(Long taskId);
+    List<PDATaskStocktakingItemVO> pdaItemList(PDATaskStocktakingItemDTO pdaTaskStocktakingItemDTO);
 
 
 }

+ 1 - 0
src/main/java/com/jsh/erp/service/UserBusinessService.java

@@ -80,6 +80,7 @@ public class UserBusinessService {
             String value = userBusiness.getValue();
             String newValue = value.replaceAll(",","\\]\\[");
             newValue = newValue.replaceAll("\\[0\\]","").replaceAll("\\[\\]","");
+            newValue = newValue.replace("\"", "");
             userBusiness.setValue(newValue);
             result=userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
             logService.insertLog("关联关系", BusinessConstants.LOG_OPERATION_TYPE_EDIT, request);

+ 17 - 0
src/main/java/com/jsh/erp/service/impl/ApkVersionServiceImpl.java

@@ -0,0 +1,17 @@
+package com.jsh.erp.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jsh.erp.datasource.entities.ApkVersion;
+import com.jsh.erp.datasource.mappers.ApkVersionMapper;
+import com.jsh.erp.service.ApkVersionService;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+
+@Service
+@RequiredArgsConstructor
+@Slf4j
+public class ApkVersionServiceImpl extends ServiceImpl<ApkVersionMapper, ApkVersion> implements ApkVersionService {
+
+}

+ 70 - 3
src/main/java/com/jsh/erp/service/impl/DepotHeadServiceImpl.java

@@ -5,12 +5,16 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.jsh.erp.constants.BusinessConstants;
 import com.jsh.erp.constants.ExceptionConstants;
 import com.jsh.erp.datasource.entities.*;
 import com.jsh.erp.datasource.mappers.DepotHeadMapper;
 import com.jsh.erp.datasource.mappers.DepotHeadMapperEx;
 import com.jsh.erp.datasource.mappers.DepotItemMapperEx;
+import com.jsh.erp.datasource.mappers.MaterialCurrentStockMapper;
+import com.jsh.erp.datasource.mappers.MaterialCurrentStockMapperEx;
 import com.jsh.erp.datasource.pda.dto.PDADepotHeadDTO;
 import com.jsh.erp.datasource.pda.dto.PDADepotMaterialDto;
 import com.jsh.erp.datasource.pda.vo.PDADepotHeadVO;
@@ -22,6 +26,7 @@ import com.jsh.erp.query.QueryWrapperX;
 import com.jsh.erp.service.*;
 import com.jsh.erp.util.QRCodeGenerator;
 import com.jsh.erp.utils.ExcelUtils;
+import com.jsh.erp.utils.HttpClient;
 import com.jsh.erp.utils.PageUtils;
 import com.jsh.erp.utils.StringUtil;
 import com.jsh.erp.utils.Tools;
@@ -92,6 +97,8 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
     private MaterialService materialService;
     @Resource
     private MaterialExtendService materialExtendService;
+    @Resource
+    private SyncTescoSystemService syncTescoSystemService;
 
     /**
      * PDA查询订单
@@ -104,6 +111,11 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
     }
 
     @Override
+    public PDADepotHeadVO pdaDetail(Long id) {
+        return depotHeadMapper.pdaDetail(id);
+    }
+
+    @Override
     public DepotHead getDepotHead(long id)throws Exception {
         DepotHead result=null;
         try{
@@ -1006,7 +1018,10 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
                 if(materialsListMap!=null) {
                     dh.setMaterialsList(materialsListMap.get(dh.getId()));
                 }
-                dh.setCreatorName(userService.getUser(dh.getCreator()).getUsername());
+                User creatorUser = userService.getUser(dh.getCreator());
+                if(creatorUser != null){
+                    dh.setCreatorName(creatorUser.getUsername());
+                }
                 resList.add(dh);
             }
         }catch(Exception e){
@@ -1150,7 +1165,6 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
                         String.format(ExceptionConstants.DEPOT_HEAD_FILE_NUM_LIMIT_MSG, 4));
             }
         }
-        //生成订单二维码
         JSONArray rowArr = JSONArray.parseArray(rows);
         //商品数量
         int operNumber = 0;
@@ -1184,6 +1198,8 @@ 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));
         }
         logService.insertLog("单据",
                 new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(depotHead.getNumber()).toString(),
@@ -1272,6 +1288,10 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
         depotHead.setGoodsQuantity(operNumber);
         //商品总类
         depotHead.setGoodsTypeCount(rowArr.size());
+        //修改时间
+        depotHead.setOperTime(new Date());
+        //修改操作人
+        depotHead.setOperId(userService.getCurrentUser().getId());
         //修改单据主表
         depotHeadMapper.updateByPrimaryKeySelective(depotHead);
         //如果存在多账户结算需要将原账户的id置空
@@ -1297,6 +1317,7 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
         }
         /**入库和出库处理单据子表信息*/
         depotItemService.saveDetials(rows,depotHead.getId(), "update",request);
+        updateTotalPriceById(depotHead);
         logService.insertLog("单据",
                 new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(depotHead.getNumber()).toString(),
                 ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
@@ -1841,11 +1862,17 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
             Long headId = list.get(0).getId();
             /** 销售订单 单据子表信息 */
             depotItemService.saveOrderItem(depotHead, depotItemList);
+            List<Long> mIdList = depotItemList.stream().map(DepotItemXsddRequestVO::getMaterialId).collect(Collectors.toList());
+            //同步集采库存
+            syncTescoSystemService.sycnTescoStock(mIdList);
         }
+
         logService.insertLog("销售订单", new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(depotHead.getNumber()).toString(), ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest());
         return "";
     }
 
+
+
     /**
      * 根据商品id获取最后一条销售订单
      * @param mid 商品id
@@ -1871,6 +1898,8 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
         List<DepotItem> depotItems = depotItemService.getListByHeaderId(depotHead.getId());
         //设置单据主表信息
         depotHead.setId(null);
+        //设置关联订单
+        depotHead.setLinkNumber(depotHead.getNumber());
         String number = sequenceService.buildOnlyNumber();
         //设置单号
         if ("采购订单".equals(depotHead.getSubType())){
@@ -1903,9 +1932,11 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
             }
         }
         //判断用户是否已经登录过,登录过不再处理
-        User userInfo=userService.getCurrentUser();
+        User userInfo = userService.getCurrentUser();
         depotHead.setCreator(userInfo==null?null:userInfo.getId());
         depotHead.setCreateTime(new Timestamp(System.currentTimeMillis()));
+        depotHead.setOperId(userInfo==null?null:userInfo.getId());
+        depotHead.setOperTime(new Timestamp(System.currentTimeMillis()));
         if(StringUtil.isEmpty(depotHead.getStatus())) {
             depotHead.setStatus(BusinessConstants.BILLS_STATUS_UN_AUDIT);
         }
@@ -1950,6 +1981,7 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
         User user = userService.getCurrentUser();
         depotHead.setTenantId(user.getId());
         depotHead.setCreateTime(new Timestamp(System.currentTimeMillis()));
+        depotHead.setStatus("2");
         //添加主表
         depotHeadMapper.insertSelective(depotHead);
         //根据单据编号查询单据id
@@ -1992,14 +2024,49 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
                 }
             }
             depotItem.setWarehousingUser(user.getId());
+            //基本单位数量*单价
+            depotItem.setAllPrice(depotItem.getBasicNumber().multiply(depotItem.getUnitPrice()));
+            //单价总额 + 税额
+            depotItem.setTaxLastMoney(depotItem.getAllPrice().add(depotItem.getTaxMoney()));
             //添加单据子表
             depotItemService.insertDepotItemWithObj(depotItem);
+            if(BusinessConstants.DEPOTHEAD_TYPE_IN.equals(depotHead.getType())){
+                //表单入库,修改商品库存
+                materialExtend.setInventory(materialExtend.getInventory().add(depotItem.getBasicNumber()));
+                materialExtendService.updateInventory("单据",depotItem.getId(),materialExtend);
+            }else if(BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())){
+                //表单入库,修改商品库存
+                materialExtend.setInventory(materialExtend.getInventory().subtract(depotItem.getBasicNumber()));
+                materialExtendService.updateInventory("单据",depotItem.getId(),materialExtend);
+            }
+            //更新当前库存
+            depotItemService.updateCurrentStock(depotItem);
+            //更新当前成本价
+            depotItemService.updateCurrentUnitPrice(depotItem);
             //修改商品生产日期
             materialExtendService.update(new UpdateWrapper<MaterialExtend>().set("production_date",materialMap.get(batchNumber).getProductionDate()).eq("id", materialExtend.getId()));
+            updateTotalPriceById(depotHead);
         }
         //修改采购订单状态完成
         this.update(new UpdateWrapper<DepotHead>().set("status", "2").eq("id", pdaDepotHeadDTO.getId()));
         return true;
     }
 
+    /**
+     * 修改订单总额
+     */
+    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();
+        }
+        update(new UpdateWrapper<DepotHead>().set("total_price",totalPrice).set("change_amount",totalPrice).set("discount_last_money",sum).eq("id",list.get(0).getId()));
+    }
+
 }

+ 89 - 24
src/main/java/com/jsh/erp/service/impl/DepotItemServiceImpl.java

@@ -2,6 +2,8 @@ package com.jsh.erp.service.impl;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jsh.erp.constants.BusinessConstants;
 import com.jsh.erp.constants.ExceptionConstants;
@@ -18,6 +20,7 @@ import com.jsh.erp.exception.BusinessRunTimeException;
 import com.jsh.erp.exception.JshException;
 import com.jsh.erp.query.LambdaQueryWrapperX;
 import com.jsh.erp.service.*;
+import com.jsh.erp.utils.HttpClient;
 import com.jsh.erp.utils.StringUtil;
 import com.jsh.erp.utils.Tools;
 import org.slf4j.Logger;
@@ -74,6 +77,9 @@ public class DepotItemServiceImpl extends ServiceImpl<DepotItemMapper, DepotItem
     @Resource
     private MaterialExtendMapper materialExtendMapper;
 
+    @Resource
+    private SyncTescoSystemService syncTescoSystemService;
+
     /**
      * pda根据订单信息查询商品列表
      * @return
@@ -100,7 +106,7 @@ public class DepotItemServiceImpl extends ServiceImpl<DepotItemMapper, DepotItem
      */
     @Override
     public List<PDADepotItemVO> materialDepotDetail(String type , Long materialId) {
-        return depotItemMapper.materialDepotDetail(type , materialId);
+        return depotItemMapper.materialDepotDetail(type, materialId);
     }
 
     @Override
@@ -259,6 +265,7 @@ public class DepotItemServiceImpl extends ServiceImpl<DepotItemMapper, DepotItem
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     public int insertDepotItemWithObj(DepotItem depotItem)throws Exception {
         User user = userService.getCurrentUser();
+        depotItem.setCreateTime(new Date());
         depotItem.setTenantId(user.getId());
         int result =0;
         try{
@@ -498,7 +505,7 @@ public class DepotItemServiceImpl extends ServiceImpl<DepotItemMapper, DepotItem
                 depotItem.setWarehousingVariance(rowObj.getBigDecimal("warehousingVariance"));
                 depotItem.setReasonOfDifference(rowObj.getString("reasonOfDifference"));
                 depotItem.setWarehousingUser(rowObj.getLong("warehousingUser"));
-                depotItem.setWarehousingTime(rowObj.getDate("warehousingTime"));
+                depotItem.setWarehousingTime(rowObj.getString("warehousingTime"));
                 Material material= materialService.getMaterial(depotItem.getMaterialId());
                 if (BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED.equals(material.getEnableSerialNumber()) ||
                         BusinessConstants.ENABLE_BATCH_NUMBER_ENABLED.equals(material.getEnableBatchNumber())) {
@@ -596,7 +603,8 @@ public class DepotItemServiceImpl extends ServiceImpl<DepotItemMapper, DepotItem
                     depotItem.setOperNumber(rowObj.getBigDecimal("operNumber"));
                     //获取子表单商品单位
                     String unit = rowObj.get("unit") == null ? "" :rowObj.get("unit").toString();
-                    BigDecimal oNumber = rowObj.getBigDecimal("operNumber");
+                    //获取实际出入库数量
+                    BigDecimal oNumber = rowObj.getBigDecimal("actualQuantityInStorage");
                     if (StringUtil.isNotEmpty(unitInfo.getName())) {
                         String basicUnit = unitInfo.getBasicUnit(); //基本单位
                         if (unit.equals(basicUnit)) { //如果等于基本单位
@@ -679,11 +687,18 @@ public class DepotItemServiceImpl extends ServiceImpl<DepotItemMapper, DepotItem
                         depotItem.setPurchaseUnitPrice(getDepotItemByBatchNumber(depotItem.getMaterialExtendId(),depotItem.getBatchNumber()).getUnitPrice());
                     }
                 }
+                //含税单价
                 if (StringUtil.isExist(rowObj.get("taxUnitPrice"))) {
                     depotItem.setTaxUnitPrice(rowObj.getBigDecimal("taxUnitPrice"));
                 }
+                //总金额,不含税
                 if (StringUtil.isExist(rowObj.get("allPrice"))) {
-                    depotItem.setAllPrice(rowObj.getBigDecimal("allPrice"));
+                    if (depotItem.getActualQuantityInStorage() == null || depotItem.getActualQuantityInStorage().equals(BigDecimal.ZERO)){
+                        depotItem.setAllPrice(rowObj.getBigDecimal("allPrice"));
+                    }else {
+                        //基本单位数量*单价
+                        depotItem.setAllPrice(depotItem.getBasicNumber().multiply(depotItem.getUnitPrice()));
+                    }
                 }
                 if (StringUtil.isExist(rowObj.get("depotId"))) {
                     depotItem.setDepotId(rowObj.getLong("depotId"));
@@ -708,14 +723,24 @@ public class DepotItemServiceImpl extends ServiceImpl<DepotItemMapper, DepotItem
                                 String.format(ExceptionConstants.DEPOT_HEAD_ANOTHER_DEPOT_FAILED_MSG));
                     }
                 }
+                //税率
                 if (StringUtil.isExist(rowObj.get("taxRate"))) {
                     depotItem.setTaxRate(rowObj.getBigDecimal("taxRate"));
                 }
+                //税额
                 if (StringUtil.isExist(rowObj.get("taxMoney"))) {
-                    depotItem.setTaxMoney(rowObj.getBigDecimal("taxMoney"));
+                    if (depotItem.getActualQuantityInStorage() == null || depotItem.getActualQuantityInStorage().equals(BigDecimal.ZERO)){
+                        depotItem.setTaxMoney(rowObj.getBigDecimal("taxMoney"));
+                    }else {
+                        //单价总金额*税率
+                        depotItem.setTaxMoney(depotItem.getAllPrice().multiply(depotItem.getTaxRate()));
+                    }
                 }
+                //价税合计
                 if (StringUtil.isExist(rowObj.get("taxLastMoney"))) {
-                    depotItem.setTaxLastMoney(rowObj.getBigDecimal("taxLastMoney"));
+                    //单价总额 + 税额
+                    depotItem.setTaxLastMoney(depotItem.getAllPrice().add(depotItem.getTaxMoney()));
+                    //depotItem.setTaxLastMoney(rowObj.getBigDecimal("taxLastMoney"));
                 }
                 if (StringUtil.isExist(rowObj.get("mType"))) {
                     depotItem.setMaterialType(rowObj.getString("mType"));
@@ -764,6 +789,15 @@ public class DepotItemServiceImpl extends ServiceImpl<DepotItemMapper, DepotItem
                         }
                     }
                 }
+                if(BusinessConstants.DEPOTHEAD_TYPE_IN.equals(depotHead.getType())){
+                    //表单入库,修改商品库存
+                    materialExtend.setInventory(materialExtend.getInventory().add(depotItem.getBasicNumber()));
+                    materialExtendService.updateInventory("单据",depotItem.getId(),materialExtend);
+                }else if(BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())){
+                    //表单入库,修改商品库存
+                    materialExtend.setInventory(materialExtend.getInventory().subtract(depotItem.getBasicNumber()));
+                    materialExtendService.updateInventory("单据",depotItem.getId(),materialExtend);
+                }
                 this.insertDepotItemWithObj(depotItem);
                 //更新当前库存
                 updateCurrentStock(depotItem);
@@ -814,6 +848,29 @@ public class DepotItemServiceImpl extends ServiceImpl<DepotItemMapper, DepotItem
             for (DepotItemXsddRequestVO item : itemList) {
                 DepotItem depotItem = new DepotItem();
                 BeanUtils.copyProperties(item, depotItem);
+                // 以下进行单位换算
+                Unit unitInfo = materialService.findUnit(depotItem.getMaterialId()); // 查询多单位信息
+                if (depotItem.getOperNumber() != null) {
+                    // 获取子表单商品单位
+                    String unit = depotItem.getMaterialUnit() == null ? "" : depotItem.getMaterialUnit();
+                    BigDecimal oNumber = depotItem.getOperNumber();
+                    if (StringUtil.isNotEmpty(unitInfo.getName())) {
+                        String basicUnit = unitInfo.getBasicUnit(); // 基本单位
+                        if (unit.equals(basicUnit)) { // 如果等于基本单位
+                            depotItem.setBasicNumber(oNumber); // 数量一致
+                        } else if (unit.equals(unitInfo.getOtherUnit())) { // 如果等于副单位
+                            depotItem.setBasicNumber(oNumber.multiply(unitInfo.getRatio())); // 数量乘以比例
+                        } else if (unit.equals(unitInfo.getOtherUnitTwo())) { // 如果等于副单位2
+                            depotItem.setBasicNumber(oNumber.multiply(unitInfo.getRatioTwo())); // 数量乘以比例
+                        } else if (unit.equals(unitInfo.getOtherUnitThree())) { // 如果等于副单位3
+                            depotItem.setBasicNumber(oNumber.multiply(unitInfo.getRatioThree())); // 数量乘以比例
+                        } else {
+                            depotItem.setBasicNumber(oNumber); // 数量一致
+                        }
+                    } else {
+                        depotItem.setBasicNumber(oNumber); // 其他情况
+                    }
+                }
                 depotItem.setHeaderId(depotHead.getId());
                 this.insertDepotItem(depotItem);
                 // 更新当前库存
@@ -1140,7 +1197,7 @@ public class DepotItemServiceImpl extends ServiceImpl<DepotItemMapper, DepotItem
             stockSum = inTotal.add(transfInTotal).add(assemInTotal).add(disAssemInTotal)
                     .subtract(outTotal).subtract(transfOutTotal).subtract(assemOutTotal).subtract(disAssemOutTotal);
         }
-        return initStock.add(stockCheckSum).add(inventory).add(stockSum);
+        return initStock.add(stockCheckSum).add(inventory);
     }
 
     /**
@@ -1273,26 +1330,17 @@ public class DepotItemServiceImpl extends ServiceImpl<DepotItemMapper, DepotItem
     @Override
     public void updateCurrentStockFun(Long mId, Long dId) throws Exception {
         if(mId!=null && dId!=null) {
-            MaterialCurrentStockExample example = new MaterialCurrentStockExample();
-            //条件 添加商品id,仓库id ,删除状态
-            example.createCriteria().andMaterialIdEqualTo(mId).andDepotIdEqualTo(dId)
-                    .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_EXISTS);
-            //获取商品当前库存信息
-            List<MaterialCurrentStock> list = materialCurrentStockMapper.selectByExample(example);
+            //-先清除再插入,防止商品仓库变更,数据对不上
+            materialCurrentStockMapper.delete(new LambdaQueryWrapperX<MaterialCurrentStock>().eq(MaterialCurrentStock::getMaterialId,mId).eqIfPresent(MaterialCurrentStock::getDepotId,dId));
             MaterialCurrentStock materialCurrentStock = new MaterialCurrentStock();
             materialCurrentStock.setMaterialId(mId);
             materialCurrentStock.setDepotId(dId);
             //设置当前库存数量
             materialCurrentStock.setCurrentNumber(getStockByParam(dId,mId,null,null));
-            if(list!=null && list.size()>0) {
-                //当前库存信息存在,修改当前库存信息
-                Long mcsId = list.get(0).getId();
-                materialCurrentStock.setId(mcsId);
-                materialCurrentStockMapper.updateByPrimaryKeySelective(materialCurrentStock);
-            } else {
-                //当前库存信息不存在,新增当前库存信息
-                materialCurrentStockMapper.insertSelective(materialCurrentStock);
-            }
+            //添加当前库存
+            materialCurrentStockMapper.insertSelective(materialCurrentStock);
+            //同步商品库存
+            syncTescoSystemService.sycnTescoStock(mId);
         }
     }
 
@@ -1449,7 +1497,8 @@ public class DepotItemServiceImpl extends ServiceImpl<DepotItemMapper, DepotItem
         //根据批次号获取商品数据
         List<MaterialVo4Unit> list = new ArrayList<>();
         if ("XSDD".equals(prefixNo)){ //销售订单导入
-            List<String> strings = Arrays.asList(batchNumbers.replace("^\"|\"$","").split(","));
+            String systemSku = batchNumbers.replace("'","");
+            List<String> strings = Arrays.asList(systemSku.split(","));
             //根据系统sku查询商品
             for (String str : strings) {
                 MaterialVo4Unit materialVo4Unit = depotItemMapperEx.getDepotMaterialBySystemSku(str);
@@ -1463,7 +1512,11 @@ public class DepotItemServiceImpl extends ServiceImpl<DepotItemMapper, DepotItem
         //仓库集合
         Map<String, Long> depotMap = new HashMap<>();
         for (MaterialVo4Unit material: list) {
-            materialMap.put(material.getBatchNumber(), material);
+            if ("XSDD".equals(prefixNo)){
+                materialMap.put(material.getSystemSku(), material);
+            }else {
+                materialMap.put(material.getBatchNumber(), material);
+            }
         }
         //获取当前用户所有仓库
         JSONArray depotArr = depotService.findDepotByCurrentUser();
@@ -1603,4 +1656,16 @@ public class DepotItemServiceImpl extends ServiceImpl<DepotItemMapper, DepotItem
         }
         return materialOther;
     }
+
+    //删除前回复库存
+    private void ReplyInventoryByHeadId(Long id) throws Exception {
+        DepotHead depotHead = depotHeadService.getDepotHead(id);
+        List<DepotItem> list = getListByHeaderId(id);
+        for (DepotItem depotItem : list) {
+            if (depotHead.getType().equals("入库")){
+
+            }
+        }
+    }
+
 }

+ 407 - 0
src/main/java/com/jsh/erp/service/impl/DepotServiceImpl.java

@@ -0,0 +1,407 @@
+package com.jsh.erp.service.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jsh.erp.constants.BusinessConstants;
+import com.jsh.erp.constants.ExceptionConstants;
+import com.jsh.erp.datasource.entities.*;
+import com.jsh.erp.datasource.mappers.*;
+import com.jsh.erp.datasource.vo.SpinnerVO;
+import com.jsh.erp.exception.BusinessRunTimeException;
+import com.jsh.erp.exception.JshException;
+import com.jsh.erp.query.QueryWrapperX;
+import com.jsh.erp.service.*;
+import com.jsh.erp.utils.PageUtils;
+import com.jsh.erp.utils.StringUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@Service
+public class DepotServiceImpl extends ServiceImpl<DepotMapper, Depot> implements DepotService {
+    private Logger logger = LoggerFactory.getLogger(DepotService.class);
+
+    @Resource
+    private DepotMapper depotMapper;
+    @Resource
+    private DepotMapperEx depotMapperEx;
+    @Resource
+    private UserService userService;
+    @Resource
+    private SystemConfigService systemConfigService;
+    @Resource
+    private UserBusinessService userBusinessService;
+    @Resource
+    private LogService logService;
+    @Resource
+    private DepotItemMapperEx depotItemMapperEx;
+    @Resource
+    private MaterialInitialStockMapperEx materialInitialStockMapperEx;
+    @Resource
+    private MaterialCurrentStockMapperEx materialCurrentStockMapperEx;
+    @Resource
+    private MaterialExtendMapperEx materialExtendMapperEx;
+
+    @Override
+    public List<SpinnerVO> depotSpinnerList() {
+        return depotMapper.depotSpinnerList();
+    }
+
+    @Override
+    public Depot getDepot(long id)throws Exception {
+        Depot result=null;
+        try{
+            result=depotMapper.selectByPrimaryKey(id);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return result;
+    }
+
+    @Override
+    public List<Depot> getDepotListByIds(String ids)throws Exception {
+        List<Long> idList = StringUtil.strToLongList(ids);
+        DepotExample example = new DepotExample();
+        example.createCriteria().andIdIn(idList);
+        return depotMapper.selectByExample(example);
+    }
+
+    @Override
+    public List<Depot> getDepot()throws Exception {
+        DepotExample example = new DepotExample();
+        example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
+        List<Depot> list=null;
+        try{
+            list=depotMapper.selectByExample(example);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return list;
+    }
+
+    @Override
+    public List<Depot> getAllList()throws Exception {
+        DepotExample example = new DepotExample();
+        example.createCriteria().andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
+        example.setOrderByClause("sort asc, id desc");
+        List<Depot> list=null;
+        try{
+            list=depotMapper.selectByExample(example);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return list;
+    }
+
+    @Override
+    public List<DepotEx> select(String name, Integer type, String remark)throws Exception {
+        List<DepotEx> list=null;
+        try{
+            PageUtils.startPage();
+            list=depotMapperEx.selectByConditionDepot(name, type, remark);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return list;
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int insertDepot(JSONObject obj, HttpServletRequest request)throws Exception {
+        Depot depot = JSONObject.parseObject(obj.toJSONString(), Depot.class);
+        int result=0;
+        try{
+            depot.setType(0);
+            List<Depot> depotList = getDepot();
+            if(depotList.size() == 0) {
+                depot.setIsDefault(true);
+            } else {
+                depot.setIsDefault(false);
+            }
+            depot.setEnabled(true);
+            result=depotMapper.insertSelective(depot);
+            //新增仓库时给当前用户自动授权
+            Long userId = userService.getUserId(request);
+            Long depotId = getIdByName(depot.getName());
+            String ubKey = "[" + depotId + "]";
+            List<UserBusiness> ubList = userBusinessService.getBasicData(userId.toString(), "UserDepot");
+            if(ubList ==null || ubList.size() == 0) {
+                JSONObject ubObj = new JSONObject();
+                ubObj.put("type", "UserDepot");
+                ubObj.put("keyId", userId);
+                ubObj.put("value", ubKey);
+                userBusinessService.insertUserBusiness(ubObj, request);
+            } else {
+                UserBusiness ubInfo = ubList.get(0);
+                JSONObject ubObj = new JSONObject();
+                ubObj.put("id", ubInfo.getId());
+                ubObj.put("type", ubInfo.getType());
+                ubObj.put("keyId", ubInfo.getKeyId());
+                ubObj.put("value", ubInfo.getValue() + ubKey);
+                userBusinessService.updateUserBusiness(ubObj, request);
+            }
+            logService.insertLog("仓库",
+                    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(depot.getName()).toString(), request);
+        }catch(Exception e){
+            JshException.writeFail(logger, e);
+        }
+        return result;
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int updateDepot(JSONObject obj, HttpServletRequest request) throws Exception{
+        Depot depot = JSONObject.parseObject(obj.toJSONString(), Depot.class);
+        int result=0;
+        try{
+            result= depotMapper.updateByPrimaryKeySelective(depot);
+            logService.insertLog("仓库",
+                    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(depot.getName()).toString(), request);
+        }catch(Exception e){
+            JshException.writeFail(logger, e);
+        }
+        return result;
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int deleteDepot(Long id, HttpServletRequest request)throws Exception {
+        return batchDeleteDepotByIds(id.toString());
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int batchDeleteDepot(String ids, HttpServletRequest request) throws Exception{
+        return batchDeleteDepotByIds(ids);
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int batchDeleteDepotByIds(String ids)throws Exception {
+        int result=0;
+        String [] idArray=ids.split(",");
+        //校验单据子表	jsh_depot_item
+        List<DepotItem> depotItemList = depotItemMapperEx.getDepotItemListListByDepotIds(idArray);
+        if(depotItemList!=null&&depotItemList.size()>0){
+            logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]",
+                    ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
+            throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
+                    ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
+        }
+        //校验商品子表
+        int count = materialExtendMapperEx.getMaterialExtendCountByDepotIds(idArray);
+        if(count > 0){
+            logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]",
+                    ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
+            throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
+                    ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
+        }
+        try{
+            //记录日志
+            StringBuffer sb = new StringBuffer();
+            sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE);
+            List<Depot> list = getDepotListByIds(ids);
+            for(Depot depot: list){
+                sb.append("[").append(depot.getName()).append("]");
+            }
+            User userInfo=userService.getCurrentUser();
+            //校验通过执行删除操作
+            //删除仓库关联的商品的初始库存
+            materialInitialStockMapperEx.batchDeleteByDepots(idArray);
+            //删除仓库关联的商品的当前库存
+            materialCurrentStockMapperEx.batchDeleteByDepots(idArray);
+            //删除仓库
+            result = depotMapperEx.batchDeleteDepotByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
+            //记录日志
+            logService.insertLog("仓库", sb.toString(),
+                    ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
+        } catch (Exception e) {
+            JshException.writeFail(logger, e);
+        }
+        return result;
+    }
+
+    @Override
+    public int checkIsNameExist(Long id, String name)throws Exception {
+        DepotExample example = new DepotExample();
+        example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
+        List<Depot> list=null;
+        try{
+            list= depotMapper.selectByExample(example);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return list==null?0:list.size();
+    }
+
+    @Override
+    public List<Depot> findUserDepot()throws Exception{
+        DepotExample example = new DepotExample();
+        example.createCriteria().andTypeEqualTo(0).andEnabledEqualTo(true)
+                .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
+        example.setOrderByClause("sort asc, id desc");
+        List<Depot> list=null;
+        try{
+            list= depotMapper.selectByExample(example);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return list;
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int updateIsDefault(Long depotId) throws Exception{
+        int result=0;
+        try{
+            //全部取消默认
+            Depot allDepot = new Depot();
+            allDepot.setIsDefault(false);
+            DepotExample allExample = new DepotExample();
+            allExample.createCriteria();
+            depotMapper.updateByExampleSelective(allDepot, allExample);
+            //给指定仓库设为默认
+            Depot depot = new Depot();
+            depot.setIsDefault(true);
+            DepotExample example = new DepotExample();
+            example.createCriteria().andIdEqualTo(depotId);
+            depotMapper.updateByExampleSelective(depot, example);
+            logService.insertLog("仓库",BusinessConstants.LOG_OPERATION_TYPE_EDIT+depotId,
+                    ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
+            result = 1;
+        }catch(Exception e){
+            JshException.writeFail(logger, e);
+        }
+        return result;
+    }
+
+    /**
+     * 根据名称获取id
+     * @param name
+     */
+    @Override
+    public Long getIdByName(String name){
+        Long id = 0L;
+        DepotExample example = new DepotExample();
+        example.createCriteria().andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
+        List<Depot> list = depotMapper.selectByExample(example);
+        if(list!=null && list.size()>0) {
+            id = list.get(0).getId();
+        }
+        return id;
+    }
+
+
+    /**
+     * 解析仓库列表
+     * @param depotId 仓库id
+     * @return 仓库id为空,返回当前用户有权限的仓库,不为空返回仓库id的集合
+     */
+    @Override
+    public List<Long> parseDepotList(Long depotId) throws Exception {
+        List<Long> depotList = new ArrayList<>();
+        if(depotId !=null) {
+            depotList.add(depotId);
+        } else {
+            //未选择仓库时默认为当前用户有权限的仓库
+            JSONArray depotArr = findDepotByCurrentUser();
+            for(Object obj: depotArr) {
+                JSONObject object = JSONObject.parseObject(obj.toString());
+                depotList.add(object.getLong("id"));
+            }
+        }
+        return depotList;
+    }
+
+    @Override
+    public JSONArray findDepotByCurrentUser() throws Exception {
+        JSONArray arr = new JSONArray();
+        String type = "UserDepot";
+        Long userId = userService.getCurrentUser().getId();
+        List<Depot> dataList = findUserDepot();
+        //开始拼接json数据
+        if (null != dataList) {
+            boolean depotFlag = systemConfigService.getDepotFlag();
+            if(depotFlag) {
+                List<UserBusiness> list = userBusinessService.getBasicData(userId.toString(), type);
+                if(list!=null && list.size()>0) {
+                    String depotStr = list.get(0).getValue();
+                    if(StringUtil.isNotEmpty(depotStr)){
+                        depotStr = depotStr.replaceAll("\\[", "").replaceAll("]", ",");
+                        String[] depotArr = depotStr.split(",");
+                        for (Depot depot : dataList) {
+                            for(String depotId: depotArr) {
+                                if(depot.getId() == Long.parseLong(depotId)){
+                                    JSONObject item = new JSONObject();
+                                    item.put("id", depot.getId());
+                                    item.put("depotName", depot.getName());
+                                    item.put("isDefault", depot.getIsDefault());
+                                    arr.add(item);
+                                }
+                            }
+                        }
+                    }
+                }
+            } else {
+                for (Depot depot : dataList) {
+                    JSONObject item = new JSONObject();
+                    item.put("id", depot.getId());
+                    item.put("depotName", depot.getName());
+                    item.put("isDefault", depot.getIsDefault());
+                    arr.add(item);
+                }
+            }
+        }
+        return arr;
+    }
+
+    /**
+     * 当前用户有权限使用的仓库列表的id,用逗号隔开
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public String findDepotStrByCurrentUser() throws Exception {
+        JSONArray arr =  findDepotByCurrentUser();
+        StringBuffer sb = new StringBuffer();
+        for(Object object: arr) {
+            JSONObject obj = (JSONObject)object;
+            sb.append(obj.getLong("id")).append(",");
+        }
+        String depotStr = sb.toString();
+        if(StringUtil.isNotEmpty(depotStr)){
+            depotStr = depotStr.substring(0, depotStr.length()-1);
+        }
+        return depotStr;
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int batchSetStatus(Boolean status, String ids)throws Exception {
+        logService.insertLog("仓库",
+                new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ENABLED).toString(),
+                ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
+        List<Long> depotIds = StringUtil.strToLongList(ids);
+        Depot depot = new Depot();
+        depot.setEnabled(status);
+        DepotExample example = new DepotExample();
+        example.createCriteria().andIdIn(depotIds);
+        int result=0;
+        try{
+            result = depotMapper.updateByExampleSelective(depot, example);
+        }catch(Exception e){
+            JshException.writeFail(logger, e);
+        }
+        return result;
+    }
+}

+ 12 - 0
src/main/java/com/jsh/erp/service/impl/InventoryLogServiceImpl.java

@@ -0,0 +1,12 @@
+package com.jsh.erp.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jsh.erp.datasource.entities.InventoryLog;
+import com.jsh.erp.datasource.mappers.InventoryLogMapper;
+import com.jsh.erp.service.InventoryLogService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class InventoryLogServiceImpl extends ServiceImpl<InventoryLogMapper, InventoryLog> implements InventoryLogService {
+
+}

+ 316 - 0
src/main/java/com/jsh/erp/service/impl/MaterialCategoryServiceImpl.java

@@ -0,0 +1,316 @@
+package com.jsh.erp.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jsh.erp.constants.BusinessConstants;
+import com.jsh.erp.constants.ExceptionConstants;
+import com.jsh.erp.datasource.entities.*;
+import com.jsh.erp.datasource.mappers.MaterialCategoryMapper;
+import com.jsh.erp.datasource.mappers.MaterialCategoryMapperEx;
+import com.jsh.erp.datasource.mappers.MaterialMapperEx;
+import com.jsh.erp.datasource.vo.TreeNode;
+import com.jsh.erp.exception.BusinessRunTimeException;
+import com.jsh.erp.exception.JshException;
+import com.jsh.erp.service.LogService;
+import com.jsh.erp.service.MaterialCategoryService;
+import com.jsh.erp.service.UserService;
+import com.jsh.erp.utils.PageUtils;
+import com.jsh.erp.utils.StringUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@Service
+public class MaterialCategoryServiceImpl extends ServiceImpl<MaterialCategoryMapper, MaterialCategory> implements MaterialCategoryService {
+    private Logger logger = LoggerFactory.getLogger(MaterialCategoryServiceImpl.class);
+
+    @Resource
+    private MaterialCategoryMapper materialCategoryMapper;
+    @Resource
+    private MaterialCategoryMapperEx materialCategoryMapperEx;
+    @Resource
+    private UserService userService;
+    @Resource
+    private LogService logService;
+    @Resource
+    private MaterialMapperEx materialMapperEx;
+
+    @Override
+    public MaterialCategory getMaterialCategory(long id)throws Exception {
+        MaterialCategory result=null;
+        try{
+            result=materialCategoryMapper.selectByPrimaryKey(id);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return result;
+    }
+
+    @Override
+    public List<MaterialCategory> getMaterialCategoryListByIds(String ids)throws Exception {
+        List<Long> idList = StringUtil.strToLongList(ids);
+        List<MaterialCategory> list = new ArrayList<>();
+        try{
+            MaterialCategoryExample example = new MaterialCategoryExample();
+            example.createCriteria().andIdIn(idList);
+            list = materialCategoryMapper.selectByExample(example);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return list;
+    }
+
+    @Override
+    public List<MaterialCategory> getMaterialCategory()throws Exception {
+        MaterialCategoryExample example = new MaterialCategoryExample();
+        List<MaterialCategory> list=null;
+        try{
+            list=materialCategoryMapper.selectByExample(example);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return list;
+    }
+
+    @Override
+    public List<MaterialCategory> getAllList(Long parentId)throws Exception {
+        List<MaterialCategory> list=null;
+        try{
+            list = getMCList(parentId);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return list;
+    }
+
+    @Override
+    public List<MaterialCategory> getMCList(Long parentId)throws Exception {
+        List<MaterialCategory> res= new ArrayList<MaterialCategory>();
+        List<MaterialCategory> list=null;
+        MaterialCategoryExample example = new MaterialCategoryExample();
+        example.createCriteria().andParentIdEqualTo(parentId).andIdNotEqualTo(1L);
+        example.setOrderByClause("id");
+        list=materialCategoryMapper.selectByExample(example);
+        if(list!=null && list.size()>0) {
+            res.addAll(list);
+            for(MaterialCategory mc : list) {
+                List<MaterialCategory> mcList = getMCList(mc.getId());
+                if(mcList!=null && mcList.size()>0) {
+                    res.addAll(mcList);
+                }
+            }
+        }
+        return res;
+    }
+
+    @Override
+    public List<MaterialCategory> select(String name, Integer parentId) throws Exception{
+        List<MaterialCategory> list=null;
+        try{
+            PageUtils.startPage();
+            list=materialCategoryMapperEx.selectByConditionMaterialCategory(name, parentId);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return list;
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int insertMaterialCategory(JSONObject obj, HttpServletRequest request)throws Exception {
+        MaterialCategory materialCategory = JSONObject.parseObject(obj.toJSONString(), MaterialCategory.class);
+        materialCategory.setCreateTime(new Date());
+        materialCategory.setUpdateTime(new Date());
+        User user = userService.getCurrentUser();
+        materialCategory.setTenantId(user.getId());
+        int result = 0;
+        try{
+            result = materialCategoryMapper.insertSelective(materialCategory);
+            logService.insertLog("商品类型",
+                    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(materialCategory.getName()).toString(), request);
+        }catch(Exception e){
+            JshException.writeFail(logger, e);
+        }
+        return result;
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int updateMaterialCategory(JSONObject obj, HttpServletRequest request) throws Exception{
+        MaterialCategory materialCategory = JSONObject.parseObject(obj.toJSONString(), MaterialCategory.class);
+        materialCategory.setUpdateTime(new Date());
+        int result=0;
+        try{
+            result=materialCategoryMapperEx.editMaterialCategory(materialCategory);
+            logService.insertLog("商品类型",
+                    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(materialCategory.getName()).toString(), request);
+        }catch(Exception e){
+            JshException.writeFail(logger, e);
+        }
+        return result;
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int deleteMaterialCategory(Long id, HttpServletRequest request)throws Exception {
+        return batchDeleteMaterialCategoryByIds(id.toString());
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int batchDeleteMaterialCategory(String ids, HttpServletRequest request)throws Exception {
+        return batchDeleteMaterialCategoryByIds(ids);
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int batchDeleteMaterialCategoryByIds(String ids) throws Exception {
+        int result=0;
+        String [] idArray=ids.split(",");
+        //校验产品表	jsh_material
+        List<Material> materialList=null;
+        try{
+            materialList= materialMapperEx.getMaterialListByCategoryIds(idArray);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        if(materialList!=null&&materialList.size()>0){
+            logger.error("异常码[{}],异常提示[{}],参数,CategoryIds[{}]",
+                    ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
+            throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
+                    ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
+        }
+        StringBuffer sb = new StringBuffer();
+        sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE);
+        List<MaterialCategory> list = getMaterialCategoryListByIds(ids);
+        for(MaterialCategory materialCategory: list){
+            sb.append("[").append(materialCategory.getName()).append("]");
+        }
+        logService.insertLog("商品类型", sb.toString(),
+                ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
+        //更新时间
+        Date updateDate = new Date();
+        //更新人
+        User userInfo = userService.getCurrentUser();
+        Long updater = userInfo==null ? null : userInfo.getId();
+        String strArray[]=ids.split(",");
+        if(strArray.length<1){
+            return 0;
+        }
+        List<MaterialCategory> mcList = materialCategoryMapperEx.getMaterialCategoryListByCategoryIds(idArray);
+        if(mcList!=null && mcList.size()>0) {
+            logger.error("异常码[{}],异常提示[{}]",
+                    ExceptionConstants.MATERIAL_CATEGORY_CHILD_NOT_SUPPORT_DELETE_CODE,ExceptionConstants.MATERIAL_CATEGORY_CHILD_NOT_SUPPORT_DELETE_MSG);
+            throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_CHILD_NOT_SUPPORT_DELETE_CODE,
+                    ExceptionConstants.MATERIAL_CATEGORY_CHILD_NOT_SUPPORT_DELETE_MSG);
+        } else {
+            result=materialCategoryMapperEx.batchDeleteMaterialCategoryByIds(updateDate,updater,strArray);
+        }
+        return result;
+    }
+
+    @Override
+    public int checkIsNameExist(Long id, String name)throws Exception {
+        MaterialCategoryExample example = new MaterialCategoryExample();
+        example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
+        List<MaterialCategory> list=null;
+        try{
+            list= materialCategoryMapper.selectByExample(example);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return list==null?0:list.size();
+    }
+
+    @Override
+    public List<MaterialCategory> findById(Long id)throws Exception {
+        List<MaterialCategory> list=null;
+        if(id!=null) {
+            MaterialCategoryExample example = new MaterialCategoryExample();
+            example.createCriteria().andIdEqualTo(id);
+            try{
+                list=materialCategoryMapper.selectByExample(example);
+            }catch(Exception e){
+                JshException.readFail(logger, e);
+            }
+        }
+        return list;
+    }
+
+    /**
+     * description:
+     * 获取商品类别树数据
+     */
+    @Override
+    public List<TreeNode> getMaterialCategoryTree(Long id) throws Exception{
+        List<TreeNode> list=null;
+        try{
+            list=materialCategoryMapperEx.getNodeTree(id);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+       return list;
+    }
+    /**
+     * 根据商品类别编号判断商品类别是否已存在
+     * */
+    @Override
+    public void  checkMaterialCategorySerialNo(MaterialCategory mc)throws Exception {
+        if(mc==null){
+            return;
+        }
+        if( mc.getSerialNo() < 0){
+            return;
+        }
+        //根据商品类别编号查询商品类别
+        List<MaterialCategory> mList=null;
+        try{
+            mList= materialCategoryMapperEx.getMaterialCategoryBySerialNo(mc.getSerialNo(), mc.getId());
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        if(mList==null||mList.size()<1){
+            //未查询到对应数据,编号可用
+            return;
+        }
+        if(mList.size()>1){
+            //查询到的数据条数大于1,编号已存在
+            throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE,
+                    ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG);
+        }
+        if(mc.getId()==null){
+            //新增时,编号已存在
+            throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE,
+                    ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG);
+        }
+        /**
+         * 包装类型用equals来比较
+         * */
+        if(mc.getId().equals(mList.get(0).getId())){
+            //修改时,相同编号,id不同
+            throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE,
+                    ExceptionConstants.MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG);
+        }
+    }
+
+    @Override
+    public Long getCategoryIdByName(String name){
+        Long categoryId = null;
+        MaterialCategoryExample example = new MaterialCategoryExample();
+        example.createCriteria().andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
+        List<MaterialCategory> list = materialCategoryMapper.selectByExample(example);
+        if(list!=null && list.size()>0) {
+            categoryId = list.get(0).getId();
+        }
+        return categoryId;
+    }
+}

+ 36 - 14
src/main/java/com/jsh/erp/service/impl/MaterialExtendServiceImpl.java

@@ -1,22 +1,17 @@
 package com.jsh.erp.service.impl;
-
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jsh.erp.constants.BusinessConstants;
-import com.jsh.erp.constants.ExceptionConstants;
 import com.jsh.erp.datasource.entities.*;
 import com.jsh.erp.datasource.mappers.MaterialCurrentStockMapper;
 import com.jsh.erp.datasource.mappers.MaterialExtendMapper;
 import com.jsh.erp.datasource.mappers.MaterialExtendMapperEx;
 import com.jsh.erp.datasource.vo.MaterialExtendVo4List;
-import com.jsh.erp.exception.BusinessRunTimeException;
 import com.jsh.erp.exception.JshException;
-import com.jsh.erp.service.MaterialExtendService;
-import com.jsh.erp.service.MaterialService;
-import com.jsh.erp.service.RedisService;
-import com.jsh.erp.service.UserService;
+import com.jsh.erp.service.*;
 import com.jsh.erp.utils.DateUtils;
 import com.jsh.erp.utils.RandomHelper;
 import com.jsh.erp.utils.StringUtil;
@@ -49,9 +44,14 @@ public class MaterialExtendServiceImpl extends ServiceImpl<MaterialExtendMapper,
     private UserService userService;
     @Resource
     private RedisService redisService;
-
     @Resource
     private MaterialService materialService;
+    @Resource
+    private DepotItemService depotItemService;
+    @Resource
+    private InventoryLogService inventoryLogService;
+    @Resource
+    private SyncTescoSystemService syncTescoSystemService;
 
     @Override
     public MaterialExtend getMaterialExtend(long id)throws Exception {
@@ -274,16 +274,21 @@ public class MaterialExtendServiceImpl extends ServiceImpl<MaterialExtendMapper,
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     public int insertMaterialExtend(MaterialExtend materialExtend)throws Exception {
         User user = userService.getCurrentUser();
+        //设置是否为默认单位
         materialExtend.setDeleteFlag(BusinessConstants.DELETE_FLAG_EXISTS);
+        //创建时间
         materialExtend.setCreateTime(new Date());
+        //修改时间
         materialExtend.setUpdateTime(new Date().getTime());
+        //创建用户
         materialExtend.setCreateSerial(user.getLoginName());
+        //修改用户
         materialExtend.setUpdateSerial(user.getLoginName());
-        materialExtend.setTenantId(user.getId());
         int result = 0;
         try{
             result= materialExtendMapper.insertSelective(materialExtend);
-
+            //更新当前库存
+            depotItemService.updateCurrentStockFun(materialExtend.getMaterialId(), materialExtend.getDepotId());
         }catch(Exception e){
             JshException.writeFail(logger, e);
         }
@@ -306,6 +311,8 @@ public class MaterialExtendServiceImpl extends ServiceImpl<MaterialExtendMapper,
         materialExtend.setUpdateSerial(user.getLoginName());
         int res =0;
         try{
+            //修改库存
+            updateInventory("商品修改",null,materialExtend);
             res= materialExtendMapper.updateByPrimaryKeySelective(materialExtend);
         }catch(Exception e){
             JshException.writeFail(logger, e);
@@ -491,11 +498,26 @@ public class MaterialExtendServiceImpl extends ServiceImpl<MaterialExtendMapper,
     }
 
     /**
-     * 设置当前库存
-     * @param depotId 仓库id
-     * @param mId   商品id
-     * @param stock 库存数量
+     * 修改子商品库存
      */
+    @Override
+    public synchronized void updateInventory(String type, Long id, MaterialExtend materialExtend) throws Exception {
+        if (materialExtend.getInventory() != null){
+            User user = userService.getCurrentUser();
+            InventoryLog log = new InventoryLog();
+            log.setUpdateUser(user.getId());
+            log.setUpdateTime(new Date());
+            log.setMaterialId(materialExtend.getMaterialId());
+            log.setMaterialExtendId(materialExtend.getId());
+            log.setOriginalStock(materialExtendMapper.selectByPrimaryKey(materialExtend.getId()).getInventory().intValue());
+            Integer i = materialExtend.getInventory().intValue();
+            log.setCurrentStock(i);
+            log.setItemId(id);
+            log.setType(type);
+            inventoryLogService.save(log);
+            update(new UpdateWrapper<MaterialExtend>().set("inventory",materialExtend.getInventory()).set("position",materialExtend.getPosition()).eq("id",materialExtend.getId()));
+        }
+    }
     /**
      * 设置当前库存
      * @param depotId 仓库id

+ 169 - 128
src/main/java/com/jsh/erp/service/impl/MaterialServiceImpl.java

@@ -9,11 +9,17 @@ import com.jsh.erp.constants.BusinessConstants;
 import com.jsh.erp.constants.ExceptionConstants;
 import com.jsh.erp.datasource.entities.*;
 import com.jsh.erp.datasource.mappers.*;
+import com.jsh.erp.datasource.pda.dto.PDAInventoryDTO;
+import com.jsh.erp.datasource.pda.vo.PDADepotItemVO;
+import com.jsh.erp.datasource.vo.MaterialCurrentStock4SystemSku;
+import com.jsh.erp.datasource.pda.vo.PDATypeTree;
 import com.jsh.erp.datasource.vo.MaterialVoSearch;
 import com.jsh.erp.datasource.vo.MaterialWarnListVo;
+import com.jsh.erp.datasource.vo.TreeNode;
 import com.jsh.erp.exception.BusinessRunTimeException;
 import com.jsh.erp.exception.JshException;
 import com.jsh.erp.query.LambdaQueryWrapperX;
+import com.jsh.erp.query.QueryWrapperX;
 import com.jsh.erp.service.*;
 import com.jsh.erp.utils.*;
 import jxl.Sheet;
@@ -209,11 +215,14 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
                             //设置初始库
                             insertInitialStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number), lowSafeStock, highSafeStock);
                             //设置当前库
-                            insertCurrentStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number));
+                            //insertCurrentStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number));
+                            //更新当前库存
+                            depotItemService.updateCurrentStockFun(mId, depotId);
                         }
                     }
                 }
             }
+
             logService.insertLog("商品",
                     new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(m.getName()).toString(), request);
             return 1;
@@ -236,7 +245,6 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     public int updateMaterial(JSONObject obj, HttpServletRequest request) throws Exception{
         Material material = JSONObject.parseObject(obj.toJSONString(), Material.class);
-
         try{
             //修改商品属性
             materialMapper.updateByPrimaryKeySelective(material);
@@ -1633,9 +1641,16 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
         if (CollectionUtil.isEmpty(systemSkuList)){
             return null;
         }
-        String[] systemSkuArray = systemSkuList.toArray(new String[0]);
-        List<MaterialVo4Unit> list =  materialMapperEx.getMaterialBySystemSku(systemSkuArray);
-        return list;
+        String[] systemSkuArray = systemSkuList.toArray(new String[systemSkuList.size()]);
+        return materialMapperEx.getMaterialBySystemSku(systemSkuArray);
+    }
+
+    @Override
+    public List<MaterialCurrentStock4SystemSku> getMaterialCurrentPriceByIdList(List<Long> idList) {
+        if (CollectionUtil.isEmpty(idList)) {
+            return null;
+        }
+        return materialMapperEx.getMaterialCurrentPriceByIdList(idList);
     }
 
     /**
@@ -1715,13 +1730,6 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
         return vo;
     }
 
-    /**
-     * 导入表格
-     * @param file
-     * @param request
-     * @return
-     * @throws Exception
-     */
     @Override
     public BaseResponseInfo importExcelTwo(MultipartFile file, HttpServletRequest request) throws Exception {
         BaseResponseInfo info = new BaseResponseInfo();
@@ -1740,6 +1748,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
             Sheet src = workbook.getSheet(0);
             //获取真实的行数,剔除掉空白行
             int rightRows = ExcelUtils.getRightRows(src);
+            //获取所有仓库
             List<Depot> depotList= depotService.getDepot();
             int depotCount = depotList.size();
             Map<String, Long> depotMap = parseDepotToMap(depotList);
@@ -1752,33 +1761,6 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
             }
             for (int i = 2; i < rightRows; i++) {
                 String name = ExcelUtils.getContent(src, i, 0); //名称
-                String standard = ExcelUtils.getContent(src, i, 1); //规格
-                String model = ExcelUtils.getContent(src, i, 2); //型号
-                String color = ExcelUtils.getContent(src, i, 3); //颜色
-                String brand = ExcelUtils.getContent(src, i, 4); //品牌
-                String categoryName = ExcelUtils.getContent(src, i, 5); //类别
-                String weight = ExcelUtils.getContent(src, i, 6); //基础重量(kg)
-                String unit = ExcelUtils.getContent(src, i, 7); //基本单位
-                String manyUnit = ExcelUtils.getContent(src, i, 8); //副单位
-                String ratio = ExcelUtils.getContent(src, i, 9); //比例
-                String sku = ExcelUtils.getContent(src, i, 10); //多属性
-                String purchaseDecimal = ExcelUtils.getContent(src, i, 11); //采购价
-                String commodityDecimal = ExcelUtils.getContent(src, i, 12); //零售价
-                String wholesaleDecimal = ExcelUtils.getContent(src, i, 13); //销售价
-                String lowDecimal = ExcelUtils.getContent(src, i, 14); //最低售价
-                String enabled = ExcelUtils.getContent(src, i, 15); //状态
-                String enableSerialNumber = ExcelUtils.getContent(src, i, 16); //序列号
-                String productionDate = ExcelUtils.getContent(src, i, 17); //生产日期
-                String expiryNum = ExcelUtils.getContent(src, i, 18); //保质期天数
-                String supplier = ExcelUtils.getContent(src, i, 19); //供应商
-                String barCode = ExcelUtils.getContent(src, i, 20); //商品条码
-                String depotName = ExcelUtils.getContent(src, i, 21); //仓库名称
-                String position = ExcelUtils.getContent(src, i, 22); //仓位货架
-                String inventory = ExcelUtils.getContent(src,i,23);//库存
-                String otherField1 = ExcelUtils.getContent(src, i, 24); //自定义1
-                String otherField2 = ExcelUtils.getContent(src, i, 25); //自定义2
-                String otherField3 = ExcelUtils.getContent(src, i, 26); //自定义3
-                String remark = ExcelUtils.getContent(src, i, 27); //备注
                 //名称为空
                 if(StringUtil.isEmpty(name)) {
                     throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NAME_EMPTY_CODE,
@@ -1789,21 +1771,21 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
                     throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_NAME_OVER_CODE,
                             String.format(ExceptionConstants.MATERIAL_NAME_OVER_MSG, i+1));
                 }
+                String standard = ExcelUtils.getContent(src, i, 1); //规格
                 //规格长度超出
                 if(StringUtil.isNotEmpty(standard) && standard.length()>100) {
                     throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_STANDARD_OVER_CODE,
                             String.format(ExceptionConstants.MATERIAL_STANDARD_OVER_MSG, i+1));
                 }
+                String model = ExcelUtils.getContent(src, i, 2); //型号
                 //型号长度超出
                 if(StringUtil.isNotEmpty(model) && model.length()>100) {
                     throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_MODEL_OVER_CODE,
                             String.format(ExceptionConstants.MATERIAL_MODEL_OVER_MSG, i+1));
                 }
-                //基本单位为空
-                if(StringUtil.isEmpty(unit)) {
-                    throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_UNIT_EMPTY_CODE,
-                            String.format(ExceptionConstants.MATERIAL_UNIT_EMPTY_MSG, i+1));
-                }
+                String color = ExcelUtils.getContent(src, i, 3); //颜色
+                String brand = ExcelUtils.getContent(src, i, 4); //品牌
+                String categoryName = ExcelUtils.getContent(src, i, 5); //类别
                 //类别为空
                 if(StringUtil.isEmpty(categoryName)) {
                     throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_Category_Name_EMPTY_CODE,
@@ -1816,8 +1798,46 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
                     throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_TYPE_NOT_DECIMAL_CODE,
                             String.format(ExceptionConstants.MATERIAL_TYPE_NOT_DECIMAL_MSG, i+1));
                 }
+                String weight = ExcelUtils.getContent(src, i, 6); //基础重量(kg)
+                if(StringUtil.isNotEmpty(weight)) {
+                    //校验基础重量是否是数字(含小数)
+                    if(!StringUtil.isPositiveBigDecimal(weight)) {
+                        throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_WEIGHT_NOT_DECIMAL_CODE,
+                                String.format(ExceptionConstants.MATERIAL_WEIGHT_NOT_DECIMAL_MSG, i+1));
+                    }
+                }
+                String unit = ExcelUtils.getContent(src, i, 7); //基本单位
+                //基本单位为空
+                if(StringUtil.isEmpty(unit)) {
+                    throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_UNIT_EMPTY_CODE,
+                            String.format(ExceptionConstants.MATERIAL_UNIT_EMPTY_MSG, i+1));
+                }
+                String manyUnit = ExcelUtils.getContent(src, i, 8); //副单位
+                String ratio = ExcelUtils.getContent(src, i, 9); //比例
+                String sku = ExcelUtils.getContent(src, i, 10); //多属性
+                String purchaseDecimal = ExcelUtils.getContent(src, i, 11); //采购价
+                String commodityDecimal = ExcelUtils.getContent(src, i, 12); //零售价
+                String wholesaleDecimal = ExcelUtils.getContent(src, i, 13); //销售价
+                String lowDecimal = ExcelUtils.getContent(src, i, 14); //最低售价
+                String enabled = ExcelUtils.getContent(src, i, 15); //状态
+                //状态格式错误
+                if(!"1".equals(enabled) && !"0".equals(enabled)) {
+                    throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_ENABLED_ERROR_CODE,
+                            String.format(ExceptionConstants.MATERIAL_ENABLED_ERROR_MSG, i+1));
+                }
+                String enableSerialNumber = ExcelUtils.getContent(src, i, 16); //序列号
+                String productionDate = ExcelUtils.getContent(src, i, 17); //生产日期
+                String expiryNum = ExcelUtils.getContent(src, i, 18); //保质期天数
+                if(StringUtil.isNotEmpty(expiryNum)) {
+                    //校验保质期是否是正整数
+                    if(!StringUtil.isPositiveLong(expiryNum)) {
+                        throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_EXPIRY_NUM_NOT_INTEGER_CODE,
+                                String.format(ExceptionConstants.MATERIAL_EXPIRY_NUM_NOT_INTEGER_MSG, i+1));
+                    }
+                }
+                String supplier = ExcelUtils.getContent(src, i, 19); //供应商
                 Long supplierId = null;
-                if (supplier != null && !supplier.isEmpty()){
+                if(StringUtil.isNotEmpty(supplier)) {
                     //根据供应商查询供应商id
                     Supplier s  = supplierService.getOne(new LambdaQueryWrapperX<Supplier>().eq(Supplier::getSupplier,supplier));
                     supplierId = s.getId();
@@ -1827,8 +1847,10 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
                                 String.format(ExceptionConstants.MATERIAL_SUPPLIER_NOT_DECIMAL_MSG, i+1));
                     }
                 }
+                String barCode = ExcelUtils.getContent(src, i, 20); //商品条码
+                String depotName = ExcelUtils.getContent(src, i, 21); //仓库名称
                 Long depotId = null;
-                if (depotName != null && !depotName.isEmpty()){
+                if(StringUtil.isNotEmpty(supplier)) {
                     //根据仓库名查询仓库id
                     depotId = depotMapperEx.selectByConditionDepot(depotName,null,null).get(0).getId();
                     if (depotId == null){
@@ -1837,6 +1859,12 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
                                 String.format(ExceptionConstants.MATERIAL_DEPOT_NOT_DECIMAL_MSG, i+1));
                     }
                 }
+                String position = ExcelUtils.getContent(src, i, 22); //仓位货架
+                String inventory = ExcelUtils.getContent(src,i,23);//库存
+                String otherField1 = ExcelUtils.getContent(src, i, 24); //自定义1
+                String otherField2 = ExcelUtils.getContent(src, i, 25); //自定义2
+                String otherField3 = ExcelUtils.getContent(src, i, 26); //自定义3
+                String remark = ExcelUtils.getContent(src, i, 27); //备注
                 MaterialWithInitStock m = new MaterialWithInitStock();
                 //设置商品名字、规格、型号、颜色、品牌、类型id
                 m.setName(name);
@@ -1847,53 +1875,42 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
                 m.setCategoryId(categoryId);
                 //通过名称生成助记码
                 m.setMnemonic(PinYinUtil.getFirstLettersLo(name));
+                //设置单位、备注、基础重量
+                m.setUnit(unit);
+                m.setRemark(remark);
+                m.setWeight(new BigDecimal(weight));
+                //设置商品是否启用
+                m.setEnabled("1".equals(enabled));
+                //设置商品是否开启序列号
+                if(StringUtil.isNotEmpty(enableSerialNumber) && "1".equals(enableSerialNumber)) {
+                    m.setEnableSerialNumber("1");
+                } else {
+                    m.setEnableSerialNumber("0");
+                }
                 //获取类型编码
                 Long serial_no = categoryId == null ? null : materialCategoryService.getMaterialCategory(m.getCategoryId()).getSerialNo();
                 //设置系统sku
-                m.setSystemSku(serial_no + DateUtils.dateTimeNow());
-                if(StringUtil.isNotEmpty(weight)) {
-                    //校验基础重量是否是数字(含小数)
-                    if(!StringUtil.isPositiveBigDecimal(weight)) {
-                        throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_WEIGHT_NOT_DECIMAL_CODE,
-                                String.format(ExceptionConstants.MATERIAL_WEIGHT_NOT_DECIMAL_MSG, i+1));
-                    }
-                    m.setWeight(new BigDecimal(weight));
-                }
-                if(StringUtil.isNotEmpty(expiryNum)) {
-                    //校验保质期是否是正整数
-                    if(!StringUtil.isPositiveLong(expiryNum)) {
-                        throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_EXPIRY_NUM_NOT_INTEGER_CODE,
-                                String.format(ExceptionConstants.MATERIAL_EXPIRY_NUM_NOT_INTEGER_MSG, i+1));
-                    }
-                    //m.setExpiryNum(Integer.parseInt(expiryNum));
-                }
+                m.setSystemSku(serial_no + DateUtils.dateTimeNow() + RandomHelper.getRandomStr(6));
                 m.setOtherField1(StringUtil.isNotEmpty(otherField1)?otherField1:null);
                 m.setOtherField2(StringUtil.isNotEmpty(otherField2)?otherField2:null);
                 m.setOtherField3(StringUtil.isNotEmpty(otherField3)?otherField3:null);
                 m.setRemark(remark);
-                //状态格式错误
-                if(!"1".equals(enabled) && !"0".equals(enabled)) {
-                    throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_ENABLED_ERROR_CODE,
-                            String.format(ExceptionConstants.MATERIAL_ENABLED_ERROR_MSG, i+1));
-                }
-                //批量校验excel中有无重复商品,是指名称、规格、型号、颜色、单位、多属性
-                //batchCheckExistMaterialListByParam(mList, name, standard, model, color, unit, sku);
                 //设置商品拓展属性
                 JSONObject materialExObj = new JSONObject();
                 JSONObject basicObj = new JSONObject();
-                basicObj.put("commodityUnit", unit);
-                basicObj.put("sku", sku);
-                basicObj.put("purchaseDecimal", purchaseDecimal);
-                basicObj.put("commodityDecimal", commodityDecimal);
-                basicObj.put("wholesaleDecimal", wholesaleDecimal);
-                basicObj.put("lowDecimal", lowDecimal);
-                basicObj.put("productionDate",productionDate);
-                basicObj.put("expiryNum",expiryNum);
-                basicObj.put("supplierId",supplierId);
-                basicObj.put("barCode", barCode);
-                basicObj.put("inventory",inventory);
-                basicObj.put("depotId",depotId);
-                basicObj.put("position",position);
+                basicObj.put("commodityUnit", unit);    //商品单位
+                basicObj.put("sku", sku);   //商品属性
+                basicObj.put("purchaseDecimal", purchaseDecimal);   //采购价格
+                basicObj.put("commodityDecimal", commodityDecimal); //零售价格
+                basicObj.put("wholesaleDecimal", wholesaleDecimal); //销售价格
+                basicObj.put("lowDecimal", lowDecimal); //最低售价
+                basicObj.put("productionDate",productionDate); //生产日期
+                basicObj.put("expiryNum",expiryNum);    //保质期天数
+                basicObj.put("supplierId",supplierId); //供应商id
+                basicObj.put("barCode", barCode); //商品条码
+                basicObj.put("inventory",inventory); //库存
+                basicObj.put("depotId",depotId);    //仓库id
+                basicObj.put("position",position);  //仓位货架
                 materialExObj.put("basic", basicObj);
                 if(StringUtil.isNotEmpty(manyUnit) && StringUtil.isNotEmpty(ratio)){ //多单位
                     //校验比例是否是数字(含小数)
@@ -1906,68 +1923,34 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
                         m.setUnitId(unitId);
                         m.setUnit("");
                     }
-                    JSONObject otherObj = new JSONObject();
-                    otherObj.put("commodityUnit", manyUnit);
-                    otherObj.put("purchaseDecimal", parsePrice(purchaseDecimal,ratio));
-                    otherObj.put("commodityDecimal", parsePrice(commodityDecimal,ratio));
-                    otherObj.put("wholesaleDecimal", parsePrice(wholesaleDecimal,ratio));
-                    otherObj.put("lowDecimal", parsePrice(lowDecimal,ratio));
-                    materialExObj.put("other", otherObj);
+//                    JSONObject otherObj = new JSONObject();
+//                    otherObj.put("commodityUnit", manyUnit);
+//                    otherObj.put("purchaseDecimal", parsePrice(purchaseDecimal,ratio));
+//                    otherObj.put("commodityDecimal", parsePrice(commodityDecimal,ratio));
+//                    otherObj.put("wholesaleDecimal", parsePrice(wholesaleDecimal,ratio));
+//                    otherObj.put("lowDecimal", parsePrice(lowDecimal,ratio));
+//                    materialExObj.put("other", otherObj);
                 } else {
                     m.setUnit(unit);
                     m.setUnitId(null);
                 }
                 m.setMaterialExObj(materialExObj);
-                //设置商品是否启用
-                m.setEnabled("1".equals(enabled));
-                //设置商品是否开启序列号
-                if(StringUtil.isNotEmpty(enableSerialNumber) && "1".equals(enableSerialNumber)) {
-                    m.setEnableSerialNumber("1");
-                } else {
-                    m.setEnableSerialNumber("0");
-                }
-                //批号去掉
-//                if(StringUtil.isNotEmpty(enableBatchNumber) && "1".equals(enableBatchNumber)) {
-//                    m.setEnableBatchNumber("1");
-//                } else {
-//                    m.setEnableBatchNumber("0");
-//                }
-//                if("1".equals(enableSerialNumber) && "1".equals(enableBatchNumber)) {
-//                    throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_ENABLE_MUST_ONE_CODE,
-//                            String.format(ExceptionConstants.MATERIAL_ENABLE_MUST_ONE_MSG, barCode));
-//                }
                 //设置库存
                 m.setStockMap(getStockMapCache(src, depotCount, depotMap, i));
                 mList.add(m);
             }
             //处理表单信息,转为对象集合
             List<Material> materialList = parseMapByExcelData(mList);
-            List<Long> deleteInitialStockMaterialIdList = new ArrayList<>();
-            List<Long> deleteCurrentStockMaterialIdList = new ArrayList<>();
-            List<MaterialInitialStock> insertInitialStockMaterialList = new ArrayList<>();
-            List<MaterialCurrentStock> insertCurrentStockMaterialList = new ArrayList<>();
-            //防止初始库存和当前库存出现重复
-            Map<String, String> materialDepotInitialMap = new HashMap<>();
-            Map<String, String> materialDepotCurrentMap = new HashMap<>();
             for (Material material : materialList) {
-                //添加商品
+                //添加商品信息
                 materialMapperEx.insertSelectiveEx(material);
-                //
-                Long mId = material.getId();
+                //添加商品子信息
                 for (MaterialExtend materialExtend : material.getList()) {
-                    materialExtend.setMaterialId(mId);
+                    //设置商品id
+                    materialExtend.setMaterialId( material.getId());
                     materialExtendService.insertMaterialExtend(materialExtend);
                 }
             }
-            //批量更新库存,先删除后新增
-//            if(insertInitialStockMaterialList.size()>0) {
-//                batchDeleteInitialStockByMaterialList(deleteInitialStockMaterialIdList);
-//                materialInitialStockMapperEx.batchInsert(insertInitialStockMaterialList);
-//            }
-//            if(insertCurrentStockMaterialList.size()>0) {
-//                batchDeleteCurrentStockByMaterialList(deleteCurrentStockMaterialIdList);
-//                materialCurrentStockMapperEx.batchInsert(insertCurrentStockMaterialList);
-//            }
             //添加日志
             logService.insertLog("商品",
                     new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_IMPORT).append(mList.size()).append(BusinessConstants.LOG_DATA_UNIT).toString(),
@@ -1987,6 +1970,48 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
         return info;
     }
 
+    @Override
+    public List<PDADepotItemVO> inventoryInquiry(PDAInventoryDTO pdaInventoryDTO) throws Exception {
+        //查询类型id的子类型
+        pdaInventoryDTO.setCategoryIds(selectCategoryIds(pdaInventoryDTO.getCategoryId()));
+        return materialMapperEx.inventoryInquiry(pdaInventoryDTO);
+    }
+
+    /**
+     * 查询库位树
+     */
+    @Override
+    public List<PDATypeTree> selectPosition() {
+        List<String> positions = materialExtendMapper.selectPosition();
+        Map<String,List<String>> map = new HashMap<>();
+        for (String s : positions) {
+            String [] str = s.split("-");
+            if (map.get(str[0]) == null){
+                List<String> list = new ArrayList<>();
+                map.put(str[0],list);
+            }
+            if (str.length > 2){
+                map.get(str[0]).add(str[1]);
+            }
+        }
+        List<PDATypeTree> typeTrees = new ArrayList<>();
+        map.forEach((key,value) -> {
+            PDATypeTree typeTree = new PDATypeTree();
+            typeTree.setLabel(key);
+            typeTree.setValue(key);
+            List<PDATypeTree> children = new ArrayList<>();
+            for (String s : value) {
+                PDATypeTree childrenTree = new PDATypeTree();
+                childrenTree.setLabel(key + "-" + s);
+                childrenTree.setValue(key + "-" + s);
+                children.add(childrenTree);
+            }
+            typeTree.setChildren(children);
+            typeTrees.add(typeTree);
+        });
+        return typeTrees;
+    }
+
     /**
      * 解析excel表格数据为商品对象
      */
@@ -2025,10 +2050,16 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
                 material.setMnemonic(m.getMnemonic());
                 //颜色
                 material.setColor(m.getColor());
+                //商品类别
+                material.setCategoryId(m.getCategoryId());
                 //单位-单个
                 material.setUnit(m.getUnit());
                 //计量单位Id
                 material.setUnitId(m.getUnitId());
+                //备注
+                material.setRemark(m.getRemark());
+                //基础重量
+                material.setWeight(m.getWeight());
                 //启用 0-禁用  1-启用
                 material.setEnabled(m.getEnabled());
                 //自定义1
@@ -2074,6 +2105,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
             materialExtend.setDepotId(basicObj.getLong("depotId"));
             //仓位货架
             materialExtend.setPosition(basicObj.getString("position"));
+            //库存
             materialExtend.setInventory(basicObj.getBigDecimal("inventory"));
             materialMap.get(str).getList().add(materialExtend);
         }
@@ -2081,4 +2113,13 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
         return materials;
     }
 
+    public List<Long> selectCategoryIds(Long id) throws Exception {
+        List<Long> longs = new ArrayList<>();
+        longs.add(id);
+        List<MaterialCategory> list = materialCategoryService.list(new LambdaQueryWrapperX<MaterialCategory>().eq(MaterialCategory::getParentId,id).eq(MaterialCategory::getDeleteFlag,"0"));
+        for (MaterialCategory materialCategory : list) {
+            longs.addAll(selectCategoryIds(materialCategory.getId()));
+        }
+        return longs;
+    }
 }

+ 14 - 0
src/main/java/com/jsh/erp/service/impl/SupplierServiceImpl.java

@@ -282,6 +282,20 @@ public class SupplierServiceImpl extends ServiceImpl<SupplierMapper, Supplier> i
         return list==null?0:list.size();
     }
 
+    @Override
+    public int checkIsTelephoneAndTypeExist(Long id, String telephone, String type) {
+        telephone = (telephone == null) ? "" : telephone;
+        SupplierExample example = new SupplierExample();
+        example.createCriteria().andIdNotEqualTo(id).andTelephoneEqualTo(telephone).andTypeEqualTo(type).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
+        List<Supplier> list = null;
+        try {
+            list = supplierMapper.selectByExample(example);
+        } catch (Exception e) {
+            JshException.readFail(logger, e);
+        }
+        return list == null ? 0 : list.size();
+    }
+
     /**
      * 更新会员的预付款
      * @param supplierId

+ 14 - 0
src/main/java/com/jsh/erp/service/impl/TaskStocktakingItemServiceImpl.java

@@ -3,9 +3,23 @@ package com.jsh.erp.service.impl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jsh.erp.datasource.entities.TaskStocktakingItem;
 import com.jsh.erp.datasource.mappers.TaskStocktakingItemMapper;
+import com.jsh.erp.datasource.vo.SpinnerVO;
 import com.jsh.erp.service.TaskStocktakingItemService;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 @Service
+@RequiredArgsConstructor
+@Slf4j
 public class TaskStocktakingItemServiceImpl extends ServiceImpl<TaskStocktakingItemMapper, TaskStocktakingItem> implements TaskStocktakingItemService {
+
+    private final TaskStocktakingItemMapper taskStocktakingItemMapper;
+
+    @Override
+    public List<SpinnerVO> creatorSpinnerList(Long taskId) {
+        return taskStocktakingItemMapper.creatorSpinnerList(taskId);
+    }
 }

+ 38 - 22
src/main/java/com/jsh/erp/service/impl/TaskStocktakingServiceImpl.java

@@ -1,22 +1,22 @@
 package com.jsh.erp.service.impl;
 
-import cn.hutool.core.collection.CollectionUtil;
-import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jsh.erp.datasource.dto.TaskStocktakingDTO;
+import com.jsh.erp.datasource.dto.TaskStocktakingItemQueryDTO;
+import com.jsh.erp.datasource.dto.TaskStocktakingQueryDTO;
 import com.jsh.erp.datasource.entities.*;
 import com.jsh.erp.datasource.mappers.*;
+import com.jsh.erp.datasource.pda.dto.PDATaskStocktakingItemDTO;
 import com.jsh.erp.datasource.pda.vo.PDATaskStocktakingItemVO;
 import com.jsh.erp.datasource.pda.vo.PDATaskStocktakingVO;
 import com.jsh.erp.datasource.vo.TaskStocktakingItemVO;
 import com.jsh.erp.datasource.vo.TaskStocktakingVO;
 import com.jsh.erp.query.LambdaQueryWrapperX;
 import com.jsh.erp.service.DepotService;
+import com.jsh.erp.service.SequenceService;
 import com.jsh.erp.service.TaskStocktakingService;
 import com.jsh.erp.service.UserService;
-import com.jsh.erp.utils.DateUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
@@ -51,9 +51,11 @@ public class TaskStocktakingServiceImpl extends ServiceImpl<TaskStocktakingMappe
 
     private final UserService userService;
 
+    private final SequenceService sequenceService;
+
     @Override
-    public List<TaskStocktakingVO> listBy() {
-        return taskStocktakingMapper.listBy();
+    public List<TaskStocktakingVO> listBy(TaskStocktakingQueryDTO taskStocktakingQueryDTO) {
+        return taskStocktakingMapper.listBy(taskStocktakingQueryDTO);
     }
 
     /**
@@ -95,6 +97,8 @@ public class TaskStocktakingServiceImpl extends ServiceImpl<TaskStocktakingMappe
             taskStocktakingDTO.setCreateBy(currentUser.getId());
             taskStocktakingDTO.setCreateTime(new Date());
             taskStocktakingDTO.setTaskStatus(1);
+            //生成单据编号
+            taskStocktakingDTO.setNumber("PDRW"+sequenceService.buildOnlyNumber());
             //生成任务
             this.save(taskStocktakingDTO);
             //生成任务明细
@@ -180,7 +184,7 @@ public class TaskStocktakingServiceImpl extends ServiceImpl<TaskStocktakingMappe
             taskStocktakingDTO.setCreateTime(new Date());
             taskStocktakingDTO.setTaskStatus(1);
             //生成任务
-            this.save(taskStocktakingDTO);
+            this.updateById(taskStocktakingDTO);
             List<Long> taskStocktakingItemIdList = taskStocktakingItemMapper.selectList(new LambdaQueryWrapperX<TaskStocktakingItem>().eq(TaskStocktakingItem::getTaskStocktakingId, taskStocktakingDTO.getId())).stream().map(TaskStocktakingItem::getId).collect(Collectors.toList());
             //生成任务明细
             List<TaskStocktakingItem> addTaskStocktakingItemList = new ArrayList<>();
@@ -195,15 +199,17 @@ public class TaskStocktakingServiceImpl extends ServiceImpl<TaskStocktakingMappe
             List<Long> materialExtendIdList = materialExtendList.stream().map(MaterialExtend::getId).collect(Collectors.toList());
             taskStocktakingItemIdList.forEach(item -> {
                 if (!materialExtendIdList.contains(item)) {
-
-//                    taskStocktakingItemMapper.updateById();
+                    TaskStocktakingItem taskStocktakingItem = new TaskStocktakingItem();
+                    taskStocktakingItem.setId(item);
+                    taskStocktakingItem.setDeleteFlag(true);
+                    taskStocktakingItemMapper.updateById(taskStocktakingItem);
                 }
             });
             if (addTaskStocktakingItemList.size() > 0) {
                 taskStocktakingItemMapper.insertBatch(addTaskStocktakingItemList);
             }
         } catch (Exception e) {
-            log.error("创建盘点任务失败", e);
+            log.error("修改盘点任务失败", e);
             return false;
         }
         return true;
@@ -211,12 +217,12 @@ public class TaskStocktakingServiceImpl extends ServiceImpl<TaskStocktakingMappe
 
     /**
      * 任务详情-商品明细
-     * @param taskStocktakingId 盘点任务ID
+     * @param taskStocktakingItemQueryDTO 筛选参数
      * @return
      */
     @Override
-    public List<TaskStocktakingItemVO> listByTaskStocktakingId(Long taskStocktakingId) {
-        return taskStocktakingItemMapper.listByTaskStocktakingId(taskStocktakingId);
+    public List<TaskStocktakingItemVO> listByTaskStocktakingId(TaskStocktakingItemQueryDTO taskStocktakingItemQueryDTO) {
+        return taskStocktakingItemMapper.listByTaskStocktakingId(taskStocktakingItemQueryDTO);
     }
 
     /**
@@ -242,6 +248,8 @@ public class TaskStocktakingServiceImpl extends ServiceImpl<TaskStocktakingMappe
         List<TaskStocktakingItem> itemList = taskStocktakingItemMapper.selectList(new LambdaQueryWrapper<TaskStocktakingItem>().eq(TaskStocktakingItem::getTaskStocktakingId, id));
         //已操作数量
         long finishCount = itemList.stream().filter(item -> item.getCreator() != null).count();
+        //操作人数
+        long operCount = itemList.stream().filter(item -> item.getCreator() != null).map(TaskStocktakingItem::getCreator).distinct().count();
         //商品总数量
         long itemCount = itemList.size();
         //商品差异条数
@@ -251,25 +259,33 @@ public class TaskStocktakingServiceImpl extends ServiceImpl<TaskStocktakingMappe
         //差异率
         double differenceRate = 0;
         //准确率
-        double accuracyRate = 0;
+        double accuracyRate = 100;
         if (itemDifferenceCount > 0) {
-            differenceRate = BigDecimal.valueOf(itemCount)
-                    .divide(BigDecimal.valueOf(itemDifferenceCount), 4, RoundingMode.HALF_UP)
-                    .doubleValue();
-            accuracyRate = BigDecimal.valueOf(itemCount)
-                    .divide(BigDecimal.valueOf(finishCount)
-                            .subtract(BigDecimal.valueOf(itemDifferenceCount)), 4, RoundingMode.HALF_UP)
+            //差异率 = 商品差异条数/商品总数量*100%
+            differenceRate = BigDecimal.valueOf(itemDifferenceCount)
+                    .divide(BigDecimal.valueOf(itemCount), 4, RoundingMode.HALF_UP)
+                    .multiply(BigDecimal.valueOf(100))
                     .doubleValue();
+            //准确数 = 已操作数量-商品差异条数
+            BigDecimal subtract = BigDecimal.valueOf(finishCount).subtract(BigDecimal.valueOf(itemDifferenceCount));
+            //准确率 = 准确数/商品总数量*100%
+            if (!subtract.equals(BigDecimal.ZERO)) {
+                accuracyRate = subtract.divide(BigDecimal.valueOf(itemCount), 4, RoundingMode.HALF_UP)
+                        .multiply(BigDecimal.valueOf(100))
+                        .doubleValue();
+            }
         }
+        detail.setItemCount(itemCount);
         detail.setDifferenceRate(differenceRate);
         detail.setAccuracyRate(accuracyRate);
         detail.setFinishCount(finishCount);
+        detail.setOperCount(operCount);
         return detail;
     }
 
     @Override
-    public List<PDATaskStocktakingItemVO> pdaItemList(Long taskId) {
-        return taskStocktakingItemMapper.pdaList(taskId);
+    public List<PDATaskStocktakingItemVO> pdaItemList(PDATaskStocktakingItemDTO pdaTaskStocktakingItemDTO) {
+        return taskStocktakingItemMapper.pdaList(pdaTaskStocktakingItemDTO);
     }
 
     /**

+ 31 - 0
src/main/java/com/jsh/erp/utils/FileUtils.java

@@ -1,6 +1,8 @@
 package com.jsh.erp.utils;
 
+import javax.servlet.http.HttpServletRequest;
 import java.io.*;
+import java.net.URLEncoder;
 import java.util.*;
 
 /**
@@ -317,4 +319,33 @@ public class FileUtils {
 		fileName = fileName.replace("=","").replace(",","").replace("&","");
 		return fileName;
 	}
+
+	public static String setFileDownloadHeader(HttpServletRequest request, String fileName)
+			throws UnsupportedEncodingException
+	{
+		final String agent = request.getHeader("USER-AGENT");
+		String filename = fileName;
+		if (agent.contains("MSIE"))
+		{
+			// IE浏览器
+			filename = URLEncoder.encode(filename, "utf-8");
+			filename = filename.replace("+", " ");
+		}
+		else if (agent.contains("Firefox"))
+		{
+			// 火狐浏览器
+			filename = new String(fileName.getBytes(), "ISO8859-1");
+		}
+		else if (agent.contains("Chrome"))
+		{
+			// google浏览器
+			filename = URLEncoder.encode(filename, "utf-8");
+		}
+		else
+		{
+			// 其它浏览器
+			filename = URLEncoder.encode(filename, "utf-8");
+		}
+		return filename;
+	}
 }

+ 4 - 0
src/main/resources/application-dev.yml

@@ -30,3 +30,7 @@ aliyun:
     bucketName: xiangli-erp
     miniProgramAppId: wxd716cb744e32271a
     linkUrl: https://xiangli-erp.oss-cn-hangzhou.aliyuncs.com
+tesco:
+  openSycn: false
+  sycnErpMaterialStockUrl: http://localhost:8088/no-auth/erp/sync-stock
+  sycnErpMaterialPriceUrl: http://localhost:8088/no-auth/erp/sync-saleprice

+ 5 - 0
src/main/resources/application-pro.yml

@@ -30,3 +30,8 @@ aliyun:
     bucketName: xiangli-erp
     miniProgramAppId: wxd716cb744e32271a
     linkUrl: https://xiangli-erp.oss-cn-hangzhou.aliyuncs.com
+
+tesco:
+  openSycn: true
+  sycnErpMaterialStockUrl: https://tesco.xianglitech.com.cn/prod-api/no-auth/erp/sync-stock
+  sycnErpMaterialPriceUrl: https://tesco.xianglitech.com.cn/prod-api/no-auth/erp/sync-saleprice

+ 5 - 0
src/main/resources/application-test.yml

@@ -30,3 +30,8 @@ aliyun:
     bucketName: xiangli-erp
     miniProgramAppId: wxd716cb744e32271a
     linkUrl: https://xiangli-erp.oss-cn-hangzhou.aliyuncs.com
+
+tesco:
+  openSycn: false
+  sycnErpMaterialStockUrl: https://test.xianglitech.com.cn/stage-api/no-auth/erp/sync-stock
+  sycnErpMaterialPriceUrl: https://test.xianglitech.com.cn/stage-api/no-auth/erp/sync-saleprice

+ 80 - 11
src/main/resources/mapper_xml/DepotHeadMapper.xml

@@ -101,7 +101,7 @@
     account_id, change_amount, back_amount, total_price, pay_type, bill_type, remark, 
     file_name, sales_man, account_id_list, account_money_list, discount, discount_money, 
     discount_last_money, other_money, deposit, status, purchase_status, source, link_number, 
-    link_apply, tenant_id, delete_flag
+    link_apply, tenant_id, delete_flag,goods_quantity, goods_type_count, link_tesco, receiver_name, receiver_phone, receiver_address
   </sql>
   <select id="selectByExample" parameterType="com.jsh.erp.datasource.entities.DepotHeadExample" resultMap="BaseResultMap">
     select
@@ -144,7 +144,7 @@
       discount_money, discount_last_money, other_money, 
       deposit, status, purchase_status, 
       source, link_number, link_apply, 
-      tenant_id, delete_flag)
+      tenant_id, delete_flag,goods_quantity, goods_type_count, link_tesco, receiver_name, receiver_phone, receiver_address)
     values (#{id,jdbcType=BIGINT}, #{type,jdbcType=VARCHAR}, #{subType,jdbcType=VARCHAR}, 
       #{defaultNumber,jdbcType=VARCHAR}, #{number,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
       #{operTime,jdbcType=TIMESTAMP}, #{organId,jdbcType=BIGINT}, #{creator,jdbcType=BIGINT}, 
@@ -155,7 +155,9 @@
       #{discountMoney,jdbcType=DECIMAL}, #{discountLastMoney,jdbcType=DECIMAL}, #{otherMoney,jdbcType=DECIMAL}, 
       #{deposit,jdbcType=DECIMAL}, #{status,jdbcType=VARCHAR}, #{purchaseStatus,jdbcType=VARCHAR}, 
       #{source,jdbcType=VARCHAR}, #{linkNumber,jdbcType=VARCHAR}, #{linkApply,jdbcType=VARCHAR}, 
-      #{tenantId,jdbcType=BIGINT}, #{deleteFlag,jdbcType=VARCHAR})
+      #{tenantId,jdbcType=BIGINT}, #{deleteFlag,jdbcType=VARCHAR},#{goodsQuantity,jdbcType=INTEGER},
+      #{goodsTypeCount,jdbcType=INTEGER}, #{linkTesco,jdbcType=VARCHAR}, #{receiverName,jdbcType=VARCHAR},
+      #{receiverPhone,jdbcType=VARCHAR}, #{receiverAddress,jdbcType=VARCHAR})
   </insert>
   <insert id="insertSelective" parameterType="com.jsh.erp.datasource.entities.DepotHead" useGeneratedKeys="true" keyProperty="id">
     insert into jsh_depot_head
@@ -277,6 +279,9 @@
       <if test="receiverAddress != null">
         receiver_address,
       </if>
+      <if test="operId != null">
+        oper_id
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="id != null">
@@ -388,13 +393,16 @@
         #{linkTesco,jdbcType=VARCHAR},
       </if>
       <if test="receiverName != null">
-        #{receiverName,jdbcType=VARCHAR}
+        #{receiverName,jdbcType=VARCHAR},
       </if>
       <if test="receiverPhone != null">
-        #{receiverPhone,jdbcType=VARCHAR}
+        #{receiverPhone,jdbcType=VARCHAR},
       </if>
       <if test="receiverAddress != null">
-        #{receiverAddress,jdbcType=VARCHAR}
+        #{receiverAddress,jdbcType=VARCHAR},
+      </if>
+      <if test="operId != null">
+        #{operId,jdbcType=INTEGER}
       </if>
     </trim>
   </insert>
@@ -503,6 +511,27 @@
       <if test="record.deleteFlag != null">
         delete_flag = #{record.deleteFlag,jdbcType=VARCHAR},
       </if>
+      <if test="record.voucherPicture != null">
+        voucher_picture = #{record.voucherPicture,jdbcType=VARCHAR},
+      </if>
+      <if test="record.goodsQuantity != null and record.goodsQuantity != 0">
+        goods_quantity = #{record.goodsQuantity,jdbcType=INTEGER},
+      </if>
+      <if test="record.goodsTypeCount != null and record.goodsTypeCount != 0">
+        goods_type_count = #{record.goodsTypeCount,jdbcType=INTEGER},
+      </if>
+      <if test="record.linkTesco != null">
+        link_tesco = #{record.linkTesco,jdbcType=VARCHAR},
+      </if>
+      <if test="record.receiverName != null">
+        receiver_name = #{record.receiverName,jdbcType=VARCHAR},
+      </if>
+      <if test="record.receiverPhone != null">
+        receiver_phone = #{record.receiverPhone,jdbcType=VARCHAR},
+      </if>
+      <if test="record.receiverAddress != null">
+        receiver_address = #{record.receiverAddress,jdbcType=VARCHAR},
+      </if>
     </set>
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -541,7 +570,14 @@
       link_number = #{record.linkNumber,jdbcType=VARCHAR},
       link_apply = #{record.linkApply,jdbcType=VARCHAR},
       tenant_id = #{record.tenantId,jdbcType=BIGINT},
-      delete_flag = #{record.deleteFlag,jdbcType=VARCHAR}
+      delete_flag = #{record.deleteFlag,jdbcType=VARCHAR},
+      voucher_picture = #{record.voucherPicture,jdbcType=VARCHAR},
+      goods_quantity = #{record.goodsQuantity,jdbcType=INTEGER},
+      goods_type_count = #{record.goodsTypeCount,jdbcType=INTEGER},
+      link_tesco = #{record.linkTesco,jdbcType=VARCHAR},
+      receiver_name = #{record.receiverName,jdbcType=VARCHAR},
+      receiver_phone = #{record.receiverPhone,jdbcType=VARCHAR},
+      receiver_address = #{record.receiverAddress,jdbcType=VARCHAR}
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
     </if>
@@ -655,13 +691,19 @@
         link_tesco =#{linkTesco,jdbcType=VARCHAR},
       </if>
       <if test="receiverName != null">
-        receiver_name = #{receiverName,jdbcType=VARCHAR}
+        receiver_name = #{receiverName,jdbcType=VARCHAR},
       </if>
       <if test="receiverPhone != null">
-        receiver_phone = #{receiverPhone,jdbcType=VARCHAR}
+        receiver_phone = #{receiverPhone,jdbcType=VARCHAR},
       </if>
       <if test="receiverAddress != null">
-        receiver_address = #{receiverAddress,jdbcType=VARCHAR}
+        receiver_address = #{receiverAddress,jdbcType=VARCHAR},
+      </if>
+      <if test="depotId != null">
+        depot_id = #{depotId,jdbcType=BIGINT},
+      </if>
+      <if test="operId != null">
+        oper_id = #{operId,jdbcType=BIGINT}
       </if>
     </set>
     where id = #{id,jdbcType=BIGINT}
@@ -698,7 +740,14 @@
       link_number = #{linkNumber,jdbcType=VARCHAR},
       link_apply = #{linkApply,jdbcType=VARCHAR},
       tenant_id = #{tenantId,jdbcType=BIGINT},
-      delete_flag = #{deleteFlag,jdbcType=VARCHAR}
+      delete_flag = #{deleteFlag,jdbcType=VARCHAR},
+      voucher_picture = #{voucherPicture,jdbcType=VARCHAR},
+      goods_quantity = #{goodsQuantity,jdbcType=INTEGER},
+      goods_type_count = #{goodsTypeCount,jdbcType=INTEGER},
+      link_tesco = #{linkTesco,jdbcType=VARCHAR},
+      receiver_name = #{receiverName,jdbcType=VARCHAR},
+      receiver_phone = #{receiverPhone,jdbcType=VARCHAR},
+      receiver_address = #{receiverAddress,jdbcType=VARCHAR}
     where id = #{id,jdbcType=BIGINT}
   </update>
 
@@ -709,6 +758,7 @@
       dh.create_time,
       dh.goods_quantity,
       dh.goods_type_count,
+      dh.oper_time,
       s.supplier AS supplier_name,
       dh.status
     FROM
@@ -729,6 +779,25 @@
       </if>
     </where>
       GROUP BY dh.id
+      ORDER BY dh.create_time DESC
+  </select>
+
+  <select id="pdaDetail" resultType="com.jsh.erp.datasource.pda.vo.PDADepotHeadVO">
+    SELECT
+      dh.id,
+      dh.number,
+      dh.create_time,
+      dh.goods_quantity,
+      dh.goods_type_count,
+      dh.oper_time,
+      s.supplier AS supplier_name,
+      dh.status
+    FROM
+      jsh_depot_head dh
+      LEFT JOIN jsh_supplier s ON dh.organ_id = s.id
+      LEFT JOIN jsh_
+    WHERE
+      dh.id = #{id}
   </select>
 
   <select id="getDepotLastByMaterialId" resultType="com.jsh.erp.datasource.entities.DepotHead">

+ 19 - 6
src/main/resources/mapper_xml/DepotItemMapper.xml

@@ -240,9 +240,12 @@
       <if test="warehousingUser != null">
         warehousing_user,
       </if>
-      <if test="warehousingTime != null">
+      <if test="warehousingTime != null and warehousingTime != ''">
         warehousing_time,
       </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="id != null">
@@ -332,9 +335,12 @@
       <if test="warehousingUser != null">
         #{warehousingUser,jdbcType=BIGINT},
       </if>
-      <if test="warehousingTime != null">
+      <if test="warehousingTime != null and warehousingTime != ''">
         #{warehousingTime,jdbcType=DATE},
       </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=DATE},
+      </if>
     </trim>
   </insert>
     <select id="countByExample" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultType="java.lang.Long">
@@ -576,7 +582,10 @@
 	  me.bar_code AS bar_code,
 	  di.oper_number AS oper_number,
       me.commodity_unit AS commodity_unit,
-      di.material_unit AS material_unit
+      di.material_unit AS material_unit,
+      di.actual_quantity_in_storage AS actual_quantity_in_storage,
+      di.material_id AS material_id,
+      m.img_name AS img_name
     FROM
       jsh_depot_item di
     LEFT JOIN jsh_material m ON di.material_id = m.id
@@ -598,7 +607,9 @@
 	  me.bar_code AS bar_code,
 	  di.oper_number AS oper_number,
       di.material_unit AS material_unit,
-      me.create_time AS create_time
+      me.create_time AS create_time,
+      di.material_id AS material_id,
+      m.img_name AS img_name
     FROM
       jsh_depot_item di
       LEFT JOIN jsh_material m ON di.material_id = m.id
@@ -616,8 +627,9 @@
       d.name AS depot_name,
       m.standard AS material_standard,
       di.actual_quantity_in_storage AS actual_quantity_in_storage,
-      di.warehousing_time AS warehousing_time,
-      me.commodity_unit AS commodity_unit
+      dh.create_time AS warehousing_time,
+      me.commodity_unit AS commodity_unit,
+      m.img_name AS img_name
     FROM
       jsh_depot_item di
       LEFT JOIN jsh_depot_head dh ON di.header_id = dh.id
@@ -626,6 +638,7 @@
       LEFT JOIN jsh_depot d ON di.depot_id = d.id
     WHERE
       di.delete_flag = '0'
+      AND dh.delete_flag = '0'
       AND dh.status in ('2','3')
       AND dh.type = #{type}
       AND di.material_id = #{materialId}

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

@@ -322,13 +322,14 @@
         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,u.name unit_name
         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'
         left join jsh_depot dp1 on di.depot_id=dp1.id and ifnull(dp1.delete_Flag,'0') !='1'
         left join jsh_depot dp2 on di.another_depot_id=dp2.id and ifnull(dp2.delete_Flag,'0') !='1'
         left JOIN jsh_supplier s on me.supplier_id = s.id and ifnull(s.delete_Flag,'0') !='1'
+        left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
         where di.header_id = #{headerId}
         and ifnull(di.delete_flag,'0') !='1'
         order by di.id asc

+ 10 - 0
src/main/resources/mapper_xml/DepotMapper.xml

@@ -335,4 +335,14 @@
       is_default = #{isDefault,jdbcType=BIT}
     where id = #{id,jdbcType=BIGINT}
   </update>
+
+  <select id="depotSpinnerList" resultType="com.jsh.erp.datasource.vo.SpinnerVO">
+    SELECT
+      id AS value,
+      name AS label
+    FROM
+      jsh_depot
+    WHERE
+      delete_Flag = '0'
+  </select>
 </mapper>

+ 5 - 0
src/main/resources/mapper_xml/InventoryLogMapper.xml

@@ -0,0 +1,5 @@
+<?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.jsh.erp.datasource.mappers.InventoryLogMapper">
+
+</mapper>

+ 5 - 6
src/main/resources/mapper_xml/MaterialCategoryMapper.xml

@@ -116,9 +116,11 @@
       #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, 
       #{tenantId,jdbcType=BIGINT}, #{deleteFlag,jdbcType=VARCHAR})
   </insert>
+
   <insert id="insertSelective" parameterType="com.jsh.erp.datasource.entities.MaterialCategory">
     insert into jsh_material_category
     <trim prefix="(" suffix=")" suffixOverrides=",">
+      serial_no,
       <if test="id != null">
         id,
       </if>
@@ -134,9 +136,6 @@
       <if test="sort != null">
         sort,
       </if>
-      <if test="serialNo != null">
-        serial_no,
-      </if>
       <if test="remark != null">
         remark,
       </if>
@@ -154,6 +153,7 @@
       </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
+      (select ifnull(MAX(id),0) + 10001 from jsh_material_category AS mc),
       <if test="id != null">
         #{id,jdbcType=BIGINT},
       </if>
@@ -169,9 +169,7 @@
       <if test="sort != null">
         #{sort,jdbcType=VARCHAR},
       </if>
-      <if test="serialNo != null">
-        #{serialNo,jdbcType=VARCHAR},
-      </if>
+
       <if test="remark != null">
         #{remark,jdbcType=VARCHAR},
       </if>
@@ -189,6 +187,7 @@
       </if>
     </trim>
   </insert>
+
   <select id="countByExample" parameterType="com.jsh.erp.datasource.entities.MaterialCategoryExample" resultType="java.lang.Long">
     select count(*) from jsh_material_category
     <if test="_parameter != null">

+ 3 - 1
src/main/resources/mapper_xml/MaterialCategoryMapperEx.xml

@@ -102,13 +102,15 @@
         </foreach>
        )
     </update>
+
     <update id="editMaterialCategory">
        update jsh_material_category
        set update_time=#{updateTime},
-        parent_id=#{parentId},sort=#{sort},serial_no=#{serialNo},
+        parent_id=#{parentId},sort=#{sort},
         name=#{name},remark=#{remark}
        where id =#{id}
     </update>
+
     <select  id="getMaterialCategoryBySerialNo" resultMap="com.jsh.erp.datasource.mappers.MaterialCategoryMapper.BaseResultMap">
         select
         <include refid="com.jsh.erp.datasource.mappers.MaterialCategoryMapper.Base_Column_List"/>

+ 20 - 0
src/main/resources/mapper_xml/MaterialCurrentStockMapperEx.xml

@@ -31,6 +31,26 @@
         select ifnull(mcs.current_unit_price,0) as current_unit_price from jsh_material_current_stock mcs where mcs.material_id=#{materialId} limit 1
     </select>
 
+    <select id="getCurrentStockMapByMdIdList" resultType="com.jsh.erp.datasource.vo.MaterialCurrentStock4SystemSku">
+        SELECT m.id                                             AS mId,
+               m.name                                           AS mName,
+               m.unit                                           AS unit,
+               m.unit_id                                        AS unitId,
+               m.system_sku                                     AS systemSku,
+               SUM(mcs.current_number)                          AS basicUnitTotalStock,
+               MIN(mcs.current_unit_price)                      AS basicUnitSalePrice
+        FROM jsh_material_current_stock mcs
+        LEFT JOIN jsh_material m ON m.id = mcs.material_id
+        WHERE m.id IN
+        <foreach collection="materialIdList" item="materialId" index="index" separator="," open="(" close=")">
+            #{materialId}
+        </foreach>
+        AND ifnull(mcs.delete_flag,'0') !='1'
+        AND ifnull(m.delete_flag,'0') !='1'
+        GROUP BY m.id, m.system_sku
+    </select>
+
+
     <update id="batchDeleteByDepots">
         update jsh_material_current_stock
         set delete_flag='1'

+ 4 - 3
src/main/resources/mapper_xml/MaterialExtendMapper.xml

@@ -426,9 +426,6 @@
       <if test="barCode != null">
         bar_code = #{barCode,jdbcType=VARCHAR},
       </if>
-      <if test="inventory != null">
-        inventory = #{inventory,jdbcType=DECIMAL},
-      </if>
       <if test="depotId != null">
         depot_id = #{depotId,jdbcType=BIGINT},
       </if>
@@ -484,4 +481,8 @@
     AND ifnull(me.delete_Flag,'0') !='1'
   </select>
 
+  <select id="selectPosition"  resultType="String">
+    SELECT DISTINCT position FROM jsh_material_extend WHERE position IS NOT NULL AND position != "" AND ifnull(delete_Flag,'0') !='1'
+  </select>
+
 </mapper>

+ 10 - 0
src/main/resources/mapper_xml/MaterialExtendMapperEx.xml

@@ -82,4 +82,14 @@
         where material_id=#{materialId} and default_flag='1'
         and ifnull(delete_Flag,'0') !='1'
     </select>
+
+    <select id="getMaterialExtendCountByDepotIds" resultType="int">
+        SELECT COUNT(id) FROM jsh_material_extend
+        WHERE depot_id IN (
+        <foreach collection="depotIds" item="depotId" separator=",">
+            #{depotId}
+        </foreach>
+        )
+        AND IFNULL(delete_Flag,'0') != '1'
+    </select>
 </mapper>

+ 64 - 2
src/main/resources/mapper_xml/MaterialMapperEx.xml

@@ -305,7 +305,7 @@
 
     <select id="findBySelectWithBarCode" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultType="com.jsh.erp.datasource.entities.MaterialVo4Unit">
         select m.*,u.name unit_name,mc.name categoryName,me.bar_code,me.id meId,me.commodity_unit,me.sku,
-        me.production_date,me.expiry_num,me.supplier_id,me.batch_number,me.depot_id,me.position,d.`name` depotName,s.supplier supplierName
+        me.production_date,me.expiry_num,me.supplier_id,me.batch_number,me.depot_id,me.position,d.`name` depotName,s.supplier supplierName,me.inventory
         from jsh_material m
         left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
         left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
@@ -792,7 +792,7 @@
     </select>
 
     <select id="getMaterialByBatchNumber" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultType="com.jsh.erp.datasource.entities.MaterialVo4Unit">
-        select m.*,u.name unit_name, me.id meId, me.commodity_unit, me.purchase_decimal, me.commodity_decimal,
+        select m.*,u.name unit_name, me.id meId, me.commodity_unit, me.purchase_decimal, me.commodity_decimal,me.inventory,
         me.wholesale_decimal, me.low_decimal, me.sku,me.production_date, me.expiry_num, me.supplier_id, me.bar_code, me.batch_number, me.depot_id, me.position,d.`name` depotName,s.supplier supplierName
         from jsh_material m
         left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
@@ -849,4 +849,66 @@
         ORDER BY m.id DESC, me.default_flag DESC, me.production_date,me.batch_number ASC
     </select>
 
+    <select id="inventoryInquiry" parameterType="com.jsh.erp.datasource.pda.dto.PDAInventoryDTO" resultType="com.jsh.erp.datasource.pda.vo.PDADepotItemVO">
+        select m.id materialId,m.name materialName,m.standard materialStandard,u.name unit_name,mc.name categoryName,me.bar_code,me.id meId,me.commodity_unit,me.sku,
+        me.production_date,me.expiry_num,me.supplier_id,me.batch_number,me.depot_id,me.position,d.`name` depotName,s.supplier supplierName,m.img_name,me.inventory
+        from jsh_material m
+        left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
+        left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
+        left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
+        left JOIN jsh_depot d on me.depot_id = d.id and ifnull(d.delete_Flag,'0') !='1'
+        left JOIN jsh_supplier s on me.supplier_id = s.id and ifnull(s.delete_Flag,'0') !='1'
+        where m.enabled = 1
+        and me.id is not null
+        <if test="keyword != null and keyword !=''">
+            <bind name="bindKey" value="'%'+keyword+'%'"/>
+            and (me.batch_number like #{bindKey} or m.name like #{bindKey})
+        </if>
+        <if test="position != null and position !=''">
+            <bind name="bindPosition" value="'%'+position+'%'"/>
+            and me.position like #{bindPosition}
+        </if>
+        <if test="categoryId != null">
+            and m.category_id IN (
+            <foreach collection="categoryIds" item="item" separator=",">
+                #{item}
+            </foreach>
+            )
+        </if>
+        <if test="type == 'have'">
+            and me.inventory > 0
+        </if>
+        <if test="type == 'none'">
+            and me.inventory &lt;= 0
+        </if>
+        and ifnull(me.delete_flag,'0') !='1'
+    </select>
+
+    <select id="getMaterialCurrentPriceByIdList" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultType="com.jsh.erp.datasource.vo.MaterialCurrentStock4SystemSku">
+        WITH RankedExtend AS (
+            SELECT
+                me.*,
+                ROW_NUMBER() OVER (PARTITION BY me.material_id ORDER BY me.batch_number DESC) AS rn
+            FROM jsh_material_extend me
+            LEFT JOIN jsh_material m ON m.id = me.material_id
+            WHERE ifnull(me.delete_Flag, '0') != '1'
+              AND m.id IN (
+                <foreach collection="idList" item="systemSku" separator=",">
+                    #{systemSku}
+                </foreach>
+            )
+        )
+        SELECT
+            m.id                                             AS mId,
+            m.name                                           AS mName,
+            m.unit                                           AS unit,
+            m.unit_id                                        AS unitId,
+            m.system_sku                                     AS systemSku,
+            re.wholesale_decimal                             AS basicUnitSalePrice
+        FROM jsh_material m
+        LEFT JOIN RankedExtend re ON m.id = re.material_id AND re.rn = 1
+        WHERE ifnull(m.delete_flag, '0') != '1' AND re.id IS NOT NULL
+        ORDER BY m.id DESC
+    </select>
+
 </mapper>

+ 101 - 18
src/main/resources/mapper_xml/TaskStocktakingItemMapper.xml

@@ -2,17 +2,89 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.jsh.erp.datasource.mappers.TaskStocktakingItemMapper">
 
-    <select id="listByTaskStocktakingId" resultType="com.jsh.erp.datasource.vo.TaskStocktakingItemVO">
+    <select id="pdaList" parameterType="com.jsh.erp.datasource.pda.dto.PDATaskStocktakingItemDTO" resultType="com.jsh.erp.datasource.pda.vo.PDATaskStocktakingItemVO">
+        SELECT
+        tsi.id AS id,
+        tsi.material_item_id AS material_item_id,
+        me.position AS position,
+        mc.`name` AS category_name,
+        m.`name` AS material_name,
+        m.standard AS standard,
+        u.username AS create_name,
+        tsi.oper_time AS oper_time,
+        me.inventory AS inventory,
+        me.commodity_unit AS commodity_unit,
+        tsi.new_inventory AS new_inventory,
+        tsi.new_position AS new_position,
+        m.img_name AS img_name,
+        tsi.status AS status
+        FROM
+        task_stocktaking_item tsi
+        LEFT JOIN jsh_material_extend me ON tsi.material_item_id = me.id
+        LEFT JOIN jsh_material m ON me.material_id = m.id
+        LEFT JOIN jsh_material_category mc ON m.category_id = mc.id
+        LEFT JOIN jsh_user u ON u.id = tsi.creator
+        <where>
+            tsi.delete_flag = 0
+            AND tsi.task_stocktaking_id = #{taskId}
+            <if test="number != null and number != ''">
+                AND (m.name LIKE CONCAT('%',#{number},'%')
+                OR me.batch_number LIKE CONCAT('%',#{number},'%')
+                OR me.position LIKE CONCAT('%',#{number},'%')
+                OR m.system_sku LIKE CONCAT('%',#{number},'%'))
+            </if>
+            <if test="userIdList != null and userIdList.size > 0">
+                AND tsi.creator IN
+                <foreach collection="userIdList" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="categoryIdList != null and categoryIdList.size > 0">
+                AND m.category_id IN
+                <foreach collection="categoryIdList" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="positionList != null and positionList.size > 0">
+                AND
+                <foreach collection="positionList" item="item" open="(" separator="OR" close=")">
+                     me.position LIKE CONCAT('%',#{item},'%')
+                </foreach>
+            </if>
+            <if test="position != null and position != ''">
+                AND me.position LIKE CONCAT('%',#{position},'%')
+            </if>
+            <if test="statusList != null and statusList.size > 0">
+                AND tsi.status IN
+                <foreach collection="statusList" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+        ORDER BY
+        tsi.oper_time DESC,
+        tsi.id DESC
+    </select>
+
+    <select id="listByTaskStocktakingId" parameterType="com.jsh.erp.datasource.dto.TaskStocktakingItemQueryDTO" resultType="com.jsh.erp.datasource.vo.TaskStocktakingItemVO">
         SELECT
             tsi.id AS id,
             mc.`name` AS category_name,
             m.`name` AS material_name,
+            m.standard AS standard,
+            m.model AS model,
+            m.color AS color,
+            m.brand AS brand,
+            me.position AS position,
+            me.batch_number AS batch_number,
             m.system_sku AS system_sku,
+            me.sku AS sku,
             me.commodity_unit AS commodity_unit,
             me.production_date AS production_date,
             s.supplier AS supplier_name,
             me.bar_code AS bar_code,
             me.inventory AS inventory,
+            me.expiry_num AS expiry_num,
             d.`name` AS depot_name,
             tsi.new_position AS new_position,
             tsi.new_inventory AS new_inventory,
@@ -25,36 +97,47 @@
                 LEFT JOIN jsh_material_category mc ON mc.id = m.category_id
                 LEFT JOIN jsh_supplier s ON me.supplier_id = s.id
                 LEFT JOIN jsh_depot d ON me.depot_id = d.id
-        WHERE
+        <where>
             tsi.delete_flag = 0
             AND tsi.task_stocktaking_id = #{taskStocktakingId}
+            <if test="categoryId != null and categoryId != ''">
+                AND m.category_id = #{categoryId}
+            </if>
+            <if test="materialName != null and materialName != ''">
+                AND m.`name` LIKE CONCAT('%',#{materialName},'%')
+            </if>
+            <if test="batchNumber != null and batchNumber != ''">
+                AND me.batch_number = #{batchNumber}
+            </if>
+            <if test="position != null and position != ''">
+                AND me.position LIKE  CONCAT('%',#{position},'%')
+            </if>
+            <if test="isDifference != null and isDifference == '1'">
+                AND tsi.new_inventory = me.inventory
+            </if>
+            <if test="isDifference != null and isDifference == '2'">
+                AND tsi.new_inventory != 0
+                AND tsi.new_inventory != me.inventory
+            </if>
+        </where>
         ORDER BY
             tsi.oper_time DESC,
             tsi.id DESC
     </select>
 
-    <select id="pdaList" resultType="com.jsh.erp.datasource.pda.vo.PDATaskStocktakingItemVO">
+    <select id="creatorSpinnerList" resultType="com.jsh.erp.datasource.vo.SpinnerVO">
         SELECT
-            me.position AS position,
-            mc.`name` AS category_name,
-            m.`name` AS material_name,
-            m.standard AS standard,
-            u.username AS creator_name,
-            tsi.oper_time AS oper_time,
-            me.inventory AS inventory,
-            tsi.new_inventory AS new_inventory
+            tsi.creator AS value,
+            u.username AS label
         FROM
             task_stocktaking_item tsi
-                LEFT JOIN jsh_material_extend me ON tsi.material_item_id = me.id
-                LEFT JOIN jsh_material m ON me.material_id = m.id
-                LEFT JOIN jsh_material_category mc ON m.category_id = mc.id
-                LEFT JOIN jsh_user u ON u.id = tsi.creator
+            LEFT JOIN jsh_user u ON tsi.creator = u.id
         WHERE
             tsi.delete_flag = 0
+            AND tsi.creator IS NOT NULL
             AND tsi.task_stocktaking_id = #{taskId}
-        ORDER BY
-            tsi.oper_time DESC,
-            tsi.id DESC
+        GROUP BY
+            tsi.creator
     </select>
 
 </mapper>

+ 22 - 5
src/main/resources/mapper_xml/TaskStocktakingMapper.xml

@@ -2,7 +2,7 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.jsh.erp.datasource.mappers.TaskStocktakingMapper">
 
-    <select id="pdaList" resultType="com.jsh.erp.datasource.pda.vo.PDATaskStocktakingVO">
+    <select id="pdaList" parameterType="com.jsh.erp.datasource.pda.dto.PDATaskStocktakingDTO" resultType="com.jsh.erp.datasource.pda.vo.PDATaskStocktakingVO">
         SELECT
             ts.id AS id,
             ts.task_name AS task_name,
@@ -26,7 +26,7 @@
         <where>
             ts.delete_flag = 0
             <if test="number != null and number != ''">
-                AND (ts.task_name LIKE CONCAT('%',#{taskName},'%') OR ts.number LIKE CONCAT('%',#{number},'%'))
+                AND (ts.task_name LIKE CONCAT('%',#{number},'%') OR ts.number LIKE CONCAT('%',#{number},'%'))
             </if>
             <if test="taskStatus != null and taskStatus != 0">
                 AND ts.task_status = #{taskStatus}
@@ -37,7 +37,7 @@
         </where>
     </select>
 
-    <select id="listBy" resultType="com.jsh.erp.datasource.vo.TaskStocktakingVO">
+    <select id="listBy" parameterType="com.jsh.erp.datasource.dto.TaskStocktakingQueryDTO" resultType="com.jsh.erp.datasource.vo.TaskStocktakingVO">
         SELECT
             ts.id AS id,
             ts.number AS number,
@@ -45,19 +45,36 @@
             ts.task_type AS task_type,
             d.`name` AS depot_name,
             ts.position_range AS position_range,
-            ju.username AS create_name,
+            ju.username AS create_by_name,
             ts.create_time AS create_time,
             u.username AS creator_name,
             ts.task_status AS task_status,
-            ts.oper_time AS oper_time
+            ts.oper_time AS oper_time,
+            count(tsi.id) AS item_count,
+            count(tsi.id) AS material_count
         FROM
             task_stocktaking ts
                 LEFT JOIN jsh_depot d ON ts.depot_id = d.id
                 LEFT JOIN jsh_user ju ON ts.create_by = ju.id
                 LEFT JOIN jsh_user ou ON ts.oper_by = ou.id
                 LEFT JOIN jsh_user u ON ts.creator = u.id
+                LEFT JOIN task_stocktaking_item tsi ON ts.id = tsi.task_stocktaking_id
         <where>
             ts.delete_flag = 0
+            <if test="number != null and number != ''">
+                AND (ts.number LIKE CONCAT('%',#{number},'%') OR ts.task_name LIKE CONCAT('%',#{number},'%'))
+            </if>
+            <if test="taskStatus != null and taskStatus != 0">
+                AND ts.task_status = #{taskStatus}
+            </if>
+            <if test="depotId != null and depotId !=''">
+                AND ts.depot_id = #{depotId}
+            </if>
+            <if test="createBy != null and createBy !=''">
+                AND ts.create_by = #{createBy}
+            </if>
+        GROUP BY
+            ts.id
         ORDER BY
             ts.create_time DESC,
             ts.id DESC