3
2
yuedefeng 6 سال پیش
والد
کامیت
90ab1b8313
2فایلهای تغییر یافته به همراه492 افزوده شده و 0 حذف شده
  1. 323 0
      src/dashoo.cn/backend/api/controllers/lims/customer.go
  2. 169 0
      src/dashoo.cn/backend/api/routers/router.go

+ 323 - 0
src/dashoo.cn/backend/api/controllers/lims/customer.go

@@ -0,0 +1,323 @@
+package lims
+
+import (
+	"encoding/json"
+	"strings"
+
+	. "dashoo.cn/backend/api/controllers"
+	customer2 "dashoo.cn/backend/api/business/customer"
+	"dashoo.cn/utils"
+)
+
+type CustomerController struct {
+	BaseController
+}
+// 附件model
+type ContractAttachmentarrt struct {
+	Host       string
+	FileId     string
+	FileName   string
+	FileSize   int32
+	UploadDesc string
+}
+
+//保存附件UI model
+type contractFormmodel struct {
+	PId             int
+	AttachmodelList []ContractAttachmentarrt // 上传附件
+
+}
+
+// @Title 根据用户AccCode get检验主表 客户原始信息内容
+// @Description get user by token
+// @Success 200 {object} models.Userblood
+// @router /customerlist [get]
+func (this *CustomerController) Customerlist() {
+	page := this.GetPageInfoForm()
+	danwei := this.GetString("danwei")
+	lianxiren := this.GetString("lianxiren")
+	telephone := this.GetString("telephone")
+	CreateBy := this.GetString("CreateBy")
+	var list []customer2.Customer
+	svc := customer2.GetCustomerService(utils.DBE)
+	where := " 1=1 "
+	orderby := "Id"
+	asc := false
+	Order := this.GetString("Order")
+	Prop := this.GetString("Prop")
+	if Order != "" && Prop != "" {
+		orderby = Prop
+		if Order == "asc" {
+			asc = true
+		}
+	}
+	if danwei != "" {
+		where = where + " and CustomerName like '%" + danwei + "%'"
+	}
+	if CreateBy != "" {
+		where = where + " and CreateBy like '%" + CreateBy + "%'"
+	}
+	if lianxiren != "" {
+		where = where + " and Person like '%" + lianxiren + "%'"
+	}
+	if telephone != "" {
+		where = where + " and Telephone like '%" + telephone + "%'"
+	}
+	CreateOn := this.GetString("CreateOn")
+	if CreateOn != "" {
+		dates := strings.Split(CreateOn, ",")
+		if len(dates) == 2 {
+			minDate := dates[0]
+			maxDate := dates[1]
+			where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
+		}
+	}
+
+	total := svc.GetPagingEntitiesWithOrderBytbl(this.User.AccCode, page.CurrentPage, page.Size, orderby, asc, &list, where)
+	var datainfo DataInfo
+	datainfo.Items = list
+	datainfo.CurrentItemCount = total
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 添加客户原始信息内容
+// @Description 新增客户原始信息内容
+// @Param	body	body	business.device.DeviceChannels	"客户原始信息内容"
+// @Success	200	{object} controllers.Request
+// @router /customerlistadd [post]
+func (this *CustomerController) Customerlistadd() {
+	var testlistentity customer2.Customer
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &testlistentity)
+	testlistentity.CreateBy = this.User.Realname
+	testlistentity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+	testlistentity.AuthCode = utils.GetGuid()
+	svc := customer2.GetCustomerService(utils.DBE)
+	_, err := svc.InsertEntityBytbl(this.User.AccCode+CustomerName, &testlistentity)
+	var errinfo ErrorInfo
+	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()
+	}
+}
+
+// @Title 获取编辑时的客户原始信息内容
+// @Description 获取编辑时的客户原始信息内容
+// @Success 200 {object} business.device.DeviceChannels
+// @router /getcustomerlist/:id [get]
+func (this *CustomerController) Getcustomerlist() {
+	id := this.Ctx.Input.Param(":id")
+	var model customer2.Customer
+	svc := customer2.GetCustomerService(utils.DBE)
+	svc.GetEntityByIdBytbl(this.User.AccCode+CustomerName, id, &model) //修改时获取列表
+	var datainfo DataInfo
+	datainfo.Items = model
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 编辑试管信息
+// @Description 编辑试管信息
+// @Param	id	path	string	true		"需要修改的试管信息"
+// @Param	body	body	business.device.DeviceChannels	"试管信息"
+// @Success	200	{object} controllers.Request
+// @router /customerlistedit/:id [put]
+func (this *CustomerController) Customerlistedit() {
+	id := this.Ctx.Input.Param(":id")
+	var errinfo ErrorInfo
+	if id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	var model customer2.Customer
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &model)
+	var entityempty customer2.Customer
+	model.ModifiedBy = this.User.Realname
+	model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
+	svc := customer2.GetCustomerService(utils.DBE)
+
+	opdesc := "检验-" + model.Person
+	var cols []string = []string{"CustomerName", "Person", "Telephone", "Mailbox", "Address", "AuthCode", "CustomerName", "CustomerCode", "Established", "EmployeesNum", "EnterpriseType", "ZipCode", "FaxTelephone", "Website", "Representative", "MainBusiness", "ViceBusiness", "ModifiedBy", "ModifiedUserId"}
+	err := svc.UpdateOperationAndWriteLogBytbl(this.User.AccCode+CustomerName, BaseOperationLogName, id, &model, &entityempty, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "客户管理")
+	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()
+	}
+}
+
+// @Title 删除单条信息
+// @Description
+// @Success 200 {object} ErrorInfo
+// @Failure 403 :id 为空
+// @router /customerlistdelete/:Id [delete]
+func (this *CustomerController) Customerlistdelete() {
+	Id := this.Ctx.Input.Param(":Id")
+	var errinfo ErrorInfo
+	if Id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	where := " Id= " + Id
+	svc := customer2.GetCustomerService(utils.DBE)
+	err := svc.DeleteEntityBytbl(this.User.AccCode+CustomerName, where)
+	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()
+	}
+}
+
+// @Title 判断合同是否存在
+// @Description get user by token
+// @Success 200 {object} models.Userblood
+// @router /contractNoorlist [get]
+func (this *CustomerController) ContractNoorlist() {
+	ContractNo := this.GetString("ContractNo")
+	svc := customer2.GetCustomerService(utils.DBE)
+	where := " ContractNo= '" + ContractNo + "'"
+	total := svc.GetContractNo(this.User.AccCode+CellsContractName, where)
+
+	var datainfo DataInfo
+	datainfo.Items = total
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 保存附件
+// @Description 保存附件
+// @Success 200 {object}
+// @router /savesampleattach [put]
+func (this *CustomerController) SaveSampleAttach() {
+	// 获得前端传输的model
+	var jsonblob = this.Ctx.Input.RequestBody
+	var upmodel contractFormmodel
+	json.Unmarshal(jsonblob, &upmodel)
+	var errinfo ErrorInfo
+	if len(upmodel.AttachmodelList) == 0 {
+		errinfo.Message = "上传失败!无附件信息"
+		errinfo.Code = -3
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	//---附件---
+	var attachmodel customer2.CellsContractAttachment
+	attachmodel.CreateBy = this.User.Realname
+	attachmodel.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+	attachmodel.PId = upmodel.PId
+	svc := customer2.GetCustomerService(utils.DBE)
+	var err error
+	for _, val := range upmodel.AttachmodelList {
+
+		attachmodel.FileId = val.FileId
+		attachmodel.FileName = val.FileName
+		attachmodel.FileSize = val.FileSize
+		attachmodel.Host = val.Host
+		attachmodel.UploadDesc = val.UploadDesc
+		_, err = svc.InsertEntityBytbl(this.User.AccCode+CellsContractAttachmentName, &attachmodel)
+	}
+	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()
+	}
+}
+
+// @Title 质量管理根据id信息查询附件
+// @Description get user by token
+// @Success 200 {object} models.Userblood
+// @router /getcontractAttachment [get]
+func (this *CustomerController) GetcontractAttachment() {
+	PId := this.GetString("PId")
+	svc := customer2.GetCustomerService(utils.DBE)
+	where := " PId= '" + PId + "'"
+	total := svc.GetCustomerAttachment(this.User.AccCode+CellsContractAttachmentName, where)
+	var datainfo DataInfo
+	datainfo.Items = total
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title  根据id删除合同管理附件
+// @Description
+// @Success 200 {object} ErrorInfo
+// @Failure 403 :id 为空
+// @router /contractAttachmentdeletearrt/:Id [delete]
+func (this *CustomerController) ContractAttachmentdeletearrt() {
+	Id := this.Ctx.Input.Param(":Id")
+	var errinfo ErrorInfo
+	if Id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	where := " PId= " + Id
+	svc := customer2.GetCustomerService(utils.DBE)
+
+	err := svc.DeleteEntityBytbl(this.User.AccCode+CellsContractAttachmentName, where)
+
+	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()
+	}
+}
+
+// @Title 更改用户授权码
+// @Description 更改用户授权码
+// @Param	body	body	business.device.DeviceChannels	"更改用户授权码"
+// @Success	200	{object} controllers.Request
+// @router /authCodeedit [get]
+func (this *CustomerController) GetauthCode() {
+	var testlistentity customer2.Customer
+	var jsonblob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonblob, &testlistentity)
+	testlistentity.AuthCode = utils.GetGuid()
+	var datainfo DataInfo
+	datainfo.Items = testlistentity.AuthCode
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+
+}

