| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.highdatas.srs.entity.*; |
| | | import com.highdatas.srs.mapper.SysRoleMapper; |
| | | import com.highdatas.srs.pojo.CodeMsg; |
| | | import com.highdatas.srs.pojo.Result; |
| | | import com.highdatas.srs.service.ISchemeDetailService; |
| | | import com.highdatas.srs.service.ISchemeService; |
| | | import com.highdatas.srs.service.ISysRoleMappingService; |
| | | import com.highdatas.srs.service.ISysRoleService; |
| | | import com.highdatas.srs.pojo.SchemeDetailCountEntity; |
| | | import com.highdatas.srs.service.*; |
| | | import com.highdatas.srs.util.Constant; |
| | | import com.highdatas.srs.util.DbUtils; |
| | | import com.highdatas.srs.util.FileUtils; |
| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | ISysRoleService roleService; |
| | | @Autowired |
| | | ISysRoleMappingService roleMappingService; |
| | | |
| | | @Autowired |
| | | ISysUserService userService; |
| | | @Autowired |
| | | IPartimepayService partimepayService; |
| | | @Autowired |
| | | ISchemeDetailParttimeService detailParttimeService; |
| | | @Autowired |
| | | IModuleService moduleService; |
| | | @Value("{base.file.path}") |
| | | String basePath; |
| | | @Autowired |
| | | SysRoleMapper mapper; |
| | | |
| | | |
| | | @RequestMapping(value = "dayTask", method = RequestMethod.GET) |
| | | public Result dayByUser(HttpServletRequest request) { |
| | |
| | | long totalCnt = 0; |
| | | long delayCnt = 0; |
| | | for (String type : types) { |
| | | long total = schemeDetailList.stream().filter(schemeDetail -> schemeDetail.getType().getParent().equalsIgnoreCase(type)).count(); |
| | | long delay = schemeDetailList.stream().filter(schemeDetail -> schemeDetail.getType().getParent().equalsIgnoreCase(type)) |
| | | long total = schemeDetailList.stream().filter(schemeDetail -> schemeDetail.getType() != null).filter(schemeDetail -> type.equalsIgnoreCase(schemeDetail.getType().getParent())).count(); |
| | | long delay = schemeDetailList.stream().filter(schemeDetail -> schemeDetail.getType() != null).filter(schemeDetail -> type.equalsIgnoreCase(schemeDetail.getType().getParent())) |
| | | .filter(schemeDetail -> schemeDetail.getDelay()).count(); |
| | | totalCnt += total; |
| | | delayCnt += delay; |
| | |
| | | return Result.success(endResult); |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/dealParttime/{id}", method = RequestMethod.GET) |
| | | public Result deal(@PathVariable String id, @RequestParam int month,@RequestParam int year, @RequestParam BigDecimal money ) { |
| | | partimepayService.delete(new EntityWrapper<Partimepay>().eq("month", month).eq("year", year).eq("parttime_id", id)); |
| | | new Partimepay().setId(DbUtils.getUUID()).setYear(year).setMonth(month).setParttimeId(id).setMoney(money).insert(); |
| | | return Result.success(null); |
| | | } |
| | | |
| | | @RequestMapping(value = "/deal/{id}", method = RequestMethod.GET) |
| | | public Result deal(@PathVariable String id, HttpServletRequest request) { |
| | |
| | | @RequestMapping(value = "/get/{id}", method = RequestMethod.GET) |
| | | public Result get(@PathVariable String id) { |
| | | SchemeDetail schemeDetail = schemeDetailService.selectById(id); |
| | | String userId = schemeDetail.getUserId(); |
| | | SysRoleMapping mapping = roleMappingService.selectOne(new EntityWrapper<SysRoleMapping>().eq("user_id", userId)); |
| | | if (mapping != null) { |
| | | String roleId = mapping.getRoleId(); |
| | | SysRole sysRole = roleService.selectById(roleId); |
| | | if (sysRole != null) { |
| | | schemeDetail.setRoleName(sysRole.getName()); |
| | | } |
| | | List<SchemeDetailParttime> parent_id = detailParttimeService.selectList(new EntityWrapper<SchemeDetailParttime>().eq("parent_id", schemeDetail.getId())); |
| | | schemeDetail.setParttimeList(parent_id); |
| | | } |
| | | |
| | | String dataInfoTable = schemeDetail.getDataInfoTable(); |
| | | |
| | | if (!StringUtils.isEmpty(dataInfoTable)) { |
| | | Map<String, Object> stringObjectMap = mapper.selectTableById(dataInfoTable, schemeDetail.getDetailInfoId()); |
| | | Set<String> keySet = stringObjectMap.keySet(); |
| | | JSONObject object = new JSONObject(); |
| | | for (String s : keySet) { |
| | | String key = DbUtils.lineToHump(s); |
| | | Object val = stringObjectMap.get(s); |
| | | object.fluentPut(key,val); |
| | | } |
| | | |
| | | schemeDetail.setExistsObject(object); |
| | | } |
| | | return Result.success(schemeDetail); |
| | | } |
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "/getByParttime", method = RequestMethod.GET) |
| | | public Result getByParttime(@RequestParam int year, @RequestParam int month) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(year,month - 1,00); |
| | | Date startTime = calendar.getTime(); |
| | | calendar.set(year,month,00); |
| | | calendar.add(Calendar.DAY_OF_YEAR, -1); |
| | | Date endTime = calendar.getTime(); |
| | | List<Scheme> schemes = schemeService.selectList(new EntityWrapper<Scheme>().ne("status", "edit")); |
| | | |
| | | Map<String, Map<String,Double>> resultMap = new HashMap<>(); |
| | | |
| | | for (Scheme scheme : schemes) { |
| | | List<SchemeDetail> schemeDetailList = schemeDetailService.selectList(new EntityWrapper<SchemeDetail>().eq("parent_id", scheme.getId()).ge("start_time", startTime).le("end_time", endTime)); |
| | | for (SchemeDetail detail : schemeDetailList) { |
| | | Boolean finish = detail.getFinish(); |
| | | BigDecimal budget = detail.getBudget(); |
| | | List<SchemeDetailParttime> parent_id = detailParttimeService.selectList(new EntityWrapper<SchemeDetailParttime>().eq("parent_id", detail.getId())); |
| | | if (parent_id == null || parent_id.isEmpty()) { |
| | | continue; |
| | | } |
| | | |
| | | |
| | | for (SchemeDetailParttime parttime : parent_id) { |
| | | String parttimeUser = parttime.getParttimeUser(); |
| | | Map<String,Double> oneResult = resultMap.get(parttimeUser); |
| | | if (oneResult == null) { |
| | | oneResult = new HashMap<>(); |
| | | oneResult.put("payMoney", parttime.getParttimePay().doubleValue()); |
| | | } |
| | | |
| | | if (finish) { |
| | | double finishCnt = oneResult.get("finishCnt") == null ? 0 : oneResult.get("finishCnt"); |
| | | double finishMoney = oneResult.get("finishMoney") == null ? 0 : oneResult.get("finishMoney"); |
| | | finishCnt++; |
| | | oneResult.put("finishCnt", finishCnt); |
| | | oneResult.put("finishMoney", finishMoney + budget.doubleValue()); |
| | | } else { |
| | | double unFinishCnt = oneResult.get("unFinishCnt") == null ? 0 : oneResult.get("unFinishCnt"); |
| | | double unFinishMoney = oneResult.get("unFinishMoney") == null ? 0 : oneResult.get("unFinishMoney"); |
| | | unFinishCnt++; |
| | | oneResult.put("unFinishCnt", unFinishCnt); |
| | | oneResult.put("unFinishMoney", unFinishMoney + budget.doubleValue()); |
| | | } |
| | | resultMap.put(parttimeUser, oneResult); |
| | | } |
| | | } |
| | | } |
| | | Set<String> keySet = resultMap.keySet(); |
| | | List<Map<String,Object>> result = new ArrayList<>(); |
| | | for (String userId : keySet) { |
| | | SysUser sysUser = userService.selectById(userId); |
| | | if (sysUser == null) { |
| | | continue; |
| | | } |
| | | Map<String,Double> doubles = resultMap.get(userId); |
| | | HashMap<String, Object> stringObjectHashMap = new HashMap<>(doubles); |
| | | stringObjectHashMap.put("userId", sysUser.getId()); |
| | | stringObjectHashMap.put("userName", sysUser.getName()); |
| | | |
| | | Partimepay partimepay = partimepayService.selectOne(new EntityWrapper<Partimepay>().eq("year", year).eq("month", month).eq("parttime_id", userId)); |
| | | if (partimepay != null) { |
| | | stringObjectHashMap.put("money", partimepay.getMoney()); |
| | | } |
| | | |
| | | result.add(stringObjectHashMap); |
| | | } |
| | | return Result.success(result); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getMoneyByPersion", method = RequestMethod.GET) |
| | | public Result getMoneyByPersion(@RequestParam String userId, @RequestParam Boolean isParttime) { |
| | | List<Scheme> schemes = schemeService.selectList(new EntityWrapper<Scheme>().ne("status", "edit")); |
| | | |
| | | List<Map<String,Object>> resultMap = new ArrayList<>(); |
| | | List<Map<String,Object>> parentMap = new ArrayList<>(); |
| | | |
| | | for (Scheme scheme : schemes) { |
| | | double schemeBudget = 0; |
| | | List<SchemeDetail> collect; |
| | | if (isParttime) { |
| | | List<String> detailIdList = schemeDetailService.selectList(new EntityWrapper<SchemeDetail>().eq("parent_id", scheme.getId())).stream().map(SchemeDetail::getId).collect(Collectors.toList()); |
| | | if (detailIdList.isEmpty()) { |
| | | collect = new ArrayList<>(); |
| | | } else { |
| | | List<SchemeDetailParttime> parttime_user = detailParttimeService.selectList(new EntityWrapper<SchemeDetailParttime>().eq("parttime_user", userId).in("parent_id", detailIdList)); |
| | | List<String> detailList = parttime_user.stream().map(SchemeDetailParttime::getParentId).collect(Collectors.toList()); |
| | | if (detailList == null || detailList.isEmpty()) { |
| | | collect = new ArrayList<>(); |
| | | |
| | | } else { |
| | | collect = schemeDetailService.selectBatchIds(detailList); |
| | | } |
| | | } |
| | | |
| | | } else { |
| | | collect = schemeDetailService.selectList(new EntityWrapper<SchemeDetail>().eq("parent_id", scheme.getId()).eq("user_id", userId)); |
| | | } |
| | | |
| | | for (SchemeDetail detail : collect) { |
| | | Boolean finish = detail.getFinish(); |
| | | BigDecimal budget = detail.getBudget(); |
| | | String detailUserId = detail.getUserId(); |
| | | List<SchemeDetailParttime> parttimeList = detailParttimeService.selectList(new EntityWrapper<SchemeDetailParttime>().eq("parent_id", detail.getId())); |
| | | List<String> parttimeIdList = parttimeList.stream().map(SchemeDetailParttime::getParttimeUser).collect(Collectors.toList()); |
| | | if (isParttime) { |
| | | if (!parttimeIdList.contains(userId)) { |
| | | continue; |
| | | } |
| | | }else { |
| | | if (!detailUserId.equalsIgnoreCase(userId)) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | Date detailStartTime = detail.getStartTime(); |
| | | Date detailEndTime = detail.getEndTime(); |
| | | SchemeDetailType type = detail.getType(); |
| | | HashMap<String, Object> stringObjectHashMap = new HashMap<>(); |
| | | stringObjectHashMap.put("startTime", detailStartTime); |
| | | stringObjectHashMap.put("endTime", detailEndTime); |
| | | stringObjectHashMap.put("name", type.covert()); |
| | | stringObjectHashMap.put("budget", budget.doubleValue()); |
| | | stringObjectHashMap.put("finish", finish); |
| | | stringObjectHashMap.put("parentId", detail.getParentId()); |
| | | stringObjectHashMap.put("isPro", false); |
| | | stringObjectHashMap.put("id", detail.getId()); |
| | | |
| | | schemeBudget += detail.getBudget().doubleValue(); |
| | | resultMap.add(stringObjectHashMap); |
| | | |
| | | } |
| | | if (!collect.isEmpty()) { |
| | | HashMap<String, Object> proMap = new HashMap<>(); |
| | | proMap.put("startTime", scheme.getStartTime()); |
| | | proMap.put("endTime", scheme.getEndTime()); |
| | | proMap.put("name", scheme.getName()); |
| | | proMap.put("budget", schemeBudget); |
| | | proMap.put("finish", false); |
| | | proMap.put("id", scheme.getId()); |
| | | proMap.put("isPro", true); |
| | | parentMap.add(proMap); |
| | | } |
| | | |
| | | } |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("sub", resultMap); |
| | | object.fluentPut("scheme", parentMap); |
| | | return Result.success(object); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getPersion", method = RequestMethod.GET) |
| | | public Result getPersion() { |
| | | List<Scheme> schemes = schemeService.selectList(new EntityWrapper<Scheme>().ne("status", "edit")); |
| | | |
| | | Map<String, Map<String,Double>> resultMap = new HashMap<>(); |
| | | |
| | | for (Scheme scheme : schemes) { |
| | | List<SchemeDetail> schemeDetailList = schemeDetailService.selectList(new EntityWrapper<SchemeDetail>().eq("parent_id", scheme.getId())); |
| | | for (SchemeDetail detail : schemeDetailList) { |
| | | Boolean finish = detail.getFinish(); |
| | | BigDecimal budget = detail.getBudget(); |
| | | String userId = detail.getUserId(); |
| | | |
| | | Map<String,Double> oneResult = resultMap.get(userId); |
| | | if (oneResult == null) { |
| | | oneResult = new HashMap<>(); |
| | | } |
| | | if (finish) { |
| | | double finishCnt = oneResult.get("finishCnt") == null ? 0 : oneResult.get("finishCnt"); |
| | | double finishMoney = oneResult.get("finishMoney") == null ? 0 : oneResult.get("finishMoney"); |
| | | finishCnt++; |
| | | oneResult.put("finishCnt", finishCnt); |
| | | oneResult.put("finishMoney", finishMoney + budget.doubleValue()); |
| | | } else { |
| | | double unFinishCnt = oneResult.get("unFinishCnt") == null ? 0 : oneResult.get("unFinishCnt"); |
| | | double unFinishMoney = oneResult.get("unFinishMoney") == null ? 0 : oneResult.get("unFinishMoney"); |
| | | unFinishCnt++; |
| | | oneResult.put("unFinishCnt", unFinishCnt); |
| | | oneResult.put("unFinishMoney", unFinishMoney + budget.doubleValue()); |
| | | } |
| | | resultMap.put(userId, oneResult); |
| | | |
| | | } |
| | | } |
| | | Set<String> keySet = resultMap.keySet(); |
| | | List<Map<String,Object>> result = new ArrayList<>(); |
| | | for (String userId : keySet) { |
| | | SysUser sysUser = userService.selectById(userId); |
| | | if (sysUser == null) { |
| | | continue; |
| | | } |
| | | Map<String,Double> doubles = resultMap.get(userId); |
| | | HashMap<String, Object> stringObjectHashMap = new HashMap<>(doubles); |
| | | stringObjectHashMap.put("userId", sysUser.getId()); |
| | | stringObjectHashMap.put("userName", sysUser.getName()); |
| | | |
| | | |
| | | result.add(stringObjectHashMap); |
| | | } |
| | | return Result.success(result); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getMonth", method = RequestMethod.GET) |
| | |
| | | for (SchemeDetail detail : dealList) { |
| | | String userId = detail.getUserId(); |
| | | SysRoleMapping mapping = roleMappingService.selectOne(new EntityWrapper<SysRoleMapping>().eq("user_id", userId)); |
| | | String roleId = mapping.getRoleId(); |
| | | SysRole sysRole = roleService.selectById(roleId); |
| | | detail.setRoleName(sysRole.getName()); |
| | | if (mapping != null) { |
| | | String roleId = mapping.getRoleId(); |
| | | SysRole sysRole = roleService.selectById(roleId); |
| | | if (sysRole == null) { |
| | | continue; |
| | | } |
| | | detail.setRoleName(sysRole.getName()); |
| | | } |
| | | List<SchemeDetailParttime> parent_id = detailParttimeService.selectList(new EntityWrapper<SchemeDetailParttime>().eq("parent_id", detail.getId())); |
| | | detail.setParttimeList(parent_id); |
| | | |
| | | String dataInfoTable = detail.getDataInfoTable(); |
| | | if (!StringUtils.isEmpty(dataInfoTable)){ |
| | | Map<String, Object> stringObjectMap = mapper.selectTableById(dataInfoTable, detail.getDetailInfoId()); |
| | | |
| | | Set<String> keySet = stringObjectMap.keySet(); |
| | | JSONObject object = new JSONObject(); |
| | | for (String s : keySet) { |
| | | String key = DbUtils.lineToHump(s); |
| | | Object val = stringObjectMap.get(s); |
| | | object.fluentPut(key,val); |
| | | } |
| | | detail.setExistsObject(object); |
| | | } |
| | | } |
| | | return Result.success(dealList); |
| | | } |
| | | |
| | | @RequestMapping(value = "/updates", method = RequestMethod.GET) |
| | | public Result updates(@RequestParam String datas) { |
| | | @Transactional(rollbackFor = {RuntimeException.class, Error.class}) |
| | | @RequestMapping(value = "/updates", method = RequestMethod.POST) |
| | | public Result updates(@RequestBody JSONObject reqObj) { |
| | | String schemeId = reqObj.getString("schemeId"); |
| | | JSONArray datas = reqObj.getJSONArray("datas"); |
| | | Scheme scheme = schemeService.selectById(schemeId); |
| | | schemeDetailService.delete(new EntityWrapper<SchemeDetail>().eq("parent_id", schemeId)); |
| | | |
| | | try { |
| | | List<SchemeDetail> array = JSON.parseArray(datas, SchemeDetail.class); |
| | | for (SchemeDetail detail : array) { |
| | | SchemeDetail pre = schemeDetailService.selectById(detail.getId()); |
| | | if (pre == null) { |
| | | EntityWrapper<SchemeDetail> schemeDetailEntityWrapper = new EntityWrapper<>(); |
| | | schemeDetailEntityWrapper.eq("parent_id", detail.getParentId()); |
| | | schemeDetailEntityWrapper.eq("type", detail.getType()); |
| | | pre = schemeDetailService.selectOne(schemeDetailEntityWrapper); |
| | | if (pre == null) { |
| | | detail.setId(DbUtils.getUUID()); |
| | | detail.setCreateTime(new Date()); |
| | | detail.insert(); |
| | | continue; |
| | | for (Object data : datas) { |
| | | JSONObject one = (JSONObject) JSONObject.toJSON(data); |
| | | JSONObject existsObject = one.getJSONObject("existsObject"); |
| | | if (existsObject == null) { |
| | | continue; |
| | | } |
| | | SchemeDetail detail = JSON.parseObject(one.toJSONString(), SchemeDetail.class); |
| | | String dataInfoTable = detail.getDataInfoTable(); |
| | | if (!StringUtils.isEmpty(dataInfoTable)) { |
| | | String s = DbUtils.lineToHump(dataInfoTable); |
| | | String substring = s.substring(0, 1); |
| | | s = substring.toUpperCase() + s.substring(1); |
| | | s = "com.highdatas.srs.entity." +s; |
| | | Object o = JSON.parseObject(existsObject.toJSONString(), Class.forName(s)); |
| | | if (o instanceof InfoSurface) { |
| | | InfoSurface surface = (InfoSurface) o; |
| | | surface.dataInsertOrUpdate(); |
| | | } |
| | | if (o instanceof TitleService) { |
| | | TitleService titleService = (TitleService) o; |
| | | String title = titleService.getTitle(); |
| | | scheme.setName(title).updateById(); |
| | | } |
| | | } |
| | | if (pre.getMustAttach() != detail.getMustAttach()) { |
| | | if (detail.getMustAttach()) { |
| | | //必须传附件 |
| | | Scheme scheme = schemeService.selectById(detail.getParentId()); |
| | | detail.setAttachment(FileUtils.createFile(basePath, scheme.getName(), detail.getType().name())); |
| | | } else { |
| | | detail.setAttachment(null); |
| | | |
| | | } |
| | | List<SchemeDetail> array = JSON.parseArray(datas.toJSONString(), SchemeDetail.class); |
| | | for (SchemeDetail detail : array) { |
| | | if (StringUtils.isEmpty(detail.getId())) { |
| | | detail.setId(DbUtils.getUUID()).setCreateTime(new Date()); |
| | | } |
| | | detail.setUpdateTime(new Date()); |
| | | detail.insertOrUpdate(); |
| | | |
| | | if (detail.getMustAttach()) { |
| | | //必须传附件 |
| | | |
| | | detail.setAttachment(FileUtils.createFile(basePath, scheme.getName(), detail.getType().name())); |
| | | } else { |
| | | detail.setAttachment(null); |
| | | } |
| | | |
| | | detailParttimeService.delete(new EntityWrapper<SchemeDetailParttime>().eq("parent_id", detail.getId())); |
| | | Boolean parttime = detail.getParttime(); |
| | | if (parttime == null) { |
| | | parttime = false; |
| | | } |
| | | if(parttime) { |
| | | List<SchemeDetailParttime> parttimeList = detail.getParttimeList(); |
| | | for (SchemeDetailParttime schemeDetailParttime : parttimeList) { |
| | | schemeDetailParttime.setId(DbUtils.getUUID()).setParentId(detail.getId()).insert(); |
| | | } |
| | | } |
| | | detail.insertOrUpdate(); |
| | |
| | | return Result.error(CodeMsg.UPDATE_ERROR); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/view") |
| | | public Result view(@RequestParam Date startTime, @RequestParam Date endTime, HttpServletRequest request) { |
| | | String schemeId = request.getParameter("schemeId"); |
| | | String userId = request.getParameter("userId"); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(startTime); |
| | | // calendar.add(Calendar.DAY_OF_YEAR, 1); |
| | | calendar.set(Calendar.HOUR, 0); |
| | | // endTime = calendar.getTime(); |
| | | // calendar.setTime(startTime); |
| | | // calendar.set(Calendar.HOUR, 0); |
| | | // calendar.add(Calendar.DAY_OF_YEAR, 1); |
| | | startTime = calendar.getTime(); |
| | | LinkedHashMap<Date, SchemeDetailCountEntity> resultMap = new LinkedHashMap<>(); |
| | | Date now = new Date(); |
| | | |
| | | ArrayList<String> dateList = new ArrayList<>(); |
| | | ArrayList<Integer> runtimeList = new ArrayList<>(); |
| | | ArrayList<Integer> delayList = new ArrayList<>(); |
| | | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | |
| | | while (startTime.before(endTime) || startTime.compareTo(endTime) == 0) { |
| | | Wrapper<SchemeDetail> runtimeWrapper = new EntityWrapper<SchemeDetail>().eq("edit",false).eq("finish", false).eq("delay", false).le("start_time", startTime).ge("end_time", startTime); |
| | | Wrapper<SchemeDetail> delayWrapper = new EntityWrapper<SchemeDetail>().eq("edit",false).eq("finish", false).eq("delay", true).le("start_time", startTime); |
| | | if(!StringUtils.isEmpty(userId)) { |
| | | runtimeWrapper.eq("user_id", userId); |
| | | delayWrapper.eq("user_id", userId); |
| | | } |
| | | if(!StringUtils.isEmpty(schemeId)) { |
| | | runtimeWrapper.eq("parent_id", schemeId); |
| | | delayWrapper.eq("parent_id", schemeId); |
| | | } |
| | | |
| | | int runtimeCnt = schemeDetailService.selectCount(runtimeWrapper); |
| | | int delayCnt = 0; |
| | | // startTime.setDate(startTime.getDate() - 1); |
| | | |
| | | if (startTime.before(now) || startTime.compareTo(now) == 0) { |
| | | List<SchemeDetail> detailList = schemeDetailService.selectList(delayWrapper); |
| | | for (SchemeDetail detail : detailList) { |
| | | Date detailEndTime = detail.getEndTime(); |
| | | // detailEndTime.setDate(detailEndTime.getDate() + 1); |
| | | if (detailEndTime.compareTo(startTime) > -1) { |
| | | runtimeCnt++; |
| | | } else { |
| | | delayCnt++; |
| | | } |
| | | } |
| | | } |
| | | runtimeList.add(runtimeCnt); |
| | | delayList.add(delayCnt); |
| | | // startTime.setDate(startTime.getDate() - 1); |
| | | String dateStr = format.format(startTime); |
| | | // startTime.setDate(startTime.getDate() + 1); |
| | | dateList.add(dateStr); |
| | | calendar.add(Calendar.DAY_OF_YEAR, 1); |
| | | startTime = calendar.getTime(); |
| | | } |
| | | JSONObject object = new JSONObject(); |
| | | object.fluentPut("date", dateList); |
| | | object.fluentPut("runtime", runtimeList); |
| | | object.fluentPut("delay", delayList); |
| | | return Result.success(object); |
| | | } |
| | | |
| | | @RequestMapping(value = "/view/detail", method = RequestMethod.GET) |
| | | public Result view(@RequestParam Date startTime, HttpServletRequest request) { |
| | | String schemeId = request.getParameter("schemeId"); |
| | | String userId = request.getParameter("userId"); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(startTime); |
| | | // calendar.add(Calendar.DAY_OF_YEAR, 1); |
| | | calendar.set(Calendar.HOUR, 0); |
| | | startTime = calendar.getTime(); |
| | | Wrapper<SchemeDetail> runtimeWrapper = new EntityWrapper<SchemeDetail>().eq("edit",false).eq("finish", false).eq("delay", false).le("start_time", startTime).ge("end_time", startTime); |
| | | Wrapper<SchemeDetail> delayWrapper = new EntityWrapper<SchemeDetail>().eq("edit",false).eq("finish", false).eq("delay", true).le("start_time", startTime); |
| | | if(!StringUtils.isEmpty(userId)) { |
| | | runtimeWrapper.eq("user_id", userId); |
| | | delayWrapper.eq("user_id", userId); |
| | | } |
| | | if(!StringUtils.isEmpty(schemeId)) { |
| | | runtimeWrapper.eq("parent_id", schemeId); |
| | | delayWrapper.eq("parent_id", schemeId); |
| | | } |
| | | Date now = new Date(); |
| | | List<SchemeDetail> resultList = new ArrayList<>(); |
| | | List<SchemeDetail> detailList; |
| | | // now.setDate(now.getDate() + 1); |
| | | // now.setHours(23); |
| | | if(now.compareTo(startTime) > -1) { |
| | | detailList = schemeDetailService.selectList(delayWrapper); |
| | | if (detailList != null && !detailList.isEmpty()) { |
| | | for (SchemeDetail detail : detailList) { |
| | | Date detailEndTime = detail.getEndTime(); |
| | | // detailEndTime.setDate(detailEndTime.getDate() + 1); |
| | | if (detailEndTime.compareTo(startTime) > -1) { |
| | | detail.setDelay(false); |
| | | } |
| | | // detailEndTime.setDate(detailEndTime.getDate() - 1); |
| | | resultList.add(detail); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | detailList = schemeDetailService.selectList(runtimeWrapper); |
| | | if (detailList != null && !detailList.isEmpty()) { |
| | | detailList = detailList.stream().map(detail -> detail.setDelay(false)).collect(Collectors.toList()); |
| | | resultList.addAll(detailList); |
| | | } |
| | | Collections.sort(resultList, new Comparator<SchemeDetail>() { |
| | | @Override |
| | | public int compare(SchemeDetail o1, SchemeDetail o2) { |
| | | return o1.getStartTime().compareTo(o2.getStartTime()); |
| | | } |
| | | }); |
| | | for (SchemeDetail detail : resultList) { |
| | | String parentId = detail.getParentId(); |
| | | Scheme scheme = schemeService.selectById(parentId); |
| | | if (scheme == null) { |
| | | continue; |
| | | } |
| | | detail.setSchemeName(scheme.getName()); |
| | | SysUser sysUser = userService.selectById(detail.getUserId()); |
| | | detail.setUserId(sysUser.getName()); |
| | | Module module = moduleService.selectById(detail.getType()); |
| | | detail.setTypeStr(module.getTitle()); |
| | | } |
| | | return Result.success(resultList); |
| | | } |
| | | |
| | | |
| | | } |