sap.sql 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. ALTER TABLE `pasture`
  2. ADD COLUMN `empId` int NULL COMMENT '供应负责人';
  3. ALTER TABLE `diesel`
  4. ADD COLUMN `sort` int(11) DEFAULT NULL;
  5. ALTER TABLE `diesel`
  6. ADD COLUMN `oilType` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '柴油类型 0: 空 1: 0# 2: -10# 3: -20# 4: -30# 5: -35#';
  7. ALTER TABLE `diesel`
  8. ADD COLUMN `oilName` varchar(255) NOT NULL DEFAULT '' COMMENT '柴油类型名称';
  9. ALTER TABLE `diesel`
  10. ADD COLUMN`dieselCode` varchar(50) DEFAULT NULL;
  11. ALTER TABLE `diesel`
  12. ADD COLUMN
  13. `ProofCode` varchar(50) DEFAULT NULL;
  14. CREATE TABLE `diesel_off` (
  15. `id` int(11) NOT NULL,
  16. `pastureId` int(11) NOT NULL COMMENT '牧场ID',
  17. `deptId` int(11) DEFAULT NULL,
  18. `eqId` int(11) DEFAULT NULL COMMENT '备件编号',
  19. `eqCode` varchar(100) DEFAULT NULL,
  20. `oilcardId` int(11) DEFAULT NULL,
  21. `cardNumber` varchar(200) NOT NULL COMMENT '卡号',
  22. `oilClass` varchar(100) DEFAULT NULL COMMENT '加油工班',
  23. `oilAmount` decimal(20,2) DEFAULT NULL COMMENT '油量',
  24. `nowPrice` decimal(10,2) DEFAULT NULL COMMENT '本次金额',
  25. `price` decimal(10,2) DEFAULT NULL COMMENT '单价',
  26. `empId` varchar(100) DEFAULT NULL COMMENT '上班加油工',
  27. `inputId` int(11) DEFAULT NULL COMMENT '录入人',
  28. `selTime` varchar(100) DEFAULT NULL COMMENT '交易时间',
  29. `note` varchar(255) DEFAULT NULL COMMENT '备注',
  30. `ProofCode` varchar(50) DEFAULT NULL,
  31. `oilType` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '柴油类型 0: 空 1: 0# 2: -10# 3: -20# 4: -30# 5: -35#',
  32. `oilName` varchar(255) NOT NULL DEFAULT '' COMMENT '柴油类型名称',
  33. `dieselCode` varchar(50) DEFAULT NULL,
  34. `sort` int(11) DEFAULT NULL,
  35. `createTime` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  36. PRIMARY KEY (`id`) USING BTREE,
  37. KEY `selTime` (`selTime`) USING BTREE
  38. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  39. -- 水费
  40. insert into feequery(pastureId,RBUKRS,WERKS,FYLX,GJAHR,POPER,HSL,Date)
  41. select pastureId,p.company_code,p.factory_code,"水费", date_format(date ,'%Y'),date_format(date ,'%m'), sum(sumPrice) sumPrice, date_format(date ,'%Y-%m') from water join pasture p on p.id = pastureId where date_format(date ,'%Y') = '2022'
  42. group by pastureId,date_format(date ,'%Y-%m')
  43. -- 电费
  44. insert into feequery(pastureId,RBUKRS,WERKS,FYLX,GJAHR,POPER,HSL,Date)
  45. select pastureId,p.company_code,p.factory_code,"电费", date_format(date ,'%Y'),date_format(date ,'%m'), sum(sumPrice) sumPrice, date_format(date ,'%Y-%m') from electricity join pasture p on p.id = pastureId where date_format(date ,'%Y') = '2022'
  46. group by pastureId,date_format(date ,'%Y-%m')
  47. -- 燃动费
  48. insert into feequery(pastureId,RBUKRS,WERKS,FYLX,GJAHR,POPER,HSL,Date)
  49. select pastureId,p.company_code,p.factory_code,"燃动费", date_format(selTime ,'%Y'),date_format(selTime ,'%m'), sum(nowPrice) sumPrice, date_format(selTime ,'%Y-%m') from diesel join pasture p on p.id = pastureId where date_format(selTime ,'%Y') = '2022'
  50. group by pastureId,date_format(selTime ,'%Y-%m')