库存日志

This commit is contained in:
sxu 2024-08-05 16:01:47 +08:00
parent 1666b6fafb
commit 80b7d8dec0
15 changed files with 600 additions and 79 deletions

View File

@ -1,4 +1,4 @@
package com.bonus.sgzb.material.domain;
package com.bonus.sgzb.base.api.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

View File

@ -1,4 +1,4 @@
package com.bonus.sgzb.material.domain;
package com.bonus.sgzb.base.api.domain;
import com.bonus.sgzb.common.core.web.domain.BaseEntity;
import io.swagger.annotations.ApiModel;

View File

@ -1,6 +1,7 @@
package com.bonus.sgzb.system.api;
import com.bonus.sgzb.system.api.domain.BmNumLogs;
import com.bonus.sgzb.system.api.domain.BmStorageLog;
import com.bonus.sgzb.system.api.domain.SysOperLog;
import com.bonus.sgzb.system.api.factory.RemoteLogFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
@ -12,6 +13,8 @@ import com.bonus.sgzb.common.core.constant.ServiceNameConstants;
import com.bonus.sgzb.common.core.domain.R;
import com.bonus.sgzb.system.api.domain.SysLogininfor;
import java.util.List;
/**
* 日志服务
*
@ -41,6 +44,17 @@ public interface RemoteLogService
public R<Boolean> saveNumberLog(@RequestBody BmNumLogs bmNumLogs, @RequestHeader(SecurityConstants.FROM_SOURCE) String source) throws Exception;
/**
* 保存物资记录日志
* @param bmStorageLogList 物资信息
* @param source 请求来源
* @return 结果
* @throws Exception 异常信息
*/
@PostMapping("/bm_storage_logs")
public R<Boolean> batchInsert(@RequestBody List<BmStorageLog> bmStorageLogList, @RequestHeader(SecurityConstants.FROM_SOURCE) String source) throws Exception;
/**
* 保存访问记录
*

View File

@ -0,0 +1,138 @@
package com.bonus.sgzb.system.api.domain;
import com.bonus.sgzb.common.core.annotation.Excel;
import com.bonus.sgzb.common.core.web.domain.BaseEntity;
import lombok.Getter;
import lombok.Setter;
/**
* @author syruan
*/
@Getter
@Setter
public class BmStorageLog extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* ID
*/
@Excel(name = "ID")
private Integer id;
/**
* 模块名称/title标题
*/
@Excel(name = "模块名称/title标题")
private String modelTitle;
/**
* 接口地址/请求方法
*/
@Excel(name = "接口地址/请求方法")
private String method;
/** 请求方式 */
@Excel(name = "请求方式")
private String requestMethod;
/**
* 实例
*/
@Excel(name = "实例/任务")
private String taskId;
/**
* 任务名称
*/
private String taskName;
/**
* 规格id
*/
@Excel(name = "规格id")
private Integer typeId;
/**
* 规格名称
*/
private String typeName;
/**
* 父级规格名称
*/
private String typeParentName;
@Excel(name = "操作前库存")
private int preStoreNum;
@Excel(name = "入库数量")
private int inNum;
@Excel(name = "出库数量")
private int outNum;
@Excel(name = "退库数量")
private int backNum;
@Excel(name = "合格数量")
private int passNum;
@Excel(name = "维修数量")
private int maintenanceNum;
@Excel(name = "报废数量")
private int scrapNum;
@Excel(name = "操作后库存")
private int postStoreNum;
@Excel(name = "出库类型 0编码出库 1数量出库 2成套出库")
private String manageType;
/**
* 响应内容/状态码/返回参数
*/
@Excel(name = "响应内容/状态码/返回参数")
private int resultCode;
/**
* 响应内容/状态码/返回参数
*/
@Excel(name = "响应内容/状态码/返回参数")
private String resultMsg;
/**
* 创建人
*/
@Excel(name = "创建人")
private String creator;
/**
* 备注
*/
@Excel(name = "备注")
private String remark;
@Excel(name = "型号")
private String typeModelName;
@Excel(name = "状态")
private int status;
@Excel(name = "返回结果")
private String jsonResult;
// private String createBy;
// private String parentId;
// private String inputNum;
//
// @Excel(name = "http返回消息")
// private String msg;
//
// @Excel(name = "http返回码")
// private String code;
}

