对接生产订单(一半)

This commit is contained in:
磷叶 2024-11-11 18:03:04 +08:00
parent 07dc59b3fe
commit 73c1b761a7
27 changed files with 637 additions and 599 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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<String> 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());
}
/**

View File

@ -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();
}

View File

@ -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<String> 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;
}

View File

@ -4,36 +4,77 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.SysOperLogMapper">
<resultMap type="SysOperLog" id="SysOperLogResult">
<id property="operId" column="oper_id" />
<result property="title" column="title" />
<result property="businessType" column="business_type" />
<result property="method" column="method" />
<result property="requestMethod" column="request_method" />
<result property="operatorType" column="operator_type" />
<result property="operName" column="oper_name" />
<result property="deptName" column="dept_name" />
<result property="operUrl" column="oper_url" />
<result property="operIp" column="oper_ip" />
<result property="operLocation" column="oper_location" />
<result property="operParam" column="oper_param" />
<result property="jsonResult" column="json_result" />
<result property="status" column="status" />
<result property="errorMsg" column="error_msg" />
<result property="operTime" column="oper_time" />
<result property="costTime" column="cost_time" />
<resultMap type="SysOperLog" id="SysOperLogResult" autoMapping="true">
<result column="biz_ids" property="bizIds" typeHandler="com.ruoyi.common.mybatis.typehandler.StringSplitListTypeHandler"/>
</resultMap>
<sql id="selectOperLogVo">
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
</sql>
<insert id="insertOperlog" parameterType="SysOperLog">
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}
)
</insert>
<select id="selectOperLogList" parameterType="SysOperLog" resultMap="SysOperLogResult">
<include refid="selectOperLogVo"/>
<where>
@ -50,7 +91,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND business_type in
<foreach collection="businessTypes" item="businessType" open="(" separator="," close=")">
#{businessType}
</foreach>
</foreach>
</if>
<if test="status != null">
AND status = #{status}
@ -67,21 +108,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
order by oper_id desc
</select>
<delete id="deleteOperLogByIds" parameterType="Long">
delete from sys_oper_log where oper_id in
<foreach collection="array" item="operId" open="(" separator="," close=")">
#{operId}
</foreach>
</foreach>
</delete>
<select id="selectOperLogById" parameterType="Long" resultMap="SysOperLogResult">
<include refid="selectOperLogVo"/>
where oper_id = #{operId}
</select>
<update id="cleanOperLog">
truncate table sys_oper_log
</update>
</mapper>
</mapper>

View File

@ -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 = "导入日志明细";
}

View File

@ -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"; // 明细.单位
}

View File

@ -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"; // 期初生产订单
}

View File

@ -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<String> 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<JSONArray> 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("获取云星空生产订单失败");
}
}
}

View File

@ -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";
}

View File

@ -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<JSONArray> selectList(String formId, List<String> fieldKeys, int startRow, int limit) {
return selectList(formId, fieldKeys, startRow, limit, "", "");
}
/**
* 查询列表
*/
public List<JSONArray> selectList(String formId, List<String> 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("获取云星空数据失败");
}
}
}

View File

