结算管理代码提交

This commit is contained in:
liang.chao 2024-07-29 18:27:41 +08:00
parent 6b48590986
commit 4a71b8e634
16 changed files with 336 additions and 115 deletions

View File

@ -157,5 +157,7 @@ public class LeaseOutDetails implements Serializable {
private Integer manageType; private Integer manageType;
@ApiModelProperty(value = "数量出库-出库数量") @ApiModelProperty(value = "数量出库-出库数量")
private Integer inputNum; private Integer inputNum;
@ApiModelProperty(value = "0工程1长期")
private String leaseType;
} }

View File

@ -2,6 +2,8 @@ package com.bonus.sgzb.base.api.domain;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
/** /**
* @author c liu * @author c liu
* @date 2024/2/21 * @date 2024/2/21
@ -100,6 +102,10 @@ public class SltAgreementInfo {
* 租赁费用 * 租赁费用
*/ */
private String costs; private String costs;
/**
* 真实租赁费用
*/
private String realCosts;
/** /**
* 类型0不收费1收费 * 类型0不收费1收费
*/ */
@ -118,6 +124,18 @@ public class SltAgreementInfo {
private String sltType; private String sltType;
private String applyId; private String applyId;
private String keyWord; private String keyWord;
/**
* 费用承担方
*/
private String costBearingParty;
/**
* 调整天数
*/
private Integer trimDay;
/**
* 实际结算天数
*/
private BigDecimal realDays;
} }

View File