+ 169 - 0
src/dashoo.cn/backend/api/routers/router.go

@@ -5,6 +5,7 @@ package routers
 
 import (
 	"dashoo.cn/backend/api/controllers"
+	"dashoo.cn/backend/api/controllers/lims"
 	"dashoo.cn/backend/api/controllers/casbin"
 	"dashoo.cn/backend/api/controllers/document"
 	"dashoo.cn/backend/api/controllers/equipment"
@@ -244,6 +245,174 @@ func init() {
 				&controllers.PermissionsController{},
 			),
 		),
+		//lims首页
+		beego.NSNamespace("/limsindex",
+			beego.NSInclude(
+				&lims.LimsIndexController{},
+			),
+		),
+		//lims客户原始信息内容
+		beego.NSNamespace("/customer",
+			beego.NSInclude(
+				&lims.CustomerController{},
+			),
+		),
+		//lims任务委托
+		beego.NSNamespace("/limsentrust",
+			beego.NSInclude(
+				&lims.LimsEnturstController{},
+			),
+		),
+		//lims检测项目
+		beego.NSNamespace("/testtype",
+			beego.NSInclude(
+				&lims.TestTypeController{},
+			),
+		),
+		//lims样品类型
+		beego.NSNamespace("/limsampletype",
+			beego.NSInclude(
+				&lims.LimSampleTypeController{},
+			),
+		),
+		//lims任务分配
+		beego.NSNamespace("/limsbalance",
+			beego.NSInclude(
+				&lims.LimsBalanceController{},
+			),
+		),
+		//lims模板
+		beego.NSNamespace("/doctemplate",
+			beego.NSInclude(
+				&lims.LimsDocTemplateController{},
+			),
+		),
+		//onlyoffice回调函数
+		beego.NSNamespace("/doctemplate_onlyoffice",
+			beego.NSInclude(
+				&lims.OnlyController{},
+			),
+		),
+		//lims数据录入
+		beego.NSNamespace("/limsdataentry",
+			beego.NSInclude(
+				&lims.LimsDataEntryController{},
+			),
+		),
+		//lims报告生成
+		beego.NSNamespace("/createreport",
+			beego.NSInclude(
+				&lims.CreateReportController{},
+			),
+		),
+
+		//lims样品交接
+		beego.NSNamespace("/limsdeliver",
+			beego.NSInclude(
+				&lims.LimsDeliverController{},
+			),
+		),
+		//lims样品制备
+		beego.NSNamespace("/limspreparation",
+			beego.NSInclude(
+				&lims.LimsPreparationController{},
+			),
+		),
+		//lims委托单对应的样品列表limsbalance
+		beego.NSNamespace("/limsentrustsample",
+			beego.NSInclude(
+				&lims.LimsEntrustSampleController{},
+			),
+		),
+		//lims图片上传
+		beego.NSNamespace("/limsupload",
+			beego.NSInclude(
+				&lims.LimsUploadController{},
+			),
+		),
+		//lims工程监督中心试油监督日报
+		beego.NSNamespace("/limsoiltestingdaily",
+			beego.NSInclude(
+				&lims.LimsOilTestingDailyController{},
+			),
+		),
+		//lims工程监督中心钻井工程监督日报
+		beego.NSNamespace("/limsdrillingdaily",
+			beego.NSInclude(
+				&lims.LimsDrillingDailyController{},
+			),
+		),
+		//lims特检站-漏电保护数据录入
+		beego.NSNamespace("/limsreportleakprotect",
+			beego.NSInclude(
+				&lims.LimsReportLeakProtectController{},
+			),
+		),
+		beego.NSNamespace("/limsreportairfoamgenerator",
+			beego.NSInclude(
+				&lims.LimsReportAirFoamGeneratorController{},
+			),
+		),
+		//电流表数据录入
+		beego.NSNamespace("/limsreportammeter",
+			beego.NSInclude(
+				&lims.LimsReportAmmeterController{},
+			),
+		),
+		//阻火器数据录入
+		beego.NSNamespace("/limsZuhq",
+			beego.NSInclude(
+				&lims.LimsReportZuhqController{},
+			),
+		),
+		//游梁式
+		beego.NSNamespace("/limsreportbeampumpingunits",
+			beego.NSInclude(
+				&lims.LimsReportBeamPumpingUnitsController{},
+			),
+		),
+		//液压安全阀数据录入
+		beego.NSNamespace("/limsreportyeyaqf",
+			beego.NSInclude(
+				&lims.LimsReportYeyaqfController{},
+			),
+		),
+		//无游梁式
+		beego.NSNamespace("/limsreportnobeampumpingunit",
+			beego.NSInclude(
+				&lims.LimsReportNoBeamPumpingUnitController{},
+			),
+		),
+		//电气接地
+		beego.NSNamespace("/limsreportelecground",
+			beego.NSInclude(
+				&lims.LimsReportElecGroundController{},
+			),
+		),
+		//防雷等电位
+		beego.NSNamespace("/limsreportequipotent",
+			beego.NSInclude(
+				&lims.LimsReportEquipotentController{},
+			),
+		),
+		//呼吸阀数据录入
+		beego.NSNamespace("/limsreporthuxf",
+			beego.NSInclude(
+				&lims.LimsReportHuxfController{},
+			),
+		),
+		//防雷
+		beego.NSNamespace("/limsreportlightprotect",
+			beego.NSInclude(
+				&lims.LimsReportLightProtectController{},
+			),
+		),
+		//检测地点及安装位置
+		beego.NSNamespace("/limscustomerposition",
+			beego.NSInclude(
+				&lims.LimsCustomerpositionController{},
+			),
+		),
 	)
 	beego.AddNamespace(ns)
 }