结算代码提交

This commit is contained in:
1539530615@qq.com 2024-02-23 11:13:41 +08:00
parent bd05a25423
commit 7bbad756b1
18 changed files with 431 additions and 2 deletions

View File

@ -75,6 +75,7 @@ public class MaType extends BaseEntity {
@ApiModelProperty(value = "外部价格") @ApiModelProperty(value = "外部价格")
private String rentPrice; private String rentPrice;
private String finalPrice;
/** 原价 */ /** 原价 */
@ApiModelProperty(value = "原价") @ApiModelProperty(value = "原价")
@ -190,6 +191,7 @@ public class MaType extends BaseEntity {
private List<MaType> children = new ArrayList<>(); private List<MaType> children = new ArrayList<>();
public Long getTypeId() { public Long getTypeId() {
return typeId; return typeId;
} }
@ -527,4 +529,12 @@ public class MaType extends BaseEntity {
public void setCode(String code) { public void setCode(String code) {
this.code = code; this.code = code;
} }
public String getFinalPrice() {
return finalPrice;
}
public void setFinalPrice(String finalPrice) {
this.finalPrice = finalPrice;
}
} }

View File

@ -0,0 +1,64 @@
package com.bonus.sgzb.base.api.domain;
import lombok.Data;
/**
* @author c liu
* @date 2024/2/21
*/
@Data
public class SltAgreementInfo {
/**
*
*/
private Long id;
/**
*协议id
*/
private String agreementId;
/**
*机具规格id
*/
private String typeId;
/**
*机具id
*/
private String maId;
/**
*领料数量
*/
private String num;
/**
*领料时间
*/
private String startTime;
/**
*退料时间
*/
private String endTime;
/**
*0在用1退回
*/
private String status;
/**
*领料id
*/
private String leaseId;
/**
*退料id
*/
private String backId;
/**
*租赁单价
*/
private String leasePrice;
/**
*原值
*/
private String buyPrice;
/**
*
*/
private String companyId;
}

View File

@ -77,6 +77,18 @@ public class LeaseOutDetailsController extends BaseController {
return leaseOutDetailsService.submitOut(record); return leaseOutDetailsService.submitOut(record);
} }
/**
*
* @param recordList
* @return
*/
@Log(title = "领料出库", businessType = BusinessType.UPDATE)
@PostMapping("/submitOutRfid")
public AjaxResult submitOutRfid(@RequestBody List<LeaseOutDetails> recordList){
return leaseOutDetailsService.submitOutRfid(recordList);
}
/** /**
* 综合查询--领用记录查询 * 综合查询--领用记录查询

View File

@ -1,6 +1,7 @@
package com.bonus.sgzb.app.mapper; package com.bonus.sgzb.app.mapper;
import com.bonus.sgzb.app.domain.BackApplyInfo; import com.bonus.sgzb.app.domain.BackApplyInfo;
import com.bonus.sgzb.base.api.domain.SltAgreementInfo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -174,4 +175,12 @@ public interface BackReceiveMapper {
* @return List<BackApplyInfo> * @return List<BackApplyInfo>
*/ */
List<BackApplyInfo> rfidCodeQuery(BackApplyInfo record); List<BackApplyInfo> rfidCodeQuery(BackApplyInfo record);
List<SltAgreementInfo> getStlInfo(BackApplyInfo bean);
int updateStlInfo(@Param("info") SltAgreementInfo info,@Param("record") BackApplyInfo record);
int updateStlInfoTwo(@Param("info") SltAgreementInfo info,@Param("record") BackApplyInfo record, @Param("backNum") Double backNum);
int insStlInfoTwo(@Param("info")SltAgreementInfo info, @Param("many")Double many);
} }

View File

@ -1,6 +1,7 @@
package com.bonus.sgzb.app.mapper; package com.bonus.sgzb.app.mapper;
import com.bonus.sgzb.app.domain.LeaseApplyDetails; import com.bonus.sgzb.app.domain.LeaseApplyDetails;
import com.bonus.sgzb.app.domain.LeaseApplyInfo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -45,4 +46,5 @@ public interface LeaseApplyDetailsMapper {
int batchInsert(@Param("list") List<LeaseApplyDetails> list); int batchInsert(@Param("list") List<LeaseApplyDetails> list);
List<LeaseApplyDetails> getByParentId(Integer parentId); List<LeaseApplyDetails> getByParentId(Integer parentId);
} }

View File

