|
@@ -1141,15 +1141,28 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
|
|
|
|
|
|
List<SysRole> roles = sysUser.getRoles();
|
|
|
List<String> roleKeySets = map(roles, SysRole::getRoleKey);
|
|
|
+ Date todayStart = DateUtils.getTodayStart();
|
|
|
+ Date todayEnd = DateUtils.getTodayEnd();
|
|
|
+ VaccineInfoOperation condition = new VaccineInfoOperation();
|
|
|
+ condition.setStartTime(todayStart);
|
|
|
+ condition.setEndTime(todayEnd);
|
|
|
+ List<VaccineInfoOperation> list = null;
|
|
|
// 市领导
|
|
|
if (roleKeySets.contains("city") || roleKeySets.contains("admin")) {
|
|
|
List<SysDept> allDepts = remoteDeptService.listChildrenDepts(1L);
|
|
|
- List<SysDept> townsDepts = filter(allDepts, dept -> 1L == dept.getParentId());
|
|
|
+ List<SysDept> townsDepts = new ArrayList<>(16);
|
|
|
+ for (SysDept allDept : allDepts) {
|
|
|
+ if (isEmpty(allDept.getParentId())) continue;
|
|
|
+ if (allDept.getParentId() == (1L)) {
|
|
|
+ townsDepts.add(allDept);
|
|
|
+ }
|
|
|
+ }
|
|
|
result.put("zhen", townsDepts.size()); // 镇
|
|
|
|
|
|
List<SysDept> cunDepts = new ArrayList<>(16);
|
|
|
for (SysDept townsDept : townsDepts) {
|
|
|
for (SysDept allDept : allDepts) {
|
|
|
+ if (isEmpty(allDept.getParentId())) continue;
|
|
|
if (townsDept.getId().equals(allDept.getParentId())) {
|
|
|
cunDepts.add(allDept);
|
|
|
}
|
|
@@ -1167,51 +1180,70 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
|
|
|
}
|
|
|
result.put("zu", isEmpty(zuDept) ? 0 : zuDept.size());
|
|
|
|
|
|
- VaccineInfoOperation condition = new VaccineInfoOperation();
|
|
|
- condition.setStartTime(DateUtils.getTodayStart());
|
|
|
- condition.setEndTime(DateUtils.getTodayEnd());
|
|
|
-
|
|
|
-// if (deptId == null) {
|
|
|
-// deptId = AuthUtils.getLoginUser().getSysUser().getDeptId();
|
|
|
-// //判断是否是管理员
|
|
|
-// if (isNotEmpty(roles)) {
|
|
|
-// for (SysRole role : roles) {
|
|
|
-// String roleKey = role.getRoleKey();
|
|
|
-// if ("admin".equals(roleKey) || "city".equals(roleKey)) {
|
|
|
-// deptId = null;
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// List<Long> deptIdList = new ArrayList<>();
|
|
|
-// if (deptId != null) {
|
|
|
-// List<SysDept> sysDepts = remoteDeptService.listChildrenDepts(deptId);
|
|
|
-// if (sysDepts != null && sysDepts.size() > 0) {
|
|
|
-// for (SysDept sysDept : sysDepts) {
|
|
|
-// Long id = sysDept.getId();
|
|
|
-// deptIdList.add(id);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// condition.setDeptIdList(deptIdList);
|
|
|
- List<VaccineInfoOperation> list = vaccineInfoMapper.selectVaccineInfoList(condition);
|
|
|
+ list = vaccineInfoMapper.listByXzAndJs(condition);
|
|
|
+ } else if (roleKeySets.contains("sys:town")) {
|
|
|
+ // 乡镇以下的所有部门
|
|
|
+ List<SysDept> depts = remoteDeptService.listChildrenDepts(deptId);
|
|
|
+
|
|
|
+ List<SysDept> cunDepts = new ArrayList<>(16);
|
|
|
+ for (SysDept dept : depts) {
|
|
|
+ if (isEmpty(dept.getParentId())) continue;
|
|
|
+ if (deptId.equals(dept.getParentId())) {
|
|
|
+ cunDepts.add(dept);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.put("cun", isEmpty(cunDepts) ? 0 : cunDepts.size());
|
|
|
+
|
|
|
+ List<SysDept> zuDept = new ArrayList<>(16);
|
|
|
+ for (SysDept cunDept : cunDepts) {
|
|
|
+ for (SysDept dept : depts) {
|
|
|
+ if (cunDept.getId().equals(dept.getParentId())) {
|
|
|
+ zuDept.add(dept);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ result.put("zu", isEmpty(zuDept) ? 0 : zuDept.size());
|
|
|
+
|
|
|
+ condition.setDeptIdList(map(depts, SysDept::getId));
|
|
|
+ list = vaccineInfoMapper.listByXzAndJs(condition);
|
|
|
+ }
|
|
|
|
|
|
+ // 增加、减少
|
|
|
+ if (isEmpty(list)) {
|
|
|
result.put("xz", 0);
|
|
|
result.put("js", 0);
|
|
|
- } else if (roleKeySets.contains("sys:town")) {
|
|
|
- // 镇领导
|
|
|
+ } else {
|
|
|
+ int xz = 0, js = 0;
|
|
|
+ for (VaccineInfoOperation operation : list) {
|
|
|
+ Date createTime = operation.getCreateTime(), updateTime = operation.getUpdateTime();
|
|
|
+ String isDel = operation.getIsDel();
|
|
|
+ if ("N".equals(isDel) && createTime.after(todayStart) && createTime.before(todayEnd)) {
|
|
|
+ xz++;
|
|
|
+ } else if ("Y".equals(isDel) && updateTime.after(todayStart) && updateTime.before(todayEnd)) {
|
|
|
+ js++;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ result.put("xz", xz);
|
|
|
+ result.put("js", js);
|
|
|
}
|
|
|
-// int village = remoteDeptService.countChildrenByVillage(deptId);
|
|
|
-
|
|
|
|
|
|
- return null;
|
|
|
+ result.put("czrk", vaccineInfoMapper.countCzrk(condition));
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public AjaxResult deleteCzrk(VaccineInfoOperation vaccineInfoOperation) {
|
|
|
+ VaccineInfoOperation operation = vaccineInfoMapper.selectVaccineInfoById(vaccineInfoOperation.getId());
|
|
|
+ if (null == operation) {
|
|
|
+ return AjaxResult.error("该信息不存在,无法删除");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isEmpty(operation.getVillageTowns())) {
|
|
|
+ return AjaxResult.error("该人员为未认领人员,无法删除");
|
|
|
+ }
|
|
|
+
|
|
|
vaccineInfoOperation.setUpdateBy(AuthUtils.getLoginUser().getSysUser().getUserName());
|
|
|
int delete = vaccineInfoMapper.deleteCzrk(vaccineInfoOperation);
|
|
|
return delete > 0 ? AjaxResult.success() : AjaxResult.error();
|