Commit 95218239 authored by xinglei's avatar xinglei

重做计划增加修改nextGenDate字段

parent c2979340
......@@ -17,6 +17,7 @@ import com.yeejoin.amos.patrol.common.entity.Plan;
import com.yeejoin.amos.patrol.common.entity.PlanTask;
import com.yeejoin.amos.patrol.common.entity.PlanTaskDetail;
import com.yeejoin.amos.patrol.common.entity.UserModel;
import com.yeejoin.amos.patrol.common.enums.PlanTypeEnum;
import com.yeejoin.amos.patrol.service.business.bo.patrol.CheckChkExListBo;
import com.yeejoin.amos.patrol.service.business.bo.patrol.PointCheckDetailBo;
import com.yeejoin.amos.patrol.service.business.dao.mapper.PlanMapper;
......@@ -103,7 +104,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
private RemoteSecurityService remoteSecurityService;
@Override
public Page<HashMap<String, Object>> getPlanTaskInfo(String toke,String product,String appKey,PlanTaskPageParam params) {
public Page<HashMap<String, Object>> getPlanTaskInfo(String toke, String product, String appKey, PlanTaskPageParam params) {
long total = planTaskMapper.countPlanTask(params);
List<HashMap<String, Object>> content = planTaskMapper.getPlanTaskInfo(params);
......@@ -122,32 +123,23 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
List<String> userList = new ArrayList<>(set);
List<String> deptList = new ArrayList<>(deptIdSet);
Map<String, String> deptMap = new HashMap<>();
Map<String, String> userMap = new HashMap<>();
if (!CollectionUtils.isEmpty(userList)) {
userIds = String.join(",", userList);
List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds( toke, product, appKey,userIds);
List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds(toke, product, appKey, userIds);
userMap = userModelList.stream().collect(Collectors.toMap(AgencyUserModel::getUserId, AgencyUserModel::getRealName, (k1, k2) -> k2));
}
if (!CollectionUtils.isEmpty(deptList)) {
deptIds = String.join(",", deptList);
List<LinkedHashMap> deptBoList = remoteSecurityService.listDepartmentByDeptIds( toke, product, appKey,deptIds);
List<LinkedHashMap> deptBoList = remoteSecurityService.listDepartmentByDeptIds(toke, product, appKey, deptIds);
for (int i = 0; i < deptBoList.size(); i++) {
deptMap.put(deptBoList.get(i).get("sequenceNbr").toString(), deptBoList.get(i).get("departmentName").toString());
}
// deptMap = deptBoList.stream().collect(Collectors.toMap(DepartmentModel::getSequenceNbr, DepartmentModel::getDepartmentName));
deptMap.put(deptBoList.get(i).get("sequenceNbr").toString(), deptBoList.get(i).get("departmentName").toString());
}
// deptMap = deptBoList.stream().collect(Collectors.toMap(DepartmentModel::getSequenceNbr, DepartmentModel::getDepartmentName));
}
List<String> userNames = new ArrayList<>();
......@@ -169,7 +161,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
@Override
@Transactional(rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public void reGenPlanTask(HashMap<String, Object> param) throws ParseException {
//1.公共参数准备
String planId = param.get("planId").toString();//重做的计划编号id
......@@ -180,12 +172,9 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
if (plan == null) {
throw new YeeException("计划不存在");
}
if(plan.getStatus()==1){
throw new YeeException("1");
if (plan.getStatus() == 1) {
throw new YeeException("1");
}
//2.数据必输校验,不满足直接return,不再向下进行
Boolean fileFlag = PlanTaskUtil.checkMustFile(plan);
if (!fileFlag) {
......@@ -198,8 +187,6 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
if (null == vo) {//计划未开始,则结束
return;
}
if (!vo.getIsGenData()) {//日期不符合条件直接结束
return;
}
......@@ -220,6 +207,9 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
reformStatisticsPlanTask(strBginDate, strEndDate, plan.getUserId(), plan.getOrgCode());
//8、重新更新nextGenDate字段
plan.setNextGenDate(getNextDataByPlan(plan));
iplanDao.saveAndFlush(plan);
}
......@@ -266,25 +256,17 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
param.put("IDS", new ArrayList<>(taskNos));
param.put("FINISH_YES", XJConstant.PLAN_TASK_DET_FINISH_YES);
planTaskMapper.updatePlanTaskPtInfo(param);// 更新主表,点数量,完成数量
for (Long long1 : taskNos) {
int num= planTaskDetail.countByTaskNo( long1);
if(num<=0){
iplanTaskDao.deleteById(long1);
}
}
int num = planTaskDetail.countByTaskNo(long1);
if (num <= 0) {
iplanTaskDao.deleteById(long1);
}
}
}
@Override
public List<PlanTaskVo> planTaskReport(String toke,String product,String appKey,PlanTaskPageParam param) {
public List<PlanTaskVo> planTaskReport(String toke, String product, String appKey, PlanTaskPageParam param) {
List<PlanTaskVo> content = planTaskMapper.getPlanTaskInfoList(param);
Set<String> userIdSet = Sets.newHashSet(Lists.transform(content, PlanTaskVo::getUserName));
......@@ -298,15 +280,15 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
Map<String, String> userMap = new HashMap<>();
Map<String, String> deptMap = new HashMap<>();
if (!CollectionUtils.isEmpty(userIdSet)) {
List<AgencyUserModel> userModels = remoteSecurityService.listUserByUserIds(toke, product, appKey,Joiner.on(",").join(userIdSet));
List<AgencyUserModel> userModels = remoteSecurityService.listUserByUserIds(toke, product, appKey, Joiner.on(",").join(userIdSet));
userMap = userModels.stream().collect(Collectors.toMap(AgencyUserModel::getUserId, AgencyUserModel::getRealName, (k1, k2) -> k2));
}
if (!CollectionUtils.isEmpty(deptIdSet)) {
List<LinkedHashMap> departmentBos = remoteSecurityService.listDepartmentByDeptIds(toke, product, appKey,Joiner.on(",").join(deptIdSet));
List<LinkedHashMap> departmentBos = remoteSecurityService.listDepartmentByDeptIds(toke, product, appKey, Joiner.on(",").join(deptIdSet));
//deptMap = departmentBos.stream().collect(Collectors.toMap(DepartmentModel::getSequenceNbr, DepartmentModel::getDepartmentName));
for (int i = 0; i < departmentBos.size(); i++) {
deptMap.put(departmentBos.get(i).get("sequenceNbr").toString(), departmentBos.get(i).get("departmentName").toString());
}
deptMap.put(departmentBos.get(i).get("sequenceNbr").toString(), departmentBos.get(i).get("departmentName").toString());
}
}
List<String> userNames = new ArrayList<>();
......@@ -315,15 +297,13 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
content.forEach(e -> {
userNames.clear();
List<String> userIds1 = Arrays.asList(e.getUserName().split(","));
for(String userId : userIds1){
for (String userId : userIds1) {
userNames.add(finalUserMap1.get(userId));
}
userNames.remove(null);
e.setUserName(Joiner.on(",").join(userNames));
e.setDeptName(finalDeptMap1.get(String.valueOf(e.getDeptId())));
});
return content;
}
......@@ -387,16 +367,14 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
continue;
}
//2.4.删除今天可能重做生成的数据(计划重做后进行了计划的编辑)
if (iplanTaskDao.findById(plan.getPlanTaskId()) != null && plan.getFirstFlag() == XJConstant.PLAN_FIRST_STATUS_YES)
if(iplanTaskDao.existsById(plan.getPlanTaskId())){
iplanTaskDao.deleteById(plan.getPlanTaskId());
}
if (iplanTaskDao.existsById(plan.getPlanTaskId())) {
iplanTaskDao.deleteById(plan.getPlanTaskId());
}
//2.5.插入planTask及planTaskDetail
insertPlanTaskAndDet(list, plan, XJConstant.SCHED_FLAG, now);
}
}
......@@ -412,7 +390,6 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
for (long id : ids) {
iplanTaskDao.deleteById(id);
}
}
/**
......@@ -572,7 +549,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
@Override
public Page<HashMap<String, Object>> getPlanTasks(String toke,String product,String appKey,HashMap<String, Object> params) {
public Page<HashMap<String, Object>> getPlanTasks(String toke, String product, String appKey, HashMap<String, Object> params) {
CommonPageable pageParam = new CommonPageable();
List<HashMap<String, Object>> content = Lists.newArrayList();
long total = planTaskMapper.getPlanTasksCount(params);
......@@ -588,21 +565,21 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
userIds.add(userId);
}
});
List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds(toke, product, appKey,Joiner.on(",").join(userIds));
Map<String,String> userModelMap = userModelList.stream().collect(Collectors.toMap(AgencyUserModel::getUserId,AgencyUserModel::getRealName ,(k1,k2)->k2));
List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds(toke, product, appKey, Joiner.on(",").join(userIds));
Map<String, String> userModelMap = userModelList.stream().collect(Collectors.toMap(AgencyUserModel::getUserId, AgencyUserModel::getRealName, (k1, k2) -> k2));
List<String> userNames = new ArrayList<>();
content.forEach(e -> {
userNames.clear();
List<String> userIds1 = Arrays.asList(e.get("userId").toString().split(","));
for(String userId : userIds1){
for (String userId : userIds1) {
userNames.add(userModelMap.get(userId));
}
userNames.remove(null);
e.put("executiveName",Joiner.on(",").join(userNames));
e.put("executiveName", Joiner.on(",").join(userNames));
/*e.put("beginTime",new Date().getTime());
e.put("endTime",new Date().getTime());*/
});
}
return new PageImpl<>(content, pageParam, total);
......@@ -624,8 +601,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
@Override
public List<PlanTaskVo> getPlanTaskListByIds(String toke,String product,String appKey,Long[] ids) {
public List<PlanTaskVo> getPlanTaskListByIds(String toke, String product, String appKey, Long[] ids) {
List<PlanTaskVo> content = planTaskMapper.getPlanTaskListByIds(ids);
......@@ -640,15 +616,15 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
Map<String, String> userMap = new HashMap<>();
Map<String, String> deptMap = new HashMap<>();
if (!CollectionUtils.isEmpty(userIdSet)) {
List<AgencyUserModel> userModels = remoteSecurityService.listUserByUserIds(toke, product, appKey,Joiner.on(",").join(userIdSet));
List<AgencyUserModel> userModels = remoteSecurityService.listUserByUserIds(toke, product, appKey, Joiner.on(",").join(userIdSet));
userMap = userModels.stream().collect(Collectors.toMap(AgencyUserModel::getUserId, AgencyUserModel::getRealName, (k1, k2) -> k2));
}
if (!CollectionUtils.isEmpty(deptIdSet)) {
List<LinkedHashMap> departmentBos = remoteSecurityService.listDepartmentByDeptIds(toke, product, appKey,Joiner.on(",").join(deptIdSet));
List<LinkedHashMap> departmentBos = remoteSecurityService.listDepartmentByDeptIds(toke, product, appKey, Joiner.on(",").join(deptIdSet));
//deptMap = departmentBos.stream().collect(Collectors.toMap(DepartmentModel::getSequenceNbr, DepartmentModel::getDepartmentName));
for (int i = 0; i < departmentBos.size(); i++) {
deptMap.put(departmentBos.get(i).get("sequenceNbr").toString(), departmentBos.get(i).get("departmentName").toString());
}
for (int i = 0; i < departmentBos.size(); i++) {
deptMap.put(departmentBos.get(i).get("sequenceNbr").toString(), departmentBos.get(i).get("departmentName").toString());
}
}
List<String> userNames = new ArrayList<>();
......@@ -657,18 +633,14 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
content.forEach(e -> {
userNames.clear();
List<String> userIds1 = Arrays.asList(e.getUserName().split(","));
for(String userId : userIds1){
for (String userId : userIds1) {
userNames.add(finalUserMap1.get(userId));
}
userNames.remove(null);
e.setUserName(Joiner.on(",").join(userNames));
e.setDeptName(finalDeptMap1.get(String.valueOf(e.getDeptId())));
});
return content;
}
@Override
......@@ -685,11 +657,11 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
@Override
public AppPointCheckRespone queryPointPlanTaskDetail(String toke,String product,String appKey,Long planTaskId, Long pointId) {
public AppPointCheckRespone queryPointPlanTaskDetail(String toke, String product, String appKey, Long planTaskId, Long pointId) {
AppPointCheckRespone pointCheckRespone = new AppPointCheckRespone();
Check check = checkDao.findByPlanTaskIdAndPointId(planTaskId, pointId);
if (check != null) {
pointCheckRespone = checkService.queryCheckPointDetail( toke, product, appKey,check.getId());
pointCheckRespone = checkService.queryCheckPointDetail(toke, product, appKey, check.getId());
} else {
PointCheckDetailBo planPointInfo = planTaskMapper.getPointPlanTaskInfo(planTaskId, pointId);
if (planPointInfo != null) {
......@@ -751,121 +723,121 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
@Override
public PlanTask selectPlanTaskStatus(Long id) {
// TODO Auto-generated method stub
Optional<PlanTask> date=iplanTaskDao.findById(id);
if(iplanTaskDao.findById(id)!=null){
return date.get();
}else{
return null;
}
Optional<PlanTask> date = iplanTaskDao.findById(id);
if (iplanTaskDao.findById(id) != null) {
return date.get();
} else {
return null;
}
}
@Override
public CommonResponse startplan(List<String> ids) {
try {
List<Plan> plans = iplanDao.findByids(ids);
if (plans != null&&plans.size()>0) {
Plan plan =plans.get(0);
plan.setStatus(Byte.parseByte(XJConstant.PLAN_STATUS_START));
iplanDao.save(plan);
//1.公共参数准备
String planId =plan.getId()+"";//重做的计划编号id
SimpleDateFormat sdf1=new SimpleDateFormat("yyyy-MM-dd");
Date date=new Date();
Date datef = null;
try {
datef = sdf1.parse(plan.getPlanEnd());
date = sdf1.parse(sdf1.format(date));
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if(date.getTime()>datef.getTime()){
return CommonResponseUtil.failure("计划结束时间小于等于当前时间,计划不生成!");
}
String strBginDate=sdf1.format(date);
String strEndDate = plan.getPlanEnd();
plan.setPlanBegin(strBginDate);
String flag = "0";
if (plan == null) {
throw new YeeException("计划不存在");
}
if(plan.getStatus()==1){
throw new YeeException("1");
}
//2.数据必输校验,不满足直接return,不再向下进行
Boolean fileFlag = PlanTaskUtil.checkMustFile(plan);
if (!fileFlag) {
return CommonResponseUtil.failure();
}
//3.计算生成数据的日期区间(前10位:yyyy-MM-dd)
CalDateVo vo = PlanTaskUtil.reGenPlanTaskData(plan, strBginDate, strEndDate);
if (null == vo) {//计划未开始,则结束
return CommonResponseUtil.failure();
}
if (!vo.getIsGenData()) {//日期不符合条件直接结束
return CommonResponseUtil.failure();
}
//3.删除planTask表,按照计划id+日期
HashMap<String, Object> param =new HashMap<>();
param.put("beginDate",strBginDate);
param.put("endDate",strEndDate);
param.put("planId",planId);
deletePlanTaskAndDet(param);
//5.执行数据生成(具体时间 + 人员)
List<HashMap<String, Object>> list = genAllExeDate(plan, vo, XJConstant.REGEN_FLAG);
//6.插入planTask及planTaskDetail
insertPlanTaskAndDet(list, plan, flag, new Date());
//7.重新统计计划
if (ObjectUtils.isEmpty(plan.getUserId())) {
return CommonResponseUtil.failure();
}
try {
reformStatisticsPlanTask(strBginDate, strEndDate, plan.getUserId(), plan.getOrgCode());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} catch (Exception e) {
}
public CommonResponse startplan(List<String> ids) {
try {
List<Plan> plans = iplanDao.findByids(ids);
if (plans != null && plans.size() > 0) {
Plan plan = plans.get(0);
plan.setStatus(Byte.parseByte(XJConstant.PLAN_STATUS_START));
iplanDao.save(plan);
//1.公共参数准备
String planId = plan.getId() + "";//重做的计划编号id
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
Date datef = null;
try {
datef = sdf1.parse(plan.getPlanEnd());
date = sdf1.parse(sdf1.format(date));
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if (date.getTime() > datef.getTime()) {
return CommonResponseUtil.failure("计划结束时间小于等于当前时间,计划不生成!");
}
String strBginDate = sdf1.format(date);
String strEndDate = plan.getPlanEnd();
plan.setPlanBegin(strBginDate);
String flag = "0";
if (plan == null) {
throw new YeeException("计划不存在");
}
if (plan.getStatus() == 1) {
throw new YeeException("1");
}
//2.数据必输校验,不满足直接return,不再向下进行
Boolean fileFlag = PlanTaskUtil.checkMustFile(plan);
if (!fileFlag) {
return CommonResponseUtil.failure();
}
//3.计算生成数据的日期区间(前10位:yyyy-MM-dd)
CalDateVo vo = PlanTaskUtil.reGenPlanTaskData(plan, strBginDate, strEndDate);
if (null == vo) {//计划未开始,则结束
return CommonResponseUtil.failure();
}
if (!vo.getIsGenData()) {//日期不符合条件直接结束
return CommonResponseUtil.failure();
}
//3.删除planTask表,按照计划id+日期
HashMap<String, Object> param = new HashMap<>();
param.put("beginDate", strBginDate);
param.put("endDate", strEndDate);
param.put("planId", planId);
deletePlanTaskAndDet(param);
//5.执行数据生成(具体时间 + 人员)
List<HashMap<String, Object>> list = genAllExeDate(plan, vo, XJConstant.REGEN_FLAG);
//6.插入planTask及planTaskDetail
insertPlanTaskAndDet(list, plan, flag, new Date());
//7.重新统计计划
if (ObjectUtils.isEmpty(plan.getUserId())) {
return CommonResponseUtil.failure();
}
try {
reformStatisticsPlanTask(strBginDate, strEndDate, plan.getUserId(), plan.getOrgCode());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} catch (Exception e) {
}
return CommonResponseUtil.success();
}
}
/**
* 根据计划获取下一次执行时间
*
* @param plan
* @return
*/
private Date getNextDataByPlan(Plan plan) {
Date date = DateUtil.format();
switch (plan.getPlanType()) {
case "1":
date = DateUtil.getDateByNumber(date, plan.getExecuteInterval());
break;
case "2":
date = DateUtil.getDateByWeek(date, plan.getExecuteInterval());
break;
case "3":
date = DateUtil.getDateByMonth(date, plan.getExecuteInterval());
break;
}
return date;
}
}
......@@ -294,7 +294,5 @@ public class Safety3DDataSendServiceImpl implements ISafety3DDataSendService {
remoteSpcService.pushSpcCheckResult(checkResultPushSpcRequest);
return checkResultPushSpcRequest;
}
}
......@@ -589,6 +589,20 @@ public class DateUtil {
return cal.getTime();
}
public static Date getDateByWeek(Date date, Integer dayNumber) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.WEEK_OF_YEAR, dayNumber);
return cal.getTime();
}
public static Date getDateByMonth(Date date, Integer dayNumber) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.MONTH, dayNumber);
return cal.getTime();
}
public static Date getHourBeginOfDay(int hour) {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, hour);
......@@ -596,4 +610,14 @@ public class DateUtil {
cal.set(Calendar.SECOND, 0);
return cal.getTime();
}
/**
* 获取当前时间
*
* @return
*/
public static Date format() {
Date date = new Date();
return date;
}
}
......@@ -80,8 +80,6 @@ public class RemoteSecurityService {
}
//登录
public Toke come() {
IdPasswordAuthModel dPasswordAuthModel=new IdPasswordAuthModel();
dPasswordAuthModel.setLoginId(loginId);
dPasswordAuthModel.setPassword(password);
......@@ -97,7 +95,6 @@ public class RemoteSecurityService {
oked.setToke(map.get("token").toString());
oked.setProduct(productWeb);
oked.setAppKey(appKeyWeb);
}
......@@ -209,7 +206,7 @@ public class RemoteSecurityService {
if (userId == null || userId.equals("")) {
return null;
}
RequestContext.setToken(toke);
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
AgencyUserModel agencyUserModel=null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment