v0002_yq_bar.sql 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. # 新增圈舍名称字段pen和长度length字段
  2. UPDATE apisql SET sqlstr = 'SELECT
  3. bcode,bname,allowratio,autozone,autosecond,isstart,
  4. begintag,endtag,sort,enable,autosecondname,length,pen,
  5. TRIM(id) id,
  6. TRIM(pastureid)pastureid,
  7. udcode,udname
  8. FROM
  9. bar
  10. WHERE pastureid = ?
  11. AND ( bname LIKE CONCAT(''%'',?,''%'') OR ? = '''')
  12. AND ( bcode LIKE CONCAT(''%'',?,''%'') OR ? = '''')
  13. AND ( pen LIKE CONCAT(''%'',?,''%'') OR ? = '''')
  14. AND (allowratio = ? OR ? = '''')
  15. AND (enable =? OR ? = '''')
  16. AND (autozone= ? OR ? = '''')
  17. AND (autosecond = ? OR ? = '''')
  18. ORDER BY sort ',
  19. params = 'pastureid,bname,bname,bcode ,bcode,pen,pen ,allowratio ,allowratio ,enable ,enable,autozone,autozone,autosecond,autosecond'
  20. where sqlname = 'getBarList' and enable = 1;
  21. # 新增圈舍名称字段pen和长度length字段
  22. UPDATE apisql SET sqlstr = '
  23. update bar set bcode=? ,bname=?,allowratio=? ,autozone=?,autosecond=?,autosecondname=?,isstart=? ,enable=?,AUFNR = ?,pen = ?,length = ?
  24. where pastureid=? and id=?',
  25. params = 'bcode,bname,allowratio,autozone,autosecond,autosecondname,isstart,enable,AUFNR,pen,length,pastureid,id'
  26. where sqlname = 'updateBar' and enable = 1;
  27. # 新增speend 车速字段
  28. UPDATE apisql SET sqlstr ="SELECT 0 islock,
  29. eqcode,tname,datacaptureno,trim(tclassid) tclassid,
  30. (SELECT dictlist.label FROM dictlist JOIN dict ON dict.id=dictlist.pid WHERE dict.name='TMR设备类型' AND dict.ENABLE=1 and dictlist .enable=1 and value = tclassid) as tclassname,
  31. maxstirfeed,remark,enable,TRIM(id) id,TRIM(pastureid)pastureid,
  32. tcolor,imei,ifnull(datainterface,1),autozone,autosecond,if(autosecondname= '' or autosecondname is null,'禁用',autosecondname ) autosecondname,(select pasture_name from pasture where pastureid = tmr.pastureid) as pasturename,
  33. ifnull(gps,'') gps ,volume,speed,
  34. TRIM(TRAILING ''.'' FROM TRIM(TRAILING ''0'' FROM FORMAT(volume_rate, 20))) AS volume_rate
  35. FROM
  36. tmr
  37. WHERE pastureid = ? and if(?=0,tclassid in (0,6,7),tclassid in (1,2,3,4))
  38. AND (tmr.eqcode LIKE CONCAT('%',?,'%') OR ? = '')
  39. AND (tmr.tclassname =? OR ? = '')
  40. AND (tmr.tname =? OR ? = '')
  41. AND (tmr.enable =? OR ? = '') AND (tmr.imei =? OR ? = '')
  42. ORDER BY tmr.id DESC",params = 'pastureid,eqtype,eqcode,eqcode,classname,classname,tname,tname,enable,enable,imei,imei'
  43. where sqlname = 'getTmrList' and enable = 1;
  44. # 新增speend 车速字段
  45. update apisql SET sqlstr ="update tmr join dictlist JOIN `dict` ON `dict`.`id`=dictlist.`pid` set eqcode=? ,tname=? ,datacaptureno=?,tclassid=?,tclassname=? ,maxstirfeed=?,tmr.enable=?,remark=? ,tcolor = ?,imei=?,datainterface=?,autozone=if(?='',null,?),autosecond=if(?='',null,?), autosecondname=dictlist.label,gps = ?,volume = ?,speed = ifnull(?,0), volume_rate = ? where tmr.pastureid=? and tmr.id= ? and `dict`.`name`='跳转延时' AND `dict`.ENABLE=1 and dictlist.enable=1 and dictlist.`value` =? ",
  46. params = 'eqcode,tname,datacaptureno,tclassid,tclassname,maxstirfeed,enable,remark,tcolor,imei,datainterface,autozone,autozone,autosecond,autosecond,gps,volume,speed,volume_rate,pastureid,id,autosecond'
  47. where sqlname = 'updateTMR' and enable = 1;
  48. # 新增TMR设备撒料档位操作
  49. insert into apisql(sqlname,sqlstr,params) values ('getTmrGearList','select * from tmr_gear where tmr_id = ? order by rev', 'tmrId');
  50. # 新增圈舍下拉框列表数据
  51. insert into apisql(sqlname,sqlstr,params) values ('getPenList','select id,pen from bar where pastureid = ? and enable = 1 and isdelete = 0 and pen is not null group by pen order by sort', 'pastureid');
  52. ALTER TABLE `tmr` ADD COLUMN `volume_rate` decimal(12,5) NOT NULL COMMENT '撒料机每转体积';
  53. # 新增圈舍
  54. update apisql SET sqlstr = "INSERT INTO bar
  55. (pastureid,bcode,bname,allowratio,autozone,autosecond,autosecondname,isstart,enable,sort,AUFNR,pen,length)
  56. VALUES (?,?,?,?,?,?,?,?,?,( select max(b.sort) + 1 from bar b where b.pastureid = ? ),?,?,?)",
  57. params = 'pastureid,bcode,bname,allowratio,autozone,autosecond,autosecondname,isstart,enable,pastureid,AUFNR,pen,length'
  58. where sqlname = 'insertBar' and enable = 1;
  59. # 修改栏舍索引
  60. delete table from bar;
  61. # 新建栏舍表
  62. CREATE TABLE `bar` (
  63. `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '栏舍id',
  64. `pastureid` BIGINT(20) UNSIGNED NOT NULL COMMENT '牧场id',
  65. `bcode` VARCHAR(50) DEFAULT NULL COMMENT '栏舍编号',
  66. `bname` VARCHAR(200) NOT NULL COMMENT '栏舍名称',
  67. `allowratio` INT(11) DEFAULT 0 COMMENT '允许误差数',
  68. `autozone` INT(11) DEFAULT 0 COMMENT '跳转重量域(kg)',
  69. `autosecond` INT(4) DEFAULT 0 COMMENT '跳转延时值',
  70. `autosecondname` VARCHAR(50) DEFAULT NULL COMMENT '跳转延时名称',
  71. `isstart` TINYINT(1) DEFAULT 1 COMMENT '确认开始',
  72. `begintag` INT(11) DEFAULT NULL,
  73. `endtag` INT(11) DEFAULT NULL,
  74. `sort` INT(11) DEFAULT 0 COMMENT '排序',
  75. `enable` TINYINT(1) DEFAULT 1 COMMENT '是否启用',
  76. `isdelete` TINYINT(1) DEFAULT 0 COMMENT '是否删除(0为未删除,1为伪删除)',
  77. `backup1` VARCHAR(255) DEFAULT NULL COMMENT '备用1',
  78. `backup2` VARCHAR(255) DEFAULT NULL COMMENT '备用2',
  79. `AUFNR` VARCHAR(50) DEFAULT NULL COMMENT 'sap牛群订单行号',
  80. `class` VARCHAR(50) DEFAULT NULL COMMENT '牛舍类型',
  81. `classcode` VARCHAR(50) DEFAULT NULL COMMENT '牛舍类型编码',
  82. `cattle` VARCHAR(50) DEFAULT NULL COMMENT '牛群',
  83. `cattlecode` VARCHAR(50) DEFAULT NULL COMMENT '牛群编码',
  84. `sapCode` VARCHAR(50) DEFAULT NULL,
  85. `udcode` VARCHAR(50) DEFAULT NULL,
  86. `udname` VARCHAR(50) DEFAULT NULL,
  87. `length` DECIMAL(12,0) NOT NULL DEFAULT 0 COMMENT '栏舍长度',
  88. `pen` VARCHAR(30) DEFAULT NULL COMMENT '圈舍',
  89. PRIMARY KEY (`id`) USING BTREE,
  90. UNIQUE KEY `ind_pastureId_bname` (`pastureid`,`bname`)
  91. ) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 ROW_FORMAT=DYNAMIC COMMENT='栏舍';
  92. # 删除tmr表
  93. delete table from tmr;
  94. CREATE TABLE `tmr` (
  95. `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'tmr',
  96. `pastureid` BIGINT(20) UNSIGNED NOT NULL,
  97. `eqcode` CHAR(20) DEFAULT NULL COMMENT 'tmr设备编号',
  98. `tname` VARCHAR(20) NOT NULL COMMENT 'tmr车名称',
  99. `datacaptureno` INT(11) NOT NULL DEFAULT 0 COMMENT '数据采集卡编号',
  100. `tclassid` BIGINT(20) NOT NULL COMMENT 'tmr设备类型',
  101. `tclassname` VARCHAR(50) DEFAULT NULL,
  102. `ttype` TINYINT(4) DEFAULT NULL COMMENT '设备类型 0铲车,1tmr,3撒料设备,4小料',
  103. `maxstirfeed` INT(11) DEFAULT 0 COMMENT '最大搅料量(kg)(默认0)',
  104. `sort` INT(11) NOT NULL DEFAULT 0 COMMENT '顺序',
  105. `enable` TINYINT(1) NOT NULL DEFAULT 1 COMMENT '启用',
  106. `inorout` SMALLINT(1) NOT NULL DEFAULT 0 COMMENT '当前是否撒料(默认2车不在使用,1撒料,0是做料)',
  107. `projid` BIGINT(20) DEFAULT 0 COMMENT '当前执行计划',
  108. `lastsort` VARCHAR(20) DEFAULT NULL COMMENT '上一个料',
  109. `lastweight` DECIMAL(20,3) DEFAULT NULL COMMENT '上次目标重量',
  110. `lastbuttontime` DATETIME DEFAULT NULL COMMENT '上次执行时间',
  111. `nextsort` BIGINT(20) DEFAULT 0 COMMENT '下一个料',
  112. `nextweight` DECIMAL(20,3) DEFAULT NULL COMMENT '下次目标重量',
  113. `issounding` INT(11) DEFAULT 0,
  114. `tcolor` VARCHAR(50) DEFAULT '#ccc',
  115. `remark` VARCHAR(255) DEFAULT NULL COMMENT '备注',
  116. `imei` VARCHAR(255) DEFAULT NULL COMMENT 'imei唯一标识',
  117. `datainterface` VARCHAR(255) DEFAULT NULL COMMENT '数据接口',
  118. `autozone` INT(11) DEFAULT NULL COMMENT '跳转重量(kg',
  119. `autosecond` INT(11) DEFAULT NULL COMMENT '跳转延时值',
  120. `autosecondname` VARCHAR(50) DEFAULT NULL COMMENT '跳转延时名称',
  121. `lastinorout` INT(1) DEFAULT 0,
  122. `gps` VARCHAR(50) DEFAULT NULL,
  123. `volume` DECIMAL(12,2) NOT NULL DEFAULT 0.00 COMMENT '容积',
  124. `speed` DECIMAL(12,0) NOT NULL DEFAULT 0 COMMENT '速度',
  125. `volume_rate` DECIMAL(12,5) NOT NULL COMMENT '撒料机每转体积',
  126. PRIMARY KEY (`id`) USING BTREE,
  127. UNIQUE KEY `tmr_datacaptureno` (`datacaptureno`,`pastureid`) USING BTREE,
  128. UNIQUE KEY `tmr_tname` (`pastureid`,`tname`,`ttype`) USING BTREE,
  129. UNIQUE KEY `tmr_eqcode` (`pastureid`,`eqcode`,`ttype`) USING BTREE
  130. ) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COMMENT='TMR设备表';
  131. # 新增TMR 栏舍表
  132. update apisql SET sqlstr = "INSERT INTO tmr(pastureid,eqcode,tname,datacaptureno,tclassid,tclassname,maxstirfeed,
  133. `enable`,remark,ttype,tcolor,imei,datainterface,autozone,autosecond,autosecondname,gps,volume,speed,volume_rate)
  134. VALUES (?,?,?,?,?,?,?,?,?,if(?<>0,1,0),?,if(?='''',null,?),?,if(?='''',null,?),if(?='''',null,?),?,?,?,ifnull(?,0),?)",
  135. params = 'pastureid,eqcode,tname,datacaptureno,tclassid,tclassname,maxstirfeed,enable,remark,tclassid,tcolor,imei,imei,datainterface,autozone,autozone,autosecond,autosecond,autosecondname,gps,volume,speed,volume_rate'
  136. where sqlname = 'insertTmr' and enable = 1;
  137. update apisql SET sqlstr = "SELECT bname,TRIM(id) id FROM bar WHERE pastureid = ? and pen = ? and enable=1 ORDER BY id DESC",
  138. params = "pastureid,pen"
  139. where sqlname = 'getBarListEnable' and enable = 1;