2
3
Yikoo 5 rokov pred
rodič
commit
bd75cc768e

+ 13 - 1
src/dashoo.cn/backend/api/business/oilcontract/contractSumScore/contractSumScoreService.go

@@ -51,7 +51,19 @@ func (s *OilContractSumScoreService)GetMyPagingEntitiesWithOrderBytbl(pageIndex,
 	}
 	return total
 }
-
+func (s *OilContractSumScoreService)GetMyEntitiesWithOrderBytbl( orderby string, asc bool, entitiesPtr interface{}, where string) () {
+	var sql string
+	sql =  `select * `
+	sql += ` from ` + controllers.OilContractSumScoreName + ` score `
+	sql += ` left join ` + controllers.OilContractSumScoreItemsName + ` items on items.SumScoreId = score.id `
+	sql += ` where ` + where
+	if asc {
+		sql += ` order by ` + orderby + ` ASC `
+	} else {
+		sql += ` order by ` + orderby + ` DESC `
+	}
+	s.DBE.SQL(sql).Find(entitiesPtr)
+}
 func (s *OilContractSumScoreService) GetPagingComputeEntitiesWithOrderBytbl(pageIndex, itemsPerPage int64, orderby string, asc bool, entitiesPtr interface{}, where string) (total int64) {
 	var resultsSlice []map[string][]byte
 	//获取总记录数

+ 47 - 0
src/dashoo.cn/backend/api/business/workflow/ActivitiService.go

@@ -574,6 +574,53 @@ func (this *ActivitiService) FillWordTemplate(datas map[string]interface{}, temp
 	return retDocUrl
 }
 
+func (this *ActivitiService) FillExcel(datas map[string]interface{}, ContractClass string, templateUrl string, fileName string) string {
+	var wordTempVM excelTemplateVM
+	wordTempVM.ContractClass = ContractClass
+	wordTempVM.Datas         = datas
+	wordTempVM.TemplateUrl   = templateUrl
+	wordTempVM.FileName      = fileName
+	jsonParam, err := json.Marshal(wordTempVM)
+	if err != nil {
+		fmt.Println(err, "生成json字符串错误")
+	}
+	params := string(jsonParam)
+	retVal := this.PostOrigin("/excel/fill-excel", params, "")
+	if retVal.StatusCode != 200 {
+		return ""
+	}
+
+	_dir := utils.Cfg.MustValue("file", "tmplateDir") + "excel"
+	utils.CreatePath(_dir)
+	_dir += "/tmp_" + strconv.Itoa(int(time.Now().Unix())) + ".xlsx"
+	raw := retVal.Body
+	defer raw.Close()
+
+	file, err := os.Create(_dir)
+	defer file.Close()
+	writer := bufio.NewWriter(file)
+	defer writer.Flush()
+	body, err := ioutil.ReadAll(raw)
+	writer.Write(body)
+
+	if err != nil {
+		return ""
+	}
+	var sw *Seaweed
+	var filer []string
+	if _filer := os.Getenv("GOSWFS_FILER_URL"); _filer != "" {
+		filer = []string{_filer}
+	}
+	sw = NewSeaweed("http", utils.Cfg.MustValue("file", "upFileHost"), filer, 2*1024*1024, 5*time.Minute)
+	//_, fID, err := sw.Upload(retVal.Body, "tmp.pdf", int64(len(pdfByte)), "", "")
+	_, _, fID, err := sw.UploadFile(_dir, "", "")
+	retDocUrl := utils.Cfg.MustValue("file", "downFileHost") + "/" + fID
+	os.Remove(_dir)
+	fmt.Println("==retDocUrl==", retDocUrl)
+	return retDocUrl
+}
+
+
 // 带水印
 func (this *ActivitiService) FillWordWatermarkTemplate(datas map[string]interface{}, templateUrl string, fileName,watermark string) string {
 	var wordTempVM WordTemplateWatermarkVM

+ 6 - 1
src/dashoo.cn/backend/api/business/workflow/workflow.go

@@ -72,7 +72,12 @@ type WordTemplateVM struct {
 	TemplateUrl string                 `json:"templateUrl"`
 	FileName    string                 `json:"fileName"`
 }
-
+type excelTemplateVM struct {
+	Datas       map[string]interface{} `json:"datas"`
+	TemplateUrl string                 `json:"templateUrl"`
+	FileName    string                 `json:"fileName"`
+	ContractClass string               `json:"contractClass"`
+}
 type WordTemplateWatermarkVM struct {
 	Datas       map[string]interface{} `json:"datas"`
 	TemplateUrl string                 `json:"templateUrl"`

+ 2 - 0
src/dashoo.cn/backend/api/conf/app.conf

@@ -67,6 +67,8 @@ reviewGoodsUrl=http://weed1.labsop.cn:9390/2,0355a3f5ca652a
 reviewServiceUrl=http://weed1.labsop.cn:9390/3,0369a172bea898
 reviewBasisUrl=http://weed1.labsop.cn:9390/5,0369a94f72dc30
 contractSumScoreUrl=http://weed1.labsop.cn:9390/6,0369ac47ca5e40
+ServiceSumScoreUrl=http://weed1.labsop.cn:9390/1,036a3addb41d61
+GoodsSumScoreUrl=http://weed1.labsop.cn:9390/3,036a40af17839b
 
 goodsModuleHost=http://weed1.labsop.cn:9390/6,387ef1cde26d
 basisModuleHost=http://weed1.labsop.cn:9390/4,387f41329d9c

+ 120 - 3
src/dashoo.cn/backend/api/controllers/oilcontract/contractSumScore.go

@@ -726,9 +726,6 @@ func (this *OilContractSumScoreController) DocExport() {
 	datamap["Year"] = model.Year
 	datamap["Department"] = model.Unit
 
-
-
-
 	fileName := "承包商年度评价表和综合年度评价表.docx"
 	Url      := utils.Cfg.MustValue("workflow", "contractSumScoreUrl")
 
@@ -742,6 +739,126 @@ func (this *OilContractSumScoreController) DocExport() {
 	this.Data["json"] = &datainfo
 	this.ServeJSON()
 }
+// @Title 从数据录入数据导出到Excel文档
+// @Description 数据存入Excel
+// @Success	200	{object} controllers.Request
+// @router /exportexcel [get]
+func (this *OilContractSumScoreController)  ExcelExport(){
+	//获取分页信息
+	where := " 1=1 "
+	orderby := "score.Id"
+	asc := false
+	Order := this.GetString("Order")
+	Prop := this.GetString("Prop")
+	if Order != "" && Prop != "" {
+		orderby = Prop
+		if Order == "asc" {
+			asc = true
+		}
+	}
+	Id := this.GetString("Id")
+	SupplierId := this.GetString("SupplierId")
+	ContractClass := this.GetString("ContractClass")
+	SupplierName := this.GetString("SupplierName")
+	Year := this.GetString("Year")
+	Status := this.GetString("Status")
+	CreateOn := this.GetString("CreateOn")
+	CreateUserId := this.GetString("CreateUserId")
+	CreateBy := this.GetString("CreateBy")
+	ModifiedOn := this.GetString("ModifiedOn")
+	ModifiedUserId := this.GetString("ModifiedUserId")
+	ModifiedBy := this.GetString("ModifiedBy")
+	if Id != "" {
+		where = where + " and score.Id like '%" + Id + "%'"
+	}
+	if SupplierId != "" {
+		where = where + " and score.SupplierId like '%" + SupplierId + "%'"
+	}
+	if SupplierName != "" {
+		where = where + " and score.SupplierName like '%" + SupplierName + "%'"
+	}
+	if ContractClass != "" {
+		where = where + " and score.ContractClass like '%" + ContractClass + "%'"
+	}
+	if Year != "" {
+		where = where + " and score.Year like '%" + Year + "%'"
+	}
+
+	if Status != "" {
+		where = where + " and score.Status = '" + Status + "'"
+	}
+	//if CreateOn != "" {
+	//	where = where + " and CreateOn like '%" + CreateOn + "%'"
+	//}
+
+	if CreateUserId != "" {
+		where = where + " and score.CreateUserId like '%" + CreateUserId + "%'"
+	}
+
+	if CreateBy != "" {
+		where = where + " and score.CreateBy like '%" + CreateBy + "%'"
+	}
+
+	if ModifiedOn != "" {
+		where = where + " and score.ModifiedOn like '%" + ModifiedOn + "%'"
+	}
+
+	if ModifiedUserId != "" {
+		where = where + " and score.ModifiedUserId like '%" + ModifiedUserId + "%'"
+	}
+
+	if ModifiedBy != "" {
+		where = where + " and score.ModifiedBy like '%" + ModifiedBy + "%'"
+	}
+	if CreateOn != "" {
+		dates := strings.Split(CreateOn, ",")
+		if len(dates) == 2 {
+			minDate := dates[0]
+			maxDate := dates[1]
+			where = where + " and score.CreateOn>='" + minDate + "' and score.CreateOn<='" + maxDate + "'"
+		}
+	}
+	where = where + " and items.Category = '0' "
+
+	//超级管理员和有查看所有数据权限的用户不加条件
+	svcPerm := permission.GetPermissionService(utils.DBE)
+	isauth  := svcPerm.IsAuthorized(this.User.Id, "oil_contract.SumStore.AllRecord")
+	if(!isauth){
+		// 权限过滤  自己创建的评价 ,同二级部门创建的评价 ,企管法规处能看
+		where = where + " and ( score.CreateUserId =  '" + this.User.Id + "' "
+		where = where + " or score.UnitId = '" +  strconv.Itoa(this.User.UnitId) + "' "
+		where = where + " )"
+	}
+
+	svc := contractSumScore.GetOilContractSumScoreService(utils.DBE)
+	var list []contractSumScore.OilContractSumScoreVo
+	svc.GetMyEntitiesWithOrderBytbl(orderby, asc, &list, where)
+
+	var Url string
+	var fileName string
+	fileName = ""
+	Url      = ""
+	if ContractClass == "03" {
+		fileName = "服务商年度评价表.xlsx"
+		Url = utils.Cfg.MustValue("workflow", "ServiceSumScoreUrl")
+	} else if ContractClass == "01"{
+		fileName = "供应商年度评价表.xlsx"
+		Url = utils.Cfg.MustValue("workflow", "GoodsSumScoreUrl")
+	}
+
+	svcActiviti := workflow.GetActivitiService(utils.DBE)
+
+	var datamap = make(map[string]interface{})
+	datamap["data"] = list
+
+	retDocUrl := svcActiviti.FillExcel(datamap,ContractClass, Url, fileName)
+	var datainfo ErrorDataInfo
+	datainfo.Code = 0
+	datainfo.Item = retDocUrl
+	datainfo.Message = "导出成功"
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
 
 // @Title 添加
 // @Description 专业科室保存评价

BIN
src/dashoo.cn/doc/供应商年度评价表.xlsx


BIN
src/dashoo.cn/doc/供应商日常业绩评价表模板.docx


BIN
src/dashoo.cn/doc/合同导出模板.docx


BIN
src/dashoo.cn/doc/承包商年度评价表和综合年度评价表模板.docx


BIN
src/dashoo.cn/doc/承包商日常业绩评价表模板.docx


BIN
src/dashoo.cn/doc/服务商年度评价表.xlsx


BIN
src/dashoo.cn/doc/服务商日常业绩评价表模板.docx