public ActionResult SubmitForm(string keyValue, SafetyCollectEntity entity) { Operator curUser = ERCHTMS.Code.OperatorProvider.Provider.Current(); string state = string.Empty; string flowid = string.Empty; string moduleName = "竣工安全验收"; // <param name="state">是否有权限审核 1:能审核 0 :不能审核</param> ManyPowerCheckEntity mpcEntity = dailyexaminebll.CheckAuditPower(curUser, out state, moduleName, curUser.DeptId); //新增时会根据角色自动审核 List <ManyPowerCheckEntity> powerList = new ManyPowerCheckBLL().GetListBySerialNum(curUser.OrganizeCode, "竣工安全验收"); List <ManyPowerCheckEntity> checkPower = new List <ManyPowerCheckEntity>(); var outsouringengineer = outsouringengineerbll.GetEntity(entity.EngineerId); //先查出执行部门编码 for (int i = 0; i < powerList.Count; i++) { if (powerList[i].CHECKDEPTCODE == "-1" || powerList[i].CHECKDEPTID == "-1") { var createdeptentity = new DepartmentBLL().GetEntity(outsouringengineer.ENGINEERLETDEPTID); var createdeptentity2 = new DepartmentEntity(); while (createdeptentity.Nature == "专业" || createdeptentity.Nature == "班组") { createdeptentity2 = new DepartmentBLL().GetEntity(createdeptentity.ParentId); if (createdeptentity2.Nature != "专业" || createdeptentity2.Nature != "班组") { break; } } powerList[i].CHECKDEPTCODE = createdeptentity.DeptCode; powerList[i].CHECKDEPTID = createdeptentity.DepartmentId; if (createdeptentity2 != null) { powerList[i].CHECKDEPTCODE = createdeptentity.DeptCode + "," + createdeptentity2.DeptCode; powerList[i].CHECKDEPTID = createdeptentity.DepartmentId + "," + createdeptentity2.DepartmentId; } } //创建部门 if (powerList[i].CHECKDEPTCODE == "-3" || powerList[i].CHECKDEPTID == "-3") { var createdeptentity = new DepartmentBLL().GetEntityByCode(curUser.DeptCode); while (createdeptentity.Nature == "专业" || createdeptentity.Nature == "班组") { createdeptentity = new DepartmentBLL().GetEntity(createdeptentity.ParentId); } powerList[i].CHECKDEPTCODE = createdeptentity.DeptCode; powerList[i].CHECKDEPTID = createdeptentity.DepartmentId; } } //登录人是否有审核权限--有审核权限直接审核通过 for (int i = 0; i < powerList.Count; i++) { if (powerList[i].CHECKDEPTID.Contains(curUser.DeptId)) { var rolelist = curUser.RoleName.Split(','); for (int j = 0; j < rolelist.Length; j++) { if (powerList[i].CHECKROLENAME.Contains(rolelist[j])) { checkPower.Add(powerList[i]); break; } } } } if (checkPower.Count > 0) { state = "1"; ManyPowerCheckEntity check = checkPower.Last();//当前 for (int i = 0; i < powerList.Count; i++) { if (check.ID == powerList[i].ID) { flowid = powerList[i].ID; } } } else { state = "0"; mpcEntity = powerList.First(); } if (null != mpcEntity) { entity.FLOWDEPT = mpcEntity.CHECKDEPTID; entity.FLOWDEPTNAME = mpcEntity.CHECKDEPTNAME; entity.FLOWROLE = mpcEntity.CHECKROLEID; entity.FLOWROLENAME = mpcEntity.CHECKROLENAME; entity.ISSAVED = "1"; //标记已经从登记到审核阶段 entity.ISOVER = "0"; //流程未完成,1表示完成 //entity.FLOWNAME = entity.FLOWDEPTNAME + "审核中"; if (mpcEntity.CHECKDEPTNAME == "执行部门" && mpcEntity.CHECKROLENAME == "负责人") { entity.FLOWNAME = outsouringengineer.ENGINEERLETDEPT + "审批中"; } else { entity.FLOWNAME = mpcEntity.CHECKDEPTNAME + "审批中"; } entity.FlowId = mpcEntity.ID; } else //为空则表示已经完成流程 { entity.FLOWDEPT = ""; entity.FLOWDEPTNAME = ""; entity.FLOWROLE = ""; entity.FLOWROLENAME = ""; entity.ISSAVED = "1"; //标记已经从登记到审核阶段 entity.ISOVER = "1"; //流程未完成,1表示完成 entity.FLOWNAME = ""; entity.FlowId = flowid; } SafetyCollectbll.SaveForm(keyValue, entity); //添加审核记录 if (state == "1") { //审核信息表 AptitudeinvestigateauditEntity aidEntity = new AptitudeinvestigateauditEntity(); aidEntity.AUDITRESULT = "0"; //通过 aidEntity.AUDITTIME = DateTime.Now; aidEntity.AUDITPEOPLE = curUser.UserName; aidEntity.AUDITPEOPLEID = curUser.UserId; aidEntity.APTITUDEID = entity.ID; //关联的业务ID aidEntity.AUDITOPINION = ""; //审核意见 aidEntity.AUDITSIGNIMG = curUser.SignImg; if (null != mpcEntity) { aidEntity.REMARK = (powerList[0].AUTOID.Value - 1).ToString(); //备注 存流程的顺序号 //aidEntity.FlowId = mpcEntity.ID; } else { aidEntity.REMARK = "7"; } aidEntity.FlowId = flowid; aidEntity.AUDITDEPTID = curUser.DeptId; aidEntity.AUDITDEPT = curUser.DeptName; aptitudeinvestigateauditbll.SaveForm(aidEntity.ID, aidEntity); } return(Success("操作成功!")); }
public ActionResult SubmitForm(string keyValue, DangerChemicalsReceiveEntity entity) { var clEntity = DangerChemicalsBll.GetEntity(entity.MainId); if (clEntity.IsScene == "现场存放") { try { if (entity.ReceiveUnit == clEntity.Unit) { if (Convert.ToDecimal(entity.ReceiveNum) <= Convert.ToDecimal(clEntity.Inventory)) { clEntity.Inventory = (Convert.ToDecimal(clEntity.Inventory) - Convert.ToDecimal(entity.ReceiveNum)).ToString(); clEntity.Amount = (Convert.ToDecimal(clEntity.Inventory) / Convert.ToDecimal(clEntity.Specification)).ToString("#0.00"); DangerChemicalsBll.SaveForm(entity.MainId, clEntity); entity.PracticalNum = Convert.ToDecimal(entity.ReceiveNum).ToString(); //实际发放库存量 } else { return(Error("操作失败,该危化品实际库存已变化,库存为:" + clEntity.Inventory + " " + clEntity.Unit + "!")); } } if (entity.ReceiveUnit == clEntity.AmountUnit) { if (Convert.ToDecimal(entity.ReceiveNum) <= Convert.ToDecimal(clEntity.Amount)) { clEntity.Inventory = (Convert.ToDecimal(clEntity.Inventory) - (Convert.ToDecimal(entity.ReceiveNum) * Convert.ToDecimal(clEntity.Specification))).ToString(); clEntity.Amount = (Convert.ToDecimal(clEntity.Inventory) / Convert.ToDecimal(clEntity.Specification)).ToString("#0.00"); DangerChemicalsBll.SaveForm(entity.MainId, clEntity); entity.PracticalNum = (Convert.ToDecimal(entity.ReceiveNum) * Convert.ToDecimal(clEntity.Specification)).ToString(); //实际发放库存量 } else { return(Error("操作失败,该危化品实际库存已变化,库存为:" + clEntity.Inventory + " " + clEntity.Unit + "!")); } } } catch { } entity.FLOWDEPT = ""; entity.FLOWDEPTNAME = ""; entity.FLOWROLE = ""; entity.FLOWROLENAME = ""; entity.ISSAVED = "1"; //标记已经从登记到审核阶段 entity.ISOVER = "1"; //流程未完成,1表示完成 entity.GrantState = 3; //2表示发放中 entity.FLOWNAME = ""; entity.FlowId = ""; entity.GrantDate = DateTime.Now; DangerChemicalsReceiveBll.SaveForm(keyValue, entity); } else { Operator curUser = ERCHTMS.Code.OperatorProvider.Provider.Current(); string state = string.Empty; string flowid = string.Empty; string moduleName = "危化品领用"; // <param name="state">是否有权限审核 1:能审核 0 :不能审核</param> ManyPowerCheckEntity mpcEntity = dailyexaminebll.CheckAuditPower(curUser, out state, moduleName, curUser.DeptId); //新增时会根据角色自动审核 List <ManyPowerCheckEntity> powerList = new ManyPowerCheckBLL().GetListBySerialNum(curUser.OrganizeCode, "危化品领用"); List <ManyPowerCheckEntity> checkPower = new List <ManyPowerCheckEntity>(); //先查出执行部门编码 for (int i = 0; i < powerList.Count; i++) { if (powerList[i].CHECKDEPTCODE == "-1" || powerList[i].CHECKDEPTID == "-1") { var createdeptentity = new DepartmentBLL().GetEntityByCode(curUser.DeptCode); while (createdeptentity.Nature == "专业" || createdeptentity.Nature == "班组") { createdeptentity = new DepartmentBLL().GetEntity(createdeptentity.ParentId); } powerList[i].CHECKDEPTCODE = createdeptentity.DeptCode; powerList[i].CHECKDEPTID = createdeptentity.DepartmentId; } //创建部门 if (powerList[i].CHECKDEPTCODE == "-3" || powerList[i].CHECKDEPTID == "-3") { var createdeptentity = new DepartmentBLL().GetEntityByCode(curUser.DeptCode); while (createdeptentity.Nature == "专业" || createdeptentity.Nature == "班组") { createdeptentity = new DepartmentBLL().GetEntity(createdeptentity.ParentId); } powerList[i].CHECKDEPTCODE = createdeptentity.DeptCode; powerList[i].CHECKDEPTID = createdeptentity.DepartmentId; } } //登录人是否有审核权限--有审核权限直接审核通过 for (int i = 0; i < powerList.Count; i++) { if (powerList[i].CHECKDEPTID == curUser.DeptId) { var rolelist = curUser.RoleName.Split(','); for (int j = 0; j < rolelist.Length; j++) { if (powerList[i].CHECKROLENAME.Contains(rolelist[j])) { checkPower.Add(powerList[i]); break; } } } } if (checkPower.Count > 0) { ManyPowerCheckEntity check = checkPower.Last();//当前 for (int i = 0; i < powerList.Count; i++) { if (check.ID == powerList[i].ID) { flowid = powerList[i].ID; } } } else { if (powerList.Count > 0) { mpcEntity = powerList.First(); } } if (null != mpcEntity) { //保存三措两案记录 entity.FLOWDEPT = mpcEntity.CHECKDEPTID; entity.FLOWDEPTNAME = mpcEntity.CHECKDEPTNAME; entity.FLOWROLE = mpcEntity.CHECKROLEID; entity.FLOWROLENAME = mpcEntity.CHECKROLENAME; entity.ISSAVED = "1"; //标记已经从登记到审核阶段 entity.ISOVER = "0"; //流程未完成,1表示完成 entity.FLOWNAME = mpcEntity.CHECKDEPTNAME + "审核中"; entity.FlowId = mpcEntity.ID; } else //为空则表示已经完成流程 { entity.FLOWDEPT = ""; entity.FLOWDEPTNAME = ""; entity.FLOWROLE = ""; entity.FLOWROLENAME = ""; entity.ISSAVED = "1"; //标记已经从登记到审核阶段 entity.ISOVER = "1"; //流程未完成,1表示完成 entity.GrantState = 2; //2表示发放中 entity.FLOWNAME = ""; entity.FlowId = flowid; } DangerChemicalsReceiveBll.SaveForm(keyValue, entity); //添加审核记录 if (state == "1") { //审核信息表 AptitudeinvestigateauditEntity aidEntity = new AptitudeinvestigateauditEntity(); aidEntity.AUDITRESULT = "0"; //通过 aidEntity.AUDITTIME = DateTime.Now; aidEntity.AUDITPEOPLE = curUser.UserName; aidEntity.AUDITPEOPLEID = curUser.UserId; aidEntity.APTITUDEID = entity.ID; //关联的业务ID aidEntity.AUDITOPINION = ""; //审核意见 aidEntity.AUDITSIGNIMG = curUser.SignImg; if (null != mpcEntity) { aidEntity.REMARK = (powerList[0].AUTOID.Value - 1).ToString(); //备注 存流程的顺序号 //aidEntity.FlowId = mpcEntity.ID; } else { aidEntity.REMARK = "7"; } aidEntity.FlowId = flowid; aidEntity.AUDITDEPTID = curUser.DeptId; aidEntity.AUDITDEPT = curUser.DeptName; aptitudeinvestigateauditbll.SaveForm(aidEntity.ID, aidEntity); } } return(Success("操作成功!")); }