@ -3,6 +3,8 @@ package com.bonus.sgzb.app.mapper;
import com.bonus.sgzb.app.domain.LeaseApplyDetails; import com.bonus.sgzb.app.domain.LeaseApplyDetails;
import com.bonus.sgzb.app.domain.TmTask; import com.bonus.sgzb.app.domain.TmTask;
import com.bonus.sgzb.base.api.domain.LeaseOutDetails; import com.bonus.sgzb.base.api.domain.LeaseOutDetails;
import com.bonus.sgzb.base.api.domain.MaType;
import com.bonus.sgzb.base.api.domain.SltAgreementInfo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -67,4 +69,16 @@ public interface LeaseOutDetailsMapper {
* @return List<LeaseApplyDetails> * @return List<LeaseApplyDetails>
*/ */
List<LeaseApplyDetails> proUseRecord(LeaseApplyDetails bean); List<LeaseApplyDetails> proUseRecord(LeaseApplyDetails bean);
String getAgreementId(String taskId);
MaType getMaType(Integer typeId);
String getProtocol(String agreementId);
int insSltInfo(@Param("record") LeaseOutDetails record, @Param("agreementId")String agreementId,@Param("ma") MaType ma);
SltAgreementInfo getSltAgreementInfo(LeaseOutDetails record);
int updSltInfo(SltAgreementInfo sltAgreementInfo);
} }

View File

@ -63,4 +63,6 @@ public interface LeaseOutDetailsService {
* @return List<LeaseApplyDetails> * @return List<LeaseApplyDetails>
*/ */
List<LeaseApplyDetails> proUseRecord(LeaseApplyDetails bean); List<LeaseApplyDetails> proUseRecord(LeaseApplyDetails bean);
AjaxResult submitOutRfid(List<LeaseOutDetails> recordList);
} }

View File

