Merge remote-tracking branch 'origin/master'

This commit is contained in:
NewName
2026-03-23 19:05:00 +08:00
14 changed files with 828 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
package com.lideeyunji.core.framework.enhance.example.report.bygl;
import com.lideeyunji.core.framework.config.aspect.enhance.model.EnhanceContext;
import com.lideeyunji.core.framework.config.aspect.enhance.plugin.AroundAdvicePlugin;
import com.lideeyunji.core.framework.mapper.ByglByjhMapper;
import com.lideeyunji.core.framework.utils.Func;
import com.lideeyunji.tool.framework.common.constant.ByglConstant;
import com.lideeyunji.tool.framework.yunji.utils.lideeYunJiUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Map;
/**
* 保养管理-保养方案
*/
@Slf4j
@Component("byglByfaPlugin")
public class ByglByfaPlugin implements AroundAdvicePlugin {
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
private static final String SCHEME_ID_PREFIX = "FA";
@Autowired
private ByglByjhMapper byglByjhMapper;
@Override
public void beforeExecute(EnhanceContext enhanceContext) {
Map<String, Object> params = enhanceContext.getParam().getParams();
//新增方法默认状态字段(1启用)
params.put("state", ByglConstant.FA_STATE_QY);
// 获取并验证scheme_id
String scheme_id = lideeYunJiUtils.getMap2Str(params, "scheme_id");
boolean needGenerateNewId = shouldGenerateNewSchemeId(scheme_id);
if(needGenerateNewId){
String newSchemeId = generateSchemeId();
params.put("scheme_id", newSchemeId);
log.info("生成新方案ID: {}", newSchemeId);
}
}
@Override
public void afterExecute(EnhanceContext enhanceContext) {
}
/**
* 判断是否需要生成新的方案ID
*/
private boolean shouldGenerateNewSchemeId(String scheme_id) {
if(StringUtils.isBlank(scheme_id)){
return true;
}
Map<String, Object> existingScheme = byglByjhMapper.getSchemeBySchemeId(scheme_id);
return Func.isNotEmpty(existingScheme);
}
/**
* 生成方案ID
* 格式FA + 时间戳yyyyMMddHHmmss
*/
private String generateSchemeId() {
return SCHEME_ID_PREFIX + LocalDateTime.now().format(DATE_TIME_FORMATTER);
}
}

View File

