|
|
@@ -372,59 +372,39 @@ func (this *AnnualAuditController) GetSupplierForChange() {
|
|
|
// @router /adddirect [post]
|
|
|
func (this *AnnualAuditController) AddEntityDirect() {
|
|
|
var model annualaudit.OilAnnualAudit
|
|
|
- var errinfo ErrorDataInfo
|
|
|
+ var errInfo ErrorDataInfo
|
|
|
var jsonBlob = this.Ctx.Input.RequestBody
|
|
|
svc := annualaudit.GetOilAnnualAuditService(utils.DBE)
|
|
|
- firstAudit := this.GetString("firstAudit")
|
|
|
json.Unmarshal(jsonBlob, &model)
|
|
|
- supwhere := "a.Id = " + utils.ToStr(model.SupplierId) + " and b.SupplierTypeCode = '" + model.SupplierTypeName+ "' and b.Status = '8' "
|
|
|
- supsvc := supplier.GetOilSupplierService(utils.DBE)
|
|
|
+ supWhere := "a.Id = " + utils.ToStr(model.SupplierId) + " and b.SupplierTypeCode = '" + model.SupplierTypeName+ "' and b.Status = '8' "
|
|
|
+ supSvc := supplier.GetOilSupplierService(utils.DBE)
|
|
|
var list []supplier.OilSupplierView
|
|
|
- supsvc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, 1, 1, "a.Id", true, &list, supwhere)
|
|
|
- var suppliermodel supplier.OilSupplierView
|
|
|
- suppliermodel = list[0]
|
|
|
- model.AccessCardNo = suppliermodel.AccessCardNo
|
|
|
- model.RecUnitId = suppliermodel.RecUnitId
|
|
|
- model.CerId, _ = strconv.Atoi(suppliermodel.CertId)
|
|
|
- model.ApplyTime = suppliermodel.ApplyTime
|
|
|
+ supSvc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, 1, 1, "a.Id", true, &list, supWhere)
|
|
|
+ var supplierModel supplier.OilSupplierView
|
|
|
+ supplierModel = list[0]
|
|
|
+ model.AccessCardNo = supplierModel.AccessCardNo
|
|
|
+ model.RecUnitId = supplierModel.RecUnitId
|
|
|
+ model.CerId, _ = strconv.Atoi(supplierModel.CertId)
|
|
|
+ model.ApplyTime = supplierModel.ApplyTime
|
|
|
model.Status = "0"
|
|
|
model.Step = 1
|
|
|
- model.BackReason = suppliermodel.BackReason
|
|
|
+ model.BackReason = supplierModel.BackReason
|
|
|
model.CreateOn = time.Now()
|
|
|
model.CreateBy = this.User.Realname
|
|
|
model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
//添加一条年审记录
|
|
|
_, err := svc.InsertEntityBytbl(""+OilAnnualAuditName, &model)
|
|
|
- annualId := model.Id
|
|
|
- svcActiviti := workflow.GetActivitiService(utils.DBE)
|
|
|
- //启动工作流
|
|
|
- businessKey := utils.ToStr(annualId) + "-" + strconv.Itoa(model.AuditIndex)
|
|
|
- result := strconv.Itoa(this.User.IsCompanyUser)
|
|
|
- processInstanceId := svcActiviti.StartProcess2(workflow.OIL_AUDIT_APPLY, businessKey, this.User.Id, result, model.SupplierTypeName, model.SupplierName)
|
|
|
- var auditmodel annualaudit.OilAnnualAudit
|
|
|
- auditmodel.WorkflowId = processInstanceId
|
|
|
- auditmodel.FirstAudit, _ = strconv.Atoi(firstAudit)
|
|
|
- auditmodel.AuditIndex = model.AuditIndex
|
|
|
- auditmodel.BusinessKey = businessKey
|
|
|
- cols := []string{
|
|
|
- "Id",
|
|
|
- "WorkflowId",
|
|
|
- "FirstAudit",
|
|
|
- "AuditIndex",
|
|
|
- "BusinessKey",
|
|
|
- }
|
|
|
- _, err = svc.UpdateEntityByIdCols(annualId, auditmodel, cols)
|
|
|
if err == nil {
|
|
|
//新增
|
|
|
- errinfo.Message = "添加成功!"
|
|
|
- errinfo.Code = 0
|
|
|
- errinfo.Item = model.Id
|
|
|
- this.Data["json"] = &errinfo
|
|
|
+ errInfo.Message = "添加成功!"
|
|
|
+ errInfo.Code = 0
|
|
|
+ errInfo.Item = model.Id
|
|
|
+ this.Data["json"] = &errInfo
|
|
|
this.ServeJSON()
|
|
|
} else {
|
|
|
- errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
|
|
|
- errinfo.Code = -1
|
|
|
- this.Data["json"] = &errinfo
|
|
|
+ errInfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
|
|
|
+ errInfo.Code = -1
|
|
|
+ this.Data["json"] = &errInfo
|
|
|
this.ServeJSON()
|
|
|
}
|
|
|
}
|
|
|
@@ -582,59 +562,59 @@ func (this *AnnualAuditController) UpdateSuppEntity() {
|
|
|
// @router /add [post]
|
|
|
func (this *AnnualAuditController) AddEntity() {
|
|
|
var model annualaudit.OilAnnualAudit
|
|
|
- var errinfo ErrorDataInfo
|
|
|
+ var errInfo ErrorDataInfo
|
|
|
var jsonBlob = this.Ctx.Input.RequestBody
|
|
|
svc := annualaudit.GetOilAnnualAuditService(utils.DBE)
|
|
|
//firstAudit := this.GetString("firstAudit")
|
|
|
json.Unmarshal(jsonBlob, &model)
|
|
|
where := "SupplierId = " + utils.ToStr(model.SupplierId) + " and SupplierTypeName = " + model.SupplierTypeName + " and Status < 5"
|
|
|
- var auditentity []annualaudit.OilAnnualAudit
|
|
|
- svc.GetEntitysByWhere(""+OilAnnualAuditName, where, &auditentity)
|
|
|
- if len(auditentity) >= 1 {
|
|
|
- errinfo.Message = "今年已提交年审,请勿重复提交!"
|
|
|
- errinfo.Code = -1
|
|
|
- this.Data["json"] = &errinfo
|
|
|
+ var auditEntity []annualaudit.OilAnnualAudit
|
|
|
+ svc.GetEntitysByWhere(""+OilAnnualAuditName, where, &auditEntity)
|
|
|
+ if len(auditEntity) >= 1 {
|
|
|
+ errInfo.Message = "今年已提交年审,请勿重复提交!"
|
|
|
+ errInfo.Code = -1
|
|
|
+ this.Data["json"] = &errInfo
|
|
|
this.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- supwhere := "a.Id = " + utils.ToStr(model.SupplierId) + " and b.SupplierTypeCode = '" + model.SupplierTypeName+ "' and b.Status = '8' "
|
|
|
- supsvc := supplier.GetOilSupplierService(utils.DBE)
|
|
|
+ supWhere := "a.Id = " + utils.ToStr(model.SupplierId) + " and b.SupplierTypeCode = '" + model.SupplierTypeName+ "' and b.Status = '8' "
|
|
|
+ supSvc := supplier.GetOilSupplierService(utils.DBE)
|
|
|
var list []supplier.OilSupplierView
|
|
|
- total := supsvc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, 1, 1, "a.Id", true, &list, supwhere)
|
|
|
+ total := supSvc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, 1, 1, "a.Id", true, &list, supWhere)
|
|
|
if total == 0 {
|
|
|
- //errinfo.Message = "请先提交准入申请再提交年审!"
|
|
|
- errinfo.Message = "请先提交准入,准入申请通过后,才可申请年审!"
|
|
|
- errinfo.Code = -1
|
|
|
- this.Data["json"] = &errinfo
|
|
|
+ //errInfo.Message = "请先提交准入申请再提交年审!"
|
|
|
+ errInfo.Message = "请先提交准入,准入申请通过后,才可申请年审!"
|
|
|
+ errInfo.Code = -1
|
|
|
+ this.Data["json"] = &errInfo
|
|
|
this.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- var suppliermodel supplier.OilSupplierView
|
|
|
- suppliermodel = list[0]
|
|
|
- if suppliermodel.InFlag == "3" {
|
|
|
- errinfo.Message = "超过两年未年审,您已无法提交!"
|
|
|
- errinfo.Code = -1
|
|
|
- this.Data["json"] = &errinfo
|
|
|
+ var supplierModel supplier.OilSupplierView
|
|
|
+ supplierModel = list[0]
|
|
|
+ if supplierModel.InFlag == "3" {
|
|
|
+ errInfo.Message = "超过两年未年审,您已无法提交!"
|
|
|
+ errInfo.Code = -1
|
|
|
+ this.Data["json"] = &errInfo
|
|
|
this.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- aplytime := suppliermodel.ApplyTime
|
|
|
- subtime := this.getTimeSub(aplytime, time.Now())
|
|
|
- lefttime := subtime - 3
|
|
|
- if subtime > 3 {
|
|
|
- errinfo.Message = "还不到年审时间!请" + utils.ToStr(lefttime) + "个月后再来申请"
|
|
|
- errinfo.Code = -3
|
|
|
- this.Data["json"] = &errinfo
|
|
|
+ applyTime := supplierModel.ApplyTime
|
|
|
+ subTime := this.getTimeSub(applyTime, time.Now())
|
|
|
+ leftTime := subTime - 3
|
|
|
+ if subTime > 3 {
|
|
|
+ errInfo.Message = "还不到年审时间!请" + utils.ToStr(leftTime) + "个月后再来申请"
|
|
|
+ errInfo.Code = -3
|
|
|
+ this.Data["json"] = &errInfo
|
|
|
this.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
- model.AccessCardNo = suppliermodel.AccessCardNo
|
|
|
- model.RecUnitId = suppliermodel.RecUnitId
|
|
|
- model.CerId, _ = strconv.Atoi(suppliermodel.CertId)
|
|
|
- model.ApplyTime = suppliermodel.ApplyTime
|
|
|
+ model.AccessCardNo = supplierModel.AccessCardNo
|
|
|
+ model.RecUnitId = supplierModel.RecUnitId
|
|
|
+ model.CerId, _ = strconv.Atoi(supplierModel.CertId)
|
|
|
+ model.ApplyTime = supplierModel.ApplyTime
|
|
|
model.Status = "0"
|
|
|
model.Step = 1
|
|
|
- model.BackReason = suppliermodel.BackReason
|
|
|
+ model.BackReason = supplierModel.BackReason
|
|
|
model.CreateOn = time.Now()
|
|
|
model.CreateBy = this.User.Realname
|
|
|
model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
|
|
|
@@ -642,15 +622,15 @@ func (this *AnnualAuditController) AddEntity() {
|
|
|
_, err := svc.InsertEntityBytbl(""+OilAnnualAuditName, &model)
|
|
|
if err == nil {
|
|
|
//新增
|
|
|
- errinfo.Message = "添加成功!"
|
|
|
- errinfo.Code = 0
|
|
|
- errinfo.Item = model.Id
|
|
|
- this.Data["json"] = &errinfo
|
|
|
+ errInfo.Message = "添加成功!"
|
|
|
+ errInfo.Code = 0
|
|
|
+ errInfo.Item = model.Id
|
|
|
+ this.Data["json"] = &errInfo
|
|
|
this.ServeJSON()
|
|
|
} else {
|
|
|
- errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
|
|
|
- errinfo.Code = -1
|
|
|
- this.Data["json"] = &errinfo
|
|
|
+ errInfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
|
|
|
+ errInfo.Code = -1
|
|
|
+ this.Data["json"] = &errInfo
|
|
|
this.ServeJSON()
|
|
|
}
|
|
|
//annualId := model.Id
|