Commit 12533868 authored by litengwei's avatar litengwei

双规小程序接口

parent cab79c1f
......@@ -154,6 +154,44 @@ public class DateUtils {
return cal.getTime();
}
/**
* 获取某年某月的第一天日期
*
* @param date
* @param format
* @return
*/
public static Date getStartMonthDate(String date, String format) {
if (date == null || date.length() < 6 || format == null) {
return null;
}
int year = Integer.parseInt(date.substring(0, 4));
int month = Integer.parseInt(date.substring(5, 7));
Calendar calendar = Calendar.getInstance();
calendar.set(year, month - 1, 1);
return calendar.getTime();
}
/**
* 获取某年某月的最后一天日期
*
* @param date
* @param format
* @return
*/
public static Date getEndMonthDate(String date, String format) {
if (date == null || date.length() < 6 || format == null) {
return null;
}
int year = Integer.parseInt(date.substring(0, 4));
int month = Integer.parseInt(date.substring(5, 7));
Calendar calendar = Calendar.getInstance();
calendar.set(year, month - 1, 1);
int day = calendar.getActualMaximum(5);
calendar.set(year, month - 1, day);
return calendar.getTime();
}
/**
* 将长时间格式字符串转换为时间 yyyy-MM-dd HH:mm:ss
......@@ -619,6 +657,13 @@ public class DateUtils {
}
public static void main(String[] args) throws Exception {
Date startMonthDate = getStartMonthDate("2023-09", DATE_PATTERN);
// Calendar calendar = new GregorianCalendar();
// calendar.setTime(new Date());
// calendar.add(Calendar.DATE, 2);
// int i = calendar.get(Calendar.DAY_OF_WEEK) - 1;
System.out.println(dateFormat(startMonthDate,DATE_PATTERN));
/*System.out.println(dateTimeToDate(new Date()));
System.out.println(dateParse("2017-02-04 14:58:20", null));
System.out.println(dateTimeToDateStringIfTimeEndZero(new Date()));
......
......@@ -4,8 +4,8 @@ package com.yeejoin.amos.patrol.common.enums;
public enum PlanTaskTypeStatusEnum {
day("dayControl",1),
month("weeklySurvey",2),
year("monthlyScheduling",3),
week("weeklySurvey",2),
month("monthlyScheduling",3),
;
/**
......
......@@ -47,7 +47,7 @@ public interface CheckMapper extends BaseMapper {
*/
List<Map<String,Object>> calendarData(CheckRecordParam param);
List<Map<String,Object>> planCount(String checkTime, String orgCode,String type,String userId);
List<Map<String,Object>> planCount(String checkTime, String orgCode,String type,String userId, String startTime, String endTime);
List<Map<String, Object>> queryRecordByPointId(HashMap<String, Object> req);
......
......@@ -8,6 +8,7 @@ import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.yeejoin.amos.boot.biz.common.bo.DepartmentBo;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
......@@ -33,10 +34,7 @@ import com.yeejoin.amos.patrol.business.util.Toke;
import com.yeejoin.amos.patrol.business.vo.CheckAnalysisVo;
import com.yeejoin.amos.patrol.business.vo.CheckInfoVo;
import com.yeejoin.amos.patrol.business.vo.DefectVo;
import com.yeejoin.amos.patrol.common.enums.CheckStatusEnum;
import com.yeejoin.amos.patrol.common.enums.PointLevelEnum;
import com.yeejoin.amos.patrol.common.enums.PointStatusEnum;
import com.yeejoin.amos.patrol.common.enums.RuleTypeEnum;
import com.yeejoin.amos.patrol.common.enums.*;
import com.yeejoin.amos.patrol.core.common.response.*;
import com.yeejoin.amos.patrol.core.util.DateUtil;
import com.yeejoin.amos.patrol.core.util.StringUtil;
......@@ -58,6 +56,7 @@ import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
......@@ -484,6 +483,8 @@ public class CheckServiceImpl implements ICheckService {
if (!ObjectUtils.isEmpty(detail)) {
check = checkDao.findByPlanTaskIdAndPointId(requestParam.getPlanTaskId(), requestParam.getPointId());
planTask = planTaskDao.findById(requestParam.getPlanTaskId()).get();
Optional<PlanTaskDetail> planD = planTaskDetailDao.findById(Long.valueOf(detail.get("id").toString()));
taskDetail = planD.get();
routeParam.put("routeId", planTask.getRouteId());
routeParam.put("pointId", requestParam.getPointId());
......@@ -584,6 +585,9 @@ public class CheckServiceImpl implements ICheckService {
} else {
checkInput.setIsOk(CheckStatusEnum.QUALIFIED.getCode());
}
checkInput.setRoutePointItemId(item.getRoutePointItemId());
checkInput.setInputValue(item.getInputValue());
checkInput.setPointClassifyId(item.getClassifyIds());
......@@ -608,9 +612,12 @@ public class CheckServiceImpl implements ICheckService {
if (!ObjectUtils.isEmpty(error) && error.endsWith(";")) {
error.substring(0, error.length() - 1);
check.setIsOk(CheckStatusEnum.UNQUALIFIED.getCode());
taskDetail.setStatus(CheckStatusEnum.UNQUALIFIED.getCode());
} else {
check.setIsOk(CheckStatusEnum.QUALIFIED.getCode());
taskDetail.setStatus(CheckStatusEnum.QUALIFIED.getCode());
}
planTaskDetailDao.saveAndFlush(taskDetail);
check.setError(error);
check.setErrorClassify(StringUtils.join(errorClassifyNames.keySet(), ","));
//计划外巡检是否计分 ,计划内默认都是计分
......@@ -1245,9 +1252,36 @@ public class CheckServiceImpl implements ICheckService {
}
@Override
public Map<String, Object> checkCalendarNew(String checkTime, String orgCode,String type,String userId) {
public Map<String, Object> checkCalendarNew(String checkTime, String orgCode,String type,String userId) throws ParseException {
Map<String, Object> result = new HashMap<>();
List<Map<String, Object>> list = checkMapper.planCount(checkTime, orgCode, type, userId);
Calendar calendar = new GregorianCalendar();
String startTime = "" ;
String endTime = "";
if(type.equals(String.valueOf(PlanTaskTypeStatusEnum.week.getValue()))) {
Date startMonthDate = DateUtils.getStartMonthDate(checkTime, DateUtils.DATE_PATTERN);
Date endMonthDate = DateUtils.getEndMonthDate(checkTime, DateUtils.DATE_PATTERN);
calendar.setTime(startMonthDate);
int i = calendar.get(Calendar.DAY_OF_WEEK) - 1;
if (i == 0) {
calendar.add(Calendar.DAY_OF_WEEK,-6);
startTime = DateUtils.dateTimeToDateString(calendar.getTime());
} else if(i != 1) {
calendar.add(Calendar.DAY_OF_WEEK,-(i-1));
startTime = DateUtils.dateTimeToDateString(calendar.getTime());
}
calendar.setTime(endMonthDate);
int j = calendar.get(Calendar.DAY_OF_WEEK) - 1;
if (j != 0) {
calendar.add(Calendar.DAY_OF_WEEK,7-j);
endTime = DateUtils.dateTimeToDateString(calendar.getTime());
} else {
endTime = DateUtils.dateTimeToDateString(calendar.getTime());
}
}
List<Map<String, Object>> list = checkMapper.planCount(checkTime, orgCode, type, userId,startTime,endTime);
result.put("calendarData", list);
return result;
}
......
......@@ -1463,7 +1463,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
if(check != null) {
List<CheckShot> checkShots = iCheckShotDao.findAllByCheckIdAndCheckInputId(check.getId(),
0L);
List<String> photos = null;
List<String> photos = new ArrayList<>();
if (!org.springframework.util.CollectionUtils.isEmpty(checkShots)) {
photos = checkShots.stream().map(e -> {
if (e != null) {
......@@ -1505,7 +1505,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
List<CheckShot> checkShotsNew = iCheckShotDao.findAllByCheckIdAndCheckInputId(check.getId(),
action.getCheckInputId());
List<String> photosNew = null;
List<String> photosNew = new ArrayList<>();
if (!org.springframework.util.CollectionUtils.isEmpty(checkShotsNew)) {
photosNew = checkShotsNew.stream().map(e -> {
if (e != null) {
......
......@@ -18,6 +18,7 @@ import com.yeejoin.amos.patrol.exception.YeeException;
import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional;
import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -85,7 +86,7 @@ public interface ICheckService {
* @param requestParam
* @return
*/
Map<String, Object> checkCalendarNew(String time, String orgCode,String type,String userId);
Map<String, Object> checkCalendarNew(String time, String orgCode,String type,String userId) throws ParseException;
/**
* 根据点ID查询点巡检记录 手机APP
......
......@@ -568,7 +568,7 @@
WHERE
pl.plan_type = #{type}
<if test="type!=null and type==1">AND DATE_FORMAT(pt.check_date, '%Y-%m') = left(#{checkTime}, 7) </if>
<if test="type!=null and type==2">AND DATE_FORMAT(pt.check_date, '%Y-%m') = left(#{checkTime}, 7)</if>
<if test="type!=null and type==2">AND pt.check_date between #{startTime} and #{endTime} </if>
<if test="type!=null and type==3">AND DATE_FORMAT(pt.check_date, '%Y') = left(#{checkTime}, 4)</if>
<if test="userId!=null and userId!=0">AND FIND_IN_SET(#{userId}, pt.user_id)>0</if>
<!-- <if test="orgCode!=null">AND org_code LIKE #{orgCode}</if>-->
......
......@@ -8,7 +8,7 @@
<select id="findPlanTaskByTaskIdAndPointId" resultType="Map">
SELECT
p.name planName, pt.begin_time beginTime, pt.end_time endTime, pp.name pointName, pp.point_no pointNo, ptd.id planTaskDetailId, pt.route_id routeId, pr.name routeName
ptd.id , p.name planName, pt.begin_time beginTime, pt.end_time endTime, pp.name pointName, pp.point_no pointNo, ptd.id planTaskDetailId, pt.route_id routeId, pr.name routeName
FROM
p_plan_task pt
LEFT JOIN p_plan p ON pt.plan_id = p.id
......
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