-- ----------------------------- 2024-05-10 add by gaozq------------begin

alter table T_LIMS_EQUIPT add column PLANMAINTAINDATE DATETIME null comment '计划点检时间';

CALL INSERTI18N('T_LIMS_EQUIPT.PLANMAINTAINDATE','计划点检时间','计划点检时间','zh-CN','计划点检时间');
-- ----------------------------- 2024-05-10 add by gaozq------------end

-- ----------------------------- 2024-05-11 add by zhangs------------begin
INSERT INTO t_lims_report_basic_item (ID,CATEGORYID,PARAMCODE,PARAMNAME,SORTER,CHOOSEPAGECONFIG) VALUES
(1386045527755456,'reportTemplateType','lanDianResultExport','蓝电测试数据导出',9,NULL);

INSERT INTO t_lims_report_template (ID,TEMPLATECODE,TEMPLATENAME,TEMPLATETYPE,TEMPLATEFILEID,TEMPLATEFILENAME,TEMPLATEMODALTYPE,PARAM,REMARK,CREATEDBYID,CREATEDBYNAME,CREATEDTIME,CREATEDBYORGID,CREATEDBYORGNAME,ACTIVATEDFLAG,ACTIVATEDBYID,ACTIVATEDBYNAME,ACTIVATEDTIME,LAB,VERSIONNO) VALUES
(1386064709132128,'RT20240500001','蓝电测试数据导出模板','lanDianResultExport',1386079729500000,'蓝电测试数据导出模板.xlsx','word','FOLDERIDS',NULL,'zhangs','张胜','2024-05-11 15:15:53','RT','湖北融通高科先进材料股份有限公司',NULL,NULL,NULL,NULL,NULL,'V1.0');
INSERT INTO t_lims_report_template_file (ID,REPORTTEMPLATEID,FILEID,VERSIONNO,REMARK,ACTIVATEDFLAG,ACTIVATEDTIME,ACTIVATEDBYID,ACTIVATEDBYNAME,CREATEDBYID,CREATEDBYNAME,CREATEDTIME,CREATEDBYORGID,CREATEDBYORGNAME,UPLOADBYID,UPLOADBYNAME,UPLOADTIME) VALUES
(1386065573412704,1386064709132128,1386079729500000,'V1.0',NULL,'1','2024-05-11 15:20:17','zhangs','张胜','zhangs','张胜','2024-05-11 15:17:38','RT','湖北融通高科先进材料股份有限公司','zhangs','张胜','2024-05-11 15:46:00');
-- ----------------------------- 2024-05-11 add by zhangs------------end

-- ----------------------------- 2024-05-15 add by zhangs------------begin
INSERT INTO t_core_constant (ID,CONSTANTVALUE,CONSTANTDESC,CLASSFICATION,`SHOW`,LASTUPDATEDTIME,CREATEDTIME,CREATEDBYID,CREATEDBYNAME,LASTUPDATEDBYID,LASTUPDATEDBYNAME,VERSION) VALUES
('InvokeRestfulMomSwitch','0','LIMS调用MOM-RESTFul接口开关，1开启','系统','1',NULL,NULL,NULL,NULL,NULL,NULL,NULL);

INSERT INTO t_core_constant (ID,CONSTANTVALUE,CONSTANTDESC,CLASSFICATION,`SHOW`,LASTUPDATEDTIME,CREATEDTIME,CREATEDBYID,CREATEDBYNAME,LASTUPDATEDBYID,LASTUPDATEDBYNAME,VERSION) VALUES
('syncOrderStatusToMomUrl','http://172.22.5.27:30080/rtgk-tznq/v1/15/rtgk-sample-receipt-sync/batch-update','LIMS调用MOM-RESTFul LIMS-取样任务状态同步接口','系统','1',NULL,NULL,NULL,NULL,NULL,NULL,NULL);