@@ -0,0 +1,176 @@
package com.lideeyunji.core.framework.enhance.example.report.bygl;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.lideeyunji.core.framework.adapter.FrameWorkAdapter;
import com.lideeyunji.core.framework.config.aspect.enhance.model.EnhanceContext;
import com.lideeyunji.core.framework.config.aspect.enhance.plugin.AroundAdvicePlugin;
import com.lideeyunji.core.framework.entity.ByManagementGd;
import com.lideeyunji.core.framework.entity.ByManagementJl;
import com.lideeyunji.core.framework.entity.ByManagementYs;
import com.lideeyunji.core.framework.mapper.ByManagementGdMapper;
import com.lideeyunji.core.framework.mapper.ByManagementJlMapper;
import com.lideeyunji.core.framework.mapper.ByManagementYsMapper;
import com.lideeyunji.core.framework.mapper.ByglByjhMapper;
import com.lideeyunji.tool.framework.common.constant.ByglConstant;
import com.lideeyunji.tool.framework.common.util.object.BeanUtils;
import com.lideeyunji.tool.framework.yunji.tool.spring.SpringUtils;
import com.lideeyunji.tool.framework.yunji.utils.lideeYunJiUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.Map;
/**
* 保养管理-保养工单编辑
*/
@Slf4j
@Component("byglBygdBjPlugin")
public class ByglBygdBjPlugin implements AroundAdvicePlugin {
/**
* 操作类型常量
*/
private static final String SUBMIT_TYPE_CL = "cl";
private static final String SUBMIT_TYPE_YS = "ys";
/**
* 状态常量
*/
private static final int NOT_DELETED = 0;
@Autowired
private ByglByjhMapper byglByjhMapper;
@Autowired
private ByManagementJlMapper byManagementJlMapper;
@Autowired
private ByManagementYsMapper byManagementYsMapper;
@Autowired
private ByManagementGdMapper byManagementGdMapper;
@Override
public void beforeExecute(EnhanceContext enhanceContext) {
Map<String, Object> params = enhanceContext.getParam().getParams();
String submit_type = lideeYunJiUtils.getMap2Str(params, "submit_type");
log.info("开始处理工单操作submit_type: {}", submit_type);
if(StringUtils.isBlank(submit_type)){
log.info("submit_type为空跳过处理");
return;
}
String id = lideeYunJiUtils.getMap2Str(params, "id");
validateParams(id, submit_type);
FrameWorkAdapter adapter = SpringUtils.getBean(FrameWorkAdapter.class);
switch (submit_type) {
case SUBMIT_TYPE_CL://处理操作
handleClOperation(id, params, adapter);
break;
case SUBMIT_TYPE_YS://验收操作
handleYsOperation(id, params, adapter);
break;
}
}
@Override
public void afterExecute(EnhanceContext enhanceContext) {
}
/**
* 验收操作
*/
private void handleYsOperation(String id, Map<String, Object> params, FrameWorkAdapter adapter) {
String gdys_yj = lideeYunJiUtils.getMap2Str(params, "gdys_yj");
String pjxj = lideeYunJiUtils.getMap2Str(params, "pjxj");
ByManagementJl jl = byManagementJlMapper.selectById(id);
jl.setYsTime(DateUtil.now());
jl.setPjxj(pjxj);
jl.setState(ByglConstant.YSZT_STATE_YYS);
jl.setGdysYj(gdys_yj);
jl.setUpdateTime(LocalDateTime.now());
jl.setUpdateUser(adapter.getOnlineUserId());
byManagementJlMapper.updateById(jl);
ByManagementYs ys = BeanUtils.toBean(jl, ByManagementYs.class);
if(ys == null){
throw new RuntimeException("对象转换失败");
}
byManagementYsMapper.updateById(ys);
log.info("工单验收成功ID: {}", id);
}
/**
* 处理操作
*/
private void handleClOperation(String id, Map<String, Object> params, FrameWorkAdapter adapter) {
String bygd_cljg = lideeYunJiUtils.getMap2Str(params, "bygd_cljg");
int result = byglByjhMapper.updateClBygd(id, bygd_cljg, ByglConstant.BY_STATE_YWC);
if (result <= 0) {
log.info("工单处理失败ID: {}", id);
return;
}
ByManagementGd gd = byManagementGdMapper.selectById(id);
ByManagementJl jl = createByManagementJl(gd, adapter);
byManagementJlMapper.insert(jl);
syncToYsTable(jl);
log.info("工单处理成功ID: {}", id);
}
/**
* 创建保养记录
*/
private ByManagementJl createByManagementJl(ByManagementGd gd, FrameWorkAdapter adapter) {
ByManagementJl jl = new ByManagementJl();
jl.setId(IdWorker.getId());
jl.setOrderId(gd.getOrderId());
jl.setOrderName(gd.getOrderName());
jl.setEquipmentInfo(gd.getEquipmentInfo());
jl.setUpkeepLevel(gd.getUpkeepLevel());
jl.setUpkeepTime(gd.getUpkeepTime());
jl.setPriority(gd.getPriority());
jl.setState(ByglConstant.YSZT_STATE_DYS);
jl.setExecutor(gd.getExecutor());
jl.setCreateTime(LocalDateTime.now());
jl.setCreateUser(adapter.getOnlineUserId());
jl.setIsDeleted(NOT_DELETED);
return jl;
}
/**
* 同步到验收表
*/
private void syncToYsTable(ByManagementJl jl) {
ByManagementYs ys = BeanUtils.toBean(jl, ByManagementYs.class);
if(ys == null){
throw new RuntimeException("对象转换失败");
}
byManagementYsMapper.insert(ys);
}
/**
* 参数校验
*/
private void validateParams(String id, String submit_type) {
if(StringUtils.isBlank(id)){
throw new IllegalArgumentException("工单ID不能为空");
}
if(!SUBMIT_TYPE_CL.equals(submit_type) && !SUBMIT_TYPE_YS.equals(submit_type)){
throw new IllegalArgumentException("不支持的操作类型: " + submit_type);
}
}
}

