Commit 0942b466a2abda727def908f0b3c49fca3cec10b
1 parent
0474aeff
停线每日过程跟踪优化-配置的板块信息逻辑添加,安全履职检查异常数逻辑处理
Showing
14 changed files
with
421 additions
and
33 deletions
| @@ -58,6 +58,12 @@ | @@ -58,6 +58,12 @@ | ||
| 58 | <artifactId>mysql-connector-java</artifactId> | 58 | <artifactId>mysql-connector-java</artifactId> |
| 59 | <version>8.0.24</version> | 59 | <version>8.0.24</version> |
| 60 | </dependency> | 60 | </dependency> |
| 61 | + <!-- 人大金仓 KingbaseES JDBC 驱动 --> | ||
| 62 | + <dependency> | ||
| 63 | + <groupId>cn.com.kingbase</groupId> | ||
| 64 | + <artifactId>kingbase8</artifactId> | ||
| 65 | + <version>8.6.0</version> | ||
| 66 | + </dependency> | ||
| 61 | <dependency> | 67 | <dependency> |
| 62 | <groupId>com.alibaba</groupId> | 68 | <groupId>com.alibaba</groupId> |
| 63 | <artifactId>druid-spring-boot-starter</artifactId> | 69 | <artifactId>druid-spring-boot-starter</artifactId> |
| @@ -3,15 +3,18 @@ package com.qgutech.qgyun.apaas.sync.cpsipo.controller; | @@ -3,15 +3,18 @@ package com.qgutech.qgyun.apaas.sync.cpsipo.controller; | ||
| 3 | import com.qgutech.qgyun.apaas.sync.cpsipo.dto.SafetyObservationDailySummaryDTO; | 3 | import com.qgutech.qgyun.apaas.sync.cpsipo.dto.SafetyObservationDailySummaryDTO; |
| 4 | import com.qgutech.qgyun.apaas.sync.cpsipo.model.SafetyObservation; | 4 | import com.qgutech.qgyun.apaas.sync.cpsipo.model.SafetyObservation; |
| 5 | import com.qgutech.qgyun.apaas.sync.cpsipo.service.SafetyObservationService; | 5 | import com.qgutech.qgyun.apaas.sync.cpsipo.service.SafetyObservationService; |
| 6 | +import com.qgutech.qgyun.apaas.sync.utils.DateDealUtils; | ||
| 6 | import com.qgutech.qgyun.framework.common.result.JsonResult; | 7 | import com.qgutech.qgyun.framework.common.result.JsonResult; |
| 7 | import lombok.extern.slf4j.Slf4j; | 8 | import lombok.extern.slf4j.Slf4j; |
| 8 | import org.springframework.web.bind.annotation.GetMapping; | 9 | import org.springframework.web.bind.annotation.GetMapping; |
| 10 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 9 | import org.springframework.web.bind.annotation.RequestMapping; | 11 | import org.springframework.web.bind.annotation.RequestMapping; |
| 10 | import org.springframework.web.bind.annotation.RequestParam; | 12 | import org.springframework.web.bind.annotation.RequestParam; |
| 11 | import org.springframework.web.bind.annotation.RestController; | 13 | import org.springframework.web.bind.annotation.RestController; |
| 12 | 14 | ||
| 13 | import javax.annotation.Resource; | 15 | import javax.annotation.Resource; |
| 14 | import java.util.Calendar; | 16 | import java.util.Calendar; |
| 17 | +import java.util.Date; | ||
| 15 | import java.util.List; | 18 | import java.util.List; |
| 16 | 19 | ||
| 17 | /** | 20 | /** |
| @@ -74,4 +77,27 @@ public class SafetyObservationController { | @@ -74,4 +77,27 @@ public class SafetyObservationController { | ||
| 74 | List<SafetyObservation> list = safetyObservationService.listDetailByDate(qyxx, jcrq); | 77 | List<SafetyObservation> list = safetyObservationService.listDetailByDate(qyxx, jcrq); |
| 75 | return new JsonResult<>(true, "成功", list); | 78 | return new JsonResult<>(true, "成功", list); |
| 76 | } | 79 | } |
| 80 | + | ||
| 81 | + /** | ||
| 82 | + * 计算安全履职检查记录的异常数并回写。 | ||
| 83 | + * <p> | ||
| 84 | + * 获取检查日期在开始、结束时间范围内的记录,逐条统计所有检查项字段(枚举 正常/异常/不涉及)中 | ||
| 85 | + * 取值为异常(#2#)的字段个数作为异常数(exceptionNum)并更新,无异常项时置 0。 | ||
| 86 | + * 开始、结束时间没传时默认前 3 天(3 天前 00:00:00 ~ 昨天 23:59:59); | ||
| 87 | + * flag 没传(或传 false)时仅处理 exceptionNum 为空的记录,传 true 时处理范围内所有记录。 | ||
| 88 | + * | ||
| 89 | + * @param startTime 开始时间(yyyy-MM-dd 或 yyyy-MM-dd HH:mm:ss),可为空,默认 3 天前 | ||
| 90 | + * @param endTime 结束时间(yyyy-MM-dd 或 yyyy-MM-dd HH:mm:ss),可为空,默认昨天 | ||
| 91 | + * @param flag 处理范围标识:true-处理所有记录;false/空-仅处理 exceptionNum 为空的记录(默认) | ||
| 92 | + * @return 更新的记录数 | ||
| 93 | + */ | ||
| 94 | + @PostMapping("/calculate/exceptionNum") | ||
| 95 | + public JsonResult calculateExceptionNum(@RequestParam(required = false) String startTime, | ||
| 96 | + @RequestParam(required = false) String endTime, | ||
| 97 | + @RequestParam(required = false) Boolean flag) { | ||
| 98 | + Date start = DateDealUtils.parseStartTime(startTime); | ||
| 99 | + Date end = DateDealUtils.parseEndTime(endTime); | ||
| 100 | + int count = safetyObservationService.calculateExceptionNum(start, end, Boolean.TRUE.equals(flag)); | ||
| 101 | + return new JsonResult<>(true, "成功", count); | ||
| 102 | + } | ||
| 77 | } | 103 | } |
| @@ -100,7 +100,7 @@ public class StopRecordController { | @@ -100,7 +100,7 @@ public class StopRecordController { | ||
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | /** | 102 | /** |
| 103 | - * 按天汇总统计停线时长——其他板块(非物流/设备/质量) | 103 | + * 按天汇总统计停线时长——其他板块(非物流/设备/质量-获取配置的停线过程跟踪板块) |
| 104 | * | 104 | * |
| 105 | * @param xtxx 线体信息,可为空 | 105 | * @param xtxx 线体信息,可为空 |
| 106 | * @param bcxx 班次信息,可为空 | 106 | * @param bcxx 班次信息,可为空 |
| @@ -29,12 +29,12 @@ public class SafetyObservationDailySummaryDTO implements Serializable { | @@ -29,12 +29,12 @@ public class SafetyObservationDailySummaryDTO implements Serializable { | ||
| 29 | /* | 29 | /* |
| 30 | * 问题数(当日抽查结果为异常的记录条数) | 30 | * 问题数(当日抽查结果为异常的记录条数) |
| 31 | */ | 31 | */ |
| 32 | - private Integer wts; | 32 | + private Double wts; |
| 33 | 33 | ||
| 34 | public SafetyObservationDailySummaryDTO() { | 34 | public SafetyObservationDailySummaryDTO() { |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | - public SafetyObservationDailySummaryDTO(String date, Integer gws, Integer wts) { | 37 | + public SafetyObservationDailySummaryDTO(String date, Integer gws, Double wts) { |
| 38 | this.date = date; | 38 | this.date = date; |
| 39 | this.gws = gws; | 39 | this.gws = gws; |
| 40 | this.wts = wts; | 40 | this.wts = wts; |
src/main/java/com/qgutech/qgyun/apaas/sync/cpsipo/mapper/StopRecordDailyTrackingBkxxMapper.java
0 → 100644
| 1 | +package com.qgutech.qgyun.apaas.sync.cpsipo.mapper; | ||
| 2 | + | ||
| 3 | +import com.qgutech.qgyun.apaas.sync.cpsipo.model.StopRecordDailyTrackingBkxx; | ||
| 4 | +import com.qgutech.qgyun.framework.database.mybatis.registermapper.QguBaseMapper; | ||
| 5 | + | ||
| 6 | +public interface StopRecordDailyTrackingBkxxMapper extends QguBaseMapper<StopRecordDailyTrackingBkxx> { | ||
| 7 | +} |
| @@ -27,6 +27,7 @@ public class SafetyObservation extends BaseCorpModel { | @@ -27,6 +27,7 @@ public class SafetyObservation extends BaseCorpModel { | ||
| 27 | public static final String JCRQ = "jcrq"; | 27 | public static final String JCRQ = "jcrq"; |
| 28 | public static final String GCGW = "gcgw"; | 28 | public static final String GCGW = "gcgw"; |
| 29 | public static final String BGCR = "bgcr"; | 29 | public static final String BGCR = "bgcr"; |
| 30 | + public static final String EXCEPTION_NUM = "exceptionNum"; | ||
| 30 | 31 | ||
| 31 | /* | 32 | /* |
| 32 | * 区域信息 | 33 | * 区域信息 |
| @@ -61,6 +62,11 @@ public class SafetyObservation extends BaseCorpModel { | @@ -61,6 +62,11 @@ public class SafetyObservation extends BaseCorpModel { | ||
| 61 | private String ibpfgw; | 62 | private String ibpfgw; |
| 62 | 63 | ||
| 63 | /* | 64 | /* |
| 65 | + * 异常数 | ||
| 66 | + */ | ||
| 67 | + private Double exceptionNum; | ||
| 68 | + | ||
| 69 | + /* | ||
| 64 | * 是否其他 | 70 | * 是否其他 |
| 65 | */ | 71 | */ |
| 66 | private String ifqtio; | 72 | private String ifqtio; |
| 1 | +package com.qgutech.qgyun.apaas.sync.cpsipo.model; | ||
| 2 | + | ||
| 3 | +import com.qgutech.qgyun.framework.database.model.BaseCorpModel; | ||
| 4 | +import lombok.Getter; | ||
| 5 | +import lombok.Setter; | ||
| 6 | +import lombok.ToString; | ||
| 7 | + | ||
| 8 | +import javax.persistence.Table; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 停线过程跟踪板块配置记录 | ||
| 12 | + */ | ||
| 13 | +@Getter | ||
| 14 | +@Setter | ||
| 15 | +@ToString | ||
| 16 | +@Table(name = "t_auto_hfca_zlujkl_tpivim") | ||
| 17 | +public class StopRecordDailyTrackingBkxx extends BaseCorpModel { | ||
| 18 | + | ||
| 19 | + /* | ||
| 20 | + * 板块信息 | ||
| 21 | + */ | ||
| 22 | + private String bkxx; | ||
| 23 | +} |
| @@ -19,6 +19,7 @@ import com.qgutech.qgyun.apaas.sync.utils.CorpExample; | @@ -19,6 +19,7 @@ import com.qgutech.qgyun.apaas.sync.utils.CorpExample; | ||
| 19 | import com.qgutech.qgyun.apaas.sync.utils.DateDealUtils; | 19 | import com.qgutech.qgyun.apaas.sync.utils.DateDealUtils; |
| 20 | import org.apache.commons.collections4.CollectionUtils; | 20 | import org.apache.commons.collections4.CollectionUtils; |
| 21 | import org.apache.commons.lang3.StringUtils; | 21 | import org.apache.commons.lang3.StringUtils; |
| 22 | +import lombok.extern.slf4j.Slf4j; | ||
| 22 | import org.springframework.stereotype.Service; | 23 | import org.springframework.stereotype.Service; |
| 23 | import org.springframework.transaction.annotation.Transactional; | 24 | import org.springframework.transaction.annotation.Transactional; |
| 24 | import org.springframework.util.Assert; | 25 | import org.springframework.util.Assert; |
| @@ -32,6 +33,7 @@ import java.util.stream.Collectors; | @@ -32,6 +33,7 @@ import java.util.stream.Collectors; | ||
| 32 | /** | 33 | /** |
| 33 | * SafetyObservation 服务 | 34 | * SafetyObservation 服务 |
| 34 | */ | 35 | */ |
| 36 | +@Slf4j | ||
| 35 | @Service | 37 | @Service |
| 36 | public class SafetyObservationService extends BaseServiceImpl<SafetyObservation> { | 38 | public class SafetyObservationService extends BaseServiceImpl<SafetyObservation> { |
| 37 | 39 | ||
| @@ -149,15 +151,14 @@ public class SafetyObservationService extends BaseServiceImpl<SafetyObservation> | @@ -149,15 +151,14 @@ public class SafetyObservationService extends BaseServiceImpl<SafetyObservation> | ||
| 149 | List<SafetyObservation> dayList = dailyGroup.get(dateKey); | 151 | List<SafetyObservation> dayList = dailyGroup.get(dateKey); |
| 150 | if (CollectionUtils.isEmpty(dayList)) { | 152 | if (CollectionUtils.isEmpty(dayList)) { |
| 151 | // 无记录时补一条工位数和问题数都为0的记录 | 153 | // 无记录时补一条工位数和问题数都为0的记录 |
| 152 | - result.add(new SafetyObservationDailySummaryDTO(dateKey, 0, 0)); | 154 | + result.add(new SafetyObservationDailySummaryDTO(dateKey, 0, 0.0)); |
| 153 | continue; | 155 | continue; |
| 154 | } | 156 | } |
| 155 | // 走访工位数:当日明细记录条数 | 157 | // 走访工位数:当日明细记录条数 |
| 156 | int gws = dayList.size(); | 158 | int gws = dayList.size(); |
| 157 | - // 问题数:当日抽查结果为异常的记录条数 | ||
| 158 | - int wts = (int) dayList.stream() | ||
| 159 | - .filter(item -> CheckResultEnum.YICHANG == CheckResultEnum.fromCode(item.getCcjg())) | ||
| 160 | - .count(); | 159 | + // 问题数:直接取异常数字段汇总 |
| 160 | + Double wts = dayList.stream().mapToDouble(item -> item.getExceptionNum()).sum(); | ||
| 161 | + | ||
| 161 | result.add(new SafetyObservationDailySummaryDTO(dateKey, gws, wts)); | 162 | result.add(new SafetyObservationDailySummaryDTO(dateKey, gws, wts)); |
| 162 | } | 163 | } |
| 163 | 164 | ||
| @@ -197,6 +198,98 @@ public class SafetyObservationService extends BaseServiceImpl<SafetyObservation> | @@ -197,6 +198,98 @@ public class SafetyObservationService extends BaseServiceImpl<SafetyObservation> | ||
| 197 | } | 198 | } |
| 198 | 199 | ||
| 199 | /** | 200 | /** |
| 201 | + * 计算当前时间前 3 天内、异常数(exceptionNum)为空的安全履职检查记录的异常数并回写。 | ||
| 202 | + * <p> | ||
| 203 | + * 供每天凌晨 3 点定时任务调用,等同于 {@code calculateExceptionNum(null, null, false)}。 | ||
| 204 | + * | ||
| 205 | + * @return 更新的记录数 | ||
| 206 | + */ | ||
| 207 | + @Transactional | ||
| 208 | + public int calculateExceptionNumForLastThreeDays() { | ||
| 209 | + return calculateExceptionNum(null, null, false); | ||
| 210 | + } | ||
| 211 | + | ||
| 212 | + /** | ||
| 213 | + * 计算指定时间范围内安全履职检查记录的异常数并回写。 | ||
| 214 | + * <p> | ||
| 215 | + * 统计口径:记录中所有枚举值为 正常/异常/不涉及({@link CheckResultEnum})的检查项字段, | ||
| 216 | + * 取值为 异常(#2#)的字段个数作为 exceptionNum;无异常项时置 0。 | ||
| 217 | + * <p> | ||
| 218 | + * start 为空时默认 3 天前 00:00:00,end 为空时默认昨天 23:59:59(即默认前 3 个完整自然日); | ||
| 219 | + * processAll 为 true 时处理范围内所有记录,为 false 时仅处理 exceptionNum 为空的记录。 | ||
| 220 | + * | ||
| 221 | + * @param start 检查日期范围-开始,可为空,默认 3 天前 00:00:00 | ||
| 222 | + * @param end 检查日期范围-结束,可为空,默认昨天 23:59:59 | ||
| 223 | + * @param processAll 是否处理所有记录:true-处理范围内所有记录;false-仅处理 exceptionNum 为空的记录 | ||
| 224 | + * @return 更新的记录数 | ||
| 225 | + */ | ||
| 226 | + @Transactional | ||
| 227 | + public int calculateExceptionNum(Date start, Date end, boolean processAll) { | ||
| 228 | + // 1. 默认前 3 天的时间范围(3 天前 00:00:00 ~ 昨天 23:59:59,共 3 个完整自然日) | ||
| 229 | + if (start == null) { | ||
| 230 | + Calendar cal = Calendar.getInstance(); | ||
| 231 | + cal.add(Calendar.DAY_OF_MONTH, -3); | ||
| 232 | + cal.set(Calendar.HOUR_OF_DAY, 0); | ||
| 233 | + cal.set(Calendar.MINUTE, 0); | ||
| 234 | + cal.set(Calendar.SECOND, 0); | ||
| 235 | + cal.set(Calendar.MILLISECOND, 0); | ||
| 236 | + start = cal.getTime(); | ||
| 237 | + } | ||
| 238 | + if (end == null) { | ||
| 239 | + end = DateDealUtils.getYesterdayEndTime(); | ||
| 240 | + } | ||
| 241 | + | ||
| 242 | + // 2. 查询检查日期在范围内的记录(processAll 为 false 时仅取异常数为空的记录) | ||
| 243 | + Example example = new Example(entityClass); | ||
| 244 | + Example.Criteria criteria = CorpExample.criteria(example) | ||
| 245 | + .andBetween(SafetyObservation.JCRQ, start, end); | ||
| 246 | + if (!processAll) { | ||
| 247 | + criteria.andIsNull(SafetyObservation.EXCEPTION_NUM); | ||
| 248 | + } | ||
| 249 | + List<SafetyObservation> list = safetyObservationMapper.selectByExample(example); | ||
| 250 | + if (CollectionUtils.isEmpty(list)) { | ||
| 251 | + log.info("计算安全履职检查记录异常数完成,无满足条件的记录"); | ||
| 252 | + return 0; | ||
| 253 | + } | ||
| 254 | + | ||
| 255 | + // 3. 逐条统计异常字段数并回写 | ||
| 256 | + for (SafetyObservation record : list) { | ||
| 257 | + record.setExceptionNum((double) countExceptionFields(record)); | ||
| 258 | + safetyObservationMapper.updateByPrimaryKeySelective(record); | ||
| 259 | + } | ||
| 260 | + return list.size(); | ||
| 261 | + } | ||
| 262 | + | ||
| 263 | + /** | ||
| 264 | + * 统计安全履职检查记录中所有检查项字段(枚举 正常/异常/不涉及)取值为 异常(#2#)的字段个数。 | ||
| 265 | + * | ||
| 266 | + * @param record 安全履职检查记录 | ||
| 267 | + * @return 异常字段个数 | ||
| 268 | + */ | ||
| 269 | + private int countExceptionFields(SafetyObservation record) { | ||
| 270 | + String[] checkFields = { | ||
| 271 | + record.getRyfxgczhwtzxw(), record.getMytzlbyp(), record.getMygbgzzt(), record.getMytzgz(), | ||
| 272 | + record.getMyjsyx(), record.getLbypzqpd(), record.getTbxx(), record.getYbjl(), | ||
| 273 | + record.getEbxx(), record.getHxxt(), record.getGbhs(), record.getSq(), | ||
| 274 | + record.getTbjj(), record.getFhczgc(), record.getZqsy(), record.getGjwkwps(), | ||
| 275 | + record.getGjgzzklh(), record.getSbzcyx(), record.getZyhjzklh(), record.getZmgxlh(), | ||
| 276 | + record.getClbfzq(), record.getTflh(), record.getDmzj(), record.getWptfx(), | ||
| 277 | + record.getLbdkyfh(), record.getAqtdct(), record.getWzfxkk(), record.getBzfxkk(), | ||
| 278 | + record.getJzjyfxkk(), record.getDdhbdfxkk(), record.getGcdlfxkk(), record.getJdwdfxkk(), | ||
| 279 | + record.getCdfxkk(), record.getYhwzfxkk(), record.getXryhwzfxkk(), record.getZybz(), | ||
| 280 | + record.getZyzdwj(), record.getZyzdwjkczx(), record.getZyzdwjzy(), record.getAecplyqgsp(), | ||
| 281 | + record.getZsfbzyzxyq(), record.getZswxzyzxyq(), record.getCcjg() | ||
| 282 | + }; | ||
| 283 | + int count = 0; | ||
| 284 | + for (String value : checkFields) { | ||
| 285 | + if (CheckResultEnum.YICHANG.getCode().equals(value)) { | ||
| 286 | + count++; | ||
| 287 | + } | ||
| 288 | + } | ||
| 289 | + return count; | ||
| 290 | + } | ||
| 291 | + | ||
| 292 | + /** | ||
| 200 | * 批量补全安全履职检查明细关联的区域、班组、观察工位名称与编号,以及被观察人(组织用户)姓名。 | 293 | * 批量补全安全履职检查明细关联的区域、班组、观察工位名称与编号,以及被观察人(组织用户)姓名。 |
| 201 | */ | 294 | */ |
| 202 | private void fillRelatedInfo(List<SafetyObservation> list) { | 295 | private void fillRelatedInfo(List<SafetyObservation> list) { |
src/main/java/com/qgutech/qgyun/apaas/sync/cpsipo/service/StopRecordDailyTrackingBkxxService.java
0 → 100644
| 1 | +package com.qgutech.qgyun.apaas.sync.cpsipo.service; | ||
| 2 | + | ||
| 3 | +import com.qgutech.qgyun.apaas.sync.cpsipo.mapper.StopRecordDailyTrackingBkxxMapper; | ||
| 4 | +import com.qgutech.qgyun.apaas.sync.cpsipo.model.StopRecord; | ||
| 5 | +import com.qgutech.qgyun.apaas.sync.cpsipo.model.StopRecordDailyTrackingBkxx; | ||
| 6 | +import com.qgutech.qgyun.apaas.sync.utils.CorpExample; | ||
| 7 | +import com.qgutech.qgyun.framework.database.mybatis.service.BaseServiceImpl; | ||
| 8 | +import org.springframework.stereotype.Service; | ||
| 9 | +import org.springframework.transaction.annotation.Transactional; | ||
| 10 | +import tk.mybatis.mapper.entity.Example; | ||
| 11 | + | ||
| 12 | +import javax.annotation.Resource; | ||
| 13 | +import java.util.List; | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * StopRecordDailyTrackingBkxx 服务 | ||
| 17 | + */ | ||
| 18 | +@Service | ||
| 19 | +public class StopRecordDailyTrackingBkxxService extends BaseServiceImpl<StopRecordDailyTrackingBkxx> { | ||
| 20 | + | ||
| 21 | + @Resource | ||
| 22 | + private StopRecordDailyTrackingBkxxMapper stopRecordDailyTrackingBkxxMapper; | ||
| 23 | + | ||
| 24 | + @Transactional(readOnly = true) | ||
| 25 | + public List<StopRecordDailyTrackingBkxx> listAll() { | ||
| 26 | + | ||
| 27 | + Example example = CorpExample.ofCorp(entityClass); | ||
| 28 | + return stopRecordDailyTrackingBkxxMapper.selectByExample(example); | ||
| 29 | + } | ||
| 30 | +} |
| @@ -16,6 +16,7 @@ import com.qgutech.qgyun.apaas.sync.cps.model.Area; | @@ -16,6 +16,7 @@ import com.qgutech.qgyun.apaas.sync.cps.model.Area; | ||
| 16 | import com.qgutech.qgyun.apaas.sync.cpsfzzk.model.BlockInfo; | 16 | import com.qgutech.qgyun.apaas.sync.cpsfzzk.model.BlockInfo; |
| 17 | import com.qgutech.qgyun.apaas.sync.cps.model.Shift; | 17 | import com.qgutech.qgyun.apaas.sync.cps.model.Shift; |
| 18 | import com.qgutech.qgyun.apaas.sync.cpsipo.model.StopRecord; | 18 | import com.qgutech.qgyun.apaas.sync.cpsipo.model.StopRecord; |
| 19 | +import com.qgutech.qgyun.apaas.sync.cpsipo.model.StopRecordDailyTrackingBkxx; | ||
| 19 | import com.qgutech.qgyun.apaas.sync.cpsipo.model.StopWorkstation; | 20 | import com.qgutech.qgyun.apaas.sync.cpsipo.model.StopWorkstation; |
| 20 | import com.qgutech.qgyun.apaas.sync.cps.model.Team; | 21 | import com.qgutech.qgyun.apaas.sync.cps.model.Team; |
| 21 | import com.qgutech.qgyun.apaas.sync.cps.model.XtLine; | 22 | import com.qgutech.qgyun.apaas.sync.cps.model.XtLine; |
| @@ -68,6 +69,9 @@ public class StopRecordService extends BaseServiceImpl<StopRecord> { | @@ -68,6 +69,9 @@ public class StopRecordService extends BaseServiceImpl<StopRecord> { | ||
| 68 | @Resource | 69 | @Resource |
| 69 | private AreaStopMonthTargetService areaStopMonthTargetService; | 70 | private AreaStopMonthTargetService areaStopMonthTargetService; |
| 70 | 71 | ||
| 72 | + @Resource | ||
| 73 | + private StopRecordDailyTrackingBkxxService stopRecordDailyTrackingBkxxService; | ||
| 74 | + | ||
| 71 | @Transactional(readOnly = true) | 75 | @Transactional(readOnly = true) |
| 72 | public StopRecord getById(String id) { | 76 | public StopRecord getById(String id) { |
| 73 | Assert.hasLength(id, "id is empty!"); | 77 | Assert.hasLength(id, "id is empty!"); |
| @@ -373,11 +377,15 @@ public class StopRecordService extends BaseServiceImpl<StopRecord> { | @@ -373,11 +377,15 @@ public class StopRecordService extends BaseServiceImpl<StopRecord> { | ||
| 373 | 377 | ||
| 374 | List<AreaStopMonthTarget> targetList; | 378 | List<AreaStopMonthTarget> targetList; |
| 375 | if (BLOCK_OTHER.equals(blockCode)) { | 379 | if (BLOCK_OTHER.equals(blockCode)) { |
| 376 | - // 其他板块:查询区域目标记录后排除物流/设备/质量三大板块的记录 | ||
| 377 | - Set<String> specialIds = resolveSpecialBlockIds(); | 380 | + // 其他板块:以停线过程跟踪板块配置的所有板块信息 Id 作为查询条件,仅保留匹配的月度目标记录 |
| 381 | + Set<String> otherBlockIds = resolveOtherBlockIds(); | ||
| 382 | + if (otherBlockIds.isEmpty()) { | ||
| 383 | + // 未配置任何其他板块,无对应目标 | ||
| 384 | + return null; | ||
| 385 | + } | ||
| 378 | targetList = areaStopMonthTargetService.listByQyxxAndBkxxAndYearAndMonth(txqyxx, null, year, month) | 386 | targetList = areaStopMonthTargetService.listByQyxxAndBkxxAndYearAndMonth(txqyxx, null, year, month) |
| 379 | .stream() | 387 | .stream() |
| 380 | - .filter(item -> !specialIds.contains(item.getBkxx())) | 388 | + .filter(item -> otherBlockIds.contains(item.getBkxx())) |
| 381 | .collect(Collectors.toList()); | 389 | .collect(Collectors.toList()); |
| 382 | } else { | 390 | } else { |
| 383 | BlockInfo block = blockInfoService.getByBm(blockCode); | 391 | BlockInfo block = blockInfoService.getByBm(blockCode); |
| @@ -399,7 +407,8 @@ public class StopRecordService extends BaseServiceImpl<StopRecord> { | @@ -399,7 +407,8 @@ public class StopRecordService extends BaseServiceImpl<StopRecord> { | ||
| 399 | * 根据板块编码及查询条件筛选停线记录 | 407 | * 根据板块编码及查询条件筛选停线记录 |
| 400 | * <p> | 408 | * <p> |
| 401 | * 板块编码为 W/M/Q 时,先根据编码定位板块信息 Id,再按 txbkxx 等值过滤; | 409 | * 板块编码为 W/M/Q 时,先根据编码定位板块信息 Id,再按 txbkxx 等值过滤; |
| 402 | - * 板块编码为 {@link #BLOCK_OTHER} 时,过滤掉属于物流/设备/质量三者的记录(含板块为空的记录)。 | 410 | + * 板块编码为 {@link #BLOCK_OTHER} 时,以停线过程跟踪板块配置({@link StopRecordDailyTrackingBkxx}) |
| 411 | + * 所有记录的板块信息 Id 作为查询条件,仅保留 txbkxx 命中该集合的记录。 | ||
| 403 | * | 412 | * |
| 404 | * @param blockCode 板块编码(W/M/Q)或 {@link #BLOCK_OTHER} | 413 | * @param blockCode 板块编码(W/M/Q)或 {@link #BLOCK_OTHER} |
| 405 | * @param xtxx 线体信息,可为空 | 414 | * @param xtxx 线体信息,可为空 |
| @@ -413,13 +422,15 @@ public class StopRecordService extends BaseServiceImpl<StopRecord> { | @@ -413,13 +422,15 @@ public class StopRecordService extends BaseServiceImpl<StopRecord> { | ||
| 413 | private List<StopRecord> listByBlock(String blockCode, String xtxx, String bcxx, String txqyxx, | 422 | private List<StopRecord> listByBlock(String blockCode, String xtxx, String bcxx, String txqyxx, |
| 414 | String txgwxx, Date start, Date end) { | 423 | String txgwxx, Date start, Date end) { |
| 415 | if (BLOCK_OTHER.equals(blockCode)) { | 424 | if (BLOCK_OTHER.equals(blockCode)) { |
| 416 | - List<StopRecord> all = listByCondition(xtxx, bcxx, txqyxx, null, txgwxx, start, end); | ||
| 417 | - Set<String> specialIds = resolveSpecialBlockIds(); | ||
| 418 | - if (specialIds.isEmpty()) { | ||
| 419 | - return all; | 425 | + // 其他板块:以停线过程跟踪板块配置的所有板块信息 Id 作为查询条件 |
| 426 | + Set<String> otherBlockIds = resolveOtherBlockIds(); | ||
| 427 | + if (otherBlockIds.isEmpty()) { | ||
| 428 | + // 未配置任何其他板块,视为无数据 | ||
| 429 | + return new ArrayList<>(0); | ||
| 420 | } | 430 | } |
| 431 | + List<StopRecord> all = listByCondition(xtxx, bcxx, txqyxx, null, txgwxx, start, end); | ||
| 421 | return all.stream() | 432 | return all.stream() |
| 422 | - .filter(item -> !specialIds.contains(item.getTxbkxx())) | 433 | + .filter(item -> otherBlockIds.contains(item.getTxbkxx())) |
| 423 | .collect(Collectors.toList()); | 434 | .collect(Collectors.toList()); |
| 424 | } | 435 | } |
| 425 | 436 | ||
| @@ -432,20 +443,20 @@ public class StopRecordService extends BaseServiceImpl<StopRecord> { | @@ -432,20 +443,20 @@ public class StopRecordService extends BaseServiceImpl<StopRecord> { | ||
| 432 | } | 443 | } |
| 433 | 444 | ||
| 434 | /** | 445 | /** |
| 435 | - * 获取物流/设备/质量三大板块的信息 Id 集合(未配置的板块自动忽略) | 446 | + * 获取停线过程跟踪板块配置({@link StopRecordDailyTrackingBkxx})中所有记录的板块信息 Id 集合, |
| 447 | + * 作为“其他板块”的查询条件 | ||
| 436 | * | 448 | * |
| 437 | - * @return 板块 Id 集合 | 449 | + * @return 板块信息 Id 集合,未配置时返回空集合 |
| 438 | */ | 450 | */ |
| 439 | - private Set<String> resolveSpecialBlockIds() { | ||
| 440 | - Set<String> ids = new HashSet<>(); | ||
| 441 | - for (String bm : new String[]{Constant.BLOCK_CODE_LOGISTICS, | ||
| 442 | - Constant.BLOCK_CODE_EQUIPMENT, Constant.BLOCK_CODE_QUALITY}) { | ||
| 443 | - BlockInfo block = blockInfoService.getByBm(bm); | ||
| 444 | - if (block != null) { | ||
| 445 | - ids.add(block.getId()); | ||
| 446 | - } | 451 | + private Set<String> resolveOtherBlockIds() { |
| 452 | + List<StopRecordDailyTrackingBkxx> configList = stopRecordDailyTrackingBkxxService.listAll(); | ||
| 453 | + if (CollectionUtils.isEmpty(configList)) { | ||
| 454 | + return new HashSet<>(0); | ||
| 447 | } | 455 | } |
| 448 | - return ids; | 456 | + return configList.stream() |
| 457 | + .map(StopRecordDailyTrackingBkxx::getBkxx) | ||
| 458 | + .filter(StringUtils::isNotBlank) | ||
| 459 | + .collect(Collectors.toSet()); | ||
| 449 | } | 460 | } |
| 450 | 461 | ||
| 451 | /** | 462 | /** |
| 1 | +package com.qgutech.qgyun.apaas.sync.cpsipo.task; | ||
| 2 | + | ||
| 3 | +import com.qgutech.qgyun.apaas.sync.cpsipo.service.SafetyObservationService; | ||
| 4 | +import lombok.extern.slf4j.Slf4j; | ||
| 5 | +import org.springframework.scheduling.annotation.Scheduled; | ||
| 6 | +import org.springframework.stereotype.Service; | ||
| 7 | + | ||
| 8 | +import javax.annotation.Resource; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * @author cq | ||
| 12 | + * @since 2026-11-06 | ||
| 13 | + * Ipo看板相关定制业务定时任务 | ||
| 14 | + */ | ||
| 15 | +@Slf4j | ||
| 16 | +@Service | ||
| 17 | +public class IpoScheduledTask { | ||
| 18 | + | ||
| 19 | + @Resource | ||
| 20 | + private SafetyObservationService safetyObservationService; | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * 计算安全履职检查记录的异常数 | ||
| 24 | + * 定时任务执行-每天凌晨3点执行 | ||
| 25 | + */ | ||
| 26 | + @Scheduled(cron = "0 0 3 * * ?") | ||
| 27 | + public void autoCalculateSafetyObservationExceptionNum() { | ||
| 28 | + try { | ||
| 29 | + int count = safetyObservationService.calculateExceptionNumForLastThreeDays(); | ||
| 30 | + log.info("定时任务[计算安全履职检查记录的异常数]执行完成,更新 {} 条", count); | ||
| 31 | + } catch (Exception e) { | ||
| 32 | + e.printStackTrace(); | ||
| 33 | + log.error("定时任务[计算安全履职检查记录的异常数]执行异常", e); | ||
| 34 | + } | ||
| 35 | + } | ||
| 36 | +} |
src/main/resources/application-prod.yml
0 → 100644
| 1 | +server: | ||
| 2 | + port: 8003 | ||
| 3 | + | ||
| 4 | +spring: | ||
| 5 | + application: | ||
| 6 | + name: qx-apaas-sync | ||
| 7 | + thymeleaf: | ||
| 8 | + cache: false | ||
| 9 | + prefix: classpath:/templates/ | ||
| 10 | + suffix: .html | ||
| 11 | + mode: HTML | ||
| 12 | + encoding: UTF-8 | ||
| 13 | + datasource: | ||
| 14 | + url: jdbc:kingbase8://10.9.0.110:54321/kingbase?currentSchema=qixiao-apaas | ||
| 15 | + username: root | ||
| 16 | + password: Kingbase@2026.com | ||
| 17 | + type: com.alibaba.druid.pool.DruidDataSource | ||
| 18 | + driver-class-name: com.kingbase8.Driver | ||
| 19 | + initialSize: 5 | ||
| 20 | + minIdle: 5 | ||
| 21 | + maxActive: 20 | ||
| 22 | + maxWait: 60000 | ||
| 23 | + filters: stat,log4j | ||
| 24 | + useGlobalDataSourceStat: true | ||
| 25 | + | ||
| 26 | +mybatis: | ||
| 27 | + type-aliases-package: com.qgutech.qgyun.apaas.sync.cps.model | ||
| 28 | + handler: | ||
| 29 | + enable: true | ||
| 30 | + rootPath: com/qgutech | ||
| 31 | + locationPattern: /**/cenum | ||
| 32 | +mapper: | ||
| 33 | + enumAsSimpleType: true | ||
| 34 | + | ||
| 35 | +busi.base: | ||
| 36 | + cropCode: hfca | ||
| 37 | + createBy: admin | ||
| 38 | + superAdminId: admin | ||
| 39 | + | ||
| 40 | +qx-apaas-sync: | ||
| 41 | + env: dev | ||
| 42 | + | ||
| 43 | +logging: | ||
| 44 | + path: ./logs | ||
| 45 | + level: | ||
| 46 | + com.qgutech.qgyun.apaas.sync: INFO | ||
| 47 | + | ||
| 48 | +# 简道云 -> 启效 同步 | ||
| 49 | +jdy-sync: | ||
| 50 | + enabled: false # true=启用每日定时任务;false=仅通过 REST 接口手动触发 | ||
| 51 | + cron: "0 0 2 * * ?" # 每天 02:00 | ||
| 52 | + # 简道云基础地址:独立域名/独享版用 https://<域名>/api(长安: https://jdy.changan.com.cn/api);公有云用 https://api.jiandaoyun.com/api | ||
| 53 | + host: https://jdy.changan.com.cn/api | ||
| 54 | + qx: | ||
| 55 | + base-url: https://dev3.qgutech.com # 启效3.0 环境地址 | ||
| 56 | + username: 15077901670 | ||
| 57 | + password: "000000" | ||
| 58 | + corp-code: default | ||
| 59 | + apps: | ||
| 60 | + - name: 合肥长安_技术处 # 简道云应用名 | ||
| 61 | + app-id: 65fd5c0e0d1f1a7ae4f038ec # 简道云 app_id(今日实测) | ||
| 62 | + api-key: lOnr4ms8jfc0gbCwVYS7YtbYQXjBFq979Cc06BcC866427b2a7aAd054598Bc7bB | ||
| 63 | + entry-ids: # 仅同步这些表单 entry_id(实测可访问) | ||
| 64 | + - 696f1754f141344a6b794f9c | ||
| 65 | + qx-app-id: # 目标启效应用id(不填则按 name 自动创建;已存在同名应用会直接复用) | ||
| 66 | + replace: true # 是=每天清空目标表单后重建镜像;否=追加 | ||
| 67 | + # field-mapping: {姓名: name, 姓名: name} # 可选,覆盖内置字典 | ||
| 68 | + # form-names: [人员管理, 部门管理] # 可选,仅同步这些表单 | ||
| 69 | + |
src/main/resources/application-test.yml
0 → 100644
| 1 | +server: | ||
| 2 | + port: 8003 | ||
| 3 | + | ||
| 4 | +spring: | ||
| 5 | + application: | ||
| 6 | + name: qx-apaas-sync | ||
| 7 | + thymeleaf: | ||
| 8 | + cache: false | ||
| 9 | + prefix: classpath:/templates/ | ||
| 10 | + suffix: .html | ||
| 11 | + mode: HTML | ||
| 12 | + encoding: UTF-8 | ||
| 13 | + datasource: | ||
| 14 | + url: jdbc:kingbase8://10.9.0.110:54321/kingbase?currentSchema=qixiao-apaas | ||
| 15 | + username: root | ||
| 16 | + password: Kingbase@2026.com | ||
| 17 | + type: com.alibaba.druid.pool.DruidDataSource | ||
| 18 | + driver-class-name: com.kingbase8.Driver | ||
| 19 | + initialSize: 5 | ||
| 20 | + minIdle: 5 | ||
| 21 | + maxActive: 20 | ||
| 22 | + maxWait: 60000 | ||
| 23 | + filters: stat,log4j | ||
| 24 | + useGlobalDataSourceStat: true | ||
| 25 | + | ||
| 26 | +mybatis: | ||
| 27 | + type-aliases-package: com.qgutech.qgyun.apaas.sync.cps.model | ||
| 28 | + handler: | ||
| 29 | + enable: true | ||
| 30 | + rootPath: com/qgutech | ||
| 31 | + locationPattern: /**/cenum | ||
| 32 | +mapper: | ||
| 33 | + enumAsSimpleType: true | ||
| 34 | + | ||
| 35 | +busi.base: | ||
| 36 | + cropCode: hfca | ||
| 37 | + createBy: admin | ||
| 38 | + superAdminId: admin | ||
| 39 | + | ||
| 40 | +qx-apaas-sync: | ||
| 41 | + env: dev | ||
| 42 | + | ||
| 43 | +logging: | ||
| 44 | + path: ./logs | ||
| 45 | + level: | ||
| 46 | + com.qgutech.qgyun.apaas.sync: INFO | ||
| 47 | + | ||
| 48 | +# 简道云 -> 启效 同步 | ||
| 49 | +jdy-sync: | ||
| 50 | + enabled: false # true=启用每日定时任务;false=仅通过 REST 接口手动触发 | ||
| 51 | + cron: "0 0 2 * * ?" # 每天 02:00 | ||
| 52 | + # 简道云基础地址:独立域名/独享版用 https://<域名>/api(长安: https://jdy.changan.com.cn/api);公有云用 https://api.jiandaoyun.com/api | ||
| 53 | + host: https://jdy.changan.com.cn/api | ||
| 54 | + qx: | ||
| 55 | + base-url: https://dev3.qgutech.com # 启效3.0 环境地址 | ||
| 56 | + username: 15077901670 | ||
| 57 | + password: "000000" | ||
| 58 | + corp-code: default | ||
| 59 | + apps: | ||
| 60 | + - name: 合肥长安_技术处 # 简道云应用名 | ||
| 61 | + app-id: 65fd5c0e0d1f1a7ae4f038ec # 简道云 app_id(今日实测) | ||
| 62 | + api-key: lOnr4ms8jfc0gbCwVYS7YtbYQXjBFq979Cc06BcC866427b2a7aAd054598Bc7bB | ||
| 63 | + entry-ids: # 仅同步这些表单 entry_id(实测可访问) | ||
| 64 | + - 696f1754f141344a6b794f9c | ||
| 65 | + qx-app-id: # 目标启效应用id(不填则按 name 自动创建;已存在同名应用会直接复用) | ||
| 66 | + replace: true # 是=每天清空目标表单后重建镜像;否=追加 | ||
| 67 | + # field-mapping: {姓名: name, 姓名: name} # 可选,覆盖内置字典 | ||
| 68 | + # form-names: [人员管理, 部门管理] # 可选,仅同步这些表单 | ||
| 69 | + |
| @@ -10,17 +10,29 @@ spring: | @@ -10,17 +10,29 @@ spring: | ||
| 10 | suffix: .html | 10 | suffix: .html |
| 11 | mode: HTML | 11 | mode: HTML |
| 12 | encoding: UTF-8 | 12 | encoding: UTF-8 |
| 13 | +# datasource: | ||
| 14 | +# url: jdbc:mysql://10.9.0.128:3306/qixiao-apaas?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8 | ||
| 15 | +# username: guohao | ||
| 16 | +# password: Guohao@2026.com | ||
| 17 | +# type: com.alibaba.druid.pool.DruidDataSource | ||
| 18 | +# driver-class-name: com.mysql.jdbc.Driver | ||
| 19 | +# initialSize: 5 | ||
| 20 | +# minIdle: 5 | ||
| 21 | +# maxActive: 20 | ||
| 22 | +# maxWait: 60000 | ||
| 23 | +# filters: stat,wall,log4j | ||
| 24 | +# useGlobalDataSourceStat: true | ||
| 13 | datasource: | 25 | datasource: |
| 14 | - url: jdbc:mysql://10.9.0.128:3306/qixiao-apaas?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8 | ||
| 15 | - username: guohao | ||
| 16 | - password: Guohao@2026.com | 26 | + url: jdbc:kingbase8://10.9.0.110:54321/kingbase?currentSchema=qixiao-apaas |
| 27 | + username: root | ||
| 28 | + password: Kingbase@2026.com | ||
| 17 | type: com.alibaba.druid.pool.DruidDataSource | 29 | type: com.alibaba.druid.pool.DruidDataSource |
| 18 | - driver-class-name: com.mysql.jdbc.Driver | 30 | + driver-class-name: com.kingbase8.Driver |
| 19 | initialSize: 5 | 31 | initialSize: 5 |
| 20 | minIdle: 5 | 32 | minIdle: 5 |
| 21 | maxActive: 20 | 33 | maxActive: 20 |
| 22 | maxWait: 60000 | 34 | maxWait: 60000 |
| 23 | - filters: stat,wall,log4j | 35 | + filters: stat,log4j |
| 24 | useGlobalDataSourceStat: true | 36 | useGlobalDataSourceStat: true |
| 25 | 37 | ||
| 26 | mybatis: | 38 | mybatis: |