INSERT INTO t_core_constant (ID,CONSTANTVALUE,CONSTANTDESC,CLASSFICATION,`SHOW`,LASTUPDATEDTIME,CREATEDTIME,CREATEDBYID,CREATEDBYNAME,LASTUPDATEDBYID,LASTUPDATEDBYNAME,VERSION) VALUES
('syncTestAndAnalyteInfoToMomUrl','http://172.22.5.27:30080/rtgk-tznq/v1/15/rtgk-lims-interface/item-synchronize','LIMS调用MOM-RESTFul LIMS-理化检验项目同步接口','系统','1',NULL,NULL,NULL,NULL,NULL,NULL,NULL);

INSERT INTO t_core_constant (ID,CONSTANTVALUE,CONSTANTDESC,CLASSFICATION,`SHOW`,LASTUPDATEDTIME,CREATEDTIME,CREATEDBYID,CREATEDBYNAME,LASTUPDATEDBYID,LASTUPDATEDBYNAME,VERSION) VALUES
('syncTestResultsToMomUrl','http://172.22.5.27:30080/rtgk-tznq/v1/15/rtgk-inspect-value-sync/batch-update','LIMS调用MOM-RESTFul LIMS-检验结果同步接口','系统','1',NULL,NULL,NULL,NULL,NULL,NULL,NULL);
-- ----------------------------- 2024-05-15 add by zhangs------------end

-- ----------------------------- 2024-05-17 add by zhangs------------begin
ALTER TABLE t_lims_task ADD MOMHANDDATA varchar(1) NULL COMMENT 'MOM HAND推送的实验';
-- ----------------------------- 2024-05-17 add by zhangs------------end

-- ----------------------------- 2024-05-20 add by zhangs------------begin
ALTER TABLE t_lims_folder ADD INSPECTIONNUMBERHAND varchar(100) NULL COMMENT '检验单单号';
ALTER TABLE t_lims_folder ADD SAMPLETASKNUMBERHAND varchar(100) NULL COMMENT '取样单单号';

INSERT INTO t_core_schedule_task (ID,TASKNAME,SERVICENAME,METHODNAME,REMARK,CREATEDBYID,CREATEDBYNAME,CREATEDTIME,CREATEDBYORGID,CREATEDBYORGNAME,`TYPE`,IFEXECUTABLESERVICENAME,IFEXECUTABLEMETHODNAME) VALUES
('initializeTestAndAnalyteInfoToMom','初始时同步检测项目，由定时任务触发一次','com.sunwayworld.basemodule.business.test.folder.restfulmom.service.RestfulMomService','initializeTestAndAnalyteInfoToMom',NULL,NULL,NULL,NULL,NULL,NULL,'service',NULL,NULL);
-- ----------------------------- 2024-05-20 add by zhangs------------end

-- ----------------------------- 2024-05-27 add by zhangs--------------begin

-- 建表语句