View File

@ -1,6 +1,7 @@
package com.bonus.sgzb.system.api.factory;
import com.bonus.sgzb.system.api.domain.BmNumLogs;
import com.bonus.sgzb.system.api.domain.BmStorageLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
@ -10,6 +11,8 @@ import com.bonus.sgzb.system.api.RemoteLogService;
import com.bonus.sgzb.system.api.domain.SysLogininfor;
import com.bonus.sgzb.system.api.domain.SysOperLog;
import java.util.List;
/**
* 日志服务降级处理
*
@ -37,6 +40,11 @@ public class RemoteLogFallbackFactory implements FallbackFactory<RemoteLogServic
return R.fail("保存物资库存日志失败:" + throwable.getMessage());
}
@Override
public R<Boolean> batchInsert(List<BmStorageLog> bmStorageLogList, String source) throws Exception {
return R.fail("保存物资库存日志失败:" + throwable.getMessage());
}
@Override
public R<Boolean> saveLogininfor(SysLogininfor sysLogininfor, String source)
{

View File

@ -1,11 +1,11 @@
package com.bonus.sgzb.common.log.aspect;
import java.util.Collection;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.bonus.sgzb.base.api.domain.MachIneDto;
import com.bonus.sgzb.base.api.domain.SavePutInfoDto;
import com.bonus.sgzb.common.core.constant.SecurityConstants;
import com.bonus.sgzb.common.core.domain.R;
import com.bonus.sgzb.common.log.annotation.Log;
@ -14,6 +14,7 @@ import com.bonus.sgzb.common.log.filter.PropertyPreExcludeFilter;
import com.bonus.sgzb.common.log.service.AsyncLogService;
import com.bonus.sgzb.system.api.RemoteUserService;
import com.bonus.sgzb.system.api.domain.BmNumLogs;
import com.bonus.sgzb.system.api.domain.BmStorageLog;
import com.bonus.sgzb.system.api.model.LoginUser;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.ObjectUtils;
@ -147,33 +148,43 @@ public class LogAspect
protected void handleMaterialLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult) {
try
{
// *========数据库物资日志=========*//
BmNumLogs bmNumLogs = new BmNumLogs();
bmNumLogs.setStatus(BusinessStatus.SUCCESS.ordinal());
List<BmStorageLog> bmStorageLogList = new ArrayList<>();
// 请求的地址
bmNumLogs.setMethod(StringUtils.substring(Objects.requireNonNull(ServletUtils.getRequest()).getRequestURI(), 0, 255));
String username = SecurityUtils.getUsername();
R<LoginUser> userInfo = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
if (ObjectUtils.isNotEmpty(userInfo))
{
bmNumLogs.setCreator(userInfo.getData().getSysUser().getNickName());
}
if (e != null) {
bmNumLogs.setStatus(BusinessStatus.FAIL.ordinal());
bmNumLogs.setJsonResult(StringUtils.substring(e.getMessage(), 0, 2000));
}
// 设置方法名称
String className = joinPoint.getTarget().getClass().getName();
String methodName = joinPoint.getSignature().getName();
bmNumLogs.setModelTitle(className + "." + methodName + "()");
// 设置请求方式
bmNumLogs.setRequestMethod(ServletUtils.getRequest().getMethod());
// 处理设置注解上的参数
getControllerMethodDescriptionByMaterial(joinPoint, controllerLog, bmNumLogs, jsonResult);
setRequestValue(joinPoint, bmStorageLogList, controllerLog);
for (BmStorageLog bmStorageLog : bmStorageLogList) {
bmStorageLog.setStatus(BusinessStatus.SUCCESS.ordinal());
// 请求的地址
bmStorageLog.setMethod(StringUtils.substring(Objects.requireNonNull(ServletUtils.getRequest()).getRequestURI(), 0, 255));
String username = SecurityUtils.getUsername();
R<LoginUser> userInfo = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
if (ObjectUtils.isNotEmpty(userInfo))
{
bmStorageLog.setCreator(userInfo.getData().getSysUser().getNickName());
}
if (e != null) {
bmStorageLog.setStatus(BusinessStatus.FAIL.ordinal());
bmStorageLog.setJsonResult(StringUtils.substring(e.getMessage(), 0, 2000));
}
// 设置方法名称
String className = joinPoint.getTarget().getClass().getName();
String methodName = joinPoint.getSignature().getName();
bmStorageLog.setModelTitle(className + "." + methodName + "()");
// 设置请求方式
bmStorageLog.setRequestMethod(ServletUtils.getRequest().getMethod());
bmStorageLog.setModelTitle(controllerLog.title());
if (StringUtils.isNotNull(jsonResult)) {
bmStorageLog.setJsonResult(StringUtils.substring(JSON.toJSONString(jsonResult), 0, 2000));
}
}
// 保存数据库
asyncLogService.saveNumLog(bmNumLogs);
asyncLogService.batchInsert(bmStorageLogList);
}
catch (Exception exp)
{
@ -215,24 +226,22 @@ public class LogAspect
}
}
/**
* 获取注解中对方法的描述信息 用于Controller层注解
*
* @param log 日志
* @param materialLog 物资日志
* @throws Exception
*/
public void getControllerMethodDescriptionByMaterial(JoinPoint joinPoint, Log log, BmNumLogs materialLog, Object jsonResult) throws Exception
{
// 设置标题
materialLog.setModelTitle(log.title());
// 获取参数的信息传入到数据库中
setRequestValue(joinPoint, materialLog, log.excludeParamNames());
// 保存response参数和值
if (StringUtils.isNotNull(jsonResult)) {
materialLog.setJsonResult(StringUtils.substring(JSON.toJSONString(jsonResult), 0, 2000));
}
}
// /**
// * 获取注解中对方法的描述信息 用于Controller层注解
// *
// * @param log 日志
// * @param bmStorageLogList 物资日志
// * @throws Exception
// */
// public void getControllerMethodDescriptionByMaterial(JoinPoint joinPoint, Log log, List<BmStorageLog> bmStorageLogList, Object jsonResult) throws Exception
// {
// // 设置标题
//
// // 获取参数的信息传入到数据库中
// setRequestValue(joinPoint, materialLog, log.excludeParamNames());
// // 保存response参数和值
//
// }
/**
* 获取请求的参数放到log中
@ -256,36 +265,21 @@ public class LogAspect
/**
* 获取请求的参数放到log中
*
* @param numLog 物资日志
* @param bmStorageLogList 物资日志
* @throws Exception 异常
*/
private void setRequestValue(JoinPoint joinPoint, BmNumLogs numLog, String[] excludeParamNames) throws Exception {
String requestMethod = numLog.getRequestMethod();
private void setRequestValue(JoinPoint joinPoint, List<BmStorageLog> bmStorageLogList, Log controllerLog) throws Exception {
String requestMethod = ServletUtils.getRequest().getMethod();
Map<?, ?> paramsMap = ServletUtils.getParamMap(ServletUtils.getRequest());
if (StringUtils.isEmpty(paramsMap)) {
if ((HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod))){
String params = argsArrayToString(joinPoint.getArgs(), excludeParamNames);
numLog.setDescription(StringUtils.substring(params, 0, 2000));
}
} else {
if (paramsMap.containsKey("num")) {
if (paramsMap.get("num") instanceof Integer) {
numLog.setNum(String.valueOf(paramsMap.get("num")));
} else if (paramsMap.get("num") instanceof String) {
numLog.setNum((String) paramsMap.get("num"));
if (StringUtils.isEmpty(paramsMap) && (HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod))) {
if (joinPoint.getArgs()[0] instanceof SavePutInfoDto) {
SavePutInfoDto savePutInfoDto = (SavePutInfoDto) joinPoint.getArgs()[0];
for (MachIneDto machIneDto : savePutInfoDto.getMachIneDtoList()) {
BmStorageLog bmStorageLog = new BmStorageLog();
bmStorageLog.setInNum(machIneDto.getNum().intValue());
bmStorageLogList.add(bmStorageLog);
}
}
if (paramsMap.containsKey("taskId")) {
numLog.setTaskId(String.valueOf(paramsMap.get("taskId")));
}
if (paramsMap.containsKey("typeId")) {
if (paramsMap.get("typeId") instanceof Integer) {
numLog.setTypeId((Integer) paramsMap.get("typeId"));
} else if (paramsMap.get("typeId") instanceof String) {
numLog.setTypeId(Integer.valueOf((String) paramsMap.get("typeId")));
}
}
numLog.setDescription(StringUtils.substring(JSON.toJSONString(paramsMap, excludePropertyPreFilter(excludeParamNames)), 0, 2000));
}
}

View File

@ -1,6 +1,7 @@
package com.bonus.sgzb.common.log.service;
import com.bonus.sgzb.system.api.domain.BmNumLogs;
import com.bonus.sgzb.system.api.domain.BmStorageLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@ -8,6 +9,8 @@ import com.bonus.sgzb.common.core.constant.SecurityConstants;
import com.bonus.sgzb.system.api.RemoteLogService;
import com.bonus.sgzb.system.api.domain.SysOperLog;
import java.util.List;
/**
* 异步调用日志服务
*
@ -35,4 +38,9 @@ public class AsyncLogService
public void saveNumLog(BmNumLogs bmNumLogsLog) throws Exception {
remoteLogService.saveNumberLog(bmNumLogsLog, SecurityConstants.INNER);
}
@Async
public void batchInsert(List<BmStorageLog> bmStorageLogList) throws Exception {
remoteLogService.batchInsert(bmStorageLogList, SecurityConstants.INNER);
}
}

View File

@ -1,12 +1,12 @@
package com.bonus.sgzb.material.controller;
import com.bonus.sgzb.base.api.domain.SavePutInfoDto;
import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.core.web.page.TableDataInfo;
import com.bonus.sgzb.common.log.annotation.Log;
import com.bonus.sgzb.common.log.enums.BusinessType;
import com.bonus.sgzb.material.domain.PutInStorageBean;
import com.bonus.sgzb.material.domain.SavePutInfoDto;
import com.bonus.sgzb.material.service.InventoryAndWarehousingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

View File

@ -1,10 +1,9 @@
package com.bonus.sgzb.material.mapper;
import com.bonus.sgzb.material.domain.MachIneDto;
import com.bonus.sgzb.base.api.domain.MachIneDto;
import com.bonus.sgzb.material.domain.PutInStorageBean;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;

View File

@ -1,10 +1,9 @@
package com.bonus.sgzb.material.service;
import com.bonus.sgzb.base.api.domain.SavePutInfoDto;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.material.domain.PutInStorageBean;
import com.bonus.sgzb.material.domain.SavePutInfoDto;
import java.util.List;
/**

View File

@ -1,5 +1,7 @@
package com.bonus.sgzb.material.service.impl;
import com.bonus.sgzb.base.api.domain.MachIneDto;
import com.bonus.sgzb.base.api.domain.SavePutInfoDto;
import com.bonus.sgzb.common.core.exception.ServiceException;
import com.bonus.sgzb.common.core.utils.DateUtils;
import com.bonus.sgzb.common.core.utils.StringUtils;
@ -7,9 +9,7 @@ import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.security.utils.SecurityUtils;
import com.bonus.sgzb.material.config.ExceptionEnum;
import com.bonus.sgzb.material.config.FieldGenerator;
import com.bonus.sgzb.material.domain.MachIneDto;
import com.bonus.sgzb.material.domain.PutInStorageBean;
import com.bonus.sgzb.material.domain.SavePutInfoDto;
import com.bonus.sgzb.material.mapper.InventoryAndWarehousingMapper;
import com.bonus.sgzb.material.service.InventoryAndWarehousingService;
import com.bonus.sgzb.material.vo.GlobalContants;

View File

@ -0,0 +1,53 @@
package com.bonus.sgzb.system.controller;
import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.core.web.page.TableDataInfo;
import com.bonus.sgzb.common.security.annotation.InnerAuth;
import com.bonus.sgzb.system.api.domain.BmStorageLog;
import com.bonus.sgzb.system.service.impl.BmStorageLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* (bm_storage_log)表控制层
*
* @author syruan
*/
@RestController
@RequestMapping("/bm_storage_logs")
public class BmStorageLogController extends BaseController {
/**
* 服务对象
*/
@Autowired
private BmStorageLogService bmStorageLogService;
@GetMapping("/list")
public TableDataInfo list(BmStorageLog record) {
startPage();
List<BmStorageLog> list = bmStorageLogService.selectAll(record);
return getDataTable(list);
}
/**
* 通过主键查询单条数据
*
* @param id 主键
* @return 单条数据
*/
@GetMapping("selectByPrimaryKey")
public BmStorageLog selectByPrimaryKey(Integer id) {
return bmStorageLogService.selectByPrimaryKey(id);
}
@InnerAuth
@PostMapping
public AjaxResult batchInsert(@RequestBody List<BmStorageLog> bmStorageLogList) {
return toAjax(bmStorageLogService.batchInsert(bmStorageLogList));
}
}

View File

@ -0,0 +1,24 @@
package com.bonus.sgzb.system.mapper;
import com.bonus.sgzb.system.api.domain.BmStorageLog;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface BmStorageLogMapper {
int deleteByPrimaryKey(Integer id);
int insert(BmStorageLog record);
int batchInsert(List<BmStorageLog> records);
int insertSelective(BmStorageLog record);
BmStorageLog selectByPrimaryKey(Integer id);
List<BmStorageLog> selectAll(BmStorageLog record);
int updateByPrimaryKeySelective(BmStorageLog record);
int updateByPrimaryKey(BmStorageLog record);
}

View File

@ -0,0 +1,57 @@
package com.bonus.sgzb.system.service.impl;
import com.bonus.sgzb.system.api.domain.BmStorageLog;
import com.bonus.sgzb.system.mapper.BmStorageLogMapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Slf4j
public class BmStorageLogService {
@Autowired
private BmStorageLogMapper bmStorageLogMapper;
private static ObjectMapper objectMapper = new ObjectMapper();
public int deleteByPrimaryKey(Integer id) {
return bmStorageLogMapper.deleteByPrimaryKey(id);
}
public int insert(BmStorageLog record) {
return bmStorageLogMapper.insert(record);
}
public int batchInsert(List<BmStorageLog> records) {
return bmStorageLogMapper.batchInsert(records);
}
public List<BmStorageLog> selectAll(BmStorageLog record) {
return bmStorageLogMapper.selectAll(record);
}
public int insertSelective(BmStorageLog record) {
return bmStorageLogMapper.insertSelective(record);
}
public BmStorageLog selectByPrimaryKey(Integer id) {
return bmStorageLogMapper.selectByPrimaryKey(id);
}
public int updateByPrimaryKeySelective(BmStorageLog record) {
return bmStorageLogMapper.updateByPrimaryKeySelective(record);
}
public int updateByPrimaryKey(BmStorageLog record) {
return bmStorageLogMapper.updateByPrimaryKey(record);
}
}

View File

@ -0,0 +1,227 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.sgzb.system.mapper.BmStorageLogMapper">
<resultMap id="BaseResultMap" type="com.bonus.sgzb.system.api.domain.BmStorageLog">
<!--@mbg.generated-->
<!--@Table bm_storage_log-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="model_title" jdbcType="VARCHAR" property="modelTitle" />
<result column="method" jdbcType="VARCHAR" property="method" />
<result column="task_id" jdbcType="VARCHAR" property="taskId" />
<result column="task_name" jdbcType="VARCHAR" property="taskName" />
<result column="type_id" jdbcType="INTEGER" property="typeId" />
<result column="type_name" jdbcType="VARCHAR" property="typeName" />
<result column="type_parent_name" jdbcType="VARCHAR" property="typeParentName" />
<result column="pre_store_num" jdbcType="VARCHAR" property="preStoreNum" />
<result column="in_num" jdbcType="VARCHAR" property="inNum" />
<result column="out_num" jdbcType="VARCHAR" property="outNum" />
<result column="back_num" jdbcType="VARCHAR" property="backNum" />
<result column="pass_num" jdbcType="VARCHAR" property="passNum" />
<result column="maintenance_num" jdbcType="VARCHAR" property="maintenanceNum" />
<result column="scrap_num" jdbcType="VARCHAR" property="scrapNum" />
<result column="post_store_num" jdbcType="VARCHAR" property="postStoreNum" />
<result column="json_result" jdbcType="VARCHAR" property="jsonResult" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="creator" jdbcType="VARCHAR" property="creator" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="status" jdbcType="TINYINT" property="status" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, model_title, `method`, task, type_id, num, `description`, json_result, `time`, creator,
remark, `status`
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
bnl.id, bnl.model_title, bnl.`method`, bnl.task_id, bnl.type_id, bnl.pre_num, bnl.audit_num, bnl.pre_store_num, bnl.in_num, bnl.out_num,
bnl.back_num, bnl.pass_num, bnl.maintenance_num, bnl.scrap_num, bnl.`description`, bnl.json_result, bnl.create_time, bnl.creator, bnl.manage_type,
bnl.remark, bnl.`status`, mt.type_name, mt1.type_name as type_parent_name, tt.code as task_name, bnl.post_store_num
from bm_storage_log bnl
left join ma_type mt on bnl.type_id = mt.type_id
inner join ma_type mt1 on mt.parent_id = mt1.type_id
left join tm_task tt on bnl.task_id = tt.task_id
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectAll" resultMap="BaseResultMap">
select
bnl.id, bnl.model_title, bnl.`method`, bnl.task_id, bnl.type_id, bnl.pre_num, bnl.audit_num, bnl.pre_store_num, bnl.in_num, bnl.out_num,
bnl.back_num, bnl.pass_num, bnl.maintenance_num, bnl.scrap_num, bnl.`description`, bnl.json_result, bnl.create_time, bnl.creator, bnl.manage_type,
bnl.remark, bnl.`status`, mt.type_name, mt1.type_name as type_parent_name, tt.code as task_name, bnl.post_store_num
from bm_storage_log bnl
left join ma_type mt on bnl.type_id = mt.type_id
inner join ma_type mt1 on mt.parent_id = mt1.type_id
left join tm_task tt on bnl.task_id = tt.task_id
<where>
<if test="modelTitle != null and modelTitle != ''">
and bnl.model_title like concat('%', #{modelTitle}, '%')
</if>
<if test="typeName != null and typeName != ''">
and mt1.type_name like concat('%', #{typeName}, '%')
</if>
</where>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
<!--@mbg.generated-->
delete from bm_storage_log
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.system.api.domain.BmStorageLog" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into bm_storage_log (model_title, `method`, task_id, type_id,
description, json_result, create_time, creator, remark,
pre_num, input_num, out_num, audit_num, manage_type,
type_name, type_model_name, pre_store_num, in_num,
back_num, pass_num, maintenance_num, scrap_num, `status`, post_store_num
)
values (#{modelTitle,jdbcType=VARCHAR}, #{method,jdbcType=VARCHAR}, #{taskId,jdbcType=VARCHAR}, #{typeId,jdbcType=INTEGER},
#{description,jdbcType=VARCHAR}, #{jsonResult,jdbcType=VARCHAR}, now(), #{creator,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
#{preNum,jdbcType=VARCHAR}, #{inputNum,jdbcType=VARCHAR}, #{outNum,jdbcType=VARCHAR}, #{auditNum,jdbcType=VARCHAR}, #{manageType,jdbcType=VARCHAR},
#{typeName,jdbcType=VARCHAR}, #{typeModelName,jdbcType=VARCHAR}, #{preStoreNum,jdbcType=VARCHAR}, #{inNum,jdbcType=VARCHAR},
#{backNum,jdbcType=VARCHAR}, #{passNum,jdbcType=VARCHAR}, #{maintenanceNum,jdbcType=VARCHAR}, #{scrapNum,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR},
#{postStoreNum,jdbcType=VARCHAR}
)
</insert>
<insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.system.api.domain.BmStorageLog" useGeneratedKeys="true">
insert into bm_storage_log (model_title, `method`, task_id, type_id,
create_time, creator, remark, out_num, manage_type,
type_name, type_model_name, pre_store_num, in_num,
back_num, pass_num, maintenance_num,
scrap_num, `status`, post_store_num
) values
<foreach item="item" index="index" collection="list" separator=",">
(
#{item.modelTitle,jdbcType=VARCHAR}, #{item.method,jdbcType=VARCHAR}, #{item.taskId,jdbcType=VARCHAR}, #{item.typeId,jdbcType=INTEGER},
now(), #{item.creator,jdbcType=VARCHAR}, #{item.remark,jdbcType=VARCHAR}, #{item.outNum,jdbcType=INTEGER}, #{item.manageType,jdbcType=VARCHAR},
#{item.typeName,jdbcType=VARCHAR}, #{item.typeModelName,jdbcType=VARCHAR}, #{item.preStoreNum,jdbcType=INTEGER}, #{item.inNum,jdbcType=INTEGER},
#{item.backNum,jdbcType=INTEGER}, #{item.passNum,jdbcType=INTEGER}, #{item.maintenanceNum,jdbcType=INTEGER},
#{item.scrapNum,jdbcType=INTEGER}, #{item.status,jdbcType=VARCHAR}, #{item.postStoreNum,jdbcType=INTEGER}
)
</foreach>
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bonus.sgzb.system.api.domain.BmStorageLog" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into bm_storage_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="modelTitle != null and modelTitle != ''">
model_title,
</if>
<if test="method != null and method != ''">
`method`,
</if>
<if test="task != null and task != ''">
task,
</if>
<if test="typeId != null">
type_id,
</if>
<if test="num != null and num != ''">
num,
</if>
<if test="description != null and description != ''">
`description`,
</if>
<if test="jsonResult != null and jsonResult != ''">
json_result,
</if>
<if test="time != null">
`time`,
</if>
<if test="creator != null and creator != ''">
creator,
</if>
<if test="remark != null and remark != ''">
remark,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="modelTitle != null and modelTitle != ''">
#{modelTitle,jdbcType=VARCHAR},
</if>
<if test="method != null and method != ''">
#{method,jdbcType=VARCHAR},
</if>
<if test="task != null and task != ''">
#{task,jdbcType=VARCHAR},
</if>
<if test="typeId != null">
#{typeId,jdbcType=INTEGER},
</if>
<if test="num != null and num != ''">
#{num,jdbcType=VARCHAR},
</if>
<if test="description != null and description != ''">
#{description,jdbcType=VARCHAR},
</if>
<if test="jsonResult != null and jsonResult != ''">
#{jsonResult,jdbcType=VARCHAR},
</if>
<if test="time != null">
#{time,jdbcType=TIMESTAMP},
</if>
<if test="creator != null and creator != ''">
#{creator,jdbcType=VARCHAR},
</if>
<if test="remark != null and remark != ''">
#{remark,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.bonus.sgzb.system.api.domain.BmStorageLog">
<!--@mbg.generated-->
update bm_storage_log
<set>
<if test="modelTitle != null and modelTitle != ''">
model_title = #{modelTitle,jdbcType=VARCHAR},
</if>
<if test="method != null and method != ''">
`method` = #{method,jdbcType=VARCHAR},
</if>
<if test="task != null and task != ''">
task = #{task,jdbcType=VARCHAR},
</if>
<if test="typeId != null">
type_id = #{typeId,jdbcType=INTEGER},
</if>
<if test="description != null and description != ''">
description = #{description,jdbcType=VARCHAR},
</if>
<if test="jsonResult != null and jsonResult != ''">
json_result = #{jsonResult,jdbcType=VARCHAR},
</if>
<if test="time != null">
`time` = #{time,jdbcType=TIMESTAMP},
</if>
<if test="creator != null and creator != ''">
creator = #{creator,jdbcType=VARCHAR},
</if>
<if test="remark != null and remark != ''">
remark = #{remark,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.bonus.sgzb.system.api.domain.BmStorageLog">
<!--@mbg.generated-->
update bm_storage_log
set model_title = #{modelTitle,jdbcType=VARCHAR},
`method` = #{method,jdbcType=VARCHAR},
task = #{task,jdbcType=VARCHAR},
type_id = #{typeId,jdbcType=INTEGER},
description = #{description,jdbcType=VARCHAR},
json_result = #{jsonResult,jdbcType=VARCHAR},
`time` = #{time,jdbcType=TIMESTAMP},
creator = #{creator,jdbcType=VARCHAR},
remark = #{remark,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>