@ -3,6 +3,7 @@ package com.bonus.sgzb.app.service.impl;
import com.bonus.sgzb.app.domain.BackApplyInfo; import com.bonus.sgzb.app.domain.BackApplyInfo;
import com.bonus.sgzb.app.mapper.BackReceiveMapper; import com.bonus.sgzb.app.mapper.BackReceiveMapper;
import com.bonus.sgzb.app.service.BackReceiveService; import com.bonus.sgzb.app.service.BackReceiveService;
import com.bonus.sgzb.base.api.domain.SltAgreementInfo;
import com.bonus.sgzb.common.core.utils.DateUtils; import com.bonus.sgzb.common.core.utils.DateUtils;
import com.bonus.sgzb.common.core.utils.GlobalConstants; import com.bonus.sgzb.common.core.utils.GlobalConstants;
import com.bonus.sgzb.common.core.utils.StringHelper; import com.bonus.sgzb.common.core.utils.StringHelper;
@ -126,6 +127,10 @@ public class BackReceiveServiceImpl implements BackReceiveService {
if(res == 0) { if(res == 0) {
throw new RuntimeException("ma_machines"); throw new RuntimeException("ma_machines");
} }
res = updateSlt(record,hgList);
if(res == 0) {
throw new RuntimeException("slt_agreement_info");
}
} }
//维修的创建维修任务插入任务协议表 //维修的创建维修任务插入任务协议表
List<BackApplyInfo> wxList = backReceiveMapper.getWxList(record); List<BackApplyInfo> wxList = backReceiveMapper.getWxList(record);
@ -154,6 +159,33 @@ public class BackReceiveServiceImpl implements BackReceiveService {
return res; return res;
} }
private int updateSlt(BackApplyInfo record, List<BackApplyInfo> hgList) {
for (BackApplyInfo bean : hgList){
List<SltAgreementInfo> infoList = backReceiveMapper.getStlInfo(bean);
if (infoList.size() > 0){
Double backNum = Double.valueOf(bean.getBackNum());
for (SltAgreementInfo info : infoList){
Double num = Double.valueOf(info.getNum());
if (backNum.equals(num)){
backReceiveMapper.updateStlInfo(info,record);
break;
} else if (backNum > num) {
backNum = backNum - num;
backReceiveMapper.updateStlInfo(info,record);
} else if (backNum < num) {
Double many = num - backNum;
backReceiveMapper.updateStlInfoTwo(info,record,backNum);
backReceiveMapper.insStlInfoTwo(info,many);
break;
}
}
}else {
return 0;
}
}
return 1;
}
@Override @Override
public List<BackApplyInfo> codeQuery(BackApplyInfo record) { public List<BackApplyInfo> codeQuery(BackApplyInfo record) {
return backReceiveMapper.codeQuery(record); return backReceiveMapper.codeQuery(record);

View File

@ -1,15 +1,19 @@
package com.bonus.sgzb.app.service.impl; package com.bonus.sgzb.app.service.impl;
import com.bonus.sgzb.app.domain.LeaseApplyDetails; import com.bonus.sgzb.app.domain.LeaseApplyDetails;
import com.bonus.sgzb.app.domain.LeaseApplyInfo;
import com.bonus.sgzb.app.mapper.LeaseApplyDetailsMapper; import com.bonus.sgzb.app.mapper.LeaseApplyDetailsMapper;
import com.bonus.sgzb.app.mapper.LeaseOutDetailsMapper; import com.bonus.sgzb.app.mapper.LeaseOutDetailsMapper;
import com.bonus.sgzb.app.service.LeaseOutDetailsService; import com.bonus.sgzb.app.service.LeaseOutDetailsService;
import com.bonus.sgzb.base.api.domain.LeaseOutDetails; import com.bonus.sgzb.base.api.domain.LeaseOutDetails;
import com.bonus.sgzb.base.api.domain.MaMachine; import com.bonus.sgzb.base.api.domain.MaMachine;
import com.bonus.sgzb.base.api.domain.MaType;
import com.bonus.sgzb.base.api.domain.SltAgreementInfo;
import com.bonus.sgzb.base.mapper.MaMachineMapper; import com.bonus.sgzb.base.mapper.MaMachineMapper;
import com.bonus.sgzb.common.core.utils.StringUtils; import com.bonus.sgzb.common.core.utils.StringUtils;
import com.bonus.sgzb.common.core.web.domain.AjaxResult; import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
@ -44,6 +48,18 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
return leaseOutDetailsMapper.selectListByParentId(parentId); return leaseOutDetailsMapper.selectListByParentId(parentId);
} }
@Override
@Transactional
public AjaxResult submitOutRfid(List<LeaseOutDetails> recordList) {
for (LeaseOutDetails bean : recordList){
AjaxResult ajaxResult = submitOut(bean);
if (ajaxResult.isError()){
return ajaxResult;
}
}
return AjaxResult.success();
}
/** /**
* 领料出库处理 * 领料出库处理
* *
@ -51,6 +67,7 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
* @return 结果 * @return 结果
*/ */
@Override @Override
@Transactional
public AjaxResult submitOut(LeaseOutDetails record) { public AjaxResult submitOut(LeaseOutDetails record) {
String maStatus = "15"; String maStatus = "15";
double outNum = 0.1; double outNum = 0.1;
@ -96,7 +113,13 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
} else { } else {
leaseOutDetailsMapper.updateTaskStatus(taskId, 34); leaseOutDetailsMapper.updateTaskStatus(taskId, 34);
} }
int j = insSltInfo(taskId, record);
if (j > 0){
return AjaxResult.success("领料出库成功!"); return AjaxResult.success("领料出库成功!");
}else {
return AjaxResult.error("出库失败,更新设备规格库存数量时出错!");
}
// } // }
// return AjaxResult.error("领料出库失败,插入任务协议信息错误!"); // return AjaxResult.error("领料出库失败,插入任务协议信息错误!");
// } // }
@ -109,6 +132,32 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
return AjaxResult.error("出库操作失败,更新领料数量及状态时出错!"); return AjaxResult.error("出库操作失败,更新领料数量及状态时出错!");
} }
public int insSltInfo(String taskId,LeaseOutDetails record){
SltAgreementInfo sltAgreementInfo = leaseOutDetailsMapper.getSltAgreementInfo(record);
if (sltAgreementInfo != null){
double num = Double.parseDouble(sltAgreementInfo.getNum());
double outNum = record.getOutNum();
sltAgreementInfo.setNum(String.valueOf(num + outNum));
return leaseOutDetailsMapper.updSltInfo(sltAgreementInfo);
}else {
String agreementId = leaseOutDetailsMapper.getAgreementId(taskId);
String protocol = leaseOutDetailsMapper.getProtocol(agreementId);
MaType ma = leaseOutDetailsMapper.getMaType(record.getTypeId());
if (protocol.isEmpty()){
ma.setFinalPrice(ma.getLeasePrice());
}else {
if (protocol.equals("1")){
ma.setFinalPrice(ma.getLeasePrice());
}else if (protocol.equals("2")){
ma.setFinalPrice(ma.getRentPrice());
}else {
ma.setFinalPrice(ma.getLeasePrice());
}
}
return leaseOutDetailsMapper.insSltInfo(record, agreementId, ma);
}
}
/** /**
* @param maCode 编码ID * @param maCode 编码ID
* @return 数据 * @return 数据
@ -134,6 +183,8 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService {
return leaseOutDetailsMapper.proUseRecord(bean); return leaseOutDetailsMapper.proUseRecord(bean);
} }
@Override @Override
public List<MaMachine> getMaMachineByRfidCode(String rfidCode) { public List<MaMachine> getMaMachineByRfidCode(String rfidCode) {
return maMachineMapper.getMaMachineByRfidCode(rfidCode); return maMachineMapper.getMaMachineByRfidCode(rfidCode);

View File

@ -541,6 +541,10 @@
NOW() NOW()
) )
</insert> </insert>
<insert id="insStlInfoTwo">
insert into slt_agreement_info (agreement_id,type_id,ma_id,num,start_time,status,lease_id,lease_price,buy_price,company_id)
values (#{info.agreementId},#{info.typeId},#{info.maId},#{many},#{info.startTime},#{info.status},#{info.leaseId},#{info.leasePrice},#{info.buyPrice},#{info.companyId});
</insert>
<update id="updateTaskStatus"> <update id="updateTaskStatus">
@ -559,6 +563,21 @@
SET num = (IFNULL(num, 0)) + #{backNum} SET num = (IFNULL(num, 0)) + #{backNum}
WHERE type_id = #{typeId} WHERE type_id = #{typeId}
</update> </update>
<update id="updateStlInfo">
update slt_agreement_info
set end_time = now(),
back_id = #{record.parentId},
status = '1'
where id = #{info.id}
</update>
<update id="updateStlInfoTwo">
update slt_agreement_info
set num = #{backNum},
end_time = now(),
back_id = #{record.parentId},
status = '1'
where id = #{info.id}
</update>
<select id="getbackReceiveList" resultType="com.bonus.sgzb.app.domain.BackApplyInfo"> <select id="getbackReceiveList" resultType="com.bonus.sgzb.app.domain.BackApplyInfo">
SELECT SELECT
@ -770,6 +789,32 @@
WHERE WHERE
rfid_code =#{rfidCode} rfid_code =#{rfidCode}
</select> </select>
<select id="getStlInfo" resultType="com.bonus.sgzb.base.api.domain.SltAgreementInfo">
SELECT
id,
agreement_id AS agreementId,
type_id AS typeId,
ma_id AS maId,
num AS num,
start_time AS startTime,
end_time AS endTime,
status AS status,
lease_id AS leaseId,
back_id AS backId,
lease_price AS leasePrice,
buy_price AS buyPrice,
company_id AS companyId
FROM
slt_agreement_info
WHERE
agreement_id = #{agreementId}
AND
type_id = #{typeId}
<if test="maId != null">
AND ma_id = #{maId}
</if>
order by start_time asc
</select>
</mapper> </mapper>

View File

@ -129,6 +129,51 @@
AND t1.type_id = t2.type_id AND t1.type_id = t2.type_id
</select> </select>
<select id="getAgreementId" resultType="java.lang.String">
select agreement_id
from tm_task_agreement
where task_id = #{taskId}
</select>
<select id="getMaType" resultType="com.bonus.sgzb.base.api.domain.MaType">
select lease_price as leasePrice,
rent_price as rentPrice,
buy_price as buyPrice,
pay_price as payPrice,
company_id as companyId
from ma_type
where type_id = #{typeId} and del_flag = 0
</select>
<select id="getProtocol" resultType="java.lang.String">
select protocol
from bm_agreement_info
where agreement_id = #{agreementId}
</select>
<select id="getSltAgreementInfo" resultType="com.bonus.sgzb.base.api.domain.SltAgreementInfo">
SELECT
id,
agreement_id AS agreementId,
type_id AS typeId,
ma_id AS maId,
num AS num,
start_time AS startTime,
end_time AS endTime,
status AS status,
lease_id AS leaseId,
back_id AS backId,
lease_price AS leasePrice,
buy_price AS buyPrice,
company_id AS companyId
FROM
slt_agreement_info
WHERE
lease_id = #{parentId}
AND
type_id = #{typeId}
AND
ma_id IS NULL
AND
DATE(start_time) = CURDATE();
</select>
<update id="updateLeaseApplyDetailsOutNum"> <update id="updateLeaseApplyDetailsOutNum">
UPDATE UPDATE
@ -247,6 +292,11 @@
set task_status = #{status} set task_status = #{status}
where task_id = #{taskId} where task_id = #{taskId}
</update> </update>
<update id="updSltInfo">
update slt_agreement_info
set num = #{num}
where id = #{id}
</update>
<insert id="insertAgreementInfo"> <insert id="insertAgreementInfo">
insert into tm_task_agreement insert into tm_task_agreement
@ -293,4 +343,8 @@
now() now()
</trim> </trim>
</insert> </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,company_id)
values (#{agreementId},#{record.typeId},#{record.maId},#{record.outNum},now(),0,#{record.parentId},#{ma.finalPrice},#{ma.buyPrice},#{record.companyId});
</insert>
</mapper> </mapper>

View File

@ -0,0 +1,37 @@
package com.bonus.sgzb.material.controller;
import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.page.TableDataInfo;
import com.bonus.sgzb.material.domain.AgreementInfo;
import com.bonus.sgzb.material.service.SltAgreementInfoService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author c liu
* @date 2024/2/22
*/
@RestController
@RequestMapping("/sltAgreementInfo")
public class SltAgreementInfoController extends BaseController {
@Autowired
private SltAgreementInfoService service;
/**
* 根据条件获取协议结算列表
*/
@ApiOperation(value = "根据条件获取协议结算列表")
@GetMapping("/getSltAgreementInfo")
public TableDataInfo getSltAgreementInfo(AgreementInfo bean)
{
startPage();
List<AgreementInfo> list = service.getSltAgreementInfo(bean);
return getDataTable(list);
}
}