@ -44,7 +44,8 @@ public class SltAgreementRelation {
private String status; private String status;
String loseCost; String loseCost;
String leaseCost; String leaseCostOne;
String leaseCostThree;
String scrapCost; String scrapCost;
String repairCost; String repairCost;
/** /**

View File

@ -11,9 +11,10 @@ import java.util.List;
@Data @Data
public class SltInfoVo { public class SltInfoVo {
/** /**
* 租赁费用列表 * 租赁费用列表0103
*/ */
List<SltAgreementInfo> leaseList; List<SltAgreementInfo> leaseListOne;
List<SltAgreementInfo> leaseListThree;
/** /**
* 维修费用列表 * 维修费用列表
*/ */

View File

@ -261,6 +261,7 @@ public class TmTask implements Serializable {
private String manageType; private String manageType;
private String maCode; private String maCode;
private String maId; private String maId;
private String status;
private String maStatus; private String maStatus;
private String typeId; private String typeId;
private Double partNum; private Double partNum;

View File

@ -103,4 +103,8 @@ public interface LeaseOutDetailsMapper {
int getmaChineByCt(LeaseOutDetails record); int getmaChineByCt(LeaseOutDetails record);
void updateMaTypeNum(LeaseApplyDetails leaseApplyDetails); void updateMaTypeNum(LeaseApplyDetails leaseApplyDetails);
LeaseApplyDetails getLeaseApplyDetails(@Param("record") LeaseOutDetails record);
int updateLeaseApplyDetails(@Param("record") LeaseOutDetails record);
} }

View File

@ -198,6 +198,10 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
int res = 0; int res = 0;
// 首先更新领料任务详情表的领料数及状态lease_apply_details // 首先更新领料任务详情表的领料数及状态lease_apply_details
res = leaseOutDetailsMapper.updateLeaseApplyDetailsOutNum(record); res = leaseOutDetailsMapper.updateLeaseApplyDetailsOutNum(record);
LeaseApplyDetails leaseApplyDetails = leaseOutDetailsMapper.getLeaseApplyDetails(record);
if (leaseApplyDetails.getPreNum().equals(leaseApplyDetails.getAlNum()) || leaseApplyDetails.getAuditNum().equals(leaseApplyDetails.getAlNum())) {
leaseOutDetailsMapper.updateLeaseApplyDetails(record);
}
if (res > 0) { if (res > 0) {
// 插入领料出库明细表lease_out_details // 插入领料出库明细表lease_out_details
res = leaseOutDetailsMapper.insertSelective(record); res = leaseOutDetailsMapper.insertSelective(record);

View File

@ -14,13 +14,10 @@ import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.List; import java.util.List;
@ -43,7 +40,7 @@ public class MaPartTypeController extends BaseController {
@Autowired @Autowired
private IPartTypeService maPartTypeService; private IPartTypeService maPartTypeService;
@Autowired @Resource
private ExcelService excelService; private ExcelService excelService;
private static final String UPLOAD_DIR = "D:/work/wcy"; private static final String UPLOAD_DIR = "D:/work/wcy";

View File

@ -186,7 +186,7 @@
update_by = #{record.updateBy}, update_by = #{record.updateBy},
</if> </if>
update_time = now(), update_time = now(),
status = '2' status = '1'
WHERE WHERE
parennt_id = #{record.parentId} and type_id = #{record.typeId} parennt_id = #{record.parentId} and type_id = #{record.typeId}
</update> </update>
@ -315,6 +315,14 @@
WHERE WHERE
type_id = #{typeId} type_id = #{typeId}
</update> </update>
<update id="updateLeaseApplyDetails">
UPDATE
lease_apply_details
SET
status = '2'
WHERE
parennt_id = #{record.parentId} and type_id = #{record.typeId}
</update>
<insert id="insertAgreementInfo"> <insert id="insertAgreementInfo">
insert into tm_task_agreement insert into tm_task_agreement
@ -362,8 +370,8 @@
</trim> </trim>
</insert> </insert>
<insert id="insSltInfo"> <insert id="insSltInfo">
insert into slt_agreement_info (agreement_id,type_id,ma_id,num,start_time,status,lease_id,lease_price,buy_price,is_slt,company_id) insert into slt_agreement_info (agreement_id,type_id,ma_id,num,start_time,status,lease_id,lease_price,buy_price,is_slt,company_id,lease_type)
values (#{agreementId},#{record.typeId},#{record.maId},#{record.outNum},now(),0,#{record.parentId},#{ma.finalPrice},#{ma.buyPrice},'0',#{record.companyId}); values (#{agreementId},#{record.typeId},#{record.maId},#{record.outNum},now(),0,#{record.parentId},#{ma.finalPrice},#{ma.buyPrice},'0',#{record.companyId},#{record.leaseType});
</insert> </insert>
<select id="leaseOutRecordList" resultType="com.bonus.sgzb.base.api.domain.LeaseOutDetails"> <select id="leaseOutRecordList" resultType="com.bonus.sgzb.base.api.domain.LeaseOutDetails">
@ -431,4 +439,15 @@
<select id="getmaChineByCt" resultType="java.lang.Integer"> <select id="getmaChineByCt" resultType="java.lang.Integer">
select num from ma_type WHERE type_id = #{typeId} select num from ma_type WHERE type_id = #{typeId}
</select> </select>
<select id="getLeaseApplyDetails" resultType="com.bonus.sgzb.app.domain.LeaseApplyDetails">
SELECT
ifnull( pre_num, 0 ) AS preNum,
ifnull( audit_num, 0 ) AS auditNum,
ifnull( al_num, 0 ) AS alNum
FROM
lease_apply_details
WHERE
parennt_id = #{record.parentId}
AND type_id = #{record.typeId}
</select>
</mapper> </mapper>

View File

@ -1044,6 +1044,7 @@
lad.parennt_id as parentId, lad.parennt_id as parentId,
lad.pre_num - ifnull(lad.al_num,0) as outNum, lad.pre_num - ifnull(lad.al_num,0) as outNum,
lad.pre_num as preCountNum, lad.pre_num as preCountNum,
lad.status as status,
ifnull(lad.al_num,0) as alNum, ifnull(lad.al_num,0) as alNum,
mt2.type_name as typeName, mt2.type_name as typeName,
mt.type_name as typeModelName, mt.type_name as typeModelName,

View File

@ -42,22 +42,12 @@ public class SltAgreementInfoController extends BaseController {
@GetMapping("/getSltAgreementInfo") @GetMapping("/getSltAgreementInfo")
public TableDataInfo getSltAgreementInfo(AgreementInfo bean) { public TableDataInfo getSltAgreementInfo(AgreementInfo bean) {
startPage(); startPage();
List<AgreementInfo> list = new ArrayList<>(); List<AgreementInfo> list = sltAgreementInfoService.getSltAgreementInfo(bean);
//逻辑需要确认当往来单位id工程标段ID结算状态为空时是否返回异常如果返回异常前端配合改造
if (bean.getUnitId() == null && bean.getProjectId() == null && bean.getSltStatus()== null){
}else {
list = sltAgreementInfoService.getSltAgreementInfo(bean);
}
//上面代码可以改造为
/*if(bean.getUnitId() != null || bean.getProjectId() != null || bean.getSltStatus()!= null){
list = sltAgreementInfoService.getSltAgreementInfo(bean);
}*/
return getDataTable(list); return getDataTable(list);
} }
/** /**
* 根据协议获取结算清单 * 根据协议获取完工结算清单
*/ */
@ApiOperation(value = "根据协议获取结算清单") @ApiOperation(value = "根据协议获取结算清单")
@PostMapping("/getSltInfo") @PostMapping("/getSltInfo")
@ -66,13 +56,25 @@ public class SltAgreementInfoController extends BaseController {
return AjaxResult.success(bean); return AjaxResult.success(bean);
} }
/**
* 调整天数
*/
@ApiOperation(value = "调整天数")
@PostMapping("/updateTrimDay")
public AjaxResult updateTrimDay(@RequestBody List<SltAgreementInfo> sltAgreementInfo) {
int bean = sltAgreementInfoService.updateTrimDay(sltAgreementInfo);
if (bean == 0){
return AjaxResult.error("修改失败");
}
return AjaxResult.success("修改成功");
}
/** /**
* 租赁明细导出 * 租赁明细导出
*/ */
@Log(title = "租赁明细导出", businessType = BusinessType.EXPORT) @Log(title = "租赁明细导出", businessType = BusinessType.EXPORT)
@PostMapping("/exportLease") @PostMapping("/exportLease")
public void exportLease(HttpServletResponse response,@RequestBody List<AgreementInfo> list) public void exportLease(HttpServletResponse response, @RequestBody List<AgreementInfo> list) {
{
List<SltAgreementInfo> explist = sltAgreementInfoService.getLeaseList(list); List<SltAgreementInfo> explist = sltAgreementInfoService.getLeaseList(list);
List<LeaseInfo> leaseInfoList = Convert.toList(LeaseInfo.class, explist); List<LeaseInfo> leaseInfoList = Convert.toList(LeaseInfo.class, explist);
ExcelUtil<LeaseInfo> util = new ExcelUtil<LeaseInfo>(LeaseInfo.class); ExcelUtil<LeaseInfo> util = new ExcelUtil<LeaseInfo>(LeaseInfo.class);
@ -84,8 +86,7 @@ public class SltAgreementInfoController extends BaseController {
*/ */
@Log(title = "丢失明细导出", businessType = BusinessType.EXPORT) @Log(title = "丢失明细导出", businessType = BusinessType.EXPORT)
@PostMapping("/exportLose") @PostMapping("/exportLose")
public void exportLose(HttpServletResponse response,@RequestBody List<AgreementInfo> list) public void exportLose(HttpServletResponse response, @RequestBody List<AgreementInfo> list) {
{
List<SltAgreementInfo> explist = sltAgreementInfoService.getLoseList(list); List<SltAgreementInfo> explist = sltAgreementInfoService.getLoseList(list);
List<LoseInfo> leaseInfoList = Convert.toList(LoseInfo.class, explist); List<LoseInfo> leaseInfoList = Convert.toList(LoseInfo.class, explist);
ExcelUtil<LoseInfo> util = new ExcelUtil<LoseInfo>(LoseInfo.class); ExcelUtil<LoseInfo> util = new ExcelUtil<LoseInfo>(LoseInfo.class);
@ -97,8 +98,7 @@ public class SltAgreementInfoController extends BaseController {
*/ */
@Log(title = "维修明细导出", businessType = BusinessType.EXPORT) @Log(title = "维修明细导出", businessType = BusinessType.EXPORT)
@PostMapping("/exportRepair") @PostMapping("/exportRepair")
public void exportRepair(HttpServletResponse response,@RequestBody List<AgreementInfo> list) public void exportRepair(HttpServletResponse response, @RequestBody List<AgreementInfo> list) {
{
List<SltAgreementInfo> explist = sltAgreementInfoService.getRepairList(list); List<SltAgreementInfo> explist = sltAgreementInfoService.getRepairList(list);
List<LeaseInfo> leaseInfoList = Convert.toList(LeaseInfo.class, explist); List<LeaseInfo> leaseInfoList = Convert.toList(LeaseInfo.class, explist);
ExcelUtil<LeaseInfo> util = new ExcelUtil<LeaseInfo>(LeaseInfo.class); ExcelUtil<LeaseInfo> util = new ExcelUtil<LeaseInfo>(LeaseInfo.class);
@ -110,8 +110,7 @@ public class SltAgreementInfoController extends BaseController {
*/ */
@Log(title = "报废明细导出", businessType = BusinessType.EXPORT) @Log(title = "报废明细导出", businessType = BusinessType.EXPORT)
@PostMapping("/exportScrap") @PostMapping("/exportScrap")
public void exportScrap(HttpServletResponse response,@RequestBody List<AgreementInfo> list) public void exportScrap(HttpServletResponse response, @RequestBody List<AgreementInfo> list) {
{
List<SltAgreementInfo> explist = sltAgreementInfoService.getScrapList(list); List<SltAgreementInfo> explist = sltAgreementInfoService.getScrapList(list);
List<ScrapInfo> leaseInfoList = Convert.toList(ScrapInfo.class, explist); List<ScrapInfo> leaseInfoList = Convert.toList(ScrapInfo.class, explist);
ExcelUtil<ScrapInfo> util = new ExcelUtil<ScrapInfo>(ScrapInfo.class); ExcelUtil<ScrapInfo> util = new ExcelUtil<ScrapInfo>(ScrapInfo.class);
@ -123,8 +122,7 @@ public class SltAgreementInfoController extends BaseController {
*/ */
@ApiOperation(value = "费用结算提交") @ApiOperation(value = "费用结算提交")
@PostMapping("/submitFee") @PostMapping("/submitFee")
public AjaxResult submitFee(@RequestBody SltAgreementApply apply) public AjaxResult submitFee(@RequestBody SltAgreementApply apply) {
{
return sltAgreementInfoService.submitFee(apply); return sltAgreementInfoService.submitFee(apply);
} }
@ -133,8 +131,7 @@ public class SltAgreementInfoController extends BaseController {
*/ */
@ApiOperation(value = "获取结算审核列表") @ApiOperation(value = "获取结算审核列表")
@GetMapping("/getSltExam") @GetMapping("/getSltExam")
public TableDataInfo getSltExam(AgreementInfo bean) public TableDataInfo getSltExam(AgreementInfo bean) {
{
startPage(); startPage();
List<SltAgreementApply> list = sltAgreementInfoService.getSltExam(bean); List<SltAgreementApply> list = sltAgreementInfoService.getSltExam(bean);
return getDataTable(list); return getDataTable(list);
@ -145,8 +142,7 @@ public class SltAgreementInfoController extends BaseController {
*/ */
@ApiOperation(value = "获取结算审核清单") @ApiOperation(value = "获取结算审核清单")
@GetMapping("/getSltExamInfo") @GetMapping("/getSltExamInfo")
public AjaxResult getSltExamInfo(SltAgreementApply apply) public AjaxResult getSltExamInfo(SltAgreementApply apply) {
{
SltInfoVo bean = sltAgreementInfoService.getSltExamInfo(apply); SltInfoVo bean = sltAgreementInfoService.getSltExamInfo(apply);
return AjaxResult.success(bean); return AjaxResult.success(bean);
} }
@ -156,11 +152,9 @@ public class SltAgreementInfoController extends BaseController {
*/ */
@ApiOperation(value = "结算审核") @ApiOperation(value = "结算审核")
@GetMapping("/settlementReview") @GetMapping("/settlementReview")
public AjaxResult settlementReview(SltAgreementApply apply) public AjaxResult settlementReview(SltAgreementApply apply) {
{
return toAjax(sltAgreementInfoService.settlementReview(apply)); return toAjax(sltAgreementInfoService.settlementReview(apply));
} }
} }

View File

@ -20,6 +20,8 @@ public interface SltAgreementInfoMapper {
List<AgreementInfo> getSltAgreementInfo(AgreementInfo bean); List<AgreementInfo> getSltAgreementInfo(AgreementInfo bean);
List<SltAgreementInfo> getLeaseList(AgreementInfo bean); List<SltAgreementInfo> getLeaseList(AgreementInfo bean);
List<SltAgreementInfo> getLeaseListOne(AgreementInfo bean);
List<SltAgreementInfo> getLeaseListThree(AgreementInfo bean);
List<TmTask> getTaskList(@Param("bean") AgreementInfo bean, @Param("taskType")String taskType); List<TmTask> getTaskList(@Param("bean") AgreementInfo bean, @Param("taskType")String taskType);
@ -50,4 +52,6 @@ public interface SltAgreementInfoMapper {
int updateApply(SltAgreementApply apply); int updateApply(SltAgreementApply apply);
int updateMaStatus(SltAgreementInfo agreementInfo); int updateMaStatus(SltAgreementInfo agreementInfo);
int updateTrimDay(SltAgreementInfo sltAgreementInfo);
} }

View File

@ -25,12 +25,15 @@ public interface SltAgreementInfoService {
SltInfoVo getSltExamInfo(SltAgreementApply apply); SltInfoVo getSltExamInfo(SltAgreementApply apply);
int settlementReview(SltAgreementApply apply); int settlementReview(SltAgreementApply apply);
List<SltAgreementInfo> getLeaseList(List<AgreementInfo> list); List<SltAgreementInfo> getLeaseList(List<AgreementInfo> list);
List<SltAgreementInfo> getLeaseListOne(List<AgreementInfo> list);
List<SltAgreementInfo> getLeaseListThree(List<AgreementInfo> list);
List<SltAgreementInfo> getLoseList(List<AgreementInfo> list); List<SltAgreementInfo> getLoseList(List<AgreementInfo> list);
List<SltAgreementInfo> getRepairList(List<AgreementInfo> list); List<SltAgreementInfo> getRepairList(List<AgreementInfo> list);
List<SltAgreementInfo> getScrapList(List<AgreementInfo> list); List<SltAgreementInfo> getScrapList(List<AgreementInfo> list);
int updateTrimDay(List<SltAgreementInfo> sltAgreementInfo);
} }

View File

@ -43,18 +43,21 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
public SltInfoVo getSltInfo(List<AgreementInfo> list) { public SltInfoVo getSltInfo(List<AgreementInfo> list) {
SltInfoVo sltInfoVo = new SltInfoVo(); SltInfoVo sltInfoVo = new SltInfoVo();
//租赁费用列表 //租赁费用列表
List<SltAgreementInfo> leaseList = getLeaseList(list); List<SltAgreementInfo> leaseListOne = getLeaseListOne(list);
List<SltAgreementInfo> leaseListThree = getLeaseListThree(list);
//维修费用列表 //维修费用列表
List<SltAgreementInfo> repairList = getRepairList(list); List<SltAgreementInfo> repairList = getRepairList(list);
//报废费用列表 //报废费用列表
List<SltAgreementInfo> scrapList = getScrapList(list); List<SltAgreementInfo> scrapList = getScrapList(list);
//丢失费用列表 //丢失费用列表
List<SltAgreementInfo> loseList = getLoseList(list); List<SltAgreementInfo> loseList = getLoseList(list);
sltInfoVo.setLeaseList(leaseList); sltInfoVo.setLeaseListOne(leaseListOne);
sltInfoVo.setLeaseListThree(leaseListThree);
sltInfoVo.setRepairList(repairList); sltInfoVo.setRepairList(repairList);
sltInfoVo.setScrapList(scrapList); sltInfoVo.setScrapList(scrapList);
sltInfoVo.setLoseList(loseList); sltInfoVo.setLoseList(loseList);
List<SltAgreementRelation> relations = getRelations(leaseList,repairList,scrapList,loseList,list); List<SltAgreementRelation> relations = getRelations(leaseListOne, leaseListThree, repairList, scrapList, loseList, list);
sltInfoVo.setRelations(relations); sltInfoVo.setRelations(relations);
return sltInfoVo; return sltInfoVo;
} }
@ -71,11 +74,13 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
info.setAgreementId(Long.valueOf(relation.getAgreementId())); info.setAgreementId(Long.valueOf(relation.getAgreementId()));
list.add(info); list.add(info);
} }
List<SltAgreementInfo> leaseList = getLeaseList(list); List<SltAgreementInfo> leaseListOne = getLeaseListOne(list);
List<SltAgreementInfo> leaseListThree = getLeaseListThree(list);
List<SltAgreementInfo> repairList = getRepairList(list); List<SltAgreementInfo> repairList = getRepairList(list);
List<SltAgreementInfo> scrapList = getScrapList(list); List<SltAgreementInfo> scrapList = getScrapList(list);
List<SltAgreementInfo> loseList = getLoseList(list); List<SltAgreementInfo> loseList = getLoseList(list);
sltInfoVo.setLeaseList(leaseList); sltInfoVo.setLeaseListOne(leaseListOne);
sltInfoVo.setLeaseListOne(leaseListThree);
sltInfoVo.setRepairList(repairList); sltInfoVo.setRepairList(repairList);
sltInfoVo.setScrapList(scrapList); sltInfoVo.setScrapList(scrapList);
sltInfoVo.setLoseList(loseList); sltInfoVo.setLoseList(loseList);
@ -112,7 +117,78 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
return j; return j;
} }
private List<SltAgreementRelation> getRelations(List<SltAgreementInfo> leaseList, List<SltAgreementInfo> repairList, List<SltAgreementInfo> scrapList, List<SltAgreementInfo> loseList, List<AgreementInfo> list) { @Override
public List<SltAgreementInfo> getLeaseList(List<AgreementInfo> list) {
List<SltAgreementInfo> leaseList = new ArrayList<>();
for (AgreementInfo bean : list) {
List<SltAgreementInfo> oneOfList = sltAgreementInfoMapper.getLeaseList(bean);
leaseList.addAll(oneOfList);
}
for (SltAgreementInfo bean : leaseList) {
if (bean.getLeasePrice() == null) {
bean.setLeasePrice("0");
}
if (bean.getNum() == null) {
bean.setNum("0");
}
if (bean.getLeaseDays() == null) {
bean.setLeaseDays("0");
}
BigDecimal leasePrice = new BigDecimal(bean.getLeasePrice());
BigDecimal num = new BigDecimal(bean.getNum());
BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays());
BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays);
bean.setCosts(String.valueOf(costs));
/* BigDecimal costs = BigDecimal.ZERO;
//当单价数量租赁天数都不为空时计算总价
if(bean.getLeasePrice() != null && bean.getNum() != null && bean.getLeaseDays() != null){
BigDecimal leasePrice = new BigDecimal(bean.getLeasePrice());
BigDecimal num = new BigDecimal(bean.getNum());
BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays());
costs = leasePrice.multiply(num).multiply(leaseDays);
}
bean.setCosts(String.valueOf(costs));*/
}
return leaseList;
}
@Override
public List<SltAgreementInfo> getLeaseListThree(List<AgreementInfo> list) {
List<SltAgreementInfo> leaseList = new ArrayList<>();
for (AgreementInfo bean : list) {
List<SltAgreementInfo> oneOfList = sltAgreementInfoMapper.getLeaseListThree(bean);
leaseList.addAll(oneOfList);
}
for (SltAgreementInfo bean : leaseList) {
if (bean.getLeasePrice() == null) {
bean.setLeasePrice("0");
}
if (bean.getNum() == null) {
bean.setNum("0");
}
if (bean.getLeaseDays() == null) {
bean.setLeaseDays("0");
}
if (bean.getTrimDay() == null) {
bean.setTrimDay(0);
}
BigDecimal leasePrice = new BigDecimal(bean.getLeasePrice());
BigDecimal num = new BigDecimal(bean.getNum());
BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays());
// 实际结算天数领料天数 + 调整天数(可以为负整数)
BigDecimal realDays = leaseDays.add(new BigDecimal(bean.getTrimDay()));
// 实际结算金额
BigDecimal realCosts = leasePrice.multiply(num).multiply(realDays);
// 应结算金额
BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays);
bean.setCosts(String.valueOf(costs));
bean.setRealDays(realDays);
bean.setRealCosts(String.valueOf(realCosts));
}
return leaseList;
}
private List<SltAgreementRelation> getRelations(List<SltAgreementInfo> leaseListOne, List<SltAgreementInfo> leaseListThree, List<SltAgreementInfo> repairList, List<SltAgreementInfo> scrapList, List<SltAgreementInfo> loseList, List<AgreementInfo> list) {
List<SltAgreementRelation> relations = new ArrayList<>(); List<SltAgreementRelation> relations = new ArrayList<>();
for (AgreementInfo info : list) { for (AgreementInfo info : list) {
SltAgreementRelation relation = new SltAgreementRelation(); SltAgreementRelation relation = new SltAgreementRelation();
@ -121,17 +197,28 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
BigDecimal scrapCost = new BigDecimal("0"); BigDecimal scrapCost = new BigDecimal("0");
BigDecimal repairCost = new BigDecimal("0");*/ BigDecimal repairCost = new BigDecimal("0");*/
BigDecimal loseCost = BigDecimal.ZERO; BigDecimal loseCost = BigDecimal.ZERO;
BigDecimal leaseCost = BigDecimal.ZERO; BigDecimal leaseCostOne = BigDecimal.ZERO;
BigDecimal leaseCostThree = BigDecimal.ZERO;
BigDecimal scrapCost = BigDecimal.ZERO; BigDecimal scrapCost = BigDecimal.ZERO;
BigDecimal repairCost = BigDecimal.ZERO; BigDecimal repairCost = BigDecimal.ZERO;
for (SltAgreementInfo lease : leaseList){ for (SltAgreementInfo lease : leaseListOne) {
if (lease.getAgreementId().equals(info.getAgreementId().toString())) { if (lease.getAgreementId().equals(info.getAgreementId().toString())) {
relation.setAgreementId(lease.getAgreementId()); relation.setAgreementId(lease.getAgreementId());
relation.setProjectName(lease.getProjectName()); relation.setProjectName(lease.getProjectName());
relation.setUnitName(lease.getUnitName()); relation.setUnitName(lease.getUnitName());
relation.setCompanyId(lease.getCompanyId()); relation.setCompanyId(lease.getCompanyId());
BigDecimal cost = new BigDecimal(lease.getCosts()); BigDecimal cost = new BigDecimal(lease.getCosts());
leaseCost = leaseCost.add(cost); leaseCostOne = leaseCostOne.add(cost);
}
}
for (SltAgreementInfo lease : leaseListThree) {
if (lease.getAgreementId().equals(info.getAgreementId().toString())) {
relation.setAgreementId(lease.getAgreementId());
relation.setProjectName(lease.getProjectName());
relation.setUnitName(lease.getUnitName());
relation.setCompanyId(lease.getCompanyId());
BigDecimal cost = new BigDecimal(lease.getCosts());
leaseCostThree = leaseCostThree.add(cost);
} }
} }
for (SltAgreementInfo repair : repairList) { for (SltAgreementInfo repair : repairList) {
@ -157,7 +244,8 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
loseCost = loseCost.add(cost); loseCost = loseCost.add(cost);
} }
} }
relation.setLeaseCost(leaseCost.toString()); relation.setLeaseCostOne(leaseCostOne.toString());
relation.setLeaseCostThree(leaseCostThree.toString());
relation.setRepairCost(repairCost.toString()); relation.setRepairCost(repairCost.toString());
relation.setScrapCost(scrapCost.toString()); relation.setScrapCost(scrapCost.toString());
relation.setLoseCost(loseCost.toString()); relation.setLoseCost(loseCost.toString());
@ -190,11 +278,20 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
//throw new ServiceException(ExceptionDict.NEW_AGREEMENT_SETTLEMENT_ERROR_MSG,ExceptionDict.NEW_AGREEMENT_SETTLEMENT_ERROR); //throw new ServiceException(ExceptionDict.NEW_AGREEMENT_SETTLEMENT_ERROR_MSG,ExceptionDict.NEW_AGREEMENT_SETTLEMENT_ERROR);
} }
} }
List<SltAgreementInfo> leaseList = getLeaseList(list); List<SltAgreementInfo> leaseListOne = getLeaseListOne(list);
List<SltAgreementInfo> leaseListThree = getLeaseListThree(list);
List<SltAgreementInfo> repairList = getRepairList(list); List<SltAgreementInfo> repairList = getRepairList(list);
List<SltAgreementInfo> scrapList = getScrapList(list); List<SltAgreementInfo> scrapList = getScrapList(list);
List<SltAgreementInfo> loseList = getLoseList(list); List<SltAgreementInfo> loseList = getLoseList(list);
for (SltAgreementInfo info : leaseList){ for (SltAgreementInfo info : leaseListOne) {
info.setSltType("1");
//info.setSltType(CostTypeEnum.LEASE_COST.getCode());
info.setApplyId(String.valueOf(apply.getId()));
info.setPartType("1");
//info.setPartType(PartTypeEnum.CHARGE.getCode());
sltAgreementInfoMapper.insDetails(info);
}
for (SltAgreementInfo info : leaseListThree) {
info.setSltType("1"); info.setSltType("1");
//info.setSltType(CostTypeEnum.LEASE_COST.getCode()); //info.setSltType(CostTypeEnum.LEASE_COST.getCode());
info.setApplyId(String.valueOf(apply.getId())); info.setApplyId(String.valueOf(apply.getId()));
@ -281,6 +378,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
scrapList.addAll(scrapDetailsList); scrapList.addAll(scrapDetailsList);
} }
} }
if (scrapList != null && scrapList.size() > 0) { if (scrapList != null && scrapList.size() > 0) {
for (SltAgreementInfo bean : scrapList) { for (SltAgreementInfo bean : scrapList) {
@ -307,6 +405,19 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
return scrapList; return scrapList;
} }
@Override
@Transactional
public int updateTrimDay(List<SltAgreementInfo> sltAgreementInfo) {
int i = 0;
for (SltAgreementInfo agreementInfo : sltAgreementInfo) {
i = sltAgreementInfoMapper.updateTrimDay(agreementInfo);
if (i == 0) {
return i;
}
}
return i;
}
public List<SltAgreementInfo> getRepairList(List<AgreementInfo> list) { public List<SltAgreementInfo> getRepairList(List<AgreementInfo> list) {
List<SltAgreementInfo> repairList = new ArrayList<>(); List<SltAgreementInfo> repairList = new ArrayList<>();
String taskType = "41"; String taskType = "41";
@ -321,10 +432,10 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
return repairList; return repairList;
} }
public List<SltAgreementInfo> getLeaseList(List<AgreementInfo> list) { public List<SltAgreementInfo> getLeaseListOne(List<AgreementInfo> list) {
List<SltAgreementInfo> leaseList = new ArrayList<>(); List<SltAgreementInfo> leaseList = new ArrayList<>();
for (AgreementInfo bean : list) { for (AgreementInfo bean : list) {
List<SltAgreementInfo> oneOfList = sltAgreementInfoMapper.getLeaseList(bean); List<SltAgreementInfo> oneOfList = sltAgreementInfoMapper.getLeaseListOne(bean);
leaseList.addAll(oneOfList); leaseList.addAll(oneOfList);
} }
for (SltAgreementInfo bean : leaseList) { for (SltAgreementInfo bean : leaseList) {
@ -337,25 +448,28 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
if (bean.getLeaseDays() == null) { if (bean.getLeaseDays() == null) {
bean.setLeaseDays("0"); bean.setLeaseDays("0");
} }
if (bean.getTrimDay() == null) {
bean.setTrimDay(0);
}
BigDecimal leasePrice = new BigDecimal(bean.getLeasePrice()); BigDecimal leasePrice = new BigDecimal(bean.getLeasePrice());
BigDecimal num = new BigDecimal(bean.getNum()); BigDecimal num = new BigDecimal(bean.getNum());
BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays()); BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays());
// 实际结算天数领料天数 + 调整天数(可以为负整数)
BigDecimal realDays = leaseDays.add(new BigDecimal(bean.getTrimDay()));
// 实际结算金额
BigDecimal realCosts = leasePrice.multiply(num).multiply(realDays);
// 应结算金额
BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays); BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays);
bean.setCosts(String.valueOf(costs)); bean.setCosts(String.valueOf(costs));
/* BigDecimal costs = BigDecimal.ZERO; bean.setRealDays(realDays);
//当单价数量租赁天数都不为空时计算总价 bean.setRealCosts(String.valueOf(realCosts));
if(bean.getLeasePrice() != null && bean.getNum() != null && bean.getLeaseDays() != null){
BigDecimal leasePrice = new BigDecimal(bean.getLeasePrice());
BigDecimal num = new BigDecimal(bean.getNum());
BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays());
costs = leasePrice.multiply(num).multiply(leaseDays);
}
bean.setCosts(String.valueOf(costs));*/
} }
return leaseList; return leaseList;
} }
/**结算单号编码生成规则*/ /**
* 结算单号编码生成规则
*/
private String sltCodeRule(String code) { private String sltCodeRule(String code) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
Date nowDate = DateUtils.getNowDate(); Date nowDate = DateUtils.getNowDate();

View File

@ -585,7 +585,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ma_type mt ma_type mt
LEFT JOIN slt_agreement_info sai ON mt.type_id = sai.type_id LEFT JOIN slt_agreement_info sai ON mt.type_id = sai.type_id
WHERE WHERE
EXISTS ( SELECT 1 FROM slt_agreement_info sai2 WHERE sai2.type_id = mt.type_id AND sai2.agreement_id = #{agreementId} AND sai2.STATUS = '0' ) EXISTS ( SELECT 1 FROM slt_agreement_info sai2 WHERE sai2.type_id = mt.type_id AND sai2.agreement_id = #{agreementId} AND sai2.STATUS = '0' and sai.lease_type = 0)
GROUP BY GROUP BY
mt.type_id UNION ALL-- 递归情况:向上查找父级 mt.type_id UNION ALL-- 递归情况:向上查找父级
SELECT SELECT

View File

@ -85,6 +85,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
set ma_status = '103' set ma_status = '103'
where ma_id = #{maId} where ma_id = #{maId}
</update> </update>
<update id="updateTrimDay">
update slt_agreement_info
set trim_day = #{trimDay}
where agreement_id = #{agreementId} and type_id = #{typeId}
<if test="maId != null and maId != ''">
and ma_id = #{maId}
</if>
</update>
<select id="getSltAgreementInfo" resultType="com.bonus.sgzb.material.domain.AgreementInfo"> <select id="getSltAgreementInfo" resultType="com.bonus.sgzb.material.domain.AgreementInfo">
SELECT bai.agreement_id, bai.agreement_code , contract_code,file_url ,file_name,sign_time, SELECT bai.agreement_id, bai.agreement_code , contract_code,file_url ,file_name,sign_time,
bui.unit_id,bui.unit_name , bp.lot_id as projectId , bp.lot_name as projectName, bui.unit_id,bui.unit_name , bp.lot_id as projectId , bp.lot_name as projectName,
@ -111,9 +119,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<when test="sltStatus == '3'.toString()"> <when test="sltStatus == '3'.toString()">
and sar.status = '1' and sar.status = '1'
</when> </when>
<otherwise>
</otherwise>
</choose> </choose>
ORDER BY bai.agreement_id desc ORDER BY bai.agreement_id desc
</select> </select>
@ -135,6 +140,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
DATE(sai.end_time) as endTime, DATE(sai.end_time) as endTime,
DATEDIFF(IF(sai.end_time is null,CURDATE(),sai.end_time), sai.start_time) + 1 as leaseDays DATEDIFF(IF(sai.end_time is null,CURDATE(),sai.end_time), sai.start_time) + 1 as leaseDays
from slt_agreement_info sai from slt_agreement_info sai
LEFT JOIN lease_apply_info lai ON lai.id = sai.lease_id
LEFT JOIN bm_agreement_info bai on sai.agreement_id = bai.agreement_id LEFT JOIN bm_agreement_info bai on sai.agreement_id = bai.agreement_id
LEFT JOIN bm_project_lot bp ON bp.lot_id = bai.project_id LEFT JOIN bm_project_lot bp ON bp.lot_id = bai.project_id
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
@ -284,4 +290,56 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from slt_agreement_apply from slt_agreement_apply
where id = #{id} where id = #{id}
</select> </select>
<select id="getLeaseListOne" resultType="com.bonus.sgzb.base.api.domain.SltAgreementInfo">
select sai.id,
sai.agreement_id as agreementId,
bui.unit_name as unitName,
bp.lot_name as projectName,
sai.company_id as companyId,
sai.type_id as typeId,
sai.ma_id as maId,
mt1.type_name as typeName,
mt.type_name as modelName,
mt.unit_name as nuitName,
sai.lease_price as leasePrice,
sai.num as num,
sai.trim_day as trimDay,
DATE(sai.start_time) as startTime,
DATE(sai.end_time) as endTime,
DATEDIFF(IF(sai.end_time is null,CURDATE(),sai.end_time), sai.start_time) + 1 as leaseDays
from slt_agreement_info sai
LEFT JOIN lease_apply_info lai ON lai.id = sai.lease_id
LEFT JOIN bm_agreement_info bai on sai.agreement_id = bai.agreement_id
LEFT JOIN bm_project_lot bp ON bp.lot_id = bai.project_id
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
left join ma_type mt on sai.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id
where sai.agreement_id = #{agreementId} and sai.lease_type = 0 and lai.cost_bearing_party = '01'
</select>
<select id="getLeaseListThree" resultType="com.bonus.sgzb.base.api.domain.SltAgreementInfo">
select sai.id,
sai.agreement_id as agreementId,
bui.unit_name as unitName,
bp.lot_name as projectName,
sai.company_id as companyId,
sai.type_id as typeId,
sai.ma_id as maId,
mt1.type_name as typeName,
mt.type_name as modelName,
mt.unit_name as nuitName,
sai.trim_day as trimDay,
sai.lease_price as leasePrice,
sai.num as num,
DATE(sai.start_time) as startTime,
DATE(sai.end_time) as endTime,
DATEDIFF(IF(sai.end_time is null,CURDATE(),sai.end_time), sai.start_time) + 1 as leaseDays
from slt_agreement_info sai
LEFT JOIN lease_apply_info lai ON lai.id = sai.lease_id
LEFT JOIN bm_agreement_info bai on sai.agreement_id = bai.agreement_id
LEFT JOIN bm_project_lot bp ON bp.lot_id = bai.project_id
LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id
left join ma_type mt on sai.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id
where sai.agreement_id = #{agreementId} and sai.lease_type = 0 and lai.cost_bearing_party = '03'
</select>
</mapper> </mapper>