--预设成本要素数据

IF NOT EXISTS (SELECT 1 FROM T_CAD_ELEMENT WHERE FID = 773126985240072192)
INSERT INTO T_CAD_ELEMENT(FID,FTYPE,FCREATETIME,FMODIFIERID,FENABLE,FMODIFYTIME,FSTATUS,FCREATORID,FNUMBER,FISSYSTEM,FMASTERID,FELEMENTTYPEID) VALUES (773126985240072192,'001',{ts'2019-12-03  17:05:02'},1,'1',{ts'2019-12-03  18:38:55'},'C',1,'E001','1',773126985240072192,773131716901523456); 


IF NOT EXISTS (SELECT 1 FROM T_CAD_ELEMENT WHERE FID = 773141433937984512)
INSERT INTO T_CAD_ELEMENT(FID,FTYPE,FCREATETIME,FMODIFIERID,FENABLE,FMODIFYTIME,FSTATUS,FCREATORID,FNUMBER,FISSYSTEM,FMASTERID,FELEMENTTYPEID) VALUES (773141433937984512,'002',{ts'2019-12-03  17:33:43'},1,'1',{ts'2019-12-03  18:39:01'},'C',1,'E002','1',773141433937984512,773131716901523456); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_ELEMENT WHERE FID = 773177371976173568)
INSERT INTO T_CAD_ELEMENT(FID,FTYPE,FCREATETIME,FMODIFIERID,FENABLE,FMODIFYTIME,FSTATUS,FCREATORID,FNUMBER,FISSYSTEM,FMASTERID,FELEMENTTYPEID) VALUES (773177371976173568,'003',{ts'2019-12-03  18:45:04'},1,'1',{ts'2019-12-03  18:45:50'},'C',1,'E003','1',773177371976173568,773131716901523456); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_ELEMENT WHERE FID = 773173188837423104)
INSERT INTO T_CAD_ELEMENT(FID,FTYPE,FCREATETIME,FMODIFIERID,FENABLE,FMODIFYTIME,FSTATUS,FCREATORID,FNUMBER,FISSYSTEM,FMASTERID,FELEMENTTYPEID) VALUES (773173188837423104,'004',{ts'2019-12-03  18:36:49'},1,'1',{ts'2019-12-03  18:39:11'},'C',1,'E004','1',773173188837423104,773131716901523456); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_ELEMENT WHERE FID = 773173574319126528)
INSERT INTO T_CAD_ELEMENT(FID,FTYPE,FCREATETIME,FMODIFIERID,FENABLE,FMODIFYTIME,FSTATUS,FCREATORID,FNUMBER,FISSYSTEM,FMASTERID,FELEMENTTYPEID) VALUES (773173574319126528,'005',{ts'2019-12-03  18:37:34'},1,'1',{ts'2019-12-03  18:39:15'},'C',1,'E005','1',773173574319126528,773131716901523456); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_ELEMENT_L WHERE FPKID = '0DYZF2XYBLA/')
INSERT INTO T_CAD_ELEMENT_L(FID,FPKID,FLOCALEID,FREMARKS,FNAME) VALUES (773126985240072192,'0DYZF2XYBLA/','zh_CN','系统预置','物料'); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_ELEMENT_L WHERE FPKID = '0DYZF2XYBLA0')
INSERT INTO T_CAD_ELEMENT_L(FID,FPKID,FLOCALEID,FREMARKS,FNAME) VALUES (773126985240072192,'0DYZF2XYBLA0','zh_TW','係統預置','物料'); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_ELEMENT_L WHERE FPKID = '0DZ04D3XAN00')
INSERT INTO T_CAD_ELEMENT_L(FID,FPKID,FLOCALEID,FREMARKS,FNAME) VALUES (773141433937984512,'0DZ04D3XAN00','zh_CN','系统预置','物料费用'); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_ELEMENT_L WHERE FPKID = '0DZ04D3XAN01')
INSERT INTO T_CAD_ELEMENT_L(FID,FPKID,FLOCALEID,FREMARKS,FNAME) VALUES (773141433937984512,'0DZ04D3XAN01','zh_TW','係統預置','物料費用'); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_ELEMENT_L WHERE FPKID = '0DZ64L5RIQ0U')
INSERT INTO T_CAD_ELEMENT_L(FID,FPKID,FLOCALEID,FREMARKS,FNAME) VALUES (773173574319126528,'0DZ64L5RIQ0U','zh_CN','系统预置','外协加工费'); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_ELEMENT_L WHERE FPKID = '0DZ64L5RIQ0V')
INSERT INTO T_CAD_ELEMENT_L(FID,FPKID,FLOCALEID,FREMARKS,FNAME) VALUES (773173574319126528,'0DZ64L5RIQ0V','zh_TW','係統預置','外協加工費'); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_ELEMENT_L WHERE FPKID = '0DZ6V9F693XG')
INSERT INTO T_CAD_ELEMENT_L(FID,FPKID,FLOCALEID,FREMARKS,FNAME) VALUES (773177371976173568,'0DZ6V9F693XG','zh_CN','系统预置','制造费用'); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_ELEMENT_L WHERE FPKID = '0DZ6V9F693XH')
INSERT INTO T_CAD_ELEMENT_L(FID,FPKID,FLOCALEID,FREMARKS,FNAME) VALUES (773177371976173568,'0DZ6V9F693XH','zh_TW','係統預置','製造費用'); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_ELEMENT_L WHERE FPKID = '0DZ61SM9J7U6')
INSERT INTO T_CAD_ELEMENT_L(FID,FPKID,FLOCALEID,FREMARKS,FNAME) VALUES (773173188837423104,'0DZ61SM9J7U6','zh_CN','系统预置','资源'); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_ELEMENT_L WHERE FPKID = '0DZ61SM9J7U7')
INSERT INTO T_CAD_ELEMENT_L(FID,FPKID,FLOCALEID,FREMARKS,FNAME) VALUES (773173188837423104,'0DZ61SM9J7U7','zh_TW','係統預置','資源'); 

