This commit is contained in:
hongchao 2025-10-10 12:11:25 +08:00
commit a94f01e29b
12 changed files with 178 additions and 105 deletions

View File

@ -23,18 +23,22 @@ public class MaterialSltInfoVo {
* 结算工程 * 结算工程
*/ */
private String projectName; private String projectName;
/** /**
* 租赁费用列表 * 租赁费用列表
*/ */
List<MaterialSltAgreementInfo> leaseList; List<MaterialSltAgreementInfo> leaseList;
/** /**
* 维修费用列表 * 维修费用列表
*/ */
List<MaterialSltAgreementInfo> repairList; List<MaterialSltAgreementInfo> repairList;
/** /**
* 报废费用列表 * 报废费用列表
*/ */
List<MaterialSltAgreementInfo> scrapList; List<MaterialSltAgreementInfo> scrapList;
/** /**
* 丢失费用列表 * 丢失费用列表
*/ */
@ -90,6 +94,7 @@ public class MaterialSltInfoVo {
@Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss") @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date createTime; private Date createTime;
@ApiModelProperty(value = "更新人")
private String updateBy; private String updateBy;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")

View File

@ -35,12 +35,12 @@ public interface ClzSltAgreementInfoMapper {
/** /**
* 更新协议结算状态 * 更新协议结算状态
*/ */
int updateClzSltInfoByIds(@Param("agreementIds") List<Long> agreementIds); int updateClzAgreementInfoByIds(@Param("agreementIds") List<Long> agreementIds);
/** /**
* 更新协议明细表状态 * 更新协议明细表状态
*/ */
int updateClzSltDetailsByIds(@Param("agreementIds") List<Long> agreementIds); int updateClzSltInfoByIds(@Param("agreementIds") List<Long> agreementIds);
/** /**
* 查询结算审批列表 * 查询结算审批列表

View File

@ -54,6 +54,7 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic
* @param sltAgreementApply * @param sltAgreementApply
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult costExamine(SltAgreementApply sltAgreementApply) { public AjaxResult costExamine(SltAgreementApply sltAgreementApply) {
if (Objects.isNull(sltAgreementApply) || Objects.isNull(sltAgreementApply.getStatus())) { if (Objects.isNull(sltAgreementApply) || Objects.isNull(sltAgreementApply.getStatus())) {
return AjaxResult.error("结算信息为空,请刷新后重试!"); return AjaxResult.error("结算信息为空,请刷新后重试!");
@ -82,18 +83,19 @@ public class ClzSltAgreementInfoServiceImpl implements ClzSltAgreementInfoServic
} else if (Objects.equals(REVIEW_PASS, sltAgreementApply.getStatus())) { } else if (Objects.equals(REVIEW_PASS, sltAgreementApply.getStatus())) {
// 通过更新slt_apply协议审批状态 // 通过更新slt_apply协议审批状态
int examNum = clzSltAgreementInfoMapper.costExame(sltAgreementApply); int examNum = clzSltAgreementInfoMapper.costExame(sltAgreementApply);
if (examNum == GlobalConstants.INT_0) { if (examNum <= 0) {
return AjaxResult.error("结算审批失败"); return AjaxResult.error("结算审批失败");
} else { } else {
// 更新结算协议表及相关信息 // 更新结算协议表及相关信息
clzSltAgreementInfoMapper.updateClzAgreementInfoByIds(idsBySltApplyCode);
clzSltAgreementInfoMapper.updateClzSltInfoByIds(idsBySltApplyCode); clzSltAgreementInfoMapper.updateClzSltInfoByIds(idsBySltApplyCode);
clzSltAgreementInfoMapper.updateClzSltDetailsByIds(idsBySltApplyCode); return AjaxResult.success("审批完成");
return AjaxResult.success();
} }
} else { } else {
return AjaxResult.error("审批错误,状态码错误"); return AjaxResult.error("审批错误,状态码错误");
} }
} catch (Exception e) { } catch (Exception e) {
System.err.println("结算审批失败,失败原因:" + e.getMessage());
return AjaxResult.error(); return AjaxResult.error();
} }
} }

View File

@ -107,9 +107,9 @@ public class IwsCostPushController extends BaseController {
// 计算统计信息 // 计算统计信息
BigDecimal totalLeaseMoney = exportVoList.stream().map(IwsCostPushExportVo::getLeaseMoney).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal totalLeaseMoney = exportVoList.stream().map(IwsCostPushExportVo::getLeaseMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal totalRepairMoney = exportVoList.stream().map(IwsCostPushExportVo::getRepairMoney).reduce(BigDecimal.ZERO, BigDecimal::add); // BigDecimal totalRepairMoney = exportVoList.stream().map(IwsCostPushExportVo::getRepairMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal totalLostMoney = exportVoList.stream().map(IwsCostPushExportVo::getLostMoney).reduce(BigDecimal.ZERO, BigDecimal::add); // BigDecimal totalLostMoney = exportVoList.stream().map(IwsCostPushExportVo::getLostMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal totalScrapMoney = exportVoList.stream().map(IwsCostPushExportVo::getScrapMoney).reduce(BigDecimal.ZERO, BigDecimal::add); // BigDecimal totalScrapMoney = exportVoList.stream().map(IwsCostPushExportVo::getScrapMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
// 创建统计行 // 创建统计行
IwsCostPushExportVo summaryVo = new IwsCostPushExportVo(); IwsCostPushExportVo summaryVo = new IwsCostPushExportVo();

View File

@ -34,6 +34,7 @@ import com.bonus.common.core.web.page.TableDataInfo;
@RestController @RestController
@RequestMapping("/slt_agreement_apply") @RequestMapping("/slt_agreement_apply")
public class SltAgreementApplyController extends BaseController { public class SltAgreementApplyController extends BaseController {
@Autowired @Autowired
private ISltAgreementApplyService sltAgreementApplyService; private ISltAgreementApplyService sltAgreementApplyService;
@ -49,20 +50,6 @@ public class SltAgreementApplyController extends BaseController {
return getDataTable(list); return getDataTable(list);
} }
/**
* 导出结算协议申请列表
*/
@ApiOperation(value = "导出结算协议申请列表")
@PreventRepeatSubmit
@RequiresPermissions("settlement:apply:export")
@SysLog(title = "结算协议申请", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出结算协议申请")
@PostMapping("/export")
public void export(HttpServletResponse response, SltAgreementApply sltAgreementApply) {
List<SltAgreementApply> list = sltAgreementApplyService.selectSltAgreementApplyList(sltAgreementApply);
ExcelUtil<SltAgreementApply> util = new ExcelUtil<SltAgreementApply>(SltAgreementApply.class);
util.exportExcel(response, list, "结算协议申请数据");
}
/** /**
* 获取结算协议申请详细信息 * 获取结算协议申请详细信息
*/ */
@ -116,4 +103,18 @@ public class SltAgreementApplyController extends BaseController {
public AjaxResult remove(@PathVariable Long[] ids) { public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(sltAgreementApplyService.deleteSltAgreementApplyByIds(ids)); return toAjax(sltAgreementApplyService.deleteSltAgreementApplyByIds(ids));
} }
/**
* 导出结算协议申请列表
*/
@ApiOperation(value = "导出结算协议申请列表")
@PreventRepeatSubmit
@RequiresPermissions("settlement:apply:export")
@SysLog(title = "结算协议申请", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出结算协议申请")
@PostMapping("/export")
public void export(HttpServletResponse response, SltAgreementApply sltAgreementApply) {
List<SltAgreementApply> list = sltAgreementApplyService.selectSltAgreementApplyList(sltAgreementApply);
ExcelUtil<SltAgreementApply> util = new ExcelUtil<>(SltAgreementApply.class);
util.exportExcel(response, list, "结算协议申请数据");
}
} }

View File

@ -71,10 +71,10 @@ public class SltAgreementInfoController extends BaseController {
@Autowired @Autowired
private ISltAgreementInfoService sltAgreementInfoService; private ISltAgreementInfoService sltAgreementInfoService;
@Autowired @Resource
private SltAgreementInfoMapper sltAgreementInfoMapper; private SltAgreementInfoMapper sltAgreementInfoMapper;
@Autowired @Resource
private TmTaskMapper taskMapper; private TmTaskMapper taskMapper;
@Resource @Resource
@ -197,14 +197,11 @@ public class SltAgreementInfoController extends BaseController {
return AjaxResult.success(bean); return AjaxResult.success(bean);
} }
public SltInfoVo mergerData(SltInfoVo vo,List<SltInfoVo> list,List<String> unitNames,List<String> projectNames){ public SltInfoVo mergerData(SltInfoVo vo,List<SltInfoVo> list, List<String> unitNames, List<String> projectNames) {
vo.setUnitName(handleData(unitNames)); vo.setUnitName(handleData(unitNames));
vo.setProjectName(handleData(projectNames)); vo.setProjectName(handleData(projectNames));
BigDecimal leaseCost = BigDecimal.valueOf(0.00); BigDecimal leaseCost = BigDecimal.ZERO, repairCost = BigDecimal.ZERO, scrapCost = BigDecimal.ZERO;;
BigDecimal repairCost = BigDecimal.valueOf(0.00); BigDecimal loseCost = BigDecimal.ZERO, reducCost = BigDecimal.ZERO;
BigDecimal scrapCost = BigDecimal.valueOf(0.00);
BigDecimal loseCost = BigDecimal.valueOf(0.00);
BigDecimal reducCost = BigDecimal.valueOf(0.00);
//租赁费用列表 //租赁费用列表
List<SltAgreementInfo> leaseList = new ArrayList<>(); List<SltAgreementInfo> leaseList = new ArrayList<>();
//维修费用列表 //维修费用列表
@ -1426,10 +1423,10 @@ public class SltAgreementInfoController extends BaseController {
public AjaxResult submitCosts(@RequestBody SltInfoVo sltInfoVo) { public AjaxResult submitCosts(@RequestBody SltInfoVo sltInfoVo) {
return toAjax(sltAgreementInfoService.submitCosts(sltInfoVo)); return toAjax(sltAgreementInfoService.submitCosts(sltInfoVo));
} }
/** /**
* 维修单据查询 * 维修单据查询
*/ */
@ApiOperation(value = "维修报表list查询") @ApiOperation(value = "维修报表list查询")
@GetMapping("/viewRepairCode") @GetMapping("/viewRepairCode")
public TableDataInfo viewRepairCode(SltAgreementInfo bean) { public TableDataInfo viewRepairCode(SltAgreementInfo bean) {
@ -1499,7 +1496,6 @@ public class SltAgreementInfoController extends BaseController {
@ApiOperation(value = "未结算报表list查询") @ApiOperation(value = "未结算报表list查询")
@GetMapping("/getSltReportList") @GetMapping("/getSltReportList")
public TableDataInfo getSltReportList(SltAgreementInfo query) { public TableDataInfo getSltReportList(SltAgreementInfo query) {
long startTime = System.currentTimeMillis();
try { try {
// 参数预处理和校验 // 参数预处理和校验
if (query == null) { if (query == null) {
@ -1514,7 +1510,6 @@ public class SltAgreementInfoController extends BaseController {
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
return getDataTable(new ArrayList<>()); return getDataTable(new ArrayList<>());
} }
log.info("查询到未结算协议数量: {}", list.size()); log.info("查询到未结算协议数量: {}", list.size());
// ----------- 给查询出来的协议设置权限控制例如只查询工器具 --------------- // ----------- 给查询出来的协议设置权限控制例如只查询工器具 ---------------
@ -1558,8 +1553,6 @@ public class SltAgreementInfoController extends BaseController {
// && CollectionUtils.isEmpty(vo.getLoseList()) // && CollectionUtils.isEmpty(vo.getLoseList())
// ); // );
long endTime = System.currentTimeMillis();
log.info("未结算报表查询完成,耗时: {}ms返回数据: {}条", (endTime - startTime), dataList.size());
TableDataInfo resultTableData = getDataTable(dataList); TableDataInfo resultTableData = getDataTable(dataList);
if (RequestContext.get("unSltAgreementListCount") != null) { if (RequestContext.get("unSltAgreementListCount") != null) {

View File

@ -16,11 +16,10 @@ import org.apache.poi.ss.usermodel.HorizontalAlignment;
* @author xsheng * @author xsheng
* @date 2024-10-16 * @date 2024-10-16
*/ */
@Data @Data
@ToString @ToString
public class SltAgreementApply extends BaseEntity { public class SltAgreementApply extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** $column.columnComment */ /** $column.columnComment */
@ -35,7 +34,8 @@ public class SltAgreementApply extends BaseEntity {
private String code; private String code;
/** 结算类型 1工器具 2安全工器具 */ /** 结算类型 1工器具 2安全工器具 */
private Byte settlementType; @JsonFormat(shape = JsonFormat.Shape.STRING)
private Integer settlementType;
/** /**
* 是否结算 0未结算 1结算完成 2部分结算 * 是否结算 0未结算 1结算完成 2部分结算

View File

@ -23,6 +23,12 @@ import org.apache.ibatis.annotations.Param;
* @date 2024-10-16 * @date 2024-10-16
*/ */
public interface SltAgreementInfoMapper { public interface SltAgreementInfoMapper {
/**
* 根据协议ID+结算类型去更新对应的费用明细
*/
int updateSltInfoByAgreementIdType(SltAgreementInfo sltAgreementInfo);
/** /**
* 查询结算信息 * 查询结算信息
* *
@ -237,6 +243,11 @@ public interface SltAgreementInfoMapper {
*/ */
int costExame(SltAgreementApply sltAgreementApply); int costExame(SltAgreementApply sltAgreementApply);
/**
* 删除结算明细
* @param sltAgreementApply 结算申请单
*/
void costDeleteDetail(SltAgreementApply sltAgreementApply); void costDeleteDetail(SltAgreementApply sltAgreementApply);
/** /**

View File

@ -29,6 +29,7 @@ import com.bonus.material.settlement.domain.SltAgreementApply;
import com.bonus.material.settlement.domain.SltAgreementReduce; import com.bonus.material.settlement.domain.SltAgreementReduce;
import com.bonus.material.settlement.domain.SltAgreementRelation; import com.bonus.material.settlement.domain.SltAgreementRelation;
import com.bonus.material.settlement.domain.vo.SltInfoVo; import com.bonus.material.settlement.domain.vo.SltInfoVo;
import com.bonus.material.settlement.mapper.SltAgreementApplyMapper;
import com.bonus.material.settlement.mapper.SltAgreementReduceMapper; import com.bonus.material.settlement.mapper.SltAgreementReduceMapper;
import com.bonus.material.task.domain.TmTask; import com.bonus.material.task.domain.TmTask;
import com.bonus.material.task.mapper.TmTaskMapper; import com.bonus.material.task.mapper.TmTaskMapper;
@ -74,16 +75,25 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
// 安全工器具结算类型settlement_type键值 // 安全工器具结算类型settlement_type键值
private static final int SAFETY_EQUIPMENT_SETTLEMENT_TYPE = GlobalConstants.INT_2; private static final int SAFETY_EQUIPMENT_SETTLEMENT_TYPE = GlobalConstants.INT_2;
@Autowired // 结算审核通过
private static final String REVIEW_PASS = "2";
// 结算审核驳回
private static final String REVIEW_REJECT = "3";
@Resource
private SltAgreementInfoMapper sltAgreementInfoMapper; private SltAgreementInfoMapper sltAgreementInfoMapper;
@Autowired @Resource
private BmAgreementInfoMapper bmAgreementInfoMapper; private BmAgreementInfoMapper bmAgreementInfoMapper;
@Autowired @Resource
private SltAgreementApplyMapper sltAgreementApplyMapper;
@Resource
private BmConfigMapper bmConfigMapper; private BmConfigMapper bmConfigMapper;
@Autowired @Resource
private TmTaskMapper taskMapper; private TmTaskMapper taskMapper;
@Resource @Resource
@ -227,12 +237,12 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
} }
} }
for (SltAgreementInfo lose : loseList) { for (SltAgreementInfo lose : loseList) {
if(lose.getCosts()!=null){ if (lose.getCosts() != null) {
loseCost = loseCost.add(lose.getCosts()); loseCost = loseCost.add(lose.getCosts());
} }
} }
for (SltAgreementReduce reduction : reductionList) { for (SltAgreementReduce reduction : reductionList) {
if(reduction.getLeaseMoney()!=null){ if (reduction.getLeaseMoney() != null) {
reducCost = reducCost.add(reduction.getLeaseMoney()); reducCost = reducCost.add(reduction.getLeaseMoney());
} }
} }
@ -642,6 +652,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
throw new ServiceException("协议id错误"); throw new ServiceException("协议id错误");
} }
// 查询待审核+审核通过的结算单数量
int theSettledCount = sltAgreementInfoMapper.selectTheSettledCountByAgreementIdType(sltInfoVo.getSettlementType(), agreementId); int theSettledCount = sltAgreementInfoMapper.selectTheSettledCountByAgreementIdType(sltInfoVo.getSettlementType(), agreementId);
if (sltInfoVo.getAgreementIds().length <= 1) { if (sltInfoVo.getAgreementIds().length <= 1) {
// 如果不是批量提交已结算的费用类型就直接提示已结算 // 如果不是批量提交已结算的费用类型就直接提示已结算
@ -804,7 +815,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
public List<SltAgreementInfo> getSltList(SltAgreementInfo bean) { public List<SltAgreementInfo> getSltList(SltAgreementInfo bean) {
List<SltAgreementInfo> list = sltAgreementInfoMapper.getSltList(bean); List<SltAgreementInfo> list = sltAgreementInfoMapper.getSltList(bean);
if (CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
for (SltAgreementInfo row : list){ for (SltAgreementInfo row : list) {
SltInfoVo sltInfoVo; SltInfoVo sltInfoVo;
sltInfoVo = getSltInfo(row); sltInfoVo = getSltInfo(row);
if (sltInfoVo != null) { if (sltInfoVo != null) {
@ -959,41 +970,74 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
* @return 结果 * @return 结果
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult costExamine(SltAgreementApply sltAgreementApply) { public AjaxResult costExamine(SltAgreementApply sltAgreementApply) {
if (Objects.isNull(sltAgreementApply) || Objects.isNull(sltAgreementApply.getStatus())) {
return AjaxResult.error("结算信息为空,请刷新后重试!");
}
try { try {
Long userid = SecurityUtils.getLoginUser().getUserid(); sltAgreementApply.setAuditor(String.valueOf(SecurityUtils.getLoginUser().getUserid()));
sltAgreementApply.setAuditor(String.valueOf(userid));
sltAgreementApply.setAuditTime(DateUtils.getNowDate()); sltAgreementApply.setAuditTime(DateUtils.getNowDate());
sltAgreementApply.setUpdateTime(DateUtils.getNowDate()); sltAgreementApply.setUpdateTime(DateUtils.getNowDate());
if (sltAgreementApply.getStatus().equals("3")) {
// 驳回更新slt协议审批状态 if (Objects.equals(REVIEW_REJECT, sltAgreementApply.getStatus())) {
int count = sltAgreementInfoMapper.costExame(sltAgreementApply); // 驳回更新slt_apply协议审批状态
int updateNum = sltAgreementInfoMapper.costExame(sltAgreementApply);
// 删除结算详情 // 删除结算详情
sltAgreementInfoMapper.costDeleteDetail(sltAgreementApply); sltAgreementInfoMapper.costDeleteDetail(sltAgreementApply);
if (count != 1) { if (updateNum != GlobalConstants.INT_1) {
return AjaxResult.error("结算审批失败"); return AjaxResult.error("结算审批失败");
} else { } else {
// 更新协议状态 // 获取已审核和待审核的条数
int beforeSettlementCount = sltAgreementInfoMapper.getBeforeSettlementCount(new SltInfoVo().setAgreementId(sltAgreementApply.getAgreementId())); int beforeSettlementCount = sltAgreementInfoMapper.getBeforeSettlementCount(new SltInfoVo().setAgreementId(sltAgreementApply.getAgreementId()));
// 根据待审核+已审核的数量来决定更新到哪种状态 // 根据待审核+已审核的数量来决定更新到哪种状态
sltAgreementApply.setIsSlt(beforeSettlementCount > GlobalConstants.INT_0 ? GlobalConstants.INT_2 : GlobalConstants.INT_0); sltAgreementApply.setIsSlt(beforeSettlementCount > GlobalConstants.INT_0 ? GlobalConstants.INT_2 : GlobalConstants.INT_0);
int countTwo = sltAgreementInfoMapper.updateBmAgreementReject(sltAgreementApply); int countTwo = sltAgreementInfoMapper.updateBmAgreementReject(sltAgreementApply);
if(countTwo != GlobalConstants.INT_1) { if (countTwo != GlobalConstants.INT_1) {
return AjaxResult.error("bm_agreement_info修改失败"); return AjaxResult.error("bm_agreement_info修改失败");
} }
return AjaxResult.success(); return AjaxResult.success();
} }
} else { } else if (Objects.equals(REVIEW_PASS, sltAgreementApply.getStatus())) {
//通过 // 根据ID查询settlement_type
int count = sltAgreementInfoMapper.costExame(sltAgreementApply); SltAgreementApply sltAgreementApplyFromDb = sltAgreementApplyMapper.selectSltAgreementApplyById(sltAgreementApply.getId());
if (count == GlobalConstants.INT_0) { if (sltAgreementApplyFromDb == null || sltAgreementApplyFromDb.getSettlementType() == null) {
return AjaxResult.error("结算类型错误,结算权限码为空");
}
// 通过更新slt_apply协议审批状态
int examNum = sltAgreementInfoMapper.costExame(sltAgreementApply);
// 更新bm_agreement_info结算状态
int beforeCount = sltAgreementInfoMapper.getBeforeSettlementCount(new SltInfoVo().setAgreementId(sltAgreementApply.getAgreementId()));
sltAgreementApply.setIsSlt(beforeCount == 0 ? GlobalConstants.INT_1 : GlobalConstants.INT_2);
int countTwo = bmAgreementInfoMapper.updateBmAgreementInfo(new BmAgreementInfo().setIsSlt(Long.valueOf(sltAgreementApply.getIsSlt()))
.setAgreementId(sltAgreementApply.getAgreementId())
);
if (countTwo != GlobalConstants.INT_1) {
throw new ServiceException("bm_agreement_info修改失败");
}
// 修改slt_agreement_info的结算状态
int countThree = sltAgreementInfoMapper.updateSltInfoByAgreementIdType(
new SltAgreementInfo()
.setAgreementId(sltAgreementApply.getAgreementId())
.setSettlementType(Integer.valueOf(sltAgreementApplyFromDb.getSettlementType()))
);
if (countThree == 0) {
throw new ServiceException("slt_agreement_info修改失败");
}
if (examNum == GlobalConstants.INT_0) {
return AjaxResult.error("结算审批失败"); return AjaxResult.error("结算审批失败");
} else { } else {
return AjaxResult.success(); return AjaxResult.success();
} }
} else {
return AjaxResult.error("审批错误,状态码错误");
} }
} catch (Exception e) { } catch (Exception e) {
return AjaxResult.error(); throw new ServiceException(e.getMessage());
} }
} }

View File

@ -3,6 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.material.clz.mapper.ClzSltAgreementInfoMapper"> <mapper namespace="com.bonus.material.clz.mapper.ClzSltAgreementInfoMapper">
<insert id="insertSltAgreementApply" useGeneratedKeys="true" keyProperty="id"> <insert id="insertSltAgreementApply" useGeneratedKeys="true" keyProperty="id">
insert into clz_slt_agreement_apply insert into clz_slt_agreement_apply
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
@ -294,7 +295,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
saa.`code` = #{sltApplyCode} saa.`code` = #{sltApplyCode}
</select> </select>
<select id="costExame" resultType="int"> <update id="costExame">
update clz_slt_agreement_apply update clz_slt_agreement_apply
<set> <set>
<if test="status != null and status!=''">status = #{status},</if> <if test="status != null and status!=''">status = #{status},</if>
@ -303,8 +304,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="auditor != null and auditor!=''">auditor = #{auditor},</if> <if test="auditor != null and auditor!=''">auditor = #{auditor},</if>
<if test="remark != null and remark!=''">remark = #{remark}</if> <if test="remark != null and remark!=''">remark = #{remark}</if>
</set> </set>
where `code` = #{code,jdbcType=VARCHAR} where `code` = #{code}
</select> </update>
<select id="getSltAgreementIdsBySltApplyCode" resultType="java.lang.Long"> <select id="getSltAgreementIdsBySltApplyCode" resultType="java.lang.Long">
select agreement_id select agreement_id
@ -312,20 +313,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where `code` = #{sltApplyCode} where `code` = #{sltApplyCode}
</select> </select>
<update id="updateClzSltInfoByIds"> <update id="updateClzAgreementInfoByIds">
update clz_bm_agreement_info update clz_bm_agreement_info
set is_slt = 1, update_time = now(), slt_time = now() set is_slt = 1, update_time = now()
where agreement_id in where agreement_id in
<foreach item="item" index="index" collection="agreementIds" open="(" separator="," close=")"> <foreach item="item" index="index" collection="agreementIds" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
</update> </update>
<update id="updateClzSltDetailsByIds"> <update id="updateClzSltInfoByIds">
update clz_slt_agreement_info update clz_slt_agreement_info
set end_time = now(), update_time = now() set slt_time = now(), update_time = now(), is_slt = '1'
where id in where agreement_id in
<foreach item="item" index="index" collection="ids" open="(" separator="," close=")"> <foreach item="item" index="index" collection="agreementIds" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
</update> </update>

View File

@ -15,10 +15,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="companyId" column="company_id" /> <result property="companyId" column="company_id" />
<result property="cost" column="cost" /> <result property="cost" column="cost" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<result property="settlementType" column="settlement_type"/>
</resultMap> </resultMap>
<sql id="selectSltAgreementApplyVo"> <sql id="selectSltAgreementApplyVo">
select id, code, creator, create_time, update_time, auditor, audit_time, status, company_id, cost, remark from slt_agreement_apply select id, code, creator, create_time, update_time, auditor, audit_time, status, company_id, cost, remark, settlement_type from slt_agreement_apply
</sql> </sql>
<select id="selectSltAgreementApplyList" parameterType="com.bonus.material.settlement.domain.SltAgreementApply" resultMap="SltAgreementApplyResult"> <select id="selectSltAgreementApplyList" parameterType="com.bonus.material.settlement.domain.SltAgreementApply" resultMap="SltAgreementApplyResult">

View File

@ -1304,11 +1304,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sai.type_id, sai.type_id,
mt.type_name as model_name, mt.buy_price, mt.type_name as model_name, mt.buy_price,
mt1.type_name as type_name, mt1.type_name as type_name,
sai.ma_id, sai.num, sai.price as lease_price, sai.start_time, sai.end_time, sai.ma_id, sai.num, sai.price as lease_price, sai.start_time, IFNULL(sai.end_time,saa.create_time) as end_time,
mt.unit_name as mt_unit_name, mt.comsumable, mt.unit_name as mt_unit_name, mt.comsumable,
bai.remark bai.remark
FROM bm_agreement_info bai FROM bm_agreement_info bai
INNER JOIN slt_agreement_details sai ON bai.agreement_id = sai.apply_id LEFT JOIN slt_agreement_apply saa on bai.agreement_id = saa.agreement_id
LEFT JOIN slt_agreement_details sai ON saa.ID = sai.apply_id
LEFT JOIN bm_unit bu ON bai.unit_id = bu.unit_id LEFT JOIN bm_unit bu ON bai.unit_id = bu.unit_id
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
LEFT JOIN ma_type mt ON sai.type_id = mt.type_id AND mt.`level` = '4' LEFT JOIN ma_type mt ON sai.type_id = mt.type_id AND mt.`level` = '4'
@ -1338,13 +1339,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 数据库层面的时间范围过滤 - 修正跨区间租赁逻辑 --> <!-- 数据库层面的时间范围过滤 - 修正跨区间租赁逻辑 -->
AND ( AND (
<!-- 已结算协议:租赁期间与查询区间有交集 --> <!-- 已结算协议:租赁期间与查询区间有交集 -->
(bai.is_slt = 1 AND ( (bai.is_slt IN(1,2) AND (
<!-- 情况1领料时间在查询区间内 --> <!-- 情况1领料时间在查询区间内 -->
(sai.start_time IS NOT NULL AND DATE(sai.start_time) &gt;= #{startDate} AND DATE(sai.start_time) &lt;= #{endDate}) (sai.start_time IS NOT NULL AND DATE(sai.start_time) &gt;= #{startDate} AND DATE(sai.start_time) &lt;= #{endDate})
OR OR
<!-- 情况2退料时间在查询区间内 --> <!-- 情况2退料时间在查询区间内 -->
(sai.end_time IS NOT NULL AND DATE(sai.end_time) &gt;= #{startDate} AND DATE(sai.end_time) &lt;= #{endDate}) (sai.end_time IS NOT NULL AND DATE(sai.end_time) &gt;= #{startDate} AND DATE(sai.end_time) &lt;= #{endDate})
OR OR
<!-- 情况2+:结算时间在查询区间内 -->
(sai.end_time IS NULL AND DATE(saa.create_time) &gt;= #{startDate} AND DATE(saa.create_time) &lt;= #{endDate})
OR
<!-- 情况4跨区间租赁领料在区间前退料/结算在区间后) --> <!-- 情况4跨区间租赁领料在区间前退料/结算在区间后) -->
(sai.start_time IS NOT NULL AND DATE(sai.start_time) &lt; #{startDate} AND (sai.start_time IS NOT NULL AND DATE(sai.start_time) &lt; #{startDate} AND
((sai.end_time IS NOT NULL AND DATE(sai.end_time) &gt; #{endDate}) )) ((sai.end_time IS NOT NULL AND DATE(sai.end_time) &gt; #{endDate}) ))
@ -1419,4 +1423,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where where
bai.agreement_id = #{agreementId} bai.agreement_id = #{agreementId}
</select> </select>
<update id="updateSltInfoByAgreementIdType">
UPDATE
slt_agreement_info sai
JOIN
ma_type mt ON sai.type_id = mt.type_id AND mt.`level` = '4'
SET
sai.is_slt = '1', sai.slt_time = NOW()
WHERE
sai.agreement_id = #{agreementId} AND mt.jiju_type = #{settlementType}
</update>
</mapper> </mapper>