|
|
@@ -291,6 +291,68 @@ func (this *AnnualAuditController) GetEntity() {
|
|
|
this.ServeJSON()
|
|
|
}
|
|
|
|
|
|
+// @Title 添加
|
|
|
+// @Description 直接新增年审
|
|
|
+// @Success 200 {object} controllers.Request
|
|
|
+// @router /adddirect [post]
|
|
|
+func (this *AnnualAuditController) AddEntityDirect() {
|
|
|
+ var model annualaudit.OilAnnualAudit
|
|
|
+ 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)
|
|
|
+ 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
|
|
|
+ model.Status = "0"
|
|
|
+ model.Step = 1
|
|
|
+ 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)
|
|
|
+ processInstanceId := svcActiviti.StartProcess(workflow.OIL_AUDIT_APPLY, businessKey, this.User.Id)
|
|
|
+ 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
|
|
|
+ this.ServeJSON()
|
|
|
+ } else {
|
|
|
+ errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
|
|
|
+ errinfo.Code = -1
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// @Title 添加
|
|
|
// @Description 新增年审
|
|
|
// @Success 200 {object} controllers.Request
|
|
|
@@ -333,17 +395,16 @@ func (this *AnnualAuditController) AddEntity() {
|
|
|
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 = -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
|
|
|
+ this.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
model.AccessCardNo = suppliermodel.AccessCardNo
|
|
|
model.RecUnitId = suppliermodel.RecUnitId
|
|
|
model.CerId, _ = strconv.Atoi(suppliermodel.CertId)
|