BUG修复,AOP日志切面,短信发送问题解决,库存日志记录功能

This commit is contained in:
syruan 2024-12-06 18:19:55 +08:00
parent 14059db870
commit f6f08286bc
35 changed files with 2083 additions and 44 deletions

View File

@ -0,0 +1,69 @@
package com.bonus.common.biz.annotation;
import java.lang.annotation.*;
/**
* 自定义物资操作日志记录注解
*
* @author syruan
*
*/
@Target({ ElementType.PARAMETER, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface StoreLog {
/**
* 模块
*/
String title() default "";
/**
* 业务类型 默认 0 系统日志 1 业务日志 2 异常日志
*/
int logType() default 1;
/**
* 操作模块
*/
String module() default "";
/**
* 功能 -> 默认MATERIAL代表物资模块 记录库存日志
*/
String businessType() default "MATERIAL";
String details() default "";
/**
* 操作人类别 -- MANAGE:后台
*/
String operatorType() default "MANAGE";
/**
* 是否保存请求的参数
*/
public boolean isSaveRequestData() default true;
/**
* 是否保存响应的参数
*/
public boolean isSaveResponseData() default true;
/**
* 排除指定的请求参数
*/
public String[] excludeParamNames() default {};
/**
* 操作类型 默认查询
*/
String grade() default "QUERY";
/**
* 日志类型
*/
String type() default "业务日志";
}

View File

@ -0,0 +1,113 @@
package com.bonus.common.biz.aspect;
import com.alibaba.fastjson2.JSON;
import com.bonus.common.biz.annotation.StoreLog;
import com.bonus.common.biz.domain.BmStorageLog;
import com.bonus.common.biz.service.AsyncStoreLogService;
import com.bonus.common.biz.utils.HttpResult;
import com.bonus.common.core.utils.ServletUtils;
import com.bonus.common.core.utils.StringUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* @author : 阮世耀
* @version : 1.0
* @PackagePath: com.bonus.common.biz.aspect
* @CreateTime: 2024-12-06 15:04
* @Description: 物资库存日志记录
*/
@Aspect
@Component
public class StoreLogAspect {
private static final Logger log = LoggerFactory.getLogger(StoreLogAspect.class);
/** 排除敏感属性字段 */
public static final String[] EXCLUDE_PROPERTIES = { "password", "oldPassword", "newPassword", "confirmPassword" };
/** Mapper序列化JSON */
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@Resource
private AsyncStoreLogService asyncStoreLogService;
/**
* 处理完请求后执行
*
* @param joinPoint 切点
*/
@AfterReturning(pointcut = "@annotation(storeLog)", returning = "jsonResult")
public void doAfterReturning(JoinPoint joinPoint, StoreLog storeLog, Object jsonResult)
{
System.err.println("进入切面");
handelStoreLog(joinPoint, storeLog, null, jsonResult);
}
protected void handelStoreLog(final JoinPoint joinPoint, StoreLog storeLog, final Exception e, Object jsonResult) {
List<BmStorageLog> bmStorageLogList = new ArrayList<>();
try {
// 处理设置注解上的参数
setRequestValue(joinPoint, bmStorageLogList);
for (BmStorageLog bmStorageLog : bmStorageLogList) {
bmStorageLog.setStatus(200L);
// 请求的地址
bmStorageLog.setMethod(StringUtils.substring(Objects.requireNonNull(ServletUtils.getRequest()).getRequestURI(), 0, 255));
if (e != null) {
bmStorageLog.setStatus(500L);
bmStorageLog.setJsonResult(StringUtils.substring(e.getMessage(), 0, 2000));
}
// 设置方法名称
String className = joinPoint.getTarget().getClass().getName();
String methodName = joinPoint.getSignature().getName();
bmStorageLog.setModelTitle(className + "." + methodName + "()");
// 设置请求方式
bmStorageLog.setMethod(ServletUtils.getRequest().getMethod());
bmStorageLog.setModelTitle(storeLog.title());
if (StringUtils.isNotNull(jsonResult)) {
bmStorageLog.setJsonResult(StringUtils.substring(JSON.toJSONString(jsonResult), 0, 2000));
HttpResult msgCode = OBJECT_MAPPER.readValue(bmStorageLog.getJsonResult(), HttpResult.class);
bmStorageLog.setResultCode((long) msgCode.getCode());
bmStorageLog.setStatus((long) (msgCode.getCode()==200 ? 0 : 1));
bmStorageLog.setResultMsg(msgCode.getMsg());
}
}
// 保存数据库
System.err.println("调用Feign");
asyncStoreLogService.batchInsert(bmStorageLogList);
} catch (Exception exp) {
// 记录本地异常日志
log.error("异常信息:{}", exp.getMessage());
exp.printStackTrace();
}
}
/**
* 获取请求的参数放到log中
*
* @param bmStorageLogList 物资日志
* @throws Exception 异常
*/
private void setRequestValue(JoinPoint joinPoint, List<BmStorageLog> bmStorageLogList) throws Exception {
System.err.println("获取请求参数");
String requestMethod = ServletUtils.getRequest().getMethod();
Map<?, ?> paramsMap = ServletUtils.getParamMap(ServletUtils.getRequest());
}
}

View File

@ -1,4 +1,4 @@
package com.bonus.material.basic.domain;
package com.bonus.common.biz.domain;
import com.bonus.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;

View File

@ -0,0 +1,28 @@
package com.bonus.common.biz.service;
import com.bonus.common.biz.domain.BmStorageLog;
import com.bonus.common.core.constant.SecurityConstants;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* @author : 阮世耀
* @version : 1.0
* @PackagePath: com.bonus.common.biz.service
* @CreateTime: 2024-12-06 15:35
* @Description: 物资库日志异步处理
*/
@Service
public class AsyncStoreLogService {
@Resource
private RemoteStoreLogService remoteStoreLogService;
@Async
public void batchInsert(List<BmStorageLog> bmStorageLogList) throws Exception {
remoteStoreLogService.batchInsert(bmStorageLogList, SecurityConstants.INNER);
}
}

View File

@ -0,0 +1,33 @@
package com.bonus.common.biz.service;
import com.bonus.common.biz.domain.BmStorageLog;
import com.bonus.common.biz.service.factory.RemoteStoreLogFallbackFactory;
import com.bonus.common.core.constant.SecurityConstants;
import com.bonus.common.core.domain.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import java.util.List;
/**
* 物资库存日志服务
*
* @author syruan
*/
@FeignClient(contextId = "remoteStoreLogService", value = "bonus-material", fallbackFactory = RemoteStoreLogFallbackFactory.class)
public interface RemoteStoreLogService {
/**
* 保存物资记录日志
* @param bmStorageLogList 物资信息
* @param source 请求来源
* @return 结果
* @throws Exception 异常信息
*/
@PostMapping("/bm_storage_logs")
R<Boolean> batchInsert(@RequestBody List<BmStorageLog> bmStorageLogList, @RequestHeader(SecurityConstants.FROM_SOURCE) String source) throws Exception;
}

View File

@ -0,0 +1,27 @@
package com.bonus.common.biz.service.factory;
import com.bonus.common.biz.service.RemoteStoreLogService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
/**
* 物资库存日志服务降级处理
*
* @author syruan
*/
@Component
public class RemoteStoreLogFallbackFactory implements FallbackFactory<RemoteStoreLogService> {
private static final Logger log = LoggerFactory.getLogger(RemoteStoreLogFallbackFactory.class);
@Override
public RemoteStoreLogService create(Throwable throwable)
{
log.error("日志服务调用失败:{}", throwable.getMessage());
return (sysLogsVo, s) -> null;
}
}

View File

@ -0,0 +1,13 @@
package com.bonus.common.biz.utils;
import lombok.Data;
/**
* @author syruan
*/
@Data
public class HttpResult {
private int code;
private int data;
private String msg;
}

View File

@ -15,7 +15,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@EnableCustomConfig
@EnableCustomSwagger2
@EnableRyFeignClients
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@SpringBootApplication(scanBasePackages = {"com.bonus.common.biz.*", "com.bonus.material.*"}, exclude = { DataSourceAutoConfiguration.class })
public class BonusMaterialApplication
{
public static void main(String[] args)

View File

@ -30,7 +30,7 @@ import com.bonus.common.core.web.page.TableDataInfo;
/**
* 退料任务Controller
*
*
* @author xsheng
* @date 2024-10-16
*/
@ -159,7 +159,7 @@ public class BackApplyInfoController extends BaseController {
@PostMapping("/editPrintStatus")
public AjaxResult editPrintStatus(@RequestBody BackApplyInfo dto) {
try {
return backApplyInfoService.editPrintStatus(dto);
return backApplyInfoService.editPrintStatus(dto.getId());
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
}
@ -181,6 +181,22 @@ public class BackApplyInfoController extends BaseController {
}
}
/**
* 打印状态变更
*/
@ApiOperation(value = "打印状态变更")
@PreventRepeatSubmit
@RequiresPermissions("back:info:edit")
@SysLog(title = "退料任务--打印", businessType = OperaType.UPDATE, module = "退料任务->打印")
@PostMapping("/editPrint")
public AjaxResult editPrint(@RequestBody BackApplyInfo backApplyInfo) {
try {
return backApplyInfoService.editPrintStatus(backApplyInfo.getId());
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
}
}
/**
* 删除退料任务
*/

View File

@ -1,11 +1,13 @@
package com.bonus.material.back.domain;
import java.io.Serializable;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.bonus.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;
import javax.validation.constraints.Size;
@ -16,10 +18,11 @@ import javax.validation.constraints.Size;
* @date 2024-10-16
*/
@Accessors(chain = true)
@Data
@ToString
public class BackApplyInfo {
public class BackApplyInfo implements Serializable {
private static final long serialVersionUID = 1L;
private Boolean isExport;

View File

@ -47,7 +47,7 @@ public interface BackApplyInfoMapper {
* @param backApplyInfo 退料任务
* @return 结果
*/
public int updateBackApplyInfo(BackApplyInfo backApplyInfo);
int updateBackApplyInfo(BackApplyInfo backApplyInfo);
/**
* 删除退料任务

View File

@ -71,10 +71,8 @@ public interface IBackApplyInfoService {
/**
* 确认打印
* @param dto
* @return
*/
AjaxResult editPrintStatus(BackApplyInfo dto);
AjaxResult editPrintStatus(Long id);
/**
* 新增退料任务app

View File

@ -643,8 +643,9 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
* @return
*/
@Override
public AjaxResult editPrintStatus(BackApplyInfo dto) {
int result = backApplyInfoMapper.updateBackApplyInfo(dto);
public AjaxResult editPrintStatus(Long id) {
BackApplyInfo info = new BackApplyInfo().setId(id).setPrintStatus("1");
int result = backApplyInfoMapper.updateBackApplyInfo(info);
return result > 0 ? AjaxResult.success() : AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
}

View File

@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.security.annotation.RequiresPermissions;
import com.bonus.material.basic.domain.BmStorageLog;
import com.bonus.common.biz.domain.BmStorageLog;
import com.bonus.material.basic.service.IBmStorageLogService;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
@ -28,7 +28,6 @@ import com.bonus.common.core.web.page.TableDataInfo;
* 库存日志Controller
*
* @author xsheng
* @date 2024-09-27
*/
@Api(tags = "库存日志接口")
@RestController
@ -81,11 +80,9 @@ public class BmStorageLogController extends BaseController
* 新增库存日志
*/
@ApiOperation(value = "新增库存日志")
@PreventRepeatSubmit
@RequiresPermissions("basic:log:add")
@SysLog(title = "库存日志", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增库存日志")
@PostMapping
public AjaxResult add(@RequestBody BmStorageLog bmStorageLog)
public AjaxResult batchInsert(@RequestBody BmStorageLog bmStorageLog)
{
return toAjax(bmStorageLogService.insertBmStorageLog(bmStorageLog));
}

View File

@ -1,7 +1,7 @@
package com.bonus.material.basic.mapper;
import java.util.List;
import com.bonus.material.basic.domain.BmStorageLog;
import com.bonus.common.biz.domain.BmStorageLog;
/**
* 库存日志Mapper接口

View File

@ -1,7 +1,7 @@
package com.bonus.material.basic.service;
import java.util.List;
import com.bonus.material.basic.domain.BmStorageLog;
import com.bonus.common.biz.domain.BmStorageLog;
/**
* 库存日志Service接口

View File

@ -5,7 +5,7 @@ import com.bonus.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.material.basic.mapper.BmStorageLogMapper;
import com.bonus.material.basic.domain.BmStorageLog;
import com.bonus.common.biz.domain.BmStorageLog;
import com.bonus.material.basic.service.IBmStorageLogService;
/**
@ -15,8 +15,8 @@ import com.bonus.material.basic.service.IBmStorageLogService;
* @date 2024-09-26
*/
@Service
public class BmStorageLogServiceImpl implements IBmStorageLogService
{
public class BmStorageLogServiceImpl implements IBmStorageLogService {
@Autowired
private BmStorageLogMapper bmStorageLogMapper;

View File

@ -125,10 +125,14 @@ public class BmUnitServiceImpl implements IBmUnitService
if (unit != null) {
return AjaxResult.error(HttpCodeEnum.NAME_DUPLICATE.getCode(), HttpCodeEnum.NAME_DUPLICATE.getMsg());
}
if (StringUtils.isNotBlank(bmUnit.getTelphone())) {
String telPhone = Sm4Utils.encrypt(bmUnit.getTelphone());
bmUnit.setTelphone(telPhone);
} else {
return AjaxResult.error(HttpCodeEnum.INVALID_PHONE_FORMAT.getCode(), HttpCodeEnum.INVALID_PHONE_FORMAT.getMsg());
}
//判断手机号是否合法
if (StringUtils.isNotBlank(bmUnit.getTelphone()) && !PhoneUtil.isMobile(bmUnit.getTelphone())) {
String telphone = Sm4Utils.encrypt(bmUnit.getTelphone());
bmUnit.setTelphone(telphone);
if (!PhoneUtil.isMobile(bmUnit.getTelphone())) {
return AjaxResult.error(HttpCodeEnum.INVALID_PHONE_FORMAT.getCode(), HttpCodeEnum.INVALID_PHONE_FORMAT.getMsg());
}
bmUnit.setCreateTime(DateUtils.getNowDate());

View File

@ -1,6 +1,7 @@
package com.bonus.material.ma.controller;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
@ -13,6 +14,7 @@ import com.bonus.material.common.annotation.PreventRepeatSubmit;
import com.bonus.material.ma.domain.vo.MaTypeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.java.Log;
import org.apache.commons.lang3.BooleanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
@ -94,11 +96,17 @@ public class PartTypeController extends BaseController
@RequiresPermissions("ma:type:export")
@SysLog(title = "配件类型管理", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出配件类型管理")
@PostMapping("/export")
public void export(HttpServletResponse response, PartType partType)
{
List<PartType> list = partTypeService.getTypeList(partType);
ExcelUtil<PartType> util = new ExcelUtil<PartType>(PartType.class);
util.exportExcel(response, list, "配件类型管理数据");
public void export(HttpServletResponse response, PartType partType) {
List<Integer> parentIds = partTypeService.selectParentId(partType);
ExcelUtil<PartType> util = new ExcelUtil<>(PartType.class);
if (CollectionUtils.isEmpty(parentIds)) {
util.exportExcel(response, null, "配件类型管理数据");
}
List<PartType> maTypeVos = new ArrayList<>();
for (Integer parentId : parentIds) {
maTypeVos.addAll(partTypeService.getListByParentId(parentId.longValue(), partType));
}
util.exportExcel(response, maTypeVos, "配件类型管理数据");
}
/**

View File

@ -8,6 +8,7 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull;
import cn.hutool.core.convert.Convert;
import com.bonus.common.biz.annotation.StoreLog;
import com.bonus.common.biz.config.ListPagingUtil;
import com.bonus.common.core.utils.ServletUtils;
import com.bonus.common.log.enums.OperaType;
@ -45,6 +46,7 @@ public class TypeController extends BaseController {
*/
@ApiOperation(value = "查询物资类型管理列表")
@RequiresPermissions("ma:type:list")
@StoreLog(title = "物资类型管理", module = "仓储管理->物资类型查询库存记录")
@GetMapping("/list")
public TableDataInfo list(MaTypeVo type) {
startPage();
@ -59,6 +61,7 @@ public class TypeController extends BaseController {
@PreventRepeatSubmit
@RequiresPermissions("ma:type:export")
@SysLog(title = "物资类型管理", businessType = OperaType.EXPORT, module = "仓储管理->导出物资类型")
@StoreLog(title = "物资类型管理", module = "仓储管理->导出物资类型查询库存记录")
@PostMapping("/export")
public void export(HttpServletResponse response, MaTypeVo maTypeVo) {
List<Integer> parentIds = typeService.selectParentId(maTypeVo);
@ -89,6 +92,7 @@ public class TypeController extends BaseController {
*/
@ApiOperation(value = "根据左列表类型id查询右表格")
@GetMapping("/getListByMaType")
@StoreLog(title = "物资类型管理", module = "仓储管理->导出物资类型查询库存记录")
public AjaxResult getListByMaType(MaTypeVo maTypeVo) {
List<Integer> parentIds = typeService.selectParentId(maTypeVo);
if (CollectionUtils.isEmpty(parentIds)) {

View File

@ -0,0 +1,128 @@
package com.bonus.material.ma.controller;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.ma.domain.DirectApplyDetails;
import com.bonus.material.ma.domain.DirectApplyInfo;
import com.bonus.material.ma.domain.DirectApplyInfoDetails;
import com.bonus.material.ma.service.WorkSiteDirectManageService;
import com.bonus.material.settlement.domain.SltAgreementInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
* @author 梁超
* 工地直转管理
*/
@Api(tags = " 工地直转管理")
@RestController
@RequestMapping("/workSite")
public class WorkSiteDirectManageController extends BaseController {
@Resource(name = "workSiteDirectManageService")
private WorkSiteDirectManageService workSiteDirectManageService;
/**
* 列表展示
*/
@ApiOperation(value = "列表展示")
@GetMapping("/list")
public TableDataInfo list(DirectApplyInfo directApplyInfo) {
startPage();
List<DirectApplyInfo> directApplyInfos = workSiteDirectManageService.getList(directApplyInfo);
return getDataTable(directApplyInfos);
}
/**
* 根据协议Id查询在用数据
*/
@ApiOperation(value = "根据协议Id查询在用数据")
@GetMapping("/getUseringData")
public TableDataInfo getUseringData(SltAgreementInfo sltAgreementInfo) {
startPage();
List<SltAgreementInfo> useringData = workSiteDirectManageService.getUseringData(sltAgreementInfo);
return getDataTable(useringData);
}
/**
* 存储退料领料数据
*/
@ApiOperation(value = "保存直转方和接收方数据")
@PostMapping("/submit")
public AjaxResult submit(@RequestBody DirectApplyInfoDetails directApplyInfoDetails) {
int id = 0;
if (directApplyInfoDetails != null) {
if (directApplyInfoDetails.getDirectApplyInfo() != null) {
DirectApplyInfo directApplyInfos = directApplyInfoDetails.getDirectApplyInfo();
directApplyInfos.setCode(workSiteDirectManageService.genderLeaseCode());
directApplyInfos.setCreateTime(new Date());
int i = workSiteDirectManageService.saveDirectApplyInfo(directApplyInfos);
if (i < 0) {
return AjaxResult.error("保存失败");
}
id = directApplyInfos.getId();
} else {
return AjaxResult.error("保存失败");
}
if (directApplyInfoDetails.getDirectApplyInfoDetails() != null) {
List<DirectApplyDetails> directApplyDetails = directApplyInfoDetails.getDirectApplyInfoDetails();
for (DirectApplyDetails directApplyDetail : directApplyDetails) {
directApplyDetail.setDirectId(id);
int i = workSiteDirectManageService.saveDirectApplyDetails(directApplyDetail);
if (i < 0) {
return AjaxResult.error("保存失败");
}
}
}
} else {
return AjaxResult.error("保存失败");
}
return AjaxResult.success("保存成功");
}
// @ApiOperation(value = "通过")
// @PostMapping("/pass")
// public AjaxResult pass(@RequestBody DirectPassApplyInfoDetails directApplyInfoDetails) {
// int rows = workSiteDirectManageService.passDirectApplyInfoDetails(directApplyInfoDetails);
// if (rows == 1) {
// return AjaxResult.success("已通过");
// } else {
// return AjaxResult.error("未通过");
// }
// }
/**
* 不通过
*/
@ApiOperation(value = "不通过")
@PostMapping("/refuse")
public AjaxResult refuse(@RequestBody DirectApplyInfo directApplyInfo) {
if (directApplyInfo != null) {
directApplyInfo.setStatus("2");
directApplyInfo.setAuditor(SecurityUtils.getLoginUser().getUsername());
directApplyInfo.setAuditTime(DateUtils.getNowDate());
workSiteDirectManageService.refuseDirectApplyInfo(directApplyInfo);
} else {
return AjaxResult.error("参数为空,审核失败");
}
return AjaxResult.success();
}
@ApiOperation(value = "查看详情")
@GetMapping("/getInfo")
public AjaxResult getInfo(SltAgreementInfo sltAgreementInfo) {
return AjaxResult.success(workSiteDirectManageService.getInfoById(sltAgreementInfo));
}
}

View File

@ -0,0 +1,48 @@
package com.bonus.material.ma.domain;
import com.bonus.common.core.web.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author 梁超
*/
@EqualsAndHashCode(callSuper = false)
@Data
public class DirectApplyDetails extends BaseEntity {
/**
* id
*/
private Integer id;
/**
* 直转单号
*/
private Integer directId;
/**
* 机具类型
*/
private Integer typeId;
/**
* 机具id
*/
private Integer maId;
/**
* 直转数量
*/
private Integer directNum;
private String typeName;
private String kindName;
private String modelName;
private String maCode;
private String unitName;
private Integer useNum;
private String companyId;
}

View File

@ -0,0 +1,143 @@
package com.bonus.material.ma.domain;
import com.bonus.common.core.web.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List;
/**
* @author 梁超
* direct_apply_info 工地直转信息
*/
@EqualsAndHashCode(callSuper = false)
@Data
public class DirectApplyInfo extends BaseEntity {
/**
* id
*/
private Integer id;
/**
* 直转单号(ZZ20240226-1)
*/
private String code;
/**
* 退料单位协议
*/
private Integer backAgreementId;
/**
* 退料工程id
*/
private String backProId;
/**
* 关键字
*/
private String keyWord;
/**
* 退料工程名称
*/
private String backProName;
/**
* 退料单位id
*/
private String backUnitId;
/**
* 退料单位名称
*/
private String backUnitName;
/**
* 领料工程id
*/
private String leaseProId;
/**
* 领料工程名称
*/
private String leaseProName;
/**
* 领料单位id
*/
private String leaseUnitId;
/**
* 领料单位名称
*/
private String leaseUnitName;
/**
* 退料人
*/
private String backMan;
/**
* 手机号
*/
private String backPhone;
/**
* 退料备注
*/
private String backRemark;
/**
* 领料单位协议
*/
private int leaseAgreementId;
/**
* 领料人
*/
private String leaseMan;
/**
* 领料联系电话
*/
private String leasePhone;
/**
* 领料备注
*/
private String leaseRemark;
/**
* 直转附件
*/
private String dirUrl;
/**
* 0待审批1审批同意2驳回
*/
private String status;
/**
* 审核人
*/
private String auditor;
/**
* 审核时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date auditTime;
/**
* 审核备注
*/
private String auditRemark;
/**
* 退料单位协议
*/
private String backAgreementCode;
/**
* 领料单位协议
*/
private String leaseAgreementCode;
/**
* 退料工程id
*/
private String lotId;
/**
* 退料单位id
*/
private String unitId;
/**
* 退料明细
*/
private List<DirectApplyDetails> directApplyDetails;
}

View File

@ -0,0 +1,22 @@
package com.bonus.material.ma.domain;
import com.bonus.common.core.web.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.List;
/**
* @author 梁超
*/
@EqualsAndHashCode(callSuper = false)
@Data
public class DirectApplyInfoDetails extends BaseEntity implements Serializable {
private static final long serialVersionUID = -5152464640629428150L;
private DirectApplyInfo directApplyInfo;
private List<DirectApplyDetails> directApplyInfoDetails;
}

View File

@ -0,0 +1,27 @@
package com.bonus.material.ma.domain;
import com.bonus.common.core.web.domain.BaseEntity;
import com.bonus.material.back.domain.BackApplyInfo;
import com.bonus.material.lease.domain.LeaseOutDetails;
import com.bonus.material.task.domain.TmTask;
import lombok.Data;
import java.util.List;
/**
* @Author梁超
* @date2024/3/4 - 16:10
*/
@Data
public class DirectPassApplyInfoDetails extends BaseEntity {
private static final long serialVersionUID = 1L;
private String id;
private TmTask leaseApplyInfo;
private BackApplyInfo backApplyInfo;
private List<LeaseOutDetails> leaseOutDetails;
}

View File

@ -0,0 +1,68 @@
package com.bonus.material.ma.mapper;
import com.bonus.material.lease.domain.LeaseApplyDetails;
import com.bonus.material.lease.domain.LeaseApplyInfo;
import com.bonus.material.lease.domain.LeaseOutDetails;
import com.bonus.material.ma.domain.DirectApplyDetails;
import com.bonus.material.ma.domain.DirectApplyInfo;
import com.bonus.material.settlement.domain.SltAgreementInfo;
import com.bonus.material.task.domain.TmTask;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.ArrayList;
import java.util.List;
/**
* @Author梁超
* @date2024/3/4 - 14:49
*/
@Mapper
public interface WorkSiteDirectManageMapper {
/**
* 根据协议id查询在用数据
*
* @param
* @return
*/
List<SltAgreementInfo> getUseringData(SltAgreementInfo sltAgreementInfo);
int saveDirectApplyInfo(DirectApplyInfo directApplyInfo);
int saveDirectApplyDetails(DirectApplyDetails directApplyInfo);
int refuseDirectApplyInfo(DirectApplyInfo directApplyInfos);
List<DirectApplyInfo> getList(DirectApplyInfo directApplyInfo);
DirectApplyInfo getDirectApplyInfoById(String id);
int insertSelective(LeaseApplyInfo leaseApplyInfo);
int batchInsert(List<LeaseApplyDetails> leaseApplyDetailsList);
int batchDel(@Param("ids") ArrayList<Integer> ids);
DirectApplyInfo getMachineStatus(LeaseOutDetails leaseOutDetails);
int updateLeaseApplyDetailsOutNum(@Param("record")LeaseOutDetails leaseOutDetails);
int insertLeaseOutDetails(LeaseOutDetails leaseOutDetails);
List<DirectApplyInfo> getListLease();
int updateMaTypeStockNum(@Param("record")LeaseOutDetails leaseOutDetails);
int updateMaMachineStatus(@Param("record")LeaseOutDetails leaseOutDetails);
int insertBackApplyInfo(TmTask task);
DirectApplyInfo getInfoById(SltAgreementInfo sltAgreementInfo);
List<DirectApplyDetails> getDetailById(SltAgreementInfo sltAgreementInfo);
List<DirectApplyInfo> getListAll();
}

View File

@ -0,0 +1,52 @@
package com.bonus.material.ma.service;
import com.bonus.material.back.domain.BackApplyInfo;
import com.bonus.material.lease.domain.LeaseOutDetails;
import com.bonus.material.ma.domain.DirectApplyDetails;
import com.bonus.material.ma.domain.DirectApplyInfo;
import com.bonus.material.ma.domain.DirectPassApplyInfoDetails;
import com.bonus.material.settlement.domain.SltAgreementInfo;
import com.bonus.material.task.domain.TmTask;
import java.util.List;
/**
* @author 梁超
*/
public interface WorkSiteDirectManageService {
List<SltAgreementInfo> getUseringData(SltAgreementInfo sltAgreementInfo);
int saveDirectApplyInfo(DirectApplyInfo directApplyInfos);
int saveDirectApplyDetails(DirectApplyDetails directApplyInfos);
int refuseDirectApplyInfo(DirectApplyInfo directApplyInfos);
List<DirectApplyInfo> getList(DirectApplyInfo directApplyInfo);
String genderLeaseCode();
DirectApplyInfo getDirectApplyInfoById(String id);
int insertTmTask(TmTask bean);
// int insertAgreement(TmTask task);
// int insertApplyInfoAndDetails(TmTask task);
//
// int insertLeaseOutDetail(List<LeaseOutDetails> leaseOutDetails, TmTask task);
//
// int insertBackApplyInfoAndDetails(BackApplyInfo backApplyInfo);
//
// int insertTmTaskByBackInfo(BackApplyInfo backApplyInfo);
// int insertAgreementByBackInfo(BackApplyInfo backApplyInfo);
//
// int insertBackCheckDetails(List<BackApplyInfo> backApplyDetails);
DirectApplyInfo getInfoById(SltAgreementInfo sltAgreementInfo);
// int passDirectApplyInfoDetails(DirectPassApplyInfoDetails directApplyInfoDetails);
}

View File

@ -142,17 +142,20 @@ public class TypeServiceImpl implements ITypeService {
*/
@Override
public List<Type> selectTypeList4Keeper(Type type) {
List<Type> typeList = Collections.emptyList();
if (type != null ) {
if (StringUtils.isEmpty(type.getDelFlag())) {
// 如果没赋值则默认查询正常数据状态
type.setDelFlag(String.valueOf(DataCodeEnum.NORMAL.getCode()));
}
// 如果是顶级节点则查询所有子节点
if ("0".equals(type.getLevel())) {
if (Objects.equals(type.getLevel(), "0")) {
type.setLevel(null);
}
}
return typeMapper.selectTypeList4Keeper(type);
typeList = typeMapper.selectTypeList4Keeper(type);
typeList.removeIf(item -> item.getLevel() == null || !Objects.equals(item.getLevel(),"4"));
return typeList;
}
/**
@ -163,17 +166,23 @@ public class TypeServiceImpl implements ITypeService {
*/
@Override
public List<Type> selectTypeList4Repair(Type type) {
List<Type> typeList;
if (type != null ) {
if (StringUtils.isEmpty(type.getDelFlag())) {
// 如果没赋值则默认查询正常数据状态
type.setDelFlag(String.valueOf(DataCodeEnum.NORMAL.getCode()));
}
// 如果是顶级节点则查询所有子节点
if ("0".equals(type.getLevel())) {
if (Objects.equals(type.getLevel(), "0")) {
type.setLevel(null);
}
} else {
type = new Type();
}
return typeMapper.selectTypeList4Repair(type);
// 执行SQL
typeList = typeMapper.selectTypeList4Repair(type);
typeList.removeIf(item -> item.getLevel() == null || !Objects.equals(item.getLevel(),"4"));
return typeList;
}
/**

View File

@ -0,0 +1,611 @@
package com.bonus.material.ma.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.material.back.domain.BackApplyInfo;
import com.bonus.material.back.service.IBackApplyInfoService;
import com.bonus.material.lease.domain.LeaseApplyDetails;
import com.bonus.material.lease.domain.LeaseApplyInfo;
import com.bonus.material.lease.domain.LeaseOutDetails;
import com.bonus.material.ma.domain.DirectApplyDetails;
import com.bonus.material.ma.domain.DirectApplyInfo;
import com.bonus.material.ma.domain.DirectPassApplyInfoDetails;
import com.bonus.material.ma.mapper.WorkSiteDirectManageMapper;
import com.bonus.material.ma.service.WorkSiteDirectManageService;
import com.bonus.material.settlement.domain.SltAgreementInfo;
import com.bonus.material.task.domain.TmTask;
import com.bonus.material.task.service.ITmTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* @author 梁超
*/
@Service(value = "workSiteDirectManageService")
@Slf4j
public class WorkSiteDirectManageImpl implements WorkSiteDirectManageService {
@Resource
private WorkSiteDirectManageMapper workSiteDirectManageMapper;
@Resource
private ITmTaskService tmTaskService;
@Resource
private IBackApplyInfoService backApplyService;
// @Resource
// private BackRecordMapper backRecordMapper;
//
// @Resource
// private ApplyInfoService applyInfoService;
//
// @Resource
// private LeaseRecordMapper leaseRecordMapper;
@Override
public List<SltAgreementInfo> getUseringData(SltAgreementInfo sltAgreementInfo) {
return workSiteDirectManageMapper.getUseringData(sltAgreementInfo);
}
@Override
@Transactional
public int saveDirectApplyInfo(DirectApplyInfo directApplyInfo) {
return workSiteDirectManageMapper.saveDirectApplyInfo(directApplyInfo);
}
@Override
@Transactional
public int saveDirectApplyDetails(DirectApplyDetails directApplyDetail) {
return workSiteDirectManageMapper.saveDirectApplyDetails(directApplyDetail);
}
@Override
public int refuseDirectApplyInfo(DirectApplyInfo directApplyInfos) {
return workSiteDirectManageMapper.refuseDirectApplyInfo(directApplyInfos);
}
@Override
public List<DirectApplyInfo> getList(DirectApplyInfo directApplyInfo) {
return workSiteDirectManageMapper.getList(directApplyInfo);
}
@Override
public String genderLeaseCode() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
Date date = new Date();
String format = simpleDateFormat.format(date);
List<DirectApplyInfo> list = workSiteDirectManageMapper.getListAll();
int i = list.size() + 1;
return "ZZ" + format + "-" + list.size() + i;
}
@Override
public DirectApplyInfo getDirectApplyInfoById(String id) {
return workSiteDirectManageMapper.getDirectApplyInfoById(id);
}
@Override
public int insertTmTask(TmTask bean) {
if (StringUtils.isNull(bean)) {
return 0;
}
// 创建任务
return tmTaskService.insertTmTask(bean);
}
// @Override
// public int insertAgreement(TmTask task) {
// int res = 0;
// boolean b = tmTaskService.insertAgreement(task) > 0;
// if (b) {
// res = 1;
// }
// return res;
// }
// @Override
// public int insertApplyInfoAndDetails(TmTask task) {
// int res = 0;
// if (task.getLeaseApplyInfo() != null) {
// if (CollUtil.isEmpty(task.getLeaseApplyDetails())) {
// return res;
// }
// if (StringUtils.isNull(task.getLeaseApplyInfo())) {
// return res;
// }
//
// // 获取任务编号
// String taskId = task.getId();
// List<List<LeaseApplyDetails>> deviceByCompanyList = CollUtil.groupByField(task.getLeaseApplyDetails(), "companyId");
// // 对拆分后的集合进行each遍历
// for (List<LeaseApplyDetails> leaseApplyDetailsList : deviceByCompanyList) {
// // 判断拆分后的集合内是否有数据
// if (CollUtil.isNotEmpty(leaseApplyDetailsList)) {
// // 对领料任务表的对象做数据处理
// LeaseApplyInfo leaseApplyInfo = task.getLeaseApplyInfo();
// leaseApplyInfo.setCode(task.getCode()); // 创建领料单号
// leaseApplyInfo.setTaskId(Long.valueOf(taskId)); // 设置任务ID
// leaseApplyInfo.setCompanyId(leaseApplyDetailsList.get(0).getCompanyId()); // 设置设备所属分公司,用于交给哪家审核
// leaseApplyInfo.setType("2"); // 设置审批层级先固定2层后期根据接口传入Type区分来源设定
// leaseApplyInfo.setStatus("1"); //设置为分公司审核通过
// leaseApplyInfo.setLeaseType("0"); //设置为工程租赁
// // 创建领料任务返回领料任务编号
// boolean addLeaseTaskResult = workSiteDirectManageMapper.insertSelective(leaseApplyInfo) > 0;
// // 领料任务创建完成进行领料任务明细插入
// if (addLeaseTaskResult) {
// // 领料任务编号
// Integer leaseTaskId = leaseApplyInfo.getId();
// ArrayList<Integer> ids = new ArrayList();
// if (StringUtils.isNotNull(leaseTaskId)) {
// for (LeaseApplyDetails leaseApplyDetails : leaseApplyDetailsList) {
// leaseApplyDetails.setParenntId(leaseTaskId); // 设置领料任务ID
// ids.add(leaseApplyDetails.getId());
// }
// // 插入领料任务明细
// boolean addLeaseTaskDetailsResult = workSiteDirectManageMapper.batchInsert(leaseApplyDetailsList) > 0;
// if (addLeaseTaskDetailsResult) {
// System.out.println("领料任务创建成功");
// workSiteDirectManageMapper.batchDel(ids);
// } else {
// return res;
// }
// } else {
// return res;
// }
// } else {
// return res;
// }
// }
// }
// res = 1;
// return res;
// } else {
// return res;
// }
// }
// @Override
// @Transactional(rollbackFor = Exception.class)
// public int insertLeaseOutDetail(List<LeaseOutDetails> leaseOutDetails, TmTask lTask) {
// int res = 0;
// String maStatus = "16";
// double outNum = 0.1;
// if (StringUtils.isNull(leaseOutDetails)) {
// log.info("领料出库失败,请检查参数是否填写完整!");
// return res;
// }
// for (LeaseOutDetails leaseOutDetail : leaseOutDetails) {
// if (!(Objects.equals(Integer.valueOf(0), leaseOutDetail.getMaId()) || leaseOutDetail.getMaId() == null)) {
// DirectApplyInfo directApplyInfo = workSiteDirectManageMapper.getMachineStatus(leaseOutDetail);
// if (!maStatus.equals(directApplyInfo.getStatus())) {
// log.info("领料出库失败,该设备不是再用状态!");
// return res;
// }
// }
// // 首先更新领料任务详情表的领料数及状态
// int updateLeaseApplyDetailsOutNum = workSiteDirectManageMapper.updateLeaseApplyDetailsOutNum(leaseOutDetail);
// if (updateLeaseApplyDetailsOutNum < 1) {
// return res;
// }
// // 插入领料出库明细表
// int insertSelectiveNum = workSiteDirectManageMapper.insertLeaseOutDetails(leaseOutDetail);
// if (insertSelectiveNum < 1) {
// return res;
// }
// // 更新 (ma_machine 设备表)的状态
// workSiteDirectManageMapper.updateMaMachineStatus(leaseOutDetail);
//
// int insSltInfoNum = insSltInfo(lTask.getAgreementId().toString(), leaseOutDetail);
// if (insSltInfoNum < 1) {
// return res;
// }
// }
// res = 1;
// return res;
// }
//
// private int insSltInfo(String agreementId, LeaseOutDetails leaseOutDetail) {
// MaType ma = leaseRecordMapper.getMaType(leaseOutDetail.getTypeId());
// return leaseRecordMapper.insSltInfo(leaseOutDetail, agreementId, ma);
// }
//
// @Override
// @Transactional(rollbackFor = Exception.class)
// public int insertBackApplyInfoAndDetails(BackApplyInfo bean) {
// int res = 0;
// boolean addLeaseTaskResult = false;
// Long backApplyInfoId = 0L;
// try {
// if (bean.getTaskId() != null) {
// if (bean.getBackApplyInfo() != null) {
// if (CollUtil.isEmpty(bean.getBackApplyDetails())) {
// return res;
// }
//
// Integer taskId = Math.toIntExact(bean.getTaskId());
// // 根据设备所属分公司拆分集合
// List<List<BackApplyInfo>> backApplyInfoList = CollUtil.groupByField(bean.getBackApplyDetails(), "companyId");
// // 判断拆分后的集合内是否有数据
// if (CollUtil.isNotEmpty(backApplyInfoList)) {
// // 对拆分后的集合进行each遍历
// for (List<BackApplyInfo> leaseApplyDetailsList : backApplyInfoList) {
// BackApplyInfo backApplyInfo1 = leaseApplyDetailsList.get(0);
// // 对领料任务表的对象做数据处理
// BackApplyInfo backApplyInfo = bean.getBackApplyInfo();
// // 创建领料单号
// backApplyInfo.setCode(bean.getCode());
// // 设置任务ID
// backApplyInfo.setTaskId(taskId);
// // 设置设备所属分公司,用于交给哪家审核
// backApplyInfo.setCompanyId(backApplyInfo1.getCompanyId());
// // 创建领料任务返回领料任务编号
// addLeaseTaskResult = backApplyService.insertBackApply(backApplyInfo) > 0;
// // 领料任务编号
// backApplyInfoId = backApplyInfo.getId();
//
// // 领料任务创建完成进行领料任务明细插入
// if (addLeaseTaskResult) {
// if (StringUtils.isNotNull(backApplyInfoId)) {
// for (BackApplyInfo leaseApplyDetails : leaseApplyDetailsList) {
// //设置领料任务ID
// leaseApplyDetails.setId(backApplyInfoId);
// leaseApplyDetails.setNum(leaseApplyDetails.getDirectNum());
// leaseApplyDetails.setAuditNum(leaseApplyDetails.getDirectNum());
// // 插入领料任务明细
// boolean addLeaseTaskDetailsResult = backApplyService.upload(leaseApplyDetails) > 0;
// if (!addLeaseTaskDetailsResult) {
// log.info("退料任务创建成功,但退料任务明细插入失败");
// return res;
// }
// }
// } else {
// log.info("退料任务编号为空");
// return res;
// }
// } else {
// log.info("创建退料任务失败,或退料明细为空");
// return res;
// }
// }
// } else {
// log.info("创建任务失败,缺少数据");
// return res;
// }
// } else {
// log.info("创建任务失败");
// return res;
// }
// } else {
// log.info("创建任务失败");
// return res;
// }
// } catch (Exception e) {
// log.info("创建任务失败");
// return res;
// }
// res = 1;
// return res;
// }
//
// @Override
// public int insertTmTaskByBackInfo(BackApplyInfo backApplyInfo) {
// if (StringUtils.isNull(backApplyInfo)) {
// return 0;
// }
// // 创建任务
// return tmTaskService.insertTmTask(backApplyInfo);
// }
//
// @Override
// public int insertAgreementByBackInfo(BackApplyInfo backApplyInfo) {
// return tmTaskService.insertAgreementByBackInfo(backApplyInfo);
// }
//
// @Override
// public int insertBackCheckDetails(List<BackApplyInfo> backApplyDetails) {
// //插入back_check_details
// return insertBcd(backApplyDetails);
// }
@Override
public DirectApplyInfo getInfoById(SltAgreementInfo sltAgreementInfo) {
DirectApplyInfo directApplyInfo = workSiteDirectManageMapper.getInfoById(sltAgreementInfo);
List<DirectApplyDetails> detailById = workSiteDirectManageMapper.getDetailById(sltAgreementInfo);
directApplyInfo.setDirectApplyDetails(detailById);
return directApplyInfo;
}
// @Override
// @Transactional(rollbackFor = Exception.class)
// public int passDirectApplyInfoDetails(DirectPassApplyInfoDetails directApplyInfoDetails) {
// int res = 0;
// try {
// // 修改状态为通过
// res = updateDirectApplyInfo(directApplyInfoDetails);
// if (res == 0) {
// throw new RuntimeException("updateDirectApplyInfo异常");
// }
//
// //创建领料信息和详情
// res = createLeaseInfo(directApplyInfoDetails);
// if (res == 0) {
// throw new RuntimeException("createLeaseInfo异常");
// }
//
// //创建退料信息和详情
// res = createBackInfo(directApplyInfoDetails);
// if (res == 0) {
// throw new RuntimeException("createBackInfo异常");
// }
//
// } catch (Exception e) {
// log.error(e.getMessage());
// }
// return res;
// }
//
// private int createBackInfo(DirectPassApplyInfoDetails directApplyInfoDetails) {
// int res = 0;
// try {
// BackApplyInfo backApplyInfo = directApplyInfoDetails.getBackApplyInfo();
// // 创建退料任务(1创建tm_task )
// res = createTmTaskByBackInfo(backApplyInfo);
// if (res == 0) {
// throw new RuntimeException("createBackTmTask异常");
// }
// //2.创建协议tm_task_agreement
// res = createAgreementByBackInfo(backApplyInfo);
// if (res == 0) {
// throw new RuntimeException("createBackAgreement异常");
// }
// // 3创建back_apply_info和back_apply_details和出库记录back_check_details和计算结算数据
// res = createtBackApplyInfoAndDetails(backApplyInfo);
// if (res == 0) {
// throw new RuntimeException("createBackApplyInfoAndDetails异常");
// }
// } catch (Exception e) {
// log.error(e.getMessage());
// }
// return res;
//
// }
//
// private int createtBackApplyInfoAndDetails(BackApplyInfo backApplyInfo) {
// int res = 0;
// //新增退料信息和详情back_apply_infoback_apply_details
// res = insertBackApplyInfoAndDetails(backApplyInfo);
// if (res == 0) {
// return res;
// }
//
// List<BackApplyInfo> backApplyDetails = backApplyInfo.getBackApplyDetails();
// if (CollUtil.isEmpty(backApplyDetails)) {
// return res;
// }
// //新增退料核查back_check_details
// Integer taskId = backApplyInfo.getTaskId();
// List<BackApplyInfo> backApplyInfoList = backApplyService.selectIdByTaskId(taskId);
// List<BackApplyInfo> list = new ArrayList();
// for (BackApplyInfo backApplyInfo1 : backApplyDetails) {
// BackApplyInfo backCheckDetails = new BackApplyInfo();
// for (BackApplyInfo backApplyInfo2 : backApplyInfoList) {
// if (backApplyInfo1.getCompanyId().equals(backApplyInfo2.getCompanyId())) {
// backCheckDetails.setParentId(backApplyInfo2.getId().intValue());
// backCheckDetails.setTypeId(backApplyInfo1.getTypeId());
// backCheckDetails.setMaId(backApplyInfo1.getMaId());
// backCheckDetails.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString());
// backCheckDetails.setBackNum(backApplyInfo1.getDirectNum());
// }
// }
// list.add(backCheckDetails);
// }
// res = insertBackCheckDetails(list);
// if (res == 0) {
// return res;
// }
// for (BackApplyInfo applyInfo : list) {
// List<BackApplyInfo> allList = backRecordMapper.getAllList(applyInfo);
// if (allList != null && allList.size() > 0) {
// res = updateSlt(applyInfo, allList);
// if (res == 0) {
// return res;
// }
// }
// }
// return res;
// }
//
// private int updateSlt(BackApplyInfo record, List<BackApplyInfo> hgList) {
// for (BackApplyInfo bean : hgList) {
// List<SltAgreementInfo> infoList = backRecordMapper.getStlInfo(bean);
// if (infoList.size() > 0) {
// Double backNum = Double.valueOf(bean.getBackNum());
// for (SltAgreementInfo info : infoList) {
// Double num = Double.valueOf(info.getNum());
// if (backNum.equals(num)) {
// backRecordMapper.updateStlInfo(info, record);
// break;
// } else if (backNum > num) {
// backNum = backNum - num;
// backRecordMapper.updateStlInfo(info, record);
// } else if (backNum < num) {
// Double many = num - backNum;
// backRecordMapper.updateStlInfoTwo(info, record, backNum);
// backRecordMapper.insStlInfoTwo(info, many);
// break;
// }
// }
// } else {
// return 0;
// }
// }
// return 1;
// }
// private int createAgreementByBackInfo(BackApplyInfo backApplyInfo) {
// int res = 0;
// res = insertAgreementByBackInfo(backApplyInfo);
// if (res == 0) {
// return res;
// }
// return res;
// }
// private int createTmTaskByBackInfo(BackApplyInfo backApplyInfo) {
// int res = 0;
// if (backApplyInfo == null) {
// return res;
// }
// // 生成退料code
// String tcode = tmTaskService.genderBackCode();
// backApplyInfo.setCode(tcode);
// //创建退料任务tm_task
// backApplyInfo.setTaskType(36);
// backApplyInfo.setTaskStatus("40");
// res = insertTmTaskByBackInfo(backApplyInfo);
// if (res == 0) {
// return res;
// }
// return res;
// }
// private int createLeaseInfo(DirectPassApplyInfoDetails directApplyInfoDetails) {
// int res = 0;
// try {
// TmTask lTask = directApplyInfoDetails.getLeaseApplyInfo();
// // 创建领料任务(1创建tm_task )
// int leaseTaskId = createTmTask(lTask, "1");
// if (leaseTaskId == 0) {
// throw new RuntimeException("createLeaseTmTask异常");
// }
// //2.创建协议tm_task_agreement
// lTask.setTaskId((long) leaseTaskId);
// res = createAgreementInfo(lTask);
// if (res == 0) {
// throw new RuntimeException("createAgreementInfo异常");
// }
// // 3创建lease_apply_info和lease_apply_details和出库记录lease_out_details
// res = createLeaseDetails(lTask);
// if (res == 0) {
// throw new RuntimeException("createLeaseDetails异常");
// }
//
// } catch (Exception e) {
// log.error(e.getMessage());
// }
//
// return res;
//
// }
// private int createLeaseDetails(TmTask lTask) {
// int res = 0;
// //新增领料信息和详情lease_apply_infolease_apply_details
// int res3 = insertApplyInfoAndDetails(lTask);
// if (res3 == 0) {
// return res;
// }
//
// List<LeaseApplyDetails> leaseApplyDetails = lTask.getLeaseApplyDetails();
// if (CollUtil.isEmpty(leaseApplyDetails)) {
// return res;
// }
// List<LeaseApplyInfo> leaseApplyInfoList = applyInfoService.selectIdByTaskId(Integer.parseInt(lTask.getId()));
// List<LeaseOutDetails> list = new ArrayList();
// for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) {
// LeaseOutDetails leaseOutDetails = new LeaseOutDetails();
// for (LeaseApplyInfo leaseApplyInfo : leaseApplyInfoList) {
// if (leaseApplyInfo.getCompanyId().equals(leaseApplyDetail.getCompanyId())) {
// leaseOutDetails.setParentId(leaseApplyInfo.getId());
// }
// }
// leaseOutDetails.setTypeId(leaseApplyDetail.getTypeId());
// leaseOutDetails.setMaId(leaseApplyDetail.getMaId());
// leaseOutDetails.setOutNum(leaseApplyDetail.getPreNum());
// leaseOutDetails.setCompanyId(leaseApplyDetail.getCompanyId());
// list.add(leaseOutDetails);
// }
// // 新增领料出库记录
// res = insertLeaseOutDetail(list, lTask);
// if (res == 0) {
// return res;
// }
// return res;
//
// }
// private int createAgreementInfo(TmTask task) {
// //任务与协议建立关联关系 (tm_task_agreement)
// int res = 0;
// try {
// res = insertAgreement(task);
// if (res == 0) {
// throw new RuntimeException("insertAgreement异常");
// }
//
// } catch (Exception e) {
// log.error(e.getMessage());
// }
// return res;
// }
// private int createTmTask(TmTask task, String taskType) {
// int taskId = 0;
// int res = 0;
// try {
// if ("1".equals(taskType)) {
// // 生成领料code
// String lcode = tmTaskService.genderLeaseCode();
// if (StringUtils.isEmpty(lcode)) {
// return res;
// }
// task.setCode(lcode);
// task.setTaskStatus(35);
// // 创建领料任务tm_task
// res = insertTmTask(task);
// if (res == 0) {
// throw new RuntimeException("insertTmTask异常");
// }
// taskId = Integer.valueOf(task.getId());
// }
// } catch (Exception e) {
// log.error(e.getMessage());
// }
//
// return taskId;
//
// }
//
// private int updateDirectApplyInfo(DirectPassApplyInfoDetails directApplyInfoDetails) {
// int res = 0;
// if (StringUtils.isNotBlank(directApplyInfoDetails.getId())) {
// DirectApplyInfo directApplyInfos = getDirectApplyInfoById(directApplyInfoDetails.getId());
// directApplyInfos.setStatus("1");
// directApplyInfos.setAuditor(SecurityUtils.getLoginUser().getUsername());
// directApplyInfos.setAuditTime(DateUtils.getNowDate());
// res = refuseDirectApplyInfo(directApplyInfos);
// } else {
// return res;
// }
// return res;
// }
//
// public int insertBcd(List<BackApplyInfo> backApplyDetails) {
// int res = 0;
// for (BackApplyInfo backApplyDetail : backApplyDetails) {
// backApplyDetail.setBackStatus("1");
// res = backRecordMapper.insertCheckDetails(backApplyDetail);
// }
// return res;
// }
}

View File

@ -5,6 +5,7 @@ import com.bonus.common.biz.enums.PurchaseTaskStatusEnum;
import com.bonus.common.biz.enums.TmTaskTypeEnum;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.encryption.Sm4Utils;
import com.bonus.common.core.utils.sms.SmsUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.purchase.domain.dto.PurchaseNoticePersonDto;
@ -71,9 +72,26 @@ public class PurchaseNoticePersonServiceImpl implements IPurchaseNoticePersonSer
@Override
@Transactional
public AjaxResult batchSendSms(PurchaseNoticePersonDto purchaseNoticePersonDto) {
// for (String phoneNumber : purchaseNoticePersonDto.getPhoneNumbers()) {
// if (phoneNumber != null && phoneNumber.length() != 11) {
// String decrypted = Sm4Utils.decrypt(phoneNumber);
// }
// }
for (int i = 0; i < purchaseNoticePersonDto.getPhoneNumbers().size(); i++) {
String phoneNumber = purchaseNoticePersonDto.getPhoneNumbers().get(i);
if (phoneNumber != null && phoneNumber.length() != 11) {
String decrypted = Sm4Utils.decrypt(phoneNumber);
purchaseNoticePersonDto.getPhoneNumbers().set(i, decrypted);
}
}
String splitPhoneNumber = String.join(",", purchaseNoticePersonDto.getPhoneNumbers());
try {
String sendResult = SmsUtils.smsToken(splitPhoneNumber, purchaseNoticePersonDto.getContent(), "60");
String sendResult = SmsUtils.smsToken(splitPhoneNumber, purchaseNoticePersonDto.getContent(),"");
if (sendResult != null) {
// 发送短信后修改任务状态
tmTaskMapper.updateTmTask(new TmTask()

View File

@ -1,6 +1,7 @@
package com.bonus.material.repair.controller;
import java.util.List;
import java.util.Objects;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull;
@ -31,6 +32,8 @@ import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.utils.poi.ExcelUtil;
import com.bonus.common.core.web.page.TableDataInfo;
import static com.bonus.common.biz.enums.TmTaskTypeEnum.TM_TASK_REPAIR_AUDIT;
/**
* 修试审核详细Controller
*
@ -50,7 +53,7 @@ public class RepairAuditDetailsController extends BaseController {
*/
@ApiOperation("查询修试审核任务列表")
@GetMapping("/questList")
@SysLog(title = "查询修试审核任务列表", businessType = OperaType.QUERY, logType = 1,module = "机具系统->查询修试审核任务列表")
@SysLog(title = "查询修试审核任务列表", businessType = OperaType.QUERY, module = "机具系统->查询修试审核任务列表")
@RequiresPermissions("service:auditing:list")
public TableDataInfo questList(RepairAuditDetails repairAuditDetails) {
startPage();
@ -63,11 +66,17 @@ public class RepairAuditDetailsController extends BaseController {
* 导出修试审核任务列表
*/
@PostMapping("/export")
@SysLog(title = "导出修试审核任务列表", businessType = OperaType.EXPORT, logType = 1,module = "机具系统->导出修试审核任务列表")
@SysLog(title = "导出修试审核任务列表", businessType = OperaType.EXPORT, module = "机具系统->导出修试审核任务列表")
public void exportAudit(HttpServletResponse response, RepairAuditDetails bean) {
if (bean == null) {
bean = new RepairAuditDetails();
}
if (Objects.isNull(bean.getTaskType())) {
bean.setTaskType(TM_TASK_REPAIR_AUDIT.getTaskTypeId());
}
repairAuditDetailsService.queryTimeCope(bean);
List<RepairAuditDetailsVO> list = repairAuditDetailsService.exportRepairQuestList(bean);
ExcelUtil<RepairAuditDetailsVO> util = new ExcelUtil<>(RepairAuditDetailsVO.class);
List<ScrapApplyDetailsVO> list = repairAuditDetailsService.selectRepairQuestList(bean);
ExcelUtil<ScrapApplyDetailsVO> util = new ExcelUtil<>(ScrapApplyDetailsVO.class);
util.exportExcel(response, list, "修试审核任务列表");
}

View File

@ -543,7 +543,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">remark = #{remark},</if>
<if test="companyId != null">company_id = #{companyId},</if>
<if test="backTime != null">back_time = #{backTime},</if>
<if test="status != null">status = #{status},</if>
<if test="status != null">`status` = #{status},</if>
<if test="directId != null">direct_id = #{directId},</if>
<if test="printStatus != null">print_status = #{printStatus},</if>
</trim>

View File

@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.material.basic.mapper.BmStorageLogMapper">
<resultMap type="com.bonus.material.basic.domain.BmStorageLog" id="BmStorageLogResult">
<resultMap type="com.bonus.common.biz.domain.BmStorageLog" id="BmStorageLogResult">
<result property="id" column="id" />
<result property="modelTitle" column="model_title" />
<result property="method" column="method" />
@ -35,7 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select id, model_title, method, type_id, pre_store_num, in_num, out_num, back_num, pass_num, repair_num, scrap_num, post_store_num, task_id, agreement_id, manage_type, type_name, type_model_name, result_code, result_msg, remark, status, json_result, creator, create_time, update_time from bm_storage_log
</sql>
<select id="selectBmStorageLogList" parameterType="com.bonus.material.basic.domain.BmStorageLog" resultMap="BmStorageLogResult">
<select id="selectBmStorageLogList" parameterType="com.bonus.common.biz.domain.BmStorageLog" resultMap="BmStorageLogResult">
<include refid="selectBmStorageLogVo"/>
<where>
<if test="modelTitle != null and modelTitle != ''"> and model_title = #{modelTitle}</if>
@ -67,7 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</select>
<insert id="insertBmStorageLog" parameterType="com.bonus.material.basic.domain.BmStorageLog" useGeneratedKeys="true" keyProperty="id">
<insert id="insertBmStorageLog" parameterType="com.bonus.common.biz.domain.BmStorageLog" useGeneratedKeys="true" keyProperty="id">
insert into bm_storage_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="modelTitle != null">model_title,</if>
@ -123,7 +123,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<update id="updateBmStorageLog" parameterType="com.bonus.material.basic.domain.BmStorageLog">
<update id="updateBmStorageLog" parameterType="com.bonus.common.biz.domain.BmStorageLog">
update bm_storage_log
<trim prefix="SET" suffixOverrides=",">
<if test="modelTitle != null">model_title = #{modelTitle},</if>

View File

@ -588,6 +588,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join ma_type_keeper mtk on mt4.type_id=mtk.type_id
left join sys_user su on mtk.user_id=su.user_id
where mt4.del_flag = 0 and mt4.level = 4
<if test="level == 1">
and mt1.type_id=#{typeId}
</if>
<if test="level == 2">
and mt2.type_id=#{typeId}
</if>
<if test="level == 3">
and mt3.type_id=#{typeId}
</if>
UNION
@ -601,6 +610,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join wh_house_set whs on mt1.type_id=whs.type_id
left join wh_house_info whi on whs.house_id=whi.house_id
where mt3.del_flag = 0 and mt3.level = 3
<if test="level == 1">
and mt1.type_id=#{typeId}
</if>
<if test="level == 2">
and mt2.type_id=#{typeId}
</if>
<if test="level == 3">
and mt3.type_id=#{typeId}
</if>
UNION
@ -613,6 +631,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join wh_house_set whs on mt1.type_id=whs.type_id
left join wh_house_info whi on whs.house_id=whi.house_id
where mt2.del_flag = 0 and mt2.level = 2
<if test="level == 1">
and mt1.type_id=#{typeId}
</if>
<if test="level == 2">
and mt2.type_id=#{typeId}
</if>
UNION
@ -624,6 +648,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join wh_house_set whs on mt1.type_id=whs.type_id
left join wh_house_info whi on whs.house_id=whi.house_id
where mt1.del_flag = 0 and mt1.level = 1
<if test="level == 1">
and mt1.type_id=#{typeId}
</if>
order by type_id
</select>
@ -642,6 +669,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join ma_type_repair mtr on mt4.type_id=mtr.type_id
left join sys_user su on mtr.user_id=su.user_id
where mt4.del_flag = 0 and mt4.level = 4
<if test="level == 1">
and mt1.type_id=#{typeId}
</if>
<if test="level == 2">
and mt2.type_id=#{typeId}
</if>
<if test="level == 3">
and mt3.type_id=#{typeId}
</if>
UNION
@ -655,6 +691,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join wh_house_set whs on mt1.type_id=whs.type_id
left join wh_house_info whi on whs.house_id=whi.house_id
where mt3.del_flag = 0 and mt3.level = 3
<if test="level == 1">
and mt1.type_id=#{typeId}
</if>
<if test="level == 2">
and mt2.type_id=#{typeId}
</if>
<if test="level == 3">
and mt3.type_id=#{typeId}
</if>
UNION
@ -667,6 +712,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join wh_house_set whs on mt1.type_id=whs.type_id
left join wh_house_info whi on whs.house_id=whi.house_id
where mt2.del_flag = 0 and mt2.level = 2
<if test="level == 1">
and mt1.type_id=#{typeId}
</if>
<if test="level == 2">
and mt2.type_id=#{typeId}
</if>
UNION
@ -678,6 +729,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join wh_house_set whs on mt1.type_id=whs.type_id
left join wh_house_info whi on whs.house_id=whi.house_id
where mt1.del_flag = 0 and mt1.level = 1
<if test="level == 1">
and mt1.type_id=#{typeId}
</if>
order by type_id
</select>

View File

@ -0,0 +1,536 @@
<?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.material.ma.mapper.WorkSiteDirectManageMapper">
<insert id="saveDirectApplyInfo" parameterType="com.bonus.material.ma.domain.DirectApplyInfo" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into direct_apply_info
(
<if test="code != null and code != ''">
code,
</if>
<if test="backAgreementId != null">
back_agreement_id,
</if>
<if test="backMan != null and backMan != ''">
back_man,
</if>
<if test="backPhone != null and backPhone != ''">
back_phone,
</if>
<if test="backRemark != null and backRemark != ''">
back_remark,
</if>
<if test="leaseAgreementId != null">
lease_agreement_id,
</if>
<if test="leaseMan != null and leaseMan != ''">
lease_man,
</if>
<if test="leasePhone != null and leasePhone != ''">
lease_phone,
</if>
<if test="dirUrl != null and dirUrl != ''">
dir_url,
</if>
<if test="status != null and status != ''">
status,
</if>
<if test="auditor != null and auditor != ''">
auditor,
</if>
<if test="auditTime != null">
audit_time,
</if>
<if test="auditRemark != null and auditRemark != ''">
audit_remark,
</if>
create_time
) values (
<if test="code != null and code != ''">
#{code},
</if>
<if test="backAgreementId != null">
#{backAgreementId},
</if>
<if test="backMan != null and backMan != ''">
#{backMan},
</if>
<if test="backPhone != null and backPhone != ''">
#{backPhone},
</if>
<if test="backRemark != null and backRemark != ''">
#{backRemark},
</if>
<if test="leaseAgreementId != null">
#{leaseAgreementId},
</if>
<if test="leaseMan != null and leaseMan != ''">
#{leaseMan},
</if>
<if test="leasePhone != null and leasePhone != ''">
#{leasePhone},
</if>
<if test="dirUrl != null and dirUrl != ''">
#{dirUrl},
</if>
<if test="status != null and status != ''">
#{status},
</if>
<if test="auditor != null and auditor != ''">
#{auditor},
</if>
<if test="auditTime != null">
#{auditTime},
</if>
<if test="auditRemark != null and auditRemark != ''">
#{auditRemark},
</if>
NOW()
)
</insert>
<insert id="saveDirectApplyDetails" parameterType="com.bonus.material.ma.domain.DirectApplyDetails">
insert into direct_apply_details(direct_id,type_id,ma_id,direct_num,create_time)
values (#{directId},#{typeId},#{maId}, #{directNum},NOW())
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bonus.material.lease.domain.LeaseApplyInfo" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into lease_apply_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="code != null">
code,
</if>
<if test="taskId != null">
task_id,
</if>
<if test="leasePerson != null and leasePerson != ''">
lease_person,
</if>
<if test="phone != null and phone != ''">
phone,
</if>
<if test="type != null and type != ''">
`type`,
</if>
<if test="companyAuditBy != null">
company_audit_by,
</if>
<if test="companyAuditTime != null and companyAuditTime != ''">
company_audit_time,
</if>
<if test="companyAuditRemark != null and companyAuditRemark != ''">
company_audit_remark,
</if>
<if test="deptAuditBy != null">
dept_audit_by,
</if>
<if test="deptAuditTime != null and deptAuditTime != ''">
dept_audit_time,
</if>
<if test="deptAuditRemark != null and deptAuditRemark != ''">
dept_audit_remark,
</if>
<if test="createBy != null and createBy != ''">
create_by,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateBy != null and updateBy != ''">
update_by,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="remark != null and remark != ''">
remark,
</if>
<if test="companyId != null">
company_id,
</if>
<if test="status != null and status != ''">
status,
</if>
<if test="leaseType != null and leaseType != ''">
lease_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="code != null">
#{code,jdbcType=VARCHAR},
</if>
<if test="taskId != null">
#{taskId,jdbcType=INTEGER},
</if>
<if test="leasePerson != null and leasePerson != ''">
#{leasePerson,jdbcType=VARCHAR},
</if>
<if test="phone != null and phone != ''">
#{phone,jdbcType=VARCHAR},
</if>
<if test="type != null and type != ''">
#{type,jdbcType=VARCHAR},
</if>
<if test="companyAuditBy != null">
#{companyAuditBy,jdbcType=INTEGER},
</if>
<if test="companyAuditTime != null and companyAuditTime != ''">
#{companyAuditTime,jdbcType=VARCHAR},
</if>
<if test="companyAuditRemark != null and companyAuditRemark != ''">
#{companyAuditRemark,jdbcType=VARCHAR},
</if>
<if test="deptAuditBy != null">
#{deptAuditBy,jdbcType=INTEGER},
</if>
<if test="deptAuditTime != null and deptAuditTime != ''">
#{deptAuditTime,jdbcType=VARCHAR},
</if>
<if test="deptAuditRemark != null and deptAuditRemark != ''">
#{deptAuditRemark,jdbcType=VARCHAR},
</if>
<if test="createBy != null and createBy != ''">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null and updateBy != ''">
#{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="remark != null and remark != ''">
#{remark,jdbcType=VARCHAR},
</if>
<if test="companyId != null">
#{companyId,jdbcType=INTEGER},
</if>
<if test="status != null and status != ''">
#{status,jdbcType=VARCHAR},
</if>
<if test="leaseType != null and leaseType != ''">
#{leaseType,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into lease_apply_details
(parennt_id, type_id, pre_num, al_num, `status`, create_by, create_time, update_by,
update_time, remark, company_id)
values
<foreach collection="list" item="item" separator=",">
(#{item.parenntId,jdbcType=INTEGER}, #{item.typeId,jdbcType=INTEGER}, #{item.preNum,jdbcType=FLOAT},
#{item.alNum,jdbcType=FLOAT}, #{item.status,jdbcType=VARCHAR}, #{item.createBy,jdbcType=VARCHAR},
NOW(), #{item.updateBy,jdbcType=VARCHAR}, NOW(),
#{item.remark,jdbcType=VARCHAR}, #{item.companyId,jdbcType=INTEGER})
</foreach>
</insert>
<insert id="insertLeaseOutDetails">
insert into lease_out_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="parentId!= null">
parent_id,
</if>
<if test="typeId!= null">
type_id,
</if>
<if test="maId!= null">
ma_id,
</if>
<if test="outNum!= null">
out_num,
</if>
<if test="outType!= null">
out_type,
</if>
<if test="createBy!= null">
create_by,
</if>
<if test="updateBy!= null">
update_by,
</if>
<if test="remark!= null">
remark,
</if>
<if test="companyId!= null">
company_id,
</if>
<if test="carCode!= null">
car_code,
</if>
create_time,
update_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parentId!= null">
#{parentId},
</if>
<if test="typeId!= null">
#{typeId},
</if>
<if test="maId!= null">
#{maId},
</if>
<if test="outNum!= null">
#{outNum},
</if>
<if test="outType!= null">
#{outType},
</if>
<if test="createBy!= null">
#{createBy},
</if>
<if test="updateBy!= null">
#{updateBy},
</if>
<if test="remark!= null">
#{remark},
</if>
<if test="companyId!= null">
#{companyId},
</if>
<if test="carCode!= null">
#{carCode},
</if>
NOW(),
NOW()
</trim>
</insert>
<insert id="insertBackApplyInfo" keyColumn="task_id" keyProperty="taskId" parameterType="com.bonus.material.back.domain.BackApplyInfo" useGeneratedKeys="true">
insert into tm_task (
<if test="taskType != null">task_type, </if>
<if test="taskStatus != null">task_status, </if>
<if test="code != null and code != ''">code, </if>
<if test="createBy != null and createBy != ''">create_by, </if>
<if test="updateBy != null and updateBy != ''">update_by, </if>
<if test="updateTime != null">update_time, </if>
<if test="remark != null and remark != ''">remark, </if>
<if test="companyId != null">company_id, </if>
create_time
) values (
<if test="taskType != null">#{taskType}, </if>
<if test="taskStatus != null">#{taskStatus}, </if>
<if test="code != null and code != ''">#{code}, </if>
<if test="createBy != null and createBy != ''">#{createBy}, </if>
<if test="updateBy != null and updateBy != ''">#{updateBy}, </if>
<if test="updateTime != null">#{updateTime}, </if>
<if test="remark != null and remark != ''">#{remark}, </if>
<if test="companyId != null">#{companyId}, </if>
NOW()
)
</insert>
<update id="refuseDirectApplyInfo">
update direct_apply_info set status = #{status},auditor=#{auditor},audit_time=#{auditTime},update_time = now() where id = #{id}
</update>
<update id="updateLeaseApplyDetailsOutNum">
UPDATE
lease_apply_details
SET
al_num = IF(al_num IS NULL, #{record.outNum}, al_num + #{record.outNum}),
<if test="record.updateBy != null and record.updateBy!= '' ">
update_by = #{record.updateBy},
</if>
update_time = now(),
status = '2'
WHERE
parennt_id = #{record.parentId} and type_id = #{record.typeId}
</update>
<update id="updateMaTypeStockNum">
UPDATE
ma_type
SET
num = num - #{record.outNum} ,update_time = NOW()
WHERE
type_id = #{record.typeId}
</update>
<update id="updateMaMachineStatus">
UPDATE
ma_machine
SET
ma_status = '16' , create_time = NOW()
<where>
type_id = #{record.typeId}
<if test="record.maId != null and record.maId != ''">
and ma_id = #{record.maId}
</if>
</where>
</update>
<delete id="batchDel">
delete
from lease_user_book
where id in
<foreach close=")" collection="ids" item="id" open="(" separator=", ">
#{id}
</foreach>
</delete>
<select id="getUseringData" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
SELECT
sai.*,
mt.type_name AS typeModelName,
mt2.type_name AS typeName,
mm.ma_code AS maCode,
sum(sai.num) AS useNum
FROM
slt_agreement_info sai
LEFT JOIN ma_type mt on sai.type_id = mt.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
LEFT JOIN ma_machine mm on sai.ma_id = mm.ma_id
where sai.agreement_id = #{agreementId} and sai.status = '0'
<if test="keyWord != null and keyWord != ''">
and (mt2.type_name like concat('%', #{keyWord}, '%') or
mt.type_name like concat('%', #{keyWord}, '%'))
</if>
GROUP BY
sai.ma_id,sai.type_id
</select>
<select id="getList" resultType="com.bonus.material.ma.domain.DirectApplyInfo">
SELECT DISTINCT
dai.*,
bpl.pro_id AS backProId,
bpl.pro_name AS backProName,
bui.unit_id AS backUnitId,
bui.unit_name AS backUnitName,
bpl1.pro_id AS leaseProId,
bpl1.pro_name AS leaseProName,
bui1.unit_id AS leaseUnitId,
bui1.unit_name AS leaseUnitName
FROM
direct_apply_info dai
LEFT JOIN bm_agreement_info bai ON dai.back_agreement_id = bai.agreement_id
LEFT JOIN bm_agreement_info bai1 ON dai.lease_agreement_id = bai1.agreement_id
LEFT JOIN bm_project bpl ON bpl.pro_id = bai.project_id
LEFT JOIN bm_project bpl1 ON bpl1.pro_id = bai1.project_id
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
LEFT JOIN bm_unit bui1 ON bui1.unit_id = bai1.unit_id
WHERE
1=1
<if test="keyWord != null and keyWord != ''">
and (bpl.pro_name like concat('%', #{keyWord}, '%') or
bui.unit_name like concat('%', #{keyWord}, '%'))
</if>
<if test="lotId != null and lotId != ''">
and bpl.pro_id = #{lotId}
</if>
<if test="unitId != null and unitId != ''">
and bui.unit_id = #{unitId}
</if>
<if test="status != null and status != ''">
and dai.status = #{status}
</if>
</select>
<select id="getDirectApplyInfoById" resultType="com.bonus.material.ma.domain.DirectApplyInfo">
select * from direct_apply_info where id = #{id}
</select>
<select id="getMachineStatus" resultType="com.bonus.material.ma.domain.DirectApplyInfo">
select ma_status as status
from ma_machine
where ma_id = #{maId}
</select>
<select id="getListLease" resultType="com.bonus.material.ma.domain.DirectApplyInfo">
SELECT DISTINCT
bpl.lot_id as backProId,bpl.lot_name as backProName,
bui.unit_id as backUnitId,bui.unit_name as backUnitName
FROM
direct_apply_info dai
LEFT JOIN bm_agreement_info bai ON dai.agreement_id = bai.agreement_id
LEFT JOIN bm_project_lot bpl ON bpl.lot_id = bai.project_id
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
</select>
<select id="getInfoById" resultType="com.bonus.material.ma.domain.DirectApplyInfo">
SELECT
dai.*,
bai.agreement_code as backAgreementCode,
bai1.agreement_code as leaseAgreementCode,
bpl.lot_id AS backProId,
bpl.lot_name AS backProName,
bui.unit_id AS backUnitId,
bui.unit_name AS backUnitName,
bpl1.lot_id AS leaseProId,
bpl1.lot_name AS leaseProName,
bui1.unit_id AS leaseUnitId,
bui1.unit_name AS leaseUnitName
FROM
direct_apply_info dai
LEFT JOIN direct_apply_details dad ON dai.id = dad.direct_id
LEFT JOIN bm_agreement_info bai ON dai.back_agreement_id = bai.agreement_id
LEFT JOIN bm_agreement_info bai1 ON dai.lease_agreement_id = bai1.agreement_id
LEFT JOIN bm_project_lot bpl ON bpl.lot_id = bai.project_id
LEFT JOIN bm_project_lot bpl1 ON bpl1.lot_id = bai1.project_id
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
LEFT JOIN bm_unit_info bui1 ON bui1.unit_id = bai1.unit_id
WHERE
dai.id = #{id} GROUP BY dai.id
</select>
<select id="getDetailById" resultType="com.bonus.material.ma.domain.DirectApplyDetails">
SELECT
dad.direct_num AS directNum,
dad.type_id AS typeId,
mt.company_id AS companyId,
mt3.type_name AS typeName,
mt2.type_name AS kindName,
mt.type_name AS modelName,
mt.unit_name AS unitName,
sum( sai.num ) AS useNum,
mm.ma_code AS maCode,
mm.ma_id AS maId
FROM
direct_apply_info dai
LEFT JOIN direct_apply_details dad ON dai.id = dad.direct_id
LEFT JOIN slt_agreement_info sai ON dai.back_agreement_id = sai.agreement_id
AND sai.type_id = dad.type_id
LEFT JOIN ma_type mt ON mt.type_id = dad.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
LEFT JOIN ma_machine mm ON dad.ma_id = mm.ma_id
WHERE
dai.id = #{id}
AND sai.STATUS = '0'
<if test="keyWord != null and keyWord != ''">
and (mt2.type_name like concat('%', #{keyWord}, '%') or
mt.type_name like concat('%', #{keyWord}, '%'))
</if>
GROUP BY
dad.id,sai.type_id
</select>
<select id="getListAll" resultType="com.bonus.material.ma.domain.DirectApplyInfo">
SELECT
dai.*,
bpl.lot_id AS backProId,
bpl.lot_name AS backProName,
bui.unit_id AS backUnitId,
bui.unit_name AS backUnitName,
bpl1.lot_id AS leaseProId,
bpl1.lot_name AS leaseProName,
bui1.unit_id AS leaseUnitId,
bui1.unit_name AS leaseUnitName
FROM
direct_apply_info dai
LEFT JOIN bm_agreement_info bai ON dai.back_agreement_id = bai.agreement_id
LEFT JOIN bm_agreement_info bai1 ON dai.lease_agreement_id = bai1.agreement_id
LEFT JOIN bm_project_lot bpl ON bpl.lot_id = bai.project_id
LEFT JOIN bm_project_lot bpl1 ON bpl1.lot_id = bai1.project_id
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
LEFT JOIN bm_unit_info bui1 ON bui1.unit_id = bai1.unit_id
</select>
</mapper>