--预设成本子要素
IF NOT EXISTS (SELECT 1 FROM T_CAD_SUBELEMENT WHERE FID = 773175233367685120)
INSERT INTO T_CAD_SUBELEMENT(FID,FTYPE,FCREATETIME,FMODIFIERID,FENABLE,FMODIFYTIME,FDEFAULTVALUE,FSTATUS,FCREATORID,FNUMBER,FISSYSTEM,FMASTERID) VALUES (773175233367685120,'001',{ts'2019-12-03  18:40:48'},1,'1',{ts'2019-12-03  18:41:10'},'1','C',1,'SE001','1',773175233367685120); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_SUBELEMENT WHERE FID = 773175492709890048)
INSERT INTO T_CAD_SUBELEMENT(FID,FTYPE,FCREATETIME,FMODIFIERID,FENABLE,FMODIFYTIME,FDEFAULTVALUE,FSTATUS,FCREATORID,FNUMBER,FISSYSTEM,FMASTERID) VALUES (773175492709890048,'002',{ts'2019-12-03  18:41:14'},1,'1',{ts'2019-12-03  18:41:41'},'1','C',1,'SE002','1',773175492709890048); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_SUBELEMENT WHERE FID = 773177997665679360)
INSERT INTO T_CAD_SUBELEMENT(FID,FTYPE,FCREATETIME,FMODIFIERID,FENABLE,FMODIFYTIME,FDEFAULTVALUE,FSTATUS,FCREATORID,FNUMBER,FISSYSTEM,FMASTERID) VALUES (773177997665679360,'003',{ts'2019-12-03  18:46:20'},1,'1',{ts'2019-12-03  18:46:39'},'1','C',1,'SE003','1',773177997665679360); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_SUBELEMENT WHERE FID = 773176352911296512)
INSERT INTO T_CAD_SUBELEMENT(FID,FTYPE,FCREATETIME,FMODIFIERID,FENABLE,FMODIFYTIME,FDEFAULTVALUE,FSTATUS,FCREATORID,FNUMBER,FISSYSTEM,FMASTERID) VALUES (773176352911296512,'004',{ts'2019-12-03  18:43:11'},1,'1',{ts'2019-12-03  18:43:23'},'1','C',1,'SE004','1',773176352911296512); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_SUBELEMENT WHERE FID = 773176488857077760)
INSERT INTO T_CAD_SUBELEMENT(FID,FTYPE,FCREATETIME,FMODIFIERID,FENABLE,FMODIFYTIME,FDEFAULTVALUE,FSTATUS,FCREATORID,FNUMBER,FISSYSTEM,FMASTERID) VALUES (773176488857077760,'005',{ts'2019-12-03  18:43:28'},1,'1',{ts'2019-12-03  18:43:39'},'1','C',1,'SE005','1',773176488857077760); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_SUBELEMENT_L WHERE FPKID = '0DZ6FONXR1PX')
INSERT INTO T_CAD_SUBELEMENT_L(FID,FPKID,FLOCALEID,FREMARKS,FNAME) VALUES (773175233367685120,'0DZ6FONXR1PX','zh_CN','系统预置','物料'); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_SUBELEMENT_L WHERE FPKID = '0DZ6FONXR1PY')
INSERT INTO T_CAD_SUBELEMENT_L(FID,FPKID,FLOCALEID,FREMARKS,FNAME) VALUES (773175233367685120,'0DZ6FONXR1PY','zh_TW','係統預置','物料'); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_SUBELEMENT_L WHERE FPKID = '0DZ6HKCB3999')
INSERT INTO T_CAD_SUBELEMENT_L(FID,FPKID,FLOCALEID,FREMARKS,FNAME) VALUES (773175492709890048,'0DZ6HKCB3999','zh_CN','系统预置','物料费用'); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_SUBELEMENT_L WHERE FPKID = '0DZ6HKCB399=')
INSERT INTO T_CAD_SUBELEMENT_L(FID,FPKID,FLOCALEID,FREMARKS,FNAME) VALUES (773175492709890048,'0DZ6HKCB399=','zh_TW','係統預置','物料費用'); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_SUBELEMENT_L WHERE FPKID = '0DZ6ZU8Y/4/4')
INSERT INTO T_CAD_SUBELEMENT_L(FID,FPKID,FLOCALEID,FREMARKS,FNAME) VALUES (773177997665679360,'0DZ6ZU8Y/4/4','zh_CN','系统预置','制造费用'); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_SUBELEMENT_L WHERE FPKID = '0DZ6ZU8Y/4/5')
INSERT INTO T_CAD_SUBELEMENT_L(FID,FPKID,FLOCALEID,FREMARKS,FNAME) VALUES (773177997665679360,'0DZ6ZU8Y/4/5','zh_TW','係統預置','製造費用'); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_SUBELEMENT_L WHERE FPKID = '0DZ6NUU6JGO+')
INSERT INTO T_CAD_SUBELEMENT_L(FID,FPKID,FLOCALEID,FREMARKS,FNAME) VALUES (773176352911296512,'0DZ6NUU6JGO+','zh_CN','系统预置','资源'); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_SUBELEMENT_L WHERE FPKID = '0DZ6NUU6JGO/')
INSERT INTO T_CAD_SUBELEMENT_L(FID,FPKID,FLOCALEID,FREMARKS,FNAME) VALUES (773176352911296512,'0DZ6NUU6JGO/','zh_TW','係統預置','資源'); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_SUBELEMENT_L WHERE FPKID = '0DZ6OUFZ/4IR')
INSERT INTO T_CAD_SUBELEMENT_L(FID,FPKID,FLOCALEID,FREMARKS,FNAME) VALUES (773176488857077760,'0DZ6OUFZ/4IR','zh_CN','系统预置','外协加工费'); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_SUBELEMENT_L WHERE FPKID = '0DZ6OUFZ/4IS')
INSERT INTO T_CAD_SUBELEMENT_L(FID,FPKID,FLOCALEID,FREMARKS,FNAME) VALUES (773176488857077760,'0DZ6OUFZ/4IS','zh_TW','係統預置','外協加工費'); 