CREATE TABLE IF NOT EXISTS `T_LIMS_TEST_SPLIT`(
     `ID` BIGINT NOT NULL COMMENT '主键',
     `TESTID` BIGINT DEFAULT NULL COMMENT '项目ID',
     `ITEMID` BIGINT DEFAULT NULL COMMENT '其他项目ID',
     `CREATEDBYID` VARCHAR(36)  DEFAULT NULL COMMENT '制单人编码',
     `CREATEDBYNAME` VARCHAR(60)  DEFAULT NULL COMMENT '制单人名称',
     `CREATEDTIME` DATETIME DEFAULT NULL COMMENT '制单时间',
     `CREATEDBYORGID` VARCHAR(36)  DEFAULT NULL COMMENT '制单人单位编码',
     `CREATEDBYORGNAME` VARCHAR(270)  DEFAULT NULL COMMENT '制单人单位名称',
      PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='MOM检测项目拆分';


INSERT INTO T_CORE_AT_CONFIG (ID, AUDITTRAIL, CREATEDBYID, CREATEDBYNAME, CREATEDTIME, CREATEDBYORGID, CREATEDBYORGNAME)
VALUES ('T_LIMS_TEST_SPLIT', '1', 'zhangsheng', 'zhangsheng', NOW(), 'L005', '五行业');


INSERT INTO T_CORE_AUDIT_CONFIG (ID, NAME, CATEGORY, AUDITABLE)
VALUES ('T_LIMS_TEST_SPLIT', 'MOM检测项目拆分', 'service', '1');
CALL INSERTI18N('T_LIMS_TEST_SPLIT.SERVICE_NAME', 'MOM检测项目拆分', 'MOM检测项目拆分', 'zh-CN', 'MOM检测项目拆分');
CALL INSERTI18N('T_LIMS_TEST_SPLIT.ID', 'MOM检测项目拆分的主键', '主键', 'zh-CN', '主键');
CALL INSERTI18N('T_LIMS_TEST_SPLIT.TESTID', 'MOM检测项目拆分的项目ID', '项目ID', 'zh-CN', '项目ID');
CALL INSERTI18N('T_LIMS_TEST_SPLIT.ITEMID', 'MOM检测项目拆分的其他项目ID', '其他项目ID', 'zh-CN', '其他项目ID');
CALL INSERTI18N('T_LIMS_TEST_SPLIT.CREATEDBYID', 'MOM检测项目拆分的制单人编码', '制单人编码', 'zh-CN', '制单人编码');
CALL INSERTI18N('T_LIMS_TEST_SPLIT.CREATEDBYNAME', 'MOM检测项目拆分的制单人名称', '制单人名称', 'zh-CN', '制单人名称');
CALL INSERTI18N('T_LIMS_TEST_SPLIT.CREATEDTIME', 'MOM检测项目拆分的制单时间', '制单时间', 'zh-CN', '制单时间');
CALL INSERTI18N('T_LIMS_TEST_SPLIT.CREATEDBYORGID', 'MOM检测项目拆分的制单人单位编码', '制单人单位编码', 'zh-CN', '制单人单位编码');
CALL INSERTI18N('T_LIMS_TEST_SPLIT.CREATEDBYORGNAME', 'MOM检测项目拆分的制单人单位名称', '制单人单位名称', 'zh-CN', '制单人单位名称');
CALL INSERTI18N('BASEMODULE.COREDATA.TESTS.MODAL.ADD', '新增', '新增', 'zh-CN', '新增');
CALL INSERTI18N('BASEMODULE.COREDATA.TESTS.TAB.BASE_INFO', '基本信息', '基本信息', 'zh-CN', '基本信息');
CALL INSERTI18N('BASEMODULE.COREDATA.TESTS.BUTTON.BUTTON', '按钮', '按钮', 'zh-CN', '按钮');
CALL INSERTI18N('BASEMODULE.COREDATA.TESTS.TIP.TIP', '提示框', '提示框', 'zh-CN', '提示框');
CALL INSERTI18N('BASEMODULE.COREDATA.TESTS.MODAL.MODAL', '对话框', '对话框', 'zh-CN', '对话框');


INSERT INTO T_CORE_TABLE (ID, AUDITABLE, ATTACHMENT)
VALUES ('T_LIMS_TEST_SPLIT', '0', '0');


COMMIT;
CREATE INDEX t_lims_test_split_TESTID_IDX USING BTREE ON t_lims_test_split (TESTID);
CREATE INDEX t_lims_test_split_ITEMID_IDX USING BTREE ON t_lims_test_split (ITEMID);
ALTER TABLE t_lims_test ADD MOMFORMULA longtext NULL COMMENT 'MOM结果取值公式';
ALTER TABLE t_lims_task ADD TESTSPLITFLAG varchar(1) NULL COMMENT 'LIMS拆分细分项目标记';
ALTER TABLE t_lims_task ADD PARENTTESTID bigint NULL COMMENT '父级试验ID';
ALTER TABLE t_lims_test_split CHANGE TESTID PARENTTESTID bigint NULL COMMENT '父项目ID';
ALTER TABLE t_lims_test_split MODIFY COLUMN PARENTTESTID bigint NULL COMMENT '父项目ID';
-- ----------------------------- 2024-05-27 add by zhangs------------end

-- ----------------------------- 2024-05-29 add by zhangs------------begin
INSERT INTO t_core_constant (ID,CONSTANTVALUE,CONSTANTDESC,CLASSFICATION,`SHOW`,LASTUPDATEDTIME,CREATEDTIME,CREATEDBYID,CREATEDBYNAME,LASTUPDATEDBYID,LASTUPDATEDBYNAME,VERSION) VALUES
('momTokenUrl','http://61.157.139.13:30080/oauth/oauth/token','LIMS调用MOM-RESTFul 获取accessToken','系统','1',NULL,NULL,NULL,NULL,NULL,NULL,NULL);
INSERT INTO t_core_constant (ID,CONSTANTVALUE,CONSTANTDESC,CLASSFICATION,`SHOW`,LASTUPDATEDTIME,CREATEDTIME,CREATEDBYID,CREATEDBYNAME,LASTUPDATEDBYID,LASTUPDATEDBYNAME,VERSION) VALUES
('momTokenClient_id','RTGK-ITF','LIMS调用MOM-RESTFul 获取accessToken的client_id','系统','1',NULL,NULL,NULL,NULL,NULL,NULL,NULL);
INSERT INTO t_core_constant (ID,CONSTANTVALUE,CONSTANTDESC,CLASSFICATION,`SHOW`,LASTUPDATEDTIME,CREATEDTIME,CREATEDBYID,CREATEDBYNAME,LASTUPDATEDBYID,LASTUPDATEDBYNAME,VERSION) VALUES
('momTokenClient_secret','rtgk#2024','LIMS调用MOM-RESTFul 获取accessToken的client_secret','系统','1',NULL,NULL,NULL,NULL,NULL,NULL,NULL);
-- ----------------------------- 2024-05-29 add by zhangs------------end

-- ----------------------------- 2024-05-30 add by zhangs------------begin
CALL INSERTI18N('T_LIMS_EQUIP_MAINTAIN_PLAN_ITEM.LASTMAINTAINTIME', '上次保养/点检时间', '上次保养/点检时间', 'zh-CN', '上次保养/点检时间');
CALL INSERTI18N('T_LIMS_EQUIP_MAINTAIN_PLAN_ITEM.NEXTMAINTAINTIME', '下次保养/点检时间', '下次保养/点检时间', 'zh-CN', '下次保养/点检时间');

delete from t_core_todo_config where id=1397926727832128;

INSERT INTO t_core_todo_config (ID,NAME,MENUID,CATEGORY,ICON,INHERITPARAM,JSONPARAM,SERVICEMETHOD,ACTIVATEDFLAG,ACTIVATEDBYID,ACTIVATEDBYNAME,ACTIVATEDTIME,DESCEXPRESSION,ORDERNO,I18NCODE,VOICEWARNING,SELECTSQL) VALUES
	 (1397926727832128,'点检待办','20230919003','business','006.png','1',NULL,NULL,'1','admin','系统管理员','2024-05-28 09:56:37',NULL,NULL,NULL,'1','select
	count(1)
		from
			T_LIMS_EQUIP_MAINTAIN_RECORD T
		left join T_LIMS_EQUIPT E on
			T.EQUIPID = E.ID
			where
		 T.STATUS = ''0''
		and exists (
		select
			1
		from
			T_CORE_USER_PERMISSION TCUP
		where
			TCUP.USERID = ''${loginUserId}''
			and TCUP.PERMISSIONTYPEID = ''T_CORE_ORG''
			and E.orgId = TCUP.TARGETID)');
-- ----------------------------- 2024-05-30 add by zhangs------------end

-- ----------------------------- 2024-05-31 add by zhangs------------begin
ALTER TABLE T_LIMS_TASK ADD INSPECTIONNUMBERHAND varchar(100) NULL COMMENT '检验单单号';
ALTER TABLE t_lims_folder DROP COLUMN INSPECTIONNUMBERHAND;
-- ----------------------------- 2024-05-31 add by zhangs------------end




