Commit 82eea33c authored by 廖旭伟's avatar 廖旭伟

部门考核、个人考核依据明细增加启停接口

parent 96b8a46f
package com.mortals.xhx.module.perform.service;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.perform.model.PerformDeptConfDetailEntity;
import com.mortals.xhx.module.perform.dao.PerformDeptConfDetailDao;
......@@ -13,4 +15,12 @@ import com.mortals.xhx.module.perform.dao.PerformDeptConfDetailDao;
public interface PerformDeptConfDetailService extends ICRUDService<PerformDeptConfDetailEntity,Long>{
PerformDeptConfDetailDao getDao();
/**
* 启用停用规则
* @param id
* @return
* @throws AppException
*/
int enable(Long id, Context context) throws AppException;
}
\ No newline at end of file
package com.mortals.xhx.module.perform.service;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.perform.model.PerformStaffConfDetailEntity;
import com.mortals.xhx.module.perform.dao.PerformStaffConfDetailDao;
......@@ -13,4 +15,12 @@ import com.mortals.xhx.module.perform.dao.PerformStaffConfDetailDao;
public interface PerformStaffConfDetailService extends ICRUDService<PerformStaffConfDetailEntity,Long>{
PerformStaffConfDetailDao getDao();
/**
* 启用停用规则
* @param id
* @return
* @throws AppException
*/
int enable(Long id, Context context) throws AppException;
}
\ No newline at end of file
package com.mortals.xhx.module.perform.service.impl;
import com.mortals.xhx.common.code.EnabledEnum;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
......@@ -7,6 +8,9 @@ import com.mortals.xhx.module.perform.dao.PerformDeptConfDetailDao;
import com.mortals.xhx.module.perform.model.PerformDeptConfDetailEntity;
import com.mortals.xhx.module.perform.service.PerformDeptConfDetailService;
import lombok.extern.slf4j.Slf4j;
import java.util.Date;
/**
* PerformDeptConfDetailService
* 部门考核内容详细信息 service实现
......@@ -17,5 +21,27 @@ import lombok.extern.slf4j.Slf4j;
@Service("performDeptConfDetailService")
@Slf4j
public class PerformDeptConfDetailServiceImpl extends AbstractCRUDServiceImpl<PerformDeptConfDetailDao, PerformDeptConfDetailEntity, Long> implements PerformDeptConfDetailService {
@Override
public int enable(Long id, Context context) throws AppException {
if(id == null){
throw new AppException("考核内容详细Id不能为空");
}
PerformDeptConfDetailEntity temp = this.get(id);
if(temp == null){
throw new AppException("考核内容详细Id不正确");
}
PerformDeptConfDetailEntity entity = new PerformDeptConfDetailEntity();
entity.setId(id);
if(temp.getEnable() == EnabledEnum.停止.getValue()){
entity.setEnable(EnabledEnum.启用.getValue());
}else {
entity.setEnable(EnabledEnum.停止.getValue());
}
if(context!=null && context.getUser()!=null){
entity.setUpdateTime(new Date());
entity.setUpdateUserId(context.getUser().getId());
}
return this.dao.update(entity);
}
}
\ No newline at end of file
......@@ -51,6 +51,15 @@ public class PerformDeptConfServiceImpl extends AbstractCRUDServiceImpl<PerformD
}
}
@Override
protected void updateBefore(PerformDeptConfEntity entity, Context context) throws AppException {
super.updateBefore(entity, context);
DeptEntity deptEntity = deptService.get(entity.getDeptId());
if (deptEntity != null) {
entity.setDeptName(deptEntity.getDeptName());
}
}
@Override
protected void saveBefore(PerformDeptConfEntity entity, Context context) throws AppException {
super.saveBefore(entity,context);
......
package com.mortals.xhx.module.perform.service.impl;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.common.code.EnabledEnum;
import com.mortals.xhx.module.perform.dao.PerformStaffConfDetailDao;
import com.mortals.xhx.module.perform.model.PerformStaffConfDetailEntity;
import com.mortals.xhx.module.perform.service.PerformStaffConfDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* PerformStaffConfDetailService
* 人员考核内容详细信息 service实现
......@@ -17,5 +22,27 @@ import lombok.extern.slf4j.Slf4j;
@Service("performStaffConfDetailService")
@Slf4j
public class PerformStaffConfDetailServiceImpl extends AbstractCRUDServiceImpl<PerformStaffConfDetailDao, PerformStaffConfDetailEntity, Long> implements PerformStaffConfDetailService {
@Override
public int enable(Long id, Context context) throws AppException {
if(id == null){
throw new AppException("考核内容详细Id不能为空");
}
PerformStaffConfDetailEntity temp = this.get(id);
if(temp == null){
throw new AppException("考核内容详细Id不正确");
}
PerformStaffConfDetailEntity entity = new PerformStaffConfDetailEntity();
entity.setId(id);
if(temp.getEnable() == EnabledEnum.停止.getValue()){
entity.setEnable(EnabledEnum.启用.getValue());
}else {
entity.setEnable(EnabledEnum.停止.getValue());
}
if(context!=null && context.getUser()!=null){
entity.setUpdateTime(new Date());
entity.setUpdateUserId(context.getUser().getId());
}
return this.dao.update(entity);
}
}
\ No newline at end of file
......@@ -92,6 +92,27 @@ public class PerformStaffConfServiceImpl extends AbstractCRUDServiceImpl<Perform
}
}
@Override
protected void updateBefore(PerformStaffConfEntity entity, Context context) throws AppException {
super.updateBefore(entity,context);
if(StringUtils.isNotEmpty(entity.getStaffIds())){
List<Long> staffIdList = StringUtils.converStr2Long(entity.getStaffIds());
StaffQuery staffQuery = new StaffQuery();
staffQuery.setIdList(staffIdList);
List<StaffEntity> staffEntityList = staffService.find(staffQuery);
if(CollectionUtils.isNotEmpty(staffEntityList)){
String names = "";
for (StaffEntity item:staffEntityList){
names+=item.getName()+",";
}
entity.setStaffNames(names.substring(0,names.length()-1));
entity.setStaffCount(staffEntityList.size());
}else {
entity.setStaffCount(0);
}
}
}
@Override
protected void saveAfter(PerformStaffConfEntity entity, Context context) throws AppException {
if(CollectionUtils.isNotEmpty(entity.getStaffConfDetail())){
......
......@@ -49,5 +49,35 @@ public class PerformDeptConfDetailController extends BaseCRUDJsonBodyMappingCont
super.init(model, context);
}
/**
* 启用停用
* @param id
* @return
*/
@RequestMapping(value = {"enable"},method = {RequestMethod.POST, RequestMethod.GET})
public String enable(Long id) {
Context context = this.getContext();
if (id == null) {
return this.createFailJsonResp("请至少选择一条记录");
} else {
Map<String, Object> model = new HashMap();
int code = 1;
String busiDesc = "启用/停用" + this.getModuleDesc();
try {
int iRet = this.service.enable(id, context);
model.put("message_info", this.getModuleDesc() + "启用/停用成功!");
this.recordSysLog(this.request, busiDesc + " 【成功】 [id:" + id + "]");
} catch (Exception var7) {
code = -1;
this.doException(this.request, busiDesc, model, var7);
}
JSONObject ret = new JSONObject();
ret.put("code", Integer.valueOf(code));
ret.put("msg", model.remove("message_info"));
ret.put("data", model);
return ret.toJSONString();
}
}
}
\ No newline at end of file
......@@ -49,5 +49,35 @@ public class PerformStaffConfDetailController extends BaseCRUDJsonBodyMappingCon
super.init(model, context);
}
/**
* 启用停用
* @param id
* @return
*/
@RequestMapping(value = {"enable"},method = {RequestMethod.POST, RequestMethod.GET})
public String enable(Long id) {
Context context = this.getContext();
if (id == null) {
return this.createFailJsonResp("请至少选择一条记录");
} else {
Map<String, Object> model = new HashMap();
int code = 1;
String busiDesc = "启用/停用" + this.getModuleDesc();
try {
int iRet = this.service.enable(id, context);
model.put("message_info", this.getModuleDesc() + "启用/停用成功!");
this.recordSysLog(this.request, busiDesc + " 【成功】 [id:" + id + "]");
} catch (Exception var7) {
code = -1;
this.doException(this.request, busiDesc, model, var7);
}
JSONObject ret = new JSONObject();
ret.put("code", Integer.valueOf(code));
ret.put("msg", model.remove("message_info"));
ret.put("data", model);
return ret.toJSONString();
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment