Merge remote-tracking branch 'origin/master'

This commit is contained in:
mashuai 2025-02-18 09:21:08 +08:00
commit a72cebcb00
39 changed files with 1992 additions and 97 deletions

View File

@ -498,6 +498,7 @@ public class DateTimeHelper {
return first;
}
public static String getLastDay() {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
// 获取当前月最后一天

View File

@ -237,4 +237,20 @@ public class LeaseApplyInfo extends BaseEntity{
*/
@ApiModelProperty(value = "分包商单位委托书")
List<BmFileInfo> bmFileInfos;
/**
* 标准配置id
*/
@ApiModelProperty(value = "标准配置id")
private Long configId;
/**
* 是否为领用申请
*/
@ApiModelProperty(value = "是否为领用申请")
private Integer isLease;
@ApiModelProperty(value = "采购申请编号")
private String applyCode;
}

View File

@ -9,7 +9,8 @@ import lombok.Getter;
*/
@Getter
public enum LeaseTaskStatusEnum {
//0-领用申请任务待审核其余为领料申请流程状态
LEASE_TASK_ZERO(0, "待审核"),
LEASE_TASK_TO_PUBLISHED(1, "待发布"),
LEASE_TASK_TO_AUDIT(2, "待审核"),
LEASE_TASK_IN_PROGRESS(3, "出库进行中"),

View File

@ -264,4 +264,19 @@ public class LeaseApplyInfoController extends BaseController {
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(leaseApplyInfoService.deleteLeaseApplyInfoByIds(ids));
}
/**
* 领用任务批量审核
*/
@ApiOperation(value = "领用任务批量审核")
@PreventRepeatSubmit
@SysLog(title = "领用任务批量审核", businessType = OperaType.UPDATE, logType = 1,module = "领用审核->领用任务批量审核")
@PostMapping("/useExamine")
public AjaxResult useExamine(@RequestBody @NotNull(message = "任务信息不能为空") List<LeaseApplyInfo> leaseApplyInfos) {
for (LeaseApplyInfo leaseApplyInfo : leaseApplyInfos) {
leaseApplyInfoService.useExamine(leaseApplyInfo);
}
return success("审核完成");
}
}

View File

@ -0,0 +1,104 @@
package com.bonus.material.lease.controller;
import cn.hutool.core.convert.Convert;
import com.bonus.common.biz.config.ListPagingUtil;
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
import com.bonus.common.core.utils.ServletUtils;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import com.bonus.material.common.annotation.PreventRepeatSubmit;
import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo;
import com.bonus.material.lease.service.ILeaseApplyInfoService;
import com.bonus.material.lease.service.ILeaseTaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
/**
* @author hay
* @description 业务办理--领用任务
* @date 2025/2/17 13:13
*/
@Api(tags = "领用任务接口")
@RestController
@RequestMapping("/leaseTask")
public class LeaseTaskController extends BaseController {
@Resource
private ILeaseTaskService service;
/**
* 新增领用任务
*/
@ApiOperation(value = "新增领用任务")
@PreventRepeatSubmit
@SysLog(title = "领用任务", businessType = OperaType.INSERT, logType = 1, module = "领用申请->新增领用任务")
@PostMapping
public AjaxResult add(@NotNull(message = "领用任务不能为空") @RequestBody LeaseApplyRequestVo leaseApplyRequestVo) {
try {
return service.insertLeaseApplyInfo(leaseApplyRequestVo);
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
}
}
/**
* 领用记录查询
*/
@ApiOperation(value = "领用记录列表查询")
@GetMapping("/list")
public AjaxResult list(LeaseApplyInfo leaseApplyInfo) {
Integer pageIndex = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
Integer pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
try {
List<LeaseApplyInfo> list = service.selectLeaseApplyInfoList(leaseApplyInfo);
return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, list));
} catch (Exception e) {
return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, new ArrayList<>()));
}
}
/**
* 领用记录详情查看
*/
@ApiOperation(value = "领用记录详情查看")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@NotNull(message = "领用任务ID不能为空") @PathVariable("id") Long id,
@RequestParam(value = "keyWord", required = false) String keyWord) {
return success(service.selectLeaseApplyInfoById(id, keyWord));
}
/**
* 修改领用任务
*/
@ApiOperation(value = "修改领用任务")
@PreventRepeatSubmit
@SysLog(title = "领用任务", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改领用任务")
@PutMapping
public AjaxResult edit(@RequestBody @NotNull LeaseApplyRequestVo leaseApplyRequestVo) {
try {
return toAjax(service.updateLeaseApplyInfo(leaseApplyRequestVo));
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
}
}
/**
* 删除领用任务
*/
@ApiOperation(value = "删除领用任务")
@PreventRepeatSubmit
@SysLog(title = "领用任务", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除领用任务")
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(service.deleteLeaseApplyInfoByIds(ids));
}
}

View File

@ -0,0 +1,63 @@
package com.bonus.material.lease.mapper;
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
import com.bonus.material.lease.domain.LeaseApplyDetails;
import java.util.List;
/**
* @description 业务办理--领用任务
* @author hay
* @date 2025/2/17 13:18
*/
public interface LeaseTaskMapper {
/**
* 新增领用任务
*
* @param leaseApplyInfo 领用任务
* @return 结果
*/
int insertLeaseApplyInfo(LeaseApplyInfo leaseApplyInfo);
/**
* 插入详情数据
*
* @param leaseApplyDetails 领用任务详情
* @return 结果
*/
int insertLeaseApplyDetailsList(List<LeaseApplyDetails> leaseApplyDetails);
/**
* 领用记录列表查询
*
* @param leaseApplyInfo 领用任务
* @return 领用任务集合
*/
List<LeaseApplyInfo> selectLeaseApplyInfoList(LeaseApplyInfo leaseApplyInfo);
/**
* 查询领用任务详细列表
*
* @param leaseApplyDetails 领用任务详细
* @return 领用任务详细集合
*/
List<LeaseApplyDetails> selectLeaseApplyDetailsList(LeaseApplyDetails leaseApplyDetails);
/**
* 修改领用任务
*
* @param leaseApplyInfo 领用任务
* @return 结果
*/
int updateLeaseApplyInfo(LeaseApplyInfo leaseApplyInfo);
/**
* 查询领用任务
*
* @param leaseApplyInfo
* @return 领用任务
*/
LeaseApplyInfo selectLeaseApplyInfoById(LeaseApplyInfo leaseApplyInfo);
}

View File

@ -135,4 +135,11 @@ public interface ILeaseApplyInfoService {
* @return
*/
AjaxResult leaseOutBack(LeaseOutDetails leaseOutDetails);
/**
* 领用任务批量审核
* @param leaseApplyInfo
* @return
*/
AjaxResult useExamine(LeaseApplyInfo leaseApplyInfo);
}

View File

@ -0,0 +1,59 @@
package com.bonus.material.lease.service;
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo;
import java.util.List;
/**
* @author hay
* @description 业务办理--领用任务
* @date 2025/2/17 13:15
*/
public interface ILeaseTaskService {
/**
* 新增领用任务
*
* @param leaseApplyRequestVo 领用任务
* @return 结果
*/
AjaxResult insertLeaseApplyInfo(LeaseApplyRequestVo leaseApplyRequestVo);
/**
* 领用记录列表查询
*
* @param leaseApplyInfo 领用任务
* @return 领用任务集合
*/
List<LeaseApplyInfo> selectLeaseApplyInfoList(LeaseApplyInfo leaseApplyInfo);
/**
* 领用记录详情查看
*
* @param id
* @param keyWord
* @return
*/
LeaseApplyRequestVo selectLeaseApplyInfoById(Long id, String keyWord);
/**
* 修改领用任务
*
* @param leaseApplyRequestVo 领用任务
* @return 结果
*/
boolean updateLeaseApplyInfo(LeaseApplyRequestVo leaseApplyRequestVo);
/**
* 批量删除领用任务
*
* @param ids 需要删除的领用任务主键集合
* @return 结果
*/
int deleteLeaseApplyInfoByIds(Long[] ids);
}

View File

@ -177,7 +177,7 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
/**
* 新增领料任务
*
*
* @param leaseApplyRequestVo 领料任务
* @return 结果
*/
@ -270,6 +270,37 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
}
}
/**
* 领用任务审核
*/
@Override
public AjaxResult useExamine(LeaseApplyInfo leaseApplyInfo) {
if (leaseApplyInfo.getId() == null) {
return AjaxResult.error("ID为空,请完善后重新发布!");
}
if (leaseApplyInfo.getTaskId() == null) {
return AjaxResult.error("任务ID为空,请完善后重新发布!");
}
try {
int result = leaseApplyInfoMapper.updateLeaseApplyInfo(leaseApplyInfo);
if (result > 0) {
// 同步修改tm_task任务状态, 如果不需要审核改成 LEASE_TASK_IN_PROGRESS 如果需要审核改成 LEASE_TASK_TO_AUDIT
TmTask tmTask = new TmTask();
tmTask.setTaskType(TmTaskTypeEnum.TM_TASK_LEASE.getTaskTypeId());
tmTask.setTaskId(leaseApplyInfo.getTaskId());
tmTask.setTaskStatus(LeaseTaskStatusEnum.LEASE_TASK_TO_PUBLISHED.getStatus());
tmTaskMapper.updateTmTask(tmTask);
return AjaxResult.success("审核成功");
}
return AjaxResult.error("审核失败");
} catch (DataAccessException e) {
// 抛出异常回滚数据
throw new RuntimeException();
} catch (Exception e) {
return AjaxResult.error("审核失败:" + e.getMessage());
}
}
private AjaxResult insertPurchaseCheckDetails(List<LeaseApplyDetails> leaseApplyDetailsList, Long parentId) {
if (!CollectionUtils.isEmpty(leaseApplyDetailsList)) {
for (LeaseApplyDetails details : leaseApplyDetailsList) {

View File

@ -0,0 +1,320 @@
package com.bonus.material.lease.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.bonus.common.biz.constant.MaterialConstants;
import com.bonus.common.biz.domain.BmFileInfo;
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
import com.bonus.common.biz.enums.LeaseTaskStatusEnum;
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.StringUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.back.domain.vo.MaCodeVo;
import com.bonus.material.basic.mapper.BmFileInfoMapper;
import com.bonus.material.lease.domain.LeaseApplyDetails;
import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo;
import com.bonus.material.lease.mapper.LeaseApplyDetailsMapper;
import com.bonus.material.lease.mapper.LeaseApplyInfoMapper;
import com.bonus.material.lease.mapper.LeaseTaskMapper;
import com.bonus.material.lease.service.ILeaseTaskService;
import com.bonus.material.task.domain.TmTask;
import com.bonus.material.task.domain.TmTaskAgreement;
import com.bonus.material.task.mapper.TmTaskAgreementMapper;
import com.bonus.material.task.mapper.TmTaskMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @author hay
* @description 业务办理--领用任务
* @date 2025/2/17 13:16
*/
@Service
@Slf4j
public class LeaseTaskServiceImpl implements ILeaseTaskService {
@Resource
private LeaseTaskMapper mapper;
@Resource
private LeaseApplyInfoMapper leaseApplyInfoMapper;
@Resource
private LeaseApplyDetailsMapper leaseApplyDetailsMapper;
@Resource
private TmTaskMapper tmTaskMapper;
@Resource
TmTaskAgreementMapper tmTaskAgreementMapper;
@Resource
private BmFileInfoMapper bmFileInfoMapper;
/**
* 新增领用任务
*
* @param leaseApplyRequestVo 领用任务
* @return 结果
*/
@Override
public AjaxResult insertLeaseApplyInfo(LeaseApplyRequestVo leaseApplyRequestVo) {
if (null == leaseApplyRequestVo.getLeaseApplyInfo()) {
return AjaxResult.error("请先填写领用任务信息");
}
if (CollectionUtil.isEmpty(leaseApplyRequestVo.getLeaseApplyDetailsList())) {
return AjaxResult.error("请先添加领用任务物资明细");
}
leaseApplyRequestVo.getLeaseApplyInfo().setCreateTime(DateUtils.getNowDate());
leaseApplyRequestVo.getLeaseApplyInfo().setCreateBy(SecurityUtils.getUsername());
try {
int thisMonthMaxOrder = tmTaskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_LEASE.getTaskTypeId());
String taskCode = genderTaskCode(thisMonthMaxOrder);
TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_LEASE.getTaskTypeId(),
LeaseTaskStatusEnum.LEASE_TASK_ZERO.getStatus(),
leaseApplyRequestVo.getLeaseApplyInfo().getCompanyId(),thisMonthMaxOrder + 1, taskCode);
tmTask.setCreateTime(DateUtils.getNowDate());
tmTask.setCreateBy(SecurityUtils.getUsername());
tmTaskMapper.insertTmTask(tmTask);
TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(tmTask.getTaskId(), leaseApplyRequestVo.getLeaseApplyInfo().getAgreementId());
tmTaskAgreement.setCreateTime(DateUtils.getNowDate());
tmTaskAgreement.setCreateBy(SecurityUtils.getUsername());
tmTaskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
leaseApplyRequestVo.getLeaseApplyInfo().setTaskId(tmTask.getTaskId());
leaseApplyRequestVo.getLeaseApplyInfo().setCode(taskCode);
/** 设置审批人为默认的董班长 --防止代码冲突 **/
Long peopleId = leaseApplyInfoMapper.getDirectAuditBy();
leaseApplyRequestVo.getLeaseApplyInfo().setDirectAuditBy(peopleId);
/** 设置审批人为默认的董班长 --防止代码冲突 **/
int count = mapper.insertLeaseApplyInfo(leaseApplyRequestVo.getLeaseApplyInfo());
if (!CollectionUtils.isEmpty(leaseApplyRequestVo.getLeaseApplyInfo().getBmFileInfos())) {
leaseApplyRequestVo.getLeaseApplyInfo().getBmFileInfos().forEach(bmFileInfo -> {
bmFileInfo.setTaskType(2);
bmFileInfo.setTaskId(tmTask.getTaskId());
bmFileInfo.setModelId(leaseApplyRequestVo.getLeaseApplyInfo().getId());
bmFileInfo.setFileType(5L);
bmFileInfo.setCreateBy(SecurityUtils.getUsername());
bmFileInfo.setCreateTime(DateUtils.getNowDate());
bmFileInfoMapper.insertBmFileInfo(bmFileInfo);
});
}
if (count > 0) {
return insertPurchaseCheckDetails(leaseApplyRequestVo.getLeaseApplyDetailsList(), leaseApplyRequestVo.getLeaseApplyInfo().getId());
} else {
return AjaxResult.error("新增任务失败,lease_apply_info表插入0条");
}
} catch (DataAccessException e) {
return AjaxResult.error("数据库操作失败:" + e.getMessage());
} catch (Exception e) {
return AjaxResult.error("新增任务失败:" + e.getMessage());
}
}
/**
* 领用记录列表查询
*
* @param leaseApplyInfo 领用任务
* @return 领用任务
*/
@Override
public List<LeaseApplyInfo> selectLeaseApplyInfoList(LeaseApplyInfo leaseApplyInfo) {
Long userId = SecurityUtils.getUserId();
leaseApplyInfo.setUserId(userId == 0 ? null : userId);
List<LeaseApplyInfo> list = mapper.selectLeaseApplyInfoList(leaseApplyInfo);
if (!CollectionUtils.isEmpty(list)) {
String keyWord = leaseApplyInfo.getKeyWord();
// 如果关键字不为空进行过滤
if (!StringUtils.isBlank(keyWord)) {
list = list.stream()
.filter(item -> containsKeyword(item, keyWord))
.collect(Collectors.toList());
}
}
return list;
}
/**
* 根据id查询领用任务
*
* @param id 领用任务id
* @return 领用任务
*/
@Override
public LeaseApplyRequestVo selectLeaseApplyInfoById(Long id, String keyWord) {
try {
LeaseApplyInfo leaseApplyInfo = new LeaseApplyInfo();
leaseApplyInfo.setId(id);
Long userId = SecurityUtils.getUserId();
leaseApplyInfo.setUserId(userId);
Optional<LeaseApplyInfo> optionalInfo = Optional.ofNullable(mapper.selectLeaseApplyInfoById(leaseApplyInfo));
LeaseApplyRequestVo leaseApplyRequestVo = new LeaseApplyRequestVo();
optionalInfo.ifPresent(info -> {
BmFileInfo bmFileInfo = new BmFileInfo();
bmFileInfo.setModelId(id);
bmFileInfo.setTaskType(2);
bmFileInfo.setFileType(5L);
List<BmFileInfo> bmFileInfoList = bmFileInfoMapper.selectBmFileInfoList(bmFileInfo);
if (!CollectionUtils.isEmpty(bmFileInfoList)) {
info.setBmFileInfos(bmFileInfoList);
}
/** 设置审批人签名url 防止代码冲突 **/
String directAuditUrl = leaseApplyInfoMapper.getDirectAuditUrl(info);
info.setDirectAuditSignUrl(directAuditUrl);
/** 设置审批人签名url 防止代码冲突 **/
/** 设置发料单位 防止代码冲突 **/
if(info.getDirectAuditBy() != null){
String sendUnit = leaseApplyInfoMapper.getSendUnit(info);
info.setSendUnit(sendUnit);
}
/** 设置发料单位 防止代码冲突 **/
leaseApplyRequestVo.setLeaseApplyInfo(info);
// 获取领料单详情
List<LeaseApplyDetails> details = mapper.selectLeaseApplyDetailsList(new LeaseApplyDetails(info.getId(), keyWord, userId));
if (!CollectionUtils.isEmpty(details)) {
leaseApplyRequestVo.setLeaseApplyDetailsList(details);
for (LeaseApplyDetails detail : details) {
// 获取编码详情
List<MaCodeVo> maCodeVoList = leaseApplyDetailsMapper.getCodeList(id, detail.getTypeId());
if (!CollectionUtils.isEmpty(maCodeVoList)) {
detail.setMaCodeVoList(maCodeVoList);
}
}
}
});
return leaseApplyRequestVo;
} catch (Exception e) {
// 记录异常日志
System.err.println("Error occurred while selecting lease apply info by ID: " + id + e.getMessage());
throw new RuntimeException("Failed to select lease apply info", e);
}
}
@Override
public boolean updateLeaseApplyInfo(LeaseApplyRequestVo leaseApplyRequestVo) {
try {
// 提取到局部变量中减少重复代码
LeaseApplyInfo leaseApplyInfo = leaseApplyRequestVo.getLeaseApplyInfo();
if (leaseApplyInfo != null && leaseApplyInfo.getId() != null) {
leaseApplyInfo.setUpdateTime(DateUtils.getNowDate());
leaseApplyInfo.setUpdateBy(SecurityUtils.getUsername());
// 去除创建一个新的数组对象直接复用
Long[] ids = {leaseApplyInfo.getId()};
if (CollectionUtil.isNotEmpty(leaseApplyInfo.getBmFileInfos())) {
// 删除原有数据
BmFileInfo bmFileInfo = new BmFileInfo();
bmFileInfo.setTaskId(leaseApplyInfo.getTaskId());
bmFileInfo.setModelId(leaseApplyInfo.getId());
bmFileInfo.setTaskType(2);
bmFileInfo.setFileType(5L);
bmFileInfoMapper.deleteBmFileInfoByBizInfo(bmFileInfo);
for (BmFileInfo fileInfo : leaseApplyInfo.getBmFileInfos()) {
fileInfo.setTaskId(leaseApplyInfo.getTaskId());
fileInfo.setModelId(leaseApplyInfo.getId());
fileInfo.setTaskType(2);
fileInfo.setFileType(5L);
fileInfo.setCreateBy(SecurityUtils.getUsername());
fileInfo.setCreateTime(DateUtils.getNowDate());
bmFileInfoMapper.insertBmFileInfo(fileInfo);
}
}
if (CollectionUtil.isNotEmpty(leaseApplyRequestVo.getLeaseApplyDetailsList())) {
// 业务逻辑代码
leaseApplyDetailsMapper.deleteLeaseApplyDetailsByParentIds(ids);
insertPurchaseCheckDetails(leaseApplyRequestVo.getLeaseApplyDetailsList(), leaseApplyInfo.getId());
}
// 修改外层info
mapper.updateLeaseApplyInfo(leaseApplyInfo);
return true;
}
return false;
} catch (DataAccessException dae) {
throw new ServiceException("数据访问异常: " + dae.getMessage());
} catch (IllegalArgumentException iae) {
throw new ServiceException("非法参数异常: " + iae.getMessage());
} catch (Exception e) {
throw new ServiceException("未知异常: " + e.getMessage());
}
}
/**
* 批量删除领用任务
*
* @param ids 需要删除的领用任务主键
* @return 结果
*/
@Override
public int deleteLeaseApplyInfoByIds(Long[] ids) {
return leaseApplyInfoMapper.deleteLeaseApplyInfoByIds(ids);
}
/**
* 关键字搜索
* @param item
* @param keyWord
* @return
*/
private boolean containsKeyword(LeaseApplyInfo item, String keyWord) {
return (item.getMaTypeNames() != null && item.getMaTypeNames().contains(keyWord)) ||
(item.getUnitName() != null && item.getUnitName().contains(keyWord)) ||
(item.getProjectName() != null && item.getProjectName().contains(keyWord)) ||
(item.getCode() != null && item.getCode().contains(keyWord)) ||
(item.getCreateBy() != null && item.getCreateBy().contains(keyWord)) ||
(item.getLeasePerson() != null && item.getLeasePerson().contains(keyWord)) ||
(item.getLeasePhone() != null && item.getLeasePhone().contains(keyWord)) ||
(item.getContractPart() != null && item.getContractPart().contains(keyWord)) ||
(item.getImpUnitName() != null && item.getImpUnitName().contains(keyWord));
}
private AjaxResult insertPurchaseCheckDetails(List<LeaseApplyDetails> leaseApplyDetailsList, Long parentId) {
if (!CollectionUtils.isEmpty(leaseApplyDetailsList)) {
for (LeaseApplyDetails details : leaseApplyDetailsList) {
details.setParentId(parentId);
details.setCreateTime(DateUtils.getNowDate());
details.setCreateBy(SecurityUtils.getUsername());
}
// 批量插入详情数据
int count = mapper.insertLeaseApplyDetailsList(leaseApplyDetailsList);
if (count > 0) {
return AjaxResult.success("新增任务成功");
} else {
return AjaxResult.error("新增任务失败,lease_apply_detail详情表插入0条");
}
} else {
return AjaxResult.success("新增任务成功");
}
}
/**
* 生成任务编号并构造Tm_Task任务对象
* @param thisMonthMaxOrder 当月最大单号
* @return 任务对象
*/
private static String genderTaskCode(Integer thisMonthMaxOrder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date nowDate = DateUtils.getNowDate();
String format = dateFormat.format(nowDate);
String result = format.replace("-", "");
return MaterialConstants.LEASE_TASK_TYPE_LABEL + result + String.format("-%03d", thisMonthMaxOrder + 1);
}
}

View File

@ -6,6 +6,7 @@ import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import com.bonus.common.security.annotation.RequiresPermissions;
import com.bonus.material.common.annotation.PreventRepeatSubmit;
import com.bonus.material.common.domain.dto.SelectDto;
import com.bonus.material.ma.domain.StandardConfigBean;
import com.bonus.material.ma.domain.Type;
import com.bonus.material.ma.domain.vo.StandardConfigDetailsVo;
@ -38,6 +39,17 @@ public class StandardConfigManageController extends BaseController {
return service.getConfigTreeSelect(configName, parentId);
}
/**
* 标准配置下拉选--只有二级数据
* @param bean
* @return
*/
@ApiOperation(value = "标准配置下拉选")
@PostMapping("getConfigLevelTwoList")
public AjaxResult getConfigLevelTwoList(@RequestBody StandardConfigBean bean){
return service.getConfigLevelTwoList(bean);
}
/**
* 根据左配置id查询右表格
*/
@ -85,15 +97,12 @@ public class StandardConfigManageController extends BaseController {
@SysLog(title = "机械设备标准配置管理", businessType = OperaType.INSERT, module = "机械设备标准配置管理->新增标准配置明细")
@PostMapping(value = "/addConfigDetails")
public AjaxResult addConfigDetails(@RequestBody StandardConfigDetailsVo bean) {
int result = service.addConfigDetails(bean);
if (result == 0){
return AjaxResult.error("操作失败!");
} else if (result == -2){
return AjaxResult.error("该类型下已存在该配置!");
} else if (result >0){
try {
service.addConfigDetails(bean);
return AjaxResult.success();
} else {
return AjaxResult.error("操作失败!");
} catch (Exception e) {
// 这里无需手动回滚因为@Transactional会自动处理
return AjaxResult.error(e.getMessage());
}
}
@ -117,4 +126,14 @@ public class StandardConfigManageController extends BaseController {
return service.delConfigDetails(bean);
}
/**
* 根据配置id查询配置明细
* 返回参数和规格型号树参数一致
*/
@ApiOperation(value = "根据配置id查询配置明细")
@GetMapping("/getListsByConfigId")
public AjaxResult getListsByConfigId(StandardConfigDetailsVo bean) {
return service.getListsByConfigId(bean);
}
}

View File

@ -154,6 +154,17 @@ public class TypeController extends BaseController {
return success(listByMaType);
}
/**
* 查询物资类型3级--前端联动式下拉框
* 没有4级规格型号
*/
@ApiOperation(value = "获取物资类型连动式下拉框")
@GetMapping("/equipmentThreeType")
public AjaxResult equipmentThreeType(@RequestParam(required = false) Long typeId, @RequestParam(required = false) String typeName) {
List<Type> listByMaType = typeService.getEquipmentThreeType(typeId, typeName);
return success(listByMaType);
}
/**
* TODO : 后续优化代码逻辑

View File

@ -44,21 +44,41 @@ public class StandardConfigDetailsVo extends Type {
@ApiModelProperty(value = "物资名称")
private String typeName;
@ApiModelProperty(value = "类型名称")
private String maTypeName;
@ApiModelProperty(value = "规格ID")
private Long typeId;
@ApiModelProperty(value = "规格IDs")
private Long[] typeIds;
@ApiModelProperty(value = "规格型号")
private String typeModelName;
@ApiModelProperty(value = "计量单位")
private String unit;
@ApiModelProperty(value = "计量单位")
private String unitName;
@ApiModelProperty(value = "数量")
private BigDecimal num;
@ApiModelProperty(value = "预领数量")
private BigDecimal preNum;
/** 实时库存 */
@ApiModelProperty(value = "实时库存")
private BigDecimal storageNum;
@ApiModelProperty(value = "备注")
private String remark;
/** 管理方式(0编号 1计数) */
@ApiModelProperty(value = "管理方式(0编号 1计数)")
private String manageType;
@ApiModelProperty(value = "创建者")
private String createBy;

View File

@ -1,6 +1,7 @@
package com.bonus.material.ma.mapper;
import com.bonus.common.biz.domain.lease.LeaseOutDetails;
import com.bonus.material.common.domain.vo.SelectVo;
import com.bonus.material.ma.domain.MaTypeHistory;
import com.bonus.material.ma.domain.StandardConfigBean;
import com.bonus.material.ma.domain.Type;
@ -106,4 +107,19 @@ public interface StandardConfigManageMapper {
* @return
*/
int delConfigDetails(StandardConfigDetailsVo bean);
/**
* 标准配置下拉选--只有二级数据
* @param bean
* @return
*/
List<StandardConfigBean> getConfigLevelTwoList(StandardConfigBean bean);
/**
* 根据配置id查询配置明细
* 返回参数和规格型号树参数一致
* @param configId
* @return
*/
List<StandardConfigDetailsVo> getListsByConfigId(Long configId);
}

View File

@ -24,6 +24,14 @@ public interface TypeMapper {
List<Type> selectMaTypeList(@Param("typeId") Long typeId,@Param("typeName") String typeName);
/**
* 查询物资类型3级--前端联动式下拉框
* 没有4级规格型号
* @param typeName
* @return
*/
List<Type> selectMaTypeThreeList(String typeName);
/**
* 查询物资类型
*
@ -174,4 +182,5 @@ public interface TypeMapper {
* @return
*/
int addMaTypeStockNum(@Param("record") LeaseOutDetails leaseOutDetails);
}

View File

@ -27,6 +27,15 @@ public interface ITypeService {
List<Type> getEquipmentType(Long typeId, String typeName);
/**
* 查询物资类型3级--前端联动式下拉框
* 没有4级规格型号
* @param typeId
* @param typeName
* @return
*/
List<Type> getEquipmentThreeType(Long typeId, String typeName);
List<MaTypeSelectVo> selectMaTypeListByHouseId(Long houseId);
List<MaTypeVo> getListByParentId(Long typeId, MaTypeVo type);
@ -112,4 +121,5 @@ public interface ITypeService {
// AjaxResult getMaTypeConfigList(MaTypeConfigDto maTypeConfigDto);
List<MaTypeVo> getMyTypeAndBindUsers(List<MaTypeVo> list,Long userId);
}

View File

@ -57,9 +57,10 @@ public interface StandardConfigManageService {
/**
* 新增机械设备标准配置管理明细
* @param bean
* @throws Exception
* @return
*/
int addConfigDetails(StandardConfigDetailsVo bean);
int addConfigDetails(StandardConfigDetailsVo bean) throws Exception;
/**
* 修改机械设备标准配置管理明细
@ -74,4 +75,19 @@ public interface StandardConfigManageService {
* @return
*/
AjaxResult delConfigDetails(StandardConfigDetailsVo bean);
/**
* 标准配置下拉选--只有二级数据
* @param bean
* @return
*/
AjaxResult getConfigLevelTwoList(StandardConfigBean bean);
/**
* 根据配置id查询配置明细
* 返回参数和规格型号树参数一致
* @param bean
* @return
*/
AjaxResult getListsByConfigId(StandardConfigDetailsVo bean);
}

View File

@ -9,6 +9,7 @@ import com.bonus.common.core.utils.ServletUtils;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.common.domain.vo.SelectVo;
import com.bonus.material.ma.domain.StandardConfigBean;
import com.bonus.material.ma.domain.Type;
import com.bonus.material.ma.domain.vo.MaTypeVo;
@ -17,6 +18,7 @@ import com.bonus.material.ma.mapper.StandardConfigManageMapper;
import com.bonus.material.ma.mapper.TypeMapper;
import com.bonus.material.ma.service.StandardConfigManageService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
@ -57,13 +59,18 @@ public class StandardConfigManageServiceImpl implements StandardConfigManageServ
Integer pageIndex = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
Integer pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
try {
//根据level层级和配置id 查询父级ID
List<Integer> parentIds = mapper.selectParentId(bean);
if (CollectionUtils.isEmpty(parentIds)) {
return AjaxResult.success(new ArrayList<>());
}
for (Integer parentId : parentIds) {
list.addAll(mapper.getListByParentId(parentId.longValue(), bean));
if (StringUtils.isNull(bean.getConfigId())){
//查全部
list.addAll(mapper.getListByParentId(null, bean));
}else {
//根据level层级和配置id 查询父级ID
List<Integer> parentIds = mapper.selectParentId(bean);
if (CollectionUtils.isEmpty(parentIds)) {
return AjaxResult.success(new ArrayList<>());
}
for (Integer parentId : parentIds) {
list.addAll(mapper.getListByParentId(parentId.longValue(), bean));
}
}
return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, list));
} catch (Exception e) {
@ -72,6 +79,18 @@ public class StandardConfigManageServiceImpl implements StandardConfigManageServ
}
}
@Override
public AjaxResult getListsByConfigId(StandardConfigDetailsVo bean) {
List<StandardConfigDetailsVo> list = new ArrayList<>();
try {
list= mapper.getListsByConfigId(bean.getConfigId());
return AjaxResult.success(list);
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.success(new ArrayList<>());
}
}
@Override
public int insertConfig(StandardConfigBean bean) {
//根据类型名称判断去重
@ -104,11 +123,11 @@ public class StandardConfigManageServiceImpl implements StandardConfigManageServ
if (StringUtils.isNull(bean.getConfigId())){
return AjaxResult.error("删除失败,缺少参数");
}
//根据configId查询删除类型下属是否有关联有关联无法删除
List<StandardConfigDetailsVo> list = mapper.selectByConfigId(bean.getConfigId());
if (list!=null && list.size()>0) {
return AjaxResult.error("该类型下有子类型,无法删除");
}
// //根据configId查询删除类型下属是否有关联有关联无法删除
// List<StandardConfigDetailsVo> list = mapper.selectByConfigId(bean.getConfigId());
// if (list!=null && list.size()>0) {
// return AjaxResult.error("该类型下有子类型,无法删除");
// }
bean.setUpdateTime(DateUtils.getNowDate());
bean.setUpdateBy(SecurityUtils.getUserId().toString());
int result = mapper.deleteConfigByConfigId(bean);
@ -119,21 +138,27 @@ public class StandardConfigManageServiceImpl implements StandardConfigManageServ
}
@Override
public int addConfigDetails(StandardConfigDetailsVo bean) {
try {
//根据configId和typeId 查询是否存在数据
int count = mapper.getCountById(bean);
if (count > 0) {
return -2;
@Transactional(rollbackFor = Exception.class)
public int addConfigDetails(StandardConfigDetailsVo bean) throws Exception {
if (bean.getTypeIds() != null && bean.getTypeIds().length > 0){
for (Long typeId : bean.getTypeIds()) {
// 根据configId和typeId 查询是否存在数据
StandardConfigDetailsVo bean1 = new StandardConfigDetailsVo();
bean1.setConfigId(bean.getConfigId());
bean1.setTypeId(typeId);
int count = mapper.getCountById(bean1);
if (count > 0) {
throw new Exception("该类型下已存在该配置!");
}
bean1.setCreateTime(DateUtils.getNowDate());
bean1.setCreateBy(SecurityUtils.getUserId().toString());
int result = mapper.addConfigDetails(bean1);
if(result <= 0){
throw new Exception("操作失败!");
}
}
bean.setCreateTime(DateUtils.getNowDate());
bean.setCreateBy(SecurityUtils.getUserId().toString());
int result = mapper.addConfigDetails(bean);
return result;
} catch (Exception e) {
e.printStackTrace();
return 0;
}
return 1;
}
@Override
@ -163,6 +188,17 @@ public class StandardConfigManageServiceImpl implements StandardConfigManageServ
}
}
@Override
public AjaxResult getConfigLevelTwoList(StandardConfigBean bean) {
List<StandardConfigBean> list = new ArrayList<>();
try {
list = mapper.getConfigLevelTwoList(bean);
} catch (Exception e) {
return AjaxResult.success(new ArrayList());
}
return AjaxResult.success(list);
}
public List<TreeSelect> getConfigTree(String typeName, String parentId) {
List<StandardConfigBean> standardConfigs = mapper.selectStandardConfigTree();
List<StandardConfigBean> builtConfigList = buildConfigTree(standardConfigs);

View File

@ -99,6 +99,23 @@ public class TypeServiceImpl implements ITypeService {
return list;
}
@Override
public List<Type> getEquipmentThreeType(Long typeId, String typeName) {
List<Type> maTypes = typeMapper.selectMaTypeThreeList("");
List<Type> list = new ArrayList<>();
for (Type maType : maTypes) {
if (maType.getParentId() == 0) {
list.add(maType);
}
}
//根据父节点获取对应的儿子节点
for (Type maType : list) {
List<Type> child = getChild(maTypes, maType.getTypeId());
maType.setChildren(child);
}
return list;
}
@Override
public List<MaTypeSelectVo> selectMaTypeListByHouseId(Long houseId) {

View File

@ -8,7 +8,7 @@ import org.apache.ibatis.annotations.Param;
/**
* 新购验收任务详细Mapper接口
*
*
* @author xsheng
* @date 2024-10-16
*/
@ -27,7 +27,7 @@ public interface PurchaseCheckDetailsMapper {
/**
* 查询新购验收任务详细
*
*
* @param id 新购验收任务详细主键
* @return 新购验收任务详细
*/
@ -47,7 +47,7 @@ public interface PurchaseCheckDetailsMapper {
/**
* 查询新购验收任务详细列表
*
*
* @param purchaseCheckDetails 新购验收任务详细
* @return 新购验收任务详细集合
*/
@ -57,7 +57,7 @@ public interface PurchaseCheckDetailsMapper {
/**
* 新增新购验收任务详细
*
*
* @param purchaseCheckDetails 新购验收任务详细
* @return 结果
*/
@ -71,7 +71,7 @@ public interface PurchaseCheckDetailsMapper {
/**
* 修改新购验收任务详细
*
*
* @param purchaseCheckDetails 新购验收任务详细
* @return 结果
*/
@ -82,7 +82,7 @@ public interface PurchaseCheckDetailsMapper {
* @param taskId 任务id
* @param newTaskStatus 新状态
*/
int batchUpdateDetailsTaskStatus(@Param("taskId") Long taskId, @Param("newTaskStatus") Integer newTaskStatus, @Param("checkResult") String checkResult);
int batchUpdateDetailsTaskStatus(@Param("taskId") Long taskId,@Param("newTaskStatus") Integer newTaskStatus, @Param("checkResult") String checkResult);
// int updatePurchaseDetails(PurchaseCheckDetails details);
@ -92,7 +92,7 @@ public interface PurchaseCheckDetailsMapper {
/**
* 删除新购验收任务详细
*
*
* @param id 新购验收任务详细主键
* @return 结果
*/
@ -102,7 +102,7 @@ public interface PurchaseCheckDetailsMapper {
/**
* 批量删除新购验收任务详细
*
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/

View File

@ -4,6 +4,7 @@ import com.bonus.common.core.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
@ -20,6 +21,7 @@ import java.util.List;
* @Description: i皖送费用推送
*/
@Data
@Accessors(chain = true)
public class IwsCostPushBean implements Serializable {
private static final long serialVersionUID = -1473066593962126100L;
@ -82,6 +84,11 @@ public class IwsCostPushBean implements Serializable {
private BigDecimal leasePrice;
/**
* 总费用统计领料 丢失 报废 维修费用
*/
private BigDecimal totalMoney;
private String time;
// 月份
@ -110,6 +117,10 @@ public class IwsCostPushBean implements Serializable {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime settlementTime;
// 签订时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime signTime;
// 是否匹配
@Excel(name = "是否匹配", readConverterExp = "0=未匹配,1=已匹配", sort = 5)
private Byte isMatch = 0;

View File

@ -35,6 +35,11 @@ public interface IwsCostPushMapper {
*/
int insertCalcMonthRecord(IwsCostPushBean record);
/**
* 插入项目月费用数据 -- 批量
*/
int insertProjectMonthCosts(List<IwsCostPushBean> recordList);
/**
* 根据协议ID查询领用物资数据
* @param record 协议信息及条件

View File

@ -7,6 +7,9 @@ import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.push.domain.IwsCostPushBean;
import com.bonus.material.push.mapper.IwsCostPushMapper;
import com.bonus.material.push.service.IwsCostPushService;
import com.bonus.material.settlement.domain.SltAgreementInfo;
import com.bonus.material.settlement.domain.vo.SltInfoVo;
import com.bonus.material.settlement.service.ISltAgreementInfoService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -17,10 +20,7 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.*;
/**
* @author : 阮世耀
@ -35,6 +35,9 @@ public class IwsCostPushServiceImpl implements IwsCostPushService {
@Resource
private IwsCostPushMapper iwsCostPushMapper;
@Resource
private ISltAgreementInfoService sltAgreementInfoService;
/**
* 根据给定的条件查找协议信息
@ -55,6 +58,7 @@ public class IwsCostPushServiceImpl implements IwsCostPushService {
return iwsCostPushMapper.getCostPushCheckList(o);
}
/**
* 计算月结费用
*
@ -63,38 +67,34 @@ public class IwsCostPushServiceImpl implements IwsCostPushService {
*/
@Override
public AjaxResult computeTheMonthCost(IwsCostPushBean costDto) {
// 获取当月第一天的日期和最后一天日期
String firstDay = DateTimeHelper.getFirstDay();
String lastDay = DateTimeHelper.getLastDay();
// 获取当前年月 2025-01
// 获取当前年月 例如:2025-01
String month = DateTimeHelper.getNowMonth();
// 获取当月第一天的日期和最后一天日期
LocalDateTime firstDayOfMonth = getFirstDayOfMonth(month);
LocalDateTime lastDayOfMonth = getLastDayOfMonthZ(month);
costDto.setMonth(month);
costDto.setStartTime(firstDay);
costDto.setEndTime(lastDay);
// 清除旧的费用计算数据
// cleanSameMonthOldRecords(record);
// 插入新的当前月份记录,并生成id
// 插入新的当前月份,并生成记录id
iwsCostPushMapper.insertCalcMonthRecord(costDto);
String taskId = costDto.getId();
// 查询协议信息列表
List<IwsCostPushBean> agreementList = iwsCostPushMapper.findAgreement(costDto);
// 处理数据,计算4项费用
computeMonthInfoDetail(agreementList, month, firstDayOfMonth, lastDayOfMonth);
// 存入数据库
agreementList.forEach(item -> item.setMonth(month));
int addProjectMonthCostsMapperResult = iwsCostPushMapper.insertProjectMonthCosts(agreementList);
// 处理数据
computeMonthInfoDetail(agreementList, costDto, taskId, month);
// TODO 未完成费用结算 待完善
return null;
return 0 < addProjectMonthCostsMapperResult ? AjaxResult.success("月结费用计算成功") : AjaxResult.error("月结费用计算失败");
}
/**
* 根据协议ID及月份查询当月租赁费用明细
*
* @param record 查询信息
* @param record 传入查询的年月yyyy-MM 协议ID
*/
@Override
public List<IwsCostPushBean> getLeaseCostsByAgreementIdAndMonth(IwsCostPushBean record) {
@ -157,34 +157,77 @@ public class IwsCostPushServiceImpl implements IwsCostPushService {
/**
* 计算月结费用详情
* @param agreementList 协议集合
* @param costDto 要进行结算的信息
* @param taskId 任务id
* @param month 月份
* @param firstDay 月份第一天
* @param lastDay 月份最后一天
*/
private void computeMonthInfoDetail(List<IwsCostPushBean> agreementList, IwsCostPushBean costDto, String taskId, String month) {
private void computeMonthInfoDetail(List<IwsCostPushBean> agreementList, String month, LocalDateTime firstDay, LocalDateTime lastDay) {
if (null == agreementList || agreementList.isEmpty()) {
return;
System.err.println("---------agreementList为空----------");
} else {
System.out.println("agreementList = " + agreementList);
System.out.println("agreementList数据不为空");
// 过滤异常数据
agreementList.removeIf(item ->
Objects.isNull(item) ||
Objects.isNull(item.getAgreementId()) ||
Objects.isNull(item.getSignTime()) ||
Objects.isNull(item.getIsSettlement()) ||
item.getSignTime().isAfter(lastDay) || item.getSettlementTime().isBefore(firstDay)
);
for (IwsCostPushBean agreement : agreementList) {
// 协议id
String agreementId = agreement.getAgreementId();
// 更新协议推送状态
updatePushStatus(agreement);
BigDecimal changeMoney = BigDecimal.ZERO;
IwsCostPushBean bean = new IwsCostPushBean();
bean.setAgreementId(agreement.getAgreementId());
// 查询领料费用
List<IwsCostPushBean> baseInfo = iwsCostPushMapper.getPaidSltBaseInfo(bean);
List<IwsCostPushBean> l = new ArrayList<>();
// 对已结算未结算分开处理
if (0 == agreement.getIsSettlement()) {
// 未结算时无丢失维修报废费用
agreement.setLostMoney(BigDecimal.ZERO);
agreement.setRepairMoney(BigDecimal.ZERO);
agreement.setScrapMoney(BigDecimal.ZERO);
if (null != baseInfo && !baseInfo.isEmpty()) {
l = baseInfo;
} else {
System.err.println("baseInfo为空 = " + baseInfo);
// 查询领料费用
List<IwsCostPushBean> leaseCostsByAgreementIdAndMonth = this.getLeaseCostsByAgreementIdAndMonth(new IwsCostPushBean()
.setAgreementId(agreementId)
.setMonth(month)
);
if (CollectionUtils.isEmpty(leaseCostsByAgreementIdAndMonth)) {
agreement.setLeaseMoney(BigDecimal.ZERO);
} else {
leaseCostsByAgreementIdAndMonth.removeIf(item -> Objects.isNull(item) || Objects.isNull(item.getLeaseMoney()));
// 合并计算领料费用
agreement.setLeaseMoney(leaseCostsByAgreementIdAndMonth
.stream()
.map(IwsCostPushBean::getLeaseMoney)
.reduce(BigDecimal.ZERO, BigDecimal::add)
);
}
} else if (1 == agreement.getIsSettlement()) {
// 已结算费用计算
SltInfoVo sltServiceResult = sltAgreementInfoService.getSltInfo(new SltAgreementInfo().setAgreementId(Long.valueOf(agreementId)));
if (Objects.isNull(sltServiceResult)) {
System.err.println("sltServiceResult为空----null");
agreement.setLostMoney(BigDecimal.ZERO);
agreement.setRepairMoney(BigDecimal.ZERO);
agreement.setScrapMoney(BigDecimal.ZERO);
agreement.setLeaseMoney(BigDecimal.ZERO);
} else {
// 已经结算时要统计领料丢失维修报废费用
agreement.setLostMoney(Optional.ofNullable(sltServiceResult.getLoseCost()).orElse(BigDecimal.ZERO));
agreement.setRepairMoney(Optional.ofNullable(sltServiceResult.getRepairCost()).orElse(BigDecimal.ZERO));
agreement.setScrapMoney(Optional.ofNullable(sltServiceResult.getScrapCost()).orElse(BigDecimal.ZERO));
agreement.setLeaseMoney(Optional.ofNullable(sltServiceResult.getLeaseCost()).orElse(BigDecimal.ZERO));
}
}
if (!l.isEmpty()) {
// TODO 待完善
}
// 合并统计费用
agreement.setTotalMoney(agreement.getLeaseMoney()
.add(agreement.getLostMoney())
.add(agreement.getRepairMoney())
.add(agreement.getScrapMoney())
);
}
}
}
@ -202,11 +245,11 @@ public class IwsCostPushServiceImpl implements IwsCostPushService {
}
/**
* 检查是否需要推送,包含大件及机械化的不需要进行push
* return true 需要推送, false 不需要推送
* 检查是否包含大件及机械化项目id为空
* return true 包含大件机械化 工程id为空, false 不包含
*/
private boolean checkPush(IwsCostPushBean o) {
return !(o.getUnitName().contains("大件") || o.getUnitName().contains("机械化") || StringUtils.isEmpty(o.getProjectId()));
return (o.getUnitName().contains("大件") || o.getUnitName().contains("机械化") || StringUtils.isEmpty(o.getProjectId()));
}
/**

View File

@ -0,0 +1,35 @@
package com.bonus.material.push.task;
import com.bonus.material.push.domain.IwsCostPushBean;
import com.bonus.material.push.service.IwsCostPushService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* @author : 阮世耀
* @version : 1.0
* @PackagePath: com.bonus.material.push.task
* @CreateTime: 2025-02-15 16:01
* @Description: i皖送费用推送定时任务类
*/
@Component
public class IwsCostPushTask {
@Resource
private IwsCostPushService iwsCostPushService;
/**
* 定时任务 -- 计算月结费用 -- 每月最后一天的23点30分执行
*/
@Scheduled(cron = "0 30 23 L * ?")
public void computeTheMonthCostTask() {
System.out.println("-----------开始计算四类未结算费用定时器-----------");
iwsCostPushService.computeTheMonthCost(new IwsCostPushBean());
System.out.println("-----------四类未结算费用定时器执行完毕-----------");
}
}

View File

@ -0,0 +1,77 @@
package com.bonus.material.settlement.controller;
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.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import com.bonus.common.security.annotation.RequiresPermissions;
import com.bonus.material.settlement.domain.SltAgreementReduce;
import com.bonus.material.settlement.service.ISltAgreementReduceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 结算协议申请Controller
*
* @author xsheng
* @date 2024-10-16
*/
@Api(tags = "结算协议减免接口")
@RestController
@RequestMapping("/slt_agreement_reduce")
public class SltAgreementReduceController extends BaseController {
@Autowired
private ISltAgreementReduceService sltAgreementReduceService;
/**
* 查询结算协议减免申请列表
*/
@ApiOperation(value = "查询结算协议减免申请列表")
@RequiresPermissions("settlement:apply:list")
@GetMapping("/list")
public TableDataInfo list(SltAgreementReduce sltAgreement) {
startPage();
List<SltAgreementReduce> list = sltAgreementReduceService.selectSltAgreementReduceList(sltAgreement);
return getDataTable(list);
}
/**
* 查询协议申请减免明细
*/
@ApiOperation(value = "查询协议申请减免明细")
// @RequiresPermissions("settlement:apply:list")
@GetMapping("/applyByParam")
public AjaxResult applyByParam(SltAgreementReduce sltAgreement) {
List<SltAgreementReduce> list = null;
if(sltAgreement!=null){
if (sltAgreement.getAgreementId()!=null){
list = sltAgreementReduceService.getApplyReduceList(sltAgreement);
}
}else{
}
return success(list);
}
/**
* 查询协议申请减免明细
*/
@ApiOperation(value = "查询协议申请减免明细")
// @RequiresPermissions("settlement:apply:list")
@SysLog(title = "申请减免", businessType = OperaType.INSERT, logType = 1,module = "结算关联->申请减免")
@PostMapping("/addApply")
public AjaxResult addApply( @RequestBody SltAgreementReduce sltAgreement) {
try {
return sltAgreementReduceService.addApply(sltAgreement);
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
}
}
}

View File

@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import com.bonus.common.core.web.domain.BaseEntity;
import lombok.experimental.Accessors;
/**
* 结算信息对象 slt_agreement_info
@ -15,10 +16,9 @@ import com.bonus.common.core.web.domain.BaseEntity;
* @author xsheng
* @date 2024-10-16
*/
@Data
@ToString
@Accessors(chain = true)
public class SltAgreementInfo extends BaseEntity {
private static final long serialVersionUID = 1L;

View File

@ -0,0 +1,120 @@
package com.bonus.material.settlement.domain;
import com.bonus.common.biz.domain.BmFileInfo;
import com.bonus.common.core.annotation.Excel;
import com.bonus.common.core.web.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import org.apache.poi.hpsf.Decimal;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* 结算协议申请对象 slt_agreement_reduce
*
* @author csyue
* @date 2025-10-16
*/
@Data
@ToString
public class SltAgreementReduce extends BaseEntity {
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 协议id */
@ApiModelProperty(value = "协议id")
private Long agreementId;
/** 结算单号例如JM202402-1 */
@Excel(name = "减免单号", readConverterExp = "例=如JM202402-1")
private String code;
/** 创建人 */
@Excel(name = "创建人")
@ApiModelProperty(value = "创建人")
private String creator;
/** 状态0未结算1待审核2审核通过3审核驳回 */
@Excel(name = "状态0未结算1待审核2审核通过3审核驳回")
@ApiModelProperty(value = "状态0未结算1待审核2审核通过3审核驳回")
private String status;
/** 数据所属 */
@Excel(name = "数据所属")
@ApiModelProperty(value = "数据所属")
private Long companyId;
/** 结算总费用 */
@Excel(name = "结算总费用")
@ApiModelProperty(value = "结算总费用")
private BigDecimal cost;
@ApiModelProperty(value = "原因")
private String remark;
@ApiModelProperty(value = "机具规格id")
private String typeId;
@ApiModelProperty(value = "机具名称")
private String maName;
@ApiModelProperty(value = "机具规格")
private String maModel;
@ApiModelProperty(value = "机具单位")
private String maUnit;
@ApiModelProperty(value = "租赁数量")
private BigDecimal num;
@ApiModelProperty(value = "租赁单价")
private BigDecimal leasePrice;
@ApiModelProperty(value = "租赁开始时间")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date startTime;
@ApiModelProperty(value = "租赁结束时间")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date endTime;
@ApiModelProperty(value = "租赁天数")
private Long days;
@ApiModelProperty(value = "租赁金额")
private BigDecimal leaseMoney;
@ApiModelProperty(value = "减免数量")
private BigDecimal reduceNum;
@ApiModelProperty(value = "减免租赁单价")
private BigDecimal reduceLeasePrice;
@ApiModelProperty(value = "减免开始时间")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date reduceStartTime;
@ApiModelProperty(value = "减免结束时间")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date reduceEndTime;
@ApiModelProperty(value = "减免租赁费用")
private BigDecimal reduceLeaseMoney;
@ApiModelProperty(value = "减免天数")
private Long reduceDays;
private BmFileInfo file;
private List<SltAgreementReduce> detailList;
}

View File

@ -0,0 +1,29 @@
package com.bonus.material.settlement.mapper;
import com.bonus.material.settlement.domain.SltAgreementReduce;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 结算协议减免Mapper接口
*
* @author yuecs
* @date 2025-10-16
*/
public interface SltAgreementReduceMapper {
List<SltAgreementReduce> selectSltAgreementReduceList(SltAgreementReduce sltAgreement);
List<SltAgreementReduce> getApplyReduceList(SltAgreementReduce sltAgreement);
String getMaxCode(String date);
Long insertReduce(SltAgreementReduce sltAgreement);
void insertReduceDetail(SltAgreementReduce sltAgreementReduce);
void insertBatchReduceDetail(@Param("detailList") List<SltAgreementReduce> detailList);
List<SltAgreementReduce> findOverlappingReductions(SltAgreementReduce detail);
}

View File

@ -0,0 +1,21 @@
package com.bonus.material.settlement.service;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.settlement.domain.SltAgreementReduce;
import java.util.List;
/**
* 结算协议减免Service接口
*
* @author yuecs
* @date 2025-10-16
*/
public interface ISltAgreementReduceService {
List<SltAgreementReduce> selectSltAgreementReduceList(SltAgreementReduce sltAgreement);
List<SltAgreementReduce> getApplyReduceList(SltAgreementReduce sltAgreement);
AjaxResult addApply(SltAgreementReduce sltAgreement);
}

View File

@ -0,0 +1,172 @@
package com.bonus.material.settlement.service.impl;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.basic.mapper.BmFileInfoMapper;
import com.bonus.material.settlement.domain.SltAgreementReduce;
import com.bonus.material.settlement.mapper.SltAgreementReduceMapper;
import com.bonus.material.settlement.service.ISltAgreementReduceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* 结算协议减免Service业务层处理
*
* @author yuecs
* @date 2025-10-16
*/
@Service
@Slf4j
public class SltAgreementReduceServiceImpl implements ISltAgreementReduceService {
@Autowired
private SltAgreementReduceMapper sltAgreementRecudceMapper;
@Autowired
private BmFileInfoMapper bmFileInfoMapper;
@Override
public List<SltAgreementReduce> selectSltAgreementReduceList(SltAgreementReduce sltAgreement) {
return sltAgreementRecudceMapper.selectSltAgreementReduceList(sltAgreement);
}
@Override
public List<SltAgreementReduce> getApplyReduceList(SltAgreementReduce sltAgreement) {
return sltAgreementRecudceMapper.getApplyReduceList(sltAgreement);
}
@Override
@Transactional(rollbackFor = Exception.class) // 对所有异常回滚
public AjaxResult addApply(SltAgreementReduce sltAgreement) {
try {
List<SltAgreementReduce> list = sltAgreement.getDetailList();
//bmFileInfoMapper.insertBmFileInfo()
// 初始化 SltAgreementReduce 对象
initSltAgreement(sltAgreement);
List<SltAgreementReduce> applyReduction = applyReduction(sltAgreement);
Long rs = sltAgreementRecudceMapper.insertReduce(sltAgreement);
Long id = sltAgreement.getId();
if (rs > 0 && list != null) {
// 批量插入明细
List<SltAgreementReduce> detailList = list.stream()
.peek(detail -> detail.setId(id))
.collect(Collectors.toList());
sltAgreementRecudceMapper.insertBatchReduceDetail(detailList);
}
return AjaxResult.success();
} catch (DataAccessException e) {
// 记录详细的数据库操作异常日志
log.error("数据库操作失败: {}", e.getMessage(), e);
return AjaxResult.error("系统错误, 数据库操作失败");
} catch (Exception e) {
// 记录其他异常日志
log.error("系统错误: {}", e.getMessage(), e);
return AjaxResult.error("系统错误, " + e.getMessage());
}
}
private void initSltAgreement(SltAgreementReduce sltAgreement) {
sltAgreement.setCode(generateCode());
sltAgreement.setCreateTime(new Date());
}
public List<SltAgreementReduce> applyReduction(SltAgreementReduce sltAgreement) {
// 初始化结果列表
List<SltAgreementReduce> newReductions = new ArrayList<>();
// 遍历申请减免的每个区间
for (SltAgreementReduce detail : sltAgreement.getDetailList()) {
if (detail.getReduceStartTime() != null && detail.getReduceEndTime() != null) {
// 将当前区间添加到结果列表中
// 查询与当前区间有重叠的历史减免记录
List<SltAgreementReduce> historyReductions = sltAgreementRecudceMapper.findOverlappingReductions(detail);
// 对比并去掉重叠部分
for (SltAgreementReduce history : historyReductions) {
List<SltAgreementReduce> temp = new ArrayList<>();
for (SltAgreementReduce current : newReductions) {
// 如果当前区间与历史区间没有重叠直接保留
if (current.getEndTime().before(history.getStartTime()) || current.getStartTime().after(history.getEndTime())) {
temp.add(current);
} else {
// 如果有重叠拆分当前区间
if (current.getStartTime().before(history.getStartTime())) {
// 生成新的区间申请开始时间到历史开始时间的前一天
SltAgreementReduce newReduction = new SltAgreementReduce();
//计算新的租赁情况
newReduction.setStartTime(current.getStartTime());
newReduction.setEndTime(new Date(history.getStartTime().getTime() - 86400000));
long days = (history.getStartTime().getTime() - current.getStartTime().getTime()) / (24 * 60 * 60 * 1000) +1;
BigDecimal num = current.getNum();
BigDecimal leasePrice = current.getLeasePrice();
newReduction.setLeasePrice(leasePrice);
BigDecimal leaseMoney = new BigDecimal(days).multiply(num).multiply(leasePrice);
newReduction.setLeaseMoney(leaseMoney);
temp.add(
newReduction
);
}
if (current.getEndTime().after(history.getEndTime())) {
// 生成新的区间历史结束时间的后一天到申请结束时间
SltAgreementReduce newReduction = new SltAgreementReduce();
//计算新的租赁情况
newReduction.setStartTime( new Date(history.getEndTime().getTime() + 86400000));
newReduction.setEndTime( current.getEndTime());
long days = (current.getEndTime().getTime() - history.getEndTime().getTime()) / (24 * 60 * 60 * 1000) +1;
BigDecimal num = current.getNum();
BigDecimal leasePrice = current.getLeasePrice();
newReduction.setLeasePrice(leasePrice);
BigDecimal leaseMoney = new BigDecimal(days).multiply(num).multiply(leasePrice);
newReduction.setLeaseMoney(leaseMoney);
temp.add(
newReduction
);
}
}
}
newReductions = temp;
}
}
}
return newReductions;
}
public String generateCode() {
// 获取当前日期格式为 YYYYMMDD
String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
// 获取当前日期格式为 YYY-YM-MDD
// 查询当前最大单号
String maxCode = sltAgreementRecudceMapper.getMaxCode(date);
// 生成新单号
String newCode;
if (maxCode == null) {
// 如果当天没有单号生成第一个单号
newCode = "JM" + date + "-0001";
} else {
// 提取序号部分并加 1
int lastNumber = Integer.parseInt(maxCode.substring(maxCode.length() - 4));
// 补零到 4
String newNumber = String.format("%04d", lastNumber + 1);
newCode = "JM" + date + "-" + newNumber;
}
return newCode;
}
}

View File

@ -112,6 +112,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="leaseType != null and leaseType != ''"> and lai.lease_type = #{leaseType}</if>
<if test="estimateLeaseTime != null "> and lai.estimate_lease_time = #{estimateLeaseTime}</if>
<if test="costBearingParty != null and costBearingParty != ''"> and lai.cost_bearing_party = #{costBearingParty}</if>
and tt.task_status != '0'
</where>
GROUP BY lai.id
ORDER BY tt.task_status,tt.create_time desc

View File

@ -0,0 +1,301 @@
<?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.lease.mapper.LeaseTaskMapper">
<resultMap type="com.bonus.common.biz.domain.lease.LeaseApplyInfo" id="LeaseApplyInfoResult">
<result property="id" column="id" />
<result property="code" column="code" />
<result property="taskId" column="task_id" />
<result property="leasePerson" column="lease_person" />
<result property="phone" column="phone" />
<result property="type" column="type" />
<result property="companyAuditBy" column="company_audit_by" />
<result property="companyAuditTime" column="company_audit_time" />
<result property="companyAuditRemark" column="company_audit_remark" />
<result property="deptAuditBy" column="dept_audit_by" />
<result property="deptAuditTime" column="dept_audit_time" />
<result property="deptAuditRemark" column="dept_audit_remark" />
<result property="directAuditBy" column="direct_audit_by" />
<result property="directAuditTime" column="direct_audit_time" />
<result property="directAuditRemark" column="direct_audit_remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="companyId" column="company_id" />
<result property="directId" column="direct_id" />
<result property="leaseType" column="lease_type" />
<result property="estimateLeaseTime" column="estimate_lease_time" />
<result property="costBearingParty" column="cost_bearing_party" />
<result property="leaseProject" column="pro_name" />
<result property="leaseProjectId" column="project_id" />
<result property="leaseUnit" column="unit_name" />
<result property="leaseUnitId" column="unit_id" />
<result property="agreementCode" column="agreement_code" />
<result property="leaseSignUrl" column="lease_sign_url" />
<result property="leaseSignType" column="lease_sign_type" />
<result property="applyCode" column="apply_code" />
</resultMap>
<resultMap type="com.bonus.material.lease.domain.LeaseApplyDetails" id="LeaseApplyDetailsResult">
<result property="id" column="id" />
<result property="parentId" column="parent_id" />
<result property="typeId" column="type_id" />
<result property="typeName" column="type_name" />
<result property="maTypeName" column="ma_type_name" />
<result property="unitName" column="unit_name" />
<result property="unitValue" column="unit_value" />
<result property="storageNum" column="storage_num" />
<result property="preNum" column="pre_num" />
<result property="auditNum" column="audit_num" />
<result property="alNum" column="al_num" />
<result property="status" column="status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="companyId" column="company_id" />
</resultMap>
<sql id="selectLeaseApplyInfoVo">
select
lai.id, lai.code, lai.task_id, lai.lease_person, lai.phone, lai.type, lai.company_audit_by,lai.apply_code,
lai.company_audit_time, lai.company_audit_remark, lai.dept_audit_by, lai.dept_audit_time,
lai.dept_audit_remark, lai.direct_audit_by, lai.direct_audit_time, lai.direct_audit_remark,
lai.create_by, lai.create_time, lai.update_by, lai.update_time, lai.remark, lai.company_id,
lai.direct_id, lai.lease_type, lai.estimate_lease_time, lai.cost_bearing_party, lai.lease_sign_url, lai.lease_sign_type,
bai.unit_id,bai.project_id,bu.unit_name, bp.pro_name, bai.agreement_code, tt.task_status as taskStatus,
sda.dict_label as taskStatusName,
IFNULL(sum(lad.pre_num),0) as preCountNum,
IFNULL(sum(lad.al_num),0) as alNum,
GROUP_CONCAT(DISTINCT mt1.type_name) AS maTypeNames,
bp.contract_part as contractPart,
sd.dept_name as impUnitName
from
lease_apply_info lai
left join tm_task tt on lai.task_id = tt.task_id
left join lease_apply_details lad on lai.id = lad.parent_id
left join tm_task_agreement tta on lai.task_id = tta.task_id
left join bm_agreement_info bai on tta.agreement_id = bai.agreement_id
left join bm_unit bu on bu.unit_id = bai.unit_id
left join bm_project bp on bp.pro_id = bai.project_id
left join sys_dept sd on sd.dept_id = bp.imp_unit
left join sys_dict_data sda on tt.task_status = sda.dict_value
and sda.dict_type = 'lease_task_status'
left join ma_type mt on lad.type_id = mt.type_id and mt.del_flag = '0'
left join ma_type mt1 on mt.parent_id = mt1.type_id and mt1.del_flag = '0'
<!-- <if test="userId != null">-->
<!-- JOIN ma_type_keeper mtk ON mtk.type_id = lad.type_id AND mtk.user_id = #{userId}-->
<!-- </if>-->
</sql>
<sql id="selectLeaseApplyDetailsVo">
select
lad.id, lad.parent_id, mt.type_id, mt.type_name, mt2.type_name as ma_type_name,
CASE mt.manage_type
WHEN 0 THEN
IFNULL(subquery0.num, 0)
ELSE
IFNULL(mt.storage_num, 0)
END as storage_num,
mt.manage_type as manageType,
(lad.pre_num - IF(lad.al_num IS NULL,'0',lad.al_num)) AS outNum,
IFNULL(lad.pre_num,0) as pre_num,
IFNULL(lad.audit_num,0) as audit_num,
IFNULL(lad.al_num,0) as al_num,
IFNULL(lad.status,0) as status, mt.unit_name,mt.unit_value,
lad.create_by, lad.create_time, lad.update_by, lad.update_time, lad.remark, lad.company_id
from
lease_apply_details lad
left join
ma_type mt on lad.type_id = mt.type_id and mt.`level` = '4' and mt.del_flag = '0'
left join
ma_type mt2 on mt2.type_id = mt.parent_id and mt2.`level` = '3' and mt2.del_flag = '0'
left join (SELECT mt.type_id,
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
count(mm.ma_id) num
FROM ma_machine mm
LEFT JOIN ma_type mt ON mt.type_id = mm.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
WHERE mm.ma_code is not null and mm.ma_status in (1)
GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = mt.type_id
<!-- <if test="userId != null">-->
<!-- JOIN ma_type_keeper mtk ON mtk.type_id = lad.type_id AND mtk.user_id = #{userId}-->
<!-- </if>-->
</sql>
<insert id="insertLeaseApplyInfo" parameterType="com.bonus.common.biz.domain.lease.LeaseApplyInfo" useGeneratedKeys="true" keyProperty="id">
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">lease_person,</if>
<if test="phone != null">phone,</if>
<if test="type != null">type,</if>
<if test="companyAuditBy != null">company_audit_by,</if>
<if test="companyAuditTime != null">company_audit_time,</if>
<if test="companyAuditRemark != null">company_audit_remark,</if>
<if test="deptAuditBy != null">dept_audit_by,</if>
<if test="deptAuditTime != null">dept_audit_time,</if>
<if test="deptAuditRemark != null">dept_audit_remark,</if>
<if test="directAuditBy != null">direct_audit_by,</if>
<if test="directAuditTime != null">direct_audit_time,</if>
<if test="directAuditRemark != null">direct_audit_remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="companyId != null">company_id,</if>
<if test="directId != null">direct_id,</if>
<if test="leaseType != null">lease_type,</if>
<if test="estimateLeaseTime != null">estimate_lease_time,</if>
<if test="costBearingParty != null">cost_bearing_party,</if>
<if test="applyCode != null">apply_code,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="code != null">#{code},</if>
<if test="taskId != null">#{taskId},</if>
<if test="leasePerson != null">#{leasePerson},</if>
<if test="phone != null">#{phone},</if>
<if test="type != null">#{type},</if>
<if test="companyAuditBy != null">#{companyAuditBy},</if>
<if test="companyAuditTime != null">#{companyAuditTime},</if>
<if test="companyAuditRemark != null">#{companyAuditRemark},</if>
<if test="deptAuditBy != null">#{deptAuditBy},</if>
<if test="deptAuditTime != null">#{deptAuditTime},</if>
<if test="deptAuditRemark != null">#{deptAuditRemark},</if>
<if test="directAuditBy != null">#{directAuditBy},</if>
<if test="directAuditTime != null">#{directAuditTime},</if>
<if test="directAuditRemark != null">#{directAuditRemark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="companyId != null">#{companyId},</if>
<if test="directId != null">#{directId},</if>
<if test="leaseType != null">#{leaseType},</if>
<if test="estimateLeaseTime != null">#{estimateLeaseTime},</if>
<if test="costBearingParty != null">#{costBearingParty},</if>
<if test="applyCode != null">#{applyCode},</if>
</trim>
</insert>
<insert id="insertLeaseApplyDetailsList" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
insert into lease_apply_details
(parent_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.parentId,jdbcType=INTEGER}, #{item.typeId,jdbcType=INTEGER}, #{item.preNum,jdbcType=INTEGER},
#{item.alNum,jdbcType=INTEGER}, #{item.status,jdbcType=VARCHAR}, #{item.createBy,jdbcType=VARCHAR},
NOW(), #{item.updateBy,jdbcType=VARCHAR}, NOW(),
#{item.remark,jdbcType=VARCHAR}, #{item.companyId,jdbcType=INTEGER})
</foreach>
</insert>
<update id="updateLeaseApplyInfo">
update lease_apply_info
<trim prefix="SET" suffixOverrides=",">
<if test="code != null">code = #{code},</if>
<if test="taskId != null">task_id = #{taskId},</if>
<if test="leasePerson != null">lease_person = #{leasePerson},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="type != null">`type` = #{type},</if>
<if test="companyAuditBy != null">company_audit_by = #{companyAuditBy},</if>
<if test="companyAuditTime != null">company_audit_time = #{companyAuditTime},</if>
<if test="companyAuditRemark != null">company_audit_remark = #{companyAuditRemark},</if>
<if test="deptAuditBy != null">dept_audit_by = #{deptAuditBy},</if>
<if test="deptAuditTime != null">dept_audit_time = #{deptAuditTime},</if>
<if test="deptAuditRemark != null">dept_audit_remark = #{deptAuditRemark},</if>
<if test="directAuditBy != null">direct_audit_by = #{directAuditBy},</if>
<if test="directAuditTime != null">direct_audit_time = #{directAuditTime},</if>
<if test="directAuditRemark != null">direct_audit_remark = #{directAuditRemark},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="applyCode != null">apply_code = #{applyCode},</if>
update_time = now(),
<if test="remark != null">remark = #{remark},</if>
<if test="companyId != null">company_id = #{companyId},</if>
<if test="directId != null">direct_id = #{directId},</if>
<if test="leaseType != null">lease_type = #{leaseType},</if>
<if test="estimateLeaseTime != null">estimate_lease_time = #{estimateLeaseTime},</if>
<if test="costBearingParty != null">cost_bearing_party = #{costBearingParty},</if>
</trim>
where id = #{id}
</update>
<select id="selectLeaseApplyInfoList" parameterType="com.bonus.common.biz.domain.lease.LeaseApplyInfo" resultMap="LeaseApplyInfoResult">
<include refid="selectLeaseApplyInfoVo"/>
<where>
<if test="code != null and code != ''"> and lai.code = #{code}</if>
<if test="taskId != null "> and lai.task_id = #{taskId}</if>
<if test="leasePerson != null and leasePerson != ''"> and lai.lease_person = #{leasePerson}</if>
<if test="phone != null and phone != ''"> and lai.phone = #{phone}</if>
<if test="type != null and type != ''"> and lai.type = #{type}</if>
<if test="companyAuditBy != null "> and lai.company_audit_by = #{companyAuditBy}</if>
<if test="companyAuditTime != null "> and lai.company_audit_time = #{companyAuditTime}</if>
<if test="companyAuditRemark != null and companyAuditRemark != ''"> and lai.company_audit_remark = #{companyAuditRemark}</if>
<if test="deptAuditBy != null "> and lai.dept_audit_by = #{deptAuditBy}</if>
<if test="deptAuditTime != null "> and lai.dept_audit_time = #{deptAuditTime}</if>
<if test="deptAuditRemark != null and deptAuditRemark != ''"> and lai.dept_audit_remark = #{deptAuditRemark}</if>
<if test="directAuditBy != null "> and lai.direct_audit_by = #{directAuditBy}</if>
<if test="directAuditTime != null "> and lai.direct_audit_time = #{directAuditTime}</if>
<if test="directAuditRemark != null and directAuditRemark != ''"> and lai.direct_audit_remark = #{directAuditRemark}</if>
<if test="companyId != null "> and lai.company_id = #{companyId}</if>
<if test="statusList != null and statusList.size() > 0">
and tt.task_status in
<foreach item="item" collection="statusList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="keyWord != null and keyWord != ''">
and (bu.unit_name like concat('%', #{keyWord}, '%') or
bp.pro_name like concat('%', #{keyWord}, '%') or
lai.code like concat('%', #{keyWord}, '%') or
lai.create_by like concat('%', #{keyWord}, '%') or
lai.lease_person like concat('%', #{keyWord}, '%') or
lai.phone like concat('%', #{keyWord}, '%') or
bp.contract_part like concat('%', #{keyWord}, '%') or
sd.dept_name like concat('%', #{keyWord}, '%')
)
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
<![CDATA[ AND DATE_FORMAT( lai.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} ]]>
</if>
<if test="directId != null "> and lai.direct_id = #{directId}</if>
<if test="leaseType != null and leaseType != ''"> and lai.lease_type = #{leaseType}</if>
<if test="estimateLeaseTime != null "> and lai.estimate_lease_time = #{estimateLeaseTime}</if>
<if test="costBearingParty != null and costBearingParty != ''"> and lai.cost_bearing_party = #{costBearingParty}</if>
and lai.apply_code is not null
</where>
GROUP BY lai.id
ORDER BY tt.task_status,tt.create_time desc
</select>
<select id="selectLeaseApplyDetailsList" parameterType="com.bonus.material.lease.domain.LeaseApplyDetails" resultMap="LeaseApplyDetailsResult">
<include refid="selectLeaseApplyDetailsVo"/>
<where>
<if test="parentId != null "> and lad.parent_id = #{parentId}</if>
<if test="keyword != null and keyword != ''">
AND (mt.type_name LIKE CONCAT('%', #{keyword}, '%')
OR mt2.type_name LIKE CONCAT('%', #{keyword}, '%'))
</if>
<if test="typeId != null "> and lad.type_id = #{typeId}</if>
<if test="preNum != null "> and lad.pre_num = #{preNum}</if>
<if test="auditNum != null "> and lad.audit_num = #{auditNum}</if>
<if test="alNum != null "> and lad.al_num = #{alNum}</if>
<if test="status != null and status != ''"> and lad.status = #{status}</if>
<if test="companyId != null "> and lad.company_id = #{companyId}</if>
</where>
</select>
<select id="selectLeaseApplyInfoById" parameterType="Long" resultMap="LeaseApplyInfoResult">
<include refid="selectLeaseApplyInfoVo"/>
where lai.id = #{id}
</select>
</mapper>

View File

@ -60,11 +60,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="deleteConfigByConfigId">
update bm_standard_config
set
del_flag = 2,
update_by = #{updateBy},
update_time = #{updateTime}
where id = #{configId}
set del_flag = 2,
update_by = #{updateBy},
update_time = #{updateTime}
where id = #{configId};
update bm_standard_config_details
set del_flag = 2,
update_by = #{updateBy},
update_time = #{updateTime}
where config_id = #{configId}
</update>
<update id="updateConfigDetails">
update bm_standard_config_details
@ -154,8 +159,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND mt.del_flag = '0'
) a ON a.typeId = bscd.type_id
WHERE
bscd.config_id = #{configId}
AND bscd.del_flag = 0
bscd.del_flag = 0
<if test="configId != null and configId != ''">
AND bscd.config_id = #{configId}
</if>
<if test="bean.keyWord != null and bean.keyWord !=''">
AND (a.houseName like concat('%',#{bean.keyWord},'%')
or a.constructionType like concat('%',#{bean.keyWord},'%')
@ -165,6 +172,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
or bscd.remark like concat('%',#{bean.keyWord},'%')
)
</if>
order by bscd.type_id asc
</select>
<select id="queryByNameAndParentId" resultType="com.bonus.material.ma.domain.StandardConfigBean">
@ -195,4 +203,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND config_id = #{configId}
AND type_id = #{typeId}
</select>
<select id="getConfigLevelTwoList" resultType="com.bonus.material.ma.domain.StandardConfigBean">
SELECT
bsc.id AS configId,
bsc.`name` AS configName,
bsc.parent_id AS parentId,
bsc.`level` AS level
FROM
bm_standard_config bsc
WHERE
bsc.del_flag = 0
AND bsc.`level` = 2
</select>
<select id="getListsByConfigId" resultType="com.bonus.material.ma.domain.vo.StandardConfigDetailsVo">
select *
from (SELECT mt1.type_id as typeId,
mt1.manage_type as manageType,
mt2.type_name as maTypeName,
mt1.type_name as typeName,
mt1.unit_name as unitName,
bscd.num as preNum,
CASE mt1.manage_type
WHEN 0 THEN
IFNULL(subquery0.num, 0)
ELSE
IFNULL(mt1.storage_num, 0)
END as storageNum
FROM bm_standard_config_details bscd
LEFT JOIN ma_type mt1 on mt1.type_id = bscd.type_id and mt1.del_flag = 0
LEFT JOIN ma_type mt2 ON mt2.type_id = mt1.parent_id and mt2.del_flag = 0
left join (SELECT mt.type_id,
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
count(mm.ma_id) num
FROM ma_machine mm
LEFT JOIN ma_type mt ON mt.type_id = mm.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
WHERE mm.ma_code is not null
and mm.ma_status in (1)
GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = mt1.type_id
WHERE bscd.config_id = #{configId}) a
where a.storageNum !=0
</select>
</mapper>

View File

@ -526,6 +526,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectMaTypeThreeList" resultMap="TypeResult">
select DISTINCT m.type_id, m.type_name, m.parent_id, m.unit_id, m.unit_name, m.unit_value,m.manage_type,
m.lease_price,m.eff_time, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
m.holding_time, m.warn_num,
m.del_flag, m.create_by, m.create_time,
m.remark,m.type_id id , m.type_name label,
CASE m.manage_type
WHEN 0 THEN
IFNULL(subquery0.num, 0)
ELSE
IFNULL(m.storage_num, 0)
END as storage_num
from ma_type m
left join (SELECT mt.type_id,
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
count(mm.ma_id) num
FROM ma_machine mm
LEFT JOIN ma_type mt ON mt.type_id = mm.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
WHERE mm.ma_code is not null and mm.ma_status in (1)
GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = m.type_id
<where>
m.del_flag = '0'
and m.level != '4'
<if test="typeName != null and typeName !=''">
AND m.type_name like concat('%',#{typeName},'%')
</if>
</where>
</select>
<select id="getListByTypeName" resultType="com.bonus.material.ma.domain.vo.MaTypeVo">
SELECT DISTINCT
m3.type_name AS itemType,

View File

@ -342,6 +342,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bm_qrcode_info bqi
WHERE
qr_code = #{qrCode}
<if test="taskId != null">
AND bqi.task_id = #{taskId}
</if>
</select>
<select id="selectPurchaseCheckDetailsById" resultType="com.bonus.material.purchase.domain.vo.PurchaseVo">

View File

@ -316,7 +316,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update
purchase_check_details
set
`status` = #{newTaskStatus}, check_result = #{checkResult}
pre_status = #{status}, `status` = #{newTaskStatus}, check_result = #{checkResult}
where
task_id = #{taskId}
and

View File

@ -9,10 +9,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bp.pro_id AS projectId, bp.pro_name AS projectName, bp.pro_code AS projectCode,
bu.unit_name AS unitName,
bma.agreement_id AS agreementId,bma.`agreement_code` AS agreementCode, bma.is_slt AS isSettlement,
bma.sign_time AS settlementTime, bma.is_push AS isPush
bma.sign_time AS signTime, bma.is_push AS isPush,
saa.audit_time AS settlementTime
FROM bm_agreement_info bma
LEFT JOIN bm_project bp ON bp.pro_id = bma.project_id
LEFT JOIN bm_unit bu ON bu.unit_id = bma.unit_id
LEFT JOIN slt_agreement_apply saa ON saa.agreement_id = bma.agreement_id AND bma.is_slt = 1
<where>
<if test="agreementCode != null and agreementCode != ''">
AND bma.agreement_code LIKE CONCAT('%',#{agreementCode},'%')
@ -102,4 +104,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bma.agreement_id = #{agreementId}
</where>
</select>
<insert id="insertProjectMonthCosts">
INSERT INTO project_month_costs(
AGREEMENT_ID,
LEASE_MONEY,
LOST_MONEY,
REPAIR_MONEY,
SCRAP_MONEY,
CHECK_STATUS,
MONTH
)
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.agreementId},
#{item.leaseMoney},
#{item.lostMoney},
#{item.repairMoney},
#{item.scrapMoney},
#{item.checkStatus},
#{item.month}
)
</foreach>
</insert>
</mapper>

View File

@ -0,0 +1,191 @@
<?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.settlement.mapper.SltAgreementReduceMapper">
<resultMap type="com.bonus.material.settlement.domain.SltAgreementReduce" id="SltAgreementReudceResult">
<result property="id" column="id" />
<result property="code" column="code" />
<result property="creator" column="creator" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="status" column="status" />
<result property="companyId" column="company_id" />
<result property="cost" column="cost" />
<result property="remark" column="remark" />
<result property="typeId" column="typeId" />
<result property="maName" column="maName" />
<result property="maModel" column="maModel" />
<result property="num" column="num" />
<result property="leasePrice" column="leasePrice" />
<result property="startTime" column="startTime" />
<result property="endTime" column="endTime" />
<result property="days" column="days" />
<result property="leaseMoney" column="leaseMoney" />
</resultMap>
<sql id="selectSltAgreementReduceVo">
select id, code, creator, create_time, update_time, status, company_id, cost, remark from slt_reduce_apply
</sql>
<select id="selectSltAgreementReduceList" parameterType="com.bonus.material.settlement.domain.SltAgreementReduce" resultMap="SltAgreementReudceResult">
<include refid="selectSltAgreementReduceVo"/>
<where>
<if test="code != null and code != ''"> and code = #{code}</if>
<if test="creator != null and creator != ''"> and creator = #{creator}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="companyId != null "> and company_id = #{companyId}</if>
<if test="cost != null "> and cost = #{cost}</if>
</where>
</select>
<select id="getApplyReduceList" resultMap="SltAgreementReudceResult">
SELECT
rs.id,
rs.typeId,
rs.agreementId,
rs.maName,
rs.maModel,
rs.maUnit,
SUM(rs.num) as num,
rs.leasePrice,
LEFT(rs.startTime,10) startTime,
LEFT(rs.endTime,10) endTime,
DATEDIFF(rs.endTime,rs.startTime)+1 as days ,
ROUND(SUM(rs.num)*rs.leasePrice*(DATEDIFF(rs.endTime,rs.startTime)+1) ,2)AS leaseMoney
FROM
(
SELECT
sai.id,
sai.agreement_id as agreementId,
sai.type_id as typeId,
sai.ma_id,
mt2.type_name as maName,
mt.type_name as maModel,
mt.unit_name as maUnit,
sai.num,
sai.start_time as startTime,
IFNULL(sai.end_time,NOW()) as endTime,
DATEDIFF(IFNULL(sai.end_time,NOW()),sai.start_time)+1 as days,
sai.`status`,
sai.lease_price as leasePrice
FROM
slt_agreement_info sai
left join ma_type mt on sai.type_id = mt.type_id
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
where
sai.agreement_id = #{agreementId}
<if test="startTime != null">
AND start_time &lt;= #{endTime}
AND (end_time &gt;= #{startTime} OR end_time IS NULL)
</if>
) rs
GROUP BY rs.typeId,rs.startTime
ORDER BY rs.maName
</select>
<select id="getMaxCode" resultType="java.lang.String">
SELECT
MAX( CODE ) AS maxCode
FROM
slt_reduce_apply
WHERE
code LIKE CONCAT('%', #{date},'%')
</select>
<insert id="insertReduce" useGeneratedKeys="true" keyProperty="id">
insert into slt_reduce_apply
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="code != null">code,</if>
<if test="creator != null">creator,</if>
<if test="createTime != null">create_time,</if>
<if test="agreementId != null">agreement_id,</if>
<if test="status != null">status,</if>
<if test="companyId != null">company_id,</if>
<if test="cost != null">cost,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="code != null">#{code},</if>
<if test="creator != null">#{creator},</if>
<if test="createTime != null">#{createTime},</if>
<if test="agreementId != null">#{agreementId},</if>
<if test="status != null">#{status},</if>
<if test="companyId != null">#{companyId},</if>
<if test="cost != null">#{cost},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<insert id="insertReduceDetail">
insert into slt_reduce_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">apply_id,</if>
<if test="startTime != null">start_time,</if>
<if test="endTime != null">end_time,</if>
<if test="typeId != null">type_id,</if>
<if test="num != null">num,</if>
<if test="reduceNum != null">reduce_num,</if>
<if test="reduceStartTime != null">r_start_time,</if>
<if test="reduceEndTime != null">r_end_time,</if>
<if test="reduceLeasePrice != null">lease_price,</if>
<if test="reduceLeaseMoney != null">lease_money,</if>
<if test="reduceDays != null">days,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="code != null">#{id},</if>
<if test="startTime != null">#{startTime},</if>
<if test="endTime != null">#{endTime},</if>
<if test="typeId != null">#{typeId},</if>
<if test="num != null">#{num},</if>
<if test="reduceNum != null">#{reduceNum},</if>
<if test="reduceStartTime != null">#{reduceStartTime},</if>
<if test="reduceEndTime != null">#{reduceEndTime},</if>
<if test="reduceLeasePrice != null">#{reduceLeasePrice},</if>
<if test="reduceLeaseMoney != null">#{reduceLeaseMoney},</if>
<if test="reduceDays != null">#{reduceDays},</if>
</trim>
</insert>
<insert id="insertBatchReduceDetail" parameterType="java.util.List">
INSERT INTO slt_reduce_details
(apply_id, start_time, end_time, type_id, num, reduce_num, r_start_time, r_end_time, lease_price, lease_money, days)
VALUES
<foreach collection="detailList" item="item" index="index" separator=",">
(
#{item.id},
#{item.startTime},
#{item.endTime},
#{item.typeId},
#{item.num},
#{item.reduceNum},
#{item.reduceStartTime},
#{item.reduceEndTime},
#{item.leasePrice},
#{item.reduceLeaseMoney},
#{item.reduceDays}
)
</foreach>
</insert>
<select id="findOverlappingReductions" resultMap="SltAgreementReudceResult">
SELECT *
FROM slt_reduce_details sd
left join slt_reduce_apply sa on sd.apply_id = sa.id
WHERE
sa.agreement_id = #{agreementId}
AND sd.type_id = #{typeId}
AND start_time &lt;= #{endTime}
AND end_time &gt;= #{startTime}
</select>
</mapper>

View File

@ -271,6 +271,9 @@
</configuration>
<version>3.12.0</version>
</plugin>
</plugins>
<pluginManagement>
<plugins>
@ -288,5 +291,10 @@
</plugin>
</plugins>
</pluginManagement>
</build>
</project>