diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MachIneDto.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MachIneDto.java similarity index 98% rename from sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MachIneDto.java rename to sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MachIneDto.java index 2e16225d..ce58c7d8 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/MachIneDto.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MachIneDto.java @@ -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; diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/SavePutInfoDto.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SavePutInfoDto.java similarity index 98% rename from sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/SavePutInfoDto.java rename to sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SavePutInfoDto.java index c3864724..bffc3b20 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/SavePutInfoDto.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SavePutInfoDto.java @@ -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; diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/RemoteLogService.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/RemoteLogService.java index bfb0168f..c643510a 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/RemoteLogService.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/RemoteLogService.java @@ -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 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 batchInsert(@RequestBody List bmStorageLogList, @RequestHeader(SecurityConstants.FROM_SOURCE) String source) throws Exception; + + /** * 保存访问记录 * diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/BmStorageLog.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/BmStorageLog.java new file mode 100644 index 00000000..afb9734c --- /dev/null +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/BmStorageLog.java @@ -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; + +} \ No newline at end of file diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/factory/RemoteLogFallbackFactory.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/factory/RemoteLogFallbackFactory.java index f25abcec..6eaee7f0 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/factory/RemoteLogFallbackFactory.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/factory/RemoteLogFallbackFactory.java @@ -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 batchInsert(List bmStorageLogList, String source) throws Exception { + return R.fail("保存物资库存日志失败:" + throwable.getMessage()); + } + @Override public R saveLogininfor(SysLogininfor sysLogininfor, String source) { diff --git a/sgzb-common/sgzb-common-log/src/main/java/com/bonus/sgzb/common/log/aspect/LogAspect.java b/sgzb-common/sgzb-common-log/src/main/java/com/bonus/sgzb/common/log/aspect/LogAspect.java index f1a56391..6cd9ebea 100644 --- a/sgzb-common/sgzb-common-log/src/main/java/com/bonus/sgzb/common/log/aspect/LogAspect.java +++ b/sgzb-common/sgzb-common-log/src/main/java/com/bonus/sgzb/common/log/aspect/LogAspect.java @@ -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 bmStorageLogList = new ArrayList<>(); - // 请求的地址 - bmNumLogs.setMethod(StringUtils.substring(Objects.requireNonNull(ServletUtils.getRequest()).getRequestURI(), 0, 255)); - String username = SecurityUtils.getUsername(); - R 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 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 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 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)); } } diff --git a/sgzb-common/sgzb-common-log/src/main/java/com/bonus/sgzb/common/log/service/AsyncLogService.java b/sgzb-common/sgzb-common-log/src/main/java/com/bonus/sgzb/common/log/service/AsyncLogService.java index ce44d28f..f24a6237 100644 --- a/sgzb-common/sgzb-common-log/src/main/java/com/bonus/sgzb/common/log/service/AsyncLogService.java +++ b/sgzb-common/sgzb-common-log/src/main/java/com/bonus/sgzb/common/log/service/AsyncLogService.java @@ -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 bmStorageLogList) throws Exception { + remoteLogService.batchInsert(bmStorageLogList, SecurityConstants.INNER); + } } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/InventoryAndWarehousingController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/InventoryAndWarehousingController.java index 86424028..57217c42 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/InventoryAndWarehousingController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/InventoryAndWarehousingController.java @@ -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; diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/InventoryAndWarehousingMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/InventoryAndWarehousingMapper.java index df85421e..778283a5 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/InventoryAndWarehousingMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/InventoryAndWarehousingMapper.java @@ -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; diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/InventoryAndWarehousingService.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/InventoryAndWarehousingService.java index 8e57c83d..7eb2f13c 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/InventoryAndWarehousingService.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/InventoryAndWarehousingService.java @@ -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; /** diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/InventoryAndWarehousingServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/InventoryAndWarehousingServiceImpl.java index 087fea9c..6df67528 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/InventoryAndWarehousingServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/InventoryAndWarehousingServiceImpl.java @@ -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; diff --git a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/BmStorageLogController.java b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/BmStorageLogController.java new file mode 100644 index 00000000..f73adc30 --- /dev/null +++ b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/BmStorageLogController.java @@ -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 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 bmStorageLogList) { + return toAjax(bmStorageLogService.batchInsert(bmStorageLogList)); + } + + +} diff --git a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/mapper/BmStorageLogMapper.java b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/mapper/BmStorageLogMapper.java new file mode 100644 index 00000000..8a132e88 --- /dev/null +++ b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/mapper/BmStorageLogMapper.java @@ -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 records); + + int insertSelective(BmStorageLog record); + + BmStorageLog selectByPrimaryKey(Integer id); + + List selectAll(BmStorageLog record); + + int updateByPrimaryKeySelective(BmStorageLog record); + + int updateByPrimaryKey(BmStorageLog record); +} \ No newline at end of file diff --git a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/BmStorageLogService.java b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/BmStorageLogService.java new file mode 100644 index 00000000..30ba8558 --- /dev/null +++ b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/BmStorageLogService.java @@ -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 records) { + return bmStorageLogMapper.batchInsert(records); + } + + public List 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); + } + +} diff --git a/sgzb-modules/sgzb-system/src/main/resources/mapper/system/BmStorageLogMapper.xml b/sgzb-modules/sgzb-system/src/main/resources/mapper/system/BmStorageLogMapper.xml new file mode 100644 index 00000000..4f5a8547 --- /dev/null +++ b/sgzb-modules/sgzb-system/src/main/resources/mapper/system/BmStorageLogMapper.xml @@ -0,0 +1,227 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, model_title, `method`, task, type_id, num, `description`, json_result, `time`, creator, + remark, `status` + + + + + + + + + delete from bm_storage_log + where id = #{id,jdbcType=INTEGER} + + + + + 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 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 + + ( + #{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} + ) + + + + + + insert into bm_storage_log + + + model_title, + + + `method`, + + + task, + + + type_id, + + + num, + + + `description`, + + + json_result, + + + `time`, + + + creator, + + + remark, + + + + + #{modelTitle,jdbcType=VARCHAR}, + + + #{method,jdbcType=VARCHAR}, + + + #{task,jdbcType=VARCHAR}, + + + #{typeId,jdbcType=INTEGER}, + + + #{num,jdbcType=VARCHAR}, + + + #{description,jdbcType=VARCHAR}, + + + #{jsonResult,jdbcType=VARCHAR}, + + + #{time,jdbcType=TIMESTAMP}, + + + #{creator,jdbcType=VARCHAR}, + + + #{remark,jdbcType=VARCHAR}, + + + + + + + update bm_storage_log + + + 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 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} + + + \ No newline at end of file