|
|
@@ -1992,3 +1992,84 @@ func (this *OilGoodsAptitudeController) FindInconformity() {
|
|
|
this.ServeJSON()
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// @Title get 导入excel对比差异
|
|
|
+// @Description get SampleType by token
|
|
|
+// @Success 200 {object} sampletype.SampleType
|
|
|
+// @router /oilcompare [get]
|
|
|
+func (this *OilGoodsAptitudeController) OilCompare() {
|
|
|
+
|
|
|
+ url := this.GetString("ExcelUrl")
|
|
|
+ session := utils.DBE.NewSession()
|
|
|
+ err := session.Begin()
|
|
|
+ svc := goodsaptitude.GetOilGoodsAptitudeSession(session)
|
|
|
+
|
|
|
+ timeUnixNano := strconv.FormatInt(int64(time.Now().UnixNano()), 10)
|
|
|
+ _dir := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx"
|
|
|
+ utils.DownloadFile(url, timeUnixNano+".xlsx", _dir)
|
|
|
+ filePath := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx/" + timeUnixNano + ".xlsx"
|
|
|
+ xlFile, err := xlsx.OpenFile(filePath)
|
|
|
+
|
|
|
+ //excelFileName := "F:/物资类项目与资质对照表-2017.xlsx"
|
|
|
+ if err != nil {
|
|
|
+ fmt.Printf("open failed: %s\n", err)
|
|
|
+ }
|
|
|
+ var sheet = xlFile.Sheets[0]
|
|
|
+ defer func() {
|
|
|
+ session.Close()
|
|
|
+ }()
|
|
|
+
|
|
|
+ var List []supplier.OilSupplier
|
|
|
+ var Comparelist []suppliercertsub.OilCompare
|
|
|
+ var Compare suppliercertsub.OilCompare
|
|
|
+ var CompanyName = sheet.Rows[2].Cells[4].Value
|
|
|
+ where := "SupplierName = '" + CompanyName + "'"
|
|
|
+ svc.GetEntitysByWhere(OilSupplierName, where, &List)
|
|
|
+
|
|
|
+ for i := 2; i < len(sheet.Rows); i++ {
|
|
|
+ Compare.SortCoding = sheet.Rows[i].Cells[0].Value
|
|
|
+ Compare.SortName = sheet.Rows[i].Cells[1].Value
|
|
|
+ Compare.Level = sheet.Rows[i].Cells[2].Value
|
|
|
+ //Compare.SupplierCode = sheet.Rows[i].Cells[3].Value
|
|
|
+ Compare.SupplierName = sheet.Rows[i].Cells[4].Value
|
|
|
+ //Compare.SurplusCount = sheet.Rows[i].Cells[5].Value
|
|
|
+ Compare.ManagementUnitType = sheet.Rows[i].Cells[6].Value
|
|
|
+ //Compare.EliminationCause = sheet.Rows[i].Cells[7].Value
|
|
|
+ //Compare.AccessList = sheet.Rows[i].Cells[8].Value
|
|
|
+ //Compare.SupplierSubTime = sheet.Rows[i].Cells[9].Value
|
|
|
+ //Compare.ProductType = sheet.Rows[i].Cells[10].Value
|
|
|
+ //Compare.Editor = sheet.Rows[i].Cells[11].Value
|
|
|
+ //Compare.EditingTime = sheet.Rows[i].Cells[12].Value
|
|
|
+ //Compare.FlowState = sheet.Rows[i].Cells[13].Value
|
|
|
+ //Compare.ProcessNotes = sheet.Rows[i].Cells[14].Value
|
|
|
+ //Compare.Reviewime = sheet.Rows[i].Cells[15].Value
|
|
|
+ //Compare.Brand = sheet.Rows[i].Cells[16].Value
|
|
|
+ //Compare.WorkCode = sheet.Rows[i].Cells[17].Value
|
|
|
+ //Compare.WorkType = sheet.Rows[i].Cells[18].Value
|
|
|
+ //Compare.ProductScope = sheet.Rows[i].Cells[19].Value
|
|
|
+ //Compare.IsBid = sheet.Rows[i].Cells[20].Value
|
|
|
+ //Compare.MoreInfo = sheet.Rows[i].Cells[21].Value
|
|
|
+ //Compare.ManufacturerCode = sheet.Rows[i].Cells[22].Value
|
|
|
+ //Compare.ManufacturerName = sheet.Rows[i].Cells[23].Value
|
|
|
+ Compare.Diff = "0"
|
|
|
+ if len(List)<1 {
|
|
|
+ Compare.Diff = "1"
|
|
|
+ }
|
|
|
+ if len(List)>0 {
|
|
|
+ var certsublist2 []suppliercertsub.OilSupplierCertSub
|
|
|
+ namewhere := "SupplierId = '" + strconv.Itoa(List[0].Id) + "' and Code ='" + Compare.SortCoding + "'"
|
|
|
+ svc.GetEntitysByWhere(OilSupplierCertSubName, namewhere, &certsublist2)
|
|
|
+ if len(certsublist2) < 1 {
|
|
|
+ Compare.Diff = "1"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Comparelist = append(Comparelist, Compare)
|
|
|
+ }
|
|
|
+
|
|
|
+ os.Remove(filePath)
|
|
|
+
|
|
|
+ var datainfo DataInfo
|
|
|
+ datainfo.Items = Comparelist
|
|
|
+ this.Data["json"] = &datainfo
|
|
|
+ this.ServeJSON()
|
|
|
+}
|