View File

@@ -0,0 +1,68 @@
package com.lideeyunji.core.framework.enhance.example.report.bygl;
import com.lideeyunji.core.framework.config.aspect.enhance.model.EnhanceContext;
import com.lideeyunji.core.framework.config.aspect.enhance.plugin.AroundAdvicePlugin;
import com.lideeyunji.core.framework.mapper.ByglByjhMapper;
import com.lideeyunji.core.framework.utils.Func;
import com.lideeyunji.tool.framework.common.constant.ByglConstant;
import com.lideeyunji.tool.framework.yunji.utils.lideeYunJiUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Map;
/**
* 保养管理-保养工单
*/
@Slf4j
@Component("byglBygdPlugin")
public class ByglBygdPlugin implements AroundAdvicePlugin {
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
private static final String ORDER_ID_PREFIX = "GD";
@Autowired
private ByglByjhMapper byglByjhMapper;
@Override
public void beforeExecute(EnhanceContext enhanceContext) {
Map<String, Object> params = enhanceContext.getParam().getParams();
//新增方法默认状态字段
params.put("order_state",ByglConstant.GD_STATE_DKS);
String order_id = lideeYunJiUtils.getMap2Str(params, "order_id");
boolean needGenerateNewId = shouldGenerateNewOrderId(order_id);
if(needGenerateNewId){
String newOrderId = generateOrderId();
params.put("order_id",newOrderId);
log.info("生成新工单ID: {}", newOrderId);
}
}
@Override
public void afterExecute(EnhanceContext enhanceContext) {
}
/**
* 判断是否需要生成新的工单ID
*/
private boolean shouldGenerateNewOrderId(String order_id) {
if(StringUtils.isBlank(order_id)){
return true;
}
Map<String, Object> existingOrder = byglByjhMapper.getOrderByPlanId(order_id);
return Func.isNotEmpty(existingOrder);
}
/**
* 生成工单ID
* 格式GD + 时间戳yyyyMMddHHmmss
*/
private String generateOrderId() {
return ORDER_ID_PREFIX + LocalDateTime.now().format(DATE_TIME_FORMATTER);
}
}

View File

@@ -0,0 +1,43 @@
package com.lideeyunji.core.framework.enhance.example.report.bygl;
import com.lideeyunji.core.framework.config.aspect.enhance.model.EnhanceContext;
import com.lideeyunji.core.framework.config.aspect.enhance.plugin.AroundAdvicePlugin;
import com.lideeyunji.core.framework.mapper.ByglByjhMapper;
import com.lideeyunji.core.framework.utils.Func;
import com.lideeyunji.tool.framework.yunji.utils.lideeYunJiUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
/**
* 保养管理-保养计划-列表
*/
@Slf4j
@Component("byglByjlLbPlugin")
public class ByglByjhLbPlugin implements AroundAdvicePlugin {
@Autowired
private ByglByjhMapper byglByjhMapper;
@Override
public void beforeExecute(EnhanceContext enhanceContext) {
}
@Override
public void afterExecute(EnhanceContext enhanceContext) {
List<Map<String, Object>> records = enhanceContext.getResult().getRecords();
if (Func.isEmpty(records)) {
return;
}
for (Map<String, Object> record : records) {
String plan_id = lideeYunJiUtils.getMap2Str(record, "plan_id");
Map<String, Object> countByPlanId = byglByjhMapper.getCountByPlanId(plan_id);
record.put("plan_count",lideeYunJiUtils.getMap2Long(countByPlanId,"jhs"));
record.put("completed_count",lideeYunJiUtils.getMap2Long(countByPlanId,"wcs"));
}
}
}

View File

