weaver-hrm-organization/src/com/engine/organization/service/impl/SchemeServiceImpl.java

180 lines
7.2 KiB
Java
Raw Normal View History

2022-05-07 10:18:50 +08:00
package com.engine.organization.service.impl;
2022-05-09 14:40:18 +08:00
import com.api.browser.bean.SearchConditionGroup;
import com.api.browser.bean.SearchConditionItem;
2022-05-07 11:32:48 +08:00
import com.cloudstore.eccom.result.WeaResultMsg;
2022-05-07 10:18:50 +08:00
import com.engine.core.impl.Service;
2022-05-07 11:32:48 +08:00
import com.engine.organization.component.OrganizationWeaTable;
2022-05-09 14:40:18 +08:00
import com.engine.organization.entity.scheme.dto.SchemeDTO;
2022-05-07 22:03:42 +08:00
import com.engine.organization.entity.scheme.param.SchemeSearchParam;
2022-05-07 10:18:50 +08:00
import com.engine.organization.entity.scheme.po.SchemePO;
2022-05-07 11:32:48 +08:00
import com.engine.organization.entity.scheme.vo.SchemeTableVO;
import com.engine.organization.mapper.scheme.SchemeMapper;
2022-05-07 10:18:50 +08:00
import com.engine.organization.service.SchemeService;
2022-05-10 13:49:36 +08:00
import com.engine.organization.util.MenuBtn;
2022-05-07 14:45:35 +08:00
import com.engine.organization.util.OrganizationAssert;
2022-05-09 14:40:18 +08:00
import com.engine.organization.util.OrganizationFormItemUtil;
import com.engine.organization.util.RefreshIsUsedUtil;
2022-05-07 11:32:48 +08:00
import com.engine.organization.util.db.DBType;
2022-05-07 14:45:35 +08:00
import com.engine.organization.util.db.MapperProxyFactory;
2022-05-07 11:32:48 +08:00
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
2022-05-09 14:40:18 +08:00
import weaver.general.StringUtil;
2022-05-07 11:32:48 +08:00
import weaver.general.Util;
2022-06-06 19:19:28 +08:00
import weaver.hrm.HrmUserVarify;
2022-05-07 10:18:50 +08:00
2022-05-09 14:40:18 +08:00
import java.util.*;
2022-05-07 10:18:50 +08:00
/**
2022-05-09 14:40:18 +08:00
* @Author dxfeng
2022-05-07 10:18:50 +08:00
* @Description: TODO
2022-05-09 14:40:18 +08:00
* @Date 2022/5/9
2022-05-07 10:18:50 +08:00
* @Version V1.0
**/
public class SchemeServiceImpl extends Service implements SchemeService {
2022-05-10 21:07:50 +08:00
private SchemeMapper getSchemeMapper() {
return MapperProxyFactory.getProxy(SchemeMapper.class);
}
2022-05-07 22:03:42 +08:00
@Override
public Map<String, Object> listPage(Map<String, Object> params) {
2022-06-06 19:19:28 +08:00
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("hasRight", hasRight());
if (!hasRight()) {
return resultMap;
}
// 刷新引用状态
RefreshIsUsedUtil.RefreshScheme("jcl_org_scheme");
2022-05-07 22:03:42 +08:00
OrganizationWeaTable<SchemeTableVO> table = new OrganizationWeaTable<>(user, SchemeTableVO.class);
String sqlWhere = buildSqlWhere(params);
table.setSqlwhere(sqlWhere);
WeaResultMsg result = new WeaResultMsg(false);
result.putAll(table.makeDataResult());
result.success();
2022-06-06 19:19:28 +08:00
resultMap.putAll(result.getResultMap());
return resultMap;
2022-05-07 22:03:42 +08:00
}
2022-05-07 10:18:50 +08:00
@Override
2022-05-07 22:03:42 +08:00
public Map<String, Object> save(SchemeSearchParam param) {
2022-06-06 19:19:28 +08:00
OrganizationAssert.isTrue(hasRight(), "暂无权限");
Map<String, Object> apidatas = new HashMap<>(16);
2022-05-10 21:07:50 +08:00
List<SchemePO> list = getSchemeMapper().listByNo(Util.null2String(param.getSchemeNo()));
2022-05-07 22:03:42 +08:00
OrganizationAssert.isEmpty(list, "编号不允许重复");
2022-05-09 14:40:18 +08:00
SchemePO schemePO = SchemeDTO.convertParamToPO(param, (long) user.getUID());
2022-05-10 21:07:50 +08:00
getSchemeMapper().insertIgnoreNull(schemePO);
2022-05-07 11:32:48 +08:00
return apidatas;
2022-05-07 10:18:50 +08:00
}
2022-05-07 22:03:42 +08:00
@Override
public Map<String, Object> updateScheme(SchemeSearchParam param) {
2022-06-06 19:19:28 +08:00
OrganizationAssert.isTrue(hasRight(), "暂无权限");
Map<String, Object> apidatas = new HashMap<>();
2022-05-09 14:40:18 +08:00
SchemePO schemePO = SchemeDTO.convertParamToPO(param, (long) user.getUID());
2022-05-10 21:07:50 +08:00
getSchemeMapper().updateScheme(schemePO);
2022-05-07 22:03:42 +08:00
return apidatas;
}
2022-05-07 11:32:48 +08:00
2022-05-07 10:18:50 +08:00
@Override
2022-05-09 14:40:18 +08:00
public void updateForbiddenTagById(SchemeSearchParam params) {
2022-06-06 19:19:28 +08:00
OrganizationAssert.isTrue(hasRight(), "暂无权限");
2022-05-10 14:54:49 +08:00
SchemePO schemePO = SchemePO.builder().id(params.getId()).forbiddenTag(params.getForbiddenTag() ? 0 : 1).build();
2022-05-10 21:07:50 +08:00
getSchemeMapper().updateForbiddenTagById(schemePO);
2022-05-07 22:03:42 +08:00
}
2022-05-07 11:32:48 +08:00
2022-05-07 22:03:42 +08:00
@Override
public void deleteByIds(Collection<Long> ids) {
2022-06-06 19:19:28 +08:00
OrganizationAssert.isTrue(hasRight(), "暂无权限");
2022-05-07 22:03:42 +08:00
OrganizationAssert.notEmpty(ids, "请选择要删除的数据");
2022-05-10 21:07:50 +08:00
getSchemeMapper().deleteByIds(ids);
2022-05-07 22:03:42 +08:00
}
2022-05-09 14:40:18 +08:00
2022-05-07 22:03:42 +08:00
@Override
2022-05-09 14:40:18 +08:00
public Map<String, Object> getSearchCondition(Map<String, Object> params) {
2022-06-06 19:19:28 +08:00
OrganizationAssert.isTrue(hasRight(), "暂无权限");
2022-05-09 14:40:18 +08:00
Map<String, Object> apiDatas = new HashMap<>();
List<SearchConditionGroup> addGroups = new ArrayList<>();
List<SearchConditionItem> conditionItems = new ArrayList<>();
2022-05-10 13:49:36 +08:00
SearchConditionItem schemeNameCondition = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "方案名称", "schemeName");
SearchConditionItem schemeNoCondition = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "方案编号", "schemeNo");
2022-05-09 14:40:18 +08:00
conditionItems.add(schemeNameCondition);
conditionItems.add(schemeNoCondition);
addGroups.add(new SearchConditionGroup("高级搜索条件", true, conditionItems));
apiDatas.put("conditions", addGroups);
return apiDatas;
}
@Override
public Map<String, Object> getSchemeForm(Map<String, Object> params) {
2022-06-06 19:19:28 +08:00
OrganizationAssert.isTrue(hasRight(), "暂无权限");
2022-05-09 14:40:18 +08:00
Map<String, Object> apiDatas = new HashMap<>();
List<SearchConditionItem> selectItems = new ArrayList<>();
List<SearchConditionGroup> addGroups = new ArrayList<>();
2022-05-10 10:54:41 +08:00
SearchConditionItem schemeNameCondition = OrganizationFormItemUtil.inputItem(user, 2, 17, 3, 50, "方案名称", "schemeName");
schemeNameCondition.setRules("required|string");
2022-05-10 13:49:36 +08:00
SearchConditionItem schemeNoCondition = OrganizationFormItemUtil.inputItem(user, 2, 17, 3, 50, "方案编号", "schemeNo");
2022-05-10 10:54:41 +08:00
schemeNoCondition.setRules("required|string");
2022-05-11 13:38:58 +08:00
SearchConditionItem textareaItem = OrganizationFormItemUtil.textareaItem(user, 2, 17, true, 2, 60, "方案说明", "schemeDescription");
2022-05-09 14:40:18 +08:00
// 编辑状态下赋值操作
String id = Util.null2String(params.get("id"));
2022-05-09 14:40:18 +08:00
if (!StringUtil.isEmpty(id)) {
2022-05-10 21:07:50 +08:00
SchemePO schemePO = getSchemeMapper().getSchemeByID(Integer.parseInt(id));
2022-05-09 14:40:18 +08:00
OrganizationAssert.notNull(schemePO, "选择的数据不存在,或数据已删除");
schemeNameCondition.setValue(schemePO.getSchemeName());
schemeNoCondition.setValue(schemePO.getSchemeNo());
textareaItem.setValue(schemePO.getSchemeDescription());
2022-05-10 13:49:36 +08:00
// 编辑状态下,编号只读
schemeNoCondition.setViewAttr(1);
2022-05-09 14:40:18 +08:00
}
selectItems.add(schemeNoCondition);
2022-05-10 13:49:36 +08:00
selectItems.add(schemeNameCondition);
2022-05-09 14:40:18 +08:00
selectItems.add(textareaItem);
addGroups.add(new SearchConditionGroup("基本信息", true, selectItems));
apiDatas.put("condition", addGroups);
return apiDatas;
2022-05-07 11:32:48 +08:00
}
@Override
public Map<String, Object> getTableBtn() {
2022-06-06 19:19:28 +08:00
OrganizationAssert.isTrue(hasRight(), "暂无权限");
2022-05-10 21:07:50 +08:00
return MenuBtn.getCommonBtnDatas();
}
2022-05-07 11:32:48 +08:00
/**
* 查询条件
2022-05-07 14:45:35 +08:00
*
2022-05-07 11:32:48 +08:00
* @param params
* @return
*/
private String buildSqlWhere(Map<String, Object> params) {
DBType dbType = DBType.get(new RecordSet().getDBType());
String sqlWhere = " where delete_type ='0' ";
2022-05-10 13:49:36 +08:00
String name = (String) params.get("schemeName");
2022-05-07 11:32:48 +08:00
if (StringUtils.isNotBlank(name)) {
sqlWhere += " AND scheme_name " + dbType.like(name);
}
2022-05-10 13:49:36 +08:00
String no = (String) params.get("schemeNo");
2022-05-07 22:03:42 +08:00
if (StringUtils.isNotBlank(no)) {
2022-05-07 11:32:48 +08:00
sqlWhere += " AND scheme_no " + dbType.like(no);
}
return sqlWhere;
2022-05-07 10:18:50 +08:00
}
2022-06-06 19:19:28 +08:00
/**
* 是否有该模块权限
*
* @return
*/
private boolean hasRight() {
return HrmUserVarify.checkUserRight("Scheme:All", user);
}
2022-05-07 10:18:50 +08:00
}