|
@@ -75,7 +75,8 @@ func (s *TmpzcgtSession) InsertSupplier() error {
|
|
|
CreateBy,
|
|
CreateBy,
|
|
|
SetupTime,
|
|
SetupTime,
|
|
|
OilCertificateNo,
|
|
OilCertificateNo,
|
|
|
- BusinessScope
|
|
|
|
|
|
|
+ BusinessScope,
|
|
|
|
|
+ OldSupplierName
|
|
|
) SELECT
|
|
) SELECT
|
|
|
max(企业名称) AS SupplierName,
|
|
max(企业名称) AS SupplierName,
|
|
|
max(级别) AS Grade,
|
|
max(级别) AS Grade,
|
|
@@ -119,7 +120,8 @@ func (s *TmpzcgtSession) InsertSupplier() error {
|
|
|
'导入' As CreateBy,
|
|
'导入' As CreateBy,
|
|
|
STR_TO_DATE(IF(max(成立时间)='', NULL, max(成立时间)),IF(LENGTH(max(成立时间))>8 or locate('-',max(成立时间)) >0, '%Y-%m-%d', '%Y%m%d')) AS SetupTime,
|
|
STR_TO_DATE(IF(max(成立时间)='', NULL, max(成立时间)),IF(LENGTH(max(成立时间))>8 or locate('-',max(成立时间)) >0, '%Y-%m-%d', '%Y%m%d')) AS SetupTime,
|
|
|
max(中石油供应商证书号) as OilCertificateNo,
|
|
max(中石油供应商证书号) as OilCertificateNo,
|
|
|
- max(推荐单位的推荐意见) as BusinessScope
|
|
|
|
|
|
|
+ max(推荐单位的推荐意见) as BusinessScope,
|
|
|
|
|
+ 曾用名 AS OldSupplierName
|
|
|
FROM
|
|
FROM
|
|
|
T_资格预审表 GROUP BY 企业名称;` //WHERE 准入标识 != '取消'
|
|
T_资格预审表 GROUP BY 企业名称;` //WHERE 准入标识 != '取消'
|
|
|
_, err := s.DBE.Query(sql)
|
|
_, err := s.DBE.Query(sql)
|
|
@@ -133,8 +135,8 @@ FROM
|
|
|
|
|
|
|
|
func (s *TmpzcgtSession) InsertSupplierCert() error {
|
|
func (s *TmpzcgtSession) InsertSupplierCert() error {
|
|
|
s.DBE.Query("SET unique_checks=0;")
|
|
s.DBE.Query("SET unique_checks=0;")
|
|
|
- sql := "INSERT INTO OilSupplierCert (SupplierId,OutsideFlog, `Status` , Step, WorkerTotal, AccessCardNo,SupplierTypeName,InFlag,EffectStartTime,EffectEndTime,AddinTime,EffectTime,ApplyTime,Remark,CreateBy,GfID,RecUnitName,MgrUnit,RecDate) " +
|
|
|
|
|
- "SELECT -1 As SupplierId,企业名称 AS OutsideFlog,'8' As `Status`, 3 as Step, 1 as WorkerTotal, 准入证号 As AccessCardNo,准入类别 AS SupplierTypeName,准入标识 AS InFlag, STR_TO_DATE(IF(有效期起='', NULL, 有效期起),'%Y年%m月%d日') AS EffectStartTime, STR_TO_DATE(IF(有效期止='', NULL, 有效期止),'%Y年%m月%d日') AS EffectEndTime,审核日期 as AddinTime, 有效期起 as EffectTime, (SELECT STR_TO_DATE(IF(MAX(年审日期)='', NULL, MAX(年审日期)),'%Y-%m-%d') from T_年审 b WHERE b.企业名称 = a.企业名称 AND b.状态标识='办理完毕') AS ApplyTime,备注 AS Remark,'导入' As CreateBy,ID,推荐单位名称 as RecUnitName,管理单位 as MgrUnit,推荐日期 as RecDate " +
|
|
|
|
|
|
|
+ sql := "INSERT INTO OilSupplierCert (SupplierId,OutsideFlog, `Status` , Step, WorkerTotal, AccessCardNo,SupplierTypeName,InFlag,EffectStartTime,EffectEndTime,AddinTime,EffectTime,ApplyTime,Remark,CreateBy,GfID,RecUnitName,MgrUnit,RecDate,OldCardNo) " +
|
|
|
|
|
+ "SELECT -1 As SupplierId,企业名称 AS OutsideFlog,'8' As `Status`, 3 as Step, 1 as WorkerTotal, 准入证号 As AccessCardNo,准入类别 AS SupplierTypeName,准入标识 AS InFlag, STR_TO_DATE(IF(有效期起='', NULL, 有效期起),'%Y年%m月%d日') AS EffectStartTime, STR_TO_DATE(IF(有效期止='', NULL, 有效期止),'%Y年%m月%d日') AS EffectEndTime,审核日期 as AddinTime, 有效期起 as EffectTime, (SELECT STR_TO_DATE(IF(MAX(年审日期)='', NULL, MAX(年审日期)),'%Y-%m-%d') from T_年审 b WHERE b.企业名称 = a.企业名称 AND b.状态标识='办理完毕') AS ApplyTime,备注 AS Remark,'导入' As CreateBy,ID,推荐单位名称 as RecUnitName,管理单位 as MgrUnit,推荐日期,曾用准入证号 as RecDate " +
|
|
|
"FROM T_资格预审表 a ;" //WHERE 准入标识 != '取消'
|
|
"FROM T_资格预审表 a ;" //WHERE 准入标识 != '取消'
|
|
|
// s.DBE.Query("SET @@SESSION.sql_mode='ALLOW_INVALID_DATES'")
|
|
// s.DBE.Query("SET @@SESSION.sql_mode='ALLOW_INVALID_DATES'")
|
|
|
_, err := s.DBE.Query(sql)
|
|
_, err := s.DBE.Query(sql)
|
|
@@ -678,3 +680,50 @@ func (s *TmpzcgtSession) UpdateOilCatalog2() error {
|
|
|
return err
|
|
return err
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 导入曾用名
|
|
|
|
|
+func (s *TmpzcgtSession) InsertOldName() error {
|
|
|
|
|
+ s.DBE.Query("SET unique_checks=0;")
|
|
|
|
|
+ // s.DBE.Query("SET autocommit=0;")
|
|
|
|
|
+ sql := "insert into OilSupplierOldName(OldName) select `曾用名` from `T_资格预审表` where 曾用名 is not null group by 曾用名"
|
|
|
|
|
+ _, err := s.DBE.Query(sql)
|
|
|
|
|
+
|
|
|
|
|
+ // s.DBE.Query("commit;")
|
|
|
|
|
+ s.DBE.Query("SET unique_checks=1;")
|
|
|
|
|
+ // s.DBE.Query("SET autocommit=1;")
|
|
|
|
|
+ return err
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 导入曾用准入证号
|
|
|
|
|
+func (s *TmpzcgtSession) InsertOldCardNo() error {
|
|
|
|
|
+ s.DBE.Query("SET unique_checks=0;")
|
|
|
|
|
+ // s.DBE.Query("SET autocommit=0;")
|
|
|
|
|
+ sql := "insert into OilSupplierOldCardNo(OldCardNo,SupplierTypeCode, GfId) select `曾用准入证号`,(CASE 准入类别 WHEN '物资类' THEN '01' WHEN '基建类' THEN '02' WHEN '服务类' THEN '03' WHEN '技术服务类' THEN '03' END ), ID from `T_资格预审表` where 曾用准入证号 is not null"
|
|
|
|
|
+ _, err := s.DBE.Query(sql)
|
|
|
|
|
+
|
|
|
|
|
+ // s.DBE.Query("commit;")
|
|
|
|
|
+ s.DBE.Query("SET unique_checks=1;")
|
|
|
|
|
+ // s.DBE.Query("SET autocommit=1;")
|
|
|
|
|
+ return err
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 修改曾用名
|
|
|
|
|
+func (s *TmpzcgtSession) UpdatetOldName() error {
|
|
|
|
|
+ sql := "update OilSupplierOldName a,(select ID,曾用名 from `T_资格预审表`) c set a.GfId = c.ID where a.OldName = c.曾用名"
|
|
|
|
|
+ _, err := s.DBE.Query(sql)
|
|
|
|
|
+ return err
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 修改曾用名
|
|
|
|
|
+func (s *TmpzcgtSession) UpdatetOldName2() error {
|
|
|
|
|
+ sql := "update OilSupplierOldName a,(select SupplierId,GfId from OilSupplierCert) c set a.SupplierId = c.SupplierId where a.GfId = c.GfId"
|
|
|
|
|
+ _, err := s.DBE.Query(sql)
|
|
|
|
|
+ return err
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 修改曾用准入编号
|
|
|
|
|
+func (s *TmpzcgtSession) UpdateOldCardNo() error {
|
|
|
|
|
+ sql := "update OilSupplierOldCardNo a,(select GfId,Id,SupplierId from OilSupplierCert) b set a.SupplierId = b.SupplierId,a.SupplierCertId = b.Id where a.GfId = b.GfId"
|
|
|
|
|
+ _, err := s.DBE.Query(sql)
|
|
|
|
|
+ return err
|
|
|
|
|
+}
|
|
|
|
|
+
|