@ -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)
{

View File

@ -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<LogImportDetailVO> 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)
{

View File

@ -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

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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());

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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
</sql>
<sql id="searchCondition">
<if test="query.id != null "> and bpo.id = #{query.id}</if>
<if test="query.erpId != null "> and bpo.erp_id = #{query.erpId}</if>
<if test="query.billNo != null and query.billNo != ''"> and bpo.bill_no like concat('%', #{query.billNo}, '%')</if>
<if test="query.eqBillNo != null and query.eqBillNo != ''"> and bpo.bill_no = #{query.eqBillNo}</if>
<if test="query.type != null and query.type != ''"> and bpo.type = #{query.type}</if>
<if test="query.billDate != null "> and bpo.bill_date = #{query.billDate}</if>
<if test="query.status != null and query.status != ''"> and bpo.status = #{query.status}</if>
<if test="query.transferStatus != null and query.transferStatus != ''"> and bpo.transfer_status = #{query.transferStatus}</if>
<if test="query.pickStatus != null and query.pickStatus != ''"> and bpo.pick_status = #{query.pickStatus}</if>
<if test="query.materialName != null and query.materialName != ''"> and bpo.material_name like concat('%', #{query.materialName}, '%')</if>
<if test="query.spec != null and query.spec != ''"> and bpo.spec like concat('%', #{query.spec}, '%')</if>
<if test="query.unit != null and query.unit != ''"> and bpo.unit = #{query.unit}</if>
<if test="query.num != null "> and bpo.num = #{query.num}</if>
<if test="query.bizStatus != null and query.bizStatus != ''"> and bpo.biz_status = #{query.bizStatus}</if>
<if test="query.batchNo != null and query.batchNo != ''"> and bpo.batch_no = #{query.batchNo}</if>
<if test="query.releaseTime != null "> and bpo.release_time = #{query.releaseTime}</if>
<if test="query.sourceNo != null and query.sourceNo != ''"> and bpo.source_no like concat('%', #{query.sourceNo}, '%')</if>
<if test="query.demandBill != null and query.demandBill != ''"> and bpo.demand_bill like concat('%', #{query.demandBill}, '%')</if>
<if test="query.planTrackNo != null and query.planTrackNo != ''"> and bpo.plan_track_no = #{query.planTrackNo}</if>
<if test="query.productType != null and query.productType != ''"> and bpo.product_type = #{query.productType}</if>
<if test="query.materialNo != null and query.materialNo != ''"> and bpo.material_no like concat('%', #{query.materialNo}, '%')</if>
<if test="query.quaStore != null "> and bpo.qua_store = #{query.quaStore}</if>
<if test="query.erpId != null and query.erpId != ''"> and bpo.erp_id like concat('%', #{query.erpId}, '%')</if>
<if test="query.eqErpId != null and query.eqErpId != ''"> and bpo.erp_id = #{query.eqErpId}</if>
<if test="query.erpBillNo != null and query.erpBillNo != ''"> and bpo.erp_bill_no like concat('%', #{query.erpBillNo}, '%')</if>
<if test="query.eqErpBillNo != null and query.eqErpBillNo != ''"> and bpo.erp_bill_no = #{query.eqErpBillNo}</if>
<if test="query.erpDocumentStatus != null and query.erpDocumentStatus != ''"> and bpo.erp_document_status = #{query.erpDocumentStatus}</if>
<if test="query.erpDescription != null and query.erpDescription != ''"> and bpo.erp_description like concat('%', #{query.erpDescription}, '%')</if>
<if test="query.erpIsRework != null"> and bpo.erp_is_rework = #{query.erpIsRework}</if>
<if test="query.erpRowId != null and query.erpRowId != ''"> and bpo.erp_row_id like concat('%', #{query.erpRowId}, '%')</if>
<if test="query.eqErpRowId != null and query.eqErpRowId != ''"> and bpo.erp_row_id = #{query.eqErpRowId}</if>
<if test="query.erpMemoItem != null and query.erpMemoItem != ''"> and bpo.erp_memo_item like concat('%', #{query.erpMemoItem}, '%')</if>
<if test="query.erpStatus != null and query.erpStatus != ''"> and bpo.erp_status = #{query.erpStatus}</if>
<if test="query.erpWorkShopId != null and query.erpWorkShopId != ''"> and bpo.erp_work_shop_id like concat('%', #{query.erpWorkShopId}, '%')</if>
<if test="query.erpReqSrc != null and query.erpReqSrc != ''"> and bpo.erp_req_src = #{query.erpReqSrc}</if>
<if test="query.deptId != null "> and bpo.dept_id = #{query.deptId}</if>
<if test="query.erpDeptId != null and query.erpDeptId != ''"> and bpo.erp_dept_id = #{query.erpDeptId}</if>
${query.params.dataScope}
</sql>
@ -76,60 +62,48 @@
where bpo.id = #{id}
</select>
<insert id="insertProdOrder" parameterType="ProdOrder">
<insert id="insertProdOrder" parameterType="ProdOrder" useGeneratedKeys="true" keyProperty="id">
insert into bst_prod_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="erpId != null">erp_id,</if>
<if test="billNo != null and billNo != ''">bill_no,</if>
<if test="type != null">type,</if>
<if test="billDate != null">bill_date,</if>
<if test="status != null">`status`,</if>
<if test="transferStatus != null">transfer_status,</if>
<if test="pickStatus != null">pick_status,</if>
<if test="materialName != null">material_name,</if>
<if test="spec != null">spec,</if>
<if test="unit != null">unit,</if>
<if test="num != null">num,</if>
<if test="bizStatus != null">biz_status,</if>
<if test="batchNo != null">batch_no,</if>
<if test="remark != null">remark,</if>
<if test="releaseTime != null">release_time,</if>
<if test="sourceNo != null">source_no,</if>
<if test="demandBill != null">demand_bill,</if>
<if test="planTrackNo != null">plan_track_no,</if>
<if test="productType != null">product_type,</if>
<if test="materialNo != null">material_no,</if>
<if test="quaStore != null">qua_store,</if>
<if test="erpId != null and erpId != ''">erp_id,</if>
<if test="erpBillNo != null and erpBillNo != ''">erp_bill_no,</if>
<if test="erpDocumentStatus != null">erp_document_status,</if>
<if test="erpCreateDate != null">erp_create_date,</if>
<if test="erpModifyDate != null">erp_modify_date,</if>
<if test="erpDescription != null">erp_description,</if>
<if test="erpDate != null">erp_date,</if>
<if test="erpIsRework != null">erp_is_rework,</if>
<if test="erpRowId != null and erpRowId != ''">erp_row_id,</if>
<if test="erpMemoItem != null">erp_memo_item,</if>
<if test="erpConveyDate != null">erp_convey_date,</if>
<if test="erpStatus != null">erp_status,</if>
<if test="erpWorkShopId != null">erp_work_shop_id,</if>
<if test="erpReqSrc != null">erp_req_src,</if>
<if test="erpQty != null">erp_qty,</if>
<if test="deptId != null">dept_id,</if>
<if test="erpDeptId != null">erp_dept_id,</if>
<if test="erpBaseUnitQty != null">erp_base_unit_qty,</if>
<if test="erpUnitId != null">erp_unit_id,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="erpId != null">#{erpId},</if>
<if test="billNo != null and billNo != ''">#{billNo},</if>
<if test="type != null">#{type},</if>
<if test="billDate != null">#{billDate},</if>
<if test="status != null">#{status},</if>
<if test="transferStatus != null">#{transferStatus},</if>
<if test="pickStatus != null">#{pickStatus},</if>
<if test="materialName != null">#{materialName},</if>
<if test="spec != null">#{spec},</if>
<if test="unit != null">#{unit},</if>
<if test="num != null">#{num},</if>
<if test="bizStatus != null">#{bizStatus},</if>
<if test="batchNo != null">#{batchNo},</if>
<if test="remark != null">#{remark},</if>
<if test="releaseTime != null">#{releaseTime},</if>
<if test="sourceNo != null">#{sourceNo},</if>
<if test="demandBill != null">#{demandBill},</if>
<if test="planTrackNo != null">#{planTrackNo},</if>
<if test="productType != null">#{productType},</if>
<if test="materialNo != null">#{materialNo},</if>
<if test="quaStore != null">#{quaStore},</if>
<if test="erpId != null and erpId != ''">#{erpId},</if>
<if test="erpBillNo != null and erpBillNo != ''">#{erpBillNo},</if>
<if test="erpDocumentStatus != null">#{erpDocumentStatus},</if>
<if test="erpCreateDate != null">#{erpCreateDate},</if>
<if test="erpModifyDate != null">#{erpModifyDate},</if>
<if test="erpDescription != null">#{erpDescription},</if>
<if test="erpDate != null">#{erpDate},</if>
<if test="erpIsRework != null">#{erpIsRework},</if>
<if test="erpRowId != null and erpRowId != ''">#{erpRowId},</if>
<if test="erpMemoItem != null">#{erpMemoItem},</if>
<if test="erpConveyDate != null">#{erpConveyDate},</if>
<if test="erpStatus != null">#{erpStatus},</if>
<if test="erpWorkShopId != null">#{erpWorkShopId},</if>
<if test="erpReqSrc != null">#{erpReqSrc},</if>
<if test="erpQty != null">#{erpQty},</if>
<if test="deptId != null">#{deptId},</if>
<if test="erpDeptId != null">#{erpDeptId},</if>
<if test="erpBaseUnitQty != null">#{erpBaseUnitQty},</if>
<if test="erpUnitId != null">#{erpUnitId},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
@ -143,29 +117,24 @@
</update>
<sql id="updateColumns">
<if test="data.erpId != null">erp_id = #{data.erpId},</if>
<if test="data.billNo != null and data.billNo != ''">bill_no = #{data.billNo},</if>
<if test="data.type != null">type = #{data.type},</if>
<if test="data.billDate != null">bill_date = #{data.billDate},</if>
<if test="data.status != null">`status` = #{data.status},</if>
<if test="data.transferStatus != null">transfer_status = #{data.transferStatus},</if>
<if test="data.pickStatus != null">pick_status = #{data.pickStatus},</if>
<if test="data.materialName != null">material_name = #{data.materialName},</if>
<if test="data.spec != null">spec = #{data.spec},</if>
<if test="data.unit != null">unit = #{data.unit},</if>
<if test="data.num != null">num = #{data.num},</if>
<if test="data.bizStatus != null">biz_status = #{data.bizStatus},</if>
<if test="data.batchNo != null">batch_no = #{data.batchNo},</if>
<if test="data.remark != null">remark = #{data.remark},</if>
<if test="data.releaseTime != null">release_time = #{data.releaseTime},</if>
<if test="data.sourceNo != null">source_no = #{data.sourceNo},</if>
<if test="data.demandBill != null">demand_bill = #{data.demandBill},</if>
<if test="data.planTrackNo != null">plan_track_no = #{data.planTrackNo},</if>
<if test="data.productType != null">product_type = #{data.productType},</if>
<if test="data.materialNo != null">material_no = #{data.materialNo},</if>
<if test="data.quaStore != null">qua_store = #{data.quaStore},</if>
<if test="data.erpId != null and data.erpId != ''">erp_id = #{data.erpId},</if>
<if test="data.erpBillNo != null and data.erpBillNo != ''">erp_bill_no = #{data.erpBillNo},</if>
<if test="data.erpDocumentStatus != null">erp_document_status = #{data.erpDocumentStatus},</if>
<if test="data.erpCreateDate != null">erp_create_date = #{data.erpCreateDate},</if>
<if test="data.erpModifyDate != null">erp_modify_date = #{data.erpModifyDate},</if>
<if test="data.erpDescription != null">erp_description = #{data.erpDescription},</if>
<if test="data.erpDate != null">erp_date = #{data.erpDate},</if>
<if test="data.erpIsRework != null">erp_is_rework = #{data.erpIsRework},</if>
<if test="data.erpRowId != null and data.erpRowId != ''">erp_row_id = #{data.erpRowId},</if>
<if test="data.erpMemoItem != null">erp_memo_item = #{data.erpMemoItem},</if>
<if test="data.erpConveyDate != null">erp_convey_date = #{data.erpConveyDate},</if>
<if test="data.erpStatus != null">erp_status = #{data.erpStatus},</if>
<if test="data.erpWorkShopId != null">erp_work_shop_id = #{data.erpWorkShopId},</if>
<if test="data.erpReqSrc != null">erp_req_src = #{data.erpReqSrc},</if>
<if test="data.erpQty != null">erp_qty = #{data.erpQty},</if>
<if test="data.deptId != null">dept_id = #{data.deptId},</if>
<if test="data.erpDeptId != null">erp_dept_id = #{data.erpDeptId},</if>
<if test="data.erpBaseUnitQty != null">erp_base_unit_qty = #{data.erpBaseUnitQty},</if>
<if test="data.erpUnitId != null">erp_unit_id = #{data.erpUnitId},</if>
<if test="data.createTime != null">create_time = #{data.createTime},</if>
</sql>

View File

@ -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;
}

View File

@ -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<String> 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<JSONArray> erpList = k3ProdOrderService.selectList(0, 2000);
List<JSONArray> erpList = k3Service.selectList(K3FormIds.PROD_ORDER, fieldKeys,0, 2000);
// 转为PO
List<ProdOrder> prodOrderList = prodOrderConverter.toPoByErpList(K3ProdOrderService.MAIN_FIELD_KEYS, erpList);
List<ProdOrder> 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);
}
}

View File

@ -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));

View File

@ -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();
}
}

View File

@ -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;