diff --git a/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Log.java b/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Log.java index b7c3a0c..1f5139a 100644 --- a/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Log.java +++ b/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Log.java @@ -6,6 +6,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.enums.LogBizType; import com.ruoyi.common.enums.OperatorType; /** @@ -50,8 +51,12 @@ public @interface Log public String[] excludeParamNames() default {}; /** - * 业务表ID - * @return + * 业务表ID获取方法 */ - long bizId() default -1; + String bizIdName() default ""; + + /** + * 业务类型 + */ + LogBizType bizType() default LogBizType.UNKNOWN; } diff --git a/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/enums/LogBizType.java b/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/enums/LogBizType.java new file mode 100644 index 0000000..9c2ddb3 --- /dev/null +++ b/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/enums/LogBizType.java @@ -0,0 +1,22 @@ +package com.ruoyi.common.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 日志业务类型 + * @author wjh + * 2024/11/11 + */ +@Getter +@AllArgsConstructor +public enum LogBizType { + + UNKNOWN("0", "未知"), + PRICE("1", "单价"), + REPORT("2", "报表"), + PROD_ORDER("3", "生产订单" ); + + private final String type; + private final String msg; +} diff --git a/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java b/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java index 8c474dc..986b0b2 100644 --- a/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java +++ b/common-ruoyi/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java @@ -317,6 +317,9 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils } public static LocalDateTime toLocalDateTime(Date date) { + if (date == null) { + return null; + } return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); } diff --git a/common-ruoyi/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java b/common-ruoyi/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java index e7bedf5..1dd15c6 100644 --- a/common-ruoyi/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java +++ b/common-ruoyi/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java @@ -1,11 +1,14 @@ package com.ruoyi.framework.aspectj; +import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Parameter; -import java.util.Collection; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.framework.web.domain.log.LogBizParam; import org.apache.commons.lang3.ArrayUtils; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.AfterReturning; @@ -57,46 +60,87 @@ public class LogAspect @Before(value = "@annotation(controllerLog)") public void boBefore(JoinPoint joinPoint, Log controllerLog) { -// MethodSignature signature = (MethodSignature) joinPoint.getSignature(); -// Method method = signature.getMethod(); -// -// // 获取方法的所有参数 -// Parameter[] parameters = method.getParameters(); -// Object[] args = joinPoint.getArgs(); -// -// // 获取注解中的 paramName -// String paramName = myMethodAnnotation.paramName(); -// -// // 查找参数名对应的参数值 -// for (int i = 0; i < parameters.length; i++) { -// Parameter parameter = parameters[i]; -// if (parameter.getName().equals(paramName.split("\\.")[0])) { -// Object paramValue = args[i]; -// -// // 如果参数是复杂类型,进一步获取属性值 -// if (paramName.contains(".")) { -// String[] parts = paramName.split("\\."); -// Object currentObject = paramValue; -// for (int j = 1; j < parts.length; j++) { -// String part = parts[j]; -// try { -// Field field = currentObject.getClass().getDeclaredField(part); -// field.setAccessible(true); -// currentObject = field.get(currentObject); -// } catch (NoSuchFieldException | IllegalAccessException e) { -// throw new RuntimeException("Failed to access field " + part, e); -// } -// } -// paramValue = currentObject; -// } -// -// System.out.println("Parameter value for " + paramName + ": " + paramValue); -// } -// } - TIME_THREADLOCAL.set(System.currentTimeMillis()); } + /** + * 获取业务ID列表 + */ + private List getBizIds(JoinPoint joinPoint, Log controllerLog) { + String paramName = controllerLog.bizIdName(); + if (StringUtils.isBlank(paramName)) { + return null; + } + + Object bizIds = getJoinPointParamValue(joinPoint, paramName); + if (bizIds == null) { + return Collections.emptyList(); + } + + if (bizIds instanceof Collection) { + return new ArrayList<>((Collection) bizIds).stream() + .filter(Objects::nonNull) + .map(Object::toString).collect(Collectors.toList()); + } else { + return Collections.singletonList(bizIds.toString()); + } + } + + private Object getJoinPointParamValue(JoinPoint joinPoint, String paramName) { + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); + Method method = signature.getMethod(); + + // 获取方法的所有参数 + Parameter[] parameters = method.getParameters(); + Object[] args = joinPoint.getArgs(); + + // 查找参数名对应的参数值 + for (int i = 0; i < parameters.length; i++) { + Parameter parameter = parameters[i]; + if (parameter.getName().equals(paramName)) { + Object paramValue = args[i]; + + // 处理多层嵌套属性 + paramValue = getNestedProperty(paramValue, paramName); + + // 检查参数是否实现了 LogBizParam 接口 + if (paramValue instanceof LogBizParam) { + LogBizParam logBizParam = (LogBizParam) paramValue; + paramValue = logBizParam.logBizId(); + } + + return paramValue; + } + } + + return null; + } + + private Object getNestedProperty(Object obj, String propertyName) { + if (obj == null || propertyName == null || propertyName.isEmpty()) { + return null; + } + + String[] parts = propertyName.split("\\."); + Object currentObject = obj; + + for (int i = 1; i < parts.length; i++) { + String part = parts[i]; + if (currentObject == null) { + return null; + } + try { + Field field = currentObject.getClass().getDeclaredField(part); + field.setAccessible(true); + currentObject = field.get(currentObject); + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new RuntimeException("Failed to access field " + part, e); + } + } + + return currentObject; + } + /** * 处理完请求后执行 * @@ -144,8 +188,7 @@ public class LogAspect } } - if (e != null) - { + if (e != null) { operLog.setStatus(BusinessStatus.FAIL.ordinal()); operLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000)); } @@ -184,22 +227,24 @@ public class LogAspect public void getControllerMethodDescription(JoinPoint joinPoint, Log log, SysOperLog operLog, Object jsonResult) throws Exception { // 设置action动作 - operLog.setBusinessType(log.businessType().ordinal()); + operLog.setBusinessType(log.businessType().name()); // 设置标题 operLog.setTitle(log.title()); // 设置操作人类别 operLog.setOperatorType(log.operatorType().ordinal()); // 是否需要保存request,参数和值 - if (log.isSaveRequestData()) - { + if (log.isSaveRequestData()) { // 获取参数的信息,传入到数据库中。 setRequestValue(joinPoint, operLog, log.excludeParamNames()); } // 是否需要保存response,参数和值 - if (log.isSaveResponseData() && StringUtils.isNotNull(jsonResult)) - { + if (log.isSaveResponseData() && StringUtils.isNotNull(jsonResult)) { operLog.setJsonResult(StringUtils.substring(JSON.toJSONString(jsonResult), 0, 2000)); } + + // 设置业务类型及ID + operLog.setBizIds(getBizIds(joinPoint, log)); + operLog.setBizType(log.bizType().getType()); } /** diff --git a/common-ruoyi/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/log/LogBizParam.java b/common-ruoyi/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/log/LogBizParam.java new file mode 100644 index 0000000..fb12eb8 --- /dev/null +++ b/common-ruoyi/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/log/LogBizParam.java @@ -0,0 +1,17 @@ +package com.ruoyi.framework.web.domain.log; + +import lombok.Data; + +/** + * 日志获取业务信息接口 + * @author wjh + * 2024/11/11 + */ +public interface LogBizParam { + + /** + * 获取日志业务ID + */ + Object logBizId(); + +} diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOperLog.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOperLog.java index f6761df..f199b8a 100644 --- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOperLog.java +++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOperLog.java @@ -1,16 +1,20 @@ package com.ruoyi.system.domain; import java.util.Date; +import java.util.List; + import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel.ColumnType; import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; /** * 操作日志记录表 oper_log - * + * * @author ruoyi */ +@Data public class SysOperLog extends BaseEntity { private static final long serialVersionUID = 1L; @@ -25,7 +29,7 @@ public class SysOperLog extends BaseEntity /** 业务类型(0其它 1新增 2修改 3删除) */ @Excel(name = "业务类型", readConverterExp = "0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据") - private Integer businessType; + private String businessType; /** 业务类型数组 */ private Integer[] businessTypes; @@ -87,183 +91,9 @@ public class SysOperLog extends BaseEntity @Excel(name = "消耗时间", suffix = "毫秒") private Long costTime; - public Long getOperId() - { - return operId; - } + @Excel(name = "业务ID列表") + private List bizIds; - public void setOperId(Long operId) - { - this.operId = operId; - } - - public String getTitle() - { - return title; - } - - public void setTitle(String title) - { - this.title = title; - } - - public Integer getBusinessType() - { - return businessType; - } - - public void setBusinessType(Integer businessType) - { - this.businessType = businessType; - } - - public Integer[] getBusinessTypes() - { - return businessTypes; - } - - public void setBusinessTypes(Integer[] businessTypes) - { - this.businessTypes = businessTypes; - } - - public String getMethod() - { - return method; - } - - public void setMethod(String method) - { - this.method = method; - } - - public String getRequestMethod() - { - return requestMethod; - } - - public void setRequestMethod(String requestMethod) - { - this.requestMethod = requestMethod; - } - - public Integer getOperatorType() - { - return operatorType; - } - - public void setOperatorType(Integer operatorType) - { - this.operatorType = operatorType; - } - - public String getOperName() - { - return operName; - } - - public void setOperName(String operName) - { - this.operName = operName; - } - - public String getDeptName() - { - return deptName; - } - - public void setDeptName(String deptName) - { - this.deptName = deptName; - } - - public String getOperUrl() - { - return operUrl; - } - - public void setOperUrl(String operUrl) - { - this.operUrl = operUrl; - } - - public String getOperIp() - { - return operIp; - } - - public void setOperIp(String operIp) - { - this.operIp = operIp; - } - - public String getOperLocation() - { - return operLocation; - } - - public void setOperLocation(String operLocation) - { - this.operLocation = operLocation; - } - - public String getOperParam() - { - return operParam; - } - - public void setOperParam(String operParam) - { - this.operParam = operParam; - } - - public String getJsonResult() - { - return jsonResult; - } - - public void setJsonResult(String jsonResult) - { - this.jsonResult = jsonResult; - } - - public Integer getStatus() - { - return status; - } - - public void setStatus(Integer status) - { - this.status = status; - } - - public String getErrorMsg() - { - return errorMsg; - } - - public void setErrorMsg(String errorMsg) - { - this.errorMsg = errorMsg; - } - - public Date getOperTime() - { - return operTime; - } - - public void setOperTime(Date operTime) - { - this.operTime = operTime; - } - - public Long getCostTime() - { - return costTime; - } - - public void setCostTime(Long costTime) - { - this.costTime = costTime; - } + @Excel(name = "业务类型") + private String bizType; } diff --git a/common-ruoyi/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml b/common-ruoyi/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml index 201db07..7433355 100644 --- a/common-ruoyi/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml +++ b/common-ruoyi/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml @@ -4,36 +4,77 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - - - - - - - - - - + + - select oper_id, title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, oper_time, cost_time + select + oper_id, + title, + business_type, + method, + request_method, + operator_type, + oper_name, + dept_name, + oper_url, + oper_ip, + oper_location, + oper_param, + json_result, + status, + error_msg, + oper_time, + cost_time, + biz_ids, + biz_type from sys_oper_log - + - insert into sys_oper_log(title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, cost_time, oper_time) - values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, #{costTime}, sysdate()) + insert into sys_oper_log( + title, + business_type, + method, + request_method, + operator_type, + oper_name, + dept_name, + oper_url, + oper_ip, + oper_location, + oper_param, + json_result, + status, + error_msg, + cost_time, + oper_time, + biz_ids, + biz_type + ) + values ( + #{title}, + #{businessType}, + #{method}, + #{requestMethod}, + #{operatorType}, + #{operName}, + #{deptName}, + #{operUrl}, + #{operIp}, + #{operLocation}, + #{operParam}, + #{jsonResult}, + #{status}, + #{errorMsg}, + #{costTime}, + sysdate(), + #{bizIds,typeHandler=com.ruoyi.common.mybatis.typehandler.StringSplitListTypeHandler}, + #{bizType} + ) - + - + delete from sys_oper_log where oper_id in #{operId} - + - + - + truncate table sys_oper_log - \ No newline at end of file + diff --git a/ruoyi-web/src/main/java/com/ruoyi/common/constants/LogTitle.java b/ruoyi-web/src/main/java/com/ruoyi/common/constants/LogTitle.java new file mode 100644 index 0000000..1f62cb9 --- /dev/null +++ b/ruoyi-web/src/main/java/com/ruoyi/common/constants/LogTitle.java @@ -0,0 +1,17 @@ +package com.ruoyi.common.constants; + +import lombok.Data; + +/** + * 日志模块标题 + * @author wjh + * 2024/11/11 + */ +public class LogTitle { + + public static final String PRICE = "单价"; + public static final String REPORT = "报表"; + public static final String PROD_ORDER = "生产订单"; + public static final String LOG_IMPORT = "导入日志"; + public static final String LOG_IMPORT_DETAIL = "导入日志明细"; +} diff --git a/ruoyi-web/src/main/java/com/ruoyi/k3cloud/business/prodOrder/constants/K3ProdField.java b/ruoyi-web/src/main/java/com/ruoyi/k3cloud/business/prodOrder/constants/K3ProdField.java new file mode 100644 index 0000000..73e44ff --- /dev/null +++ b/ruoyi-web/src/main/java/com/ruoyi/k3cloud/business/prodOrder/constants/K3ProdField.java @@ -0,0 +1,25 @@ +package com.ruoyi.k3cloud.business.prodOrder.constants; + +/** + * @author wjh + * 2024/10/30 + */ +public class K3ProdField { + public static final String FID = "FID"; // 单据ID + public static final String F_BILL_NO = "FBillNo"; // 单据编号 + public static final String F_DOCUMENT_STATUS = "FDocumentStatus"; // 单据状态 + public static final String F_CREATE_DATE = "FCreateDate"; // 创建日期 + public static final String F_MODIFY_DATE = "FModifyDate"; // 修改日期 + public static final String F_DESCRIPTION = "FDescription"; // 备注 + public static final String F_DATE = "FDate"; // 单据日期 + public static final String F_IS_REWORK = "FIsRework"; // 是否返工 + public static final String F_ROW_ID = "FRowId"; // 明细.行标识 + public static final String F_MEMO_ITEM = "FMemoItem"; // 明细.备注 + public static final String F_CONVEY_DATE = "FConveyDate"; // 明细.下达日期 + public static final String F_STATUS = "FStatus"; // 明细.业务状态 + public static final String F_WORK_SHOP_ID = "FWorkShopID"; // 明细.生产车间 + public static final String F_REQ_SRC = "FReqSrc"; // 明细.需求来源 + public static final String F_BASE_UNIT_QTY = "FBaseUnitQty"; // 明细.基本单位数量 + public static final String F_QTY = "FQty"; // 明细.数量 + public static final String F_UNIT_ID = "FUnitId"; // 明细.单位 +} diff --git a/ruoyi-web/src/main/java/com/ruoyi/k3cloud/business/prodOrder/constants/K3ProdMainField.java b/ruoyi-web/src/main/java/com/ruoyi/k3cloud/business/prodOrder/constants/K3ProdMainField.java deleted file mode 100644 index ee5ad58..0000000 --- a/ruoyi-web/src/main/java/com/ruoyi/k3cloud/business/prodOrder/constants/K3ProdMainField.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.ruoyi.k3cloud.business.prodOrder.constants; - -/** - * @author wjh - * 2024/10/30 - */ -public class K3ProdMainField { - public static final String FID = "FID"; // 单据ID - public static final String F_BILL_NO = "FBillNo"; // 单据编号 - public static final String F_DOCUMENT_STATUS = "FDocumentStatus"; // 单据状态 - public static final String F_APPROVER_ID = "FApproverId"; // 审核人 - public static final String F_APPROVE_DATE = "FApproveDate"; // 审核日期 - public static final String F_MODIFIER_ID = "FModifierId"; // 修改人 - public static final String F_CREATE_DATE = "FCreateDate"; // 创建日期 - public static final String F_CREATOR_ID = "FCreatorId"; // 创建人 - public static final String F_MODIFY_DATE = "FModifyDate"; // 修改日期 - public static final String F_CANCEL_DATE = "FCancelDate"; // 作废日期 - public static final String F_CANCELER = "FCanceler"; // 作废人 - public static final String F_CANCEL_STATUS = "FCancelStatus"; // 作废状态 - public static final String F_DESCRIPTION = "FDescription"; // 备注 - public static final String F_BILL_TYPE = "FBillType"; // 单据类型 - public static final String F_TRUSTTEED = "FTrustteed"; // 受托 - public static final String F_WORK_SHOP_ID0 = "FWorkShopID0"; // 车间 - public static final String F_PRD_ORG_ID = "FPrdOrgId"; // 生产组织 - public static final String F_PLANNER_ID = "FPlannerID"; // 计划员 - public static final String F_DATE = "FDate"; // 单据日期 - public static final String F_OWNER_TYPE_ID = "FOwnerTypeId"; // 货主类型 - public static final String F_OWNER_ID = "FOwnerId"; // 货主 - public static final String F_WORK_GROUP_ID = "FWorkGroupId"; // 计划组 - public static final String F_BUSINESS_TYPE = "FBusinessType"; // 销售业务类型 - public static final String F_IS_REWORK = "FIsRework"; // 是否返工 - public static final String F_IS_ENTRUST = "FIsEntrust"; // 组织受托加工 - public static final String F_EN_TRUST_ORG_ID = "FEnTrustOrgId"; // 委托组织 - public static final String FPPBOM_TYPE = "FPPBOMType"; // 用料清单展开 - public static final String F_ISSUE_MTRL = "FIssueMtrl"; // 生产发料 - public static final String F_IS_QCMO = "FIsQCMO"; // 期初生产订单 -} diff --git a/ruoyi-web/src/main/java/com/ruoyi/k3cloud/business/prodOrder/service/K3ProdOrderService.java b/ruoyi-web/src/main/java/com/ruoyi/k3cloud/business/prodOrder/service/K3ProdOrderService.java deleted file mode 100644 index e8e58f6..0000000 --- a/ruoyi-web/src/main/java/com/ruoyi/k3cloud/business/prodOrder/service/K3ProdOrderService.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.ruoyi.k3cloud.business.prodOrder.service; - -import com.alibaba.fastjson2.JSONArray; -import com.alibaba.fastjson2.JSONObject; -import com.kingdee.bos.webapi.sdk.K3CloudApi; -import com.ruoyi.common.exception.ServiceException; -import com.ruoyi.k3cloud.business.prodOrder.constants.K3ProdMainField; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.*; - -/** - * 金蝶生产订单Service - * @author wjh - * 2024/10/30 - */ -@Service -@Slf4j -public class K3ProdOrderService { - - @Autowired - private K3CloudApi api; - - // 表单ID - public static final String FORM_ID = "PRD_MO"; - - // 字段列表 - public static final List MAIN_FIELD_KEYS = Arrays.asList( - K3ProdMainField.FID, - K3ProdMainField.F_BILL_NO, - K3ProdMainField.F_DOCUMENT_STATUS, - K3ProdMainField.F_CREATE_DATE, - K3ProdMainField.F_DESCRIPTION, - K3ProdMainField.F_BILL_TYPE, - K3ProdMainField.F_WORK_SHOP_ID0, - K3ProdMainField.F_PRD_ORG_ID, - K3ProdMainField.F_DATE, - K3ProdMainField.F_IS_REWORK - ); - - /** - * 查询列表 - */ - public List selectList(int startRow, int limit) { - try { - JSONObject params = new JSONObject(); - params.put("FormId", FORM_ID); - params.put("FieldKeys", String.join(",", MAIN_FIELD_KEYS)); - params.put("FilterString", ""); - params.put("OrderString", ""); - params.put("TopRowCount", 0); - params.put("StartRow", startRow); - params.put("Limit", limit); - params.put("SubSystemId", ""); - String res = api.executeBillQueryJson(JSONObject.toJSONString(params)); - if (StringUtils.isBlank(res)) { - return Collections.emptyList(); - } - return JSONArray.parseArray(res, JSONArray.class); - } catch (Exception e) { - log.error("获取云星空生产订单失败{}", e.getMessage()); - throw new ServiceException("获取云星空生产订单失败"); - } - } -} diff --git a/ruoyi-web/src/main/java/com/ruoyi/k3cloud/constants/K3FormIds.java b/ruoyi-web/src/main/java/com/ruoyi/k3cloud/constants/K3FormIds.java new file mode 100644 index 0000000..c9b4821 --- /dev/null +++ b/ruoyi-web/src/main/java/com/ruoyi/k3cloud/constants/K3FormIds.java @@ -0,0 +1,14 @@ +package com.ruoyi.k3cloud.constants; + +/** + * @author wjh + * 2024/11/11 + */ +public class K3FormIds { + + /** + * 生产订单 + */ + public static final String PROD_ORDER = "PRD_MO"; + +} diff --git a/ruoyi-web/src/main/java/com/ruoyi/k3cloud/service/K3Service.java b/ruoyi-web/src/main/java/com/ruoyi/k3cloud/service/K3Service.java new file mode 100644 index 0000000..b0268a3 --- /dev/null +++ b/ruoyi-web/src/main/java/com/ruoyi/k3cloud/service/K3Service.java @@ -0,0 +1,55 @@ +package com.ruoyi.k3cloud.service; + +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; +import com.kingdee.bos.webapi.sdk.K3CloudApi; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.k3cloud.business.prodOrder.constants.K3ProdField; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; + +/** + * 金蝶生产订单Service + * @author wjh + * 2024/10/30 + */ +@Service +@Slf4j +public class K3Service { + + @Autowired + private K3CloudApi api; + + public List selectList(String formId, List fieldKeys, int startRow, int limit) { + return selectList(formId, fieldKeys, startRow, limit, "", ""); + } + + /** + * 查询列表 + */ + public List selectList(String formId, List fieldKeys, int startRow, int limit, String filterString, String orderString) { + try { + JSONObject params = new JSONObject(); + params.put("FormId", formId); + params.put("FieldKeys", String.join(",", fieldKeys)); + params.put("StartRow", startRow); + params.put("Limit", limit); + params.put("FilterString", filterString); + params.put("OrderString", orderString); + params.put("TopRowCount", 0); + params.put("SubSystemId", ""); + String res = api.executeBillQueryJson(JSONObject.toJSONString(params)); + if (StringUtils.isBlank(res)) { + return Collections.emptyList(); + } + return JSONArray.parseArray(res, JSONArray.class); + } catch (Exception e) { + log.error("获取云星空数据失败: formId = {}, message = {}", formId, e.getMessage()); + throw new ServiceException("获取云星空数据失败"); + } + } +} diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/yh/logImport/controller/LogImportController.java b/ruoyi-web/src/main/java/com/ruoyi/web/yh/logImport/controller/LogImportController.java index 34f65c9..2ecd88f 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/yh/logImport/controller/LogImportController.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/yh/logImport/controller/LogImportController.java @@ -4,6 +4,7 @@ import java.util.Collections; import java.util.List; import javax.servlet.http.HttpServletResponse; +import com.ruoyi.common.constants.LogTitle; import com.ruoyi.web.yh.logImport.service.LogImportAssembler; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; @@ -42,6 +43,8 @@ public class LogImportController extends BaseController @Autowired private LogImportAssembler logImportAssembler; + private static final String LOG_TITLE = LogTitle.LOG_IMPORT; + /** * 查询导入日志列表 */ @@ -60,7 +63,7 @@ public class LogImportController extends BaseController * 导出导入日志列表 */ @PreAuthorize("@ss.hasPermi('yh:logImport:export')") - @Log(title = "导出导入日志", businessType = BusinessType.EXPORT) + @Log(title = LOG_TITLE, businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, LogImportQuery query) { @@ -86,7 +89,7 @@ public class LogImportController extends BaseController * 新增导入日志 */ @PreAuthorize("@ss.hasPermi('yh:logImport:add')") - @Log(title = "新增导入日志", businessType = BusinessType.INSERT) + @Log(title = LOG_TITLE, businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody LogImport logImport) { @@ -97,7 +100,7 @@ public class LogImportController extends BaseController * 修改导入日志 */ @PreAuthorize("@ss.hasPermi('yh:logImport:edit')") - @Log(title = "修改导入日志", businessType = BusinessType.UPDATE) + @Log(title = LOG_TITLE, businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody LogImport logImport) { @@ -108,7 +111,7 @@ public class LogImportController extends BaseController * 删除导入日志 */ @PreAuthorize("@ss.hasPermi('yh:logImport:remove')") - @Log(title = "删除导入日志", businessType = BusinessType.DELETE) + @Log(title = LOG_TITLE, businessType = BusinessType.DELETE) @DeleteMapping("/{logIds}") public AjaxResult remove(@PathVariable Long[] logIds) { diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/yh/logImportDetail/controller/LogImportDetailController.java b/ruoyi-web/src/main/java/com/ruoyi/web/yh/logImportDetail/controller/LogImportDetailController.java index 5169c1d..bb899a4 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/yh/logImportDetail/controller/LogImportDetailController.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/yh/logImportDetail/controller/LogImportDetailController.java @@ -6,6 +6,7 @@ import java.util.Objects; import javax.servlet.http.HttpServletResponse; import com.alibaba.fastjson2.JSON; +import com.ruoyi.common.constants.LogTitle; import com.ruoyi.common.utils.collection.CollectionUtils; import com.ruoyi.web.yh.logImport.domain.enums.LogImportBizType; import com.ruoyi.web.yh.logImportDetail.domain.interfaces.ImportContent; @@ -46,6 +47,8 @@ public class LogImportDetailController extends BaseController @Autowired private ILogImportDetailService logImportDetailService; + private final static String LOG_TITLE = LogTitle.LOG_IMPORT_DETAIL; + /** * 查询导入日志明细列表 */ @@ -63,7 +66,7 @@ public class LogImportDetailController extends BaseController * 导出导入日志明细列表 */ @PreAuthorize("@ss.hasPermi('yh:logImportDetail:export')") - @Log(title = "导出导入日志明细", businessType = BusinessType.EXPORT) + @Log(title = LOG_TITLE, businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, LogImportDetailQuery query) { List list = logImportDetailService.selectLogImportDetailList(query); @@ -101,7 +104,7 @@ public class LogImportDetailController extends BaseController * 新增导入日志明细 */ @PreAuthorize("@ss.hasPermi('yh:logImportDetail:add')") - @Log(title = "新增导入日志明细", businessType = BusinessType.INSERT) + @Log(title = LOG_TITLE, businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody LogImportDetail logImportDetail) { @@ -112,7 +115,7 @@ public class LogImportDetailController extends BaseController * 修改导入日志明细 */ @PreAuthorize("@ss.hasPermi('yh:logImportDetail:edit')") - @Log(title = "修改导入日志明细", businessType = BusinessType.UPDATE) + @Log(title = LOG_TITLE, businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody LogImportDetail logImportDetail) { @@ -123,7 +126,7 @@ public class LogImportDetailController extends BaseController * 删除导入日志明细 */ @PreAuthorize("@ss.hasPermi('yh:logImportDetail:remove')") - @Log(title = "删除导入日志明细", businessType = BusinessType.DELETE) + @Log(title = LOG_TITLE, businessType = BusinessType.DELETE) @DeleteMapping("/{detailIds}") public AjaxResult remove(@PathVariable Long[] detailIds) { diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/yh/price/controller/PriceController.java b/ruoyi-web/src/main/java/com/ruoyi/web/yh/price/controller/PriceController.java index 9e07b31..3df7760 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/yh/price/controller/PriceController.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/yh/price/controller/PriceController.java @@ -6,7 +6,9 @@ import java.util.concurrent.TimeUnit; import javax.servlet.http.HttpServletResponse; import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.constants.LogTitle; import com.ruoyi.common.core.validate.ValidGroup; +import com.ruoyi.common.enums.LogBizType; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.web.yh.price.domain.dto.PriceVerifyDTO; import com.ruoyi.web.yh.price.service.PriceConverter; @@ -68,7 +70,7 @@ public class PriceController extends BaseController } @PreAuthorize("@ss.hasPermi('yh:price:export')") - @Log(title = "单价", businessType = BusinessType.EXPORT) + @Log(title = LogTitle.PRICE, businessType = BusinessType.EXPORT, bizType = LogBizType.PRICE) @PostMapping("/export") @DataScope(deptAlias = "sd") public void export(HttpServletResponse response, PriceQuery query) @@ -86,7 +88,7 @@ public class PriceController extends BaseController } @PreAuthorize("@ss.hasPermi('yh:price:add')") - @Log(title = "单价新增", businessType = BusinessType.INSERT) + @Log(title = LogTitle.PRICE, businessType = BusinessType.INSERT, bizType = LogBizType.PRICE, bizIdName = "arg0") @PostMapping public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) Price data) { @@ -95,7 +97,7 @@ public class PriceController extends BaseController } @PreAuthorize("@ss.hasPermi('yh:price:edit')") - @Log(title = "单价修改", businessType = BusinessType.UPDATE) + @Log(title = LogTitle.PRICE, businessType = BusinessType.UPDATE, bizType = LogBizType.PRICE, bizIdName = "arg0") @PutMapping public AjaxResult edit(@RequestBody @Validated(ValidGroup.Update.class) Price data) { @@ -104,21 +106,21 @@ public class PriceController extends BaseController } @PreAuthorize("@ss.hasPermi('yh:price:submit')") - @Log(title = "单价提交", businessType = BusinessType.UPDATE) + @Log(title = LogTitle.PRICE, businessType = BusinessType.SUBMIT, bizType = LogBizType.PRICE, bizIdName = "arg0") @PutMapping("/{priceId}/submit") public AjaxResult submit(@PathVariable Long priceId) { return toAjax(priceService.submit(priceId)); } @PreAuthorize("@ss.hasPermi('yh:price:cancel')") - @Log(title = "单价取消提交", businessType = BusinessType.CANCEL) + @Log(title = LogTitle.PRICE, businessType = BusinessType.CANCEL, bizType = LogBizType.PRICE, bizIdName = "arg0") @PutMapping("/{priceId}/cancel") public AjaxResult cancel(@PathVariable Long priceId) { return toAjax(priceService.cancel(priceId)); } @PreAuthorize("@ss.hasPermi('yh:price:verify')") - @Log(title = "单价审核", businessType = BusinessType.VERIFY) + @Log(title = LogTitle.PRICE, businessType = BusinessType.VERIFY, bizType = LogBizType.PRICE, bizIdName = "arg0") @PutMapping("/verify") public AjaxResult submit(@RequestBody @Validated PriceVerifyDTO dto) { dto.setVerifyUser(SecurityUtils.getLoginUser().getUser()); @@ -126,14 +128,14 @@ public class PriceController extends BaseController } @PreAuthorize("@ss.hasPermi('yh:price:disable')") - @Log(title = "单价禁用", businessType = BusinessType.DISABLE) + @Log(title = LogTitle.PRICE, businessType = BusinessType.DISABLE, bizType = LogBizType.PRICE, bizIdName = "arg0") @PutMapping("/{priceId}/disable") public AjaxResult disable(@PathVariable Long priceId) { return toAjax(priceService.disable(priceId)); } @PreAuthorize("@ss.hasPermi('yh:price:enable')") - @Log(title = "单价启用", businessType = BusinessType.ENABLE) + @Log(title = LogTitle.PRICE, businessType = BusinessType.ENABLE, bizType = LogBizType.PRICE, bizIdName = "arg0") @PutMapping("/{priceId}/enable") public AjaxResult enable(@PathVariable Long priceId) { return toAjax(priceService.enable(priceId)); @@ -146,7 +148,7 @@ public class PriceController extends BaseController util.importTemplateExcel(response, "单价数据"); } - @Log(title = "单价导入", businessType = BusinessType.IMPORT) + @Log(title = "单价导入", businessType = BusinessType.IMPORT, bizType = LogBizType.PRICE) @PreAuthorize("@ss.hasPermi('yh:price:import')") @PostMapping("/importData") public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/yh/price/domain/Price.java b/ruoyi-web/src/main/java/com/ruoyi/web/yh/price/domain/Price.java index 01ce67c..202471f 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/yh/price/domain/Price.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/yh/price/domain/Price.java @@ -7,6 +7,7 @@ import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.constants.DictType; import com.ruoyi.common.core.validate.ValidGroup; +import com.ruoyi.framework.web.domain.log.LogBizParam; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; @@ -25,7 +26,7 @@ import javax.validation.constraints.Size; */ @Data @EqualsAndHashCode(callSuper = true) -public class Price extends BaseEntity +public class Price extends BaseEntity implements LogBizParam { private static final long serialVersionUID = 1L; @@ -139,4 +140,12 @@ public class Price extends BaseEntity @Excel(name = "备注") private String remark; + + /** + * 获取日志业务ID + */ + @Override + public Object logBizId() { + return this.getPriceId(); + } } diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/yh/price/domain/dto/PriceVerifyDTO.java b/ruoyi-web/src/main/java/com/ruoyi/web/yh/price/domain/dto/PriceVerifyDTO.java index 0d4378c..1e8fe3c 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/yh/price/domain/dto/PriceVerifyDTO.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/yh/price/domain/dto/PriceVerifyDTO.java @@ -1,6 +1,7 @@ package com.ruoyi.web.yh.price.domain.dto; import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.framework.web.domain.log.LogBizParam; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -12,7 +13,7 @@ import javax.validation.constraints.NotNull; * 2024/10/17 */ @Data -public class PriceVerifyDTO { +public class PriceVerifyDTO implements LogBizParam { @ApiModelProperty("单价ID") @NotNull(message = "单价ID不允许为空") @@ -24,4 +25,12 @@ public class PriceVerifyDTO { @ApiModelProperty("审核人") private SysUser verifyUser; + + /** + * 获取日志业务ID + */ + @Override + public Object logBizId() { + return this.getPriceId(); + } } diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/controller/ProdOrderController.java b/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/controller/ProdOrderController.java index 612e2db..a374884 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/controller/ProdOrderController.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/controller/ProdOrderController.java @@ -2,6 +2,9 @@ package com.ruoyi.web.yh.prodOrder.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.common.constants.LogTitle; +import com.ruoyi.common.enums.LogBizType; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -53,7 +56,7 @@ public class ProdOrderController extends BaseController * 导出生产订单列表 */ @PreAuthorize("@ss.hasPermi('yh:prodOrder:export')") - @Log(title = "导出生产订单", businessType = BusinessType.EXPORT) + @Log(title = LogTitle.PROD_ORDER, businessType = BusinessType.EXPORT, bizType = LogBizType.PROD_ORDER) @PostMapping("/export") public void export(HttpServletResponse response, ProdOrderQuery query) { @@ -76,7 +79,7 @@ public class ProdOrderController extends BaseController * 新增生产订单 */ @PreAuthorize("@ss.hasPermi('yh:prodOrder:add')") - @Log(title = "新增生产订单", businessType = BusinessType.INSERT) + @Log(title = LogTitle.PROD_ORDER, businessType = BusinessType.INSERT, bizType = LogBizType.PROD_ORDER, bizIdName = "arg0") @PostMapping public AjaxResult add(@RequestBody ProdOrder prodOrder) { @@ -87,7 +90,7 @@ public class ProdOrderController extends BaseController * 修改生产订单 */ @PreAuthorize("@ss.hasPermi('yh:prodOrder:edit')") - @Log(title = "修改生产订单", businessType = BusinessType.UPDATE) + @Log(title = LogTitle.PROD_ORDER, businessType = BusinessType.UPDATE, bizType = LogBizType.PROD_ORDER, bizIdName = "arg0") @PutMapping public AjaxResult edit(@RequestBody ProdOrder prodOrder) { @@ -98,7 +101,7 @@ public class ProdOrderController extends BaseController * 删除生产订单 */ @PreAuthorize("@ss.hasPermi('yh:prodOrder:remove')") - @Log(title = "删除生产订单", businessType = BusinessType.DELETE) + @Log(title = LogTitle.PROD_ORDER, businessType = BusinessType.DELETE, bizType = LogBizType.PROD_ORDER, bizIdName = "arg0") @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { @@ -106,7 +109,7 @@ public class ProdOrderController extends BaseController } @PreAuthorize("@ss.hasPermi('yh:productOrder:sync')") - @Log(title = "同步生产订单", businessType = BusinessType.SYNC) + @Log(title = LogTitle.PROD_ORDER, businessType = BusinessType.SYNC, bizType = LogBizType.PROD_ORDER) @PutMapping("/sync") public AjaxResult sync() { return success(prodOrderService.sync()); diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/domain/ProdOrder.java b/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/domain/ProdOrder.java index 2e6c063..ec0f4c7 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/domain/ProdOrder.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/domain/ProdOrder.java @@ -1,7 +1,7 @@ package com.ruoyi.web.yh.prodOrder.domain; import java.math.BigDecimal; -import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; @@ -15,7 +15,7 @@ import com.ruoyi.common.core.domain.BaseEntity; * 生产订单对象 bst_prod_order * * @author ruoyi - * @date 2024-10-30 + * @date 2024-11-11 */ @Data public class ProdOrder extends BaseEntity @@ -30,88 +30,74 @@ public class ProdOrder extends BaseEntity @Excel(name = "ERP单据编号") @ApiModelProperty("ERP单据编号") - private String billNo; - - @Excel(name = "ERP单据类型") - @ApiModelProperty("ERP单据类型") - private String type; - - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "ERP单据日期", width = 30, dateFormat = "yyyy-MM-dd") - @ApiModelProperty("ERP单据日期") - private LocalDate billDate; + private String erpBillNo; @Excel(name = "ERP单据状态") @ApiModelProperty("ERP单据状态") - private String status; - - @Excel(name = "ERP调拨状态") - @ApiModelProperty("ERP调拨状态") - private String transferStatus; - - @Excel(name = "ERP领料状态") - @ApiModelProperty("ERP领料状态") - private String pickStatus; - - @Excel(name = "ERP物料名称") - @ApiModelProperty("ERP物料名称") - private String materialName; - - @Excel(name = "ERP规格型号") - @ApiModelProperty("ERP规格型号") - private String spec; - - @Excel(name = "ERP单位") - @ApiModelProperty("ERP单位") - private String unit; - - @Excel(name = "ERP数量") - @ApiModelProperty("ERP数量") - private BigDecimal num; - - @Excel(name = "ERP业务状态") - @ApiModelProperty("ERP业务状态") - private String bizStatus; - - @Excel(name = "ERP批号") - @ApiModelProperty("ERP批号") - private String batchNo; + private String erpDocumentStatus; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - @Excel(name = "ERP下达时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") - @ApiModelProperty("ERP下达时间") - private Date releaseTime; + @Excel(name = "ERP创建日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty("ERP创建日期") + private LocalDateTime erpCreateDate; - @Excel(name = "ERP源单编号") - @ApiModelProperty("ERP源单编号") - private String sourceNo; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "ERP修改日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty("ERP修改日期") + private LocalDateTime erpModifyDate; - @Excel(name = "ERP需求单据") - @ApiModelProperty("ERP需求单据") - private String demandBill; + @Excel(name = "ERP备注") + @ApiModelProperty("ERP备注") + private String erpDescription; - @Excel(name = "ERP计划跟踪号") - @ApiModelProperty("ERP计划跟踪号") - private String planTrackNo; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "ERP单据日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty("ERP单据日期") + private LocalDateTime erpDate; - @Excel(name = "ERP产品类型") - @ApiModelProperty("ERP产品类型") - private String productType; + @Excel(name = "ERP是否返工") + @ApiModelProperty("ERP是否返工") + private Boolean erpIsRework; - @Excel(name = "ERP物料编码") - @ApiModelProperty("ERP物料编码") - private String materialNo; + @Excel(name = "ERP明细行标识") + @ApiModelProperty("ERP明细行标识") + private String erpRowId; - @Excel(name = "ERP合格品入库数量") - @ApiModelProperty("ERP合格品入库数量") - private BigDecimal quaStore; + @Excel(name = "ERP明细备注") + @ApiModelProperty("ERP明细备注") + private String erpMemoItem; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "ERP明细下达日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty("ERP明细下达日期") + private LocalDateTime erpConveyDate; + + @Excel(name = "ERP明细业务状态") + @ApiModelProperty("ERP明细业务状态") + private String erpStatus; + + @Excel(name = "ERP明细生产车间ID") + @ApiModelProperty("ERP明细生产车间ID") + private String erpWorkShopId; + + @Excel(name = "ERP明细需求来源") + @ApiModelProperty("ERP明细需求来源") + private String erpReqSrc; + + @Excel(name = "ERP明细数量") + @ApiModelProperty("ERP明细数量") + private BigDecimal erpQty; @Excel(name = "部门ID") @ApiModelProperty("部门ID") private Long deptId; - @Excel(name = "ERP部门ID") - @ApiModelProperty("ERP部门ID") - private String erpDeptId; + @Excel(name = "ERP明细基本单位数量") + @ApiModelProperty("ERP明细基本单位数量") + private BigDecimal erpBaseUnitQty; + + @Excel(name = "ERP明细单位") + @ApiModelProperty("ERP明细单位") + private String erpUnitId; } diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/domain/ProdOrderQuery.java b/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/domain/ProdOrderQuery.java index 36844ce..cf346b0 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/domain/ProdOrderQuery.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/domain/ProdOrderQuery.java @@ -11,7 +11,13 @@ import lombok.Data; public class ProdOrderQuery extends ProdOrderVO { @ApiModelProperty("精准查询单据编号") - private String eqBillNo; + private String eqErpBillNo; + + @ApiModelProperty("精准ERP ID") + private String eqErpId; + + @ApiModelProperty("精准ERP明细ID") + private String eqErpRowId; } diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/mapper/ProdOrderMapper.xml b/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/mapper/ProdOrderMapper.xml index 3cc3852..15705fc 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/mapper/ProdOrderMapper.xml +++ b/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/mapper/ProdOrderMapper.xml @@ -10,57 +10,43 @@ select bpo.id, bpo.erp_id, - bpo.bill_no, - bpo.type, - bpo.bill_date, - bpo.status, - bpo.transfer_status, - bpo.pick_status, - bpo.material_name, - bpo.spec, - bpo.unit, - bpo.num, - bpo.biz_status, - bpo.batch_no, - bpo.remark, - bpo.release_time, - bpo.source_no, - bpo.demand_bill, - bpo.plan_track_no, - bpo.product_type, - bpo.material_no, - bpo.qua_store, + bpo.erp_bill_no, + bpo.erp_document_status, + bpo.erp_create_date, + bpo.erp_modify_date, + bpo.erp_description, + bpo.erp_date, + bpo.erp_is_rework, + bpo.erp_row_id, + bpo.erp_memo_item, + bpo.erp_convey_date, + bpo.erp_status, + bpo.erp_work_shop_id, + bpo.erp_req_src, + bpo.erp_qty, bpo.dept_id, - bpo.erp_dept_id, + bpo.erp_base_unit_qty, + bpo.erp_unit_id, bpo.create_time from bst_prod_order bpo and bpo.id = #{query.id} - and bpo.erp_id = #{query.erpId} - and bpo.bill_no like concat('%', #{query.billNo}, '%') - and bpo.bill_no = #{query.eqBillNo} - and bpo.type = #{query.type} - and bpo.bill_date = #{query.billDate} - and bpo.status = #{query.status} - and bpo.transfer_status = #{query.transferStatus} - and bpo.pick_status = #{query.pickStatus} - and bpo.material_name like concat('%', #{query.materialName}, '%') - and bpo.spec like concat('%', #{query.spec}, '%') - and bpo.unit = #{query.unit} - and bpo.num = #{query.num} - and bpo.biz_status = #{query.bizStatus} - and bpo.batch_no = #{query.batchNo} - and bpo.release_time = #{query.releaseTime} - and bpo.source_no like concat('%', #{query.sourceNo}, '%') - and bpo.demand_bill like concat('%', #{query.demandBill}, '%') - and bpo.plan_track_no = #{query.planTrackNo} - and bpo.product_type = #{query.productType} - and bpo.material_no like concat('%', #{query.materialNo}, '%') - and bpo.qua_store = #{query.quaStore} + and bpo.erp_id like concat('%', #{query.erpId}, '%') + and bpo.erp_id = #{query.eqErpId} + and bpo.erp_bill_no like concat('%', #{query.erpBillNo}, '%') + and bpo.erp_bill_no = #{query.eqErpBillNo} + and bpo.erp_document_status = #{query.erpDocumentStatus} + and bpo.erp_description like concat('%', #{query.erpDescription}, '%') + and bpo.erp_is_rework = #{query.erpIsRework} + and bpo.erp_row_id like concat('%', #{query.erpRowId}, '%') + and bpo.erp_row_id = #{query.eqErpRowId} + and bpo.erp_memo_item like concat('%', #{query.erpMemoItem}, '%') + and bpo.erp_status = #{query.erpStatus} + and bpo.erp_work_shop_id like concat('%', #{query.erpWorkShopId}, '%') + and bpo.erp_req_src = #{query.erpReqSrc} and bpo.dept_id = #{query.deptId} - and bpo.erp_dept_id = #{query.erpDeptId} ${query.params.dataScope} @@ -76,60 +62,48 @@ where bpo.id = #{id} - + insert into bst_prod_order - id, - erp_id, - bill_no, - type, - bill_date, - `status`, - transfer_status, - pick_status, - material_name, - spec, - unit, - num, - biz_status, - batch_no, - remark, - release_time, - source_no, - demand_bill, - plan_track_no, - product_type, - material_no, - qua_store, + erp_id, + erp_bill_no, + erp_document_status, + erp_create_date, + erp_modify_date, + erp_description, + erp_date, + erp_is_rework, + erp_row_id, + erp_memo_item, + erp_convey_date, + erp_status, + erp_work_shop_id, + erp_req_src, + erp_qty, dept_id, - erp_dept_id, + erp_base_unit_qty, + erp_unit_id, create_time, - #{id}, - #{erpId}, - #{billNo}, - #{type}, - #{billDate}, - #{status}, - #{transferStatus}, - #{pickStatus}, - #{materialName}, - #{spec}, - #{unit}, - #{num}, - #{bizStatus}, - #{batchNo}, - #{remark}, - #{releaseTime}, - #{sourceNo}, - #{demandBill}, - #{planTrackNo}, - #{productType}, - #{materialNo}, - #{quaStore}, + #{erpId}, + #{erpBillNo}, + #{erpDocumentStatus}, + #{erpCreateDate}, + #{erpModifyDate}, + #{erpDescription}, + #{erpDate}, + #{erpIsRework}, + #{erpRowId}, + #{erpMemoItem}, + #{erpConveyDate}, + #{erpStatus}, + #{erpWorkShopId}, + #{erpReqSrc}, + #{erpQty}, #{deptId}, - #{erpDeptId}, + #{erpBaseUnitQty}, + #{erpUnitId}, #{createTime}, @@ -143,29 +117,24 @@ - erp_id = #{data.erpId}, - bill_no = #{data.billNo}, - type = #{data.type}, - bill_date = #{data.billDate}, - `status` = #{data.status}, - transfer_status = #{data.transferStatus}, - pick_status = #{data.pickStatus}, - material_name = #{data.materialName}, - spec = #{data.spec}, - unit = #{data.unit}, - num = #{data.num}, - biz_status = #{data.bizStatus}, - batch_no = #{data.batchNo}, - remark = #{data.remark}, - release_time = #{data.releaseTime}, - source_no = #{data.sourceNo}, - demand_bill = #{data.demandBill}, - plan_track_no = #{data.planTrackNo}, - product_type = #{data.productType}, - material_no = #{data.materialNo}, - qua_store = #{data.quaStore}, + erp_id = #{data.erpId}, + erp_bill_no = #{data.erpBillNo}, + erp_document_status = #{data.erpDocumentStatus}, + erp_create_date = #{data.erpCreateDate}, + erp_modify_date = #{data.erpModifyDate}, + erp_description = #{data.erpDescription}, + erp_date = #{data.erpDate}, + erp_is_rework = #{data.erpIsRework}, + erp_row_id = #{data.erpRowId}, + erp_memo_item = #{data.erpMemoItem}, + erp_convey_date = #{data.erpConveyDate}, + erp_status = #{data.erpStatus}, + erp_work_shop_id = #{data.erpWorkShopId}, + erp_req_src = #{data.erpReqSrc}, + erp_qty = #{data.erpQty}, dept_id = #{data.deptId}, - erp_dept_id = #{data.erpDeptId}, + erp_base_unit_qty = #{data.erpBaseUnitQty}, + erp_unit_id = #{data.erpUnitId}, create_time = #{data.createTime}, diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/service/impl/ProdOrderConverterImpl.java b/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/service/impl/ProdOrderConverterImpl.java index 5560c31..95d2f9e 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/service/impl/ProdOrderConverterImpl.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/service/impl/ProdOrderConverterImpl.java @@ -2,7 +2,7 @@ package com.ruoyi.web.yh.prodOrder.service.impl; import com.alibaba.fastjson2.JSONArray; import com.ruoyi.common.utils.DateUtils; -import com.ruoyi.k3cloud.business.prodOrder.constants.K3ProdMainField; +import com.ruoyi.k3cloud.business.prodOrder.constants.K3ProdField; import com.ruoyi.web.yh.prodOrder.domain.ProdOrder; import com.ruoyi.web.yh.prodOrder.service.ProdOrderConverter; import org.springframework.stereotype.Service; @@ -38,20 +38,56 @@ public class ProdOrderConverterImpl implements ProdOrderConverter { for (int i = 0; i < headers.size(); i++) { String header = headers.get(i); switch(header) { - case K3ProdMainField.FID: + case K3ProdField.FID: po.setErpId(row.getString(i)); break; - case K3ProdMainField.F_BILL_NO: - po.setBillNo(row.getString(i)); + case K3ProdField.F_BILL_NO: + po.setErpBillNo(row.getString(i)); break; - case K3ProdMainField.F_BILL_TYPE: - po.setType(row.getString(i)); + case K3ProdField.F_DOCUMENT_STATUS: + po.setErpDocumentStatus(row.getString(i)); break; - case K3ProdMainField.F_DATE: - po.setBillDate(DateUtils.toLocalDate(row.getDate(i))); + case K3ProdField.F_CREATE_DATE: + po.setErpCreateDate(DateUtils.toLocalDateTime(row.getDate(i))); break; - case K3ProdMainField.F_DOCUMENT_STATUS: - po.setStatus(row.getString(i)); + case K3ProdField.F_MODIFY_DATE: + po.setErpModifyDate(DateUtils.toLocalDateTime(row.getDate(i))); + break; + case K3ProdField.F_DESCRIPTION: + po.setErpDescription(row.getString(i)); + break; + case K3ProdField.F_DATE: + po.setErpDate(DateUtils.toLocalDateTime(row.getDate(i))); + break; + case K3ProdField.F_IS_REWORK: + po.setErpIsRework(row.getBoolean(i)); + break; + case K3ProdField.F_ROW_ID: + po.setErpRowId(row.getString(i)); + break; + case K3ProdField.F_MEMO_ITEM: + po.setErpMemoItem(row.getString(i)); + break; + case K3ProdField.F_CONVEY_DATE: + po.setErpConveyDate(DateUtils.toLocalDateTime(row.getDate(i))); + break; + case K3ProdField.F_STATUS: + po.setErpStatus(row.getString(i)); + break; + case K3ProdField.F_WORK_SHOP_ID: + po.setErpWorkShopId(row.getString(i)); + break; + case K3ProdField.F_REQ_SRC: + po.setErpReqSrc(row.getString(i)); + break; + case K3ProdField.F_BASE_UNIT_QTY: + po.setErpBaseUnitQty(row.getBigDecimal(i)); + break; + case K3ProdField.F_QTY: + po.setErpQty(row.getBigDecimal(i)); + break; + case K3ProdField.F_UNIT_ID: + po.setErpUnitId(row.getString(i)); break; default: break; } diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/service/impl/ProdOrderServiceImpl.java b/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/service/impl/ProdOrderServiceImpl.java index 1afd120..47a5cd7 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/service/impl/ProdOrderServiceImpl.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/yh/prodOrder/service/impl/ProdOrderServiceImpl.java @@ -1,12 +1,11 @@ package com.ruoyi.web.yh.prodOrder.service.impl; -import java.util.Collections; +import java.util.Arrays; import java.util.List; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import com.alibaba.fastjson2.JSONArray; -import com.alibaba.fastjson2.JSONObject; import com.github.pagehelper.PageHelper; import com.ruoyi.common.core.redis.RedisLock; import com.ruoyi.common.core.redis.enums.RedisLockKey; @@ -14,7 +13,9 @@ import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.k3cloud.business.prodOrder.service.K3ProdOrderService; +import com.ruoyi.k3cloud.business.prodOrder.constants.K3ProdField; +import com.ruoyi.k3cloud.constants.K3FormIds; +import com.ruoyi.k3cloud.service.K3Service; import com.ruoyi.web.yh.prodOrder.service.ProdOrderConverter; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -40,7 +41,7 @@ public class ProdOrderServiceImpl implements ProdOrderService private ProdOrderMapper prodOrderMapper; @Autowired - private K3ProdOrderService k3ProdOrderService; + private K3Service k3Service; @Autowired private ProdOrderConverter prodOrderConverter; @@ -126,11 +127,31 @@ public class ProdOrderServiceImpl implements ProdOrderService @Override public int sync() { + // 查询字段 + List fieldKeys = Arrays.asList( + K3ProdField.FID, + K3ProdField.F_BILL_NO, + K3ProdField.F_DOCUMENT_STATUS, + K3ProdField.F_CREATE_DATE, + K3ProdField.F_MODIFY_DATE, + K3ProdField.F_DESCRIPTION, + K3ProdField.F_DATE, + K3ProdField.F_IS_REWORK, + K3ProdField.F_ROW_ID, + K3ProdField.F_MEMO_ITEM, + K3ProdField.F_CONVEY_DATE, + K3ProdField.F_STATUS, + K3ProdField.F_WORK_SHOP_ID, + K3ProdField.F_REQ_SRC, + K3ProdField.F_BASE_UNIT_QTY, + K3ProdField.F_QTY, + K3ProdField.F_UNIT_ID + ); // 查询ERP数据 - List erpList = k3ProdOrderService.selectList(0, 2000); + List erpList = k3Service.selectList(K3FormIds.PROD_ORDER, fieldKeys,0, 2000); // 转为PO - List prodOrderList = prodOrderConverter.toPoByErpList(K3ProdOrderService.MAIN_FIELD_KEYS, erpList); + List prodOrderList = prodOrderConverter.toPoByErpList(fieldKeys, erpList); // 新增或修改 return this.syncByBillNo(prodOrderList); @@ -147,7 +168,7 @@ public class ProdOrderServiceImpl implements ProdOrderService return null; } ProdOrderQuery query = new ProdOrderQuery(); - query.setEqBillNo(billNo); + query.setEqErpBillNo(billNo); return this.selectOne(query); } @@ -186,15 +207,15 @@ public class ProdOrderServiceImpl implements ProdOrderService private int syncByBillNo(ProdOrder prodOrder) { String errorMsg = "成功"; try { - if (prodOrder == null || StringUtils.isBlank(prodOrder.getBillNo())) { + if (prodOrder == null || StringUtils.isBlank(prodOrder.getErpBillNo())) { throw new ServiceException("参数错误"); } - String lockKey = prodOrder.getErpId(); + String lockKey = prodOrder.getErpRowId(); ServiceUtil.assertion(!redisLock.lock(RedisLockKey.SYNC_PROD_BILL, lockKey), "当前生产订单正在处理中,请稍后重试"); try { // 若数据库中没有,则新增,否则修改 - ProdOrderVO old = this.selectByErpId(prodOrder.getErpId()); + ProdOrderVO old = this.selectByErpRowId(prodOrder.getErpRowId()); if (old == null) { return this.insertProdOrder(prodOrder); } else { @@ -204,7 +225,6 @@ public class ProdOrderServiceImpl implements ProdOrderService } finally { redisLock.unlock(RedisLockKey.SYNC_PROD_BILL, lockKey); } - } catch (Exception e) { errorMsg = e.getMessage(); return 0; @@ -214,9 +234,18 @@ public class ProdOrderServiceImpl implements ProdOrderService } } + private ProdOrderVO selectByErpRowId(String erpRowId) { + if (StringUtils.isBlank(erpRowId)) { + return null; + } + ProdOrderQuery query = new ProdOrderQuery(); + query.setEqErpRowId(erpRowId); + return selectOne(query); + } + private ProdOrderVO selectByErpId(String erpId) { ProdOrderQuery query = new ProdOrderQuery(); - query.setErpId(erpId); + query.setEqErpId(erpId); return this.selectOne(query); } } diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/yh/report/controller/ReportController.java b/ruoyi-web/src/main/java/com/ruoyi/web/yh/report/controller/ReportController.java index eb5388d..4adda63 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/yh/report/controller/ReportController.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/yh/report/controller/ReportController.java @@ -4,7 +4,9 @@ import java.util.Collections; import java.util.List; import javax.servlet.http.HttpServletResponse; +import com.ruoyi.common.constants.LogTitle; import com.ruoyi.common.core.validate.ValidGroup; +import com.ruoyi.common.enums.LogBizType; import com.ruoyi.web.yh.report.domain.bo.ReportBO; import com.ruoyi.web.yh.report.domain.dto.ReportVerifyDTO; import com.ruoyi.web.yh.report.service.ReportAssembler; @@ -43,6 +45,8 @@ public class ReportController extends BaseController @Autowired private ReportAssembler reportAssembler; + private static final String LOG_TITLE = LogTitle.REPORT; + /** * 查询报表列表 */ @@ -60,7 +64,7 @@ public class ReportController extends BaseController * 导出报表列表 */ @PreAuthorize("@ss.hasPermi('yh:report:export')") - @Log(title = "车间报表导出", businessType = BusinessType.EXPORT) + @Log(title = LOG_TITLE, businessType = BusinessType.EXPORT, bizType = LogBizType.REPORT) @PostMapping("/export") public void export(HttpServletResponse response, ReportQuery query) { @@ -90,7 +94,7 @@ public class ReportController extends BaseController * 新增报表 */ @PreAuthorize("@ss.hasPermi('yh:report:add')") - @Log(title = "车间报表新增", businessType = BusinessType.INSERT) + @Log(title = LOG_TITLE, businessType = BusinessType.INSERT, bizType = LogBizType.REPORT, bizIdName = "arg0") @PostMapping public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) ReportVO data) { @@ -102,7 +106,7 @@ public class ReportController extends BaseController * 修改报表 */ @PreAuthorize("@ss.hasPermi('yh:report:edit')") - @Log(title = "车间报表修改", businessType = BusinessType.UPDATE) + @Log(title = LOG_TITLE, businessType = BusinessType.UPDATE, bizType = LogBizType.REPORT, bizIdName = "arg0") @PutMapping public AjaxResult edit(@RequestBody @Validated(ValidGroup.Update.class) ReportVO data) { ReportBO bo = reportConverter.toBoByUpdate(data); @@ -113,7 +117,7 @@ public class ReportController extends BaseController * 删除报表 */ @PreAuthorize("@ss.hasPermi('yh:report:remove')") - @Log(title = "车间报表删除", businessType = BusinessType.DELETE) + @Log(title = LOG_TITLE, businessType = BusinessType.DELETE, bizType = LogBizType.REPORT, bizIdName = "arg0") @DeleteMapping("/{reportIds}") public AjaxResult remove(@PathVariable Long[] reportIds) { @@ -121,21 +125,21 @@ public class ReportController extends BaseController } @PreAuthorize("@ss.hasPermi('yh:report:verify')") - @Log(title = "车间报表审核", businessType = BusinessType.VERIFY) + @Log(title = LOG_TITLE, businessType = BusinessType.VERIFY, bizType = LogBizType.REPORT, bizIdName = "arg0") @PutMapping("/verify") public AjaxResult verify(@RequestBody @Validated ReportVerifyDTO dto) { return toAjax(reportService.verify(dto, getUserId())); } @PreAuthorize("@ss.hasPermi('yh:report:cancel')") - @Log(title = "车间报表取消提交", businessType = BusinessType.CANCEL) + @Log(title = LOG_TITLE, businessType = BusinessType.CANCEL, bizType = LogBizType.REPORT, bizIdName = "arg0") @PutMapping("/{reportId}/cancel") public AjaxResult cancel(@PathVariable Long reportId) { return toAjax(reportService.cancel(reportId)); } @PreAuthorize("@ss.hasPermi('yh:report:submit')") - @Log(title = "车间报表提交", businessType = BusinessType.SUBMIT) + @Log(title = LOG_TITLE, businessType = BusinessType.SUBMIT, bizType = LogBizType.REPORT, bizIdName = "arg0") @PutMapping("/{reportId}/submit") public AjaxResult submit(@PathVariable Long reportId) { return toAjax(reportService.submit(reportId)); diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/yh/report/domain/Report.java b/ruoyi-web/src/main/java/com/ruoyi/web/yh/report/domain/Report.java index e430bfd..349061f 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/yh/report/domain/Report.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/yh/report/domain/Report.java @@ -5,6 +5,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.framework.web.domain.log.LogBizParam; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -23,7 +24,7 @@ import javax.validation.constraints.NotNull; * @date 2024-10-18 */ @Data -public class Report extends BaseEntity +public class Report extends BaseEntity implements LogBizParam { private static final long serialVersionUID = 1L; @@ -74,4 +75,12 @@ public class Report extends BaseEntity @NotNull(message = "总金额不能为空") @Min(value = 0, message = "总金额必须大于0") private BigDecimal totalAmount; + + /** + * 获取日志业务ID + */ + @Override + public Object logBizId() { + return this.getReportId(); + } } diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/yh/report/domain/ReportVO.java b/ruoyi-web/src/main/java/com/ruoyi/web/yh/report/domain/ReportVO.java index aa1e016..e822253 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/yh/report/domain/ReportVO.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/yh/report/domain/ReportVO.java @@ -1,5 +1,6 @@ package com.ruoyi.web.yh.report.domain; +import com.ruoyi.framework.web.domain.log.LogBizParam; import com.ruoyi.web.yh.reportProd.domain.ReportProdVO; import io.swagger.annotations.ApiModelProperty; import lombok.Data;