--预设成本要素分类
IF NOT EXISTS (SELECT 1 FROM T_CAD_ELEMENTTYPE WHERE FID = 773131716901523456)
INSERT INTO T_CAD_ELEMENTTYPE(FID,FCREATETIME,FMODIFIERID,FENABLE,FMODIFYTIME,FSTATUS,FCREATORID,FNUMBER,FMASTERID) VALUES (773131716901523456,{ts'2019-12-03  17:14:25'},1,'1',{ts'2019-12-03  17:14:42'},'C',1,'ET001',773131716901523456); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_ELEMENTTYPE_L WHERE FPKID = '0DZ+AKM01VV+')
INSERT INTO T_CAD_ELEMENTTYPE_L(FID,FPKID,FLOCALEID,FDESCRIPTION,FNAME) VALUES (773131716901523456,'0DZ+AKM01VV+','zh_CN','基本要素分类','基本要素分类'); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_ELEMENTTYPE_L WHERE FPKID = '0DZ+AKM01VV/')
INSERT INTO T_CAD_ELEMENTTYPE_L(FID,FPKID,FLOCALEID,FDESCRIPTION,FNAME) VALUES (773131716901523456,'0DZ+AKM01VV/','zh_TW','基本要素分類','基本要素分類'); 

--预设要素子要素关系
DELETE FROM T_CAD_ELEMENTDETAIL WHERE FID = 773175233745172480;
INSERT INTO T_CAD_ELEMENTDETAIL(FID,FELEMENTTYPEID,FELEMENTID,FSUBELEMENTID) VALUES (773175233745172480,773131716901523456,773126985240072192,773175233367685120); 