@@ -0,0 +1,70 @@
package com.lideeyunji.core.framework.enhance.example.report.bygl;
import com.lideeyunji.core.framework.config.aspect.enhance.model.EnhanceContext;
import com.lideeyunji.core.framework.config.aspect.enhance.plugin.AroundAdvicePlugin;
import com.lideeyunji.core.framework.mapper.ByglByjhMapper;
import com.lideeyunji.core.framework.utils.Func;
import com.lideeyunji.tool.framework.common.constant.ByglConstant;
import com.lideeyunji.tool.framework.yunji.utils.lideeYunJiUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Map;
/**
* 保养管理-保养计划-新增
*/
@Slf4j
@Component("byglByjhPlugin")
public class ByglByjhPlugin implements AroundAdvicePlugin {
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
private static final String PLAN_ID_PREFIX = "BYJH";
@Autowired
private ByglByjhMapper byglByjhMapper;
@Override
public void beforeExecute(EnhanceContext enhanceContext) {
Map<String, Object> params = enhanceContext.getParam().getParams();
//新增方法默认状态字段
params.put("plan_state", ByglConstant.JH_STATE_JXZ);
String plan_id = lideeYunJiUtils.getMap2Str(params, "plan_id");
boolean needGenerateNewId = shouldGenerateNewPlanId(plan_id);
if(needGenerateNewId){
String newPlanId = generatePlanId();
params.put("plan_id",newPlanId);
log.info("生成新计划ID: {}", newPlanId);
}
}
@Override
public void afterExecute(EnhanceContext enhanceContext) {
}
/**
* 判断是否需要生成新的计划ID
*/
private boolean shouldGenerateNewPlanId(String plan_id) {
if(StringUtils.isBlank(plan_id)){
return true;
}
Map<String, Object> existingPlan = byglByjhMapper.getPlanByPlanId(plan_id);
return Func.isNotEmpty(existingPlan);
}
/**
* 生成计划ID
* 格式BYJH + 时间戳yyyyMMddHHmmss
*/
private String generatePlanId() {
return PLAN_ID_PREFIX + LocalDateTime.now().format(DATE_TIME_FORMATTER);
}
}

View File

@@ -0,0 +1,114 @@
package com.lideeyunji.core.framework.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.lideeyunji.tool.framework.yunji.model.global.BaseTenantEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 保养管理-保养工单
*/
@TableName("by_management_gd")
@Data
@EqualsAndHashCode
public class ByManagementGd extends BaseTenantEntity {
/**
* ID
*/
private Long id;
/**
* 工单编号
*/
private String orderId;
/**
* 工单名称
*/
private String orderName;
/**
* 设备类型
*/
private String deviceTypeName;
/**
*设备
*/
private String equipmentInfo;
/**
*设备编号
*/
private String equipmentCode;
/**
*保养级别
*/
private String upkeepLevel;
/**
*优先级
*/
private String priority;
/**
*可能更换零件
*/
private String possibleReplacements;
/**
*计划保养时间
*/
private String planUpkeepTime;
/**
*是否申请备件
*/
private String applyForParts;
/**
*是否已停机
*/
private String isStopped;
/**
*执行人
*/
private String executor;
/**
*状态
*/
private String orderState;
/**
* 备注
*/
private String remark;
/**
* 完成时间
*/
private String upkeepTime;
/**
* 保养方案
*/
private String schemeId;
/**
* 处理结果
*/
private String bygdCljg;
/**
* 计划id
*/
private String planId;
}

View File

@@ -0,0 +1,77 @@
package com.lideeyunji.core.framework.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.lideeyunji.tool.framework.yunji.model.global.BaseTenantEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 保养管理-保养记录
*/
@TableName("by_management_jl")
@Data
@EqualsAndHashCode
public class ByManagementJl extends BaseTenantEntity {
/**
* ID
*/
private Long id;
/**
* 工单编号
*/
private String orderId;
/**
* 工单名称
*/
private String orderName;
/**
*设备
*/
private String equipmentInfo;
/**
*优先级
*/
private String priority;
/**
*保养级别
*/
private String upkeepLevel;
/**
*完成时间
*/
private String upkeepTime;
/**
*状态
*/
private String state;
/**
*执行人
*/
private String executor;
/**
*验收时间
*/
private String ysTime;
/**
*评价星级
*/
private String pjxj;
/**
*验收意见
*/
private String gdysYj;
}

View File

