Commit 4995a874 authored by H2T's avatar H2T

Merge remote-tracking branch 'origin/develop_tzs_register' into develop_tzs_register

parents a648228d 8b824f25
......@@ -185,9 +185,9 @@ public class JobService implements IJobService {
iPlanTaskDetailDao.saveAndFlush(action);
});
}
if (PlanTaskFinishStatusEnum.OVERTIME.getValue() == status) {
createOmissionCheckRecord(planTask);
}
// if (PlanTaskFinishStatusEnum.OVERTIME.getValue() == status) {
// createOmissionCheckRecord(planTask);
// }
}
/**
......
package com.yeejoin.amos.boot.module.elevator.api.dto;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
*
*
* @author system_generator
* @date 2023-11-09
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="AlertMaintenanceUnitStatisticsDto", description="")
public class AlertMaintenanceUnitStatisticsDto extends BaseDto {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "监管单位ID")
private String supervisoryUnitId;
@ApiModelProperty(value = "监管单位名称")
private String supervisoryUnitName;
@ApiModelProperty(value = "监管单位编码")
private String supervisoryUnitOrgCode;
@ApiModelProperty(value = "统计月份")
private String statisticsDate;
@ApiModelProperty(value = "开始日期")
private String startDate;
@ApiModelProperty(value = "结束日期")
private String endDate;
@ApiModelProperty(value = "维保单位")
private String maintenanceName;
@ApiModelProperty(value = "困人救援")
private Integer trappedNum;
@ApiModelProperty(value = "故障救援")
private Integer faultNum;
@ApiModelProperty(value = "总事件数")
private Integer alertNum;
@ApiModelProperty(value = "比率")
private String rate;
}
package com.yeejoin.amos.boot.module.elevator.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
*
*
* @author system_generator
* @date 2023-11-09
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("tzs_alert_maintenance_unit_statistics")
public class AlertMaintenanceUnitStatistics extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 监管单位ID
*/
@TableField("supervisory_unit_id")
private String supervisoryUnitId;
/**
* 监管单位名称
*/
@TableField("supervisory_unit_name")
private String supervisoryUnitName;
/**
* 监管单位编码
*/
@TableField("supervisory_unit_org_code")
private String supervisoryUnitOrgCode;
/**
* 统计月份
*/
@TableField("statistics_date")
private String statisticsDate;
/**
* 开始日期
*/
@TableField("start_date")
private String startDate;
/**
* 结束日期
*/
@TableField("end_date")
private String endDate;
/**
* 维保单位
*/
@TableField("maintenance_name")
private String maintenanceName;
/**
* 困人救援
*/
@TableField("trapped_num")
private Integer trappedNum;
/**
* 故障救援
*/
@TableField("fault_num")
private Integer faultNum;
/**
* 总事件数
*/
@TableField("alert_num")
private Integer alertNum;
/**
* 比率
*/
@TableField("rate")
private String rate;
/**
* 维保电梯数量
*/
@TableField("equip_num")
private Integer equipNum;
}
package com.yeejoin.amos.boot.module.elevator.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.elevator.api.entity.AlertMaintenanceUnitStatistics;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* Mapper 接口
*
* @author system_generator
* @date 2023-11-09
*/
public interface AlertMaintenanceUnitStatisticsMapper extends BaseMapper<AlertMaintenanceUnitStatistics> {
List<Map<String, String>> getMessage(@Param("startDate")String startDate , @Param("endDate")String endDate);
AlertMaintenanceUnitStatistics countMessage(@Param("unitCode") String unitCode, @Param("equipId") String equipId);
}
package com.yeejoin.amos.boot.module.elevator.api.service;
import com.yeejoin.amos.boot.module.elevator.api.entity.AlertMaintenanceUnitStatistics;
import java.util.List;
/**
* 接口类
*
* @author system_generator
* @date 2023-11-09
*/
public interface IAlertMaintenanceUnitStatisticsService {
void statisticalGeneration();
List<AlertMaintenanceUnitStatistics> getList(String date);
}
package com.yeejoin.amos.boot.module.elevator.api.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
@Data
public class AlertMaintenanceUnitStatisticsExportVo {
@ColumnWidth(10)
@ExcelProperty(value = "序号", index = 0)
private Integer number;
@ColumnWidth(30)
@ExcelProperty(value = "区 域", index = 1)
private String supervisoryUnitName;
@ColumnWidth(30)
@ExcelProperty(value = "维保单位名称", index = 2)
private String maintenanceName;
@ExcelProperty(value = "困人次数", index = 4)
private Integer trappedNum;
@ExcelProperty(value = "故障次数", index = 5)
private Integer faultNum;
@ExcelProperty(value = "总事件数", index = 6)
private Integer alertNum;
@ExcelProperty(value = "比 率", index = 7)
private String rate;
@ExcelProperty(value = "维保电梯数量", index = 3)
private Integer equipNum;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.elevator.api.mapper.AlertMaintenanceUnitStatisticsMapper">
<select id="getMessage" resultType="java.util.Map">
SELECT mainCode as maintenanceCode, orgBranchName,orgBranchCode, equipmentId
from (
SELECT
tac.equipment_id as equipmentId,
(
SELECT ME_UNIT_CREDIT_CODE
from idx_biz_jg_maintenance_record_info
WHERE RECORD = equipment_id
ORDER BY INFORM_START LIMIT 1
) as mainCode,
jsi."ORG_BRANCH_NAME" as orgBranchName,
jsi."ORG_BRANCH_code" as orgBranchCode
from tz_alert_called tac
LEFT JOIN idx_biz_jg_supervision_info jsi on tac.equipment_id = jsi.RECORD
WHERE tac.alarm_type_code != '962'
and tac.equipment_id is not null
and call_time between #{startDate} and #{endDate}
)
WHERE mainCode is not null
GROUP BY equipmentId
</select>
<select id="countMessage"
resultType="com.yeejoin.amos.boot.module.elevator.api.entity.AlertMaintenanceUnitStatistics">
SELECT
(
SELECT count(DISTINCT(RECORD)) FROM idx_biz_jg_maintenance_record_info WHERE ME_UNIT_CREDIT_CODE = #{unitCode}
)as equipNum,
(
SELECT count(1) from tz_alert_called WHERE equipment_id = #{equipId} and alarm_type_code = '960'
) as trappedNum,
(
SELECT count(1) from tz_alert_called WHERE equipment_id = #{equipId} and alarm_type_code = '961'
) as faultNum,
(
SELECT ME_UNIT_NAME from idx_biz_jg_maintenance_record_info WHERE ME_UNIT_CREDIT_CODE = #{unitCode} limit 1
) as maintenanceName
</select>
</mapper>
......@@ -4,18 +4,9 @@ import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil;
import com.yeejoin.amos.boot.module.elevator.api.entity.AlertPlaceStatistics;
import com.yeejoin.amos.boot.module.elevator.api.entity.AlertRescueStatistics;
import com.yeejoin.amos.boot.module.elevator.api.entity.AlertStatistics;
import com.yeejoin.amos.boot.module.elevator.api.entity.AlertUseUnitStatistics;
import com.yeejoin.amos.boot.module.elevator.api.service.IAlertPlaceStatisticsService;
import com.yeejoin.amos.boot.module.elevator.api.service.IAlertRescueStatisticsService;
import com.yeejoin.amos.boot.module.elevator.api.service.IAlertStatisticsService;
import com.yeejoin.amos.boot.module.elevator.api.service.IAlertUseUnitStatisticsService;
import com.yeejoin.amos.boot.module.elevator.api.vo.AlertPlaceStatisticsExportVo;
import com.yeejoin.amos.boot.module.elevator.api.vo.AlertRescueStatisticsExportVo;
import com.yeejoin.amos.boot.module.elevator.api.vo.AlertStatisticsExportVo;
import com.yeejoin.amos.boot.module.elevator.api.vo.AlertUseUnitStatisticsVo;
import com.yeejoin.amos.boot.module.elevator.api.entity.*;
import com.yeejoin.amos.boot.module.elevator.api.service.*;
import com.yeejoin.amos.boot.module.elevator.api.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -55,6 +46,9 @@ public class StatisticsController extends BaseController {
@Autowired
private IAlertUseUnitStatisticsService alertUseUnitStatisticsService;
@Autowired
private IAlertMaintenanceUnitStatisticsService alertMaintenanceUnitStatisticsService;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/statisticalGeneration")
@ApiOperation(httpMethod = "GET", value = "生成统计数据", notes = "生成统计数据")
......@@ -253,4 +247,52 @@ public class StatisticsController extends BaseController {
ExcelUtil.createTemplate(response, "月度困人故障高发使用单位", "月度困人故障高发使用单位", exportVos, AlertUseUnitStatisticsVo.class, null, false);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/statisticalMaintenanceUnitGeneration")
@ApiOperation(httpMethod = "GET", value = "生成统计数据", notes = "生成统计数据")
public ResponseModel<Object> statisticalMaintenanceUnitGeneration() {
alertMaintenanceUnitStatisticsService.statisticalGeneration();
return ResponseHelper.buildResponse("success");
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/maintenanceUnitList")
@ApiOperation(httpMethod = "GET", value = "查询列表", notes = "查询列表")
public ResponseModel<Object> maintenanceUnitList(@RequestParam(value = "date", required = false) String date) {
if (ObjectUtils.isEmpty(date)) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
Date nowDate = cal.getTime();
date = format.format(nowDate);
}
Page<AlertMaintenanceUnitStatistics> alertRescueStatisticsPage = new Page<>();
alertRescueStatisticsPage.setRecords(alertMaintenanceUnitStatisticsService.getList(date));
return ResponseHelper.buildResponse(alertRescueStatisticsPage);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/exportMaintenanceUnitData")
@ApiOperation(httpMethod = "GET", value = "月度故障高发维保单位统计导出", notes = "月度故障高发维保单位统计导出")
public void exportMaintenanceUnitData(HttpServletResponse response, @RequestParam(value = "date", required = false) String date) throws ParseException {
if (ObjectUtils.isEmpty(date)) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
Date nowDate = cal.getTime();
date = format.format(nowDate);
}
ArrayList<AlertMaintenanceUnitStatisticsExportVo> exportVos = new ArrayList<>();
List<AlertMaintenanceUnitStatistics> list = alertMaintenanceUnitStatisticsService.getList(date);
int number = 1;
for (AlertMaintenanceUnitStatistics item : list) {
AlertMaintenanceUnitStatisticsExportVo vo = new AlertMaintenanceUnitStatisticsExportVo();
BeanUtil.copyProperties(item, vo);
vo.setNumber(number);
number = number + 1;
exportVos.add(vo);
}
ExcelUtil.createTemplate(response, "月度故障高发维保单位统计", "月度故障高发维保单位统计", exportVos, AlertMaintenanceUnitStatisticsExportVo.class, null, false);
}
}
package com.yeejoin.amos.boot.module.elevator.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.elevator.api.dto.AlertMaintenanceUnitStatisticsDto;
import com.yeejoin.amos.boot.module.elevator.api.entity.AlertMaintenanceUnitStatistics;
import com.yeejoin.amos.boot.module.elevator.api.entity.AlertRescueStatistics;
import com.yeejoin.amos.boot.module.elevator.api.mapper.AlertMaintenanceUnitStatisticsMapper;
import com.yeejoin.amos.boot.module.elevator.api.service.IAlertMaintenanceUnitStatisticsService;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* 服务实现类
*
* @author system_generator
* @date 2023-11-09
*/
@Service
public class AlertMaintenanceUnitStatisticsServiceImpl extends BaseService<AlertMaintenanceUnitStatisticsDto, AlertMaintenanceUnitStatistics, AlertMaintenanceUnitStatisticsMapper> implements IAlertMaintenanceUnitStatisticsService {
@Autowired
private AlertStatisticsServiceImpl alertStatisticsService;
@Override
@Scheduled(cron = "0 0 0 1 * ?")
@SchedulerLock(name = "AlertMaintenanceUnitStatisticsServiceImpl", lockAtMostFor = "PT10M", lockAtLeastFor = "PT10M")
public void statisticalGeneration() {
DecimalFormat decimalFormat = new DecimalFormat("0.00");
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
ArrayList<AlertMaintenanceUnitStatistics> list = new ArrayList<>();
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.MONTH, -1);
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
Date firstDayOfMonth = cal.getTime();
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
Date lastDayOfMonth = cal.getTime();
List<LinkedHashMap> supervisionList = alertStatisticsService.getSupervisionList();
if (!ObjectUtils.isEmpty(supervisionList)) {
List<Map<String, String>> message = this.baseMapper.getMessage(format.format(firstDayOfMonth) + " 00:00:00", format.format(lastDayOfMonth) + " 23:59:59");
supervisionList.forEach(item -> {
List<Map<String, String>> collect = message.stream().filter(maintenance -> maintenance.get("orgBranchCode").startsWith(String.valueOf(item.get("orgCode")))).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(collect)) {
collect.forEach(data -> {
AlertMaintenanceUnitStatistics alertMaintenanceStatistics = this.baseMapper.countMessage(data.get("maintenanceCode"), data.get("equipmentId"));
alertMaintenanceStatistics.setSupervisoryUnitName(String.valueOf(item.get("companyName")));
alertMaintenanceStatistics.setSupervisoryUnitOrgCode(String.valueOf(item.get("orgCode")));
alertMaintenanceStatistics.setSupervisoryUnitId(String.valueOf(item.get("sequenceNbr")));
alertMaintenanceStatistics.setAlertNum(alertMaintenanceStatistics.getTrappedNum() + alertMaintenanceStatistics.getFaultNum());
if (alertMaintenanceStatistics.getAlertNum() != 0 && alertMaintenanceStatistics.getEquipNum() != 0) {
BigDecimal bigDecimal = new BigDecimal(alertMaintenanceStatistics.getAlertNum());
BigDecimal bigDecimal1 = new BigDecimal(alertMaintenanceStatistics.getEquipNum());
BigDecimal divide = bigDecimal.divide(bigDecimal1, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
alertMaintenanceStatistics.setRate(decimalFormat.format(divide) + "%");
} else {
alertMaintenanceStatistics.setRate("0%");
}
alertMaintenanceStatistics.setStartDate(format.format(firstDayOfMonth));
alertMaintenanceStatistics.setEndDate(format.format(lastDayOfMonth));
alertMaintenanceStatistics.setStatisticsDate(format.format(lastDayOfMonth).substring(0, 7));
list.add(alertMaintenanceStatistics);
});
}
});
if (!ObjectUtils.isEmpty(list)) {
this.saveBatch(list);
}
}
}
@Override
public List<AlertMaintenanceUnitStatistics> getList(String date) {
LambdaQueryWrapper<AlertMaintenanceUnitStatistics> lambda = new QueryWrapper<AlertMaintenanceUnitStatistics>().lambda();
lambda.eq(AlertMaintenanceUnitStatistics::getStatisticsDate, date);
return this.baseMapper.selectList(lambda);
}
}
\ No newline at end of file
......@@ -6,6 +6,8 @@ import com.yeejoin.amos.boot.module.elevator.api.dto.AlertPlaceStatisticsDto;
import com.yeejoin.amos.boot.module.elevator.api.entity.AlertPlaceStatistics;
import com.yeejoin.amos.boot.module.elevator.api.mapper.AlertPlaceStatisticsMapper;
import com.yeejoin.amos.boot.module.elevator.api.service.IAlertPlaceStatisticsService;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.rdbms.service.BaseService;
......@@ -26,6 +28,8 @@ public class AlertPlaceStatisticsServiceImpl extends BaseService<AlertPlaceStati
@Override
@Scheduled(cron = "0 0 0 1 * ?")
@SchedulerLock(name = "AlertPlaceStatisticsServiceImpl", lockAtMostFor = "PT10M", lockAtLeastFor = "PT10M")
public void statisticalGeneration() {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
DecimalFormat decimalFormat = new DecimalFormat("0.00");
......
......@@ -34,7 +34,7 @@ public class AlertRescueStatisticsServiceImpl extends BaseService<AlertRescueSta
@Override
@Scheduled(cron = "0 0 0 1 * ?")
@SchedulerLock(name = "statisticalGeneration", lockAtMostFor = "PT10M", lockAtLeastFor = "PT10M")
@SchedulerLock(name = "AlertRescueStatisticsServiceImpl", lockAtMostFor = "PT10M", lockAtLeastFor = "PT10M")
public void statisticalGeneration() {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal = Calendar.getInstance();
......
......@@ -34,7 +34,7 @@ public class AlertStatisticsServiceImpl extends BaseService<AlertStatisticsDto,
@Override
@Scheduled(cron = "0 0 0 1 * ?")
@SchedulerLock(name = "statisticalGeneration", lockAtMostFor = "PT10M", lockAtLeastFor = "PT10M")
@SchedulerLock(name = "AlertStatisticsServiceImpl", lockAtMostFor = "PT10M", lockAtLeastFor = "PT10M")
public void statisticalGeneration() {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal = Calendar.getInstance();
......
......@@ -8,6 +8,8 @@ import com.yeejoin.amos.boot.module.elevator.api.dto.AlertUseUnitStatisticsDto;
import com.yeejoin.amos.boot.module.elevator.api.entity.AlertUseUnitStatistics;
import com.yeejoin.amos.boot.module.elevator.api.mapper.AlertUseUnitStatisticsMapper;
import com.yeejoin.amos.boot.module.elevator.api.service.IAlertUseUnitStatisticsService;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.rdbms.service.BaseService;
......@@ -27,9 +29,10 @@ public class AlertUseUnitStatisticsServiceImpl extends BaseService<AlertUseUnitS
@Override
@Scheduled(cron = "0 0 0 1 * ?")
@SchedulerLock(name = "AlertUseUnitStatisticsServiceImpl", lockAtMostFor = "PT10M", lockAtLeastFor = "PT10M")
public void statisticalGeneration() {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
DecimalFormat decimalFormat = new DecimalFormat("0.00");
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.MONTH, -1);
......
......@@ -835,20 +835,20 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
if (userResult == null || userResult.getResult() == null) {
throw new BadRequest("单位注册失败");
}
//同步创建为当前注册管理员添加两员配备人员信息
if (userResult.getStatus() == 200) {
TzsUserInfo tzsUserInfo = new TzsUserInfo();
tzsUserInfo.setName(regUnitInfo.getAdminName());
tzsUserInfo.setCertificateType("344");
tzsUserInfo.setLockStatus("UNLOCK");
tzsUserInfo.setCertificateNum(regUnitInfo.getAdminIdNumber());
tzsUserInfo.setUnitName(regUnitInfo.getName());
tzsUserInfo.setUnitCode(regUnitInfo.getUnitCode());
tzsUserInfo.setPhone(regUnitInfo.getAdminTel());
tzsUserInfo.setAmosUserId(userResult.getResult().getUserId());
tzsUserInfo.setAmosUserName(regUnitInfo.getAdminLoginName());
tzsUserInfoService.save(tzsUserInfo);
}
// //同步创建为当前注册管理员添加两员配备人员信息
// if (userResult.getStatus() == 200) {
// TzsUserInfo tzsUserInfo = new TzsUserInfo();
// tzsUserInfo.setName(regUnitInfo.getAdminName());
// tzsUserInfo.setCertificateType("344");
// tzsUserInfo.setLockStatus("UNLOCK");
// tzsUserInfo.setCertificateNum(regUnitInfo.getAdminIdNumber());
// tzsUserInfo.setUnitName(regUnitInfo.getName());
// tzsUserInfo.setUnitCode(regUnitInfo.getUnitCode());
// tzsUserInfo.setPhone(regUnitInfo.getAdminTel());
// tzsUserInfo.setAmosUserId(userResult.getResult().getUserId());
// tzsUserInfo.setAmosUserName(regUnitInfo.getAdminLoginName());
// tzsUserInfoService.save(tzsUserInfo);
// }
regUnitInfo.setAdminUserId(userResult.getResult().getUserId());
regUnitInfo.setAmosCompanySeq(companyInfo.getSequenceNbr().toString());
// 3.3 org_user 创建组织机构
......
......@@ -37,20 +37,20 @@
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="debug"/>
<logger name="org.mybatis" level="debug" />
<logger name="java.sql.Connection" level="debug"/>
<logger name="java.sql.Statement" level="debug"/>
<logger name="java.sql.PreparedStatement" level="debug"/>
<logger name="org.springframework" level="debug"/>
<logger name="com.apache.ibatis" level="INFO"/>
<logger name="org.mybatis" level="INFO" />
<logger name="java.sql.Connection" level="INFO"/>
<logger name="java.sql.Statement" level="INFO"/>
<logger name="java.sql.PreparedStatement" level="INFO"/>
<logger name="org.springframework" level="INFO"/>
<logger name="com.baomidou.mybatisplus" level="debug"/>
<logger name="org.apache.activemq" level="debug"/>
<logger name="org.typroject" level="debug"/>
<logger name="com.yeejoin" level="debug"/>
<logger name="com.baomidou.mybatisplus" level="INFO"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="INFO"/>
<logger name="com.yeejoin" level="INFO"/>
<!-- 日志输出级别 -->
<root level="debug">
<root level="INFO">
<!-- <appender-ref ref="FILE" /> -->
<appender-ref ref="STDOUT" />
<!-- <appender-ref ref="ELK" />-->
......
......@@ -43,7 +43,7 @@ public class MyIdGeneratorConfig implements IdentifierGenerator {
}
public synchronized long snowflakeId(long workerId, long datacenterId) {
Snowflake snowflake = IdUtil.createSnowflake(workerId, datacenterId);
Snowflake snowflake = IdUtil.getSnowflake(workerId, datacenterId);
return snowflake.nextId();
}
......
......@@ -21,6 +21,7 @@ import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.core.env.Environment;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.client.RestTemplate;
......
......@@ -372,6 +372,7 @@ public class XJConstant {
public static final String NORISK = "无风险";
public static final String NOUSE = "不涉及";
public static final int INIT_NUM = 0;
public static final int RISK_NUM = 1;
public static final int NORISK_NUM = 2;
......
......@@ -205,16 +205,9 @@ public class CheckController extends AbstractBaseController {
public ResponseModel<Object> saveCheckRecordNew(
@ApiParam(value = "检查信息", required = false) @RequestBody(required = true) CheckRecordParam requestParam) {
int statu = -1;
PlanTask planTask =null;
PlanTask planTask = planTaskService.selectPlanTaskStatus(requestParam.getPlanTaskId());
log.info("手机app保存巡检记录++++++++++++++++++++++: {}", JSON.toJSONString(requestParam));
if(requestParam.getPlanTaskId()!=null && requestParam.getPlanTaskId() !=0){
List<Map<String, Object>> map = checkService.selectCheckById(requestParam.getPlanTaskId(), requestParam.getPointId());
if (!CollectionUtils.isEmpty(map)) {
List<Long> ids = map.stream().map(m -> Long.valueOf(m.get("id").toString())).collect(Collectors.toList());
checkService.delCheckByTaskId(requestParam.getPlanTaskId(), ids, requestParam.getPointId());
}
planTask = planTaskService.selectPlanTaskStatus(requestParam.getPlanTaskId());
}
AgencyUserModel user = getUserInfo();
String userId = user.getUserId();
String realName = user.getRealName();
......@@ -251,7 +244,7 @@ public class CheckController extends AbstractBaseController {
String orgCode =reginParams.getPersonIdentity().getBizOrgCode();
requestParam.setOrgCode(orgCode);
requestParam.setUserId(getUserId());
CheckDto checkDto = checkService.saveCheckRecordNew(requestParam);
CheckDto checkDto = checkService.saveCheckRecordNew(requestParam, planTask);
return ResponseHelper.buildResponse(checkDto);
} else {
return ResponseHelperUtil.buildErrorResponse("无需重新巡检");
......@@ -723,7 +716,7 @@ public class CheckController extends AbstractBaseController {
@RequestMapping(value = "/v2/queryCheckPointDetail", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryCheckPointDetailInVersion2(@RequestParam long checkId) {
try {
AppPointCheckRespone pointCheckRespone = checkService.queryCheckPointDetailInVersion2(getToken(),getProduct(),getAppKey(),checkId);
AppPointCheckRespone pointCheckRespone = checkService.queryCheckPointDetailInVersion2(getToken(),getProduct(),getAppKey(),checkId, null , null);
return CommonResponseUtil.success(pointCheckRespone);
} catch (Exception e) {
e.printStackTrace();
......
......@@ -3,11 +3,13 @@ package com.yeejoin.amos.patrol.business.dao.repository;
import com.yeejoin.amos.patrol.dao.entity.PlanTaskDetail;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Repository("planTaskDetail")
@EnableJpaRepositories
public interface IPlanTaskDetailDao extends BaseDao<PlanTaskDetail, Long> {
@Modifying
......
package com.yeejoin.amos.patrol.business.dao.repository;
import org.springframework.stereotype.Repository;
@Repository
public interface RepositoryTs {
// 批量存储的方法
<S> Iterable<S> batchSave(Iterable<S> var1);
// 批量更新的方法
<S> Iterable<S> batchUpdate(Iterable<S> var1);
}
package com.yeejoin.amos.patrol.business.service.impl;
import com.yeejoin.amos.patrol.business.dao.repository.RepositoryTs;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.Iterator;
@Service
public class RepositoryTImpl implements RepositoryTs {
private static final int BATCH_SIZE = 1000 ;
@PersistenceContext
private final EntityManager em;
public RepositoryTImpl(EntityManager em) {
this.em = em;
}
@Override
@Transactional
@Async("asyncServiceExecutor")
public <S> Iterable<S> batchSave(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;
}
@Override
public <S> Iterable<S> batchUpdate(Iterable<S> var1) {
Iterator<S> iterator = var1.iterator();
int index = 0;
while (iterator.hasNext()){
em.merge(iterator.next());
index++;
if (index % BATCH_SIZE == 0){
em.flush();
em.clear();
}
}
if (index % BATCH_SIZE != 0){
em.flush();
em.clear();
}
return var1;
}
}
......@@ -30,6 +30,8 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
......@@ -78,6 +80,15 @@ public class RouteServiceImpl extends ServiceImpl<RouteMapper, Route> implement
@Autowired
private IRoutePointItemDao iRoutePointItemDao;
@Autowired
private RepositoryTs repositoryTs;
@PersistenceContext
private final EntityManager em;
public RouteServiceImpl(EntityManager em) {
this.em = em;
}
@Override
@Transactional
......@@ -257,43 +268,44 @@ public class RouteServiceImpl extends ServiceImpl<RouteMapper, Route> implement
points.add(rp);
pointIds.add(rp.getPointId());
});
List<RoutePoint> savedPoints = iRoutePointDao.saveAll(points);
List<Map<String, Object>> pointRefItem = pointMapper.getPointRefItem(pointIds);
if (!savedPoints.isEmpty()) {
savedPoints.forEach(rp -> {
String excludeItems = rp.getExcludeItems();
Set<Long> excludeItemIdSet = new HashSet<>();
if (excludeItems != null && !excludeItems.isEmpty()) {
String[] itemIds = excludeItems.split(",");
for (String itemId : itemIds) {
try {
excludeItemIdSet.add(Long.valueOf(itemId));
} catch (Exception e) {
}
for (RoutePoint rt: routePoints
) {
em.persist(rt);
em.flush();
em.clear();
String excludeItems = rt.getExcludeItems();
Set<Long> excludeItemIdSet = new HashSet<>();
if (excludeItems != null && !excludeItems.isEmpty()) {
String[] itemIds = excludeItems.split(",");
for (String itemId : itemIds) {
try {
excludeItemIdSet.add(Long.valueOf(itemId));
} catch (Exception e) {
}
}
final int[] orderNum = {1};
pointRefItem.forEach(ref -> {
Long pointId = rp.getPointId();
if(pointId.equals(ref.get("pointId"))){
if(!excludeItemIdSet.contains(ref.get("itemId"))) {
RoutePointItem item = new RoutePointItem();
item.setPointInputItemId((Long) ref.get("id"));
item.setRoutePointId(rp.getId());
item.setPointClassifyId(ref.containsKey("classifyId")?Long.valueOf(ref.get("classifyId").toString()):null);
item.setOrderNo(orderNum[0]++);
item.setPointId(pointId);
item.setIsDelete(false);
items.add(item);
}
}
final int[] orderNum = {1};
pointRefItem.forEach(ref -> {
Long pointId = rt.getPointId();
if(pointId.equals(ref.get("pointId"))){
if(!excludeItemIdSet.contains(ref.get("itemId"))) {
RoutePointItem item = new RoutePointItem();
item.setPointInputItemId((Long) ref.get("id"));
item.setRoutePointId(rt.getId());
item.setPointClassifyId(ref.containsKey("classifyId")?Long.valueOf(ref.get("classifyId").toString()):null);
item.setOrderNo(orderNum[0]++);
item.setPointId(pointId);
item.setIsDelete(false);
items.add(item);
}
});
}
});
if(!items.isEmpty()) {
for (RoutePointItem routePointItem: items
) {
iRoutePointItemDao.saveAndFlush(routePointItem);
}
repositoryTs.batchSave(items);
}
}
}
......
......@@ -14,6 +14,7 @@ import com.yeejoin.amos.patrol.core.common.response.CommonPage;
import com.yeejoin.amos.patrol.core.common.response.GraphInitDataResponse;
import com.yeejoin.amos.patrol.core.common.response.QueryCriteriaRespone;
import com.yeejoin.amos.patrol.dao.entity.CheckShot;
import com.yeejoin.amos.patrol.dao.entity.PlanTask;
import com.yeejoin.amos.patrol.exception.YeeException;
import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional;
......@@ -36,7 +37,7 @@ public interface ICheckService {
void saveCheckImg(List<CheckShot> imgList);
CheckDto saveCheckRecord(CheckRecordParam requestParam, AgencyUserModel user, DepartmentBo departmentModel, Toke token);
CheckDto saveCheckRecordNew(CheckRecordParam requestParam);
CheckDto saveCheckRecordNew(CheckRecordParam requestParam, PlanTask planTask);
/**
* 巡检记录删除
*
......@@ -69,7 +70,7 @@ public interface ICheckService {
AppPointCheckRespone queryCheckPointDetail(String toke,String product,String appKey,long checkId);
AppPointCheckRespone queryCheckPointDetailInVersion2(String toke,String product,String appKey,long checkId);
AppPointCheckRespone queryCheckPointDetailInVersion2(String toke,String product,String appKey,long checkId,Long planTaskId, Long pointId);
AppPointCheckRespone queryCheckPointDetailInVersion2New(long checkId);
/**
......
package com.yeejoin.amos.patrol.config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
/**
* @author 瑾年
* @className ExecutorConfig
* @date 2020/8/26 10:31
*/
@Slf4j
@Configuration
@EnableAsync
public class ExecutorConfig {
/**
* 配置队列大小
* */
@Value("${executor.queueCapacity}")
private int queueCapacity;
/***
* 配置线程池中的线程的名称前缀
* */
@Value("${executor.namePrefix}")
private String namePrefix;
/**
* 线程池维护线程所允许的空闲时间
* */
@Value("${executor.keepAliveSeconds}")
private int keepAliveSeconds;
@Bean(name = "asyncServiceExecutor")
public Executor asyncServiceExecutor() {
log.info("初始化异步线程池");
//获取cpu核心数,最大线程数和核心线程数为cpu核心数的2倍
int curSystemThreads = Runtime.getRuntime().availableProcessors() * 2;
log.info("系统可用线程池个数:{}",curSystemThreads);
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
//配置核心线程数
executor.setCorePoolSize(curSystemThreads);
//配置最大线程数
executor.setMaxPoolSize(curSystemThreads);
//配置队列大小
executor.setQueueCapacity(queueCapacity);
//配置线程池中的线程的名称前缀
executor.setThreadNamePrefix(namePrefix);
//线程池维护线程所允许的空闲时间
executor.setKeepAliveSeconds(keepAliveSeconds);
// rejection-policy:当pool已经达到max size的时候,如何处理新任务
// CALLER_RUNS:不在新线程中执行任务,而是有调用者所在的线程来执行--拒绝策略
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
//执行初始化
executor.initialize();
//等待所有任务结束后再关闭线程池
executor.setWaitForTasksToCompleteOnShutdown(true);
return executor;
}
}
......@@ -19,8 +19,8 @@ public class LatentDanerScheduled {
* 每1分钟执行一次:查询逾期的隐患,修改状态
*/
@Scheduled(cron = "0 0/1 * * * ?")
public void updateDangerStateOfOvertime() {
iLatentDangerService.updateDangerStateOfOvertime();
}
// @Scheduled(cron = "0 0/1 * * * ?")
// public void updateDangerStateOfOvertime() {
// iLatentDangerService.updateDangerStateOfOvertime();
// }
}
\ No newline at end of file
......@@ -501,7 +501,7 @@
AND ptd.id = #{planTaskId} and pptd.status = #{planTaskDetailStatus}
) temp2 on(temp1.point_id = temp2.pointId
AND temp1.route_id = temp2.routeId)
GROUP BY pointName
</select>
<!-- 巡检执行情况统计分页用 -->
<select id="countChkExListData" resultType="long">
......
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