Merge branch 'lc20240808'

This commit is contained in:
liang.chao 2024-08-15 14:32:57 +08:00
commit 4efbea7893
13 changed files with 114 additions and 62 deletions

View File

@ -59,7 +59,8 @@ public class SltAgreementApply {
*结算总费用
*/
private String cost;
private String repairIds;
private List<SltAgreementRelation> relations;
private SltAgreementRelation relation;
}

View File

@ -44,6 +44,10 @@ public class SltAgreementInfo {
*机具id
*/
private String maId;
/**
*配件单价
*/
private String partPrice;
/**
*领料数量
*/
@ -67,6 +71,10 @@ public class SltAgreementInfo {
*领料id
*/
private String leaseId;
/**
*配件数量
*/
private String partNum;
/**
*退料id
*/

View File

@ -47,6 +47,7 @@ public class SltAgreementRelation {
private String leaseCostOne;
private String leaseCostThree;
private String scrapCost;
private String preScrapCost;
private String repairCost;
private String isSltOne;
private String isSltThree;

View File

@ -119,6 +119,7 @@ public class RepairApplyRecord implements Serializable {
private List<RepairPartDetails> partList;
private String partStrList;
private Long companyId;
private Integer partId;
/**
* 损坏照片id
*/

View File

@ -161,4 +161,6 @@ public interface RepairMapper {
List<RepairTask> exportRepairTaskList(RepairTask bean);
int addRepairCost(@Param("bean") RepairApplyRecord bean, @Param("costs") BigDecimal costs,@Param("partType") String partType);
String selectPartPrice(Long partId);
}

View File

@ -8,11 +8,11 @@ import com.bonus.sgzb.base.domain.vo.DictVo;
import com.bonus.sgzb.base.mapper.RepairMapper;
import com.bonus.sgzb.base.service.RepairService;
import com.bonus.sgzb.common.core.exception.ServiceException;
import com.bonus.sgzb.common.core.utils.StringUtils;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.security.utils.SecurityUtils;
import com.bonus.sgzb.system.api.domain.SysUser;
import com.bonus.sgzb.system.api.model.LoginUser;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -58,8 +58,6 @@ public class RepairServiceImpl implements RepairService {
bean.setCreateBy(loginUser.getUserid());
List<RepairPartDetails> partList = bean.getPartList();
BigDecimal sfCosts = new BigDecimal("0");
BigDecimal bsfCosts = new BigDecimal("0");
Integer partNum = 0;
String nbType = "1";
String fcType = "2";
String sfPart = "1";
@ -103,6 +101,7 @@ public class RepairServiceImpl implements RepairService {
if (nbType.equals(bean.getRepairType())) {
for (RepairPartDetails partDetails : partList) {
if (partDetails.getPartId() != null) {
// 有维修配件时
if (partDetails.getPartCost() == null || partDetails.getPartCost().isEmpty()) {
partDetails.setPartCost("0");
}
@ -111,14 +110,21 @@ public class RepairServiceImpl implements RepairService {
partDetails.setTypeId(bean.getTypeId());
partDetails.setCreateBy(loginUser.getUserid());
partDetails.setCompanyId(bean.getCompanyId());
// 根据partid 找到配件单价
String partPrice = mapper.selectPartPrice(partDetails.getPartId());
partDetails.setPartCost(partPrice);
mapper.addPart(partDetails);
bean.setPartPrice(partDetails.getPartCost());
partNum += partDetails.getPartNum();
bean.setPartId(partDetails.getPartId().intValue());
bean.setPartNum(partDetails.getPartNum());
bean.setRepairContent(partDetails.getRepairContent());
bean.setPartType(partDetails.getPartType());
mapper.addRecord(bean);
} else {
// 不选维修配件时
mapper.addRecord(bean);
}
}
bean.setPartNum(partNum);
}
if (fcType.equals(bean.getRepairType())) {
bean.setPartName(partList.get(0).getPartName());
@ -129,40 +135,26 @@ public class RepairServiceImpl implements RepairService {
} else {
bean.setSupplierId(partList.get(0).getSupplierId());
}
if (bean.getPartPrice() == null || bean.getPartPrice().isEmpty()) {
if (partList.get(0).getPartPrice() == null || partList.get(0).getPartPrice().isEmpty()) {
bean.setPartPrice("0");
} else {
bean.setPartPrice(partList.get(0).getPartPrice());
}
bean.setPartNum(partList.get(0).getPartNum());
mapper.addRecord(bean);
}
for (RepairPartDetails partDetails : partList) {
if (sfPart.equals(partDetails.getPartType())) {
if (StringUtils.isBlank(partDetails.getPartCost())) {
partDetails.setPartCost("0");
}
if (StringUtils.isNotBlank(partDetails.getPartCost())) {
BigDecimal partCost = new BigDecimal(partDetails.getPartCost());
BigDecimal partNumber = new BigDecimal(partDetails.getPartNum());
sfCosts = sfCosts.add(partCost.multiply(partNumber));
} else if (bsfPart.equals(partDetails.getPartType())) {
if (StringUtils.isBlank(partDetails.getPartCost())) {
partDetails.setPartCost("0");
}
BigDecimal partCost = new BigDecimal(partDetails.getPartCost());
bsfCosts = bsfCosts.add(partCost);
} else {
throw new ServiceException("请选择配件收费类型");
}
}
if (!"0".equals(sfCosts.toString())) {
mapper.addRepairCost(bean, sfCosts, sfPart);
}
if (!"0".equals(bsfCosts.toString())) {
mapper.addRepairCost(bean, bsfCosts, bsfPart);
}
}
mapper.addRecord(bean);
return AjaxResult.success();
}

View File

@ -145,4 +145,8 @@ public interface RepairAuditDetailsMapper
List<RepairPart> getPartRecord(RepairAuditDetails bean);
int updateRepairCost(@Param("inputDetails")RepairAuditDetails inputDetails, @Param("status") String status);
List<String> getRepairApplyRecordId(Long repairId);
void updateRecodeStatus(String id);
}

View File

@ -70,4 +70,6 @@ public interface SltAgreementInfoMapper {
int updateOutSourceCosts(SltAgreementInfo sltAgreementInfo);
int updateBmAgreementInfo(@Param("agreementId") String agreementId);
int updateRecodeIsSlt(String id);
}

View File

@ -241,6 +241,12 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService
repairTestInputMapper.insertRepairInputDetails(repairInputDetails);
}
repairAuditDetailsMapper.updateRepairCost(inputDetails,status);
// 根据repairId找到taskId和 typeId maid
List<String> repairApplyRecordId = repairAuditDetailsMapper.getRepairApplyRecordId(inputDetails.getRepairId());
// 再去repair_apply_record 中查并给一个标识表示审核完成
for (String id : repairApplyRecordId) {
repairAuditDetailsMapper.updateRecodeStatus(id);
}
}
}
if (scrapNumList != null && scrapNumList.size() > 0) {

View File

@ -71,7 +71,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
sltInfoVo.setScrapList(scrapList);
sltInfoVo.setPreScrapList(preScrapList);
sltInfoVo.setLoseList(loseList);
List<SltAgreementRelation> relations = getRelations(leaseListOne, leaseListThree, repairList, scrapList, loseList, list);
List<SltAgreementRelation> relations = getRelations(leaseListOne, leaseListThree, repairList, scrapList, preScrapList, loseList, list);
sltInfoVo.setRelations(relations);
return sltInfoVo;
}
@ -237,7 +237,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
return leaseList;
}
private List<SltAgreementRelation> getRelations(List<SltAgreementInfo> leaseListOne, List<SltAgreementInfo> leaseListThree, List<SltAgreementInfo> repairList, List<SltAgreementInfo> scrapList, List<SltAgreementInfo> loseList, List<AgreementInfo> list) {
private List<SltAgreementRelation> getRelations(List<SltAgreementInfo> leaseListOne, List<SltAgreementInfo> leaseListThree, List<SltAgreementInfo> repairList, List<SltAgreementInfo> scrapList, List<SltAgreementInfo> preScrapList, List<SltAgreementInfo> loseList, List<AgreementInfo> list) {
List<SltAgreementRelation> relations = new ArrayList<>();
for (AgreementInfo info : list) {
SltAgreementRelation relation = new SltAgreementRelation();
@ -245,6 +245,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
BigDecimal leaseCostOne = BigDecimal.ZERO;
BigDecimal leaseCostThree = BigDecimal.ZERO;
BigDecimal scrapCost = BigDecimal.ZERO;
BigDecimal preScrapCost = BigDecimal.ZERO;
BigDecimal repairCost = BigDecimal.ZERO;
for (SltAgreementInfo lease : leaseListOne) {
if (lease.getAgreementId().equals(info.getAgreementId().toString())) {
@ -268,7 +269,8 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
}
for (SltAgreementInfo repair : repairList) {
if (repair.getAgreementId().equals(info.getAgreementId().toString())) {
BigDecimal allCost = new BigDecimal(repair.getAllCosts());
// 暂时先计算配件总价后期需要加上委外维修费用
BigDecimal allCost = new BigDecimal(repair.getPartAllCosts());
repairCost = repairCost.add(allCost);
}
}
@ -278,6 +280,12 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
scrapCost = scrapCost.add(cost);
}
}
for (SltAgreementInfo scrap : preScrapList) {
if (scrap.getAgreementId().equals(info.getAgreementId().toString())) {
BigDecimal cost = new BigDecimal(scrap.getCosts());
preScrapCost = preScrapCost.add(cost);
}
}
for (SltAgreementInfo lose : loseList) {
if (lose.getAgreementId().equals(info.getAgreementId().toString())) {
//TODO 上面已经set过值这里为什么还要set值
@ -307,6 +315,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
relation.setLeaseCostThree(leaseCostThree.toString());
relation.setRepairCost(repairCost.toString());
relation.setScrapCost(scrapCost.toString());
relation.setPreScrapCost(preScrapCost.toString());
relation.setLoseCost(loseCost.toString());
relations.add(relation);
}
@ -316,8 +325,16 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService {
@Override
@Transactional
public AjaxResult submitFee(SltAgreementApply apply) {
SltAgreementRelation relation = apply.getRelation();
if (StringUtils.isNotBlank(apply.getRepairIds())) {
for (String id : apply.getRepairIds().split(",")) {
sltAgreementInfoMapper.updateRecodeIsSlt(id);
}
}
sltAgreementInfoMapper.updateInfoStatus(apply.getAgreementId());
int i = sltAgreementInfoMapper.updateBmAgreementInfo(apply.getAgreementId());
sltAgreementInfoMapper.updateBmAgreementInfo(apply.getAgreementId());
relation.setAgreementId(apply.getAgreementId());
int i = sltAgreementInfoMapper.insRelation(relation);
if (i > 0) {
return AjaxResult.success("结算成功");
} else {

View File

@ -2,8 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.bonus.sgzb.base.mapper.RepairMapper">
<insert id="addRecord">
insert into repair_apply_record (task_id,ma_id,type_id,repair_num,scrap_num,repair_type,create_by,create_time,repair_content,company_id,scrap_reason,scrap_type,supplier_id,part_num,part_price,part_type,part_name,repairer,file_ids,remark)
values (#{taskId},#{maId},#{typeId},#{repairNum},#{scrapNum},#{repairType},#{createBy},now(),#{repairContent},#{companyId},#{scrapReason},#{scrapType},#{supplierId},#{partNum},#{partPrice},#{partType},#{partName},#{repairer},#{fileIds},#{remark});
insert into repair_apply_record (task_id,ma_id,type_id,repair_num,scrap_num,repair_type,create_by,create_time,repair_content,company_id,scrap_reason,scrap_type,supplier_id,part_num,part_price,part_type,part_name,repairer,file_ids,remark,part_id)
values (#{taskId},#{maId},#{typeId},#{repairNum},#{scrapNum},#{repairType},#{createBy},now(),#{repairContent},#{companyId},#{scrapReason},#{scrapType},#{supplierId},#{partNum},#{partPrice},#{partType},#{partName},#{repairer},#{fileIds},#{remark},#{partId});
</insert>
<insert id="addPart">
insert into repair_part_details (task_id,ma_id,type_id,part_id,part_num,part_cost,part_type,create_by,create_time,company_id,repair_content)
@ -272,6 +272,9 @@
from repair_apply_details
where task_id = #{taskId}
</select>
<select id="selectPartPrice" resultType="java.lang.String">
select ifnull(buy_price,0) from ma_part_type where pa_id = #{partId}
</select>
</mapper>

View File

@ -223,6 +223,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
set part_type = #{status}
where repair_id = #{inputDetails.repairId}
</update>
<update id="updateRecodeStatus">
update repair_apply_record set status = 1 where id = #{id}
</update>
<delete id="deleteRepairAuditDetailsById" parameterType="Long">
delete from repair_audit_details where id = #{id}
@ -451,5 +454,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from repair_apply_details
where id = #{repairId}
</select>
<select id="getRepairApplyRecordId" resultType="java.lang.String">
SELECT DISTINCT
rar.id
FROM
repair_apply_record rar
LEFT JOIN repair_cost rc ON rar.task_id = rc.task_id
AND rar.type_id = rc.type_id
AND ( rar.ma_id = rc.ma_id OR rar.ma_id IS NULL )
WHERE
rc.repair_id = #{repairId}
</select>
</mapper>

View File

@ -31,8 +31,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
values (#{code},#{creator},now(),'0',#{companyId},#{cost});
</insert>
<insert id="insRelation">
insert into slt_agreement_relation (apply_id,agreement_id,add_cost,sub_cost,remark,cost,status,lease_cost,repair_cost,scrap_cost,lose_cost)
values (#{applyId},#{agreementId},#{addCost},#{subCost},#{remark},#{cost},'0',#{leaseCost},#{repairCost},#{scrapCost},#{loseCost});
insert into slt_agreement_relation (apply_id,agreement_id,add_cost,sub_cost,remark,cost,status,lease_one_cost,lease_three_cost,repair_cost,scrap_cost,lose_cost)
values (#{applyId},#{agreementId},#{addCost},#{subCost},#{remark},#{cost},'0',#{leaseCostOne},#{leaseCostThree},#{repairCost},#{scrapCost},#{loseCost});
</insert>
<insert id="insDetails">
insert into slt_agreement_details
@ -112,6 +112,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateBmAgreementInfo">
update bm_agreement_info set is_slt = 1 where agreement_id = #{agreementId}
</update>
<update id="updateRecodeIsSlt">
update repair_apply_record set is_slt = 1 where id = #{id}
</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,
@ -192,38 +195,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where tta.agreement_id = #{bean.agreementId} and tt.task_type = #{taskType}
</select>
<select id="getRepairDetailsList" resultType="com.bonus.sgzb.base.api.domain.SltAgreementInfo">
select tta.agreement_id as agreementId,
bui.unit_name as unitName,
bp.lot_name as projectName,
rc.type_id as typeId,
rc.id,
rc.ma_id as maId,
mt1.type_name as typeName,
mt.type_name as modelName,
mt.unit_name as nuitName,
rc.repair_num as num,
rc.costs as costs,
rc.out_source_costs as outSourceCosts,
rc.costs AS partAllCosts,
ROUND(rc.costs + IFNULL(rc.out_source_costs ,0), 2) AS allCosts,
mpt.pa_name partModelName,
mpt2.pa_name partName,
case rc.part_type when '0' then '不收费' when '1' then '收费' else '' end as partType,
rc.status as repairStatus,
rc.company_id as companyId
from repair_cost rc
left join tm_task_agreement tta on rc.task_id = tta.task_id
LEFT JOIN repair_part_details rpd on rc.task_id = rpd.task_id and rc.type_id = rpd.type_id and (rc.ma_id = rpd.ma_id OR rpd.ma_id IS NULL)
LEFT JOIN ma_part_type mpt on rpd.part_id = mpt.pa_id
LEFT JOIN ma_part_type mpt2 on mpt.parent_id = mpt2.pa_id
LEFT JOIN bm_agreement_info bai on tta.agreement_id = bai.agreement_id
SELECT
rar.id,
rar.is_slt AS isSlt,
tta.agreement_id AS agreementId,
bui.unit_name AS unitName,
bp.lot_name AS projectName,
rar.type_id AS typeId,
rar.ma_id AS maId,
mt1.type_name AS typeName,
mt.type_name AS modelName,
mt.unit_name AS nuitName,
rar.repair_num AS num,
rar.part_num AS partNum,
rar.part_price AS partPrice,
rar.part_num * rar.part_price AS partAllCosts,
mpt.pa_name partModelName,
mpt2.pa_name partName
FROM
repair_apply_record rar
LEFT JOIN tm_task_agreement tta ON rar.task_id = tta.task_id
LEFT JOIN bm_agreement_info bai ON tta.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 rc.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id
where rc.status in ('0','1')
LEFT JOIN ma_type mt ON rar.type_id = mt.type_id
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
LEFT JOIN ma_part_type mpt ON rar.part_id = mpt.pa_id
LEFT JOIN ma_part_type mpt2 ON mpt.parent_id = mpt2.pa_id
where rar.repair_type in (1,2) and rar.part_num != 0 and rar.status = 1
<if test="taskList != null and taskList.size() > 0">
and rc.task_id in
and rar.task_id in
<foreach item="task" collection="taskList" open="(" separator="," close=")">
#{task.taskId}
</foreach>