|
|
@@ -1277,15 +1277,11 @@ func (this *OilGoodsAptitudeController) ImportExcel() {
|
|
|
this.Data["json"] = &errorinfo
|
|
|
this.ServeJSON()
|
|
|
}
|
|
|
+ svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
|
|
|
|
|
|
- session := utils.DBE.NewSession()
|
|
|
- err := session.Begin()
|
|
|
- svc := goodsaptitude.GetOilGoodsAptitudeSession(session)
|
|
|
-
|
|
|
- err = svc.TruncateTable(Tmp_OilGoodsAptitudeName)
|
|
|
+ err := svc.TruncateTable(Tmp_OilGoodsAptitudeName)
|
|
|
|
|
|
if err != nil {
|
|
|
- session.Rollback()
|
|
|
errorinfo.Code = -2
|
|
|
errorinfo.Message = "导入失败!"
|
|
|
this.Data["json"] = &errorinfo
|
|
|
@@ -1295,7 +1291,6 @@ func (this *OilGoodsAptitudeController) ImportExcel() {
|
|
|
err = svc.TruncateTable(Tmp_OilGoodsAptitudeClassName)
|
|
|
|
|
|
if err != nil {
|
|
|
- session.Rollback()
|
|
|
errorinfo.Code = -2
|
|
|
errorinfo.Message = "导入失败!"
|
|
|
this.Data["json"] = &errorinfo
|
|
|
@@ -1320,27 +1315,37 @@ func (this *OilGoodsAptitudeController) ImportExcel() {
|
|
|
Fstrs = "GoodsLevel,GoodsDesc,Standard,CompanyType," + Fstrs
|
|
|
columnArr := strings.Split(Fstrs, ",")
|
|
|
|
|
|
- defer func() {
|
|
|
- session.Close()
|
|
|
- }()
|
|
|
-
|
|
|
codemap := make(map[string]int)
|
|
|
for i := 2; i < len(sheet.Rows); i++ {
|
|
|
lineNo := strconv.Itoa(i + 1)
|
|
|
- this.OperationCell(svc, lineNo, columnArr, codemap, sheet.Rows[i].Cells, &errLineNum)
|
|
|
+ this.OperationCell(lineNo, columnArr, codemap, sheet.Rows[i].Cells, &errLineNum)
|
|
|
}
|
|
|
os.Remove(filePath)
|
|
|
|
|
|
if errLineNum != "" {
|
|
|
- session.Rollback()
|
|
|
errorinfo.Code = -1
|
|
|
errorinfo.Message = "导入失败!错误行号:" + errLineNum
|
|
|
this.Data["json"] = &errorinfo
|
|
|
this.ServeJSON()
|
|
|
} else {
|
|
|
- session.Commit()
|
|
|
elapsed := time.Since(t)
|
|
|
log.Println(elapsed)
|
|
|
+ //清空
|
|
|
+ svc.TruncateTable("OilSupplierContrast")
|
|
|
+ // 插入对比列表
|
|
|
+ svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
|
|
|
+ var list1 []supplier.OilSupplier
|
|
|
+ svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, 0, 0, "Id", false, &list1, " 1=1")
|
|
|
+ for _, item := range list1 {
|
|
|
+ var list []supplier.OilSupplierContrast
|
|
|
+ where := " b.SupplierTypeCode='01' and a.Id = " + strconv.Itoa(item.Id)
|
|
|
+ svc.GetPagingTmpCheckedEntities(&list, where)
|
|
|
+ if list != nil {
|
|
|
+ svc.InsertEntityBytbl("OilSupplierContrast", list[0])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ elapsed1 := time.Since(t)
|
|
|
+ log.Println(elapsed1)
|
|
|
errorinfo.Code = 0
|
|
|
errorinfo.Message = "导入成功!"
|
|
|
this.Data["json"] = &errorinfo
|
|
|
@@ -1348,7 +1353,7 @@ func (this *OilGoodsAptitudeController) ImportExcel() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (this *OilGoodsAptitudeController) OperationCell(svc *goodsaptitude.OilGoodsAptitudeSession, lineNo string, columnArr []string, codemap map[string]int, cellsArr []*xlsx.Cell, errLineNum *string) {
|
|
|
+func (this *OilGoodsAptitudeController) OperationCell(lineNo string, columnArr []string, codemap map[string]int, cellsArr []*xlsx.Cell, errLineNum *string) {
|
|
|
|
|
|
defer func() {
|
|
|
if err := recover(); err != nil {
|
|
|
@@ -1356,6 +1361,7 @@ func (this *OilGoodsAptitudeController) OperationCell(svc *goodsaptitude.OilGood
|
|
|
*errLineNum += lineNo + ","
|
|
|
}
|
|
|
}()
|
|
|
+ svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
|
|
|
parentId := 0
|
|
|
classId := 0
|
|
|
cellsArrLen := len(cellsArr)
|
|
|
@@ -1898,7 +1904,7 @@ func (this *OilGoodsAptitudeController) GetDelCertSubList() {
|
|
|
//获取分页信息
|
|
|
page := this.GetPageInfoForm()
|
|
|
where := " 1=1 "
|
|
|
- orderby := "Id"
|
|
|
+ orderby := "a.Id"
|
|
|
asc := false
|
|
|
Order := this.GetString("Order")
|
|
|
Prop := this.GetString("Prop")
|
|
|
@@ -1924,55 +1930,55 @@ func (this *OilGoodsAptitudeController) GetDelCertSubList() {
|
|
|
ModifiedBy := this.GetString("ModifiedBy")
|
|
|
|
|
|
if Id != "" {
|
|
|
- where = where + " and Id like '%" + Id + "%'"
|
|
|
+ where = where + " and a.Id like '%" + Id + "%'"
|
|
|
}
|
|
|
|
|
|
if SupplierId != "" {
|
|
|
- where = where + " and SupplierId like '%" + SupplierId + "%'"
|
|
|
+ where = where + " and a.SupplierId like '%" + SupplierId + "%'"
|
|
|
}
|
|
|
|
|
|
if SupplierCertId != "" {
|
|
|
- where = where + " and SupplierCertId = '" + SupplierCertId + "'"
|
|
|
+ where = where + " and a.SupplierCertId = '" + SupplierCertId + "'"
|
|
|
}
|
|
|
|
|
|
if SupplierTypeCode != "" {
|
|
|
- where = where + " and SupplierTypeCode = '" + SupplierTypeCode + "'"
|
|
|
+ where = where + " and a.SupplierTypeCode = '" + SupplierTypeCode + "'"
|
|
|
}
|
|
|
|
|
|
if Code != "" {
|
|
|
- where = where + " and Code like '%" + Code + "%'"
|
|
|
+ where = where + " and a.Code like '%" + Code + "%'"
|
|
|
}
|
|
|
|
|
|
if Name != "" {
|
|
|
- where = where + " and Name like '%" + Name + "%'"
|
|
|
+ where = where + " and a.Name like '%" + Name + "%'"
|
|
|
}
|
|
|
|
|
|
if Remark != "" {
|
|
|
- where = where + " and Remark like '%" + Remark + "%'"
|
|
|
+ where = where + " and a.Remark like '%" + Remark + "%'"
|
|
|
}
|
|
|
|
|
|
if IsDelete != "" {
|
|
|
- where = where + " and IsDelete like '%" + IsDelete + "%'"
|
|
|
+ where = where + " and a.IsDelete like '%" + IsDelete + "%'"
|
|
|
}
|
|
|
|
|
|
if CreateUserId != "" {
|
|
|
- where = where + " and CreateUserId like '%" + CreateUserId + "%'"
|
|
|
+ where = where + " and a.CreateUserId like '%" + CreateUserId + "%'"
|
|
|
}
|
|
|
|
|
|
if CreateBy != "" {
|
|
|
- where = where + " and CreateBy like '%" + CreateBy + "%'"
|
|
|
+ where = where + " and a.CreateBy like '%" + CreateBy + "%'"
|
|
|
}
|
|
|
|
|
|
if ModifiedOn != "" {
|
|
|
- where = where + " and ModifiedOn like '%" + ModifiedOn + "%'"
|
|
|
+ where = where + " and a.ModifiedOn like '%" + ModifiedOn + "%'"
|
|
|
}
|
|
|
|
|
|
if ModifiedUserId != "" {
|
|
|
- where = where + " and ModifiedUserId like '%" + ModifiedUserId + "%'"
|
|
|
+ where = where + " and a.ModifiedUserId like '%" + ModifiedUserId + "%'"
|
|
|
}
|
|
|
|
|
|
if ModifiedBy != "" {
|
|
|
- where = where + " and ModifiedBy like '%" + ModifiedBy + "%'"
|
|
|
+ where = where + " and a.ModifiedBy like '%" + ModifiedBy + "%'"
|
|
|
}
|
|
|
|
|
|
if CreateOn != "" {
|
|
|
@@ -1980,14 +1986,38 @@ func (this *OilGoodsAptitudeController) GetDelCertSubList() {
|
|
|
if len(dates) == 2 {
|
|
|
minDate := dates[0]
|
|
|
maxDate := dates[1]
|
|
|
- where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
|
|
|
+ where = where + " and a.CreateOn>='" + minDate + "' and a.CreateOn<='" + maxDate + "'"
|
|
|
}
|
|
|
}
|
|
|
- where = where + " and Type in (1, 3)"
|
|
|
+ where = where + " and a.Type in (1, 3)"
|
|
|
svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
|
|
|
- var list []suppliercertsub.Tmp_OilSupplierCertSub
|
|
|
+ var list []suppliercertsub.OilSupplierCertSub
|
|
|
//total := svc.GetMyPagingEntitiesWithOrderBytbl(TmpOilSupplierCertSubName, page.CurrentPage, page.Size, orderby, asc, &list, where)
|
|
|
- total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierCertSubName, page.CurrentPage, page.Size, orderby, asc, &list, where)
|
|
|
+ //total := svc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierCertSubName, page.CurrentPage, page.Size, orderby, asc, &list, where)
|
|
|
+ total := svc.GetPagingSubEntities(page.CurrentPage, page.Size, orderby, asc, &list, where)
|
|
|
+ a := 0
|
|
|
+ for _, item := range list {
|
|
|
+ sql := "SELECT CONCAT_WS(',',IF(ifnull(F01, '') = '', '', F01),IF(ifnull(F02, '') = '', '', F02),IF(ifnull(F03, '') = '', '', F03),IF(ifnull(F04, '') = '', '', F04),IF(ifnull(F05, '') = '', '', F05),IF(ifnull(F06, '') = '', '', F06),IF(ifnull(F07, '') = '', '', F07),IF(ifnull(F08, '') = '', '', F08),IF(ifnull(F09, '') = '', '', F09),IF(ifnull(F10, '') = '', '', F10),IF(ifnull(F11, '') = '', '', F11),IF(ifnull(F12, '') = '', '', F12),IF(ifnull(F13, '') = '', '', F13),IF(ifnull(F14, '') = '', '', F14),IF(ifnull(F15, '') = '', '', F15),IF(ifnull(F16, '') = '', '', F16),IF(ifnull(F17, '') = '', '', F17),IF(ifnull(F18, '') = '', '', F18),IF(ifnull(F19, '') = '', '', F19),IF(ifnull(F20, '') = '', '', F20),IF(ifnull(F21, '') = '', '', F21),IF(ifnull(F22, '') = '', '', F22),IF(ifnull(F23, '') = '', '', F23),IF(ifnull(F24, '') = '', '', F24),IF(ifnull(F25, '') = '', '', F25),IF(ifnull(F26, '') = '', '', F26),IF(ifnull(F27, '') = '', '', F27),IF(ifnull(F28, '') = '', '', F28),IF(ifnull(F29, '') = '', '', F29),IF(ifnull(F30, '') = '', '', F30),IF(ifnull(F31, '') = '', '', F31),IF(ifnull(F32, '') = '', '', F32),IF(ifnull(F33, '') = '', '', F33),IF(ifnull(F34, '') = '', '', F34),IF(ifnull(F35, '') = '', '', F35),IF(ifnull(F36, '') = '', '', F36),IF(ifnull(F37, '') = '', '', F37),IF(ifnull(F38, '') = '', '', F38),IF(ifnull(F39, '') = '', '', F39),IF(ifnull(F40, '') = '', '', F40),IF(ifnull(F41, '') = '', '', F41),IF(ifnull(F42, '') = '', '', F42),IF(ifnull(F43, '') = '', '', F43),IF(ifnull(F44, '') = '', '', F44),IF(ifnull(F45, '') = '', '', F45),IF(ifnull(F46, '') = '', '', F46)) AS Codes FROM OilGoodsAptitude "
|
|
|
+ sql += " where ClassId = "+ strconv.Itoa(item.SubClassId)
|
|
|
+ model, _ := svc.DBE.QueryString(sql)
|
|
|
+ code := strings.Split(model[0]["Codes"], ",")
|
|
|
+ i := 1
|
|
|
+ for _, value := range code {
|
|
|
+ if i > 10 {
|
|
|
+ if value == "1" && strings.Index(item.HeaderCodes, "F"+strconv.Itoa(i)) < 0 {
|
|
|
+ list[a].Checked = 1
|
|
|
+ break
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if value == "1" && strings.Index(item.HeaderCodes, "F0"+strconv.Itoa(i)) < 0 {
|
|
|
+ list[a].Checked = 1
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ i += 1
|
|
|
+ }
|
|
|
+ a += 1
|
|
|
+ }
|
|
|
var datainfo DataInfo
|
|
|
datainfo.Items = list
|
|
|
datainfo.CurrentItemCount = total
|
|
|
@@ -2151,12 +2181,12 @@ func (this *OilGoodsAptitudeController) GetCompareTmpSupplier() {
|
|
|
where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
|
|
|
}
|
|
|
}
|
|
|
- where = where + " and sub.Type in (1, 3)"
|
|
|
svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
|
|
|
- var list []supplier.OilSupplierContrast
|
|
|
- total := svc.GetPagingTmpCheckedEntities(page.CurrentPage, page.Size, orderby, asc, &list, where)
|
|
|
+ var list2 []supplier.OilSupplierContrast
|
|
|
+
|
|
|
+ total := svc.GetMyPagingEntitiesWithOrderBytbl("OilSupplierContrast", page.CurrentPage, page.Size, orderby, asc, &list2, where)
|
|
|
var datainfo DataInfo
|
|
|
- datainfo.Items = list
|
|
|
+ datainfo.Items = list2
|
|
|
datainfo.CurrentItemCount = total
|
|
|
datainfo.PageIndex = page.CurrentPage
|
|
|
datainfo.ItemsPerPage = page.Size
|
|
|
@@ -2164,7 +2194,32 @@ func (this *OilGoodsAptitudeController) GetCompareTmpSupplier() {
|
|
|
this.ServeJSON()
|
|
|
}
|
|
|
|
|
|
+// @Title 导出到execl
|
|
|
+// @Description 导出到execl
|
|
|
+// @Success 200 {object} controllers.Request
|
|
|
+// @router /exportexecl [post]
|
|
|
+func (this *OilGoodsAptitudeController) ExeclExport() {
|
|
|
+ // 填物资类信息表首页信息
|
|
|
+ svcActiviti := workflow.GetActivitiService(utils.DBE)
|
|
|
+ svc := goodsaptitude.GetOilGoodsAptitudeService(utils.DBE)
|
|
|
+ var list2 []supplier.OilSupplierContrast
|
|
|
+ where := " 1=1"
|
|
|
+ svc.GetMyPagingEntitiesWithOrderBytbl("OilSupplierContrast", 0,0, "Id", false, &list2, where)
|
|
|
+
|
|
|
+ fileName := "资质导入对比表.xlsx"
|
|
|
+ Url := utils.Cfg.MustValue("workflow", "ContrastExcel")
|
|
|
|
|
|
+ var datamap = make(map[string]interface{})
|
|
|
+ datamap["data"] = list2
|
|
|
+ retDocUrl := svcActiviti.ContrastExcel(datamap, Url, fileName)
|
|
|
+ var datainfo ErrorDataInfo
|
|
|
+ datainfo.Code = 0
|
|
|
+ datainfo.Item = retDocUrl
|
|
|
+ datainfo.Message = "打印成功"
|
|
|
+ this.Data["json"] = &datainfo
|
|
|
+ this.ServeJSON()
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
// @Title 修改资质后找出不符合的准入
|
|
|
// @Description 修改实体
|