View File

@ -95,4 +95,8 @@ public class AgreementInfo extends BaseEntity {
@Excel(name = "协议类型") @Excel(name = "协议类型")
@ApiModelProperty(value = "协议类型(1内部单位 2外部单位)") @ApiModelProperty(value = "协议类型(1内部单位 2外部单位)")
private Integer protocol; private Integer protocol;
@ApiModelProperty(value = "结算总费用")
private String cost;
@ApiModelProperty(value = "结算状态")
private String sltStatus;
} }

View File

@ -0,0 +1,15 @@
package com.bonus.sgzb.material.mapper;
import com.bonus.sgzb.material.domain.AgreementInfo;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @author c liu
* @date 2024/2/22
*/
@Mapper
public interface SltAgreementInfoMapper {
List<AgreementInfo> getSltAgreementInfo(AgreementInfo bean);
}

View File

@ -0,0 +1,14 @@
package com.bonus.sgzb.material.service;
import com.bonus.sgzb.material.domain.AgreementInfo;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author c liu
* @date 2024/2/22
*/
public interface SltAgreementInfoService {
List<AgreementInfo> getSltAgreementInfo(AgreementInfo bean);
}

View File

@ -0,0 +1,24 @@
package com.bonus.sgzb.material.service.impl;
import com.bonus.sgzb.material.domain.AgreementInfo;
import com.bonus.sgzb.material.mapper.SltAgreementInfoMapper;
import com.bonus.sgzb.material.service.SltAgreementInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author c liu
* @date 2024/2/22
*/
@Service
public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
@Autowired
private SltAgreementInfoMapper mapper;
@Override
public List<AgreementInfo> getSltAgreementInfo(AgreementInfo bean) {
return mapper.getSltAgreementInfo(bean);
}
}

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.sgzb.material.mapper.SltAgreementInfoMapper">
<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,
plan_start_time,lease_day,auth_person,phone,bai.remark,bai.protocol,saa.cost as cost
FROM bm_agreement_info bai
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 slt_agreement_apply saa on bai.agreement_id = saa.agreement_id
where bai.status = '1'
<if test="unitId != null and unitId != ''">
and bui.unit_id = #{unitId}
</if>
<if test="projectId != null and projectId != ''">
and bp.lot_id = #{projectId}
</if>
<if test="sltStatus != null and sltStatus != ''">
<choose>
<when test="sltStatus == '1'">
and saa.id is null
</when>
<when test="sltStatus == '2'">
and saa.status = '0'
</when>
<when test="sltStatus == '3'">
and saa.status = '1'
</when>
<otherwise>
</otherwise>
</choose>
</if>
ORDER BY bai.agreement_id asc
</select>
</mapper>