@@ -0,0 +1,68 @@
package com.lideeyunji.core.framework.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.lideeyunji.tool.framework.yunji.model.global.BaseTenantEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 保养管理-保养验收
*/
@TableName("by_management_ys")
@Data
@EqualsAndHashCode
public class ByManagementYs extends BaseTenantEntity {
/**
* ID
*/
private Long id;
/**
* 工单编号
*/
private String orderId;
/**
* 工单名称
*/
private String orderName;
/**
*设备
*/
private String equipmentInfo;
/**
*优先级
*/
private String priority;
/**
*保养级别
*/
private String upkeepLevel;
/**
*完成时间
*/
private String upkeepTime;
/**
*状态
*/
private String state;
/**
*执行人
*/
private String executor;
/**
*验收时间
*/
private String ysTime;
}

View File

@@ -0,0 +1,13 @@
package com.lideeyunji.core.framework.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lideeyunji.core.framework.entity.ByManagementGd;
/**
* 保养管理-保养工单Mapper接口
*
* @date 2026-03-20
*/
public interface ByManagementGdMapper extends BaseMapper<ByManagementGd> {
}

View File

@@ -0,0 +1,13 @@
package com.lideeyunji.core.framework.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lideeyunji.core.framework.entity.ByManagementJl;
/**
* 保养管理-保养记录Mapper接口
*
* @date 2026-03-20
*/
public interface ByManagementJlMapper extends BaseMapper<ByManagementJl> {
}

View File

@@ -0,0 +1,13 @@
package com.lideeyunji.core.framework.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lideeyunji.core.framework.entity.ByManagementYs;
/**
* 保养管理-保养验收Mapper接口
*
* @date 2026-03-20
*/
public interface ByManagementYsMapper extends BaseMapper<ByManagementYs> {
}

View File

@@ -0,0 +1,23 @@
package com.lideeyunji.core.framework.mapper;
import com.baomidou.dynamic.datasource.annotation.Master;
import java.util.Map;
/**
*
*/
@Master
public interface ByglByjhMapper{
Map<String,Object> getCountByPlanId(String plan_id);
Map<String,Object> getPlanByPlanId(String plan_id);
Map<String, Object> getOrderByPlanId(String order_id);
Map<String, Object> getSchemeBySchemeId(String scheme_id);
int updateClBygd(String id, String bygd_cljg, String order_state);
}

View File

@@ -0,0 +1,50 @@
<?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.lideeyunji.core.framework.mapper.ByglByjhMapper">
<select id="getCountByPlanId" resultType="java.util.Map">
SELECT
COUNT(*) AS jhs,
COUNT(CASE WHEN order_state = '1' THEN 1 ELSE NULL END) AS wcs
FROM
by_management_gd
WHERE
is_deleted = 0
AND plan_id = #{plan_id}
</select>
<select id="getPlanByPlanId" resultType="java.util.Map">
SELECT
*
FROM
by_management_plan
WHERE
is_deleted = 0
AND plan_id = #{plan_id}
</select>
<select id="getOrderByPlanId" resultType="java.util.Map">
SELECT
*
FROM
by_management_gd
WHERE
is_deleted = 0
AND order_id = #{order_id}
</select>
<select id="getSchemeBySchemeId" resultType="java.util.Map">
SELECT
*
FROM
by_management_fa
WHERE
is_deleted = 0
AND scheme_id = #{scheme_id}
</select>
<update id="updateClBygd">
update by_management_gd set bygd_cljg = #{bygd_cljg}, order_state = #{order_state}, upkeep_time = DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s') where id = #{id}
</update>
</mapper>

View File

@@ -0,0 +1,30 @@
package com.lideeyunji.tool.framework.common.constant;
/**
* 保养管理
*/
public interface ByglConstant {
/**进行中*/
String JH_STATE_JXZ = "0";
/**已完成*/
String JH_STATE_YWC = "1";
/**待开始*/
String GD_STATE_DKS = "0";
/**已完成*/
String BY_STATE_YWC = "1";
/**方案停用*/
String FA_STATE_TY = "0";
/**方案启用*/
String FA_STATE_QY = "1";
/**待验收*/
String YSZT_STATE_DYS = "0";
/**已验收*/
String YSZT_STATE_YYS = "1";
}