结算管理代码提交

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;
@ApiModelProperty(value = "数量出库-出库数量")
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 java.math.BigDecimal;
/**
* @author c liu
* @date 2024/2/21
@ -100,6 +102,10 @@ public class SltAgreementInfo {
* 租赁费用
*/
private String costs;
/**
* 真实租赁费用
*/
private String realCosts;
/**
* 类型0不收费1收费
*/
@ -118,6 +124,18 @@ public class SltAgreementInfo {
private String sltType;
private String applyId;
private String keyWord;
/**
* 费用承担方
*/
private String costBearingParty;
/**
* 调整天数
*/
private Integer trimDay;
/**
* 实际结算天数
*/
private BigDecimal realDays;
}

View File

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

View File

@ -11,9 +11,10 @@ import java.util.List;
@Data
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 maCode;
private String maId;
private String status;
private String maStatus;
private String typeId;
private Double partNum;

View File

@ -103,4 +103,8 @@ public interface LeaseOutDetailsMapper {
int getmaChineByCt(LeaseOutDetails record);
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;
// 首先更新领料任务详情表的领料数及状态lease_apply_details
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) {
// 插入领料出库明细表lease_out_details
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.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileOutputStream;
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.Paths;
import java.util.List;
@ -43,7 +40,7 @@ public class MaPartTypeController extends BaseController {
@Autowired
private IPartTypeService maPartTypeService;
@Autowired
@Resource
private ExcelService excelService;
private static final String UPLOAD_DIR = "D:/work/wcy";

View File

@ -186,7 +186,7 @@
update_by = #{record.updateBy},
</if>
update_time = now(),
status = '2'
status = '1'
WHERE
parennt_id = #{record.parentId} and type_id = #{record.typeId}
</update>
@ -315,6 +315,14 @@
WHERE
type_id = #{typeId}
</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 into tm_task_agreement
@ -362,8 +370,8 @@
</trim>
</insert>
<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)
values (#{agreementId},#{record.typeId},#{record.maId},#{record.outNum},now(),0,#{record.parentId},#{ma.finalPrice},#{ma.buyPrice},'0',#{record.companyId});
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},#{record.leaseType});
</insert>
<select id="leaseOutRecordList" resultType="com.bonus.sgzb.base.api.domain.LeaseOutDetails">
@ -431,4 +439,15 @@
<select id="getmaChineByCt" resultType="java.lang.Integer">
select num from ma_type WHERE type_id = #{typeId}
</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>

View File

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

View File

@ -42,22 +42,12 @@ public class SltAgreementInfoController extends BaseController {
@GetMapping("/getSltAgreementInfo")
public TableDataInfo getSltAgreementInfo(AgreementInfo bean) {
startPage();
List<AgreementInfo> list = new ArrayList<>();
//逻辑需要确认当往来单位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);
}*/
List<AgreementInfo> list = sltAgreementInfoService.getSltAgreementInfo(bean);
return getDataTable(list);
}
/**
* 根据协议获取结算清单
* 根据协议获取完工结算清单
*/
@ApiOperation(value = "根据协议获取结算清单")
@PostMapping("/getSltInfo")
@ -66,15 +56,27 @@ public class SltAgreementInfoController extends BaseController {
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)
@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<LeaseInfo> leaseInfoList = Convert.toList(LeaseInfo.class,explist);
List<LeaseInfo> leaseInfoList = Convert.toList(LeaseInfo.class, explist);
ExcelUtil<LeaseInfo> util = new ExcelUtil<LeaseInfo>(LeaseInfo.class);
util.exportExcel(response, leaseInfoList, "租赁明细导出");
}
@ -84,10 +86,9 @@ public class SltAgreementInfoController extends BaseController {
*/
@Log(title = "丢失明细导出", businessType = BusinessType.EXPORT)
@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<LoseInfo> leaseInfoList = Convert.toList(LoseInfo.class,explist);
List<LoseInfo> leaseInfoList = Convert.toList(LoseInfo.class, explist);
ExcelUtil<LoseInfo> util = new ExcelUtil<LoseInfo>(LoseInfo.class);
util.exportExcel(response, leaseInfoList, "丢失明细导出");
}
@ -97,10 +98,9 @@ public class SltAgreementInfoController extends BaseController {
*/
@Log(title = "维修明细导出", businessType = BusinessType.EXPORT)
@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<LeaseInfo> leaseInfoList = Convert.toList(LeaseInfo.class,explist);
List<LeaseInfo> leaseInfoList = Convert.toList(LeaseInfo.class, explist);
ExcelUtil<LeaseInfo> util = new ExcelUtil<LeaseInfo>(LeaseInfo.class);
util.exportExcel(response, leaseInfoList, "维修明细导出");
}
@ -110,10 +110,9 @@ public class SltAgreementInfoController extends BaseController {
*/
@Log(title = "报废明细导出", businessType = BusinessType.EXPORT)
@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<ScrapInfo> leaseInfoList = Convert.toList(ScrapInfo.class,explist);
List<ScrapInfo> leaseInfoList = Convert.toList(ScrapInfo.class, explist);
ExcelUtil<ScrapInfo> util = new ExcelUtil<ScrapInfo>(ScrapInfo.class);
util.exportExcel(response, leaseInfoList, "维修明细导出");
}
@ -123,8 +122,7 @@ public class SltAgreementInfoController extends BaseController {
*/
@ApiOperation(value = "费用结算提交")
@PostMapping("/submitFee")
public AjaxResult submitFee(@RequestBody SltAgreementApply apply)
{
public AjaxResult submitFee(@RequestBody SltAgreementApply apply) {
return sltAgreementInfoService.submitFee(apply);
}
@ -133,8 +131,7 @@ public class SltAgreementInfoController extends BaseController {
*/
@ApiOperation(value = "获取结算审核列表")
@GetMapping("/getSltExam")
public TableDataInfo getSltExam(AgreementInfo bean)
{
public TableDataInfo getSltExam(AgreementInfo bean) {
startPage();
List<SltAgreementApply> list = sltAgreementInfoService.getSltExam(bean);
return getDataTable(list);
@ -145,8 +142,7 @@ public class SltAgreementInfoController extends BaseController {
*/
@ApiOperation(value = "获取结算审核清单")
@GetMapping("/getSltExamInfo")
public AjaxResult getSltExamInfo(SltAgreementApply apply)
{
public AjaxResult getSltExamInfo(SltAgreementApply apply) {
SltInfoVo bean = sltAgreementInfoService.getSltExamInfo(apply);
return AjaxResult.success(bean);
}
@ -156,11 +152,9 @@ public class SltAgreementInfoController extends BaseController {
*/
@ApiOperation(value = "结算审核")
@GetMapping("/settlementReview")
public AjaxResult settlementReview(SltAgreementApply apply)
{
public AjaxResult settlementReview(SltAgreementApply apply) {
return toAjax(sltAgreementInfoService.settlementReview(apply));
}
}

View File

@ -20,6 +20,8 @@ public interface SltAgreementInfoMapper {
List<AgreementInfo> getSltAgreementInfo(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);
@ -50,4 +52,6 @@ public interface SltAgreementInfoMapper {
int updateApply(SltAgreementApply apply);
int updateMaStatus(SltAgreementInfo agreementInfo);
int updateTrimDay(SltAgreementInfo sltAgreementInfo);
}

View File

@ -25,12 +25,15 @@ public interface SltAgreementInfoService {
SltInfoVo getSltExamInfo(SltAgreementApply apply);
int settlementReview(SltAgreementApply apply);
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> getRepairList(List<AgreementInfo> list);
List<SltAgreementInfo> getScrapList(List<AgreementInfo> list);
int updateTrimDay(List<SltAgreementInfo> sltAgreementInfo);
}

View File

@ -35,7 +35,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
private SltAgreementInfoMapper sltAgreementInfoMapper;
@Override
public List<AgreementInfo> getSltAgreementInfo(AgreementInfo bean) {
public List<AgreementInfo> getSltAgreementInfo(AgreementInfo bean) {
return sltAgreementInfoMapper.getSltAgreementInfo(bean);
}
@ -43,18 +43,21 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
public SltInfoVo getSltInfo(List<AgreementInfo> list) {
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> scrapList = getScrapList(list);
//丢失费用列表
List<SltAgreementInfo> loseList = getLoseList(list);
sltInfoVo.setLeaseList(leaseList);
sltInfoVo.setLeaseListOne(leaseListOne);
sltInfoVo.setLeaseListThree(leaseListThree);
sltInfoVo.setRepairList(repairList);
sltInfoVo.setScrapList(scrapList);
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);
return sltInfoVo;
}
@ -66,16 +69,18 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
String cost = sltAgreementInfoMapper.getCost(apply);
List<SltAgreementRelation> relations = sltAgreementInfoMapper.getRelations(apply);
sltInfoVo.setRelations(relations);
for (SltAgreementRelation relation : relations){
for (SltAgreementRelation relation : relations) {
AgreementInfo info = new AgreementInfo();
info.setAgreementId(Long.valueOf(relation.getAgreementId()));
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> scrapList = getScrapList(list);
List<SltAgreementInfo> loseList = getLoseList(list);
sltInfoVo.setLeaseList(leaseList);
sltInfoVo.setLeaseListOne(leaseListOne);
sltInfoVo.setLeaseListOne(leaseListThree);
sltInfoVo.setRepairList(repairList);
sltInfoVo.setScrapList(scrapList);
sltInfoVo.setLoseList(loseList);
@ -90,64 +95,146 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
apply.setAuditor(String.valueOf(userid));
int i = sltAgreementInfoMapper.updateRelation(apply);
int j = 0;
if (i > 0){
if (i > 0) {
List<SltAgreementRelation> relations = sltAgreementInfoMapper.getRelations(apply);
List<AgreementInfo> infos = new ArrayList<>();
for (SltAgreementRelation bean : relations){
for (SltAgreementRelation bean : relations) {
AgreementInfo info = new AgreementInfo();
info.setAgreementId(Long.valueOf(bean.getAgreementId()));
infos.add(info);
}
List<SltAgreementInfo> loseList = getLoseList(infos);
for (SltAgreementInfo agreementInfo : loseList){
if (agreementInfo.getMaId() != null && agreementInfo.getMaId().isEmpty()){
for (SltAgreementInfo agreementInfo : loseList) {
if (agreementInfo.getMaId() != null && agreementInfo.getMaId().isEmpty()) {
sltAgreementInfoMapper.updateMaStatus(agreementInfo);
}
}
j = sltAgreementInfoMapper.updateApply(apply);
}else {
} else {
throw new ServiceException("结算审核失败");
//throw new ServiceException(ExceptionDict.SETTLEMENT_REVIEW_ERROR_MSG,ExceptionDict.SETTLEMENT_REVIEW_ERROR);
}
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<>();
for (AgreementInfo info : list){
for (AgreementInfo info : list) {
SltAgreementRelation relation = new SltAgreementRelation();
/*BigDecimal loseCost = new BigDecimal("0");
BigDecimal leaseCost = new BigDecimal("0");
BigDecimal scrapCost = new BigDecimal("0");
BigDecimal repairCost = new BigDecimal("0");*/
BigDecimal loseCost = BigDecimal.ZERO;
BigDecimal leaseCost = BigDecimal.ZERO;
BigDecimal leaseCostOne = BigDecimal.ZERO;
BigDecimal leaseCostThree = BigDecimal.ZERO;
BigDecimal scrapCost = BigDecimal.ZERO;
BigDecimal repairCost = BigDecimal.ZERO;
for (SltAgreementInfo lease : leaseList){
if (lease.getAgreementId().equals(info.getAgreementId().toString())){
for (SltAgreementInfo lease : leaseListOne) {
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());
leaseCost = leaseCost.add(cost);
leaseCostOne = leaseCostOne.add(cost);
}
}
for (SltAgreementInfo repair : repairList){
if (repair.getAgreementId().equals(info.getAgreementId().toString())){
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) {
if (repair.getAgreementId().equals(info.getAgreementId().toString())) {
BigDecimal cost = new BigDecimal(repair.getCosts());
repairCost = repairCost.add(cost);
}
}
for (SltAgreementInfo scrap : scrapList){
if (scrap.getAgreementId().equals(info.getAgreementId().toString())){
for (SltAgreementInfo scrap : scrapList) {
if (scrap.getAgreementId().equals(info.getAgreementId().toString())) {
BigDecimal cost = new BigDecimal(scrap.getCosts());
scrapCost = scrapCost.add(cost);
}
}
for (SltAgreementInfo lose : loseList){
if (lose.getAgreementId().equals(info.getAgreementId().toString())){
for (SltAgreementInfo lose : loseList) {
if (lose.getAgreementId().equals(info.getAgreementId().toString())) {
//TODO 上面已经set过值这里为什么还要set值
relation.setAgreementId(lose.getAgreementId());
relation.setProjectName(lose.getProjectName());
@ -157,7 +244,8 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
loseCost = loseCost.add(cost);
}
}
relation.setLeaseCost(leaseCost.toString());
relation.setLeaseCostOne(leaseCostOne.toString());
relation.setLeaseCostThree(leaseCostThree.toString());
relation.setRepairCost(repairCost.toString());
relation.setScrapCost(scrapCost.toString());
relation.setLoseCost(loseCost.toString());
@ -177,24 +265,25 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
apply.setCode(code);
apply.setCompanyId(relations.get(0).getCompanyId());
int i = sltAgreementInfoMapper.insApply(apply);
if (i > 0){
for (SltAgreementRelation relation : relations){
if (i > 0) {
for (SltAgreementRelation relation : relations) {
AgreementInfo info = new AgreementInfo();
info.setAgreementId(Long.valueOf(relation.getAgreementId()));
list.add(info);
relation.setApplyId(String.valueOf(apply.getId()));
sltAgreementInfoMapper.updateInfoStatus(relation.getAgreementId());
int j = sltAgreementInfoMapper.insRelation(relation);
if (j < 0){
if (j < 0) {
throw new ServiceException("新增协议结算记录失败");
//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> scrapList = getScrapList(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()));
@ -202,7 +291,15 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
//info.setPartType(PartTypeEnum.CHARGE.getCode());
sltAgreementInfoMapper.insDetails(info);
}
for (SltAgreementInfo info : repairList){
for (SltAgreementInfo info : leaseListThree) {
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 : repairList) {
info.setSltType("3");
//info.setSltType(CostTypeEnum.MAINTENANCE_COST.getCode());
info.setApplyId(String.valueOf(apply.getId()));
@ -211,7 +308,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
info.setPartType(info.getPartType().equals("不收费") ? "0" : "1");
sltAgreementInfoMapper.insDetails(info);
}
for (SltAgreementInfo info : scrapList){
for (SltAgreementInfo info : scrapList) {
info.setSltType("4");
//info.setSltType(CostTypeEnum.SCRAP_COST.getCode());
info.setApplyId(String.valueOf(apply.getId()));
@ -220,16 +317,16 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
info.setPartType(info.getScrapType().equals("自然") ? "0" : "1");
sltAgreementInfoMapper.insDetails(info);
}
for (SltAgreementInfo info : loseList){
for (SltAgreementInfo info : loseList) {
info.setSltType("2");
//info.setSltType(CostTypeEnum.LOSE_COST.getCode());
info.setApplyId(String.valueOf(apply.getId()));
info.setPartType("1");
info.setPartType("1");
//info.setPartType(PartTypeEnum.CHARGE.getCode());
sltAgreementInfoMapper.insDetails(info);
}
}else {
} else {
throw new ServiceException("新增结算单号失败");
//throw new ServiceException(ExceptionDict.NEW_SETTLEMENT_NUMBER_ERROR_MSG,ExceptionDict.NEW_SETTLEMENT_NUMBER_ERROR);
}
@ -244,15 +341,15 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
public List<SltAgreementInfo> getLoseList(List<AgreementInfo> list) {
List<SltAgreementInfo> loseList = new ArrayList<>();
for (AgreementInfo bean : list){
for (AgreementInfo bean : list) {
List<SltAgreementInfo> oneOfList = sltAgreementInfoMapper.getLoseList(bean);
loseList.addAll(oneOfList);
}
for (SltAgreementInfo bean : loseList){
if (bean.getBuyPrice() == null){
for (SltAgreementInfo bean : loseList) {
if (bean.getBuyPrice() == null) {
bean.setBuyPrice("0");
}
if (bean.getNum() == null){
if (bean.getNum() == null) {
bean.setNum("0");
}
BigDecimal buyPrice = new BigDecimal(bean.getBuyPrice());
@ -274,20 +371,21 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
List<SltAgreementInfo> scrapList = new ArrayList<>();
String taskType = "57";
//String taskType = TaskTypeEnum.SCRAP_TASK.getCode();
for (AgreementInfo bean : list){
List<TmTask> taskList = sltAgreementInfoMapper.getTaskList(bean,taskType);
if (taskList != null && taskList.size() > 0){
for (AgreementInfo bean : list) {
List<TmTask> taskList = sltAgreementInfoMapper.getTaskList(bean, taskType);
if (taskList != null && taskList.size() > 0) {
List<SltAgreementInfo> scrapDetailsList = sltAgreementInfoMapper.getScrapDetailsList(taskList);
scrapList.addAll(scrapDetailsList);
}
}
if (scrapList != null && scrapList.size() > 0){
for (SltAgreementInfo bean : scrapList){
if (bean.getBuyPrice() == null){
if (scrapList != null && scrapList.size() > 0) {
for (SltAgreementInfo bean : scrapList) {
if (bean.getBuyPrice() == null) {
bean.setBuyPrice("0");
}
if (bean.getNum() == null){
if (bean.getNum() == null) {
bean.setNum("0");
}
BigDecimal buyPrice = new BigDecimal(bean.getBuyPrice());
@ -307,13 +405,26 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
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) {
List<SltAgreementInfo> repairList = new ArrayList<>();
String taskType = "41";
//String taskType = TaskTypeEnum.MAINTENANCE_TASK.getCode();
for (AgreementInfo bean : list){
List<TmTask> taskList = sltAgreementInfoMapper.getTaskList(bean,taskType);
if (taskList != null && taskList.size() > 0){
for (AgreementInfo bean : list) {
List<TmTask> taskList = sltAgreementInfoMapper.getTaskList(bean, taskType);
if (taskList != null && taskList.size() > 0) {
List<SltAgreementInfo> repairDetailsList = sltAgreementInfoMapper.getRepairDetailsList(taskList);
repairList.addAll(repairDetailsList);
}
@ -321,41 +432,44 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
return repairList;
}
public List<SltAgreementInfo> getLeaseList(List<AgreementInfo> list) {
public List<SltAgreementInfo> getLeaseListOne(List<AgreementInfo> list) {
List<SltAgreementInfo> leaseList = new ArrayList<>();
for (AgreementInfo bean : list){
List<SltAgreementInfo> oneOfList = sltAgreementInfoMapper.getLeaseList(bean);
for (AgreementInfo bean : list) {
List<SltAgreementInfo> oneOfList = sltAgreementInfoMapper.getLeaseListOne(bean);
leaseList.addAll(oneOfList);
}
for (SltAgreementInfo bean : leaseList){
if (bean.getLeasePrice() == null){
for (SltAgreementInfo bean : leaseList) {
if (bean.getLeasePrice() == null) {
bean.setLeasePrice("0");
}
if (bean.getNum() == null){
if (bean.getNum() == null) {
bean.setNum("0");
}
if (bean.getLeaseDays() == null){
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));
/* 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));*/
bean.setRealDays(realDays);
bean.setRealCosts(String.valueOf(realCosts));
}
return leaseList;
}
/**结算单号编码生成规则*/
/**
* 结算单号编码生成规则
*/
private String sltCodeRule(String code) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
Date nowDate = DateUtils.getNowDate();

View File

@ -585,7 +585,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ma_type mt
LEFT JOIN slt_agreement_info sai ON mt.type_id = sai.type_id
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
mt.type_id UNION ALL-- 递归情况:向上查找父级
SELECT

View File

@ -85,6 +85,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
set ma_status = '103'
where ma_id = #{maId}
</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 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,
@ -111,9 +119,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<when test="sltStatus == '3'.toString()">
and sar.status = '1'
</when>
<otherwise>
</otherwise>
</choose>
ORDER BY bai.agreement_id desc
</select>
@ -135,6 +140,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
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
@ -284,4 +290,56 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from slt_agreement_apply
where id = #{id}
</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>