|
|
@@ -4,8 +4,9 @@ import (
|
|
|
"dashoo.cn/backend/api/business/limscustomerposition"
|
|
|
"dashoo.cn/backend/api/business/organize"
|
|
|
"encoding/json"
|
|
|
+ "github.com/tealeg/xlsx"
|
|
|
"strconv"
|
|
|
-
|
|
|
+ "strings"
|
|
|
//"strings"
|
|
|
"time"
|
|
|
|
|
|
@@ -56,7 +57,7 @@ func (this *LimsCheckEquipmentListController) GetEntityList() {
|
|
|
TemplateTypeId := this.GetString("TemplateTypeId")
|
|
|
PositionAllTypeId := this.GetString("PositionAllTypeId")
|
|
|
QueryCheckDate := this.GetString("QueryCheckDate")
|
|
|
- statusValue:=this.GetString("statusValue")
|
|
|
+ statusValue := this.GetString("statusValue")
|
|
|
|
|
|
if Id != "" {
|
|
|
where = where + " and Id like '%" + Id + "%'"
|
|
|
@@ -118,12 +119,12 @@ func (this *LimsCheckEquipmentListController) GetEntityList() {
|
|
|
where = where + " and date_add(LastCheckDate, interval " + QueryCheckDate + " month) >= now()"
|
|
|
}
|
|
|
|
|
|
- if statusValue!=""{
|
|
|
- if statusValue=="-2"{
|
|
|
+ if statusValue != "" {
|
|
|
+ if statusValue == "-2" {
|
|
|
where = where + " and NextCheckDate < DATE_FORMAT(NOW(),'%Y-%m-%d') "
|
|
|
- }else if statusValue=="-1"{
|
|
|
+ } else if statusValue == "-1" {
|
|
|
where = where + " and NextCheckDate >= DATE_FORMAT(NOW(),'%Y-%m-%d') and NextCheckDate <= DATE_FORMAT(date_add(NOW(), interval 1 month),'%Y-%m-%d') "
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
where = where + " and NextCheckDate > DATE_FORMAT(date_add(NOW(), interval 1 month),'%Y-%m-%d') "
|
|
|
}
|
|
|
}
|
|
|
@@ -133,7 +134,7 @@ func (this *LimsCheckEquipmentListController) GetEntityList() {
|
|
|
positionSvc := limscustomerposition.GetLimsCustomerpositionService(utils.DBE)
|
|
|
if this.User.UintThirdId > 0 {
|
|
|
var entitys []limscustomerposition.LimsCustomerPosition
|
|
|
- entitys = positionSvc.GetPositionCheckList( this.User.AccCode + LimsCustomerpositionName, strconv.Itoa(this.User.UintThirdId) )
|
|
|
+ entitys = positionSvc.GetPositionCheckList(this.User.AccCode+LimsCustomerpositionName, strconv.Itoa(this.User.UintThirdId))
|
|
|
for _, value := range entitys {
|
|
|
strPositionList += strconv.Itoa(value.Id) + ","
|
|
|
}
|
|
|
@@ -147,7 +148,7 @@ func (this *LimsCheckEquipmentListController) GetEntityList() {
|
|
|
}
|
|
|
thrOrgList += "0"
|
|
|
var entitys []limscustomerposition.LimsCustomerPosition
|
|
|
- entitys = positionSvc.GetPositionCheckList( this.User.AccCode + LimsCustomerpositionName, thrOrgList )
|
|
|
+ entitys = positionSvc.GetPositionCheckList(this.User.AccCode+LimsCustomerpositionName, thrOrgList)
|
|
|
for _, value := range entitys {
|
|
|
strPositionList += strconv.Itoa(value.Id) + ","
|
|
|
}
|
|
|
@@ -230,14 +231,14 @@ func (this *LimsCheckEquipmentListController) AddEntity() {
|
|
|
model.Departmentname = organizeEntity.Fullname
|
|
|
|
|
|
//计算下次检测日期
|
|
|
- if model.CycleUnit=="天"{
|
|
|
- model.NextCheckDate=model.LastCheckDate.AddDate(0,0,int(model.Cycle))
|
|
|
- }else if model.CycleUnit=="月"{
|
|
|
- model.NextCheckDate=model.LastCheckDate.AddDate(0,int(model.Cycle),0)
|
|
|
- }else if model.CycleUnit=="年"{
|
|
|
- model.NextCheckDate=model.LastCheckDate.AddDate(int(model.Cycle),0,0)
|
|
|
- }else{
|
|
|
- model.NextCheckDate=model.LastCheckDate
|
|
|
+ if model.CycleUnit == "天" {
|
|
|
+ model.NextCheckDate = model.LastCheckDate.AddDate(0, 0, int(model.Cycle))
|
|
|
+ } else if model.CycleUnit == "月" {
|
|
|
+ model.NextCheckDate = model.LastCheckDate.AddDate(0, int(model.Cycle), 0)
|
|
|
+ } else if model.CycleUnit == "年" {
|
|
|
+ model.NextCheckDate = model.LastCheckDate.AddDate(int(model.Cycle), 0, 0)
|
|
|
+ } else {
|
|
|
+ model.NextCheckDate = model.LastCheckDate
|
|
|
}
|
|
|
_, err := svc.InsertEntityBytbl(this.User.AccCode+LimsCheckEquipmentListName, &model)
|
|
|
|
|
|
@@ -283,14 +284,14 @@ func (this *LimsCheckEquipmentListController) UpdateEntity() {
|
|
|
model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
|
|
|
//计算下次检测日期
|
|
|
- if model.CycleUnit=="天"{
|
|
|
- model.NextCheckDate=model.LastCheckDate.AddDate(0,0,int(model.Cycle))
|
|
|
- }else if model.CycleUnit=="月"{
|
|
|
- model.NextCheckDate=model.LastCheckDate.AddDate(0,int(model.Cycle),0)
|
|
|
- }else if model.CycleUnit=="年"{
|
|
|
- model.NextCheckDate=model.LastCheckDate.AddDate(int(model.Cycle),0,0)
|
|
|
- }else{
|
|
|
- model.NextCheckDate=model.LastCheckDate
|
|
|
+ if model.CycleUnit == "天" {
|
|
|
+ model.NextCheckDate = model.LastCheckDate.AddDate(0, 0, int(model.Cycle))
|
|
|
+ } else if model.CycleUnit == "月" {
|
|
|
+ model.NextCheckDate = model.LastCheckDate.AddDate(0, int(model.Cycle), 0)
|
|
|
+ } else if model.CycleUnit == "年" {
|
|
|
+ model.NextCheckDate = model.LastCheckDate.AddDate(int(model.Cycle), 0, 0)
|
|
|
+ } else {
|
|
|
+ model.NextCheckDate = model.LastCheckDate
|
|
|
}
|
|
|
|
|
|
cols := []string{
|
|
|
@@ -491,7 +492,7 @@ func (this *LimsCheckEquipmentListController) GetEntityWarningList() {
|
|
|
positionSvc := limscustomerposition.GetLimsCustomerpositionService(utils.DBE)
|
|
|
if this.User.UintThirdId > 0 {
|
|
|
var entitys []limscustomerposition.LimsCustomerPosition
|
|
|
- entitys = positionSvc.GetPositionCheckList( this.User.AccCode + LimsCustomerpositionName, strconv.Itoa(this.User.UintThirdId) )
|
|
|
+ entitys = positionSvc.GetPositionCheckList(this.User.AccCode+LimsCustomerpositionName, strconv.Itoa(this.User.UintThirdId))
|
|
|
for _, value := range entitys {
|
|
|
strPositionList += strconv.Itoa(value.Id) + ","
|
|
|
}
|
|
|
@@ -505,7 +506,7 @@ func (this *LimsCheckEquipmentListController) GetEntityWarningList() {
|
|
|
}
|
|
|
thrOrgList += "0"
|
|
|
var entitys []limscustomerposition.LimsCustomerPosition
|
|
|
- entitys = positionSvc.GetPositionCheckList( this.User.AccCode + LimsCustomerpositionName, thrOrgList )
|
|
|
+ entitys = positionSvc.GetPositionCheckList(this.User.AccCode+LimsCustomerpositionName, thrOrgList)
|
|
|
for _, value := range entitys {
|
|
|
strPositionList += strconv.Itoa(value.Id) + ","
|
|
|
}
|
|
|
@@ -520,8 +521,8 @@ func (this *LimsCheckEquipmentListController) GetEntityWarningList() {
|
|
|
var list []limscheckequipmentlist.LimsCheckEquipmentList
|
|
|
|
|
|
where = where + " and CASE WHEN CycleUnit ='年' THEN DATE_ADD(LastCheckDate , INTERVAL Cycle YEAR) < NOW() || DATE_ADD(LastCheckDate , INTERVAL Cycle YEAR) < DATE_ADD(NOW(),INTERVAL 1 MONTH) " +
|
|
|
- "WHEN CycleUnit ='月' THEN DATE_ADD(LastCheckDate , INTERVAL Cycle MONTH) < NOW() || DATE_ADD(LastCheckDate , INTERVAL Cycle MONTH) < DATE_ADD(NOW(),INTERVAL 1 MONTH)" +
|
|
|
- "WHEN CycleUnit ='天' THEN DATE_ADD(LastCheckDate , INTERVAL Cycle DAY) < NOW() || DATE_ADD(LastCheckDate , INTERVAL Cycle DAY) < DATE_ADD(NOW(),INTERVAL 1 MONTH) ELSE FALSE END"
|
|
|
+ "WHEN CycleUnit ='月' THEN DATE_ADD(LastCheckDate , INTERVAL Cycle MONTH) < NOW() || DATE_ADD(LastCheckDate , INTERVAL Cycle MONTH) < DATE_ADD(NOW(),INTERVAL 1 MONTH)" +
|
|
|
+ "WHEN CycleUnit ='天' THEN DATE_ADD(LastCheckDate , INTERVAL Cycle DAY) < NOW() || DATE_ADD(LastCheckDate , INTERVAL Cycle DAY) < DATE_ADD(NOW(),INTERVAL 1 MONTH) ELSE FALSE END"
|
|
|
total := svc.GetPagingEntitiesWithOrderBytbl(this.User.AccCode, page.CurrentPage, page.Size, orderby, asc, &list, where)
|
|
|
var datainfo DataInfo
|
|
|
datainfo.Items = list
|
|
|
@@ -530,4 +531,88 @@ func (this *LimsCheckEquipmentListController) GetEntityWarningList() {
|
|
|
datainfo.ItemsPerPage = page.Size
|
|
|
this.Data["json"] = &datainfo
|
|
|
this.ServeJSON()
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+// @Title get 导出ex
|
|
|
+// @Description get SampleType by token
|
|
|
+// @Success 200 {object}
|
|
|
+// @router /exportexcelall [get]
|
|
|
+func (this *LimsCheckEquipmentListController) ExportExcelAll() {
|
|
|
+ //获取分页信息
|
|
|
+ //page := this.GetPageInfoForm()
|
|
|
+ where := " 1=1 "
|
|
|
+
|
|
|
+ PositionAllTypeId := this.GetString("PositionAllTypeId")
|
|
|
+ if PositionAllTypeId != "" {
|
|
|
+ where = where + " and (PositionCheckId = '" + PositionAllTypeId + "' or PositionID = '" + PositionAllTypeId + "')"
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ strPositionList := ""
|
|
|
+ orgSvc := organize.GetOrganizeService(utils.DBE)
|
|
|
+ positionSvc := limscustomerposition.GetLimsCustomerpositionService(utils.DBE)
|
|
|
+ if this.User.UintThirdId > 0 {
|
|
|
+ var entitys []limscustomerposition.LimsCustomerPosition
|
|
|
+ entitys = positionSvc.GetPositionCheckList(this.User.AccCode+LimsCustomerpositionName, strconv.Itoa(this.User.UintThirdId))
|
|
|
+ for _, value := range entitys {
|
|
|
+ strPositionList += strconv.Itoa(value.Id) + ","
|
|
|
+ }
|
|
|
+ strPositionList += "0"
|
|
|
+ } else if this.User.UnitId > 0 {
|
|
|
+ orgEntityList := orgSvc.GetAllThirdChildByTopId(strconv.Itoa(this.User.UnitId), this.User.Id)
|
|
|
+ //取消3级单位ID列表
|
|
|
+ thrOrgList := ""
|
|
|
+ for _, orgValue := range orgEntityList {
|
|
|
+ thrOrgList += strconv.Itoa(orgValue.Id) + ","
|
|
|
+ }
|
|
|
+ thrOrgList += "0"
|
|
|
+ var entitys []limscustomerposition.LimsCustomerPosition
|
|
|
+ entitys = positionSvc.GetPositionCheckList(this.User.AccCode+LimsCustomerpositionName, thrOrgList)
|
|
|
+ for _, value := range entitys {
|
|
|
+ strPositionList += strconv.Itoa(value.Id) + ","
|
|
|
+ }
|
|
|
+ strPositionList += "0"
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(strPositionList) > 0 {
|
|
|
+ where = where + " and PositionCheckId in ('" + strPositionList + "')"
|
|
|
+ }
|
|
|
+
|
|
|
+ svc := limscheckequipmentlist.GetLimsCheckEquipmentListService(utils.DBE)
|
|
|
+ var list []limscheckequipmentlist.LimsCheckEquipmentList
|
|
|
+ svc.GetEntitysByWhere(this.User.AccCode+LimsCheckEquipmentListName, where, &list)
|
|
|
+
|
|
|
+ //var title []string
|
|
|
+ filetitle := "设备台账"
|
|
|
+ //自定义显示列
|
|
|
+ showcolumnarr := "设备类型,编号,规格型号,制造厂家,检测地点,安装位置,所属单位,上次检测日期,检测周期,下次检测日期"
|
|
|
+ //titlestring := "TemplateTypeName,CustNo,Spec,Manufacturer,PositionCheck,Position,LastCheckDate,Cycle"
|
|
|
+ //title = strings.Split(titlestring, ",")
|
|
|
+ f := xlsx.NewFile()
|
|
|
+ sheet, _ := f.AddSheet(filetitle)
|
|
|
+ //rowhead := sheet.AddRow()
|
|
|
+ //rowhead.WriteSlice(&title, -1)
|
|
|
+ cellname := strings.Split(showcolumnarr, ",")
|
|
|
+ row := sheet.AddRow()
|
|
|
+ row.WriteSlice(&cellname, -1)
|
|
|
+
|
|
|
+ for _, v := range list {
|
|
|
+ datastring := v.TemplateTypeName + "," + v.CustNo + "," + v.Spec + "," + v.Manufacturer + "," + v.PositionCheck + "," + v.Position + "," + v.Departmentname + "," + utils.ToStr(v.LastCheckDate.Format("2006-01-02")) + "," + strconv.FormatFloat(float64(v.Cycle), 'f', 0, 64) + v.CycleUnit + "," + utils.ToStr(v.NextCheckDate.Format("2006-01-02"))
|
|
|
+
|
|
|
+ cellname := strings.Split(datastring, ",")
|
|
|
+ row := sheet.AddRow()
|
|
|
+ row.WriteSlice(&cellname, -1)
|
|
|
+ }
|
|
|
+
|
|
|
+ for c, cl := 0, len(sheet.Cols); c < cl; c++ {
|
|
|
+ sheet.Cols[c].Width = 20
|
|
|
+ }
|
|
|
+ //this.SaveSampleXlsx(filetitle, title, showcolumnarr, list, f)
|
|
|
+
|
|
|
+ dir := "static/file/excel/report/" + this.GetAccode()
|
|
|
+ SaveDirectory(dir)
|
|
|
+ path := dir + "/" + utils.TimeFormat(time.Now(), "200612") + filetitle + ".xlsx"
|
|
|
+ f.Save(path)
|
|
|
+ this.Data["json"] = this.Ctx.Request.Host + "/" + path
|
|
|
+ this.ServeJSON()
|
|
|
+}
|