diff --git a/Sqlitedb/training.db b/Sqlitedb/training.db index 849fbdd..a0fd03c 100644 Binary files a/Sqlitedb/training.db and b/Sqlitedb/training.db differ diff --git a/src/main/java/com/jingcheng/cms/model/Honor.java b/src/main/java/com/jingcheng/cms/model/Honor.java index 6e7cb42..5c023dd 100644 --- a/src/main/java/com/jingcheng/cms/model/Honor.java +++ b/src/main/java/com/jingcheng/cms/model/Honor.java @@ -47,7 +47,7 @@ public class Honor { * * @mbggenerated Wed May 03 18:26:57 CST 2023 */ - @Excel(name = "荣誉说明", orderNum = "3") + @Excel(name = "奖惩内容", orderNum = "3") private String honorDescription; /** diff --git a/src/main/java/com/jingcheng/cms/service/impl/EmployeeServiceImpl.java b/src/main/java/com/jingcheng/cms/service/impl/EmployeeServiceImpl.java index 78dc76c..1e44f05 100644 --- a/src/main/java/com/jingcheng/cms/service/impl/EmployeeServiceImpl.java +++ b/src/main/java/com/jingcheng/cms/service/impl/EmployeeServiceImpl.java @@ -4,6 +4,7 @@ import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.ExcelImportUtil; import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.ImportParams; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.jingcheng.cms.constants.Constants; import com.jingcheng.cms.mapper.*; @@ -52,12 +53,21 @@ public class EmployeeServiceImpl implements EmployeeService { Example.Criteria criteria = example.createCriteria(); criteria.andEqualTo("state",Constants.STATE_VALID); String honorLevel = jsonObject.getString("honorLevel"); + String honorDescription = jsonObject.getString("honorDescription"); + JSONArray jsonArray = jsonObject.getJSONArray("ptqIds"); + List ptqIds = jsonArray != null ? jsonArray.toJavaList(Long.class) : new ArrayList<>(); List honorEmployees = new ArrayList<>(); - if (StringUtils.isNotEmpty(honorLevel)) { - Honor honor = new Honor(); - honor.setHonorLevel(honorLevel); - honor.setState(Constants.STATE_VALID); - List honors = honorMapper.select(honor); + if (StringUtils.isNotEmpty(honorLevel) || StringUtils.isNotEmpty(honorDescription)) { + Example example1 = new Example(Honor.class); + Example.Criteria criteria1 = example1.createCriteria(); + criteria1.andEqualTo("state",Constants.STATE_VALID); + if (StringUtils.isNotEmpty(honorLevel)) { + criteria1.andEqualTo("honorLevel", honorLevel); + } + if (StringUtils.isNotEmpty(honorDescription)) { + criteria1.andLike("honorDescription", "%"+honorDescription+"%"); + } + List honors = honorMapper.selectByExample(example1); honorEmployees.addAll(honors.stream().map(item -> item.getEmployeeNo()).collect(Collectors.toSet())); } Integer current = jsonObject.getInteger("current") == null ? 1 : jsonObject.getInteger("current"); @@ -68,11 +78,11 @@ public class EmployeeServiceImpl implements EmployeeService { if (StringUtils.isNotEmpty(employee.getMobile())) criteria.andLike("mobile", "%"+employee.getMobile()+"%"); if (null != employee.getPostId()) criteria.andEqualTo("postId", employee.getPostId()); if (null != employee.getGroupsId()) criteria.andEqualTo("groupsId", employee.getGroupsId()); - if (null != employee.getPtqId()) criteria.andEqualTo("ptqId", employee.getPtqId()); + if (null != ptqIds && ptqIds.size() > 0) criteria.andIn("ptqId", ptqIds); if (null != employee.getSkillLevelId()) criteria.andEqualTo("skillLevelId", employee.getSkillLevelId()); if (null != employee.getHighestEducationId()) criteria.andEqualTo("highestEducationId", employee.getHighestEducationId()); List employeeList = employeeMapper.selectByExample(example); - if (StringUtils.isNotEmpty(honorLevel) && honorEmployees.size() == 0) employeeList = new ArrayList<>(); + if ((StringUtils.isNotEmpty(honorLevel) || StringUtils.isNotEmpty(honorDescription)) && honorEmployees.size() == 0) employeeList = new ArrayList<>(); JSONObject pageJson = PageUtils.page(employeeList,current,pageSize); return pageJson; } @@ -85,12 +95,21 @@ public class EmployeeServiceImpl implements EmployeeService { Example.Criteria criteria = example.createCriteria(); criteria.andEqualTo("state",Constants.STATE_VALID); String honorLevel = jsonObject.getString("honorLevel"); + String honorDescription = jsonObject.getString("honorDescription"); + JSONArray jsonArray = jsonObject.getJSONArray("ptqIds"); + List ptqIds = jsonArray.toJavaList(Long.class); List honorEmployees = new ArrayList<>(); - if (StringUtils.isNotEmpty(honorLevel)) { - Honor honor = new Honor(); - honor.setHonorLevel(honorLevel); - honor.setState(Constants.STATE_VALID); - List honors = honorMapper.select(honor); + if (StringUtils.isNotEmpty(honorLevel) || StringUtils.isNotEmpty(honorDescription)) { + Example example1 = new Example(Honor.class); + Example.Criteria criteria1 = example1.createCriteria(); + criteria1.andEqualTo("state",Constants.STATE_VALID); + if (StringUtils.isNotEmpty(honorLevel)) { + criteria1.andEqualTo("honorLevel", honorLevel); + } + if (StringUtils.isNotEmpty(honorDescription)) { + criteria1.andLike("honorDescription", "%"+honorDescription+"%"); + } + List honors = honorMapper.selectByExample(example1); honorEmployees.addAll(honors.stream().map(item -> item.getEmployeeNo()).collect(Collectors.toSet())); } if (StringUtils.isNotEmpty(employee.getEmployeeNo())) criteria.andLike("employeeNo", "%"+employee.getEmployeeNo()+"%"); @@ -99,11 +118,11 @@ public class EmployeeServiceImpl implements EmployeeService { if (StringUtils.isNotEmpty(employee.getMobile())) criteria.andLike("mobile", "%"+employee.getMobile()+"%"); if (null != employee.getPostId()) criteria.andEqualTo("postId", employee.getPostId()); if (null != employee.getGroupsId()) criteria.andEqualTo("groupsId", employee.getGroupsId()); - if (null != employee.getPtqId()) criteria.andEqualTo("ptqId", employee.getPtqId()); + if (null != ptqIds && ptqIds.size() > 0) criteria.andIn("ptqId", ptqIds); if (null != employee.getSkillLevelId()) criteria.andEqualTo("skillLevelId", employee.getSkillLevelId()); if (null != employee.getHighestEducationId()) criteria.andEqualTo("highestEducationId", employee.getHighestEducationId()); List employeeList = employeeMapper.selectByExample(example); - if (StringUtils.isNotEmpty(honorLevel) && honorEmployees.size() == 0) employeeList = new ArrayList<>(); + if ((StringUtils.isNotEmpty(honorLevel) || StringUtils.isNotEmpty(honorDescription)) && honorEmployees.size() == 0) employeeList = new ArrayList<>(); ExportParams exportParams = new ExportParams(); Workbook workbook = ExcelExportUtil.exportExcel(exportParams,Employee.class, employeeList); ExcelUtils.export(workbook, response, "员工导出"); @@ -198,7 +217,7 @@ public class EmployeeServiceImpl implements EmployeeService { employeeListUpdate.add(employee); } } - employeeMapper.insertList(employeeListInsert); + if(employeeListInsert.size() > 0) employeeMapper.insertList(employeeListInsert); if (employeeListUpdate != null && employeeListUpdate.size() != 0) { for (Employee employee : employeeListUpdate) { employeeMapper.updateByPrimaryKey(employee); diff --git a/src/main/java/com/jingcheng/cms/service/impl/InfoSettingServiceImpl.java b/src/main/java/com/jingcheng/cms/service/impl/InfoSettingServiceImpl.java index 7ccc73e..7e80638 100644 --- a/src/main/java/com/jingcheng/cms/service/impl/InfoSettingServiceImpl.java +++ b/src/main/java/com/jingcheng/cms/service/impl/InfoSettingServiceImpl.java @@ -48,7 +48,7 @@ public class InfoSettingServiceImpl implements InfoSettingService { AjaxResult ajaxResult = new AjaxResult(); InfoSetting infoSetting = JSONObject.toJavaObject(jsonObject, InfoSetting.class); JSONArray jsonArray = jsonObject.getJSONArray("infoSettingValues"); - List infoSettingValues = jsonArray.toJavaList(InfoSettingValue.class); + List infoSettingValues = jsonArray != null ? jsonArray.toJavaList(InfoSettingValue.class) : new ArrayList<>(); infoSetting.setState(Constants.ENABLE); if (null == infoSetting.getId()) { infoSetting.setState(Constants.ENABLE); @@ -59,7 +59,7 @@ public class InfoSettingServiceImpl implements InfoSettingService { } infoSettingValue.setState(Constants.ENABLE); } - infoSettingValueMapper.insertList(infoSettingValues); + if (infoSettingValues.size() > 0) infoSettingValueMapper.insertList(infoSettingValues); } else { infoSettingMapper.updateByPrimaryKey(infoSetting); InfoSettingValue infoSettingValue = new InfoSettingValue(); @@ -69,7 +69,7 @@ public class InfoSettingServiceImpl implements InfoSettingService { infoSettingValue1.setSettingId(infoSetting.getId()); infoSettingValue.setState(Constants.ENABLE); } - infoSettingValueMapper.insertList(infoSettingValues); + if (infoSettingValues.size() > 0) infoSettingValueMapper.insertList(infoSettingValues); } return ajaxResult; }