Commit 8a68b3d0 authored by lisong's avatar lisong

Merge branch 'develop_tzs_new_patrol' into develop_tzs_register

parents fe5366ab f48ba754
......@@ -140,6 +140,10 @@ public class ControllerAop {
// 验证token有效性,防止token失效
AgencyUserModel userModel;
try {
String authToken = RedisKey.buildReginKey(RequestContext.getExeUserId(), token);
if (redisUtils.hasKey(authToken)) {
return;
}
FeignClientResult<AgencyUserModel> agencyUserModel = Privilege.agencyUserClient.getme();
userModel = agencyUserModel.getResult();
if (userModel == null) {
......
......@@ -15,7 +15,9 @@ import java.util.List;
*/
public interface ThreeSystemsMapper extends BaseMapper<ThreeSystems> {
List<ThreeSystemsDto> getCompanyThreeSystemsStatisticsList(@Param("type") Integer type, @Param("startDay") String startDay, @Param("endDay") String endDay);
List<ThreeSystemsDto> getCompanyThreeSystemsStatisticsList(@Param("staticTableName") String staticTableName,
@Param("startDay") String startDay,
@Param("endDay") String endDay);
void saveOrUpdateBatch(@Param("resultList") List<ThreeSystems> resultList);
......
......@@ -28,5 +28,8 @@ public interface TzsTwoStaffingMapper extends BaseMapper<TzsTwoStaffing> {
void truncateTwoStaffingStatistics();
List<TzsTwoStaffing> getListByOrgCode(@Param("orgCode")String orgCode, @Param("type")String type, @Param("level")String level);
Page<TzsTwoStaffingCompanyCheckDto> getCompanyCheckList(@Param("page")Page<TzsTwoStaffingCompanyCheckDto> page, @Param("orgCode") String orgCode, @Param("companyDto")TzsTwoStaffingCompanyCheckDto companyDto);
Page<TzsTwoStaffingCompanyCheckDto> getCompanyCheckList(@Param("page")Page<TzsTwoStaffingCompanyCheckDto> page,
@Param("orgCode") String orgCode,
@Param("staticTableName") String staticTableName,
@Param("companyDto")TzsTwoStaffingCompanyCheckDto companyDto);
}
......@@ -10,27 +10,26 @@
ei.supervise_org_code supervisoryUnitOrgCode,
ei.unit_type unitType,
CASE
WHEN (
SELECT COUNT
( 1 )
FROM
amos_tzs_biz.p_plan_task pt
${staticTableName} pt
WHERE
pt.finish_status = '2'
AND ppt.use_code = pt.use_code
AND pt.check_date BETWEEN #{startDay}
pt.not_start = 0
AND pt.time_out = 0
AND (pt.risk_end > 0 or pt.no_risk_end > 0)
AND psd.unit_code = pt.unit_code
AND pt.check_time BETWEEN #{startDay}
AND #{endDay}
AND pt.plan_type = #{type}
) > 0 THEN
1 ELSE 0
END AS checkStatus
FROM
amos_tzs_biz.tz_base_enterprise_info ei
LEFT JOIN amos_tzs_biz.p_plan_task ppt ON ei.use_code = ppt.use_code
tz_base_enterprise_info ei
LEFT JOIN ${staticTableName} psd ON ei.use_code = psd.unit_code
GROUP BY
ei.use_code
</select>
<select id="saveOrUpdateBatch">
......
......@@ -65,19 +65,19 @@
ei.legal_person,
ei.contact_phone,
CASE
WHEN ( SELECT COUNT ( 1 ) FROM amos_tzs_biz.p_plan_task pt WHERE pt.finish_status = '3' AND ppt.use_code = pt.use_code AND pt.plan_type = #{companyDto.planType} AND pt.check_date BETWEEN #{companyDto.checkStartTime} AND #{companyDto.checkEndTime} ) > 0 THEN
WHEN ( SELECT COUNT ( 1 ) FROM ${staticTableName} pt WHERE pt.time_out > 0 AND psd.unit_code = ei.use_code AND pt.check_time BETWEEN #{companyDto.checkStartTime} AND #{companyDto.checkEndTime} ) > 0 THEN
'超期未检'
WHEN ( SELECT COUNT ( 1 ) FROM amos_tzs_biz.p_plan_task pt WHERE (pt.finish_status = '0' OR pt.finish_status = '1') AND ppt.use_code = pt.use_code AND pt.plan_type = #{companyDto.planType} AND pt.check_date BETWEEN #{companyDto.checkStartTime} AND #{companyDto.checkEndTime} ) > 0 THEN
WHEN ( SELECT COUNT ( 1 ) FROM ${staticTableName} pt WHERE pt.not_start > 0 AND psd.unit_code = ei.use_code AND pt.check_time BETWEEN #{companyDto.checkStartTime} AND #{companyDto.checkEndTime} ) > 0 THEN
'未完成'
WHEN ( SELECT COUNT ( 1 ) FROM amos_tzs_biz.p_plan_task pt WHERE pt.finish_status = '2' AND pt.risk_status = '1' AND ppt.use_code = pt.use_code AND pt.plan_type = #{companyDto.planType} AND pt.check_date BETWEEN #{companyDto.checkStartTime} AND #{companyDto.checkEndTime} ) > 0 THEN
WHEN ( SELECT COUNT ( 1 ) FROM ${staticTableName} pt WHERE pt.risk_end > 0 AND psd.unit_code = ei.use_code AND pt.check_time BETWEEN #{companyDto.checkStartTime} AND #{companyDto.checkEndTime} ) > 0 THEN
'已完成有风险'
WHEN ( SELECT COUNT ( 1 ) FROM amos_tzs_biz.p_plan_task pt WHERE pt.finish_status = '2' AND pt.risk_status = '2' AND ppt.use_code = pt.use_code AND pt.plan_type = #{companyDto.planType} AND pt.check_date BETWEEN #{companyDto.checkStartTime} AND #{companyDto.checkEndTime} ) > 0 THEN
WHEN ( SELECT COUNT ( 1 ) FROM ${staticTableName} pt WHERE pt.no_risk_end > 0 AND psd.unit_code = ei.use_code AND pt.check_time BETWEEN #{companyDto.checkStartTime} AND #{companyDto.checkEndTime} ) > 0 THEN
'已完成无风险'
ELSE '无任务'
END AS checkStatus
FROM
amos_tzs_biz.tz_base_enterprise_info ei
LEFT JOIN amos_tzs_biz.p_plan_task ppt ON ei.use_code = ppt.use_code
tz_base_enterprise_info ei
LEFT JOIN ${staticTableName} psd ON ei.use_code = psd.unit_code
WHERE
ei.supervise_org_code like concat(#{orgCode},'%')
<if test="companyDto.useUnit != '' and companyDto.useUnit != null">
......@@ -94,7 +94,5 @@
and tt.checkStatus = #{companyDto.checkStatus}
</if>
</where>
</select>
</mapper>
......@@ -24,7 +24,7 @@ import java.util.LinkedHashMap;
import java.util.List;
@RestController
@Api(tags = "三个规定统计")
@Api(tags = "三个制度统计")
@RequestMapping(value = "/threeProvisions")
public class ThreeSystemsController<string> extends BaseController {
private static final String REGULATOR_UNIT_TREE = "REGULATOR_UNIT_TREE";
......
......@@ -103,230 +103,236 @@ public class ThreeSystemsServiceImpl extends BaseService<ThreeSystemsDto, ThreeS
}
@Override
public void getThreeSystemsStatistics(String type) {
if (type.equals("1")) {
createDayThreeSystemsStatistics();
} else if (type.equals("2")) {
createWeekThreeSystemsStatistics();
} else if (type.equals("3")) {
createMonthThreeSystemsStatistics();
}
}
@Scheduled(cron = "0 0 2,13 * * ?")
@SchedulerLock(name = "createDayThreeSystemsStatistics", lockAtMostFor = "PT1H")
public void createDayThreeSystemsStatistics() {
createThreeSystemsStatistics(1, false);
}
@Scheduled(cron = "0 0 2,13 * * ?")
@SchedulerLock(name = "createWeekThreeSystemsStatistics", lockAtMostFor = "PT1H")
public void createWeekThreeSystemsStatistics() {
Date nowDay = new Date();
String day = DateUtils.convertDateToString(nowDay, DateUtils.DATE_HOUR_PATTERN);
Calendar c = DateUtils.getCalendar();
c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
String monday = DateUtils.convertDateToString(c.getTime(), DateUtils.DATE_HOUR_PATTERN);
Boolean flag = false;
//判断今天是否本周第一天凌晨2点,如果是则最后一次更新上月数据
if (day.equals(monday)) {
flag = true;
}
createThreeSystemsStatistics(2, flag);
}
@Scheduled(cron = "0 0 2,13 * * ?")
@SchedulerLock(name = "createMonthThreeSystemsStatistics", lockAtMostFor = "PT1H")
public void createMonthThreeSystemsStatistics() {
Date nowDay = new Date();
String day = DateUtils.convertDateToString(nowDay, DateUtils.DATE_HOUR_PATTERN);
String monthday = DateUtils.convertDateToString(nowDay, DateUtils.MONTH_PATTERN) + "-01 02";
Boolean flag = false;
//判断今天是否本月第一天凌晨2点,如果是则最后一次更新上月数据
if (day.equals(monthday)) {
flag = true;
}
createThreeSystemsStatistics(3, flag);
}
private void createThreeSystemsStatistics(Integer type, Boolean isFirstDay) {
// 所有监管单位列表
List<LinkedHashMap<String, Object>> supervisionList = tzsTwoStaffingService.getSupervisionList();
List<ThreeSystems> resultList;
// 所有企业排查情况列表(昨天/上周/上月)
List<ThreeSystemsDto> oldStaffingCompanyList;
// 所有企业排查情况列表(今天/本周/本月)
List<ThreeSystemsDto> newStaffingCompanyList;
String start = " 00:00:00";
String end = " 23:59:59";
Date nowDay = new Date();
String day = DateUtils.getDateNowShortStr();
String hour = DateUtils.convertDateToString(nowDay, DateUtils.DATE_HOUR_PATTERN);
String startDay = "";
String endDay = "";
String lastStart = "";
String lastEnd = "";
// 根据类型设置不同的时间
if (1 == type) {
startDay = day + start;
endDay = day + end;
if (hour.endsWith("02")) {
LocalDate today = LocalDate.now();
// 获取昨天日期
LocalDate yesterday = today.minusDays(1);
lastStart = yesterday + start;
lastEnd = yesterday + end;
}
} else if (2 == type) {
//获取当前周第一天:
Calendar c = DateUtils.getCalendar();
c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
startDay = DateUtils.convertDateToString(c.getTime(), DateUtils.DATE_PATTERN) + start;
//获取当前周最后一天
c.add(Calendar.DAY_OF_WEEK, 6);
endDay = DateUtils.convertDateToString(c.getTime(), DateUtils.DATE_PATTERN) + end;
if (isFirstDay) {
//获取上前周第一天
c.add(Calendar.DAY_OF_WEEK, -13);
lastStart = DateUtils.convertDateToString(c.getTime(), DateUtils.DATE_PATTERN) + start;
//获取上前周最后一天
c.add(Calendar.DAY_OF_WEEK, 6);
lastEnd = DateUtils.convertDateToString(c.getTime(), DateUtils.DATE_PATTERN) + end;
}
} else {
//获取当前月第一天:
Calendar c = DateUtils.getCalendar();
c.add(Calendar.MONTH, 0);
c.set(Calendar.DAY_OF_MONTH, 1);//设置为1号,当前日期既为本月第一天
startDay = DateUtils.convertDateToString(c.getTime(), DateUtils.DATE_PATTERN) + start;
//获取当前月最后一天
c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH));
endDay = DateUtils.convertDateToString(c.getTime(), DateUtils.DATE_PATTERN) + end;
if (isFirstDay) {
//获取上月第一天
c.add(Calendar.MONTH, -1);
c.set(Calendar.DAY_OF_MONTH, 1);//设置为1号,当前日期既为本月第一天
lastStart = DateUtils.convertDateToString(c.getTime(), DateUtils.DATE_PATTERN) + start;
//获取上月最后一天
c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH));
lastEnd = DateUtils.convertDateToString(c.getTime(), DateUtils.DATE_PATTERN) + end;
}
}
//获取当天、本周、本月新的数据
newStaffingCompanyList = threeSystemsMapper.getCompanyThreeSystemsStatisticsList(type, startDay, endDay);
//调用三项制度统计方法处理数据
resultList = getThreeSystems(supervisionList, newStaffingCompanyList, type, startDay, true);
//将新数据存入统计表中
threeSystemsMapper.saveOrUpdateBatch(resultList);
List<ThreeSystems> oldList;
//根据lastStart和lastEnd判断是否需要更新日/周/月的历史数据(为空不更新)
if (!"".equals(lastStart) && !"".equals(lastEnd)) {
//获取日/周/月的历史数据
oldStaffingCompanyList = threeSystemsMapper.getOldCompanyThreeSystemsStatisticsList(type, DateUtils.dateToString(lastStart));
//获取日/周/月历史数据的最新状态数据
List<ThreeSystemsDto> oldNewStaffingCompanyList = threeSystemsMapper.getCompanyThreeSystemsStatisticsList(type, lastStart, lastEnd);
if (!ValidationUtil.isEmpty(oldNewStaffingCompanyList)) {
// 调用三项制度统计方法处理数据
oldList = ValidationUtil.isEmpty(oldStaffingCompanyList) ?
getThreeSystems(supervisionList, oldNewStaffingCompanyList, type, lastStart, true) :
getThreeSystems(supervisionList, oldNewStaffingCompanyList, type, lastStart, false);
//如果历史数据不为空,更新历史数据实体
if (!ValidationUtil.isEmpty(oldStaffingCompanyList)) {
if (!ValidationUtil.isEmpty(oldList)) {
for (ThreeSystems e : oldList) {
ThreeSystemsDto threeSystemsDto = oldStaffingCompanyList.stream().filter(i ->
i.getSupervisoryUnitOrgCode().equals(e.getSupervisoryUnitOrgCode()) &&
i.getCheckDate().equals(e.getCheckDate())).collect(Collectors.toList()).get(0);
e.setSequenceNbr(threeSystemsDto.getSequenceNbr());
}
}
}
//更新统计表历史数据
threeSystemsMapper.saveOrUpdateBatch(oldList);
}
}
}
/**
* 三项制度统计数据方法
* @param supervisionList 行政区划列表
* @param StaffingCompanyList 需要统计处理的数据列表
* @param type 统计类型
* @param date 统计日期,做筛选用,日统计传当天日期,周统计传周一日期,月统计传月一号日期
* @param isNew 是否新数据,新数据会生成主键
* @return
*/
private List<ThreeSystems> getThreeSystems(List<LinkedHashMap<String, Object>> supervisionList,
List<ThreeSystemsDto> StaffingCompanyList,
Integer type,
String date,
boolean isNew) {
List<ThreeSystems> resultList = new ArrayList<>();
supervisionList.forEach(i -> {
ThreeSystemsDto nowDayThreeSystemsDto = new ThreeSystemsDto();
//对应orgCode下所有注册企业列表
List<ThreeSystemsDto> allUnit = StaffingCompanyList.stream().filter(ii -> ii.getSupervisoryUnitOrgCode().startsWith(i.get("orgCode").toString())).collect(Collectors.toList());
//对应注册企业下所有应排查的企业列表
List<ThreeSystemsDto> shouldCheckUnit = allUnit.stream().filter(ii -> !(ii.getUnitType().contains("个人主体") || ii.getUnitType().equals("检验检测机构"))).collect(Collectors.toList());
//应排查的企业下已排查完成的企业列表
List<ThreeSystemsDto> checkCompleteUnit = shouldCheckUnit.stream().filter(ii -> "1".equals(ii.getCheckStatus())).collect(Collectors.toList());
if (isNew) {
try {
nowDayThreeSystemsDto.setSequenceNbr(IdWorker.getFlowIdWorkerInstance().nextId());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
nowDayThreeSystemsDto.setRecDate(new Date());
nowDayThreeSystemsDto.setRecUserId(amosRequestContext.getUserId());
nowDayThreeSystemsDto.setRecUserName(amosRequestContext.getUserName());
nowDayThreeSystemsDto.setIsDelete(false);
nowDayThreeSystemsDto.setSupervisoryUnitId(i.get("sequenceNbr").toString());
nowDayThreeSystemsDto.setSupervisoryUnitLevel(i.get("level").toString());
nowDayThreeSystemsDto.setSupervisoryUnitName(i.get("companyName").toString());
nowDayThreeSystemsDto.setRegisteredNum(allUnit.size());
nowDayThreeSystemsDto.setCheckNum(shouldCheckUnit.size());
nowDayThreeSystemsDto.setFinishCheckNum(checkCompleteUnit.size());
nowDayThreeSystemsDto.setSupervisoryUnitOrgCode(i.get("orgCode").toString());
nowDayThreeSystemsDto.setPlanType(1 == type ? "1" : 2 == type ? "2" : "3");
nowDayThreeSystemsDto.setCheckDate(DateUtils.dateToString(date));
if (shouldCheckUnit.size() == 0) {
nowDayThreeSystemsDto.setProportion("0%");
} else {
DecimalFormat decimalFormat = new DecimalFormat("0.##");
BigDecimal result = new BigDecimal(checkCompleteUnit.size()).divide(new BigDecimal(shouldCheckUnit.size()), 4, RoundingMode.HALF_UP);
nowDayThreeSystemsDto.setProportion(decimalFormat.format(result.multiply(new BigDecimal(100))) + "%");
}
ThreeSystems threeSystems = new ThreeSystems();
BeanUtils.copyProperties(nowDayThreeSystemsDto, threeSystems);
resultList.add(threeSystems);
});
return resultList;
}
@Override
public void getThreeSystemsStatistics(String type) {
if (type.equals("1")) {
createDayThreeSystemsStatistics();
} else if (type.equals("2")) {
createWeekThreeSystemsStatistics();
} else if (type.equals("3")) {
createMonthThreeSystemsStatistics();
}
}
@Scheduled(cron = "0 0 2,13 * * ?")
@SchedulerLock(name = "createDayThreeSystemsStatistics", lockAtMostFor = "PT1H")
public void createDayThreeSystemsStatistics() {
createThreeSystemsStatistics(1, false);
}
@Scheduled(cron = "0 0 2,13 * * ?")
@SchedulerLock(name = "createWeekThreeSystemsStatistics", lockAtMostFor = "PT1H")
public void createWeekThreeSystemsStatistics() {
Date nowDay = new Date();
String day = DateUtils.convertDateToString(nowDay, DateUtils.DATE_HOUR_PATTERN);
Calendar c = DateUtils.getCalendar();
c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
String monday = DateUtils.convertDateToString(c.getTime(), DateUtils.DATE_HOUR_PATTERN);
Boolean flag = false;
//判断今天是否本周第一天凌晨2点,如果是则最后一次更新上月数据
if (day.equals(monday)) {
flag = true;
}
createThreeSystemsStatistics(2, flag);
}
@Scheduled(cron = "0 0 2,13 * * ?")
@SchedulerLock(name = "createMonthThreeSystemsStatistics", lockAtMostFor = "PT1H")
public void createMonthThreeSystemsStatistics() {
Date nowDay = new Date();
String day = DateUtils.convertDateToString(nowDay, DateUtils.DATE_HOUR_PATTERN);
String monthday = DateUtils.convertDateToString(nowDay, DateUtils.MONTH_PATTERN) + "-01 02";
Boolean flag = false;
//判断今天是否本月第一天凌晨2点,如果是则最后一次更新上月数据
if (day.equals(monthday)) {
flag = true;
}
createThreeSystemsStatistics(3, flag);
}
private void createThreeSystemsStatistics(Integer type, Boolean isFirstDay) {
// 所有监管单位列表
List<LinkedHashMap<String, Object>> supervisionList = tzsTwoStaffingService.getSupervisionList();
List<ThreeSystems> resultList;
// 所有企业排查情况列表(昨天/上周/上月)
List<ThreeSystemsDto> oldStaffingCompanyList;
// 所有企业排查情况列表(今天/本周/本月)
List<ThreeSystemsDto> newStaffingCompanyList;
String start = " 00:00:00";
String end = " 23:59:59";
Date nowDay = new Date();
String day = DateUtils.getDateNowShortStr();
String hour = DateUtils.convertDateToString(nowDay, DateUtils.DATE_HOUR_PATTERN);
String startDay = "";
String endDay = "";
String lastStart = "";
String lastEnd = "";
// 根据类型设置不同的时间
if (1 == type) {
startDay = day + start;
endDay = day + end;
if (hour.endsWith("02")) {
LocalDate today = LocalDate.now();
// 获取昨天日期
LocalDate yesterday = today.minusDays(1);
lastStart = yesterday + start;
lastEnd = yesterday + end;
}
} else if (2 == type) {
//获取当前周第一天:
Calendar c = DateUtils.getCalendar();
c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
startDay = DateUtils.convertDateToString(c.getTime(), DateUtils.DATE_PATTERN) + start;
//获取当前周最后一天
c.add(Calendar.DAY_OF_WEEK, 6);
endDay = DateUtils.convertDateToString(c.getTime(), DateUtils.DATE_PATTERN) + end;
if (isFirstDay) {
//获取上前周第一天
c.add(Calendar.DAY_OF_WEEK, -13);
lastStart = DateUtils.convertDateToString(c.getTime(), DateUtils.DATE_PATTERN) + start;
//获取上前周最后一天
c.add(Calendar.DAY_OF_WEEK, 6);
lastEnd = DateUtils.convertDateToString(c.getTime(), DateUtils.DATE_PATTERN) + end;
}
} else {
//获取当前月第一天:
Calendar c = DateUtils.getCalendar();
c.add(Calendar.MONTH, 0);
c.set(Calendar.DAY_OF_MONTH, 1);//设置为1号,当前日期既为本月第一天
startDay = DateUtils.convertDateToString(c.getTime(), DateUtils.DATE_PATTERN) + start;
//获取当前月最后一天
c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH));
endDay = DateUtils.convertDateToString(c.getTime(), DateUtils.DATE_PATTERN) + end;
if (isFirstDay) {
//获取上月第一天
c.add(Calendar.MONTH, -1);
c.set(Calendar.DAY_OF_MONTH, 1);//设置为1号,当前日期既为本月第一天
lastStart = DateUtils.convertDateToString(c.getTime(), DateUtils.DATE_PATTERN) + start;
//获取上月最后一天
c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH));
lastEnd = DateUtils.convertDateToString(c.getTime(), DateUtils.DATE_PATTERN) + end;
}
}
// todo 此处统计表名通过接口查询得到 接口暂未实现
String planType = type.toString();
String staticTableName = "p_static_day";
//获取当天、本周、本月新的数据
newStaffingCompanyList = threeSystemsMapper.getCompanyThreeSystemsStatisticsList(staticTableName, startDay, endDay);
//调用三项制度统计方法处理数据
resultList = getThreeSystems(supervisionList, newStaffingCompanyList, type, startDay, true);
//将新数据存入统计表中
threeSystemsMapper.saveOrUpdateBatch(resultList);
List<ThreeSystems> oldList;
//根据lastStart和lastEnd判断是否需要更新日/周/月的历史数据(为空不更新)
if (!"".equals(lastStart) && !"".equals(lastEnd)) {
//获取日/周/月的历史数据
oldStaffingCompanyList = threeSystemsMapper.getOldCompanyThreeSystemsStatisticsList(type, DateUtils.dateToString(lastStart));
//获取日/周/月历史数据的最新状态数据
// todo 此处统计表名通过接口查询得到 接口暂未实现
List<ThreeSystemsDto> oldNewStaffingCompanyList = threeSystemsMapper.getCompanyThreeSystemsStatisticsList(staticTableName, lastStart, lastEnd);
if (!ValidationUtil.isEmpty(oldNewStaffingCompanyList)) {
// 调用三项制度统计方法处理数据
oldList = ValidationUtil.isEmpty(oldStaffingCompanyList) ?
getThreeSystems(supervisionList, oldNewStaffingCompanyList, type, lastStart, true) :
getThreeSystems(supervisionList, oldNewStaffingCompanyList, type, lastStart, false);
//如果历史数据不为空,更新历史数据实体
if (!ValidationUtil.isEmpty(oldStaffingCompanyList)) {
if (!ValidationUtil.isEmpty(oldList)) {
for (ThreeSystems e : oldList) {
ThreeSystemsDto threeSystemsDto = oldStaffingCompanyList.stream().filter(i ->
i.getSupervisoryUnitOrgCode().equals(e.getSupervisoryUnitOrgCode()) &&
i.getCheckDate().equals(e.getCheckDate())).collect(Collectors.toList()).get(0);
e.setSequenceNbr(threeSystemsDto.getSequenceNbr());
}
}
}
//更新统计表历史数据
threeSystemsMapper.saveOrUpdateBatch(oldList);
}
}
}
/**
* 三项制度统计数据方法
*
* @param supervisionList 行政区划列表
* @param StaffingCompanyList 需要统计处理的数据列表
* @param type 统计类型
* @param date 统计日期,做筛选用,日统计传当天日期,周统计传周一日期,月统计传月一号日期
* @param isNew 是否新数据,新数据会生成主键
* @return
*/
private List<ThreeSystems> getThreeSystems(List<LinkedHashMap<String, Object>> supervisionList,
List<ThreeSystemsDto> StaffingCompanyList,
Integer type,
String date,
boolean isNew) {
List<ThreeSystems> resultList = new ArrayList<>();
supervisionList.forEach(i -> {
ThreeSystemsDto nowDayThreeSystemsDto = new ThreeSystemsDto();
//对应orgCode下所有注册企业列表
List<ThreeSystemsDto> allUnit = StaffingCompanyList.stream().filter(ii -> ii.getSupervisoryUnitOrgCode().startsWith(i.get("orgCode").toString())).collect(Collectors.toList());
//对应注册企业下所有应排查的企业列表
List<ThreeSystemsDto> shouldCheckUnit = allUnit.stream().filter(ii -> !(ii.getUnitType().contains("个人主体") || ii.getUnitType().equals("检验检测机构"))).collect(Collectors.toList());
//应排查的企业下已排查完成的企业列表
List<ThreeSystemsDto> checkCompleteUnit = shouldCheckUnit.stream().filter(ii -> "1".equals(ii.getCheckStatus())).collect(Collectors.toList());
if (isNew) {
try {
nowDayThreeSystemsDto.setSequenceNbr(IdWorker.getFlowIdWorkerInstance().nextId());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
nowDayThreeSystemsDto.setRecDate(new Date());
nowDayThreeSystemsDto.setRecUserId(amosRequestContext.getUserId());
nowDayThreeSystemsDto.setRecUserName(amosRequestContext.getUserName());
nowDayThreeSystemsDto.setIsDelete(false);
nowDayThreeSystemsDto.setSupervisoryUnitId(i.get("sequenceNbr").toString());
nowDayThreeSystemsDto.setSupervisoryUnitLevel(i.get("level").toString());
nowDayThreeSystemsDto.setSupervisoryUnitName(i.get("companyName").toString());
nowDayThreeSystemsDto.setRegisteredNum(allUnit.size());
nowDayThreeSystemsDto.setCheckNum(shouldCheckUnit.size());
nowDayThreeSystemsDto.setFinishCheckNum(checkCompleteUnit.size());
nowDayThreeSystemsDto.setSupervisoryUnitOrgCode(i.get("orgCode").toString());
nowDayThreeSystemsDto.setPlanType(1 == type ? "1" : 2 == type ? "2" : "3");
nowDayThreeSystemsDto.setCheckDate(DateUtils.dateToString(date));
if (shouldCheckUnit.size() == 0) {
nowDayThreeSystemsDto.setProportion("0%");
} else {
DecimalFormat decimalFormat = new DecimalFormat("0.##");
BigDecimal result = new BigDecimal(checkCompleteUnit.size()).divide(new BigDecimal(shouldCheckUnit.size()), 4, RoundingMode.HALF_UP);
nowDayThreeSystemsDto.setProportion(decimalFormat.format(result.multiply(new BigDecimal(100))) + "%");
}
ThreeSystems threeSystems = new ThreeSystems();
BeanUtils.copyProperties(nowDayThreeSystemsDto, threeSystems);
resultList.add(threeSystems);
});
return resultList;
}
}
\ No newline at end of file
......@@ -155,7 +155,10 @@ public class TzsTwoStaffingServiceImpl extends BaseService<TzsTwoStaffingDto, Tz
companyDto.setPlanType(ObjectUtils.isEmpty(companyDto.getPlanType()) ? "1" : companyDto.getPlanType());
companyDto.setCheckStartTime(ObjectUtils.isEmpty(companyDto.getCheckStartTime()) ? startDay : companyDto.getCheckStartTime());
companyDto.setCheckEndTime(ObjectUtils.isEmpty(companyDto.getCheckEndTime()) ? endDay : companyDto.getCheckEndTime());
return tzsTwoStaffingMapper.getCompanyCheckList(page, orgCode, companyDto);
// todo 此处统计表名通过接口查询得到 接口暂未实现
String planType = companyDto.getPlanType();
String staticTableName = "p_static_day";
return tzsTwoStaffingMapper.getCompanyCheckList(page, orgCode, staticTableName, companyDto);
}
......
......@@ -4,7 +4,10 @@ import java.util.List;
public class AppCheckInputRespone{
private String inputName;
private String pointId;
private String pointInputItemId;
private String inputValue;
private String inputStatus;
......@@ -24,7 +27,12 @@ public class AppCheckInputRespone{
public String getDefaultValue() {
return defaultValue;
}
public String getPointInputItemId() {
return pointInputItemId;
}
public String getPointId() {
return pointId;
}
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
......
......@@ -9,7 +9,10 @@ import java.util.List;
public class AppPointCheckRespone {
private long id;
private long pointId;
private long planTaskId;
private String pointName;
......@@ -175,11 +178,26 @@ public class AppPointCheckRespone {
public long getPointId() {
return pointId;
}
public long getPlanTaskId() {
return planTaskId;
}
public long getId() {
return id;
}
public void setPointId(long pointId) {
this.pointId = pointId;
}
public void setId(long id) {
this.id = id;
}
public void setPlanTaskId(long planTaskId) {
this.planTaskId = planTaskId;
}
public String getRemark() {
return remark;
}
......
package com.yeejoin.amos.patrol.dao.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.data.annotation.CreatedDate;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* The persistent class for the p_check database table.
*
*/
@Entity
@Table(name="p_check_history")
public class CheckHistory implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 参考地址
*/
@Column(name="address")
private String address;
/**
* 巡检方式
*/
@Column(name="check_mode")
private String checkMode="";
/**
* 检查时间
*/
@Temporal(TemporalType.TIMESTAMP)
@Column(name="check_time")
private Date checkTime;
/**
* 设备编号
*/
@Column(name="device_id")
private String deviceId;
/**
* 不合格项目
*/
private String error;
/**
* 是否合格
*/
@Column(name="is_ok")
private String isOk;
/**
* 经度
*/
private String latitude;
/**
* 纬度
*/
private String longitude;
/**
* 权限系统org code
*/
@Column(name="org_code")
private String orgCode;
/**
* 计划编号
*/
@Column(name="plan_id")
private Long planId;
/**
* 线路名称
*/
@Column(name="plan_name")
private String planName;
/**
* 计划执行编号
*/
@Column(name="plan_task_id")
private Long planTaskId;
/**
* 执行计划详情id
*/
@Column(name="plan_task_detail_id")
private Long planTaskDetailId;
/**
* 巡检点id
*/
@Column(name="point_id")
private Long pointId;
/**
* 点名称
*/
@Column(name="point_name")
private String pointName;
/**
* 巡检备注说明
*/
private String remark;
/**
* 路线编号
*/
@Column(name="route_id")
private Long routeId;
/**
* 路线名称
*/
@Column(name="route_name")
private String routeName;
/**
* 评分
*/
private int score;
/**
* 拍照数量
*/
@Column(name="shot_number")
private int shotNumber;
/**
* 记录上传时间
*/
@Temporal(TemporalType.TIMESTAMP)
@Column(name="upload_time")
private Date uploadTime;
/**
* 巡检人ids
*/
@Column(name="user_id")
private String userId;
/**
* 执行人名称
*/
@Column(name="user_name")
private String userName;
/**
* 执行部门ids
*/
@Column(name="dep_id")
private String depId;
/**
* 执行部门名称
*/
@Column(name="dep_name")
private String depName;
@Column(name="error_classify")
private String errorClassify;
public CheckHistory() {
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getDepId() {
return depId;
}
public void setDepId(String depId) {
this.depId = depId;
}
public String getDepName() {
return depName;
}
public void setDepName(String depName) {
this.depName = depName;
}
public long getPlanTaskDetailId() {
return planTaskDetailId;
}
public void setPlanTaskDetailId(long planTaskDetailId) {
this.planTaskDetailId = planTaskDetailId;
}
public String getAddress() {
return this.address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCheckMode() {
return this.checkMode;
}
public void setCheckMode(String checkMode) {
this.checkMode = checkMode;
}
public Date getCheckTime() {
return this.checkTime;
}
public void setCheckTime(Date checkTime) {
this.checkTime = checkTime;
}
public String getDeviceId() {
return this.deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public String getError() {
return this.error;
}
public void setError(String error) {
this.error = error;
}
public String getIsOk() {
return this.isOk;
}
public void setIsOk(String isOk) {
this.isOk = isOk;
}
public String getLatitude() {
return this.latitude;
}
public void setLatitude(String latitude) {
this.latitude = latitude;
}
public String getLongitude() {
return this.longitude;
}
public void setLongitude(String longitude) {
this.longitude = longitude;
}
public String getOrgCode() {
return this.orgCode;
}
public void setOrgCode(String orgCode) {
this.orgCode = orgCode;
}
public long getPlanId() {
return this.planId;
}
public void setPlanId(long planId) {
this.planId = planId;
}
public long getPlanTaskId() {
return this.planTaskId;
}
public void setPlanTaskId(long planTaskId) {
this.planTaskId = planTaskId;
}
public long getPointId() {
return this.pointId;
}
public void setPointId(long pointId) {
this.pointId = pointId;
}
public String getRemark() {
return this.remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public long getRouteId() {
return this.routeId;
}
public void setRouteId(long routeId) {
this.routeId = routeId;
}
public int getScore() {
return this.score;
}
public void setScore(int score) {
this.score = score;
}
public int getShotNumber() {
return this.shotNumber;
}
public void setShotNumber(int shotNumber) {
this.shotNumber = shotNumber;
}
public Date getUploadTime() {
return this.uploadTime;
}
public void setUploadTime(Date uploadTime) {
this.uploadTime = uploadTime;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getErrorClassify() {
return errorClassify;
}
public void setErrorClassify(String errorClassify) {
this.errorClassify = errorClassify;
}
public String getPlanName() {
return planName;
}
public void setPlanName(String planName) {
this.planName = planName;
}
public String getPointName() {
return pointName;
}
public void setPointName(String pointName) {
this.pointName = pointName;
}
public String getRouteName() {
return routeName;
}
public void setRouteName(String routeName) {
this.routeName = routeName;
}
/**
* id
*/
private long id;
@CreatedDate
@Column(name="create_date")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createDate;
@Id
@Column(name = "ID",nullable=false,unique=true)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
}
\ No newline at end of file
package com.yeejoin.amos.patrol.dao.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.data.annotation.CreatedDate;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
* The persistent class for the p_check_input database table.
*
*/
@Entity
@Table(name="p_check_input_history")
public class CheckInputHistory implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 巡检记录id
*/
@Column(name="check_id")
private Long checkId;
/**
* 检查项id
*/
@Column(name="input_id")
private Long inputId;
/**
* 检查项名称
*/
@Column(name="input_name")
private String inputName;
/**
* 巡检点检查项
*/
@Column(name="route_point_item_id")
private Long routePointItemId;
/**
* 输入值
*/
@Column(name="input_value")
private String inputValue;
/**
* 是否合格
*/
@Column(name="is_ok")
private String isOk;
/**
* 序号
*/
@Column(name="order_no")
private int orderNo;
/**
* 权限系统org code
*/
@Column(name="org_code")
private String orgCode;
/**
* 检查点分类id
*/
@Column(name="point_classify_id")
private Long pointClassifyId;
/**
* 检查点分类名称
*/
@Column(name="point_classify_name")
private String pointClassifyName;
/**
* 评分
*/
private int score;
/**
* 备注
*/
private String remark;
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public CheckInputHistory() {
}
public Long getCheckId() {
return this.checkId;
}
public void setCheckId(Long checkId) {
this.checkId = checkId;
}
public Long getInputId() {
return this.inputId;
}
public void setInputId(Long inputId) {
this.inputId = inputId;
}
public String getInputValue() {
return this.inputValue;
}
public void setInputValue(String inputValue) {
this.inputValue = inputValue;
}
public String getIsOk() {
return this.isOk;
}
public void setIsOk(String isOk) {
this.isOk = isOk;
}
public int getOrderNo() {
return this.orderNo;
}
public void setOrderNo(int orderNo) {
this.orderNo = orderNo;
}
public String getOrgCode() {
return this.orgCode;
}
public void setOrgCode(String orgCode) {
this.orgCode = orgCode;
}
public int getScore() {
return this.score;
}
public void setScore(int score) {
this.score = score;
}
public String getInputName() {
return inputName;
}
public void setInputName(String inputName) {
this.inputName = inputName;
}
public Long getRoutePointItemId() {
return routePointItemId;
}
public void setRoutePointItemId(Long routePointItemId) {
this.routePointItemId = routePointItemId;
}
public Long getPointClassifyId() {
return pointClassifyId;
}
public void setPointClassifyId(Long pointClassifyId) {
this.pointClassifyId = pointClassifyId;
}
public String getPointClassifyName() {
return pointClassifyName;
}
public void setPointClassifyName(String pointClassifyName) {
this.pointClassifyName = pointClassifyName;
}
/**
* id
*/
private long id;
@CreatedDate
@Column(name="create_date")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createDate;
@Id
@Column(name = "ID",nullable=false,unique=true)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
}
\ No newline at end of file
package com.yeejoin.amos.patrol.dao.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.data.annotation.CreatedDate;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
* The persistent class for the p_check_shot database table.
*
*/
@Entity
@Table(name="p_check_shot_history")
public class CheckShotHistory implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 巡检记录id
*/
@Column(name="check_id")
private long checkId;
/**
* 权限系统org code
*/
@Column(name="org_code")
private String orgCode;
/**
* 照片内容
*/
@Lob
@Column(name="photo_data")
private String photoData;
/**
* 拍照点名称
*/
@Column(name="point_name")
private String pointName;
/**
* 拍照类型:定点(检查项拍照),普通(检
*
*
*
*
* 点现场照片)
*/
@Column(name="shot_type")
private String shotType;
/**
* 检查项id
*/
@Column(name="check_input_id")
private long checkInputId;
/**
* 扩展分类id
*/
@Column(name="classify_id")
private long classifyId;
public long getClassifyId() {
return classifyId;
}
public void setClassifyId(long classifyId) {
this.classifyId = classifyId;
}
public long getCheckInputId() {
return checkInputId;
}
public void setCheckInputId(long checkInputId) {
this.checkInputId = checkInputId;
}
public CheckShotHistory() {
}
public long getCheckId() {
return this.checkId;
}
public void setCheckId(long checkId) {
this.checkId = checkId;
}
public String getOrgCode() {
return this.orgCode;
}
public void setOrgCode(String orgCode) {
this.orgCode = orgCode;
}
public String getPhotoData() {
return this.photoData;
}
public void setPhotoData(String photoData) {
this.photoData = photoData;
}
public String getPointName() {
return this.pointName;
}
public void setPointName(String pointName) {
this.pointName = pointName;
}
public String getShotType() {
return this.shotType;
}
public void setShotType(String shotType) {
this.shotType = shotType;
}
/**
* id
*/
private long id;
@CreatedDate
@Column(name="create_date")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createDate;
@Id
@Column(name = "ID",nullable=false,unique=true)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
}
\ No newline at end of file
package com.yeejoin.amos.patrol.dao.entity;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import java.util.List;
/**
* @Author cpp
* @Description
* @Date 2023/6/5
*/
@Data
@Accessors(chain = true)
@Document(indexName = "web_app_plan_task_list", shards = 6, replicas = 2)
public class ESPlanTaskListDto {
@Id
private String planTaskId;
@Field(type = FieldType.Text)
private String orgCode;
@Field(type = FieldType.Text)
private String planId;
@Field(type = FieldType.Text)
private String useCode;
@Field(type = FieldType.Text)
private String taskName;
@Field(type = FieldType.Text)
private String type;
@Field(type = FieldType.Text)
private String beginTime;
@Field(type = FieldType.Text)
private String endTime;
@Field(type = FieldType.Text)
private String checkDate;
@Field(type = FieldType.Text)
private String finshNum;
@Field(type = FieldType.Text)
private String taskPlanNum;
@Field(type = FieldType.Text)
private String finishStatus;
@Field(type = FieldType.Text)
private String batchNo;
@Field(type = FieldType.Text)
private String executiveName;
@Field(type = FieldType.Text)
private String userName;
@Field(type = FieldType.Text)
private String userDept;
@Field(type = FieldType.Text)
private String unplan;
@Field(type = FieldType.Text)
private String userId;
@Field(type = FieldType.Text)
private String unqualified;
@Field(type = FieldType.Text)
private String inOrder;
@Field(type = FieldType.Text)
private String omission;
@Field(type = FieldType.Object)
private List points;
}
package com.yeejoin.amos.patrol.dao.entity;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import java.util.List;
/**
* @Author cpp
* @Description
* @Date 2023/6/5
*/
@Data
@Accessors(chain = true)
@Document(indexName = "web_app_task_detail", shards = 6, replicas = 2)
public class ESTaskDetailDto {
@Id
private Long id;
@Field(type = FieldType.Text)
private String pointId;
@Field(type = FieldType.Text)
private String planTaskId;
@Field(type = FieldType.Text)
private String pointName;
@Field(type = FieldType.Text)
private String pointNo;
@Field(type = FieldType.Text)
private String shortMinNumber;
@Field(type = FieldType.Text)
private String shortMaxNumber;
@Field(type = FieldType.Text)
private String checkTime;
@Field(type = FieldType.Text)
private String beginTime;
@Field(type = FieldType.Text)
private String endTime;
@Field(type = FieldType.Text)
private String pointStatus;
@Field(type = FieldType.Text)
private String planName;
@Field(type = FieldType.Text)
private String taskStatus;
@Field(type = FieldType.Text)
private String departmentName;
@Field(type = FieldType.Text)
private String username;
@Field(type = FieldType.Text)
private String strCheckTime;
@Field(type = FieldType.Text)
private String checkId;
@Field(type = FieldType.Text)
private String remark;
@Field(type = FieldType.Text)
private String score;
@Field(type = FieldType.Text)
private List<String> pointImgUrls;
@Field(type = FieldType.Object)
private JSONObject appCheckInput;
}
......@@ -34,6 +34,18 @@ public class PlanTaskDetail extends BasicEntity {
*/
@Column(name="executor_id")
private String executorId;
/**
* 点名称
*/
@Column(name="name")
private String name;
/**
* 点编号
*/
@Column(name="point_no")
private String pointNo;
/**
* 执行时间
......@@ -69,6 +81,14 @@ public class PlanTaskDetail extends BasicEntity {
this.pointId = pointId;
}
public void setName(String name) {
this.name = name;
}
public void setPointNo(String pointNo) {
this.pointNo = pointNo;
}
public long getTaskNo() {
return this.taskNo;
}
......
package com.yeejoin.amos.patrol.dao.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.data.annotation.CreatedDate;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
* The persistent class for the p_plan_task_detail database table.
*
*/
@Entity
@Table(name="p_plan_task_detail_history")
public class PlanTaskDetailHistory implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 是否完成:是否完成0-未完成,1-已完成,2-超时漏检
*/
@Column(name="is_finish")
private int isFinish;
/**
* 点编号
*/
@Column(name="point_id")
private long pointId;
/**
* 任务批次号
*/
@Column(name="task_no")
private long taskNo;
/**
* 具体执行人id
*/
@Column(name="executor_id")
private String executorId;
/**
* 执行时间
*/
@Column(name="executor_date")
private Date executorDate;
private PlanTask planTask;
/**
* 状态:0 未开始;1 合格;2 不合格;3 漏检
*/
@Column(name="status")
private String status="0";
public PlanTaskDetailHistory() {
}
public int getIsFinish() {
return this.isFinish;
}
public void setIsFinish(int isFinish) {
this.isFinish = isFinish;
}
public long getPointId() {
return this.pointId;
}
public void setPointId(long pointId) {
this.pointId = pointId;
}
public long getTaskNo() {
return this.taskNo;
}
public void setTaskNo(long taskNo) {
this.taskNo = taskNo;
}
public void setPlanTask(PlanTask planTask) {
this.planTask = planTask;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getExecutorId() {
return executorId;
}
public void setExecutorId(String executorId) {
this.executorId = executorId;
}
public Date getExecutorDate() {
return executorDate;
}
public void setExecutorDate(Date executorDate) {
this.executorDate = executorDate;
}
/**
* id
*/
private long id;
@CreatedDate
@Column(name="create_date")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createDate;
@Id
@Column(name = "ID",nullable=false,unique=true)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
}
\ No newline at end of file
package com.yeejoin.amos.patrol.dao.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.data.annotation.CreatedDate;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
* The persistent class for the p_plan_task database table.
*
*/
@Entity
@Table(name="p_plan_task_history")
public class PlanTaskHistory implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 批次号(该字段暂时无效,取值为表id)
*/
@Column(name="batch_no")
private long batchNo;
/**
* 开始时间
*/
@Column(name="begin_time")
private String beginTime;
/**
* 巡检日期
*/
@Column(name="check_date")
private String checkDate;
/**
* 结束时间
*/
@Column(name="end_time")
private String endTime;
/**
* 已完成数量
*/
@Column(name="finish_num")
private int finishNum;
/**
* 完成状态:0-尚未开始;1-正在进行;2-已经结束;3-超时漏检
*/
@Column(name="finish_status")
private int finishStatus;
/**
* 公司Id
*/
@Column(name="org_code")
private String orgCode;
/**
* 计划编号
*/
@Column(name="plan_id")
private long planId;
/**
* 计划巡检点数
*/
@Column(name="point_num")
private int pointNum;
/**
* 信用代码
*/
@Column(name="use_code")
private String useCode;
public String getUseCode() {
return useCode;
}
public void setUseCode(String useCode) {
this.useCode = useCode;
}
public String getPlanType() {
return planType;
}
public void setPlanType(String planType) {
this.planType = planType;
}
/**
* 计划类型
*/
@Column(name="plan_type")
private String planType;
/**
* 路线编号
*/
@Column(name="route_id")
private long routeId;
/**
* 状态:0-有效;1-无效
*/
private int status;
/**
* 状态:0-有效;1-无效
*/
@Column(name="risk_status")
private int riskStatus;
public int getRiskStatus() {
return riskStatus;
}
public void setRiskStatus(int riskStatus) {
this.riskStatus = riskStatus;
}
/**
* 可执行人,一个或多个,多个用,隔开
*/
@Column(name="user_id")
private String userId;
/**
* 是否按排序0-否;1-是
*/
@Column(name="in_order")
private String inOrder;
/**
* 用户部门
*/
@Column(name="user_dept")
private String userDept;
/**
* 用户姓名
*/
@Column(name="user_name")
private String userName;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserDept() {
return userDept;
}
public void setUserDept(String userDept) {
this.userDept = userDept;
}
public PlanTaskHistory() {
}
public long getBatchNo() {
return batchNo;
}
public void setBatchNo(long batchNo) {
this.batchNo = batchNo;
}
public String getBeginTime() {
return this.beginTime;
}
public void setBeginTime(String beginTime) {
this.beginTime = beginTime;
}
public String getCheckDate() {
return this.checkDate;
}
public void setCheckDate(String checkDate) {
this.checkDate = checkDate;
}
public String getEndTime() {
return this.endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public int getFinishNum() {
return this.finishNum;
}
public void setFinishNum(int finishNum) {
this.finishNum = finishNum;
}
public int getFinishStatus() {
return this.finishStatus;
}
public void setFinishStatus(int finishStatus) {
this.finishStatus = finishStatus;
}
public String getOrgCode() {
return this.orgCode;
}
public void setOrgCode(String orgCode) {
this.orgCode = orgCode;
}
public long getPlanId() {
return this.planId;
}
public void setPlanId(long planId) {
this.planId = planId;
}
public int getPointNum() {
return this.pointNum;
}
public void setPointNum(int pointNum) {
this.pointNum = pointNum;
}
public long getRouteId() {
return this.routeId;
}
public void setRouteId(long routeId) {
this.routeId = routeId;
}
public int getStatus() {
return this.status;
}
public void setStatus(int status) {
this.status = status;
}
public String getInOrder() {
return inOrder;
}
public void setInOrder(String inOrder) {
this.inOrder = inOrder;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
/**
* id
*/
private long id;
@CreatedDate
@Column(name="create_date")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createDate;
@Id
@Column(name = "ID",nullable=false,unique=true)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
}
\ No newline at end of file
package com.yeejoin.amos.patrol.dao.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
@Entity
@Table(name="p_static_day")
public class StaticDay extends BasicEntity {
private static final long serialVersionUID = 1L;
/**
* 未完成
*/
@Column(name="not_start")
private int notStart;
/**
* 已完成有风险
*/
@Column(name="risk_end")
private int riskEnd;
/**
* 已完成无风险
*/
@Column(name="no_risk_end")
private int noRiskEnd;
/**
* 已超时
*/
@Column(name="time_out")
private int timeOut;
/**
* 检查时间
*/
@Column(name="check_time")
private String checkTime;
/**
* 单位code
*/
@Column(name="org_code")
private String orgCode;
/**
* 单位信用代码
*/
@Column(name="unit_code")
private String unitCode;
/**
* 开始时间
*/
@Column(name="begin_time")
private Date beginTime;
/**
* 结束时间
*/
@Column(name="end_time")
private Date endTime;
public Date getBeginTime() {
return beginTime;
}
public void setBeginTime(Date beginTime) {
this.beginTime = beginTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public int getNotStart() {
return notStart;
}
public void setNotStart(int notStart) {
this.notStart = notStart;
}
public int getRiskEnd() {
return riskEnd;
}
public void setRiskEnd(int riskEnd) {
this.riskEnd = riskEnd;
}
public int getNoRiskEnd() {
return noRiskEnd;
}
public void setNoRiskEnd(int noRiskEnd) {
this.noRiskEnd = noRiskEnd;
}
public int getTimeOut() {
return timeOut;
}
public void setTimeOut(int timeOut) {
this.timeOut = timeOut;
}
public String getCheckTime() {
return checkTime;
}
public void setCheckTime(String checkTime) {
this.checkTime = checkTime;
}
public String getOrgCode() {
return orgCode;
}
public void setOrgCode(String orgCode) {
this.orgCode = orgCode;
}
public String getUnitCode() {
return unitCode;
}
public void setUnitCode(String unitCode) {
this.unitCode = unitCode;
}
}
package com.yeejoin.amos.patrol.dao.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
@Entity
@Table(name="p_static_month")
public class StaticMonth extends BasicEntity {
private static final long serialVersionUID = 1L;
/**
* 未完成
*/
@Column(name="not_start")
private int notStart;
/**
* 已完成有风险
*/
@Column(name="risk_end")
private int riskEnd;
/**
* 已完成无风险
*/
@Column(name="no_risk_end")
private int noRiskEnd;
/**
* 已超时
*/
@Column(name="time_out")
private int timeOut;
/**
* 检查时间
*/
@Column(name="check_time")
private String checkTime;
/**
* 单位code
*/
@Column(name="org_code")
private String orgCode;
/**
* 单位信用代码
*/
@Column(name="unit_code")
private String unitCode;
/**
* 开始时间
*/
@Column(name="begin_time")
private Date beginTime;
/**
* 结束时间
*/
@Column(name="end_time")
private Date endTime;
public Date getBeginTime() {
return beginTime;
}
public void setBeginTime(Date beginTime) {
this.beginTime = beginTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public int getNotStart() {
return notStart;
}
public void setNotStart(int notStart) {
this.notStart = notStart;
}
public int getRiskEnd() {
return riskEnd;
}
public void setRiskEnd(int riskEnd) {
this.riskEnd = riskEnd;
}
public int getNoRiskEnd() {
return noRiskEnd;
}
public void setNoRiskEnd(int noRiskEnd) {
this.noRiskEnd = noRiskEnd;
}
public int getTimeOut() {
return timeOut;
}
public void setTimeOut(int timeOut) {
this.timeOut = timeOut;
}
public String getCheckTime() {
return checkTime;
}
public void setCheckTime(String checkTime) {
this.checkTime = checkTime;
}
public String getOrgCode() {
return orgCode;
}
public void setOrgCode(String orgCode) {
this.orgCode = orgCode;
}
public String getUnitCode() {
return unitCode;
}
public void setUnitCode(String unitCode) {
this.unitCode = unitCode;
}
}
package com.yeejoin.amos.patrol.dao.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
@Entity
@Table(name="p_static_week")
public class StaticWeek extends BasicEntity {
private static final long serialVersionUID = 1L;
/**
* 未完成
*/
@Column(name="not_start")
private int notStart;
/**
* 已完成有风险
*/
@Column(name="risk_end")
private int riskEnd;
/**
* 已完成无风险
*/
@Column(name="no_risk_end")
private int noRiskEnd;
/**
* 已超时
*/
@Column(name="time_out")
private int timeOut;
/**
* 检查时间
*/
@Column(name="check_time")
private String checkTime;
/**
* 单位code
*/
@Column(name="org_code")
private String orgCode;
/**
* 单位信用代码
*/
@Column(name="unit_code")
private String unitCode;
/**
* 开始时间
*/
@Column(name="begin_time")
private Date beginTime;
/**
* 结束时间
*/
@Column(name="end_time")
private Date endTime;
public Date getBeginTime() {
return beginTime;
}
public void setBeginTime(Date beginTime) {
this.beginTime = beginTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public int getNotStart() {
return notStart;
}
public void setNotStart(int notStart) {
this.notStart = notStart;
}
public int getRiskEnd() {
return riskEnd;
}
public void setRiskEnd(int riskEnd) {
this.riskEnd = riskEnd;
}
public int getNoRiskEnd() {
return noRiskEnd;
}
public void setNoRiskEnd(int noRiskEnd) {
this.noRiskEnd = noRiskEnd;
}
public int getTimeOut() {
return timeOut;
}
public void setTimeOut(int timeOut) {
this.timeOut = timeOut;
}
public String getCheckTime() {
return checkTime;
}
public void setCheckTime(String checkTime) {
this.checkTime = checkTime;
}
public String getOrgCode() {
return orgCode;
}
public void setOrgCode(String orgCode) {
this.orgCode = orgCode;
}
public String getUnitCode() {
return unitCode;
}
public void setUnitCode(String unitCode) {
this.unitCode = unitCode;
}
}
......@@ -173,6 +173,22 @@
<artifactId>poi</artifactId>
<version>4.0.0</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.apache.shardingsphere</groupId>-->
<!-- <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>-->
<!-- <version>5.2.1</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.apache.shardingsphere</groupId>-->
<!-- <artifactId>shardingsphere-transaction-xa-core</artifactId>-->
<!-- <version>5.2.1</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.33</version>
</dependency>
</dependencies>
<build>
<plugins>
......
......@@ -7,14 +7,32 @@ import com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.patrol.business.constants.XJConstant;
import com.yeejoin.amos.patrol.business.dao.mapper.CheckMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.PlanTaskMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.PointMapper;
import com.yeejoin.amos.patrol.business.dao.repository.ESPlanTaskList;
import com.yeejoin.amos.patrol.business.dao.repository.ICheckInputDao;
import com.yeejoin.amos.patrol.business.dto.*;
import com.yeejoin.amos.patrol.business.dto.CheckDto;
import com.yeejoin.amos.patrol.business.dto.SendToMsgRiskAlarmInfoVo;
import com.yeejoin.amos.patrol.business.dto.SendToMsgRiskDetailVo;
import com.yeejoin.amos.patrol.business.dto.SendToMsgRiskEquipInfoVo;
import com.yeejoin.amos.patrol.business.dto.TopicEntityVo;
import com.yeejoin.amos.patrol.business.param.CheckInfoPageParam;
import com.yeejoin.amos.patrol.business.param.CheckRecordParam;
import com.yeejoin.amos.patrol.business.param.CheckStatisticalParam;
import com.yeejoin.amos.patrol.business.service.intfc.*;
import com.yeejoin.amos.patrol.business.util.*;
import com.yeejoin.amos.patrol.business.service.intfc.ICheckService;
import com.yeejoin.amos.patrol.business.service.intfc.IMessageService;
import com.yeejoin.amos.patrol.business.service.intfc.IPlanTaskService;
import com.yeejoin.amos.patrol.business.service.intfc.IPointService;
import com.yeejoin.amos.patrol.business.service.intfc.ISafety3DDataSendService;
import com.yeejoin.amos.patrol.business.util.CheckPageParamUtil;
import com.yeejoin.amos.patrol.business.util.CheckParamUtil;
import com.yeejoin.amos.patrol.business.util.CommonResponse;
import com.yeejoin.amos.patrol.business.util.CommonResponseUtil;
import com.yeejoin.amos.patrol.business.util.DaoCriteria;
import com.yeejoin.amos.patrol.business.util.FileHelper;
import com.yeejoin.amos.patrol.business.util.ResponseHelperUtil;
import com.yeejoin.amos.patrol.business.util.Toke;
import com.yeejoin.amos.patrol.business.util.ToolUtils;
import com.yeejoin.amos.patrol.business.vo.CheckAnalysisVo;
import com.yeejoin.amos.patrol.business.vo.CheckInfoVo;
import com.yeejoin.amos.patrol.common.enums.PlanTaskFinishStatusEnum;
......@@ -27,9 +45,10 @@ import com.yeejoin.amos.patrol.core.common.response.GraphInitDataResponse;
import com.yeejoin.amos.patrol.core.enums.QueryOperatorEnum;
import com.yeejoin.amos.patrol.core.util.DateUtil;
import com.yeejoin.amos.patrol.core.util.StringUtil;
import com.yeejoin.amos.patrol.dao.entity.PlanTask;
import com.yeejoin.amos.patrol.dao.entity.*;
import com.yeejoin.amos.patrol.feign.RemoteSecurityService;
import com.yeejoin.amos.patrol.mqtt.WebMqttComponent;
import com.yeejoin.amos.patrol.quartz.JobService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
......@@ -41,11 +60,15 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.scheduling.annotation.Async;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.util.StopWatch;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
......@@ -53,16 +76,23 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse;
import javax.xml.transform.*;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import java.io.*;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@RestController
@RequestMapping(value = "/api/check")
......@@ -130,6 +160,21 @@ public class CheckController extends AbstractBaseController {
@Autowired
PointMapper pointMapper;
@Autowired
ESPlanTaskList esPlanTaskList;
@Autowired
JobService jobService;
private String P_STATIC_DAY = "p_static_day";
private String P_STATIC_MONTH = "p_static_month";
private String P_STATIC_WEEK = "p_static_week";
@Autowired
PlanTaskMapper planTaskMapper;
/**
*
* 巡查记录列表
......@@ -198,7 +243,6 @@ public class CheckController extends AbstractBaseController {
return ResponseHelper.buildResponse("提交成功");
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "保存巡检记录<font color='blue'>手机app</font>", notes = "保存巡检记录<font color='blue'>手机app</font>")
@RequestMapping(value = "/saveRecordNew", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
......@@ -213,23 +257,18 @@ public class CheckController extends AbstractBaseController {
String realName = user.getRealName();
requestParam.setUserId(userId);
requestParam.setUserName(realName);
requestParam.setIsOffline(requestParam.getIsOffline()==null?false:requestParam.getIsOffline());
try {
if (planTask != null) {
if (!ToolUtils.transBeanList(planTask.getUserId()).contains(userId.toString())) {
return ResponseHelper.buildResponse("无权执行该任务");
}
if (!requestParam.getIsOffline()) {
statu = planTask.getFinishStatus();
if (!requestParam.getIsOffline() && statu == PlanTaskFinishStatusEnum.OVERTIME.getValue()) {
return ResponseHelper.buildResponse("任务已超时,上传失败!");
}else if( statu == PlanTaskFinishStatusEnum.FINISHED.getValue()){
return ResponseHelper.buildResponse("任务已完成!");
}
statu = planTask.getFinishStatus();
if( statu == PlanTaskFinishStatusEnum.FINISHED.getValue()){
return ResponseHelper.buildResponse("任务已完成!");
}
Date checkTime = requestParam.getIsOffline()?DateUtil.getLongDate(requestParam.getCheckTime()):new Date();
Date checkTime = new Date();
Date beginTime = DateUtil.getLongDate(planTask.getBeginTime());
Date endTime = DateUtil.getLongDate(planTask.getEndTime());
int beginCompareTo = checkTime.compareTo(beginTime);
......@@ -245,6 +284,42 @@ public class CheckController extends AbstractBaseController {
requestParam.setOrgCode(orgCode);
requestParam.setUserId(getUserId());
CheckDto checkDto = checkService.saveCheckRecordNew(requestParam, planTask);
Long planTaskId = planTask.getId();
List<String> ids = new ArrayList<>();
ids.add(String.valueOf(planTaskId));
Map<String, Object> map = planTaskMapper.selectTaskStatus(planTaskId);
String status = map.get("status").toString();
ESPlanTaskListDto esPlanTaskListDto = esPlanTaskList.findById(String.valueOf(planTaskId)).get();
Map task = planTaskMapper.queryPlanTaskById(planTaskId);
esPlanTaskListDto.setFinshNum(ObjectUtils.isEmpty(task.get("finshNum")) ? "0" : task.get("finshNum").toString());
esPlanTaskListDto.setOmission(ObjectUtils.isEmpty(task.get("omission")) ? "0" : task.get("omission").toString());
esPlanTaskListDto.setUnqualified(ObjectUtils.isEmpty(task.get("unqualified")) ? "0" : task.get("unqualified").toString());
esPlanTaskListDto.setUnplan(ObjectUtils.isEmpty(task.get("unplan")) ? "0" : task.get("unplan").toString());
esPlanTaskListDto.setTaskPlanNum(ObjectUtils.isEmpty(task.get("taskPlanNum")) ? "0" : task.get("taskPlanNum").toString());
List<PlanTaskDetail> planTaskDetailList = planTaskMapper.selectTaskDetails("('" + planTaskId + "')");
esPlanTaskListDto.setFinishStatus(status);
esPlanTaskListDto.setPoints(planTaskDetailList);
esPlanTaskList.save(esPlanTaskListDto);
if(status.equals(String.valueOf(PlanTaskFinishStatusEnum.FINISHED.getValue()))) {
// 更新统计表
if(planTask.getPlanType().equals(String.valueOf(PlanTaskTypeStatusEnum.day.getValue()))) {
planTaskMapper.updateSingle(P_STATIC_DAY, XJConstant.RISK_NUM == Integer.parseInt(map.get("riskStatus").toString()) ? 1 : 0,
XJConstant.NORISK_NUM == Integer.parseInt(map.get("riskStatus").toString()) ? 1 : 0,
planTask.getOrgCode(),planTask.getCheckDate());
} else if(planTask.getPlanType().equals(String.valueOf(PlanTaskTypeStatusEnum.week.getValue()))) {
planTaskMapper.updateSingle(P_STATIC_WEEK, XJConstant.RISK_NUM == Integer.parseInt(map.get("riskStatus").toString()) ? 1 : 0,
XJConstant.NORISK_NUM == Integer.parseInt(map.get("riskStatus").toString()) ? 1 : 0,
planTask.getOrgCode(),planTask.getCheckDate());
} else {
planTaskMapper.updateSingle(P_STATIC_WEEK, XJConstant.RISK_NUM == Integer.parseInt(map.get("riskStatus").toString()) ? 1 : 0,
XJConstant.NORISK_NUM == Integer.parseInt(map.get("riskStatus").toString()) ? 1 : 0,
planTask.getOrgCode(),planTask.getCheckDate());
}
}
return ResponseHelper.buildResponse(checkDto);
} else {
return ResponseHelperUtil.buildErrorResponse("无需重新巡检");
......@@ -305,7 +380,7 @@ public class CheckController extends AbstractBaseController {
* 巡检计划查询
*
* @param
* @param param
* @param
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
......@@ -540,15 +615,25 @@ public class CheckController extends AbstractBaseController {
@RequestParam(required = false) String checkTime,
@RequestParam(required = true) String type) {
try {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
String userId = RequestContext.getExeUserId();
ReginParams reginParams = getSelectedOrgInfo();
String loginOrgCode = reginParams.getPersonIdentity().getBizOrgCode();
String loginOrgCode = reginParams.getPersonIdentity().getBizOrgCode();
stopWatch.stop();
log.info("获取巡检日历数据=====> loginOrgCode time: {}", stopWatch.getTotalTimeSeconds());
if(StringUtils.isBlank(checkTime)) {
checkTime = DateUtils.dateFormat(new Date(), null);
if(type.equals(String.valueOf(PlanTaskTypeStatusEnum.month.getValue()))) {
checkTime = DateUtils.dateFormat(new Date(), DateUtils.YEAR_PATTERN);
} else {
checkTime = DateUtils.dateFormat(new Date(), DateUtils.MONTH_PATTERN);
}
}
stopWatch.start();
Map<String, Object> map = checkService.checkCalendarNew(checkTime,loginOrgCode,String.valueOf(PlanTaskTypeStatusEnum.getValue(type)),userId);
stopWatch.stop();
log.info("获取巡检日历数据=====> sql map time: {}", stopWatch.getTotalTimeSeconds());
return ResponseHelper.buildResponse(map);
} catch (Exception e) {
e.printStackTrace();
......@@ -629,7 +714,7 @@ public class CheckController extends AbstractBaseController {
/**
* 巡检计划删除(支持批量)
*
* @param param
* @param
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
......@@ -681,7 +766,7 @@ public class CheckController extends AbstractBaseController {
/**
* 根据检查项ID获取所有不合格检查项
*
* @param param
* @param
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
......
......@@ -27,11 +27,22 @@ import com.yeejoin.amos.patrol.feign.RemoteSecurityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.Authorization;
import org.apache.commons.collections.CollectionUtils;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.util.ObjectUtils;
......@@ -46,6 +57,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
......@@ -70,6 +82,9 @@ public class PlanTaskController extends AbstractBaseController {
@Value("${params.isPush:false}")
private Boolean isZxj;
@Autowired
RestHighLevelClient restHighLevelClient;
@Autowired
private RemoteSecurityService remoteSecurityService;
......@@ -111,8 +126,8 @@ public class PlanTaskController extends AbstractBaseController {
PlanTaskPageParamUtil.fillPlanTask(queryRequests, params);
params.put("orgCode", reginParams.getPersonIdentity().getBizOrgCode());
params.put("userId", userId);
params.put("pageSize", pageable.getPageSize());
params.put("offset", pageable.getPageNumber() * pageable.getPageSize());
params.put("size", pageable.getPageSize());
params.put("number", pageable.getPageNumber());
if (ObjectUtils.isEmpty(params.get("orderBy"))) {
params.put("orderBy", "beginTime desc");
}
......@@ -375,6 +390,26 @@ public class PlanTaskController extends AbstractBaseController {
}
/**
* 定时查询任务状态
*
* @return
*/
@Scheduled(cron = "${jobs.cron.static}")
@ApiOperation(value = "定时任务生成统计数据", notes = "定时任务生成统计数据")
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping(value = "/initStatic", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
public CommonResponse initStatic() {
try {
planTaskService.taskStaticExecution(null);
return CommonResponseUtil.success();
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage(), e);
return CommonResponseUtil.failure();
}
}
/**
* 定时任务推送巡检待办任务消息
*/
@Scheduled(cron = "${jobs.cron}")
......@@ -568,29 +603,47 @@ public class PlanTaskController extends AbstractBaseController {
@RequestMapping(value = "/queryPlanTaskByIdNew", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public ResponseModel<Object> qryPlanTaskByIdNew(
@ApiParam(value = "巡检计划任务ID", required = true) @RequestParam(required = true) String planTaskId) {
try {
Map<String, Object> response = new HashMap<String, Object>();
Map task = planTaskService.queryPlanTaskById(Long.parseLong(planTaskId));
if (ObjectUtils.isEmpty(task) || ObjectUtils.isEmpty(task.get("planTaskId"))) {
return ResponseHelperUtil.buildErrorResponse("该计划已刷新,请重新选择!!!");
Map<String, Object> rtResponse = new HashMap<String, Object>();
SearchRequest request = new SearchRequest();
request.indices("web_app_plan_task_list");
SearchSourceBuilder builder = new SearchSourceBuilder();
builder.trackTotalHits(true);
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
if (!ObjectUtils.isEmpty(planTaskId)) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchPhraseQuery("planTaskId", "*" + planTaskId + "*"));
boolMust.must(meBuilder);
}
List points = planTaskService.getPlanTaskPoints(Long.parseLong(planTaskId));
builder.query(boolMust);
request.source(builder);
String[] userIds = task.get("userId").toString().split(",");
for (String userId : userIds) {
task.put("userId", userId);
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
task.put("checkDate", sdf.format(task.get("checkDate") != null ? sdf.parse(task.get("checkDate").toString()) : new Date()));
response.put("planTask", task);
response.put("points", points);
Object ov= response!=null?ToJson.tojson(response):null;
return ResponseHelper.buildResponse(ov);
} catch (Exception e) {
return ResponseHelperUtil.buildErrorResponse(e.getMessage());
}
SearchResponse response = null;
long totle = 0;
try {
response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits().getHits()) {
System.out.println(hit);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
JSONObject dto2 = jsonObject.getJSONObject("sourceAsMap");
rtResponse.put("points", dto2.getJSONArray("points"));
dto2.remove("points");
rtResponse.put("planTask", dto2);
}
totle = response.getInternalResponse().hits().getTotalHits().value;
if (totle == 0) {
return ResponseHelperUtil.buildErrorResponse("该计划已刷新,请重新选择!!!");
} else {
Object ov= rtResponse!=null?ToJson.tojson(rtResponse):null;
return ResponseHelper.buildResponse(ov);
}
} catch (IOException e) {
e.printStackTrace();
}
return ResponseHelperUtil.buildErrorResponse("该计划已刷新,请重新选择!!!");
}
......@@ -917,17 +970,50 @@ public class PlanTaskController extends AbstractBaseController {
public ResponseModel<Object> queryPointPlanTaskDetail(
@ApiParam(value = "巡检计划任务ID", required = true) @RequestParam(required = true) String planTaskId,
@ApiParam(value = "巡检点ID", required = true) @RequestParam(required = true) String pointId) {
SearchRequest request = new SearchRequest();
request.indices("web_app_task_detail");
SearchSourceBuilder builder = new SearchSourceBuilder();
builder.trackTotalHits(true);
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
if (!ObjectUtils.isEmpty(planTaskId)) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchPhraseQuery("planTaskId", "*" + planTaskId + "*"));
boolMust.must(meBuilder);
}
if (!ObjectUtils.isEmpty(pointId)) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchPhraseQuery("pointId", "*" + pointId + "*"));
boolMust.must(meBuilder);
}
builder.query(boolMust);
request.source(builder);
SearchResponse response = null;
long totle = 0;
Map map = null;
try {
AppPointCheckRespone result = planTaskService.queryPointPlanTaskDetail(getToken(), getProduct(), getAppKey(), Long.parseLong(planTaskId), Long.parseLong(pointId));
if (ObjectUtils.isEmpty(result)) {
return ResponseHelperUtil.buildErrorResponse("该计划巡检点已更新,请退回重新选择");
response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits().getHits()) {
System.out.println(hit);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
JSONObject dto2 = jsonObject.getJSONObject("sourceAsMap");
map = dto2;
}
Object ov= result!=null?ToJson.tojson(result):null;
return ResponseHelper.buildResponse(ov);
} catch (Exception e) {
log.error(e.getMessage(), e);
return ResponseHelperUtil.buildErrorResponse(e.getMessage());
totle = response.getInternalResponse().hits().getTotalHits().value;
if (totle == 0) {
return ResponseHelperUtil.buildErrorResponse("该点不存在,请重新选择!!!");
} else {
Object ov= ToJson.tojson(map);
return ResponseHelper.buildResponse(ov);
}
} catch (IOException e) {
e.printStackTrace();
}
return ResponseHelperUtil.buildErrorResponse("该点不存在,请重新选择!!!");
}
/**
......@@ -1102,4 +1188,18 @@ public class PlanTaskController extends AbstractBaseController {
}
}
@Scheduled(cron = "${jobs.cron.bak}")
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "巡检当天数据归档", notes = "巡检当天数据归档")
@RequestMapping(value = "/sharding/bak", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public ResponseModel bakPatrolInfo() {
try {
planTaskService.backPatrolInfo();
return CommonPatrolResponseUtil.success(null);
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonPatrolResponseUtil.failure("远程查询巡检信息失败!");
}
}
}
......@@ -187,18 +187,18 @@ public class PointController extends AbstractBaseController {
try {
//增加判断
PointClassify PointClassifyk= iPointClassifyDao.getPointClassifyByPointIdandcode(pointClassify.getPointId(),pointClassify.getCode());
if(PointClassifyk!=null){
if(PointClassifyk.getId()!=pointClassify.getId()){
return CommonResponseUtil.failure("巡查对象code,不能重复!");
}
}
// PointClassify PointClassifyk= iPointClassifyDao.getPointClassifyByPointIdandcode(pointClassify.getPointId(),pointClassify.getCode());
// if(PointClassifyk!=null){
// if(PointClassifyk.getId()!=pointClassify.getId()){
// return CommonResponseUtil.failure("巡查对象code,不能重复!");
// }
// }
List<RoutePoint> routePointList = iRoutePointDao.queryByPointId(pointClassify.getPointId());
AgencyUserModel user = getUserInfo();
PointClassify newPointClassify = new PointClassify();
newPointClassify.setEquipmentId(pointClassify.getEquipmentId());
newPointClassify.setName(pointClassify.getName());
newPointClassify.setName(ObjectUtils.isEmpty(pointClassify.getName()) ? "系统默认" : pointClassify.getName());
newPointClassify.setInspectionSpecName(pointClassify.getInspectionName());
newPointClassify.setCreatorId(user.getUserId());
newPointClassify.setPointId(pointClassify.getPointId());
......@@ -231,7 +231,7 @@ public class PointController extends AbstractBaseController {
}
newPointClassify.setCategoryCode(pointClassify.getCategoryCode());
newPointClassify.setCategoryName(pointClassify.getCategoryName());
newPointClassify.setCode(pointClassify.getCode());
newPointClassify.setCode(ObjectUtils.isEmpty(pointClassify.getCode()) ? "系统默认":pointClassify.getCode());
List<PointInputItemVo> customInputList = pointClassify.getEquipIputDetailData();//巡检项
iPointService.addPointClassifyByPointId(newPointClassify);
List<PointInputItemVo> oldInputItemList = new ArrayList<>();
......@@ -1471,7 +1471,7 @@ public class PointController extends AbstractBaseController {
@GetMapping(value = "/newQueryByIds", produces = "application/json;charset=UTF-8")
public CommonResponse queryItemList4RoutePointNew(
@ApiParam(value = "巡检点ID") @RequestParam(value = "pointId") Long pointId,
@ApiParam(value = "设备ID") @RequestParam(value = "classifyId") Long classifyId,
@ApiParam(value = "设备ID") @RequestParam(value = "classifyId", required = false) Long classifyId,
@ApiParam(value = "路线ID") @RequestParam(value = "routeId") Long routeId) {
List list = iPointService.queryItemList4RoutePointNew(routeId, pointId, classifyId);
Object ob=list!=null?ToJson.tojson(list):null;
......
......@@ -746,7 +746,7 @@ public class RouteController extends AbstractBaseController {
@PostMapping(value = "/updateRoutePointInputItemNew", produces = "application/json;charset=UTF-8")
public CommonResponse updateRoutePointInputItemNew(@ApiParam(value = "巡检路线id", required = true) @RequestParam(value = "routeId") Long routeId,
@ApiParam(value = "巡检点id", required = true) @RequestParam(value = "pointId") Long pointId,
@ApiParam(value = "巡检点分类id", required = true) @RequestParam(value = "classifyId") Long classifyId,
@ApiParam(value = "巡检点分类id") @RequestParam(value = "classifyId", required = false) Long classifyId,
@ApiParam(value = "巡检点巡检项id", required = true) @RequestParam List<Long> inputItemIds) {
try {
routeService.updateRoutePointInputItemNew(routeId, pointId,classifyId, inputItemIds);
......
......@@ -49,6 +49,8 @@ public interface CheckMapper extends BaseMapper {
List<Map<String,Object>> planCount(String checkTime, String orgCode,String type,String userId, String startTime, String endTime);
List<Map<String,Object>> planCountNew(String checkTime, String orgCode,String table, String type, String startTime, String endTime);
List<Map<String, Object>> queryRecordByPointId(HashMap<String, Object> req);
Map<String, Object> queryCheckById(@Param(value="checkId") int checkId);
......
......@@ -58,4 +58,6 @@ public interface PlanMapper extends BaseMapper {
* 初始化计划下次执行时间
*/
void initUpdatePlanNextGenDate();
Plan getPlan(String planId);
}
package com.yeejoin.amos.patrol.business.dao.mapper;
import com.yeejoin.amos.patrol.business.dto.PlanTaskStaticDto;
import com.yeejoin.amos.patrol.business.entity.mybatis.CheckChkExListBo;
import com.yeejoin.amos.patrol.business.entity.mybatis.PlanTaskPointInputItemBo;
import com.yeejoin.amos.patrol.business.entity.mybatis.PointCheckDetailBo;
......@@ -8,9 +9,12 @@ import com.yeejoin.amos.patrol.business.param.PlanTaskPageParam;
import com.yeejoin.amos.patrol.business.vo.CodeOrderVo;
import com.yeejoin.amos.patrol.business.vo.LeavePlanTaskVo;
import com.yeejoin.amos.patrol.business.vo.PlanTaskVo;
import com.yeejoin.amos.patrol.core.common.response.AppCheckInputRespone;
import com.yeejoin.amos.patrol.dao.entity.Plan;
import com.yeejoin.amos.patrol.dao.entity.PlanTask;
import com.yeejoin.amos.patrol.dao.entity.PlanTaskDetail;
import com.yeejoin.amos.patrol.dao.entity.PointInputItem;
import com.yeejoin.amos.patrol.dao.entity.*;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
......@@ -21,30 +25,37 @@ import java.util.Map;
public interface PlanTaskMapper extends BaseMapper {
/**
* 统计-计划执行
*
* @param params
* @return
*/
long countPlanTask(PlanTaskPageParam params);
/**
* 计划执行查询
* @param params
* @return
*/
/**
* 计划执行查询
*
* @param params
* @return
*/
List<HashMap<String, Object>> getPlanTaskInfo(PlanTaskPageParam params);
/**
* 批量删除
*
* @param strArry
*/
void planTaskDet(String[] strArry);
/**
* 更新任务表
*
* @param param
*/
void updatePlanTaskPtInfo(HashMap<String, Object> param);
/**
* 查询需删除的任务信息列表
*
* @param param
* @return
*/
......@@ -57,6 +68,7 @@ public interface PlanTaskMapper extends BaseMapper {
* @return
*/
List<PlanTask> getPlanTaskByRouteId(@Param(value = "routeId") Long routeId);
/**
* 根据巡检点id获取关联的计划任务
*
......@@ -64,67 +76,86 @@ public interface PlanTaskMapper extends BaseMapper {
* @return
*/
List<HashMap<String, Object>> getPlanTaskByPointId(HashMap<String, Object> param);
/**
* 根据条件查询计划任务列表
* 根据条件查询计划任务列表
*
* @param params
* @return
*/
List<Map<String, Object>> getPlanTasks(HashMap<String, Object> params);
/**
* 通过计划任务Id获得计划任务信息
* 通过计划任务Id获得计划任务信息
*
* @param planTaskId
* @return
*/
Map queryPlanTaskById(@Param(value="planTaskId") Long planTaskId);
Map queryPlanTaskById(@Param(value = "planTaskId") Long planTaskId);
/**
* 通过计划任务Id获取任务所有点信息
* 通过计划任务Id获取任务所有点信息
*
* @param planTaskId
* @return
*/
List getPlanTaskPoints(@Param(value="planTaskId") Long planTaskId);
List getPlanTaskPoints(@Param(value = "planTaskId") Long planTaskId);
/**
* 获取用户当前所有可以做的任务个数
* 获取用户当前所有可以做的任务个数
*
* @param userId
* @return
*/
int getCurrentPlanTaskCount(@Param(value="userId") String userId);
int getCurrentPlanTaskCount(@Param(value = "userId") String userId);
/**
* 根据计划任务id获取所有巡检项信息
*
* @param planTaskId
* @return
*/
List<PlanTaskPointInputItemBo> getPlanTaskPointInputItemByPlanTaskId(@Param(value="planTaskId") Long planTaskId, @Param(value="planTaskDetailStatus") String planTaskDetailStatus);
List<PlanTaskPointInputItemBo> getPlanTaskPointInputItemByPlanTaskId(@Param(value = "planTaskId") Long planTaskId, @Param(value = "planTaskDetailStatus") String planTaskDetailStatus);
/**
* 条件查询数据
*
* @param param
* @return
*/
List<PlanTaskVo> getPlanTaskInfoList(PlanTaskPageParam param);
/**
* 根据ids获取执行计划
*
* @param ids
* @return
*/
List<PlanTaskVo> getPlanTaskListByIds(@Param("ids") Long[] ids);
/**
* 分页统计
*
* @param param
* @return
*/
long countChkExListData(CheckPtListPageParam param);
long countChkExListDataNew(CheckPtListPageParam param);
/**
* 今日执行情况,业务信息查询
*
* @param param
* @return
*/
List<CheckChkExListBo> getChkExList(CheckPtListPageParam param);
List<CheckChkExListBo> getChkExListNew(CheckPtListPageParam param);
/**
* 任务分页查询数量
*
* @param params 参数
* @return long
*/
......@@ -135,6 +166,7 @@ public interface PlanTaskMapper extends BaseMapper {
/**
* 根据计划id和点id获取点详情
*
* @param planTaskId
* @param pointId
* @return
......@@ -143,19 +175,24 @@ public interface PlanTaskMapper extends BaseMapper {
/**
* 根据路线id和点id获取该点的检查项
*
* @param routeId
* @param pointId
* @return
*/
List<PointCheckDetailBo> getPointInputByRouteIdAndPointId(@Param("routeId") Long routeId,@Param("pointId") Long pointId);
List<PointCheckDetailBo> getPointInputByRouteIdAndPointId(@Param("routeId") Long routeId, @Param("pointId") Long pointId);
/**
* 统计当日任务累计完成情况
* 统计当日任务累计完成情况
*
* @param loginOrgCode
* @return
*/
String getCumulativePlanCountByOrgCode(@Param("orgCode") String loginOrgCode);
/**
* 获取用户离线巡检计划任务信息
*
* @param params
* @return
*/
......@@ -168,17 +205,19 @@ public interface PlanTaskMapper extends BaseMapper {
* @param pointId
* @return
*/
List<PointInputItem> getRoutePointInputItem(@Param(value="routeId") long routeId, @Param(value="pointId") long pointId);
List<PointInputItem> getRoutePointInputItem(@Param(value = "routeId") long routeId, @Param(value = "pointId") long pointId);
List<CodeOrderVo> queryCodeOrderVo(HashMap<String, Object> params);
/**
* 重新统计用户重做日期段内计划任务
*
* @param userId
* @param refDate
* @param orgCode
*/
void reformStatistics(@Param(value="userId") String userId, @Param(value="refDate") String refDate, @Param(value="orgCode")String orgCode);
void reformStatistics(@Param(value = "userId") String userId, @Param(value = "refDate") String refDate, @Param(value = "orgCode") String orgCode);
List<Map<String, Object>> countFinishByPlanIds(List<Long> planIds);
......@@ -192,48 +231,100 @@ public interface PlanTaskMapper extends BaseMapper {
/**
* 消防巡检信息统计
*
* @param bizOrgCode 业务公司编码
* @return 消防巡检信息统计
*/
List<Map<String, Object>> firePatrolStatics(@Param("bizOrgCode") String bizOrgCode);
long countData(@Param(value="param") PlanTaskPageParam param);
long countData(@Param(value = "param") PlanTaskPageParam param);
List<HashMap<String, Object>> planTaskPage(@Param(value="param") PlanTaskPageParam param);
List<HashMap<String, Object>> planTaskPage(@Param(value = "param") PlanTaskPageParam param);
Map<String, Object> getPlanTaskBasicInfo(@Param(value="taskDetailId") String taskDetailId);
Map<String, Object> getPlanTaskBasicInfo(@Param(value = "taskDetailId") String taskDetailId);
Map<String, Object> getPlanTaskExecuteInfo(@Param(value="taskDetailId") String taskDetailId);
Map<String, Object> getPlanTaskExecuteInfo(@Param(value = "taskDetailId") String taskDetailId);
List<String> getDefinitionObjCode(@Param(value="taskDetailId") String taskDetailId);
List<String> getDefinitionObjCode(@Param(value = "taskDetailId") String taskDetailId);
Map<String, Object> getDefectEquipInfo(@Param(value="id") String id);
Map<String, Object> getDefectEquipInfo(@Param(value = "id") String id);
List<Map<String, Object>> getCheckMissedEquipInfo(@Param(value="taskDetailId") String taskDetailId);
List<Map<String, Object>> getCheckMissedEquipInfo(@Param(value = "taskDetailId") String taskDetailId);
List<Map<String, Object>> getCheckQualifiedEquipInfo(@Param(value="taskDetailId") String taskDetailId);
List<Map<String, Object>> getCheckQualifiedEquipInfo(@Param(value = "taskDetailId") String taskDetailId);
List<Map<String, Object>> getCheckNotQualifiedEquipInfo(@Param(value="taskDetailId") String taskDetailId);
List<Map<String, Object>> getCheckNotQualifiedEquipInfo(@Param(value = "taskDetailId") String taskDetailId);
String getCheckIdByDetailId(@Param(value="taskDetailId") String taskDetailId);
String getCheckIdByDetailId(@Param(value = "taskDetailId") String taskDetailId);
String queryByCompanyCode(@Param("companyCode") String companyCode);
List<Map<String, Object>> getStatics(@Param("bizOrgCode") String bizOrgCode);
Map<String, Object> queryPatrolInfoList(@Param(value="bizOrgCode") String bizOrgCode, @Param(value="startDate") Date startDate, @Param(value="endDate") Date endDate);
Map<String, Object> queryPatrolInfoList(@Param(value = "bizOrgCode") String bizOrgCode, @Param(value = "startDate") Date startDate, @Param(value = "endDate") Date endDate);
Map<String, Object> queryPatrolEquipInfo(@Param(value="bizOrgCode") String bizOrgCode, @Param(value="startDate") Date startDate, @Param(value="endDate") Date endDate);
Map<String, Object> queryPatrolEquipInfo(@Param(value = "bizOrgCode") String bizOrgCode, @Param(value = "startDate") Date startDate, @Param(value = "endDate") Date endDate);
List<Long> getPlanTaskListByPlanId(long planId, int finishStatus);
List<PlanTask> getPlanTaskTListByPlanId(long planId, int finishStatus);
void updatePlanTaskByPlanId(List<Long> ids, int finishStatus);
void updatePlanTaskByPlanId(@Param(value = "ids") List<Long> ids, int finishStatus);
void updatePlanTaskDetailsByPlanId(List<Long> ids);
void updatePlanTaskDetailsByPlanId(@Param(value = "ids") List<Long> ids);
List<PlanTask> getInitPlanTaskList();
void updatePlanTaskList(List<String> ids, int newStatus);
List<String> selectPlanTaskIdList(long planId, int oldStatus);
List<PlanTaskDetail> selectTaskDetails(String ids);
Map<String, Object> selectTaskStatus(Long planTaskId);
void updatePlanTaskList(long planId, int oldStatus, int newStatus);
List<PlanTask> findPlanTask();
List<PlanTaskDetail> findPlanTaskDetail();
List<Check> findCheck();
List<CheckInput> findCheckInput();
List<CheckShot> findCheckShot();
List<StaticDay> findStaticDay();
List<StaticDay> findStaticWeek();
void insertAll(String table, StaticDay item);
void updateData(String table, List<StaticDay> list);
void updateSingle(String table, int riskEnd, int noRiskEnd, String orgCode, String checkTime);
int deleteDate(String table);
int deleteOne(String table, String checkDate);
Long selectRoutId(String id);
List<String> selectPlanTaskIdLists(long planId, int status, int status1);
List<PlanTask> selectTaskList(@Param(value = "ids") List<String> ids);
List<PlanTaskStaticDto> queryPlanTaskStaticById(@Param(value = "planTaskIds") String planTaskIds);
List<ESTaskDetailDto> selectTaskDetailList(@Param(value = "ids") String ids);
List<ESTaskDetailDto> selectTaskInfoList(@Param(value = "id") long id);
List<AppCheckInputRespone> selectPointInputs(@Param(value = "routeId") Long routeId);
List<String> getPlanTaskIds(@Param(value = "id") long id);
List<Map<String, String>> selectExcludeItemsByRoutId(long routeId);
}
......@@ -163,4 +163,7 @@ public interface PointMapper extends BaseMapper {
List<Point> findByName(@Param(value = "pointName") String pointName, @Param(value = "pointId") String pointId);
List<Point> findByNo(@Param(value = "pointNo") String pointNo, @Param(value = "pointId") String pointId);
Point selectPointInfo(long pointId);
}
package com.yeejoin.amos.patrol.business.dao.repository;
import com.yeejoin.amos.patrol.dao.entity.ESPlanTaskListDto;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface ESPlanTaskList extends PagingAndSortingRepository<ESPlanTaskListDto, String> {
}
package com.yeejoin.amos.patrol.business.dao.repository;
import com.yeejoin.amos.patrol.dao.entity.ESPlanTaskListDto;
import com.yeejoin.amos.patrol.dao.entity.ESTaskDetailDto;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface ESTaskDetail extends PagingAndSortingRepository<ESTaskDetailDto, String> {
}
package com.yeejoin.amos.patrol.business.dao.repository;
import com.yeejoin.amos.patrol.dao.entity.PlanTaskHistory;
import org.springframework.stereotype.Repository;
@Repository("planTaskHistoryDao")
public interface IPlanTaskHistoryDao extends BaseDao<PlanTaskHistory, Long> {
}
......@@ -59,6 +59,6 @@ public interface IPointInputItemDao extends BaseDao<PointInputItem, Long> {
@Modifying
@Transactional
@Query(value = "SELECT * FROM p_point_inputitem WHERE point_id = ?1 and classify_ids =?2", nativeQuery = true)
@Query(value = "SELECT * FROM p_point_inputitem WHERE point_id = ?1 limit 1", nativeQuery = true)
List<PointInputItem> getPointInputItemByPointIdAndClassifyId(Long pointId,Long classifyId);
}
......@@ -12,7 +12,7 @@ import java.util.List;
@Repository("iRoutePointDao")
public interface IRoutePointDao extends BaseDao<RoutePoint, Long> {
@Query(value = "SELECT COUNT( point_id ) FROM p_route_point where route_id = ?1", nativeQuery = true)
@Query(value = "SELECT COUNT( point_id ) cont FROM p_route_point where route_id = ?1", nativeQuery = true)
int countRoutePoint(Long routeId);
@Query(value = "SELECT * FROM p_route_point where point_id = ?1", nativeQuery = true)
......
......@@ -9,6 +9,7 @@ public interface RepositoryTs {
// 批量更新的方法
<S> Iterable<S> batchUpdate(Iterable<S> var1);
<S> Iterable<S> batchSaveNoAsync(Iterable<S> var1);
}
package com.yeejoin.amos.patrol.business.dto;
import lombok.Data;
import java.util.Collection;
@Data
public class PlanTaskStaticDto {
private String planTaskId;
private String finshNum;
private String omission;
private String unqualified;
private String unplan;
private String taskPlanNum;
}
\ No newline at end of file
......@@ -3,8 +3,11 @@ package com.yeejoin.amos.patrol.business.entity.mybatis;
import java.util.Date;
public class PointCheckDetailBo {
private Long id;
private long pointId;
private long inputItemId;
private String pointName;
......@@ -18,6 +21,14 @@ public class PointCheckDetailBo {
private String defaultValue;
public long getId() {
return id;
}
public long getInputItemId() {
return inputItemId;
}
public String getDefaultValue() {
return defaultValue;
}
......
......@@ -39,6 +39,8 @@ import com.yeejoin.amos.patrol.core.util.DateUtil;
import com.yeejoin.amos.patrol.core.util.StringUtil;
import com.yeejoin.amos.patrol.dao.entity.*;
import com.yeejoin.amos.patrol.feign.RemoteSecurityService;
import com.yeejoin.amos.patrol.quartz.IJobService;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.assertj.core.util.Sets;
......@@ -102,6 +104,9 @@ public class CheckServiceImpl implements ICheckService {
IEquipmentHandlerService equipmentHandlerService;
@Autowired
IJobService jobService;
@Autowired
private IPointClassifyDao iPointClassifyDao;
@Autowired
......@@ -114,8 +119,20 @@ public class CheckServiceImpl implements ICheckService {
private CheckInputMapper checkInputMapper;
@Autowired
ESTaskDetail esTaskDetail;
@Autowired
PointMapper pointMapper;
@Autowired
private IdxFeign idxFeign;
private String P_STATIC_DAY = "p_static_day";
private String P_STATIC_MONTH = "p_static_month";
private String P_STATIC_WEEK = "p_static_week";
@PersistenceContext
private final EntityManager em;
......@@ -462,7 +479,6 @@ public class CheckServiceImpl implements ICheckService {
}
@Override
@Transactional
public CheckDto saveCheckRecordNew(CheckRecordParam requestParam , PlanTask planTask) {
......@@ -485,9 +501,6 @@ public class CheckServiceImpl implements ICheckService {
routeParam.put("routeId", planTask.getRouteId());
routeParam.put("pointId", requestParam.getPointId());
if (ObjectUtils.isEmpty(check)) {
check = new Check();
}
check.setPlanTaskDetailId(Long.parseLong(detail.get("planTaskDetailId").toString()));
check.setRouteId(Long.parseLong(detail.get("routeId").toString()));
check.setRouteName(detail.get("routeName").toString());
......@@ -528,21 +541,21 @@ public class CheckServiceImpl implements ICheckService {
check.setUserName(requestParam.getUserName());
check.setCheckMode(requestParam.getCheckMode());
// check.setCheckMode(requestParam.getCheckMode());
List<CheckInputParam> list = requestParam.getCheckItems();
List<CheckInput> checkItemList = new ArrayList<>();
List<Map<String, Object>> unqualifiedcheckItemList = Lists.newArrayList();
String error = "";
HashMap<String, String> errorClassifyNames = new HashMap<>();
// HashMap<String, String> errorClassifyNames = new HashMap<>();
int score = 0;
for (CheckInputParam item : list) {
String pointClassifyName = null;
PointClassify pointClassify = null;
if (StringUtil.isNotEmpty(item.getClassifyIds()) && iPointClassifyDao.existsById(item.getClassifyIds())) {
pointClassify = iPointClassifyDao.findById(item.getClassifyIds()).get();
pointClassifyName = pointClassify.getName();
}
// String pointClassifyName = null;
// PointClassify pointClassify = null;
// if (StringUtil.isNotEmpty(item.getClassifyIds()) && iPointClassifyDao.existsById(item.getClassifyIds())) {
// pointClassify = iPointClassifyDao.findById(item.getClassifyIds()).get();
// pointClassifyName = pointClassify.getName();
// }
InputItem inputItem = inputItemDao.findById(item.getInputItemId()).get();
CheckInput checkInput = new CheckInput();
......@@ -563,9 +576,9 @@ public class CheckServiceImpl implements ICheckService {
}
if (XJConstant.NO.equals(checkInput.getIsOk())) {
String classifyName = pointClassifyName != null ? pointClassifyName + "-" : "";
error += (classifyName + inputItem.getName() + "=" + (ObjectUtils.isEmpty(item.getInputValue()) ? "" : item.getInputValue()) + ";");
errorClassifyNames.put(pointClassifyName != null ? pointClassifyName : "", "");
// String classifyName = pointClassifyName != null ? pointClassifyName + "-" : "";
error += ( inputItem.getName() + "=" + (ObjectUtils.isEmpty(item.getInputValue()) ? "" : item.getInputValue()) + ";");
// errorClassifyNames.put(pointClassifyName != null ? pointClassifyName : "", "");
checkInput.setIsOk(CheckStatusEnum.UNQUALIFIED.getCode());
Map<String, Object> unCheckMap = Maps.newHashMap();
unCheckMap.put("itemId", item.getInputItemId());
......@@ -582,7 +595,7 @@ public class CheckServiceImpl implements ICheckService {
checkInput.setRoutePointItemId(item.getRoutePointItemId());
checkInput.setInputValue(item.getInputValue());
checkInput.setPointClassifyId(item.getClassifyIds());
checkInput.setPointClassifyName(pointClassifyName);
// checkInput.setPointClassifyName(pointClassifyName);
score += checkInput.getScore();
checkItemList.add(checkInput);
}
......@@ -599,8 +612,29 @@ public class CheckServiceImpl implements ICheckService {
taskDetail.setStatus(CheckStatusEnum.QUALIFIED.getCode());
}
planTaskDetailDao.saveAndFlush(taskDetail);
ESTaskDetailDto esTaskDetailDto = esTaskDetail.findById(String.valueOf(taskDetail.getId())).get();
esTaskDetailDto.setPointStatus(String.valueOf(taskDetail.getIsFinish()));
JSONObject appCheckInput = esTaskDetailDto.getAppCheckInput();
List<CheckInputParam> checkItems = requestParam.getCheckItems();
Map<String,List<Map<String,Object>>> mapList = (Map<String,List<Map<String,Object>>>)JSON.parse(appCheckInput.toJSONString());
List<AppCheckInputRespone> appCheckInputRespones = new ArrayList<>();
for (Map<String,Object> map : mapList.get("items")) {
AppCheckInputRespone appCheckInputRespone = new AppCheckInputRespone();
CheckInputParam checkInputId = checkItems.stream().filter(x -> x.getInputItemId()== Long.valueOf(map.get("checkInputId").toString())).collect(Collectors.toList()).get(0);
BeanUtils.copyProperties(appCheckInputRespone, map);
appCheckInputRespone.setInputValue(checkInputId.getInputValue());
appCheckInputRespone.setPointInputImgUrls(ObjectUtils.isEmpty(checkInputId) ? new ArrayList<>() : checkInputId.getCheckInputImg());
appCheckInputRespones.add(appCheckInputRespone);
}
appCheckInput.put("items", appCheckInputRespones);
esTaskDetailDto.setPointImgUrls(requestParam.getCheckRecordImg());
esTaskDetailDto.setAppCheckInput(appCheckInput);
esTaskDetail.save(esTaskDetailDto);
check.setError(error);
check.setErrorClassify(StringUtils.join(errorClassifyNames.keySet(), ","));
// check.setErrorClassify(StringUtils.join(errorClassifyNames.keySet(), ","));
try {
log.error("手机app保存巡检记录++++++++++++++++++++++" + check.toString() + "<Over><Over><Over><Over>");
......@@ -921,6 +955,9 @@ public class CheckServiceImpl implements ICheckService {
pointImgUrls.add(action.getPhotoData());
});
Check check = checkDao.findById(checkId).get();
pointCheckRespone.setId(planPointInfo.getId());
pointCheckRespone.setPlanTaskId(planTaskId);
pointCheckRespone.setTaskStatus(planPointInfo.getTaskStatus());
pointCheckRespone.setPointStatus(planPointInfo.getPointStatus());
pointCheckRespone.setBeginTime(planPointInfo.getBeginTime());
......@@ -1157,8 +1194,11 @@ public class CheckServiceImpl implements ICheckService {
public Map<String, Object> checkCalendarNew(String checkTime, String orgCode,String type,String userId) throws ParseException {
Map<String, Object> result = new HashMap<>();
Calendar calendar = new GregorianCalendar();
Calendar calendarNew = new GregorianCalendar();
calendarNew.setTime(new Date());
String startTime = "" ;
String endTime = "";
String table = "";
if(type.equals(String.valueOf(PlanTaskTypeStatusEnum.week.getValue()))) {
Date startMonthDate = DateUtils.getStartMonthDate(checkTime, DateUtils.DATE_PATTERN);
Date endMonthDate = DateUtils.getEndMonthDate(checkTime, DateUtils.DATE_PATTERN);
......@@ -1181,9 +1221,32 @@ public class CheckServiceImpl implements ICheckService {
} else {
endTime = DateUtils.dateTimeToDateString(calendar.getTime());
}
int sYear = calendar.get(Calendar.YEAR);
int year = calendarNew.get(Calendar.YEAR);
if(sYear == year) {
table = P_STATIC_WEEK;
} else {
table = P_STATIC_DAY + "_" + sYear;
}
}
if(type.equals(String.valueOf(PlanTaskTypeStatusEnum.day.getValue()))) {
calendar.setTime(DateUtils.dateParse(checkTime, DateUtils.MONTH_PATTERN));
int sYear = calendar.get(Calendar.YEAR);
int sMonth = calendar.get(Calendar.MONTH) + 1;
int month = calendarNew.get(Calendar.MONTH) + 1;
if(sMonth == month) {
table = P_STATIC_DAY;
} else {
table = P_STATIC_DAY + "_" + sYear+sMonth;
}
}
if(type.equals(String.valueOf(PlanTaskTypeStatusEnum.month.getValue()))) {
table = P_STATIC_MONTH;
}
List<Map<String, Object>> list = checkMapper.planCount(checkTime, orgCode, type, userId,startTime,endTime);
List<Map<String, Object>> list = checkMapper.planCountNew(checkTime, orgCode, table, type,startTime,endTime);
result.put("calendarData", list);
return result;
}
......
......@@ -2,12 +2,16 @@ package com.yeejoin.amos.patrol.business.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.patrol.business.bo.CheckInputSyncBo;
import com.yeejoin.amos.patrol.business.bo.PlanTaskSyncBo;
import com.yeejoin.amos.patrol.business.dao.mapper.CheckMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.PlanTaskMapper;
import com.yeejoin.amos.patrol.business.dao.repository.IPlanTaskDao;
import com.yeejoin.amos.patrol.business.dao.repository.IPlanTaskDetailDao;
import com.yeejoin.amos.patrol.business.service.intfc.IPatrolDataSyncService;
import com.yeejoin.amos.patrol.common.enums.PatrolDataSyncTopicEnum;
import com.yeejoin.amos.patrol.common.enums.PlanTaskTypeStatusEnum;
import com.yeejoin.amos.patrol.dao.entity.*;
import com.yeejoin.amos.patrol.mqtt.WebMqttComponent;
import lombok.extern.slf4j.Slf4j;
......@@ -18,10 +22,9 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
@Service
@Async
......@@ -40,6 +43,19 @@ public class PatrolDataSyncServiceImpl implements IPatrolDataSyncService {
@Value("${emq.patrol.sync.switch}")
private Boolean patrolSyncSwitch;
@Autowired
private CheckMapper checkMapper;
private String P_STATIC_DAY = "p_static_day";
private String P_STATIC_MONTH = "p_static_month";
private String P_STATIC_WEEK = "p_static_week";
@Autowired
private PlanTaskMapper planTaskMapper;
@Override
public void checkDataSync(Check check) {
if (check != null) {
......@@ -238,7 +254,48 @@ public class PatrolDataSyncServiceImpl implements IPatrolDataSyncService {
}
}
@Override
@Async("asyncServiceExecutor")
public void taskStatic(String runDate) {
try {
runDate = DateUtils.dateFormat(new Date(), DateUtils.DATE_PATTERN);
} catch (ParseException e) {
e.printStackTrace();
}
log.info("开始更新统计表========");
// 插入日统计表
List<Map<String, Object>> listDay = checkMapper.planCount(runDate, null, String.valueOf(PlanTaskTypeStatusEnum.day.getValue()), null,null,null);
List<StaticDay> staticDays = listDay.stream().map(e->{
String s = JSON.toJSONString(e);
StaticDay staticDay = JSON.parseObject(s, StaticDay.class);
return staticDay;
}).collect(Collectors.toList());
// 插入周统计表
List<Map<String, Object>> listWeek = checkMapper.planCount(runDate, null, String.valueOf(PlanTaskTypeStatusEnum.week.getValue()), null,null,null);
List<StaticDay> staticWeeks = listWeek.stream().map(e->{
String s = JSON.toJSONString(e);
StaticDay staticWeek = JSON.parseObject(s, StaticDay.class);
return staticWeek;
}).collect(Collectors.toList());
// 插入月统计表
List<Map<String, Object>> listMonth = checkMapper.planCount(runDate, null, String.valueOf(PlanTaskTypeStatusEnum.month.getValue()), null,null,null);
List<StaticDay> staticMonths = listMonth.stream().map(e->{
String s = JSON.toJSONString(e);
StaticDay staticMonth = JSON.parseObject(s, StaticDay.class);
return staticMonth;
}).collect(Collectors.toList());
if(staticDays.size() > 0) {
planTaskMapper.updateData(P_STATIC_DAY,staticDays);
}
if(staticWeeks.size() > 0) {
planTaskMapper.updateData(P_STATIC_WEEK,staticDays);
}
if(staticMonths.size() > 0) {
planTaskMapper.updateData(P_STATIC_MONTH,staticDays);
}
log.info("更新统计表完成=======");
}
public String buildSyncMessage(String topic, Object object) {
Map<String, Object> map = new HashMap<>();
......
package com.yeejoin.amos.patrol.business.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.patrol.business.constants.XJConstant;
import com.yeejoin.amos.patrol.business.dao.mapper.PlanMapper;
import com.yeejoin.amos.patrol.business.dao.repository.IPlanDao;
import com.yeejoin.amos.patrol.business.dao.repository.IPlanTaskDao;
import com.yeejoin.amos.patrol.business.dao.repository.IPlanTaskDetailDao;
import com.yeejoin.amos.patrol.business.dao.mapper.PlanTaskMapper;
import com.yeejoin.amos.patrol.business.dao.repository.*;
import com.yeejoin.amos.patrol.business.entity.mybatis.PointCheckDetailBo;
import com.yeejoin.amos.patrol.business.param.PlanInfoPageParam;
import com.yeejoin.amos.patrol.business.service.intfc.ICheckService;
import com.yeejoin.amos.patrol.business.service.intfc.IPlanService;
import com.yeejoin.amos.patrol.core.common.response.AppCheckInputRespone;
import com.yeejoin.amos.patrol.core.common.response.AppPointCheckRespone;
import com.yeejoin.amos.patrol.core.util.DateUtil;
import com.yeejoin.amos.patrol.core.util.StringUtil;
import com.yeejoin.amos.patrol.dao.entity.Check;
import com.yeejoin.amos.patrol.dao.entity.CheckInput;
import com.yeejoin.amos.patrol.dao.entity.CheckShot;
import com.yeejoin.amos.patrol.dao.entity.Plan;
import liquibase.pro.packaged.L;
import org.slf4j.Logger;
......@@ -21,6 +28,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
@Service("planService")
public class PlanServiceImpl implements IPlanService {
......@@ -44,7 +52,104 @@ public class PlanServiceImpl implements IPlanService {
Page<HashMap<String, Object>> result = new PageImpl<HashMap<String, Object>>(content, param, total);
return result;
}
@Autowired
private ICheckDao checkDao;
@Autowired
private ICheckService checkService;
@Autowired
PlanTaskMapper planTaskMapper;
@Autowired
private ICheckShotDao iCheckShotDao;
@Override
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.queryCheckPointDetailInVersion2(toke, product, appKey, check.getId(), planTaskId, pointId);
} else {
PointCheckDetailBo planPointInfo = planTaskMapper.getPointPlanTaskInfo(planTaskId, pointId);
pointCheckRespone.setTaskStatus(planPointInfo.getTaskStatus());
pointCheckRespone.setPointStatus(planPointInfo.getPointStatus());
if (planPointInfo != null) {
if(check != null) {
List<CheckShot> checkShots = iCheckShotDao.findAllByCheckIdAndCheckInputId(check.getId(),
0L);
List<String> photos = new ArrayList<>();
if (!org.springframework.util.CollectionUtils.isEmpty(checkShots)) {
photos = checkShots.stream().map(e -> {
if (e != null) {
return e.getPhotoData().replaceAll("\\\\", "/");
} else {
return "";
}
}).collect(Collectors.toList());
}
pointCheckRespone.setPointImgUrls(photos);
}
pointCheckRespone.setId(planPointInfo.getId());
pointCheckRespone.setPlanTaskId(Long.valueOf(planPointInfo.getPlanTaskId()));
pointCheckRespone.setPointId(pointId);
pointCheckRespone.setPointName(planPointInfo.getPointName());
pointCheckRespone.setPointNo(planPointInfo.getPointNo());
pointCheckRespone.setBeginTime(planPointInfo.getBeginTime());
pointCheckRespone.setEndTime(planPointInfo.getEndTime());
pointCheckRespone.setPlanName(planPointInfo.getPlanName());
pointCheckRespone.setShortMaxNumber(planPointInfo.getShortMaxNumber());
pointCheckRespone.setShortMinNumber(planPointInfo.getShortMinNumber());
List<PointCheckDetailBo> pointInputs = planTaskMapper.getPointInputByRouteIdAndPointId(planPointInfo.getRouteId(), planPointInfo.getPointId());
JSONObject appResponeMap = new JSONObject();
List<AppCheckInputRespone> appCheckInputResponeList = new ArrayList<AppCheckInputRespone>();
pointInputs.forEach(action -> {
AppCheckInputRespone input = new AppCheckInputRespone();
input.setInputName(action.getInputName());
input.setCheckInputId(action.getCheckInputId());
input.setDefaultValue(action.getDefaultValue());
input.setDataJson(action.getDataJson());
input.setIsMultiline(action.getIsMultiline());
input.setIsMust(action.getIsMust());
input.setInputValue(null);
if(null != check) {
for (CheckInput ck :check.getCheckInput()
) {
if(ck.getInputId().toString().equals(String.valueOf(action.getCheckInputId()))) {
input.setInputValue(ck.getInputValue());
}
}
List<CheckShot> checkShotsNew = iCheckShotDao.findAllByCheckIdAndCheckInputId(check.getId(),
action.getCheckInputId());
List<String> photosNew = new ArrayList<>();
if (!org.springframework.util.CollectionUtils.isEmpty(checkShotsNew)) {
photosNew = checkShotsNew.stream().map(e -> {
if (e != null) {
return e.getPhotoData().replaceAll("\\\\", "/");
} else {
return "";
}
}).collect(Collectors.toList());
}
input.setPointInputImgUrls(photosNew);
}
input.setItemType(action.getItemType());
input.setOrderNo(action.getOrderNo());
input.setPictureJson(action.getPictureJson());
input.setClassifyId(action.getClassifyId());
input.setClassifyName(action.getClassifyName());
appCheckInputResponeList.add(input);
});
appResponeMap.put("items", appCheckInputResponeList);
pointCheckRespone.setAppCheckInput(appResponeMap);
}
}
return pointCheckRespone;
}
@Override
public Plan addPlan(HashMap<String, Object> map) {
Plan param = (Plan) map.get("param");
......
......@@ -5,35 +5,63 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Joiner;
import com.sun.corba.se.impl.activation.RepositoryImpl;
import com.yeejoin.amos.boot.biz.common.constants.RuleConstant;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.component.robot.AmosRequestContext;
import com.yeejoin.amos.component.rule.RuleTrigger;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.patrol.business.constants.XJConstant;
import com.yeejoin.amos.patrol.business.dao.mapper.*;
import com.yeejoin.amos.patrol.business.dao.repository.*;
import com.yeejoin.amos.patrol.business.dao.mapper.CheckMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.PlanMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.PlanTaskDetailMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.PlanTaskMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.PointMapper;
import com.yeejoin.amos.patrol.business.dao.repository.ESPlanTaskList;
import com.yeejoin.amos.patrol.business.dao.repository.ESTaskDetail;
import com.yeejoin.amos.patrol.business.dao.repository.ICheckDao;
import com.yeejoin.amos.patrol.business.dao.repository.ICheckShotDao;
import com.yeejoin.amos.patrol.business.dao.repository.IInputItemDao;
import com.yeejoin.amos.patrol.business.dao.repository.IPlanDao;
import com.yeejoin.amos.patrol.business.dao.repository.IPlanTaskDao;
import com.yeejoin.amos.patrol.business.dao.repository.IPlanTaskDetailDao;
import com.yeejoin.amos.patrol.business.dao.repository.IPlanTaskHistoryDao;
import com.yeejoin.amos.patrol.business.dao.repository.IRouteDao;
import com.yeejoin.amos.patrol.business.dao.repository.IRoutePointDao;
import com.yeejoin.amos.patrol.business.dao.repository.RepositoryTs;
import com.yeejoin.amos.patrol.business.dto.MsgRo;
import com.yeejoin.amos.patrol.business.dto.PlanTaskStaticDto;
import com.yeejoin.amos.patrol.business.dto.UserDetailsDto;
import com.yeejoin.amos.patrol.business.entity.mybatis.CheckChkExListBo;
import com.yeejoin.amos.patrol.business.entity.mybatis.PointCheckDetailBo;
import com.yeejoin.amos.patrol.business.feign.*;
import com.yeejoin.amos.patrol.business.feign.Business;
import com.yeejoin.amos.patrol.business.feign.IdxFeign;
import com.yeejoin.amos.patrol.business.feign.JcsFeignClient;
import com.yeejoin.amos.patrol.business.feign.TzsFeign;
import com.yeejoin.amos.patrol.business.param.CheckPtListPageParam;
import com.yeejoin.amos.patrol.business.param.PlanTaskPageParam;
import com.yeejoin.amos.patrol.business.service.intfc.ICheckService;
import com.yeejoin.amos.patrol.business.service.intfc.IPatrolDataSyncService;
import com.yeejoin.amos.patrol.business.service.intfc.IPlanService;
import com.yeejoin.amos.patrol.business.service.intfc.IPlanTaskService;
import com.yeejoin.amos.patrol.business.util.MyByteArrayMultipartFile;
import com.yeejoin.amos.patrol.business.util.PlanTaskUtil;
import com.yeejoin.amos.patrol.business.util.Toke;
import com.yeejoin.amos.patrol.business.util.WordTemplateUtils;
import com.yeejoin.amos.patrol.business.vo.*;
import com.yeejoin.amos.patrol.common.enums.*;
import com.yeejoin.amos.patrol.business.vo.CalDateVo;
import com.yeejoin.amos.patrol.business.vo.CodeOrderVo;
import com.yeejoin.amos.patrol.business.vo.DefectVo;
import com.yeejoin.amos.patrol.business.vo.LeavePlanTaskVo;
import com.yeejoin.amos.patrol.business.vo.PlanTaskVo;
import com.yeejoin.amos.patrol.common.enums.NotifyBusinessTypeEum;
import com.yeejoin.amos.patrol.common.enums.PlanTaskDetailIsFinishEnum;
import com.yeejoin.amos.patrol.common.enums.PlanTaskDetailStatusEnum;
import com.yeejoin.amos.patrol.common.enums.PlanTaskFinishStatusEnum;
import com.yeejoin.amos.patrol.common.enums.PlanTaskTheStatusEnum;
import com.yeejoin.amos.patrol.common.enums.PlanTaskTypeStatusEnum;
import com.yeejoin.amos.patrol.core.common.request.CommonPageable;
import com.yeejoin.amos.patrol.core.common.response.AppCheckInputRespone;
import com.yeejoin.amos.patrol.core.common.response.AppPointCheckRespone;
......@@ -41,24 +69,54 @@ import com.yeejoin.amos.patrol.core.enums.DefectLevelEnum;
import com.yeejoin.amos.patrol.core.enums.WordTemplateEnum;
import com.yeejoin.amos.patrol.core.util.DateUtil;
import com.yeejoin.amos.patrol.core.util.StringUtil;
import com.yeejoin.amos.patrol.dao.entity.*;
import com.yeejoin.amos.patrol.dao.entity.Check;
import com.yeejoin.amos.patrol.dao.entity.CheckHistory;
import com.yeejoin.amos.patrol.dao.entity.CheckInput;
import com.yeejoin.amos.patrol.dao.entity.CheckInputHistory;
import com.yeejoin.amos.patrol.dao.entity.CheckShot;
import com.yeejoin.amos.patrol.dao.entity.CheckShotHistory;
import com.yeejoin.amos.patrol.dao.entity.ESPlanTaskListDto;
import com.yeejoin.amos.patrol.dao.entity.ESTaskDetailDto;
import com.yeejoin.amos.patrol.dao.entity.InputItem;
import com.yeejoin.amos.patrol.dao.entity.Plan;
import com.yeejoin.amos.patrol.dao.entity.PlanTask;
import com.yeejoin.amos.patrol.dao.entity.PlanTaskDetail;
import com.yeejoin.amos.patrol.dao.entity.PlanTaskDetailHistory;
import com.yeejoin.amos.patrol.dao.entity.PlanTaskHistory;
import com.yeejoin.amos.patrol.dao.entity.Route;
import com.yeejoin.amos.patrol.dao.entity.StaticDay;
import com.yeejoin.amos.patrol.dao.entity.StaticMonth;
import com.yeejoin.amos.patrol.dao.entity.StaticWeek;
import com.yeejoin.amos.patrol.exception.YeeException;
import com.yeejoin.amos.patrol.feign.RemoteSecurityService;
import com.yeejoin.amos.patrol.quartz.IJobService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.compress.utils.Lists;
import org.apache.commons.compress.utils.Sets;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationAdapter;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StopWatch;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.context.RequestContext;
......@@ -66,31 +124,73 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.annotation.Resource;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Function;
import java.util.stream.Collectors;
import static com.alibaba.fastjson.JSON.toJSONString;
@Service("planTaskService")
@EnableAsync
public class PlanTaskServiceImpl implements IPlanTaskService {
private final Logger log = LoggerFactory.getLogger(PlanTaskServiceImpl.class);
@Resource
private DataSource dataSource;
@Autowired
ESPlanTaskList esPlanTaskList;
@Autowired
ESTaskDetail esTaskDetail;
@Autowired
IPlanService planService;
@Autowired
PlanTaskMapper planTaskMapper;
@Autowired
PlanTaskDetailMapper planTaskDetailMapper;
@Autowired
IInputItemDao inputItemDao;
@Autowired
private CheckMapper checkMapper;
@Autowired
PlanMapper planMapper;
@Autowired
IPlanTaskDao iplanTaskDao;
......@@ -111,6 +211,9 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
IRouteDao routeDao;
@Autowired
IPlanTaskHistoryDao planTaskHistoryDao;
@Autowired
IJobService jobService;
@Autowired
......@@ -143,10 +246,26 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
@Autowired
private ICheckShotDao iCheckShotDao;
@Autowired
PointMapper pointMapper;
@Autowired
private RepositoryTs repositoryTs;
@Autowired
RestHighLevelClient restHighLevelClient;
@Autowired
AmosRequestContext amosRequestContext;
private String DB = "amos_tzs_biz.";
private String P_STATIC_DAY = "p_static_day";
private String P_STATIC_MONTH = "p_static_month";
private String P_STATIC_WEEK = "p_static_week";
@PersistenceContext
private final EntityManager em;
......@@ -375,14 +494,16 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
//3.删除planTask表,按照计划id+日期
deletePlanTaskAndDet(param);
List<ESPlanTaskListDto> oldEsPlanTaskListDtos = deletePlanTaskAndDet(param);
//5.执行数据生成(具体时间 + 人员)
List<HashMap<String, Object>> list = genAllExeDate(plan, vo, XJConstant.REGEN_FLAG);
//6.插入planTask及planTaskDetail
insertPlanTaskAndDetNew(list, plan, flag, new Date());
insertPlanTaskAndDetNew(list, plan, flag, new Date(),oldEsPlanTaskListDtos);
// 更新统计表
taskStaticExecution(null);
}
......@@ -634,9 +755,93 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
//2.5.插入planTask及planTaskDetail
insertPlanTaskAndDetNew(list, plan, XJConstant.SCHED_FLAG, now);
insertPlanTaskAndDetNew(list, plan, XJConstant.SCHED_FLAG, now, null);
// 更新统计表
taskStaticExecution(null);
}
}
/**
* 自动任务执行
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void taskStaticExecution(String runDate) {
log.info("开始初始化统计表=======");
try {
runDate = DateUtils.dateFormat(new Date(), DateUtils.DATE_PATTERN);
} catch (ParseException e) {
e.printStackTrace();
}
// 判断当天是不是月第一天
int date = DateUtils.getDate(new Date());
int month = DateUtils.getMonth(new Date());
if(date == 1) {
// 日统计表按月归档
Calendar calendar = new GregorianCalendar();
calendar.setTime(new Date());
calendar.add(Calendar.DATE, -1);
Date oldDate = calendar.getTime();
try {
String s = DateUtils.dateFormat(oldDate, DateUtils.MONTH_PATTERN);
s = s.replace("-","");
createNeedTime(P_STATIC_DAY,DB,P_STATIC_DAY+"_"+s);
List<StaticDay> staticDay = planTaskMapper.findStaticDay();
Iterable join = CompletableFuture.supplyAsync(() -> repositoryTs.batchSave(staticDay)).join();
if(!ValidationUtil.isEmpty(join)){
planTaskMapper.deleteDate(P_STATIC_DAY);
}
} catch (ParseException e) {
e.printStackTrace();
}
if(month == 1) {
try {
String s = DateUtils.dateFormat(oldDate, DateUtils.YEAR_PATTERN);
createNeedTime(P_STATIC_WEEK,DB,P_STATIC_WEEK+"_"+s);
List<StaticDay> staticWeeks = planTaskMapper.findStaticWeek();
Iterable join = CompletableFuture.supplyAsync(() -> repositoryTs.batchSave(staticWeeks)).join();
if (!ValidationUtil.isEmpty(join)) {
planTaskMapper.deleteDate(P_STATIC_WEEK);
}
} catch (ParseException e) {
e.printStackTrace();
}
}
}
planTaskMapper.deleteOne(P_STATIC_DAY, runDate);
planTaskMapper.deleteOne(P_STATIC_WEEK, runDate);
planTaskMapper.deleteOne(P_STATIC_MONTH, runDate);
// 插入日统计表
List<Map<String, Object>> listDay = checkMapper.planCount(runDate, null, String.valueOf(PlanTaskTypeStatusEnum.day.getValue()), null,null,null);
List<StaticDay> staticDays = listDay.stream().map(e->{
String s = JSON.toJSONString(e);
StaticDay staticDay = JSON.parseObject(s, StaticDay.class);
return staticDay;
}).collect(Collectors.toList());
// 插入周统计表
List<Map<String, Object>> listWeek = checkMapper.planCount(runDate, null, String.valueOf(PlanTaskTypeStatusEnum.week.getValue()), null,null,null);
List<StaticWeek> staticWeeks = listWeek.stream().map(e->{
String s = JSON.toJSONString(e);
StaticWeek staticWeek = JSON.parseObject(s, StaticWeek.class);
return staticWeek;
}).collect(Collectors.toList());
// 插入月统计表
List<Map<String, Object>> listMonth = checkMapper.planCount(runDate, null, String.valueOf(PlanTaskTypeStatusEnum.month.getValue()), null,null,null);
List<StaticMonth> staticMonths = listMonth.stream().map(e->{
String s = JSON.toJSONString(e);
StaticMonth staticMonth = JSON.parseObject(s, StaticMonth.class);
return staticMonth;
}).collect(Collectors.toList());
repositoryTs.batchSave(staticDays);
repositoryTs.batchSave(staticWeeks);
repositoryTs.batchSave(staticMonths);
log.info("初始化统计表完成=======");
}
/**
......@@ -644,14 +849,18 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
*
* @param param
*/
public void deletePlanTaskAndDet(HashMap<String, Object> param) {
public List<ESPlanTaskListDto> deletePlanTaskAndDet(HashMap<String, Object> param) {
param.put("beginDate", param.get("beginDate") + " " + "00:00:00");
param.put("endDate", param.get("endDate") + " " + "23:59:59");
List<Long> ids = planTaskMapper.getGenPlanTask(param);
List<ESPlanTaskListDto> planTaskList = new ArrayList<>();
for (long id : ids) {
iplanTaskDao.deleteById(id);
ESPlanTaskListDto esPlanTaskListDto = new ESPlanTaskListDto();
esPlanTaskListDto.setPlanTaskId(String.valueOf(id));
planTaskList.add(esPlanTaskListDto);
}
return planTaskList;
}
/**
......@@ -689,7 +898,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
return PlanTaskUtil.genWholeExeData(timeList, plan, userDetailsDtos, route);
}
private ExecutorService threadPool = Executors.newCachedThreadPool();
/**
* plantask及det入库
......@@ -698,8 +907,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
* @param plan
* @param flag 是否初始状态0-初始 1-非初始
*/
@Async("asyncServiceExecutor")
public void insertPlanTaskAndDetNew(List<HashMap<String, Object>> list, Plan plan, String flag, Date now) {
public void insertPlanTaskAndDetNew(List<HashMap<String, Object>> list, Plan plan, String flag, Date now, List<ESPlanTaskListDto> oldEsPlanTaskListDtos) {
if (list == null || list.size() <= 0) {
HashMap<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("id", plan.getId());
......@@ -715,6 +923,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
List<PlanTaskDetail> planTaskDetailListSync = new ArrayList<>();
PlanTask planTask = new PlanTask();
List<PlanTask> taskList = new ArrayList<>();
List<ESPlanTaskListDto> esPlanTaskListDtos = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startTime = list.get(i).get("BEGIN_TIME").toString();
......@@ -795,17 +1004,24 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
//// planTaskDetail.saveAndFlush(planTaskDetailInstance);
planTaskDetailListSync.add(planTaskDetailInstance);
}
ESPlanTaskListDto esPlanTaskListDto = JSONObject.parseObject(toJSONString(planTask),
ESPlanTaskListDto.class);
esPlanTaskListDto.setPlanTaskId(String.valueOf(planTask.getId()));
esPlanTaskListDto.setPlanId(String.valueOf(plan.getId()));
esPlanTaskListDto.setTaskName(plan.getName());
esPlanTaskListDtos.add(esPlanTaskListDto);
}
em.flush();
em.clear();
// mybatisService.saveBatch(taskList);
// repositoryTs.batchSave(taskList);
repositoryTs.batchSave(planTaskDetailListSync);
// 定时任务监控
log.error("计划重做开始添加定时任务监控========");
jobService.planTaskAddJob(planTask);
Iterable<PlanTaskDetail> planTaskDetails = repositoryTs.batchSaveNoAsync(planTaskDetailListSync);
// 3.如果为自动任务调用,则更新id,如果重做或且下次时间大于等于明天,则更新planTaskId到plan表
Date genDate = DateUtil.str2Date(list.get(list.size() - 1).get("NEXT_GEN_DATE").toString(), "yyyy-MM-dd");//下次生成日期
......@@ -826,6 +1042,11 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
paramMap.put("next_gen_date", DateUtil.formatDatrToStr(now, "yyyy-MM-dd"));
}
planMapper.updPlanStatusOrGenDate(paramMap);// 更新下次任务生成日期
//存在事物,在事务提交之后执行
asyncSaveEs(planTaskDetails, esPlanTaskListDtos, oldEsPlanTaskListDtos);
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
......@@ -834,9 +1055,229 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
}
private void asyncSaveEs(Iterable<PlanTaskDetail> planTaskDetails, List<ESPlanTaskListDto> esPlanTaskListDtos, List<ESPlanTaskListDto> oldEsPlanTaskListDtos) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override
public void afterCommit() {
//异步存储任务和任务详情到es
asyncSavePlanTaskAndDetailListToEs(planTaskDetails, esPlanTaskListDtos, oldEsPlanTaskListDtos);
}
});
}
@Async
public void asyncSavePlanTaskAndDetailListToEs(Iterable<PlanTaskDetail> planTaskDetails, List<ESPlanTaskListDto> esPlanTaskListDtos, List<ESPlanTaskListDto> oldEsPlanTaskListDtos) {
log.info("异步存储任务和任务详情到es");
Plan plan = planMapper.getPlan(esPlanTaskListDtos.get(0).getPlanId());
StopWatch stopWatch = new StopWatch();
stopWatch.start();
List<String> taskIds = planTaskMapper.getPlanTaskIds(plan.getId());
List<ESTaskDetailDto> esTaskDetailDtos = new ArrayList<>();
if (!ValidationUtil.isEmpty(taskIds)) {
if (taskIds.size() > 5000) {
int index = 5000;
for (int i = 0; i < taskIds.size(); i += 5000) {
if (i + 5000 > taskIds.size()) {
index = taskIds.size() - i;
}
List<String> newList = taskIds.subList(i, i + index);
String ids = newList.stream().collect(Collectors.joining("','", "('", "')"));
List<ESTaskDetailDto> maps = planTaskMapper.selectTaskDetailList(ids);
esTaskDetailDtos.addAll(maps);
}
} else {
String ids = taskIds.stream().collect(Collectors.joining("','", "('", "')"));
List<ESTaskDetailDto> maps = planTaskMapper.selectTaskDetailList(ids);
esTaskDetailDtos.addAll(maps);
}
}
stopWatch.stop();
log.info("获取点详情基础数据,耗时:{} 秒",stopWatch.getTotalTimeSeconds());
StopWatch stopWatch1 = new StopWatch();
stopWatch1.start();
List<ESTaskDetailDto> esTaskInfo = planTaskMapper.selectTaskInfoList(plan.getId());
stopWatch1.stop();
log.info("获取点详情其他数据,耗时:{} 秒",stopWatch1.getTotalTimeSeconds());
List<AppCheckInputRespone> pointInputs = planTaskMapper.selectPointInputs(plan.getRouteId());
List<Map<String, String>> excludeItems = planTaskMapper.selectExcludeItemsByRoutId(plan.getRouteId());
StopWatch stopWatch2 = new StopWatch();
stopWatch2.start();
Map<String, List<ESTaskDetailDto>> collect1 = esTaskInfo.stream().collect(Collectors.groupingBy(ESTaskDetailDto::getPlanTaskId));
Map<String, List<AppCheckInputRespone>> collect2 = pointInputs.stream().collect(Collectors.groupingBy(AppCheckInputRespone::getPointId));
for (Map<String, String> excludeItem : excludeItems) {
String[] exclude_items = excludeItem.get("exclude_items").split(",");
List<AppCheckInputRespone> appCheckInputRespones = collect2.get(String.valueOf(excludeItem.get("point_id")));
List<AppCheckInputRespone> appCheckInputRespones1 = new ArrayList<>();
for (String exclude_item : exclude_items) {
appCheckInputRespones1.add(appCheckInputRespones.stream().filter(x -> x.getPointInputItemId().equals(exclude_item)).collect(Collectors.toList()).get(0));
}
appCheckInputRespones.removeAll(appCheckInputRespones1);
collect2.put(String.valueOf(excludeItem.get("point_id")), appCheckInputRespones);
}
for (ESTaskDetailDto esTaskDetailDto : esTaskDetailDtos) {
esTaskDetailDto.setPlanName(plan.getName());
esTaskDetailDto.setBeginTime(collect1.get(esTaskDetailDto.getPlanTaskId()).get(0).getBeginTime());
esTaskDetailDto.setEndTime(collect1.get(esTaskDetailDto.getPlanTaskId()).get(0).getEndTime());
esTaskDetailDto.setTaskStatus(collect1.get(esTaskDetailDto.getPlanTaskId()).get(0).getTaskStatus());
JSONObject appResponeMap = new JSONObject();
appResponeMap.put("items", collect2.get(esTaskDetailDto.getPointId()));
esTaskDetailDto.setAppCheckInput(appResponeMap);
}
stopWatch2.stop();
log.info("组装点详情数据,耗时:{} 秒",stopWatch2.getTotalTimeSeconds());
StopWatch stopWatch3 = new StopWatch();
stopWatch3.start();
if (!ValidationUtil.isEmpty(esTaskDetailDtos)) {
if (esTaskDetailDtos.size() > 5000) {
int index = 5000;
for (int i = 0; i < esTaskDetailDtos.size(); i += 5000) {
if (i + 5000 > esTaskDetailDtos.size()) {
index = esTaskDetailDtos.size() - i;
}
List<ESTaskDetailDto> newList = esTaskDetailDtos.subList(i, i + index);
esTaskDetail.saveAll(newList);
}
} else {
esTaskDetail.saveAll(esTaskDetailDtos);
}
}
stopWatch3.stop();
log.info("点详情数据存入es,耗时:{} 秒",stopWatch3.getTotalTimeSeconds());
StopWatch stopWatch4 = new StopWatch();
stopWatch4.start();
List<PlanTaskDetail> planTaskDetailList = new ArrayList<>();
if (!ValidationUtil.isEmpty(taskIds)) {
if (taskIds.size() > 5000) {
int index = 5000;
for (int i = 0; i < taskIds.size(); i += 5000) {
if (i + 5000 > taskIds.size()) {
index = taskIds.size() - i;
}
List<String> newList = taskIds.subList(i, i + index);
String ids = newList.stream().collect(Collectors.joining(",", "(", ")"));
List<PlanTaskDetail> maps = planTaskMapper.selectTaskDetails(ids);
planTaskDetailList.addAll(maps);
}
} else {
String ids = taskIds.stream().collect(Collectors.joining(",", "(", ")"));
List<PlanTaskDetail> maps = planTaskMapper.selectTaskDetails(ids);
planTaskDetailList.addAll(maps);
}
}
stopWatch4.stop();
log.info("planTaskDetails转化,耗时:{} 秒",stopWatch4.getTotalTimeSeconds());
StopWatch stopWatch5 = new StopWatch();
stopWatch5.start();
List<String> planTaskIds = esPlanTaskListDtos.stream().map(ESPlanTaskListDto::getPlanTaskId).collect(Collectors.toList());
List<PlanTaskStaticDto> planTaskStaticListMap = new ArrayList<>();
if (!ValidationUtil.isEmpty(planTaskIds)) {
if (planTaskIds.size() > 5000) {
int index = 5000;
for (int i = 0; i < planTaskIds.size(); i += 5000) {
if (i + 10000 > planTaskIds.size()) {
index = planTaskIds.size() - i;
}
List<String> newList = planTaskIds.subList(i, i + index);
String ids = newList.stream().collect(Collectors.joining("','", "('", "')"));
List<PlanTaskStaticDto> maps = queryPlanTaskStaticById(ids);
planTaskStaticListMap.addAll(maps);
}
} else {
String ids = planTaskIds.stream().collect(Collectors.joining("','", "('", "')"));
List<PlanTaskStaticDto> maps = queryPlanTaskStaticById(ids);
planTaskStaticListMap.addAll(maps);
}
}
stopWatch5.stop();
log.info("esPlanTaskListDtos统计组装,耗时:{} 秒",stopWatch5.getTotalTimeSeconds());
StopWatch stopWatch6 = new StopWatch();
stopWatch6.start();
Map<String, List<PlanTaskStaticDto>> collect3 = planTaskStaticListMap.stream().collect(Collectors.groupingBy(PlanTaskStaticDto::getPlanTaskId));
Map<Long, List<PlanTaskDetail>> collect = planTaskDetailList.stream().collect(Collectors.groupingBy(PlanTaskDetail::getTaskNo));
for (ESPlanTaskListDto esPlanTaskListDto : esPlanTaskListDtos) {
esPlanTaskListDto.setPoints(collect.get(Long.valueOf(esPlanTaskListDto.getPlanTaskId())));
if (!ValidationUtil.isEmpty(planTaskIds)) {
esPlanTaskListDto.setFinshNum(ObjectUtils.isEmpty(collect3.get(esPlanTaskListDto.getPlanTaskId()).get(0).getFinshNum()) ? "0" : collect3.get(esPlanTaskListDto.getPlanTaskId()).get(0).getFinshNum());
esPlanTaskListDto.setOmission(ObjectUtils.isEmpty(collect3.get(esPlanTaskListDto.getPlanTaskId()).get(0).getOmission()) ? "0" : collect3.get(esPlanTaskListDto.getPlanTaskId()).get(0).getOmission());
esPlanTaskListDto.setUnqualified(ObjectUtils.isEmpty(collect3.get(esPlanTaskListDto.getPlanTaskId()).get(0).getUnqualified()) ? "0" : collect3.get(esPlanTaskListDto.getPlanTaskId()).get(0).getUnqualified());
esPlanTaskListDto.setUnplan(ObjectUtils.isEmpty(collect3.get(esPlanTaskListDto.getPlanTaskId()).get(0).getUnplan()) ? "0" : collect3.get(esPlanTaskListDto.getPlanTaskId()).get(0).getUnplan());
esPlanTaskListDto.setTaskPlanNum(ObjectUtils.isEmpty(collect3.get(esPlanTaskListDto.getPlanTaskId()).get(0).getTaskPlanNum()) ? "0" : collect3.get(esPlanTaskListDto.getPlanTaskId()).get(0).getTaskPlanNum());
} else {
esPlanTaskListDto.setFinshNum("0");
esPlanTaskListDto.setOmission("0");
esPlanTaskListDto.setUnqualified("0");
esPlanTaskListDto.setUnplan("0");
esPlanTaskListDto.setTaskPlanNum("0");
}
}
stopWatch6.stop();
log.info("esPlanTaskListDtos数据组装,耗时:{} 秒",stopWatch6.getTotalTimeSeconds());
StopWatch stopWatch7 = new StopWatch();
stopWatch7.start();
saveEsPlanTaskList(esPlanTaskListDtos, oldEsPlanTaskListDtos);
stopWatch7.stop();
log.info("任务存入es,耗时:{} 秒",stopWatch7.getTotalTimeSeconds());
}
public static CheckInput paraseSelect(CheckInput checkInput, String json) {
JSONArray jsonArray = JSONArray.parseArray(json);
if (!ObjectUtils.isEmpty(jsonArray)) {
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
String validateName = jsonObject.getString("name");
String validateIsOk = jsonObject.getString("isOk");
if(validateIsOk.equals("是")) {
checkInput.setInputValue(validateName);
}
}
}
return checkInput;
}
private List<PlanTaskStaticDto> queryPlanTaskStaticById(String planTaskIds) {
return planTaskMapper.queryPlanTaskStaticById(planTaskIds);
}
public void saveEsPlanTaskList(List<ESPlanTaskListDto> esPlanTaskListDtos, List<ESPlanTaskListDto> oldEsPlanTaskListDtos) {
if (!ValidationUtil.isEmpty(oldEsPlanTaskListDtos)) {
if (oldEsPlanTaskListDtos.size() > 5000) {
int index = 5000;
for (int i = 0; i < oldEsPlanTaskListDtos.size(); i += 5000) {
if (i + 5000 > oldEsPlanTaskListDtos.size()) {
index = oldEsPlanTaskListDtos.size() - i;
}
List<ESPlanTaskListDto> newList = oldEsPlanTaskListDtos.subList(i, i + index);
esPlanTaskList.deleteAll(newList);
}
} else {
esPlanTaskList.deleteAll(oldEsPlanTaskListDtos);
}
}
if (!ValidationUtil.isEmpty(esPlanTaskListDtos)) {
if (esPlanTaskListDtos.size() > 5000) {
int index = 5000;
for (int i = 0; i < esPlanTaskListDtos.size(); i += 5000) {
if (i + 5000 > esPlanTaskListDtos.size()) {
index = esPlanTaskListDtos.size() - i;
}
List<ESPlanTaskListDto> newList = esPlanTaskListDtos.subList(i, i + index);
esPlanTaskList.saveAll(newList);
}
} else {
esPlanTaskList.saveAll(esPlanTaskListDtos);
}
}
}
/**
......@@ -853,7 +1294,6 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
paramMap.put("next_gen_date", DateUtil.formatDatrToStr(now, "yyyy-MM-dd"));
planMapper.updPlanStatusOrGenDate(paramMap);// 更新下次任务生成日期
}
Toke toke = remoteSecurityService.getServerToken();
Map<String, String> deptMap = new HashMap<>();
Map<String, Object> nameMap = new HashMap<>();
try {
......@@ -862,7 +1302,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
int pointNum = iRoutePointDao.countRoutePoint(plan.getRouteId());
long batchNo = now.getTime();
List<AgencyUserModel> agencyUserModels = remoteSecurityService.listUserByUserIds(toke.getToke(), toke.getProduct(), toke.getAppKey(), plan.getUserId());
List<AgencyUserModel> agencyUserModels = remoteSecurityService.listUserByUserIds(amosRequestContext.getToken(), amosRequestContext.getProduct(), amosRequestContext.getAppKey(), plan.getUserId());
for (int i = 0; i < agencyUserModels.size(); i++) {
//遍历获取orgcode
nameMap.put(agencyUserModels.get(i).getUserId(), agencyUserModels.get(i).getRealName());
......@@ -885,7 +1325,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
Map<String, String> orgCodeMap = new HashMap<>();
if (departmentIds.size() > 0) {
List<DepartmentModel> departmentModels = remoteSecurityService.getlistDepartmentByDeptIds(toke.getToke(), toke.getProduct(), toke.getAppKey(), departmentIdBuffer.toString().substring(0, departmentIdBuffer.toString().length() - 1));
List<DepartmentModel> departmentModels = remoteSecurityService.getlistDepartmentByDeptIds(amosRequestContext.getToken(), amosRequestContext.getProduct(), amosRequestContext.getAppKey(), departmentIdBuffer.toString().substring(0, departmentIdBuffer.toString().length() - 1));
for (String key : deptMap.keySet()) {
String entryValue = deptMap.get(key);
if ("-1".equals(entryValue)) {
......@@ -1062,10 +1502,9 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
public void sendMessage(Plan plan, PlanTask planTask) throws Exception {
Toke toke= remoteSecurityService.getServerToken();
RequestContext.setToken(toke.getToke());
RequestContext.setProduct(toke.getProduct());
RequestContext.setAppKey(toke.getAppKey());
RequestContext.setToken(amosRequestContext.getToken());
RequestContext.setProduct(amosRequestContext.getProduct());
RequestContext.setAppKey(amosRequestContext.getAppKey());
MsgRo msgRo = new MsgRo();
// 标题
......@@ -1120,27 +1559,115 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
@Override
@Transactional(rollbackFor = Exception.class)
public void handleAll(String id,String userId) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
Optional<PlanTask> planTaskOptional = iplanTaskDao.findById(Long.valueOf(id));
PlanTask planTask = planTaskOptional.get();
stopWatch.stop();
log.info("一键提交=========> 获取planTask耗时 :{}s", stopWatch.getTotalTimeSeconds());
if(planTask.getFinishStatus() == XJConstant.TASK_STATUS_DEAL) {
planTask.setFinishStatus(XJConstant.TASK_STATUS_FINISH);
if(planTask.getRiskStatus() != 1) {
planTask.setRiskStatus(XJConstant.NORISK_NUM);
}
stopWatch.start();
iplanTaskDao.saveAndFlush(planTask);
stopWatch.stop();
log.info("一键提交=========> 更新planTask耗时 :{}s", stopWatch.getTotalTimeSeconds());
stopWatch.start();
// 生成巡检记录
jobService.createCheckRecord(planTask, userId);
stopWatch.stop();
log.info("一键提交=========> 生成createCheckRecord检记录耗时 :{}s", stopWatch.getTotalTimeSeconds());
// 更新统计表
if(planTask.getPlanType().equals(String.valueOf(PlanTaskTypeStatusEnum.day.getValue()))) {
planTaskMapper.updateSingle(P_STATIC_DAY, XJConstant.RISK_NUM == planTask.getRiskStatus() ? 1 : 0,
XJConstant.NORISK_NUM == planTask.getRiskStatus() ? 1 : 0,
planTask.getOrgCode(),planTask.getCheckDate());
} else if(planTask.getPlanType().equals(String.valueOf(PlanTaskTypeStatusEnum.week.getValue()))) {
planTaskMapper.updateSingle(P_STATIC_WEEK, XJConstant.RISK_NUM == planTask.getRiskStatus() ? 1 : 0,
XJConstant.NORISK_NUM == planTask.getRiskStatus() ? 1 : 0,
planTask.getOrgCode(),planTask.getCheckDate());
} else {
planTaskMapper.updateSingle(P_STATIC_WEEK, XJConstant.RISK_NUM == planTask.getRiskStatus() ? 1 : 0,
XJConstant.NORISK_NUM == planTask.getRiskStatus() ? 1 : 0,
planTask.getOrgCode(),planTask.getCheckDate());
}
stopWatch.start();
List<PlanTaskDetail> planTaskDetails = iPlanTaskDetailDao.findAllByTaskNoAndStatus(planTask.getId(), PlanTaskDetailStatusEnum.NOTSTARTED.getValue());
stopWatch.stop();
log.info("一键提交=========> planTaskDetails 耗时: {}s", stopWatch.getTotalTimeSeconds());
List<ESTaskDetailDto> esTaskDetailDtos = new ArrayList<>();
if (!planTaskDetails.isEmpty()) {
planTaskDetails.stream().forEach(action -> {
Long routId = planTaskMapper.selectRoutId(id);
planTaskDetails.stream().map(action -> {
action.setStatus(PlanTaskDetailStatusEnum.QUALIFIED.getValue());
iPlanTaskDetailDao.saveAndFlush(action);
planTaskDetailMapper.finishTaskDetail(action.getId(), action.getPointId(),
action.getPlanTask().getId(), userId);
});
}
// 生成巡检记录
jobService.createCheckRecord(planTask, userId);
// AppPointCheckRespone appPointCheckRespone = planService.queryPointPlanTaskDetail(null, null, null, action.getTaskNo(), action.getPointId());
ESTaskDetailDto esTaskDetailDto = esTaskDetail.findById(String.valueOf(action.getId())).get();
JSONObject appCheckInput = esTaskDetailDto.getAppCheckInput();
Map<String,List<Map<String,Object>>> mapList = (Map<String,List<Map<String,Object>>>)JSON.parse(appCheckInput.toJSONString());
List<AppCheckInputRespone> appCheckInputRespones = new ArrayList<>();
for (Map<String,Object> map : mapList.get("items")) {
AppCheckInputRespone appCheckInputRespone = new AppCheckInputRespone();
BeanUtils.copyProperties(appCheckInputRespone, map);
Long checkInputId = Long.valueOf(map.get("checkInputId").toString());
InputItem inputItem = inputItemDao.findById(checkInputId).get();
CheckInput checkInput = new CheckInput();
String itemType = String.valueOf(map.get("itemType"));
if (XJConstant.INPUT_ITEM_SELECT.equals(itemType)) {
checkInput = paraseSelect(checkInput, String.valueOf(map.get("dataJson")));
appCheckInputRespone = JSONObject.parseObject(toJSONString(checkInput),
AppCheckInputRespone.class);
} else if (XJConstant.INPUT_ITEM_NUMBER.equals(itemType)) {
appCheckInputRespone.setInputValue(inputItem.getDefaultValue());
} else if (XJConstant.INPUT_ITEM_TEXT.equals(itemType)) {
appCheckInputRespone.setInputValue(inputItem.getDefaultValue());
}
appCheckInputRespone.setPointInputImgUrls(new ArrayList<>() );
appCheckInputRespones.add(appCheckInputRespone);
}
appCheckInput.put("items", appCheckInputRespones);
esTaskDetailDto.setPointImgUrls(new ArrayList<>());
esTaskDetailDto.setAppCheckInput(appCheckInput);
esTaskDetailDto.setPointStatus(String.valueOf(PlanTaskDetailIsFinishEnum.FINISHED.getValue()));
esTaskDetail.save(esTaskDetailDto);
JSONObject jsonObject = jobService.getCheckInput(routId, action.getPointId(), "update", null);
esTaskDetailDto.setAppCheckInput(jsonObject);
esTaskDetailDto.setPointImgUrls(new ArrayList<>());
esTaskDetailDtos.add(esTaskDetailDto);
return action;
}).collect(Collectors.toList());
}
esTaskDetail.saveAll(esTaskDetailDtos);
ESPlanTaskListDto esPlanTaskListDto = esPlanTaskList.findById(String.valueOf(planTask.getId())).get();
Map task = queryPlanTaskById(Long.valueOf(id));
esPlanTaskListDto.setFinishStatus(String.valueOf(PlanTaskFinishStatusEnum.FINISHED.getValue()));
esPlanTaskListDto.setFinshNum(ObjectUtils.isEmpty(task.get("finshNum")) ? "0" : task.get("finshNum").toString());
esPlanTaskListDto.setOmission(ObjectUtils.isEmpty(task.get("omission")) ? "0" : task.get("omission").toString());
esPlanTaskListDto.setUnqualified(ObjectUtils.isEmpty(task.get("unqualified")) ? "0" : task.get("unqualified").toString());
esPlanTaskListDto.setUnplan(ObjectUtils.isEmpty(task.get("unplan")) ? "0" : task.get("unplan").toString());
esPlanTaskListDto.setTaskPlanNum(ObjectUtils.isEmpty(task.get("taskPlanNum")) ? "0" : task.get("taskPlanNum").toString());
List<PlanTaskDetail> planTaskDetailList = planTaskMapper.selectTaskDetails("('" + esPlanTaskListDto.getPlanTaskId() + "')");
esPlanTaskListDto.setPoints(planTaskDetailList);
esPlanTaskList.save(esPlanTaskListDto);
}
}
......@@ -1165,42 +1692,63 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
if(params.containsKey("type")) {
params.put("type", String.valueOf(PlanTaskTypeStatusEnum.getValue(params.get("type").toString())));
}
long total = planTaskMapper.getPlanTasksCount(params);
if (total == 0) {
return new PageImpl<>(content, pageParam, total);
SearchRequest request = new SearchRequest();
request.indices("web_app_plan_task_list");
SearchSourceBuilder builder = new SearchSourceBuilder();
builder.trackTotalHits(true);
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
if (!ObjectUtils.isEmpty(params.get("userId"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
String test = QueryParser.escape(params.get("userId").toString());
meBuilder.must(QueryBuilders.wildcardQuery("userId", "*" + test + "*"));
boolMust.must(meBuilder);
}
if (!ObjectUtils.isEmpty(params.get("orgCode"))) {
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchPhraseQuery("orgCode", "*" + params.get("orgCode") + "*"));
boolMust.must(query);
}
if (!ObjectUtils.isEmpty(params.get("finishStatus"))) {
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchPhraseQuery("finishStatus", "*" + params.get("finishStatus") + "*"));
boolMust.must(query);
}
content = planTaskMapper.getPlanTasks(params);
// if (!ObjectUtils.isEmpty(params.get("type"))) {
// BoolQueryBuilder query = QueryBuilders.boolQuery();
// query.must(QueryBuilders.matchPhraseQuery("type", "*" + params.get("type") + "*"));
// boolMust.must(query);
// }
if (!CollectionUtils.isEmpty(content)) {
// Set<String> userIds = Sets.newHashSet();
// content.forEach(e -> {
// String userId = e.get("userId").toString();
// if (StringUtil.isNotEmpty(userId)) {
// 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<String> userNames = new ArrayList<>();
// content.forEach(e -> {
// userNames.clear();
// String[] userIds1 = e.get("userId").toString().split(",");
// for (String userId : userIds1) {
// if (!ObjectUtils.isEmpty(userModelMap.get(userId))) {
// userNames.add(userModelMap.get(userId));
// }
// }
// if (userNames.size() > 0) {
// e.put("executiveName", Joiner.on(",").join(userNames));
// } else {
// e.put("executiveName", " ");
// }
// });
content.forEach(e -> {
e.put("executiveName",e.get("userName") );
builder.query(boolMust);
// builder.sort("checkDate", SortOrder.DESC);
builder.from((Integer.parseInt(params.get("number").toString())) * Integer.parseInt(params.get("size").toString()));
builder.size(Integer.parseInt(params.get("size").toString()));
request.source(builder);
});
return new PageImpl<>(content, pageParam, total);
List<Map<String, Object>> list = new LinkedList<>();
SearchResponse response = null;
long totle = 0;
try {
response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits().getHits()) {
System.out.println(hit);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
JSONObject dto2 = jsonObject.getJSONObject("sourceAsMap");
Map map = dto2;
list.add(map);
}
totle = response.getInternalResponse().hits().getTotalHits().value;
if (!CollectionUtils.isEmpty(list)) {
list.forEach(e -> {
e.put("executiveName",e.get("userName") );
});
}
return new PageImpl<>(list, pageParam, totle);
} catch (IOException e) {
e.printStackTrace();
}
return new PageImpl<>(new ArrayList<>(), pageParam, 0);
}
......@@ -1440,92 +1988,6 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
return planTaskMapper.getPlanTaskStatisticsForApp(params);
}
@Override
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.queryCheckPointDetailInVersion2(toke, product, appKey, check.getId(), planTaskId, pointId);
} else {
PointCheckDetailBo planPointInfo = planTaskMapper.getPointPlanTaskInfo(planTaskId, pointId);
pointCheckRespone.setTaskStatus(planPointInfo.getTaskStatus());
pointCheckRespone.setPointStatus(planPointInfo.getPointStatus());
if (planPointInfo != null) {
if(check != null) {
List<CheckShot> checkShots = iCheckShotDao.findAllByCheckIdAndCheckInputId(check.getId(),
0L);
List<String> photos = new ArrayList<>();
if (!org.springframework.util.CollectionUtils.isEmpty(checkShots)) {
photos = checkShots.stream().map(e -> {
if (e != null) {
return e.getPhotoData().replaceAll("\\\\", "/");
} else {
return "";
}
}).collect(Collectors.toList());
}
pointCheckRespone.setPointImgUrls(photos);
}
pointCheckRespone.setPointId(pointId);
pointCheckRespone.setPointName(planPointInfo.getPointName());
pointCheckRespone.setPointNo(planPointInfo.getPointNo());
pointCheckRespone.setBeginTime(planPointInfo.getBeginTime());
pointCheckRespone.setEndTime(planPointInfo.getEndTime());
pointCheckRespone.setPlanName(planPointInfo.getPlanName());
pointCheckRespone.setShortMaxNumber(planPointInfo.getShortMaxNumber());
pointCheckRespone.setShortMinNumber(planPointInfo.getShortMinNumber());
List<PointCheckDetailBo> pointInputs = planTaskMapper.getPointInputByRouteIdAndPointId(planPointInfo.getRouteId(), planPointInfo.getPointId());
JSONObject appResponeMap = new JSONObject();
List<AppCheckInputRespone> appCheckInputResponeList = new ArrayList<AppCheckInputRespone>();
pointInputs.forEach(action -> {
AppCheckInputRespone input = new AppCheckInputRespone();
input.setInputName(action.getInputName());
input.setCheckInputId(action.getCheckInputId());
input.setDefaultValue(action.getDefaultValue());
input.setDataJson(action.getDataJson());
input.setIsMultiline(action.getIsMultiline());
input.setIsMust(action.getIsMust());
input.setInputValue(null);
if(null != check) {
for (CheckInput ck :check.getCheckInput()
) {
if(ck.getInputId().toString().equals(String.valueOf(action.getCheckInputId()))) {
input.setInputValue(ck.getInputValue());
}
}
List<CheckShot> checkShotsNew = iCheckShotDao.findAllByCheckIdAndCheckInputId(check.getId(),
action.getCheckInputId());
List<String> photosNew = new ArrayList<>();
if (!org.springframework.util.CollectionUtils.isEmpty(checkShotsNew)) {
photosNew = checkShotsNew.stream().map(e -> {
if (e != null) {
return e.getPhotoData().replaceAll("\\\\", "/");
} else {
return "";
}
}).collect(Collectors.toList());
}
input.setPointInputImgUrls(photosNew);
}
input.setItemType(action.getItemType());
input.setOrderNo(action.getOrderNo());
input.setPictureJson(action.getPictureJson());
input.setClassifyId(action.getClassifyId());
input.setClassifyName(action.getClassifyName());
appCheckInputResponeList.add(input);
});
appResponeMap.put("items", appCheckInputResponeList);
pointCheckRespone.setAppCheckInput(appResponeMap);
}
}
return pointCheckRespone;
}
@Override
public AppPointCheckRespone queryPointPlanTaskDetailInVersion2(String toke, String product, String appKey, Long planTaskId, Long pointId) {
......@@ -1724,8 +2186,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
userIds.add(id);
}
});
Toke toke = remoteSecurityService.getServerToken();
List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds(toke.getToke(), toke.getProduct(), toke.getAppKey(), Joiner.on(",").join(userIds));
List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds(amosRequestContext.getToken(), amosRequestContext.getProduct(), amosRequestContext.getAppKey(), Joiner.on(",").join(userIds));
Map<String, String> userModelMap = userModelList.stream().collect(Collectors.toMap(AgencyUserModel::getUserId, AgencyUserModel::getRealName, (k1, k2) -> k2));
content.forEach(e -> {
......@@ -1774,8 +2235,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
userIds.add(id);
}
});
Toke toke = remoteSecurityService.getServerToken();
List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds(toke.getToke(), toke.getProduct(), toke.getAppKey(), Joiner.on(",").join(userIds));
List<AgencyUserModel> userModelList = remoteSecurityService.listUserByUserIds(amosRequestContext.getToken(), amosRequestContext.getProduct(), amosRequestContext.getAppKey(), Joiner.on(",").join(userIds));
Map<String, String> userModelMap = userModelList.stream().collect(Collectors.toMap(AgencyUserModel::getUserId, AgencyUserModel::getRealName, (k1, k2) -> k2));
content.forEach(e -> {
......@@ -2054,6 +2514,88 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
@Override
@Transactional(rollbackFor = Exception.class)
// @ShardingSphereTransactionType(TransactionType.XA)
public void backPatrolInfo() {
long sTime = System.currentTimeMillis();
backChcek();
backChcekInput();
backPlanTask();
backChcekShot();
backPlanTaskDetail();
long eTime = System.currentTimeMillis();
System.out.printf("执行时长:%d 毫秒.", (sTime - eTime));
}
@Transactional(rollbackFor = Exception.class)
public void backPlanTask() {
log.info("开始归档p_plan_task表========");
List<PlanTask> list = planTaskMapper.findPlanTask();
List<PlanTaskHistory> collect = list.stream().map(e -> {
PlanTaskHistory d = new PlanTaskHistory();
BeanUtils.copyProperties(e, d);
return d;
}).collect(Collectors.toList());
repositoryTs.batchSave(collect);
log.info("归档p_plan_task表完成========");
}
@Transactional(rollbackFor = Exception.class)
public void backPlanTaskDetail() {
log.info("开始归档p_plan_task_detail表========");
List<PlanTaskDetail> list = planTaskMapper.findPlanTaskDetail();
List<PlanTaskDetailHistory> collect = list.stream().map(e -> {
PlanTaskDetailHistory d = new PlanTaskDetailHistory();
BeanUtils.copyProperties(e, d);
return d;
}).collect(Collectors.toList());
repositoryTs.batchSave(collect);
log.info("归档p_plan_task_detail表完成========");
}
@Transactional(rollbackFor = Exception.class)
public void backChcek() {
log.info("开始归档p_check表========");
List<Check> list = planTaskMapper.findCheck();
List<CheckHistory> collect = list.stream().map(e -> {
CheckHistory d = new CheckHistory();
BeanUtils.copyProperties(e, d);
return d;
}).collect(Collectors.toList());
repositoryTs.batchSave(collect);
log.info("归档p_check表完成========");
}
@Transactional(rollbackFor = Exception.class)
public void backChcekInput() {
log.info("开始归档p_check_input表========");
List<CheckInput> list = planTaskMapper.findCheckInput();
List<CheckInputHistory> collect = list.stream().map(e -> {
CheckInputHistory d = new CheckInputHistory();
BeanUtils.copyProperties(e, d);
return d;
}).collect(Collectors.toList());
repositoryTs.batchSave(collect);
log.info("归档p_check_input表完成========");
}
@Transactional(rollbackFor = Exception.class)
public void backChcekShot() {
log.info("开始归档p_check_shot表========");
List<CheckShot> list = planTaskMapper.findCheckShot();
List<CheckShotHistory> collect = list.stream().map(e -> {
CheckShotHistory d = new CheckShotHistory();
BeanUtils.copyProperties(e, d);
return d;
}).collect(Collectors.toList());
repositoryTs.batchSave(collect);
log.info("归档p_check_shot表完成========");
}
@Override
public List<Map<String, Object>> getStatics(String companyCode, String bizOrgCode) {
if (StringUtils.isEmpty(bizOrgCode) && StringUtil.isNotEmpty(companyCode)) {
bizOrgCode = planTaskMapper.queryByCompanyCode(companyCode);
......@@ -2125,4 +2667,62 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
return null;
}
}
private void createNeedTime(String table, String db, String create) {
DataSource dataSource = this.dataSource;
String sql = "SHOW CREATE TABLE " + table;
String existSql = "select * from information_schema.tables where table_name ='" + table + "'; ";
doCreate(dataSource, sql, existSql, create, db, table);
}
private void doCreate(DataSource dataSource, String sql, String existSql, String create, String db, String table) {
String msg = " create table: " + create + " origin table: " + table + " db: " + db;
Connection conn = null;
Statement stmt = null;
try {
conn = dataSource.getConnection().getMetaData().getConnection();
stmt = conn.createStatement();
ResultSet resultSet = stmt.executeQuery(existSql);
Assert.isTrue(resultSet.next(), msg + "初始化表不存在");
ResultSet resTable = stmt.executeQuery(sql);
Assert.isTrue(resTable.next(), msg + "初始化表不存在");
String existTableName = resTable.getString(1);
String createSqlOrigin = resTable.getString(2);
// log.info(existTableName, createSqlOrigin);
String existSqlNew = org.apache.commons.lang3.StringUtils.replaceOnce(existSql, existTableName, create);
ResultSet executeQuery = stmt.executeQuery(existSqlNew);
if (executeQuery.next()) {
log.info("table exist :" + msg);
} else {
createSqlOrigin = createSqlOrigin.substring(0,createSqlOrigin.indexOf(";"));
String creatsql = org.apache.commons.lang3.StringUtils.replace(createSqlOrigin, existTableName, create).replaceFirst(create, DB+create).replace("bigint(64)", "int8").replace("smallint(16)","int2");
if (0 == stmt.executeUpdate(creatsql)) {
log.info(msg + "success !");
} else {
log.error(msg + "fail !");
}
}
} catch (Exception e) {
log.error("create table fail error : {} ", e.getMessage());
} finally {
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
log.error("SQLException", e);
}
}
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
log.error("SQLException", e);
}
}
}
}
}
......@@ -927,9 +927,9 @@ public class PointServiceImpl implements IPointService {
@Override
public List queryItemList4RoutePointNew(Long routeId,Long pointId, Long classifyId) {
if (pointId == null || classifyId == null) {
throw new RuntimeException("查询条件有误");
}
// if (pointId == null || classifyId == null) {
// throw new RuntimeException("查询条件有误");
// }
List<Map<String, Object>> resList = pointMapper.queryItemList4RoutePoint(pointId, classifyId);
//查询管控字典值,并替换到返回值
HashMap<String, String> dictMap = new HashMap<>();
......@@ -1910,6 +1910,16 @@ public class PointServiceImpl implements IPointService {
content.forEach(e->{
if(e.get("id")!=null && !StringUtils.isBlank(e.get("id").toString())){
List<PointInputItemVo> inputItems = inputItemMapper.queryCustomInputItemByPointId(e.get("id").toString());
//匹配管控形式字典
//查询管控字典值,并替换到返回值
HashMap<String, String> dictMap = new HashMap<>();
List<DictionarieValueModel> result = Systemctl.dictionarieClient.dictValues(formOfManagementAndControl).getResult();
result.forEach(x-> dictMap.put(x.getDictDataKey(),x.getDictDataValue()));
inputItems.stream().peek(item->{
if (!ObjectUtils.isEmpty(item.getInputClassify())){
item.setInputClassify(dictMap.getOrDefault(item.getInputClassify(),"其他"));
}
}).collect(Collectors.toList());
e.put("equipIputDetailData",inputItems);
e.put("equipIputDetailDataNum",inputItems!=null?inputItems.size():0);
}
......
......@@ -60,4 +60,23 @@ public class RepositoryTImpl implements RepositoryTs {
}
return var1;
}
@Override
public <S> Iterable<S> batchSaveNoAsync(Iterable<S> var1) {
Iterator<S> iterator = var1.iterator();
int index = 0;
while (iterator.hasNext()){
em.persist(iterator.next());
index++;
if (index % BATCH_SIZE == 0){
em.flush();
em.clear();
}
}
if (index % BATCH_SIZE != 0){
em.flush();
em.clear();
}
return var1;
}
}
......@@ -560,23 +560,24 @@ public class RouteServiceImpl extends ServiceImpl<RouteMapper, Route> implement
if (oldRoutePointList != null && oldRoutePointList.size() > 0) {
RoutePoint RoutePoint = oldRoutePointList.get(0);
if (!"".equals(RoutePoint.getExcludeItems()) && RoutePoint.getExcludeItems() != null){
List<Long> split = Arrays.asList(RoutePoint.getExcludeItems().split(",")).stream().map(Long::parseLong).collect(Collectors.toList());
Set<Long> allPointInputItemIdSet = iPointInputItemDao.getPointInputItemByPointIdAndClassifyId(pointId, classifyId)
.stream().map(PointInputItem::getId)
.collect(Collectors.toSet());
List<Long> otherClassify = new ArrayList<>();
split.forEach(x -> {
if (!allPointInputItemIdSet.contains(x)) {
otherClassify.add(x);
}
});
List<Long> lastList = Stream.concat(otherClassify.stream(), inputItemIds.stream()).distinct().collect(Collectors.toList());
RoutePoint.setExcludeItems(StringUtils.join(lastList.toArray(), ","));
}else {
RoutePoint.setExcludeItems(StringUtils.join(inputItemIds.toArray(),","));
}
// if (!"".equals(RoutePoint.getExcludeItems()) && RoutePoint.getExcludeItems() != null){
// List<Long> split = Arrays.asList(RoutePoint.getExcludeItems().split(",")).stream().map(Long::parseLong).collect(Collectors.toList());
//
// Set<Long> allPointInputItemIdSet = iPointInputItemDao.getPointInputItemByPointIdAndClassifyId(pointId, classifyId)
// .stream().map(PointInputItem::getId)
// .collect(Collectors.toSet());
// List<Long> otherClassify = new ArrayList<>();
// split.forEach(x -> {
// if (!allPointInputItemIdSet.contains(x)) {
// otherClassify.add(x);
// }
// });
// List<Long> lastList = Stream.concat(otherClassify.stream(), inputItemIds.stream()).distinct().collect(Collectors.toList());
RoutePoint.setExcludeItems(StringUtils.join(inputItemIds, ","));
// }
// else {
// RoutePoint.setExcludeItems(StringUtils.join(inputItemIds.toArray(),","));
// }
iRoutePointDao.saveAndFlush(RoutePoint);
}
......
......@@ -33,4 +33,6 @@ public interface IPatrolDataSyncService {
void planTaskDataSync(List<PlanTask> planTaskList);
void planTaskDetailDataSync(List<PlanTaskDetail> planTaskDetailList);
void taskStatic(String runDate);
}
package com.yeejoin.amos.patrol.business.service.intfc;
import com.yeejoin.amos.patrol.business.param.PlanInfoPageParam;
import com.yeejoin.amos.patrol.core.common.response.AppPointCheckRespone;
import com.yeejoin.amos.patrol.dao.entity.Plan;
import org.springframework.data.domain.Page;
......@@ -21,6 +22,14 @@ public interface IPlanService {
* @param map
*/
Plan addPlan(HashMap<String, Object> map);
/**
* 根据任务id点id 获取点详情
* @param planTaskId
* @param pointId
* @return
*/
AppPointCheckRespone queryPointPlanTaskDetail(String toke, String product, String appKey, Long planTaskId, Long pointId);
/**
* 巡检计划删除
......
......@@ -67,6 +67,13 @@ public interface IPlanTaskService {
void taskExecution(String runDate);
/**
* 自动任务执行
* @param runDate
*/
void taskStaticExecution(String runDate);
/**
* 定时任务发送消息执行中的消息
*
* @param runDate
......@@ -114,7 +121,7 @@ public interface IPlanTaskService {
* @param params
* @return
*/
Page<Map<String, Object>> getPlanTasks(String toke,String product,String appKey,HashMap<String, Object> params);
Page<Map<String, Object>> getPlanTasks(String toke,String product,String appKey,HashMap<String, Object> params);
/**
* 根据计划任务Id获取计划任务信息
......@@ -150,13 +157,6 @@ public interface IPlanTaskService {
*/
List<PlanTaskVo> getPlanTaskListByIds(String toke,String product,String appKey,Long[] ids);
List<PlanTaskVo> getPlanTaskListByIdsNew(Long[] ids);
/**
* 根据任务id点id 获取点详情
* @param planTaskId
* @param pointId
* @return
*/
AppPointCheckRespone queryPointPlanTaskDetail(String toke,String product,String appKey,Long planTaskId,Long pointId);
AppPointCheckRespone queryPointPlanTaskDetailInVersion2(String toke,String product,String appKey,Long planTaskId,Long pointId);
......@@ -207,4 +207,6 @@ public interface IPlanTaskService {
void download(HttpServletRequest request, HttpServletResponse response, String taskDetailId) throws UnsupportedEncodingException;
Map<String,Object> queryPatrolInfoList(String bizOrgCode, Date startDate, Date endDate);
void backPatrolInfo();
}
package com.yeejoin.amos.patrol.config;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Arrays;
@Configuration
public class ElasticSearchClientConfig {
@Value("${spring.elasticsearch.rest.uris}")
private String uris;
@Value("${elasticsearch.username}")
private String username;
@Value("${elasticsearch.password}")
private String password;
@Bean(destroyMethod = "close")
public RestHighLevelClient restHighLevelClient() {
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(username, password));
try {
HttpHost[] httpHosts = Arrays.stream(uris.split(",")).map(HttpHost::create).toArray(HttpHost[]::new);
RestClientBuilder builder = RestClient.builder(httpHosts);
builder.setHttpClientConfigCallback(httpClientBuilder -> {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
});
// 该方法接收一个RequestConfig.Builder对象,对该对象进行修改后然后返回。
builder.setRequestConfigCallback(requestConfigBuilder -> {
// 连接超时(默认为1秒)
return requestConfigBuilder.setConnectTimeout(5000 * 1000)
// 套接字超时(默认为30秒)//更改客户端的超时限制默认30秒现在改为100*1000分钟
.setSocketTimeout(6000 * 1000);
});
return new RestHighLevelClient(builder);
} catch (Exception e) {
throw new IllegalStateException("Invalid ES nodes " + "property '" + uris + "'", e);
}
}
}
//package com.yeejoin.amos.patrol.config;
//
//
//import lombok.Getter;
//import lombok.Setter;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang3.StringUtils;
//import org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
//
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.stereotype.Component;
//import org.springframework.util.Assert;
//
//import javax.annotation.PostConstruct;
//import javax.annotation.Resource;
//import javax.sql.DataSource;
//import java.sql.Connection;
//import java.sql.ResultSet;
//import java.sql.SQLException;
//import java.sql.Statement;
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * @author liran
// */
//@Slf4j
//@Setter
//@Getter
//@Component
//public class TableCreate {
//
// @Resource
// private ShardingSphereDataSource dataSource;
//
// Map<String, Object> createdTables = new HashMap<>();
// @Value("${shardingsphere.create.tables.num:10}")
// private String num;
//
// private String PLAN_TASK = "p_plan_task";
// private String PLAN_TASK_HISTORY = "p_plan_task_history_";
//
// private String PLAN_TASK_DETAIL = "p_plan_task_detail";
// private String PLAN_TASK_DETAIL_HISTORY = "p_plan_task_detail_history_";
//
// private String P_CHECK = "p_check";
// private String P_CHECK_HISTORY = "p_check_history_";
//
// private String P_CHECK_INPUT = "p_check_input";
// private String P_CHECK_INPUT_HISTORY = "p_check_input_history_";
//
// private String P_CHECK_SHOT = "p_check_shot";
// private String P_CHECK_SHOT_HISTORY = "p_check_shot_history_";
//
// private String DB = "amos_tzs_biz.";
//
//
// @PostConstruct
// public void init() {
// for(int i = 1; i<=Integer.parseInt(num); i++) {
// createNeedTime(PLAN_TASK,DB,PLAN_TASK_HISTORY+i);
// }
// for(int i = 1; i<=Integer.parseInt(num); i++) {
// createNeedTime(PLAN_TASK_DETAIL,DB,PLAN_TASK_DETAIL_HISTORY+i);
// }
// for(int i = 1; i<=Integer.parseInt(num); i++) {
// createNeedTime(P_CHECK,DB,P_CHECK_HISTORY+i);
// }
// for(int i = 1; i<=Integer.parseInt(num); i++) {
// createNeedTime(P_CHECK_INPUT,DB,P_CHECK_INPUT_HISTORY+i);
// }
// for(int i = 1; i<=Integer.parseInt(num); i++) {
// createNeedTime(P_CHECK_SHOT,DB,P_CHECK_SHOT_HISTORY+i);
// }
// }
//
//
// private void createNeedTime(String table, String db, String create) {
// DataSource dataSource = this.dataSource;
// String sql = "SHOW CREATE TABLE " + table;
// String existSql = "select * from information_schema.tables where table_name ='" + table + "'; ";
// doCreate(dataSource, sql, existSql, create, db, table);
// }
//
// private void doCreate(DataSource dataSource, String sql, String existSql, String create, String db, String table) {
// String msg = " create table: " + create + " origin table: " + table + " db: " + db;
// Connection conn = null;
// Statement stmt = null;
// try {
// conn = dataSource.getConnection().getMetaData().getConnection();
// stmt = conn.createStatement();
// ResultSet resultSet = stmt.executeQuery(existSql);
// Assert.isTrue(resultSet.next(), msg + "初始化表不存在");
//
// ResultSet resTable = stmt.executeQuery(sql);
// Assert.isTrue(resTable.next(), msg + "初始化表不存在");
// String existTableName = resTable.getString(1);
// String createSqlOrigin = resTable.getString(2);
// // log.info(existTableName, createSqlOrigin);
//
// String existSqlNew = StringUtils.replaceOnce(existSql, existTableName, create);
// ResultSet executeQuery = stmt.executeQuery(existSqlNew);
// if (executeQuery.next()) {
// log.info("table exist :" + msg);
// } else {
// createSqlOrigin = createSqlOrigin.substring(0,createSqlOrigin.indexOf(";"));
// String creatsql = StringUtils.replace(createSqlOrigin, existTableName, create).replaceFirst(create, DB+create).replace("bigint(64)", "int8").replace("smallint(16)","int2");
// if (0 == stmt.executeUpdate(creatsql)) {
// log.info(msg + "success !");
//
// } else {
// log.error(msg + "fail !");
// }
// }
// } catch (Exception e) {
// log.error("create table fail error : {} ", e.getMessage());
// } finally {
// if (stmt != null) {
// try {
// stmt.close();
// } catch (SQLException e) {
// log.error("SQLException", e);
// }
// }
// if (conn != null) {
// try {
// conn.close();
// } catch (SQLException e) {
// log.error("SQLException", e);
// }
// }
// }
// }
//
//}
......@@ -6,6 +6,7 @@ import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.yeejoin.amos.component.robot.AmosRequestContext;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.patrol.business.dao.mapper.MsgSubscribeMapper;
import com.yeejoin.amos.patrol.business.dao.repository.IMsgDao;
......@@ -59,11 +60,15 @@ public class AsyncTask {
@Autowired
private IEmailService iEmailService;
@Autowired
AmosRequestContext amosRequestContext;
private static final String TOKE = "TOKE";
private static final String TAB = "\r\n";
/**
* 检查消息推送
* @param checkId
......@@ -109,8 +114,7 @@ public class AsyncTask {
@Async("asyncTaskExecutor")
public Future<Boolean> pushCheckMessage(Long checkId) throws InterruptedException {
Toke toke= remoteSecurityService.getServerToken();
messageService.pushCheckMessage(toke.getToke(),toke.getProduct(),toke.getAppKey(),checkId);
messageService.pushCheckMessage(amosRequestContext.getToken(),amosRequestContext.getProduct(),amosRequestContext.getAppKey(),checkId);
return new AsyncResult<Boolean>(true);
}
......@@ -223,8 +227,7 @@ public class AsyncTask {
pushMsgParam.setType(JPushTypeEnum.ALIAS.getCode());
pushMsgParam.setExtras(extras);
iMsgDao.saveAll(msgs);
Toke toke= remoteSecurityService.getServerToken();
messageService.pushMsg(toke.getToke(),toke.getProduct(),toke.getAppKey(),pushMsgParam);
messageService.pushMsg(amosRequestContext.getToken(), amosRequestContext.getProduct(), amosRequestContext.getAppKey(), pushMsgParam);
}
}
......
......@@ -25,7 +25,7 @@ public class ApplicationStartListener implements ApplicationListener<ContextRefr
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
try{
if(event.getApplicationContext().getParent().getParent().getParent() == null){
if(event.getApplicationContext().getId().equals("application-1")){
iPlanTaskService.initPlanStatusOrGenDate();
pointService.initPointStatus();
jobService.initScheduler();
......
......@@ -90,42 +90,42 @@ public class RemoteSecurityService {
return null;
}
public Toke getServerToken() {
IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel();
dPasswordAuthModel.setLoginId(loginId);
dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz"));
Toke toke = null;
try {
toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(loginId)), Toke.class);
if (ObjectUtils.isEmpty(toke)) {
toke = getLogin(dPasswordAuthModel);
} else {
RequestContext.setProduct(productWeb);
if (!TokenOperation.refresh(toke.getToke())) {
toke = getLogin(dPasswordAuthModel);
}
}
RequestContext.setAppKey(toke.getAppKey());
RequestContext.setToken(toke.getToke());
} catch (InnerInvokException e) {
e.printStackTrace();
}
return toke;
}
private Toke getLogin(IdPasswordAuthModel dPasswordAuthModel) {
Toke toke = new Toke();
RequestContext.setProduct(productWeb);
FeignClientResult feignClientResult = Privilege.authClient.idpassword(dPasswordAuthModel);
Map map = (Map) feignClientResult.getResult();
if (map != null) {
toke.setToke(map.get("token").toString());
toke.setProduct(productWeb);
toke.setAppKey(appKey);
redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
}
return toke;
}
// public Toke getServerToken() {
// IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel();
// dPasswordAuthModel.setLoginId(loginId);
// dPasswordAuthModel.setPassword(DesUtil.encode(password, "qaz"));
// Toke toke = null;
// try {
// toke = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(loginId)), Toke.class);
// if (ObjectUtils.isEmpty(toke)) {
// toke = getLogin(dPasswordAuthModel);
// } else {
// RequestContext.setProduct(productWeb);
// if (!TokenOperation.refresh(toke.getToke())) {
// toke = getLogin(dPasswordAuthModel);
// }
// }
// RequestContext.setAppKey(toke.getAppKey());
// RequestContext.setToken(toke.getToke());
// } catch (InnerInvokException e) {
// e.printStackTrace();
// }
// return toke;
// }
// private Toke getLogin(IdPasswordAuthModel dPasswordAuthModel) {
// Toke toke = new Toke();
// RequestContext.setProduct(productWeb);
// FeignClientResult feignClientResult = Privilege.authClient.idpassword(dPasswordAuthModel);
// Map map = (Map) feignClientResult.getResult();
// if (map != null) {
// toke.setToke(map.get("token").toString());
// toke.setProduct(productWeb);
// toke.setAppKey(appKey);
// redisTemplate.opsForValue().set(buildKey(dPasswordAuthModel.getLoginId()), JSONObject.toJSONString(toke), 28, TimeUnit.DAYS);
// }
// return toke;
// }
//redi缓存系统用户token信息
......
package com.yeejoin.amos.patrol.quartz;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.patrol.business.param.CheckRecordParam;
import com.yeejoin.amos.patrol.dao.entity.Msg;
import com.yeejoin.amos.patrol.dao.entity.PlanTask;
import com.yeejoin.amos.patrol.dao.entity.Task;
......@@ -63,5 +65,7 @@ public interface IJobService {
public void msgJobPerform(long msgId,String jobType,String jobName);
public void createCheckRecord(PlanTask planTask,String userId);
public JSONObject getCheckInput(Long routeId, Long pointId, String type, CheckRecordParam requestParam);
}
......@@ -6,29 +6,58 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yeejoin.amos.component.feign.config.InnerInvokException;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.component.robot.AmosRequestContext;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.MessageModel;
import com.yeejoin.amos.patrol.business.bo.CheckInputSyncBo;
import com.yeejoin.amos.patrol.business.bo.PlanTaskSyncBo;
import com.yeejoin.amos.patrol.business.constants.XJConstant;
import com.yeejoin.amos.patrol.business.dao.mapper.CheckInputMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.CheckMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.MsgMapper;
import com.yeejoin.amos.patrol.business.dao.mapper.PlanTaskMapper;
import com.yeejoin.amos.patrol.business.dao.repository.*;
import com.yeejoin.amos.patrol.business.dao.mapper.PointMapper;
import com.yeejoin.amos.patrol.business.dao.repository.ESPlanTaskList;
import com.yeejoin.amos.patrol.business.dao.repository.ESTaskDetail;
import com.yeejoin.amos.patrol.business.dao.repository.ICheckDao;
import com.yeejoin.amos.patrol.business.dao.repository.ICheckInputDao;
import com.yeejoin.amos.patrol.business.dao.repository.IInputItemDao;
import com.yeejoin.amos.patrol.business.dao.repository.IMsgDao;
import com.yeejoin.amos.patrol.business.dao.repository.IPlanDao;
import com.yeejoin.amos.patrol.business.dao.repository.IPlanTaskDao;
import com.yeejoin.amos.patrol.business.dao.repository.IPlanTaskDetailDao;
import com.yeejoin.amos.patrol.business.dao.repository.IRoutePointDao;
import com.yeejoin.amos.patrol.business.dao.repository.ITaskDao;
import com.yeejoin.amos.patrol.business.dao.repository.ITaskFeedbackDao;
import com.yeejoin.amos.patrol.business.entity.mybatis.PlanTaskPointInputItemBo;
import com.yeejoin.amos.patrol.business.entity.mybatis.PointCheckDetailBo;
import com.yeejoin.amos.patrol.business.feign.JcsFeignClient;
import com.yeejoin.amos.patrol.business.param.CheckInputParam;
import com.yeejoin.amos.patrol.business.param.MsgConfigParam;
import com.yeejoin.amos.patrol.business.param.CheckRecordParam;
import com.yeejoin.amos.patrol.business.service.intfc.IMessageService;
import com.yeejoin.amos.patrol.business.service.intfc.IPatrolDataSyncService;
import com.yeejoin.amos.patrol.business.service.intfc.IPlanTaskService;
import com.yeejoin.amos.patrol.business.service.intfc.IPlanService;
import com.yeejoin.amos.patrol.business.util.DateUtil;
import com.yeejoin.amos.patrol.business.util.Toke;
import com.yeejoin.amos.patrol.common.enums.*;
import com.yeejoin.amos.patrol.common.enums.CheckStatusEnum;
import com.yeejoin.amos.patrol.common.enums.PlanTaskDetailIsFinishEnum;
import com.yeejoin.amos.patrol.common.enums.PlanTaskDetailStatusEnum;
import com.yeejoin.amos.patrol.common.enums.PlanTaskFinishStatusEnum;
import com.yeejoin.amos.patrol.common.enums.TaskStatusEnum;
import com.yeejoin.amos.patrol.core.async.AsyncTask;
import com.yeejoin.amos.patrol.dao.entity.*;
import com.yeejoin.amos.patrol.core.common.response.AppCheckInputRespone;
import com.yeejoin.amos.patrol.core.common.response.AppPointCheckRespone;
import com.yeejoin.amos.patrol.dao.entity.Check;
import com.yeejoin.amos.patrol.dao.entity.CheckInput;
import com.yeejoin.amos.patrol.dao.entity.ESPlanTaskListDto;
import com.yeejoin.amos.patrol.dao.entity.ESTaskDetailDto;
import com.yeejoin.amos.patrol.dao.entity.InputItem;
import com.yeejoin.amos.patrol.dao.entity.Msg;
import com.yeejoin.amos.patrol.dao.entity.Plan;
import com.yeejoin.amos.patrol.dao.entity.PlanTask;
import com.yeejoin.amos.patrol.dao.entity.PlanTaskDetail;
import com.yeejoin.amos.patrol.dao.entity.Task;
import com.yeejoin.amos.patrol.dao.entity.TaskFeedback;
import com.yeejoin.amos.patrol.feign.RemoteSecurityService;
import com.yeejoin.amos.patrol.mqtt.WebMqttComponent;
import org.quartz.Job;
......@@ -37,27 +66,45 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import static com.alibaba.fastjson.JSON.toJSONString;
import static com.yeejoin.amos.patrol.common.enums.NotifyBusinessTypeEum.planTask;
@Service("jobService")
@EnableAsync
public class JobService implements IJobService {
private final Logger log = LoggerFactory.getLogger(JobService.class);
@Autowired
ESPlanTaskList esPlanTaskList;
@Autowired
IPlanService planService;
@Autowired
ESTaskDetail esTaskDetail;
@Autowired
private ITaskDao iTaskDao;
@Autowired
......@@ -90,6 +137,9 @@ public class JobService implements IJobService {
private IMsgDao iMsgDao;
@Autowired
private CheckMapper checkMapper;
@Autowired
private ITaskFeedbackDao taskFeedbackDao;
@Autowired
......@@ -109,10 +159,21 @@ public class JobService implements IJobService {
@Autowired
IInputItemDao inputItemDao;
@Autowired
IRoutePointDao iRoutePointDao;
@Autowired
AmosRequestContext amosRequestContext;
@Autowired
JcsFeignClient jcsFeignClient;
private String P_STATIC_DAY = "p_static_day";
private String P_STATIC_MONTH = "p_static_month";
private String P_STATIC_WEEK = "p_static_week";
@Override
@Transactional
public void initScheduler() {
......@@ -130,6 +191,7 @@ public class JobService implements IJobService {
SimpleDateFormat formatter = new SimpleDateFormat("ss mm HH dd MM ? yyyy");
String cronDate = formatter.format(time);
log.error("addJob==jobName==" + jobName);
QuartzManager.addJob(jobName, jobType, id, getJobInstance(name).getClass(), cronDate);
}
}
......@@ -164,48 +226,159 @@ public class JobService implements IJobService {
List<PlanTask> planTaskList = planTaskMapper.getInitPlanTaskList();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
log.error("项目初始化执行开始添加定时任务监控========");
planTaskList.forEach(planTask -> {
boolean flag = false;
for(PlanTask planTask: planTaskList) {
try {
Date beginTime = sdf.parse(planTask.getBeginTime());
Date endTime = sdf.parse(planTask.getEndTime());
long timestamp = new Date().getTime();
List<String> ids = new ArrayList<>();
if (PlanTaskFinishStatusEnum.NOTSTARTED.getValue() == planTask.getFinishStatus()) {
if (beginTime.getTime() > timestamp) {
planTaskAddJob(planTask);
log.error("项目初始化未开始监听器任务监控========");
} else if (beginTime.getTime() < timestamp && endTime.getTime() > timestamp) {
log.error("项目初始化进行中监听器任务监控========");
planTaskMapper.updatePlanTaskList(planTask.getPlanId(), PlanTaskFinishStatusEnum.NOTSTARTED.getValue(), PlanTaskFinishStatusEnum.UNDERWAY.getValue());
ids = planTaskMapper.selectPlanTaskIdList(planTask.getPlanId(), PlanTaskFinishStatusEnum.NOTSTARTED.getValue());
if (!ObjectUtils.isEmpty(ids)) {
flag = true;
if (ids.size() > 10000) {
int index = 10000;
for (int i = 0; i < ids.size(); i += 10000) {
if (i + 10000 > ids.size()) {
index = ids.size() - i;
}
List<String> newList = ids.subList(i, i + index);
planTaskMapper.updatePlanTaskList(newList, PlanTaskFinishStatusEnum.UNDERWAY.getValue());
updateEsPlanTaskList(newList, PlanTaskFinishStatusEnum.UNDERWAY.getValue(),"notApp",null);
}
} else {
planTaskMapper.updatePlanTaskList(ids, PlanTaskFinishStatusEnum.UNDERWAY.getValue());
updateEsPlanTaskList(ids, PlanTaskFinishStatusEnum.UNDERWAY.getValue(),"notApp",null);
}
}
planTaskAddJob(planTask);
} else if (endTime.getTime() < timestamp) {
flag = true;
log.error("修改为漏检生成记录========");
updatePlanTaskAndDetailStatus(planTask);
}
} else {
if (endTime.getTime() < timestamp) {
log.error("项目初始化进行中监听器任务监控2222========");
planTaskMapper.updatePlanTaskList(planTask.getPlanId(), PlanTaskFinishStatusEnum.NOTSTARTED.getValue(), PlanTaskFinishStatusEnum.UNDERWAY.getValue());
ids = planTaskMapper.selectPlanTaskIdList(planTask.getPlanId(), PlanTaskFinishStatusEnum.NOTSTARTED.getValue());
if(!ObjectUtils.isEmpty(ids)){
flag = true;
if (!ObjectUtils.isEmpty(ids)) {
if (ids.size() > 10000) {
int index = 10000;
for (int i = 0; i < ids.size(); i += 10000) {
if (i + 10000 > ids.size()) {
index = ids.size() - i;
}
List<String> newList = ids.subList(i, i + index);
planTaskMapper.updatePlanTaskList(newList, PlanTaskFinishStatusEnum.UNDERWAY.getValue());
updateEsPlanTaskList(newList, PlanTaskFinishStatusEnum.UNDERWAY.getValue(),"notApp",null);
}
} else {
planTaskMapper.updatePlanTaskList(ids, PlanTaskFinishStatusEnum.UNDERWAY.getValue());
updateEsPlanTaskList(ids, PlanTaskFinishStatusEnum.UNDERWAY.getValue(),"notApp",null);
}
}
}
planTaskAddJob(planTask);
} else {
flag = true;
log.error("修改为漏检生成记录2222========");
updatePlanTaskAndDetailStatus(planTask);
}
}
} catch (ParseException e) {
// TODO Auto-generated catch block
log.debug(e.getMessage());
log.info(e.getMessage());
e.printStackTrace();
}
});
}
// 重新更新统计表 -- 只更新当天统计的数据
if(flag) {
patrolDataSyncService.taskStatic(null);
}
}
@Autowired
PointMapper pointMapper;
public void updateEsPlanTaskList(List<String> ids, int status,String isApp,CheckRecordParam requestParam) {
String type = "save";
if ("app".equals(isApp)) {
type = "update";
}
List<ESPlanTaskListDto> esPlanTaskListDtos = new ArrayList<>();
for (String id : ids) {
ESPlanTaskListDto esPlanTaskListDto = esPlanTaskList.findById(id).get();
esPlanTaskListDto.setFinishStatus(String.valueOf(status));
Map task = planTaskMapper.queryPlanTaskById(Long.valueOf(id));
esPlanTaskListDto.setFinshNum(ObjectUtils.isEmpty(task.get("finshNum")) ? "0" : task.get("finshNum").toString());
esPlanTaskListDto.setOmission(ObjectUtils.isEmpty(task.get("omission")) ? "0" : task.get("omission").toString());
esPlanTaskListDto.setUnqualified(ObjectUtils.isEmpty(task.get("unqualified")) ? "0" : task.get("unqualified").toString());
esPlanTaskListDto.setUnplan(ObjectUtils.isEmpty(task.get("unplan")) ? "0" : task.get("unplan").toString());
esPlanTaskListDto.setTaskPlanNum(ObjectUtils.isEmpty(task.get("taskPlanNum")) ? "0" : task.get("taskPlanNum").toString());
List<PlanTaskDetail> planTaskDetailList = planTaskMapper.selectTaskDetails("('" + id + "')");
Long routId = planTaskMapper.selectRoutId(id);
List<ESTaskDetailDto> esTaskDetailDtos = new ArrayList<>();
for (PlanTaskDetail taskDetail : planTaskDetailList) {
AppPointCheckRespone appPointCheckRespone = planService.queryPointPlanTaskDetail(null, null, null, taskDetail.getTaskNo(), taskDetail.getPointId());
ESTaskDetailDto esTaskDetailDto = esTaskDetail.findById(String.valueOf(appPointCheckRespone.getId())).get();
JSONObject jsonObject = getCheckInput(routId, taskDetail.getPointId(), type, requestParam);
esTaskDetailDto.setPointStatus((status == 0 || status == 1) ? "0" : status == 2 ? "1" : "2");
esTaskDetailDto.setTaskStatus(String.valueOf(status));
appPointCheckRespone.setAppCheckInput(jsonObject);
esTaskDetailDto.setPointImgUrls(ObjectUtils.isEmpty(requestParam) ? new ArrayList<>() : requestParam.getCheckRecordImg());
esTaskDetailDtos.add(esTaskDetailDto);
}
esTaskDetail.saveAll(esTaskDetailDtos);
esPlanTaskListDto.setPoints(planTaskDetailList);
esPlanTaskListDtos.add(esPlanTaskListDto);
}
esPlanTaskList.saveAll(esPlanTaskListDtos);
}
private void updatePlanTaskAndDetailStatus(PlanTask planTask) {
planTaskMapper.updatePlanTaskList(planTask.getPlanId(), PlanTaskFinishStatusEnum.UNDERWAY.getValue(), PlanTaskFinishStatusEnum.OVERTIME.getValue());
List<Long> ids = new ArrayList<>();
ids.add(planTask.getId());
planTaskMapper.updatePlanTaskDetailsByPlanId(ids);
createOmissionCheckRecord(planTask);
List<String> esIds = planTaskMapper.selectPlanTaskIdLists(planTask.getPlanId(), PlanTaskFinishStatusEnum.UNDERWAY.getValue(),PlanTaskFinishStatusEnum.NOTSTARTED.getValue());
if(esIds.size() > 0) {
if (esIds.size() > 10000) {
int index = 10000;
for (int i = 0; i < esIds.size(); i += 10000) {
if (i + 10000 > esIds.size()) {
index = esIds.size() - i;
}
List<String> newList = esIds.subList(i, i + index);
planTaskMapper.updatePlanTaskList(newList, PlanTaskFinishStatusEnum.OVERTIME.getValue());
updateEsPlanTaskList(newList, PlanTaskFinishStatusEnum.OVERTIME.getValue(), "notApp", null);
List<PlanTask> planTaskList = planTaskMapper.selectTaskList(newList);
if (!ObjectUtils.isEmpty(planTaskList)) {
for (PlanTask task : planTaskList) {
createOmissionCheckRecord(task);
}
}
}
} else {
planTaskMapper.updatePlanTaskList(esIds, PlanTaskFinishStatusEnum.OVERTIME.getValue());
updateEsPlanTaskList(esIds, PlanTaskFinishStatusEnum.OVERTIME.getValue(), "notApp", null);
List<PlanTask> planTaskList = planTaskMapper.selectTaskList(esIds);
if (!ObjectUtils.isEmpty(planTaskList)) {
for (PlanTask task : planTaskList) {
createOmissionCheckRecord(task);
}
}
}
List<Long> ids = new ArrayList<>();
ids.add(planTask.getId());
if(!ValidationUtil.isEmpty(ids)){
planTaskMapper.updatePlanTaskDetailsByPlanId(ids);
}
}
}
private void initMsgJob() {
......@@ -243,10 +416,9 @@ public class JobService implements IJobService {
}
private void updateTaskStatus(Plan plan) {
Toke toke = remoteSecurityService.getServerToken();
RequestContext.setToken(toke.getToke());
RequestContext.setProduct(toke.getProduct());
RequestContext.setAppKey(toke.getAppKey());
RequestContext.setToken(amosRequestContext.getToken());
RequestContext.setProduct(amosRequestContext.getProduct());
RequestContext.setAppKey(amosRequestContext.getAppKey());
MessageModel model = new MessageModel();
model.setRelationId(String.valueOf(plan.getId()));
model.setMsgType("patrolSystem");
......@@ -350,6 +522,74 @@ public class JobService implements IJobService {
}
public JSONObject getCheckInput(Long routeId, Long pointId, String type, CheckRecordParam requestParam) {
List<AppCheckInputRespone> appCheckInputResponeList = new ArrayList<AppCheckInputRespone>();
List<PointCheckDetailBo> pointInputs = planTaskMapper.getPointInputByRouteIdAndPointId(routeId, pointId);
JSONObject appResponeMap = new JSONObject();
pointInputs.forEach(action -> {
AppCheckInputRespone input = new AppCheckInputRespone();
if ("save".equals(type)) {
input.setInputValue(null);
input.setPointInputImgUrls(new ArrayList<>());
} else {
InputItem inputItem = inputItemDao.findById(action.getInputItemId()).get();
CheckInput checkInput = new CheckInput();
if (!ValidationUtil.isEmpty(requestParam)) {
List<CheckInputParam> checkItems = requestParam.getCheckItems();
for (CheckInputParam x : checkItems) {
if (x.getInputItemId() == action.getInputItemId()) {
input.setInputValue(x.getInputValue());
break;
}
}
} else {
if (XJConstant.INPUT_ITEM_SELECT.equals(inputItem.getItemType())) {
checkInput = paraseSelect(checkInput, inputItem.getDataJson(), inputItem.getIsScore());
input = JSONObject.parseObject(toJSONString(checkInput),
AppCheckInputRespone.class);
} else if (XJConstant.INPUT_ITEM_NUMBER.equals(inputItem.getItemType())) {
input.setInputValue(inputItem.getDefaultValue());
} else if (XJConstant.INPUT_ITEM_TEXT.equals(inputItem.getItemType())) {
input.setInputValue(inputItem.getDefaultValue());
}
}
if (!ObjectUtils.isEmpty(requestParam)) {
List<CheckInputParam> checkItems = requestParam.getCheckItems();
for (CheckInputParam x : checkItems) {
if (x.getInputItemId() == action.getInputItemId()) {
if (x.getCheckInputImg() != null && x.getCheckInputImg().size() > 0) {
input.setPointInputImgUrls(x.getCheckInputImg());
}else {
input.setPointInputImgUrls(new ArrayList<>());
}
}
}
}
}
input.setInputName(action.getInputName());
input.setCheckInputId(action.getCheckInputId());
input.setDefaultValue(action.getDefaultValue());
input.setDataJson(action.getDataJson());
input.setIsMultiline(action.getIsMultiline());
input.setIsMust(action.getIsMust());
input.setItemType(action.getItemType());
input.setOrderNo(action.getOrderNo());
input.setPictureJson(action.getPictureJson());
input.setClassifyId(action.getClassifyId());
input.setClassifyName(action.getClassifyName());
appCheckInputResponeList.add(input);
});
appResponeMap.put("items", appCheckInputResponeList);
return appResponeMap;
}
/**
* 创建检查记录
......@@ -517,7 +757,6 @@ public class JobService implements IJobService {
if (iTaskDao.existsById(taskId)) {
Task task = iTaskDao.findById(taskId).get();
Toke toke = remoteSecurityService.getServerToken();
if (XJConstant.STATUS_MONITOR_END.equals(jobType)) {
if (TaskStatusEnum.UNDERWAY.getValue() == task.getStatus()) {
task.setStatus(TaskStatusEnum.OVERTIME.getValue());
......@@ -533,7 +772,7 @@ public class JobService implements IJobService {
taskFeedback.setMessageType(TaskStatusEnum.OVERTIME.getName());
taskFeedback = taskFeedbackDao.save(taskFeedback);
try {
asyncTask.pushTaskDetailInfoTo3D(toke.getToke(), toke.getProduct(), toke.getAppKey(), taskId); // 超时任务向3D推送
asyncTask.pushTaskDetailInfoTo3D(amosRequestContext.getToken(), amosRequestContext.getProduct(), amosRequestContext.getAppKey(), taskId); // 超时任务向3D推送
} catch (InterruptedException e) {
// TODO Auto-generated catch block
log.error(e.getMessage(), e);
......@@ -541,7 +780,7 @@ public class JobService implements IJobService {
}
}
} else {
messageService.pushTaskMessage(toke.getToke(), toke.getProduct(), toke.getAppKey(), task);
messageService.pushTaskMessage(amosRequestContext.getToken(), amosRequestContext.getProduct(), amosRequestContext.getAppKey(), task);
}
}
removeJob(jobName);
......@@ -606,16 +845,27 @@ public class JobService implements IJobService {
List<Long> StartPlanTaskList = planTaskMapper.getPlanTaskListByPlanId(planId,PlanTaskFinishStatusEnum.UNDERWAY.getValue());
List<PlanTask> planTaskList = planTaskMapper.getPlanTaskTListByPlanId(planId,PlanTaskFinishStatusEnum.UNDERWAY.getValue());
List<String> notStartPlanTaskStringList = notStartPlanTaskList.stream()
.map(Object::toString)
.collect(Collectors.toList());
List<String> StartPlanTaskStringList = StartPlanTaskList.stream()
.map(Object::toString)
.collect(Collectors.toList());
log.error("开始执行定时任务添加的任务==========>>{}", JSON.toJSONString(planTask));
if (XJConstant.STATUS_MONITOR_START.equals(jobType)) {
if (!ValidationUtil.isEmpty(notStartPlanTaskList)) {
planTaskMapper.updatePlanTaskByPlanId(notStartPlanTaskList,PlanTaskFinishStatusEnum.UNDERWAY.getValue());
planTaskMapper.updatePlanTaskByPlanId(notStartPlanTaskList, PlanTaskFinishStatusEnum.UNDERWAY.getValue());
updateEsPlanTaskList(notStartPlanTaskStringList,PlanTaskFinishStatusEnum.UNDERWAY.getValue(),"notApp",null);
patrolDataSyncService.taskStatic(null);
}
} else if (XJConstant.STATUS_MONITOR_END.equals(jobType)) {
if (!ValidationUtil.isEmpty(StartPlanTaskList)) {
planTaskMapper.updatePlanTaskByPlanId(StartPlanTaskList,PlanTaskFinishStatusEnum.OVERTIME.getValue());
planTaskMapper.updatePlanTaskDetailsByPlanId(StartPlanTaskList);
updateEsPlanTaskList(StartPlanTaskStringList,PlanTaskFinishStatusEnum.OVERTIME.getValue(),"notApp",null);
patrolDataSyncService.taskStatic(null);
for (PlanTask planTask: planTaskList
) {
createOmissionCheckRecord(planTask);
......@@ -650,8 +900,7 @@ public class JobService implements IJobService {
public void msgJobPerform(long msgId, String jobType, String jobName) {
if (iMsgDao.existsById(msgId)) {
Msg msg = iMsgDao.findById(msgId).get();
Toke toke = remoteSecurityService.getServerToken();
messageService.pushMsgAndSave(toke.getToke(), toke.getProduct(), toke.getAppKey(), msg);
messageService.pushMsgAndSave(amosRequestContext.getToken(), amosRequestContext.getProduct(), amosRequestContext.getAppKey(), msg);
}
removeJob(jobName);
}
......
......@@ -41,7 +41,7 @@ public class QuartzManager {
} else {
System.out.println("定时器已存在=========");
}
} catch (Exception e) {
} catch (Exception e) {
throw new RuntimeException(e);
}
}
......
......@@ -29,6 +29,7 @@ spring.datasource.hikari.maximum-pool-size = 10
spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1
security.password=a1234560
security.loginId=admin
security.productWeb=STUDIO_APP_WEB
......@@ -47,7 +48,9 @@ spring.redis.jedis.pool.min-idle=0
spring.redis.timeout=1000
#巡检计划定时任务
jobs.cron = 0 2 18 * * ?
jobs.cron = 0 0 22 * * ?
jobs.cron.static = 0 0 1 * * ?
jobs.cron.bak= -
#邮件配置
#params.mailPush = false
......@@ -104,6 +107,7 @@ is.zxj=true
fire-rescue=1432549862557130753
## ES properties:
action.auto_create_index:true
elasticsearch.username=elastic
elasticsearch.password=a123456
spring.elasticsearch.rest.uris=http://172.16.10.243:9200
......@@ -120,3 +124,70 @@ spring.jpa.properties.hibernate.jdbc.batch_versioned_data=true
spring.jpa.properties.hibernate.order_inserts=true
spring.jpa.properties.hibernate.order_updates =true
#spring.shardingsphere.mode.type=Standalone
#spring.shardingsphere.mode.repository.type=JDBC
## ds0
#spring.shardingsphere.datasource.ds0.type=com.zaxxer.hikari.HikariDataSource
#spring.shardingsphere.datasource.ds0.driver-class-name=cn.com.vastbase.Driver
#spring.shardingsphere.datasource.ds0.jdbc-url=jdbc:vastbase://172.16.10.243:5432/tzs_amos_tzs_biz_init?currentSchema=amos_tzs_biz&allowMultiQueries=true
#spring.shardingsphere.datasource.ds0.username=admin
#spring.shardingsphere.datasource.ds0.password=Yeejoin@2023
#spring.shardingsphere.datasource.ds0.idle-timeout=600000
#spring.shardingsphere.datasource.ds0.connection-timeout=30000
#spring.shardingsphere.datasource.ds0.validation-timeout=3000
#spring.shardingsphere.datasource.ds0.max-lifetime=58880
#spring.shardingsphere.datasource.ds0.minimum-idle=10
#spring.shardingsphere.datasource.ds0.maximum-pool-size=50
#
#
##数据源名称,多数据源以逗号分隔
#spring.shardingsphere.datasource.names=ds0
## 这里由于分库分表字段不相同配置,不然会导致使用user_id 查询找不到相应的表,如果我们分库分表都使用 user_id 则不需要这个配置
#spring.shardingsphere.rules.sharding.tables.p_plan_task_history.actual-data-nodes = ds0.p_plan_task_history_$->{1..2}
#spring.shardingsphere.rules.sharding.tables.p_plan_task_detail_history.actual-data-nodes = ds0.p_plan_task_detail_history_$->{1..2}
#spring.shardingsphere.rules.sharding.tables.p_check_history.actual-data-nodes = ds0.p_check_history_$->{1..2}
#spring.shardingsphere.rules.sharding.tables.p_check_input_history.actual-data-nodes = ds0.p_check_input_history_$->{1..2}
#spring.shardingsphere.rules.sharding.tables.p_check_shot_history.actual-data-nodes = ds0.p_check_shot_history_$->{1..2}
#
#spring.shardingsphere.sharding.default-data.source-name=ds0
#spring.main.allow-bean-definition-overriding=true
#
## -----分表开始
## 分片键位sequence_nbr,每个库分为两表,所以取模2
#spring.shardingsphere.rules.sharding.tables.p_plan_task_history.table-strategy.standard.sharding-column=id
#spring.shardingsphere.rules.sharding.tables.p_plan_task_history.table-strategy.standard.sharding-algorithm-name=task-inline
#
#spring.shardingsphere.rules.sharding.tables.p_plan_task_detail_history.table-strategy.standard.sharding-column=id
#spring.shardingsphere.rules.sharding.tables.p_plan_task_detail_history.table-strategy.standard.sharding-algorithm-name=task-detail-inline
#
#spring.shardingsphere.rules.sharding.tables.p_check_history.table-strategy.standard.sharding-column=id
#spring.shardingsphere.rules.sharding.tables.p_check_history.table-strategy.standard.sharding-algorithm-name=check-inline
#
#spring.shardingsphere.rules.sharding.tables.p_check_input_history.table-strategy.standard.sharding-column=id
#spring.shardingsphere.rules.sharding.tables.p_check_input_history.table-strategy.standard.sharding-algorithm-name=check-input-inline
#
#spring.shardingsphere.rules.sharding.tables.p_check_shot_history.table-strategy.standard.sharding-column=id
#spring.shardingsphere.rules.sharding.tables.p_check_shot_history.table-strategy.standard.sharding-algorithm-name=check-shot-inline
#
##行表达式分片算法
#spring.shardingsphere.rules.sharding.sharding-algorithms.task-inline.type=INLINE
#spring.shardingsphere.rules.sharding.sharding-algorithms.task-inline.props.algorithm-expression=p_plan_task_history_$->{id % 2 + 1}
#
#spring.shardingsphere.rules.sharding.sharding-algorithms.task-detail-inline.type=INLINE
#spring.shardingsphere.rules.sharding.sharding-algorithms.task-detail-inline.props.algorithm-expression=p_plan_task_detail_history_$->{id % 2 + 1}
#
#spring.shardingsphere.rules.sharding.sharding-algorithms.check-inline.type=INLINE
#spring.shardingsphere.rules.sharding.sharding-algorithms.check-inline.props.algorithm-expression=p_check_history_$->{id % 2 + 1}
#
#spring.shardingsphere.rules.sharding.sharding-algorithms.check-input-inline.type=INLINE
#spring.shardingsphere.rules.sharding.sharding-algorithms.check-input-inline.props.algorithm-expression=p_check_input_history_$->{id % 2 + 1}
#
#spring.shardingsphere.rules.sharding.sharding-algorithms.check-shot-inline.type=INLINE
#spring.shardingsphere.rules.sharding.sharding-algorithms.check-shot-inline.props.algorithm-expression=p_check_shot_history_$->{id % 2 + 1}
## -----分表结束
#
##是否开启SQL显示,默认值: false
#spring.shardingsphere.props.sql-show= false
#spring.shardingsphere.props.max-connections-size-per-query=5
shardingsphere.create.tables.num=10
\ No newline at end of file
......@@ -553,27 +553,21 @@
<select id="planCount" resultType="Map">
SELECT
SUM ( CASE WHEN pt.finish_status = '0' or pt.finish_status = '1' THEN ( CASE WHEN pl.plan_type = #{type} THEN 1 ELSE 0 END) ELSE 0 END ) notStart,
SUM ( CASE WHEN pt.finish_status = '2' THEN ( CASE WHEN pl.plan_type = #{type} THEN ( CASE WHEN pt.risk_status = '1' THEN 1 ELSE 0 END) ELSE 0 END) ELSE 0 END ) riskEnd,
SUM ( CASE WHEN pt.finish_status = '2' THEN ( CASE WHEN pl.plan_type = #{type} THEN ( CASE WHEN pt.risk_status = '2' THEN 1 ELSE 0 END) ELSE 0 END) ELSE 0 END ) noRiskEnd,
SUM ( CASE WHEN pt.finish_status = '3' THEN ( CASE WHEN pl.plan_type = #{type} THEN 1 ELSE 0 END) ELSE 0 END ) timeOut,
(
CASE
WHEN '2' = #{type} THEN ( 1+( date_part( 'week', pt.begin_time ) ) )
ELSE ( CASE WHEN '1' = #{type} THEN DATE_FORMAT ( pt.check_date, '%Y-%m-%d' ) ELSE ( substr( DATE_FORMAT ( pt.check_date, '%Y-%m' ) , 6)) END ) END
) stime,
pl.plan_type as type
SUM ( CASE WHEN pt.finish_status = '0' or pt.finish_status = '1' THEN ( CASE WHEN pt.plan_type = #{type} THEN 1 ELSE 0 END) ELSE 0 END ) notStart,
SUM ( CASE WHEN pt.finish_status = '2' THEN ( CASE WHEN pt.plan_type = #{type} THEN ( CASE WHEN pt.risk_status = '1' THEN 1 ELSE 0 END) ELSE 0 END) ELSE 0 END ) riskEnd,
SUM ( CASE WHEN pt.finish_status = '2' THEN ( CASE WHEN pt.plan_type = #{type} THEN ( CASE WHEN pt.risk_status = '2' THEN 1 ELSE 0 END) ELSE 0 END) ELSE 0 END ) noRiskEnd,
SUM ( CASE WHEN pt.finish_status = '3' THEN ( CASE WHEN pt.plan_type = #{type} THEN 1 ELSE 0 END) ELSE 0 END ) timeOut,
DATE_FORMAT ( pt.check_date, '%Y-%m-%d' ) checkTime,
pt.org_code orgCode,
pt.use_code unitCode,
pt.begin_time beginTime,
pt.end_time endTime
FROM
p_plan_task pt left join p_plan pl on pt.plan_id = pl.id
p_plan_task pt
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 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 pt.org_code = #{orgCode} </if>
GROUP BY stime
order by stime ASC
pt.plan_type = #{type}
AND pt.check_date = #{checkTime}
GROUP BY pt.use_code
</select>
......@@ -2298,4 +2292,25 @@
</if>
</where>
</select>
<select id="planCountNew" resultType="java.util.Map">
select tb.not_start notStart, tb.risk_end riskEnd, tb.no_risk_end noRiskEnd, tb.time_out timeOut,
(
CASE
WHEN '2' = #{type} THEN ( 1+( date_part( 'week', tb.begin_time ) ) )
ELSE ( CASE WHEN '1' = #{type} THEN DATE_FORMAT ( tb.check_time, '%Y-%m-%d' ) ELSE ( substr( DATE_FORMAT ( tb.check_time, '%Y-%m' ) , 6)) END ) END
) stime
from ${table} tb
<where>
<if test="type=='1'">
DATE_FORMAT(tb.check_time, '%Y-%m') = #{checkTime}
</if>
<if test="type=='2'">
AND tb.check_time between #{startTime} and #{endTime}
</if>
<if test="type=='3'">
AND DATE_FORMAT(tb.check_time, '%Y') = #{checkTime}
</if>
<if test="orgCode!=null">AND tb.org_code = #{orgCode} </if>
</where>
</select>
</mapper>
\ No newline at end of file
......@@ -167,4 +167,8 @@
<update id="initUpdatePlanNextGenDate">
UPDATE p_plan p SET p.next_gen_date = CURDATE() WHERE p.is_delete = 0 AND p.status = 0 AND p.plan_end IS NULL AND p.next_gen_date <![CDATA[ < ]]> CURDATE();
</update>
<select id="getPlan" resultType="com.yeejoin.amos.patrol.dao.entity.Plan">
select * from p_plan where id = #{planId}
</select>
</mapper>
\ No newline at end of file
......@@ -2,7 +2,39 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.patrol.business.dao.mapper.PlanTaskMapper">
<!--统计-计划执行 -->
<insert id="insertAll">
insert into
${table} (
id ,
not_start,
risk_end,
no_risk_end,
time_out,
check_time,
org_code,
unit_code,
create_date,
begin_time,
end_time
) values
<!-- <foreach collection="list" item="item" index="index" separator="," >-->
(
#{item.id},
#{item.notStart},
#{item.riskEnd},
#{item.noRiskEnd},
#{item.timeOut},
#{item.checkTime},
#{item.orgCode},
#{item.unitCode},
#{item.createDate},
#{item.beginTime},
#{item.endTime}
);
<!-- </foreach>-->
</insert>
<!--统计-计划执行 -->
<select id="countPlanTask" resultType="long">
SELECT COUNT(1) as total_num FROM (
SELECT
......@@ -148,6 +180,7 @@
#{Id}
</foreach>
</delete>
<update id="updatePlanTaskPtInfo" >
update p_plan_task a
set a.point_num = (select count(1) from p_plan_task_detail b where a.id = b.task_no),
......@@ -655,6 +688,8 @@
<select id="getPointPlanTaskInfo" resultType="com.yeejoin.amos.patrol.business.entity.mybatis.PointCheckDetailBo" parameterType="long">
SELECT
pptd.id,
ppt.id planTaskId,
pp.id pointId,
pp.name pointName,
pp.point_no pointNo,
......@@ -693,6 +728,7 @@
<select id="getPointInputByRouteIdAndPointId" resultType="com.yeejoin.amos.patrol.business.entity.mybatis.PointCheckDetailBo" parameterType="long">
SELECT
pii.id inputItemId,
pii.name inputName,
pii.id checkInputId,
ppc.id classifyId,
......@@ -1625,6 +1661,27 @@
plan_id,
finish_status
</select>
<select id="findPlanTask" resultType="com.yeejoin.amos.patrol.dao.entity.PlanTask">
select * from p_plan_task
</select>
<select id="findPlanTaskDetail" resultType="com.yeejoin.amos.patrol.dao.entity.PlanTaskDetail">
select * from p_plan_task_detail
</select>
<select id="findCheck" resultType="com.yeejoin.amos.patrol.dao.entity.Check">
select * from p_check
</select>
<select id="findCheckInput" resultType="com.yeejoin.amos.patrol.dao.entity.CheckInput">
select * from p_check_input
</select>
<select id="findCheckShot" resultType="com.yeejoin.amos.patrol.dao.entity.CheckShot">
select * from p_check_shot
</select>
<select id="findStaticDay" resultType="com.yeejoin.amos.patrol.dao.entity.StaticDay">
select * from p_static_day
</select>
<select id="findStaticWeek" resultType="com.yeejoin.amos.patrol.dao.entity.StaticDay">
select * from p_static_week
</select>
<update id="updatePlanTaskList">
update
......@@ -1632,7 +1689,197 @@
set
finish_status = #{newStatus}
where
plan_id = #{planId}
and finish_status = #{oldStatus}
id in
<foreach item="id" collection="ids" index="index" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<update id="updateData">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update ${table}
<set>
not_start = #{item.notStart},risk_end = #{item.riskEnd},
no_risk_end = #{item.noRiskEnd},time_out = #{item.timeOut},
create_date = now()
</set>
where org_code = #{item.orgCode} AND check_time = #{item.checkTime}
</foreach>
</update>
<update id="updateSingle">
update ${table} set not_start = not_start - 1,risk_end = risk_end + #{riskEnd},
no_risk_end = no_risk_end + #{noRiskEnd}
where org_code = #{orgCode} AND check_time = #{checkTime}
</update>
<select id="selectPlanTaskIdList" resultType="java.lang.String">
SELECT
id
FROM
"p_plan_task"
WHERE
plan_id = #{planId}
AND finish_status = #{oldStatus}
</select>
<select id="selectTaskDetails" resultType="com.yeejoin.amos.patrol.dao.entity.PlanTaskDetail">
select
pptd.is_finish,
pptd.point_id,
pptd.task_no,
pp.name,
pp.point_no,
pptd.status,
pptd.id,
pptd.create_date
from
"p_plan_task_detail" pptd LEFT JOIN p_point pp ON pp."id"=pptd.point_id
where
task_no in ${id}
</select>
<select id="selectTaskStatus" resultType="java.util.Map">
select finish_status status, org_code orgCode, check_date checkDate, plan_type planType, risk_status riskStatus from "p_plan_task" where id = #{planTaskId}
</select>
<delete id="deleteDate">
delete from ${table} where 1=1;
</delete>
<delete id="deleteOne">
delete from ${table} where check_time = #{checkDate};
</delete>
<select id="selectRoutId" resultType="java.lang.Long">
select route_id from p_plan_task where id = #{id}
</select>
<select id="selectPlanTaskIdLists" resultType="java.lang.String">
SELECT
id
FROM
"p_plan_task"
WHERE
plan_id = #{planId}
AND (finish_status = #{status} or finish_status = #{status1} )
</select>
<select id="selectTaskList" resultType="com.yeejoin.amos.patrol.dao.entity.PlanTask">
select
*
from
"p_plan_task"
where id in
<foreach item="id" collection="newList" index="index" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="queryPlanTaskStaticById" resultType="com.yeejoin.amos.patrol.business.dto.PlanTaskStaticDto">
SELECT
a.planTaskId,
sum(a.finish) finshNum,
sum(a.omission) omission,
sum(a.unqualified) unqualified,
sum(a.unplan) unplan,
count(a.finish) taskPlanNum
FROM
(
SELECT
pt.id planTaskId,
CASE ptd.status
WHEN 1 THEN
1
ELSE
0
END finish,
CASE ptd.status
WHEN 3 THEN
1
ELSE
0
END omission,
CASE ptd.status
WHEN 2 THEN
1
ELSE
0
END unqualified,
CASE ptd.status
WHEN 0 THEN
1
ELSE
0
END unplan
FROM
p_plan_task_detail ptd
LEFT JOIN p_plan_task pt ON ptd.task_no = pt.id
) a
where a.planTaskId IN ${planTaskIds}
GROUP BY a.planTaskId
</select>
<select id="selectTaskDetailList" resultType="com.yeejoin.amos.patrol.dao.entity.ESTaskDetailDto">
SELECT
pptd.id,
pptd.task_no planTaskId,
pptd.status pointStatus,
pp.id pointId,
pp.name pointName,
pp.point_no pointNo,
pp.shot_min_number shortMinNumber,
pp.shot_max_number shortMaxNumber,
'0' checkId
FROM
"p_plan_task_detail" pptd LEFT JOIN p_point pp ON pp.id = pptd.point_id
WHERE
task_no IN ${ids}
</select>
<select id="selectTaskInfoList" resultType="com.yeejoin.amos.patrol.dao.entity.ESTaskDetailDto">
SELECT
id planTaskId,
date_format(ppt.begin_time,'%Y-%m-%d %H:%i:%s') beginTime,
date_format(ppt.end_time,'%Y-%m-%d %H:%i:%s') endTime,
ppt.finish_status taskStatus
FROM
p_plan_task ppt
WHERE
plan_id = #{id};
</select>
<select id="selectPointInputs" resultType="com.yeejoin.amos.patrol.core.common.response.AppCheckInputRespone">
SELECT
prp.point_id,
null inputValue,
null pointInputImgUrls,
pii.default_value,
pii.NAME inputName,
ppi.ID pointInputItemId,
pii.ID checkInputId,
pii.item_type itemType,
pii.risk_desc riskDesc,
pii.data_json dataJson,
pii.is_must isMust,
pii.default_value defaultValue,
pii.picture_json pictureJson,
pii.is_multiline isMultiline,
pii.order_no orderNo
FROM
"p_route_point" prp
LEFT JOIN p_route_point_item pi ON prp.ID = pi.route_point_id
LEFT JOIN p_point_inputitem ppi ON pi.point_input_item_id = ppi.id
LEFT JOIN p_input_item pii ON ppi.input_item_id = pii.id
WHERE
pii."id" IS NOT NULL
AND route_id = #{routeId}
</select>
<select id="getPlanTaskIds" resultType="java.lang.String">
SELECT ID FROM p_plan_task WHERE plan_id = #{id}
</select>
<select id="selectExcludeItemsByRoutId" resultType="java.util.Map">
select point_id,exclude_items from p_route_point where route_id = #{routeId}
</select>
</mapper>
\ No newline at end of file
......@@ -1423,7 +1423,7 @@
LEFT JOIN p_input_item pii ON pii.id = ppi.input_item_id
WHERE
ppi.point_id = #{pointId}
AND ppi.classify_ids = #{classifyId}
AND ppi.classify_ids = (select id from p_point_classify where point_id = #{pointId} limit 1)
</select>
<select id="getPointRefItem" parameterType="list" resultType="map">
......@@ -1509,4 +1509,8 @@
AND pp.id != #{pointId}
</if>
</select>
<select id="selectPointInfo" resultType="com.yeejoin.amos.patrol.dao.entity.Point">
select * from p_point where id = #{pointId}
</select>
</mapper>
\ No newline at end of file
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