DELETE FROM T_CAD_ELEMENTDETAIL WHERE FID = 773175495897561088;
INSERT INTO T_CAD_ELEMENTDETAIL(FID,FELEMENTTYPEID,FELEMENTID,FSUBELEMENTID) VALUES (773175495897561088,773131716901523456,773141433937984512,773175492709890048);

DELETE FROM T_CAD_ELEMENTDETAIL WHERE FID = 773177997950892032;
INSERT INTO T_CAD_ELEMENTDETAIL(FID,FELEMENTTYPEID,FELEMENTID,FSUBELEMENTID) VALUES (773177997950892032,773131716901523456,773177371976173568,773177997665679360); 

DELETE FROM T_CAD_ELEMENTDETAIL WHERE FID = 773176353213286400;
INSERT INTO T_CAD_ELEMENTDETAIL(FID,FELEMENTTYPEID,FELEMENTID,FSUBELEMENTID) VALUES (773176353213286400,773131716901523456,773173188837423104,773176352911296512); 

DELETE FROM T_CAD_ELEMENTDETAIL WHERE FID = 773176489142290432;
INSERT INTO T_CAD_ELEMENTDETAIL(FID,FELEMENTTYPEID,FELEMENTID,FSUBELEMENTID) VALUES (773176489142290432,773131716901523456,773173574319126528,773176488857077760); 

--预制成本类型
IF NOT EXISTS (SELECT 1 FROM t_cad_costtype WHERE FID = 773781994261075968) 
INSERT INTO t_cad_costtype(FID,FTYPE,FELEMENTTYPEID,FCREATEORGID,FMASTERID,FORGID,FSTATUS,FCTRLSTRATEGY,FNUMBER,FCURRENCYID,FCREATETIME,FMODIFIERID,FENABLE,FUORG,FMODIFYTIME,FCREATORID,FISUPDATE,FISSYSTEM) VALUES (773781994261075968,'0',773131716901523456,100000,773781994261075968,100000,'C','5','CT001',1,{ts'2019-12-04  14:45:33'},1,'1',100000,{ts'2019-12-04  14:46:41'},1,'1','1'); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_COSTTYPE_L WHERE FPKID = '0E02U4FP72H7') 
INSERT INTO T_CAD_COSTTYPE_L(FID,FPKID,FLOCALEID,FREMARK,FNAME) VALUES (773781994261075968,'0E02U4FP72H7','zh_CN',' ','核算成本'); 

IF NOT EXISTS (SELECT 1 FROM T_CAD_COSTTYPE_L WHERE FPKID = '0E02U4FP72H8') 
INSERT INTO T_CAD_COSTTYPE_L(FID,FPKID,FLOCALEID,FREMARK,FNAME) VALUES (773781994261075968,'0E02U4FP72H8','zh_TW',' ','核算成本'); 

--预制管理员权限项
DELETE FROM t_perm_adminschemedetail where FENTITYNUM in ('cad_costtype','cad_subelement');
INSERT INTO t_perm_adminschemedetail (FENTRYID, FDETAILID, FSEQ, FBIZAPPID, FENTITYNUM) VALUES ('586817719983145985', '586810019983145888', '0', '0efa1992000000ac', 'cad_costtype');
INSERT INTO t_perm_adminschemedetail (FENTRYID, FDETAILID, FSEQ, FBIZAPPID, FENTITYNUM) VALUES ('586817719983145985', '586810019983145999', '0', '0efa1992000000ac', 'cad_subelement');


