|
|
|
package com.engine.organization.service.impl;
|
|
|
|
|
|
|
|
import com.api.browser.bean.SearchConditionGroup;
|
|
|
|
import com.api.browser.bean.SearchConditionItem;
|
|
|
|
import com.cloudstore.eccom.pc.table.WeaTableCheckboxpopedom;
|
|
|
|
import com.cloudstore.eccom.pc.table.WeaTablePopedom;
|
|
|
|
import com.cloudstore.eccom.result.WeaResultMsg;
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
import com.engine.organization.component.OrganizationWeaTable;
|
|
|
|
import com.engine.organization.entity.scheme.dto.SchemeDTO;
|
|
|
|
import com.engine.organization.entity.scheme.param.SchemeSearchParam;
|
|
|
|
import com.engine.organization.entity.scheme.po.SchemePO;
|
|
|
|
import com.engine.organization.entity.scheme.vo.SchemeTableVO;
|
|
|
|
import com.engine.organization.mapper.scheme.SchemeMapper;
|
|
|
|
import com.engine.organization.service.SchemeService;
|
|
|
|
import com.engine.organization.util.MenuBtn;
|
|
|
|
import com.engine.organization.util.OrganizationAssert;
|
|
|
|
import com.engine.organization.util.OrganizationFormItemUtil;
|
|
|
|
import com.engine.organization.util.db.DBType;
|
|
|
|
import com.engine.organization.util.db.MapperProxyFactory;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
import weaver.general.StringUtil;
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Author dxfeng
|
|
|
|
* @Description: TODO
|
|
|
|
* @Date 2022/5/9
|
|
|
|
* @Version V1.0
|
|
|
|
**/
|
|
|
|
public class SchemeServiceImpl extends Service implements SchemeService {
|
|
|
|
|
|
|
|
private SchemeMapper getSchemeMapper() {
|
|
|
|
return MapperProxyFactory.getProxy(SchemeMapper.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> listPage(Map<String, Object> params) {
|
|
|
|
OrganizationWeaTable<SchemeTableVO> table = new OrganizationWeaTable<>(user, SchemeTableVO.class);
|
|
|
|
|
|
|
|
String sqlWhere = buildSqlWhere(params);
|
|
|
|
table.setSqlwhere(sqlWhere);
|
|
|
|
|
|
|
|
WeaTableCheckboxpopedom checkboxpopedom = new WeaTableCheckboxpopedom();
|
|
|
|
checkboxpopedom.setShowmethod("com.engine.organization.util.ConfigTrans.getCheckBoxPopedom");
|
|
|
|
checkboxpopedom.setPopedompara("column:forbidden_tag");
|
|
|
|
table.setCheckboxpopedom(checkboxpopedom);
|
|
|
|
WeaResultMsg result = new WeaResultMsg(false);
|
|
|
|
result.putAll(table.makeDataResult());
|
|
|
|
result.success();
|
|
|
|
return result.getResultMap();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> save(SchemeSearchParam param) {
|
|
|
|
Map<String, Object> apidatas = new HashMap<String, Object>(16);
|
|
|
|
List<SchemePO> list = getSchemeMapper().listByNo(Util.null2String(param.getSchemeNo()));
|
|
|
|
OrganizationAssert.isEmpty(list, "编号不允许重复");
|
|
|
|
SchemePO schemePO = SchemeDTO.convertParamToPO(param, (long) user.getUID());
|
|
|
|
getSchemeMapper().insertIgnoreNull(schemePO);
|
|
|
|
return apidatas;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> updateScheme(SchemeSearchParam param) {
|
|
|
|
Map<String, Object> apidatas = new HashMap<String, Object>();
|
|
|
|
SchemePO schemePO = SchemeDTO.convertParamToPO(param, (long) user.getUID());
|
|
|
|
getSchemeMapper().updateScheme(schemePO);
|
|
|
|
return apidatas;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updateForbiddenTagById(SchemeSearchParam params) {
|
|
|
|
SchemePO schemePO = SchemePO.builder().id(params.getId()).forbiddenTag(params.getForbiddenTag() ? 0 : 1).build();
|
|
|
|
getSchemeMapper().updateForbiddenTagById(schemePO);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void deleteByIds(Collection<Long> ids) {
|
|
|
|
OrganizationAssert.notEmpty(ids, "请选择要删除的数据");
|
|
|
|
getSchemeMapper().deleteByIds(ids);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> getSearchCondition(Map<String, Object> params) {
|
|
|
|
Map<String, Object> apiDatas = new HashMap<>();
|
|
|
|
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
|
|
|
List<SearchConditionItem> conditionItems = new ArrayList<>();
|
|
|
|
SearchConditionItem schemeNameCondition = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "方案名称", "schemeName");
|
|
|
|
SearchConditionItem schemeNoCondition = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "方案编号", "schemeNo");
|
|
|
|
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) {
|
|
|
|
Map<String, Object> apiDatas = new HashMap<>();
|
|
|
|
List<SearchConditionItem> selectItems = new ArrayList<>();
|
|
|
|
List<SearchConditionGroup> addGroups = new ArrayList<>();
|
|
|
|
SearchConditionItem schemeNameCondition = OrganizationFormItemUtil.inputItem(user, 2, 17, 3, 50, "方案名称", "schemeName");
|
|
|
|
schemeNameCondition.setRules("required|string");
|
|
|
|
SearchConditionItem schemeNoCondition = OrganizationFormItemUtil.inputItem(user, 2, 17, 3, 50, "方案编号", "schemeNo");
|
|
|
|
schemeNoCondition.setRules("required|string");
|
|
|
|
SearchConditionItem textareaItem = OrganizationFormItemUtil.textareaItem(user, 2, 17, true, 2, 60, "方案说明", "schemeDescription");
|
|
|
|
|
|
|
|
// 编辑状态下赋值操作
|
|
|
|
String id = Util.null2String(params.get("id"));
|
|
|
|
if (!StringUtil.isEmpty(id)) {
|
|
|
|
SchemePO schemePO = getSchemeMapper().getSchemeByID(Integer.parseInt(id));
|
|
|
|
OrganizationAssert.notNull(schemePO, "选择的数据不存在,或数据已删除");
|
|
|
|
schemeNameCondition.setValue(schemePO.getSchemeName());
|
|
|
|
schemeNoCondition.setValue(schemePO.getSchemeNo());
|
|
|
|
textareaItem.setValue(schemePO.getSchemeDescription());
|
|
|
|
|
|
|
|
// 编辑状态下,编号只读
|
|
|
|
schemeNoCondition.setViewAttr(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
selectItems.add(schemeNoCondition);
|
|
|
|
selectItems.add(schemeNameCondition);
|
|
|
|
selectItems.add(textareaItem);
|
|
|
|
addGroups.add(new SearchConditionGroup("基本信息", true, selectItems));
|
|
|
|
apiDatas.put("condition", addGroups);
|
|
|
|
return apiDatas;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, Object> getTableBtn() {
|
|
|
|
return MenuBtn.getCommonBtnDatas();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询条件
|
|
|
|
*
|
|
|
|
* @param params
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
private String buildSqlWhere(Map<String, Object> params) {
|
|
|
|
DBType dbType = DBType.get(new RecordSet().getDBType());
|
|
|
|
String sqlWhere = " where delete_type ='0' ";
|
|
|
|
String name = (String) params.get("schemeName");
|
|
|
|
if (StringUtils.isNotBlank(name)) {
|
|
|
|
sqlWhere += " AND scheme_name " + dbType.like(name);
|
|
|
|
}
|
|
|
|
String no = (String) params.get("schemeNo");
|
|
|
|
if (StringUtils.isNotBlank(no)) {
|
|
|
|
sqlWhere += " AND scheme_no " + dbType.like(no);
|
|
|
|
}
|
|
|
|
return sqlWhere;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|