|
|
@@ -3,6 +3,7 @@ package oilcontract
|
|
|
import (
|
|
|
"dashoo.cn/backend/api/business/auditsetting"
|
|
|
"dashoo.cn/backend/api/business/oilcontract/contractReview"
|
|
|
+ "dashoo.cn/backend/api/business/oilsupplier/supplier"
|
|
|
"dashoo.cn/backend/api/business/organize"
|
|
|
"dashoo.cn/backend/api/business/workflow"
|
|
|
"encoding/json"
|
|
|
@@ -107,6 +108,7 @@ func (this *OilContractController) GetEntityList() {
|
|
|
SealName := this.GetString("SealName")
|
|
|
PoNumber := this.GetString("PoNumber")
|
|
|
SubPackage := this.GetString("SubPackage")
|
|
|
+ ImportStatus := this.GetString("ImportStatus")
|
|
|
|
|
|
if Id != "" {
|
|
|
where = where + " and Id like '%" + Id + "%'"
|
|
|
@@ -361,6 +363,12 @@ func (this *OilContractController) GetEntityList() {
|
|
|
where = where + " and PoNumber like '%" + SignedDate + "%'"
|
|
|
}
|
|
|
|
|
|
+ if ImportStatus != "" {
|
|
|
+ where = where + " and ImportStatus = " + ImportStatus
|
|
|
+ } else {
|
|
|
+ where = where + " and ImportStatus != 0"
|
|
|
+ }
|
|
|
+
|
|
|
// 企管法规处可看所有合同, 获取企管法规处人员
|
|
|
var setting auditsetting.Base_OilAuditSetting
|
|
|
orgSvc := organize.GetOrganizeService(utils.DBE)
|
|
|
@@ -462,110 +470,161 @@ func (this *OilContractController) GetEntity() {
|
|
|
}
|
|
|
|
|
|
// @Title get 导入excel
|
|
|
-// @Description 数据存入word
|
|
|
+// @Description 导入excel
|
|
|
// @Success 200 {object} controllers.Request
|
|
|
// @router /importexcel [get]
|
|
|
func (this *OilContractController) ImportExcel() {
|
|
|
- url := this.GetString("ExcelUrl")
|
|
|
- var errorinfo ErrorDataInfo
|
|
|
- if url == "" {
|
|
|
- errorinfo.Code = -2
|
|
|
- errorinfo.Message = "导入失败!"
|
|
|
- this.Data["json"] = &errorinfo
|
|
|
- this.ServeJSON()
|
|
|
- }
|
|
|
- session := utils.DBE.NewSession()
|
|
|
- err := session.Begin()
|
|
|
- //svc := contract.GetOilContractSession(session)
|
|
|
- if err != nil {
|
|
|
- session.Rollback()
|
|
|
- errorinfo.Code = -2
|
|
|
- errorinfo.Message = "导入失败!"
|
|
|
- this.Data["json"] = &errorinfo
|
|
|
- this.ServeJSON()
|
|
|
- }
|
|
|
+ go func() {
|
|
|
+ url := this.GetString("ExcelUrl")
|
|
|
+ //var errLineNum string
|
|
|
|
|
|
- _dir := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx"
|
|
|
- filename := strconv.Itoa(int(time.Now().Unix())) + ".xlsx"
|
|
|
- utils.DownloadFile(url, filename, _dir)
|
|
|
- t := time.Now()
|
|
|
- filePath := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx/" + filename
|
|
|
- xlFile, err := xlsx.OpenFile(filePath)
|
|
|
- var errLineNum string
|
|
|
- //excelFileName := "F:/物资类项目与资质对照表-2017.xlsx"
|
|
|
- if err != nil {
|
|
|
- fmt.Printf("open failed: %s\n", err)
|
|
|
- }
|
|
|
- var sheet = xlFile.Sheets[0]
|
|
|
- // 插入字段
|
|
|
- //Fstrs := "ContractNo,ContractName,Amount,ContractType,ContractSonClass,SmallClass,SignedDate,Number,ChooseWay,ContractMark,Currency,BudgetAmount,PerformAmount,IsInternal,IsForeign,IsDeal,MoneyFlows,MoneyChannel,MoneyChannelSon,MoneyChannelSmall,SingUnit,Place,StartDate,EndDate,DisputeResolution,Remark,ProjectOwner,SubmitDate,SealName,PoNumber"
|
|
|
- //columnArr := strings.Split(Fstrs, ",")
|
|
|
- defer func() {
|
|
|
- session.Close()
|
|
|
- }()
|
|
|
+ if url == "" {
|
|
|
+ fmt.Println("文件不能为空!")
|
|
|
+ }
|
|
|
|
|
|
- //timeTemplate1 := "2006/01/02 15:04:05" //常规类型
|
|
|
-
|
|
|
- codemap := make(map[int](map[string]string))
|
|
|
- for i := 1; i < len(sheet.Rows); i++ {
|
|
|
- lineNo := strconv.Itoa(i + 1)
|
|
|
- fmt.Println(lineNo)
|
|
|
- tmp := make(map[string]string)
|
|
|
- tmp["ContractNo"] = sheet.Rows[i].Cells[0].String()
|
|
|
- tmp["ContractName"] = sheet.Rows[i].Cells[1].String()
|
|
|
- tmp["Amount"] = sheet.Rows[i].Cells[2].String()
|
|
|
- tmp["SourceContractClass"] = sheet.Rows[i].Cells[3].String()
|
|
|
-
|
|
|
- tmp["ContractSonClass"] = sheet.Rows[i].Cells[4].String()
|
|
|
- tmp["SmallClass"] = sheet.Rows[i].Cells[5].String()
|
|
|
- tmp["SignedDate"] = convertToFormatDay(sheet.Rows[i].Cells[6].Value)
|
|
|
- tmp["SourceSupplierName"] = sheet.Rows[i].Cells[7].String()
|
|
|
-
|
|
|
- tmp["People"] = sheet.Rows[i].Cells[8].String()
|
|
|
- tmp["Number"] = sheet.Rows[i].Cells[9].String()
|
|
|
- tmp["ChooseWay"] = sheet.Rows[i].Cells[10].String()
|
|
|
- tmp["ContractMark"] = sheet.Rows[i].Cells[11].String()
|
|
|
- tmp["Currency"] = sheet.Rows[i].Cells[12].String()
|
|
|
- tmp["BudgetAmount"] = sheet.Rows[i].Cells[13].String()
|
|
|
- tmp["PerformAmount"] = sheet.Rows[i].Cells[14].String()
|
|
|
- tmp["IsInternal"] = sheet.Rows[i].Cells[15].String()
|
|
|
- tmp["IsForeign"] = sheet.Rows[i].Cells[16].String()
|
|
|
- tmp["IsDeal"] = sheet.Rows[i].Cells[17].String()
|
|
|
- tmp["MoneyFlows"] = sheet.Rows[i].Cells[18].String()
|
|
|
- tmp["MoneyChannel"] = sheet.Rows[i].Cells[19].String()
|
|
|
- tmp["MoneyChannelSon"] = sheet.Rows[i].Cells[20].String()
|
|
|
- tmp["MoneyChannelSmall"] = sheet.Rows[i].Cells[21].String()
|
|
|
- tmp["SingUnit"] = sheet.Rows[i].Cells[22].String()
|
|
|
- tmp["Place"] = sheet.Rows[i].Cells[23].String()
|
|
|
-
|
|
|
- tmp["StartDate"] = convertToFormatDay(sheet.Rows[i].Cells[24].Value)
|
|
|
- tmp["EndDate"] = convertToFormatDay(sheet.Rows[i].Cells[25].Value)
|
|
|
- tmp["DisputeResolution"] = sheet.Rows[i].Cells[26].String()
|
|
|
- tmp["Remark"] = sheet.Rows[i].Cells[27].String()
|
|
|
- tmp["ProjectOwner"] = sheet.Rows[i].Cells[28].String()
|
|
|
- tmp["SubmitDate"] = convertToFormatDay(sheet.Rows[i].Cells[29].Value)
|
|
|
- tmp["SealName"] = sheet.Rows[i].Cells[30].String()
|
|
|
- tmp["PoNumber"] = sheet.Rows[i].Cells[31].String()
|
|
|
- codemap[i-1] = tmp
|
|
|
- //this.OperationCell(svc, lineNo, columnArr, 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()
|
|
|
+ _dir := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx"
|
|
|
+ filename := strconv.Itoa(int(time.Now().Unix())) + ".xlsx"
|
|
|
+ utils.DownloadFile(url, filename, _dir)
|
|
|
+ t := time.Now()
|
|
|
+ filePath := utils.Cfg.MustValue("file", "tmplateDir") + "xlsx/" + filename
|
|
|
+ xlFile, err := xlsx.OpenFile(filePath)
|
|
|
+ //excelFileName := "F:/物资类项目与资质对照表-2017.xlsx"
|
|
|
+ if err != nil {
|
|
|
+ fmt.Printf("open failed: %s\n", err)
|
|
|
+ }
|
|
|
+ var sheet = xlFile.Sheets[0]
|
|
|
+ // 插入字段
|
|
|
+ //Fstrs := "ContractNo,ContractName,Amount,ContractType,ContractSonClass,SmallClass,SignedDate,Number,ChooseWay,ContractMark,Currency,BudgetAmount,PerformAmount,IsInternal,IsForeign,IsDeal,MoneyFlows,MoneyChannel,MoneyChannelSon,MoneyChannelSmall,SingUnit,Place,StartDate,EndDate,DisputeResolution,Remark,ProjectOwner,SubmitDate,SealName,PoNumber"
|
|
|
+ //columnArr := strings.Split(Fstrs, ",")
|
|
|
+
|
|
|
+ //timeTemplate1 := "2006/01/02 15:04:05" //常规类型
|
|
|
+ svc := contract.GetOilContractService(utils.DBE)
|
|
|
+ for i := 1; i < len(sheet.Rows); i++ {
|
|
|
+ var con contract.OilContract
|
|
|
+ var con1 contract.OilContract
|
|
|
+ lineNo := strconv.Itoa(i + 1)
|
|
|
+ fmt.Println(lineNo)
|
|
|
+ svc.GetEntityByWhere(OilContractName, "ContractNo = '" + sheet.Rows[i].Cells[0].String() + "'", &con1)
|
|
|
+ if con1.Id > 0 {
|
|
|
+ con1.ContractName = sheet.Rows[i].Cells[1].String()
|
|
|
+ con1.Amount = sheet.Rows[i].Cells[2].String()
|
|
|
+ con1.Class = sheet.Rows[i].Cells[3].String()
|
|
|
+ con1.ContractSonClass = sheet.Rows[i].Cells[4].String()
|
|
|
+ con1.SmallClass = sheet.Rows[i].Cells[5].String()
|
|
|
+ con1.SignedDate,_ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[6].Value), time.Local)
|
|
|
+ con1.Number = sheet.Rows[i].Cells[9].String()
|
|
|
+ con1.ChooseWay = sheet.Rows[i].Cells[10].String()
|
|
|
+ con1.ContractMark = sheet.Rows[i].Cells[11].String()
|
|
|
+ con1.Currency = sheet.Rows[i].Cells[12].String()
|
|
|
+ con1.BudgetAmount = sheet.Rows[i].Cells[13].String()
|
|
|
+ con1.PerformAmount = sheet.Rows[i].Cells[14].String()
|
|
|
+ con1.IsYearMoney = con1.PerformAmount
|
|
|
+ con1.IsInternal = 0
|
|
|
+ if sheet.Rows[i].Cells[15].String() == "是" {
|
|
|
+ con1.IsInternal = 1
|
|
|
+ }
|
|
|
+ con1.IsForeign = 0
|
|
|
+ if sheet.Rows[i].Cells[16].String() == "是" {
|
|
|
+ con1.IsForeign = 1
|
|
|
+ }
|
|
|
+ con1.IsDeal = 0
|
|
|
+ if sheet.Rows[i].Cells[17].String() == "是" {
|
|
|
+ con1.IsDeal = 1
|
|
|
+ }
|
|
|
+ con1.MoneyFlows = sheet.Rows[i].Cells[18].String()
|
|
|
+ con1.MoneyChannel = sheet.Rows[i].Cells[19].String()
|
|
|
+ con1.MoneyChannelSon = sheet.Rows[i].Cells[20].String()
|
|
|
+ con1.MoneyChannelSmall = sheet.Rows[i].Cells[21].String()
|
|
|
+ con1.SingUnit = sheet.Rows[i].Cells[22].String()
|
|
|
+ con1.Place = sheet.Rows[i].Cells[23].String()
|
|
|
+
|
|
|
+ con1.StartDate,_ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[24].Value), time.Local)
|
|
|
+ con1.EndDate,_ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[25].Value), time.Local)
|
|
|
+ con1.DisputeResolution = sheet.Rows[i].Cells[26].String()
|
|
|
+ con1.Remark = sheet.Rows[i].Cells[27].String()
|
|
|
+ if con1.ProjectOwner != sheet.Rows[i].Cells[28].String() {
|
|
|
+ con1.ProjectOwner = con1.ProjectOwner + "," + sheet.Rows[i].Cells[28].String()
|
|
|
+ }
|
|
|
+ con1.SubmitDate,_ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[29].Value), time.Local)
|
|
|
+ con1.SealName = sheet.Rows[i].Cells[30].String()
|
|
|
+ con1.PoNumber = sheet.Rows[i].Cells[31].String()
|
|
|
+ con1.ImportStatus = 0
|
|
|
+ svc.UpdateEntityById(con1.Id, &con1)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ con.ContractNo = sheet.Rows[i].Cells[0].String()
|
|
|
+ con.ContractName = sheet.Rows[i].Cells[1].String()
|
|
|
+ con.Amount = sheet.Rows[i].Cells[2].String()
|
|
|
+ con.Class = sheet.Rows[i].Cells[3].String()
|
|
|
+
|
|
|
+ con.ContractSonClass = sheet.Rows[i].Cells[4].String()
|
|
|
+ con.SmallClass = sheet.Rows[i].Cells[5].String()
|
|
|
+ //con.SignedDate = convertToFormatDay(sheet.Rows[i].Cells[6].Value)
|
|
|
+ con.SignedDate,_ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[6].Value), time.Local)
|
|
|
+ con.ImportSecondUnit = sheet.Rows[i].Cells[7].String()
|
|
|
+
|
|
|
+ con.ImportSupplierName = sheet.Rows[i].Cells[8].String()
|
|
|
+ var supp supplier.OilSupplier
|
|
|
+ svc.GetEntityByWhere(OilSupplierName, "SupplierName = '" + con.ImportSupplierName + "'", &supp)
|
|
|
+ if supp.Id > 0 {
|
|
|
+ con.SupplierId = supp.Id
|
|
|
+ }
|
|
|
+ var org organize.Base_Organize
|
|
|
+ svc.GetEntityByWhere("Base_Organize", "FullName = '" + sheet.Rows[i].Cells[7].String() + "'", &org)
|
|
|
+ if org.Id > 0 {
|
|
|
+ con.SecondUnit = org.Id
|
|
|
+ }
|
|
|
+ con.Number = sheet.Rows[i].Cells[9].String()
|
|
|
+ con.ChooseWay = sheet.Rows[i].Cells[10].String()
|
|
|
+ con.ContractMark = sheet.Rows[i].Cells[11].String()
|
|
|
+ con.Currency = sheet.Rows[i].Cells[12].String()
|
|
|
+ con.BudgetAmount = sheet.Rows[i].Cells[13].String()
|
|
|
+ con.PerformAmount = sheet.Rows[i].Cells[14].String()
|
|
|
+ con.IsYearMoney = con.PerformAmount
|
|
|
+ con.IsInternal = 0
|
|
|
+ if sheet.Rows[i].Cells[15].String() == "是" {
|
|
|
+ con.IsInternal = 1
|
|
|
+ }
|
|
|
+ con.IsForeign = 0
|
|
|
+ if sheet.Rows[i].Cells[16].String() == "是" {
|
|
|
+ con.IsForeign = 1
|
|
|
+ }
|
|
|
+ con.IsDeal = 0
|
|
|
+ if sheet.Rows[i].Cells[17].String() == "是" {
|
|
|
+ con.IsDeal = 1
|
|
|
+ }
|
|
|
+ con.MoneyFlows = sheet.Rows[i].Cells[18].String()
|
|
|
+ con.MoneyChannel = sheet.Rows[i].Cells[19].String()
|
|
|
+ con.MoneyChannelSon = sheet.Rows[i].Cells[20].String()
|
|
|
+ con.MoneyChannelSmall = sheet.Rows[i].Cells[21].String()
|
|
|
+ con.SingUnit = sheet.Rows[i].Cells[22].String()
|
|
|
+ con.Place = sheet.Rows[i].Cells[23].String()
|
|
|
+
|
|
|
+ con.StartDate,_ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[24].Value), time.Local)
|
|
|
+ con.EndDate,_ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[25].Value), time.Local)
|
|
|
+ con.DisputeResolution = sheet.Rows[i].Cells[26].String()
|
|
|
+ con.Remark = sheet.Rows[i].Cells[27].String()
|
|
|
+ con.ProjectOwner = sheet.Rows[i].Cells[28].String()
|
|
|
+ con.SubmitDate,_ = time.ParseInLocation("2006-01-02", convertToFormatDay(sheet.Rows[i].Cells[29].Value), time.Local)
|
|
|
+ con.SealName = sheet.Rows[i].Cells[30].String()
|
|
|
+ con.PoNumber = sheet.Rows[i].Cells[31].String()
|
|
|
+ con.ImportStatus = 0
|
|
|
+ con.Status = 1
|
|
|
+ con.SettleStatus = "1"
|
|
|
+ _, err = svc.InsertEntityBytbl(OilContractName, &con)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ os.Remove(filePath)
|
|
|
elapsed := time.Since(t)
|
|
|
log.Println(elapsed)
|
|
|
- errorinfo.Code = 0
|
|
|
- errorinfo.Message = "导入成功!"
|
|
|
- errorinfo.Item = codemap
|
|
|
- this.Data["json"] = &errorinfo
|
|
|
- this.ServeJSON()
|
|
|
- }
|
|
|
+ }()
|
|
|
+ var errorinfo ErrorDataInfo
|
|
|
+ errorinfo.Code = 0
|
|
|
+ errorinfo.Message = "导入中,请稍后!"
|
|
|
+ this.Data["json"] = &errorinfo
|
|
|
+ this.ServeJSON()
|
|
|
}
|
|
|
|
|
|
// @Title 从数据录入数据导出到word文档
|
|
|
@@ -605,101 +664,288 @@ func (this *OilContractController) DocExport() {
|
|
|
// @Success 200 {object} controllers.Request
|
|
|
// @router /importbatchsave [post]
|
|
|
func (this *OilContractController) ImportBatchSave() {
|
|
|
- var model contract.OilContractItems
|
|
|
- var jsonBlob = this.Ctx.Input.RequestBody
|
|
|
- json.Unmarshal(jsonBlob, &model)
|
|
|
+
|
|
|
+ sql := "update OilContract set ImportStatus = 1 where SupplierId != 0 and ContractClass != '' and SecondUnit != 0"
|
|
|
+ _, err := utils.DBE.Query(sql)
|
|
|
var errinfo ErrorInfo
|
|
|
- svc := contract.GetOilContractService(utils.DBE)
|
|
|
+ if err == nil {
|
|
|
+ errinfo.Message = "确认成功!"
|
|
|
+ errinfo.Code = 0
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ } else {
|
|
|
+ errinfo.Message = "确认失败!" + utils.AlertProcess(err.Error())
|
|
|
+ errinfo.Code = -1
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
// 新增配置项
|
|
|
- for i, v := range model.Items {
|
|
|
- fmt.Print(i)
|
|
|
- if v.SupplierName == "" || v.SupplierId == 0 {
|
|
|
- errinfo.Message = "操作失败!未选择供应商名称,行号:" + strconv.Itoa(i+1)
|
|
|
- errinfo.Code = -2
|
|
|
- this.Data["json"] = &errinfo
|
|
|
- this.ServeJSON()
|
|
|
- return
|
|
|
- }
|
|
|
- if v.ContractClass == "" {
|
|
|
- errinfo.Message = "操作失败!未选择合同分类,行号:" + strconv.Itoa(i+1)
|
|
|
- errinfo.Code = -2
|
|
|
- this.Data["json"] = &errinfo
|
|
|
- this.ServeJSON()
|
|
|
- return
|
|
|
- }
|
|
|
- if v.ContractNo == "" {
|
|
|
- errinfo.Message = "操作失败!合同编号不能为空,行号:" + strconv.Itoa(i+1)
|
|
|
- errinfo.Code = -2
|
|
|
- this.Data["json"] = &errinfo
|
|
|
- this.ServeJSON()
|
|
|
- return
|
|
|
- }
|
|
|
- if v.ContractName == "" {
|
|
|
- errinfo.Message = "操作失败!合同名称不能为空,行号:" + strconv.Itoa(i+1)
|
|
|
- errinfo.Code = -2
|
|
|
- this.Data["json"] = &errinfo
|
|
|
- this.ServeJSON()
|
|
|
- return
|
|
|
- }
|
|
|
+ //for i, v := range model.Items {
|
|
|
+ // fmt.Print(i)
|
|
|
+ // if v.SupplierName == "" || v.SupplierId == 0 {
|
|
|
+ // errinfo.Message = "操作失败!未选择供应商名称,行号:" + strconv.Itoa(i+1)
|
|
|
+ // errinfo.Code = -2
|
|
|
+ // this.Data["json"] = &errinfo
|
|
|
+ // this.ServeJSON()
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // if v.ContractClass == "" {
|
|
|
+ // errinfo.Message = "操作失败!未选择合同分类,行号:" + strconv.Itoa(i+1)
|
|
|
+ // errinfo.Code = -2
|
|
|
+ // this.Data["json"] = &errinfo
|
|
|
+ // this.ServeJSON()
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // if v.ContractNo == "" {
|
|
|
+ // errinfo.Message = "操作失败!合同编号不能为空,行号:" + strconv.Itoa(i+1)
|
|
|
+ // errinfo.Code = -2
|
|
|
+ // this.Data["json"] = &errinfo
|
|
|
+ // this.ServeJSON()
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // if v.ContractName == "" {
|
|
|
+ // errinfo.Message = "操作失败!合同名称不能为空,行号:" + strconv.Itoa(i+1)
|
|
|
+ // errinfo.Code = -2
|
|
|
+ // this.Data["json"] = &errinfo
|
|
|
+ // this.ServeJSON()
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // var noCount = 0
|
|
|
+ // var nameCount = 0
|
|
|
+ // for ii, vv := range model.Items {
|
|
|
+ // fmt.Print(ii)
|
|
|
+ // if vv.ContractNo == v.ContractNo {
|
|
|
+ // noCount++
|
|
|
+ // }
|
|
|
+ // if vv.ContractName == v.ContractName {
|
|
|
+ // nameCount++
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if nameCount >= 2 {
|
|
|
+ // errinfo.Message = "操作失败!合同名称已存在,行号:" + strconv.Itoa(i+1)
|
|
|
+ // errinfo.Code = -2
|
|
|
+ // this.Data["json"] = &errinfo
|
|
|
+ // this.ServeJSON()
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // var contract contract.OilContract
|
|
|
+ //
|
|
|
+ // tempCount2, _ := svc.GetCount(&contract, "ContractName='"+v.ContractName+"'")
|
|
|
+ // if tempCount2 > 0 {
|
|
|
+ // errinfo.Message = "操作失败!合同名称已存在,行号:" + strconv.Itoa(i+1)
|
|
|
+ // errinfo.Code = -2
|
|
|
+ // this.Data["json"] = &errinfo
|
|
|
+ // this.ServeJSON()
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // model.Items[i].CreateUserId, _ = strconv.Atoi(this.User.Id)
|
|
|
+ // model.Items[i].CreateOn = time.Now()
|
|
|
+ // model.Items[i].CreateBy = this.User.Realname
|
|
|
+ // svc.GetEntity(&contract, "ContractNo='"+v.ContractNo+"'")
|
|
|
+ // if contract.Id > 0 {
|
|
|
+ // cols := []string{
|
|
|
+ //
|
|
|
+ // "Id",
|
|
|
+ //
|
|
|
+ // "SupplierId",
|
|
|
+ //
|
|
|
+ // "SupplierName",
|
|
|
+ //
|
|
|
+ // "Status",
|
|
|
+ //
|
|
|
+ // "SettleStatus",
|
|
|
+ //
|
|
|
+ // "ProjectName",
|
|
|
+ //
|
|
|
+ // "ContractNo",
|
|
|
+ //
|
|
|
+ // "ProjectPlace",
|
|
|
+ //
|
|
|
+ // "ProjectOwner",
|
|
|
+ //
|
|
|
+ // "Telephone",
|
|
|
+ //
|
|
|
+ // "ProjectType",
|
|
|
+ //
|
|
|
+ // "ContractMode",
|
|
|
+ //
|
|
|
+ // "Amount",
|
|
|
+ //
|
|
|
+ // "ContractPeriod",
|
|
|
+ //
|
|
|
+ // "OpenDate",
|
|
|
+ //
|
|
|
+ // "PlanFinishDate",
|
|
|
+ //
|
|
|
+ // "ConstructionUnit",
|
|
|
+ //
|
|
|
+ // "ConstructionOwner",
|
|
|
+ //
|
|
|
+ // "ConstructionTelphone",
|
|
|
+ //
|
|
|
+ // "BuildUnit",
|
|
|
+ //
|
|
|
+ // "BuildOwner",
|
|
|
+ //
|
|
|
+ // "BuildTelphone",
|
|
|
+ //
|
|
|
+ // "SuperviseUnit",
|
|
|
+ //
|
|
|
+ // "SuperviseOwner",
|
|
|
+ //
|
|
|
+ // "SuperviseTelphone",
|
|
|
+ //
|
|
|
+ // "QualityUnit",
|
|
|
+ //
|
|
|
+ // "QualityOwner",
|
|
|
+ //
|
|
|
+ // "QualityTelphone",
|
|
|
+ //
|
|
|
+ // "Remark",
|
|
|
+ //
|
|
|
+ // "IsDelete",
|
|
|
+ //
|
|
|
+ // "CreateOn",
|
|
|
+ //
|
|
|
+ // "CreateUserId",
|
|
|
+ //
|
|
|
+ // "CreateBy",
|
|
|
+ //
|
|
|
+ // "ModifiedOn",
|
|
|
+ //
|
|
|
+ // "ModifiedUserId",
|
|
|
+ //
|
|
|
+ // "ModifiedBy",
|
|
|
+ //
|
|
|
+ // "SubPackage",
|
|
|
+ //
|
|
|
+ // "ContractName",
|
|
|
+ //
|
|
|
+ // "ContractSonClass",
|
|
|
+ //
|
|
|
+ // "SmallClass",
|
|
|
+ //
|
|
|
+ // "SignedDate",
|
|
|
+ //
|
|
|
+ // "People",
|
|
|
+ //
|
|
|
+ // "Number",
|
|
|
+ //
|
|
|
+ // "ChooseWay",
|
|
|
+ //
|
|
|
+ // "ContractMark",
|
|
|
+ //
|
|
|
+ // "Currency",
|
|
|
+ //
|
|
|
+ // "BudgetAmount",
|
|
|
+ //
|
|
|
+ // "PerformAmount",
|
|
|
+ //
|
|
|
+ // "IsInternal",
|
|
|
+ //
|
|
|
+ // "IsForeign",
|
|
|
+ //
|
|
|
+ // "IsDeal",
|
|
|
+ //
|
|
|
+ // "MoneyFlows",
|
|
|
+ //
|
|
|
+ // "MoneyChannelSon",
|
|
|
+ //
|
|
|
+ // "MoneyChannelSmall",
|
|
|
+ //
|
|
|
+ // "SingUnit",
|
|
|
+ //
|
|
|
+ // "Place",
|
|
|
+ //
|
|
|
+ // "DisputeResolution",
|
|
|
+ //
|
|
|
+ // "SubmitDate",
|
|
|
+ //
|
|
|
+ // "SealName",
|
|
|
+ //
|
|
|
+ // "PoNumber",
|
|
|
+ // }
|
|
|
+ // contract.SupplierName = v.SupplierName
|
|
|
+ // contract.ProjectName = v.ProjectName
|
|
|
+ // contract.ProjectPlace = v.ProjectPlace
|
|
|
+ // contract.ProjectOwner = contract.ProjectOwner + "," + v.ProjectOwner
|
|
|
+ // contract.Amount = v.Amount
|
|
|
+ // err = svc.UpdateEntityBytbl(OilContractName, contract.Id, &contract, cols)
|
|
|
+ // } else {
|
|
|
+ // _, err = svc.InsertEntityBytbl(OilContractName, &model.Items[i])
|
|
|
+ // }
|
|
|
+ //}
|
|
|
|
|
|
- var noCount = 0
|
|
|
- var nameCount = 0
|
|
|
- for ii, vv := range model.Items {
|
|
|
- fmt.Print(ii)
|
|
|
- if vv.ContractNo == v.ContractNo {
|
|
|
- noCount++
|
|
|
- }
|
|
|
- if vv.ContractName == v.ContractName {
|
|
|
- nameCount++
|
|
|
- }
|
|
|
- }
|
|
|
- if noCount >= 2 {
|
|
|
- errinfo.Message = "操作失败!合同编号已存在,行号:" + strconv.Itoa(i+1)
|
|
|
- errinfo.Code = -2
|
|
|
- this.Data["json"] = &errinfo
|
|
|
- this.ServeJSON()
|
|
|
- return
|
|
|
- }
|
|
|
- if nameCount >= 2 {
|
|
|
- errinfo.Message = "操作失败!合同名称已存在,行号:" + strconv.Itoa(i+1)
|
|
|
- errinfo.Code = -2
|
|
|
- this.Data["json"] = &errinfo
|
|
|
- this.ServeJSON()
|
|
|
- return
|
|
|
- }
|
|
|
|
|
|
- var contract contract.OilContract
|
|
|
- tempCount, _ := svc.GetCount(&contract, "ContractNo='"+v.ContractNo+"'")
|
|
|
- if tempCount > 0 {
|
|
|
- errinfo.Message = "操作失败!合同编号已存在,行号:" + strconv.Itoa(i+1)
|
|
|
- errinfo.Code = -2
|
|
|
- this.Data["json"] = &errinfo
|
|
|
- this.ServeJSON()
|
|
|
- return
|
|
|
- }
|
|
|
+}
|
|
|
|
|
|
- tempCount2, _ := svc.GetCount(&contract, "ContractName='"+v.ContractName+"'")
|
|
|
- if tempCount2 > 0 {
|
|
|
- errinfo.Message = "操作失败!合同名称已存在,行号:" + strconv.Itoa(i+1)
|
|
|
- errinfo.Code = -2
|
|
|
- this.Data["json"] = &errinfo
|
|
|
- this.ServeJSON()
|
|
|
- return
|
|
|
+// @Title get 批量修改字段
|
|
|
+// @Description 批量修改字段
|
|
|
+// @Success 200 {object} controllers.Request
|
|
|
+// @router /importUpdate [get]
|
|
|
+func (this *OilContractController) ImportUpdate() {
|
|
|
+ Class := this.GetString("Class")
|
|
|
+ Value := this.GetString("Value")
|
|
|
+ Column := this.GetString("Column")
|
|
|
+ Id := this.GetString("Id")
|
|
|
+ var err error
|
|
|
+ where := "1=1"
|
|
|
+ if Column == "ContractClass" {
|
|
|
+ if Id != "" {
|
|
|
+ where += " and Id = " + Id + " and ImportStatus = 0 and Class = '" + Class + "'"
|
|
|
+ } else {
|
|
|
+ where += " and ImportStatus = 0 and Class = '" + Class + "' and " + Column + " = ''"
|
|
|
}
|
|
|
+ sql := "update OilContract set " + Column + " = '" + Value + "' where " + where
|
|
|
+ _, err = utils.DBE.Query(sql)
|
|
|
+ }
|
|
|
+ if Column == "SupplierId" {
|
|
|
+ var supp supplier.OilSupplier
|
|
|
+ svc := supplier.GetOilSupplierService(utils.DBE)
|
|
|
+ svc.GetEntityById(Value, &supp)
|
|
|
+ if Id != "" {
|
|
|
+ where += " and Id = " + Id + " and ImportStatus = 0 and ImportSupplierName = '" + Class + "'"
|
|
|
+ } else {
|
|
|
+ where += " and ImportStatus = 0 and ImportSupplierName = '" + Class + "' and " + Column + " = 0"
|
|
|
+ }
|
|
|
+ sql := "update OilContract set SupplierName = '" + supp.SupplierName + "', " + Column + " = " + Value + " where " + where
|
|
|
+ _, err = utils.DBE.Query(sql)
|
|
|
+ }
|
|
|
|
|
|
- model.Items[i].CreateUserId, _ = strconv.Atoi(this.User.Id)
|
|
|
- model.Items[i].CreateOn = time.Now()
|
|
|
- model.Items[i].CreateBy = this.User.Realname
|
|
|
+ if Column == "SecondUnit" {
|
|
|
+ if Id != "" {
|
|
|
+ where += " and Id = " + Id + " and ImportStatus = 0 and ImportSecondUnit = '" + Class + "'"
|
|
|
+ } else {
|
|
|
+ where += " and ImportStatus = 0 and ImportSecondUnit = '" + Class + "' and " + Column + " = 0"
|
|
|
+ }
|
|
|
+ sql := "update OilContract set " + Column + " = " + Value + " where " + where
|
|
|
+ _, err = utils.DBE.Query(sql)
|
|
|
+ }
|
|
|
|
|
|
+ if Column == "Status" {
|
|
|
+ where += " and Id = " + Id + " and ImportStatus = 0"
|
|
|
+ sql := "update OilContract set " + Column + " = " + Value + " where " + where
|
|
|
+ _, err = utils.DBE.Query(sql)
|
|
|
}
|
|
|
- _, err := svc.DBE.Insert(model.Items)
|
|
|
+ if Column == "SettleStatus" {
|
|
|
+ where += " and Id = " + Id + " and ImportStatus = 0"
|
|
|
+ sql := "update OilContract set " + Column + " = '" + Value + "' where " + where
|
|
|
+ _, err = utils.DBE.Query(sql)
|
|
|
+ }
|
|
|
+
|
|
|
+ var errinfo ErrorInfo
|
|
|
if err == nil {
|
|
|
- errinfo.Message = "导入成功!"
|
|
|
+ errinfo.Message = "修改成功!"
|
|
|
errinfo.Code = 0
|
|
|
this.Data["json"] = &errinfo
|
|
|
this.ServeJSON()
|
|
|
} else {
|
|
|
- errinfo.Message = "导入失败!" + utils.AlertProcess(err.Error())
|
|
|
+ errinfo.Message = "修改失败!" + utils.AlertProcess(err.Error())
|
|
|
errinfo.Code = -1
|
|
|
this.Data["json"] = &errinfo
|
|
|
this.ServeJSON()
|
|
|
@@ -836,6 +1082,9 @@ func (this *OilContractController) UpdateEntity() {
|
|
|
|
|
|
var jsonBlob = this.Ctx.Input.RequestBody
|
|
|
json.Unmarshal(jsonBlob, &model)
|
|
|
+ if model.IsYearMoney == "" {
|
|
|
+ model.IsYearMoney = model.PerformAmount
|
|
|
+ }
|
|
|
model.ModifiedOn = time.Now()
|
|
|
model.ModifiedBy = this.User.Realname
|
|
|
model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
@@ -961,6 +1210,10 @@ func (this *OilContractController) UpdateEntity() {
|
|
|
"SealName",
|
|
|
|
|
|
"PoNumber",
|
|
|
+
|
|
|
+ "IsYearMoney",
|
|
|
+
|
|
|
+ "IsYear",
|
|
|
}
|
|
|
|
|
|
var contract contract.OilContract
|