| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.factory.ThreadPoolExecutorFactory; |
| | | import com.whyc.mapper.BattDischargePlanTempMapper; |
| | | import com.whyc.pojo.BaojiGroupBattGroup; |
| | | import com.whyc.pojo.BattDischargePlanTemp; |
| | | import com.whyc.pojo.BattdischargePlan; |
| | | import com.whyc.pojo.Battinf; |
| | | import com.whyc.pojo.*; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.DateUtil; |
| | | import com.whyc.util.ExcelUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.swing.*; |
| | | import java.text.ParseException; |
| | | import java.util.*; |
| | | import java.util.concurrent.CountDownLatch; |
| | | import java.util.concurrent.ThreadPoolExecutor; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | |
| | | //一年度只能生成一次审核通过的放电计划,校验 |
| | | int planYear = planTime.get(Calendar.YEAR); |
| | | QueryWrapper<BattDischargePlanTemp> query = Wrappers.query(); |
| | | query.likeRight("discharge_start_time",planYear).eq("status",1).last(" limit 1"); |
| | | query.likeRight("discharge_start_time",planYear).last(" limit 1"); |
| | | BattDischargePlanTemp tempDB = mapper.selectOne(query); |
| | | if(tempDB!=null){ |
| | | return new Response().set(1,false,"当前年度已存在计划,无法重复生成"); |
| | | return new Response().set(1,false,"当前年度已存在计划审批清单,无法重复生成"); |
| | | } |
| | | //查询所有可用的组以及每个组的站点 |
| | | List<BaojiGroupBattGroup> baoJiGroupListWithinBattGroupList = baoJiGroupBattGroupService.getBaoJiGroupListWithinBattGroupList(); |
| | |
| | | return new Response().setII(1,"删除完成"); |
| | | } |
| | | |
| | | @Transactional |
| | | public Response updateList(List<BattDischargePlanTemp> list) { |
| | | mapper.updateList(list); |
| | | return new Response().setII(1,"更新完成"); |
| | |
| | | Map<Integer, Map<Date, List<BattDischargePlanTemp>>> statusTimeMap = new HashMap<>(); |
| | | int userId = ActionUtil.getUser().getUId().intValue(); |
| | | QueryWrapper<BattDischargePlanTemp> query = Wrappers.query(); |
| | | query.eq("create_user_id",userId).eq("submit_status",1).orderByAsc("discharge_start_time"); |
| | | query.eq("create_user_id",userId).eq("submit_status",1).orderByAsc("id"); |
| | | List<BattDischargePlanTemp> list = mapper.selectList(query); |
| | | //按状态分 |
| | | Map<Integer, List<BattDischargePlanTemp>> statusMap = list.stream().collect(Collectors.groupingBy(BattDischargePlanTemp::getApproveStatus)); |
| | | Set<Integer> statusSet = statusMap.keySet(); |
| | | for (Integer status : statusSet) { |
| | | Map<Date, List<BattDischargePlanTemp>> listMapByTime = statusMap.get(status).stream().collect(Collectors.groupingBy(BattDischargePlanTemp::getDischargeStartTime)); |
| | | Map<Date, List<BattDischargePlanTemp>> listMapByTime = statusMap.get(status).stream().collect(Collectors.groupingBy(BattDischargePlanTemp::getCreateTime)); |
| | | statusTimeMap.put(status,listMapByTime); |
| | | } |
| | | return new Response().setII(1,statusTimeMap.keySet().size()>0,statusTimeMap,"查询完成"); |
| | |
| | | public Response getListMapByStatus() { |
| | | Map<Integer, Map<Date, List<BattDischargePlanTemp>>> statusTimeMap = new HashMap<>(); |
| | | QueryWrapper<BattDischargePlanTemp> query = Wrappers.query(); |
| | | query.eq("submit_status",1).orderByAsc("discharge_start_time"); |
| | | query.eq("submit_status",1).orderByAsc("id"); |
| | | List<BattDischargePlanTemp> list = mapper.selectList(query); |
| | | //按状态分 |
| | | Map<Integer, List<BattDischargePlanTemp>> statusMap = list.stream().collect(Collectors.groupingBy(BattDischargePlanTemp::getApproveStatus)); |
| | | Set<Integer> statusSet = statusMap.keySet(); |
| | | for (Integer status : statusSet) { |
| | | Map<Date, List<BattDischargePlanTemp>> listMapByTime = statusMap.get(status).stream().collect(Collectors.groupingBy(BattDischargePlanTemp::getDischargeStartTime)); |
| | | Map<Date, List<BattDischargePlanTemp>> listMapByTime = statusMap.get(status).stream().collect(Collectors.groupingBy(BattDischargePlanTemp::getCreateTime)); |
| | | statusTimeMap.put(status,listMapByTime); |
| | | } |
| | | return new Response().setII(1,statusTimeMap.keySet().size()>0,statusTimeMap,"查询完成"); |
| | | } |
| | | |
| | | /** |
| | | * 临时表审批状态变为已审批 |
| | | * |
| | | * @param approveStatus |
| | | * @param tempList |
| | | * @return |
| | | */ |
| | | public Response updateApproveDischargePlan(int approveStatus, List<BattDischargePlanTemp> tempList) { |
| | | UserInf user = ActionUtil.getUser(); |
| | | Date createTime = tempList.get(0).getCreateTime(); |
| | | updateApproveStatus(approveStatus,createTime,user.getUId().intValue()); |
| | | |
| | | if(approveStatus==1) { |
| | | planService.insertConfirmDischargePlan(tempList); |
| | | } |
| | | return new Response().setII(1,"审核完成"); |
| | | } |
| | | |
| | | |
| | | public void updateApproveStatus(int approveStatus, Date createTime, int approveUserId) { |
| | | UpdateWrapper<BattDischargePlanTemp> update = Wrappers.update(); |
| | | update.set("approve_status",approveStatus).set("approve_time",new Date()).set("approve_user_id",approveUserId).eq("create_time",createTime); |
| | | mapper.update(null,update); |
| | | } |
| | | } |