|
|
@@ -64,7 +64,7 @@ func (s *TmpzcgtSession) InsertSupplier() error {
|
|
|
国家 AS Country,
|
|
|
所代理制造商名称 AS MaunAgent,
|
|
|
施工队伍名称 AS ConstructTeam,
|
|
|
- 工商注册号 AS CommercialNo,
|
|
|
+ TRIM(工商注册号) AS CommercialNo,
|
|
|
组织机构代码 AS OrganCode,
|
|
|
税务登记证国税编号 AS CountryTaxNo,
|
|
|
税务登记证地税编号 AS LocalTaxNo,
|
|
|
@@ -99,7 +99,7 @@ func (s *TmpzcgtSession) InsertSupplier() error {
|
|
|
备注 AS Remark,
|
|
|
'导入' As CreateBy
|
|
|
FROM
|
|
|
- tmp_zcgf WHERE ID IN (SELECT MAX(ID) FROM tmp_zcgf GROUP BY 企业名称);`
|
|
|
+ tmp_zcgf WHERE ID IN (SELECT MAX(ID) FROM tmp_zcgf WHERE 准入标识 != '取消' GROUP BY 企业名称);`
|
|
|
_, err := s.Session.Query(sql)
|
|
|
return err
|
|
|
}
|
|
|
@@ -151,8 +151,8 @@ func (s *TmpzcgtSession) UpdateSupplierTypeCodeAndInFlag() error {
|
|
|
}
|
|
|
|
|
|
func (s *TmpzcgtSession) InsterAnnual() error {
|
|
|
- sql := "INSERT INTO OilAnnualAudit (SupplierTypeName, SupplierName, CreateOn, CreateBy, RecUnitId, ApplyTime, AccessCardNo, OldId) " +
|
|
|
- "SELECT ( CASE 准入类别 WHEN '物资类' THEN '01' WHEN '基建类' THEN '02' WHEN '技术服务类' THEN '03' END ) SupplierTypeName, " +
|
|
|
+ sql := "INSERT INTO OilAnnualAudit (Status,SupplierTypeName, SupplierName, CreateOn, CreateBy, RecUnitId, ApplyTime, AccessCardNo, OldId) " +
|
|
|
+ "SELECT ( '11' as Status ,CASE 准入类别 WHEN '物资类' THEN '01' WHEN '基建类' THEN '02' WHEN '技术服务类' THEN '03' END ) SupplierTypeName, " +
|
|
|
"企业名称 AS SupplierName, 申请日期 AS CreateOn, 录入员 AS CreateBy, 推荐单位编码 AS RecUnitId, 年审日期 AS ApplyTime, 准入证号 AS AccessCardNo, id AS oldId " +
|
|
|
"FROM tmp_nianshen"
|
|
|
|
|
|
@@ -253,7 +253,7 @@ func (s *TmpzcgtSession) InsertCertSub() error {
|
|
|
"CROSS JOIN mysql.help_topic b " +
|
|
|
"ON b.help_topic_id < (LENGTH(t.`准入范围`) - LENGTH(REPLACE(t.`准入范围`, ';', '')) + 1) " +
|
|
|
"WHERE " +
|
|
|
- "1=1 " +
|
|
|
+ "1=1 and 准入标识 != '取消' " +
|
|
|
"AND LENGTH( SUBSTRING_INDEX(SUBSTRING_INDEX(t.`准入范围`,';', b.help_topic_id + 1), ';', -1) ) > 0 " +
|
|
|
"ORDER BY t.ID "
|
|
|
_, err := s.Session.Query(sql)
|
|
|
@@ -291,22 +291,27 @@ func (s *TmpzcgtSession) UpdateCertSub03classId(where string) error {
|
|
|
}
|
|
|
|
|
|
func (s *TmpzcgtSession) InsertOilSupplierCertAppend() error {
|
|
|
- sql := " INSERT INTO OilSupplierCertAppend (OldId,CreateOn,AppendType,SupplierName,CreateBy,RecUnitId,ApplyDate) " +
|
|
|
- "select Max(id) as OldId,申请日期 as CreateOn, (case 准入类别 when '物资类' then '01' when '基建类' then '02' when '技术服务类' then '03' end) AppendType, "+
|
|
|
- "企业名称 as SupplierName, 录入员 as CreateBy, 推荐单位编码 as RecUnitId, 申请日期 as ApplyDate "+
|
|
|
- "from tmp_zengxiang "+
|
|
|
- "group by id,申请日期,企业名称,录入员,推荐单位编码,申请日期,准入类别"
|
|
|
+ //sql := " INSERT INTO OilSupplierCertAppend (OldId,CreateOn,AppendType,SupplierName,CreateBy,RecUnitId,ApplyDate) " +
|
|
|
+ //"select Max(id) as OldId,申请日期 as CreateOn, (case 准入类别 when '物资类' then '01' when '基建类' then '02' when '技术服务类' then '03' end) AppendType, "+
|
|
|
+ // "企业名称 as SupplierName, 录入员 as CreateBy, 推荐单位编码 as RecUnitId, 申请日期 as ApplyDate "+
|
|
|
+ // "from tmp_zengxiang "+
|
|
|
+ // "group by id,申请日期,企业名称,录入员,推荐单位编码,申请日期,准入类别"
|
|
|
+ sql := "INSERT INTO OilSupplierCertAppend "+
|
|
|
+ "(Status,CreateOn,SupplierName,AppendType,CreateBy,ApplyDate,OldId) " +
|
|
|
+ "SELECT '11' as Status, a.`申请日期` AS CreateOn, a.`企业名称` AS SupplierName, (CASE 准入类别 WHEN '物资类' THEN '01' WHEN '基建类' THEN '02' WHEN '技术服务类' THEN '03' END) AppendType, "+
|
|
|
+ "'导入' AS CreateBy,a.`申请日期` AS ApplyDate, MAX(a.id) AS OldId "+
|
|
|
+ "FROM tmp_zengxiang a GROUP BY a.`申请日期`, a.`企业名称`, a.`准入类别`"
|
|
|
_, err := s.Session.Query(sql)
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
|
|
|
func (s *TmpzcgtSession) InsertOilInfoChange () error {
|
|
|
- sql := "INSERT INTO OilInfoChange (AccessCardNo,SupplierName,OldSupplierName,SupplierTypeName,SupplierTypeCode,OilCertificateNo,Grade,OperType,Country,MaunAgent,ConstructTeam,CommercialNo,OrganCode,CountryTaxNo,LocalTaxNo, "+
|
|
|
+ sql := "INSERT INTO OilInfoChange (Status,AccessCardNo,SupplierName,OldSupplierName,SupplierTypeName,SupplierTypeCode,OilCertificateNo,Grade,OperType,Country,MaunAgent,ConstructTeam,CommercialNo,OrganCode,CountryTaxNo,LocalTaxNo, "+
|
|
|
"Address,ZipCode,QualitySystemCert,ProductQualityCert,MaunLicense,QualifCert,QualifCertLevel,SafetyLicense,TechServiceLic,TJInNotify, "+
|
|
|
"SpecIndustryCert,LegalPerson,CategoryCode,CategoryName,RegCapital,Currency,ContactName,CompanyType,DepositBank,BankAccount,EMail, "+
|
|
|
"BankCreditRating,Mobile,Telphone,Fax,CompanyTel,QQ,CompanyUrl,Remark,CreateOn,CreateBy,HouseNo) "+
|
|
|
- "select 准入证号 as AccessCardNo, 企业名称 as SupplierName, 曾用名 as OldSupplierName, 准入类别 as SupplierTypeName,(case 准入类别 when '物资类' then '01' when '基建类' then '02' when '技术服务类' then '03' end) SupplierTypeCode, "+
|
|
|
+ "select '11' as Status, 准入证号 as AccessCardNo, 企业名称 as SupplierName, 曾用名 as OldSupplierName, 准入类别 as SupplierTypeName,(case 准入类别 when '物资类' then '01' when '基建类' then '02' when '技术服务类' then '03' end) SupplierTypeCode, "+
|
|
|
"中石油供应商证书号 as OilCertificateNo, 级别 as Grade, 经营方式 as OperType, 国家 as Country, 所代理制造商名称 as MaunAgent, 施工队伍名称 as ConstructTeam, 工商注册号 as CommercialNo, 组织机构代码 as OrganCode, "+
|
|
|
"税务登记证国税编号 as CountryTaxNo, 税务登记证地税编号 as LocalTaxNo, 单位地址 as Address, 邮编 AS ZipCode, 质量管理体系认证情况及认证机构 AS QualitySystemCert, 产品质量认证情况及认证机构 AS ProductQualityCert, "+
|
|
|
"生产制造许可证获证情况及编号 AS MaunLicense, 企业资质证书编号 AS QualifCert, 企业资质证书级别 AS QualifCertLevel, 安全生产许可证 AS SafetyLicense, 技术服务类准入许可证 AS TechServiceLic, 外地企业进津备案通知书 AS TJInNotify, "+
|
|
|
@@ -318,8 +323,8 @@ func (s *TmpzcgtSession) InsertOilInfoChange () error {
|
|
|
}
|
|
|
|
|
|
func (s *TmpzcgtSession) InsertOilSupplierCertSub () error {
|
|
|
- sql := "insert into OilSupplierCertSub (Type, OldId, SupplierTypeCode, Code, Name, Remark, CreateOn, CreateBy) "+
|
|
|
- "select '2' as Type, id as OldId, ( case 准入类别 when '物资类' then '01' when '基建类' then '02' when '技术服务类' then '03' end ) SupplierTypeCode, 物资编码 as Code, 产品名称 as Name, 备注 as Remark, 申请日期 as CreateOn, 录入员 as CreateBy "+
|
|
|
+ sql := "insert into OilSupplierCertSub (ModifiedBy,Type, OldId, SupplierTypeCode, Code, Name, Remark, CreateOn, CreateBy) "+
|
|
|
+ "select 企业名称 as ModifiedBy,'3' as Type, id as OldId, ( case 准入类别 when '物资类' then '01' when '基建类' then '02' when '技术服务类' then '03' end ) SupplierTypeCode, 物资编码 as Code, 产品名称 as Name, 备注 as Remark, 申请日期 as CreateOn, 录入员 as CreateBy "+
|
|
|
"from tmp_zengxiang "
|
|
|
_, err := s.Session.Query(sql)
|
|
|
return err
|
|
|
@@ -331,3 +336,20 @@ func (s *TmpzcgtSession) UpdateOilInfoChange () error {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
+func (s *TmpzcgtSession) UpOilSupplierCertAppend () error {
|
|
|
+ sql := "UPDATE OilSupplierCertAppend b SET " +
|
|
|
+ "b.SupplierId = (SELECT a.`SupplierId` FROM OilSupplierCert a WHERE a.`GfId` = b.OldId AND a.SupplierTypeCode = b.AppendType), "+
|
|
|
+ "b.SupplierCertId = (SELECT a.`Id` FROM OilSupplierCert a WHERE a.`GfId` = b.OldId AND a.SupplierTypeCode = b.AppendType) "
|
|
|
+ _, err := s.Session.Query(sql)
|
|
|
+ return err
|
|
|
+}
|
|
|
+
|
|
|
+func (s *TmpzcgtSession) UpdateCertSubIsType2 (where string) error {
|
|
|
+ sql := "UPDATE OilSupplierCertSub b SET "+
|
|
|
+ "b.SupplierId = (SELECT a.`SupplierId` FROM OilSupplierCertAppend a WHERE a.`OldId` = b.OldId AND a.AppendType = b.SupplierTypeCode AND a.ApplyDate = b.CreateOn ), "+
|
|
|
+ "b.SupplierCertId = (SELECT a.`SupplierCertId` FROM OilSupplierCertAppend a WHERE a.`OldId` = b.OldId AND a.AppendType = b.SupplierTypeCode AND a.ApplyDate = b.CreateOn ), "+
|
|
|
+ "b.SupplierCertAppendId = (SELECT a.`Id` FROM OilSupplierCertAppend a WHERE a.`OldId` = b.OldId AND a.AppendType = b.SupplierTypeCode AND a.ApplyDate = b.CreateOn ) "+
|
|
|
+ where
|
|
|
+ _, err := s.Session.Query(sql)
|
|
|
+ return err
|
|
|
+}
|