现场维修

This commit is contained in:
mashuai 2025-10-30 18:36:33 +08:00
parent 28ea7cc40e
commit 824c23e86f
11 changed files with 483 additions and 105 deletions

View File

@ -282,4 +282,12 @@ public class MaterialRetainedEquipmentInfo {
@ApiModelProperty(value = "租赁费用(万元)")
private BigDecimal rentPrice;
@ApiModelProperty(value = "项目部集合")
private List<String> departIdList;
/**
* 是否过滤true 过滤默认过滤
*/
private Boolean enableFilter = true;
}

View File

@ -334,4 +334,11 @@ public interface MaterialMachineMapper {
* @return
*/
List<MaterialRetainedEquipmentInfo> getLeaseInfo(MaterialRetainedEquipmentInfo bean);
/**
* 获取分包商的数据
* @param bean
* @return
*/
List<MaterialProvideNumInfo> getSubNumList(MaterialRetainedEquipmentInfo bean);
}

View File

@ -1096,22 +1096,24 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
*/
@Override
public List<MaterialRetainedEquipmentInfo> getImpUnitNameList(MaterialRetainedEquipmentInfo bean) {
String username = SecurityUtils.getLoginUser().getUsername();
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
// 检查用户是否具有特殊角色
boolean hasSpecialRole = hasSpecialRole(userRoles);
if (!hasSpecialRole) {
// 根据用户名查询项目部信息
List<String> departId = mapper.getDepartId(username);
// 根据项目部id查询工程信息
if (!CollectionUtils.isEmpty(departId)) {
List<String> projectIdList = mapper.getProjectId(departId);
if (!CollectionUtils.isEmpty(projectIdList)) {
bean.setProjectIdList(projectIdList);
if (bean != null && bean.getEnableFilter()) {
String username = SecurityUtils.getLoginUser().getUsername();
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
// 检查用户是否具有特殊角色
boolean hasSpecialRole = hasSpecialRole(userRoles);
if (!hasSpecialRole) {
// 根据用户名查询项目部信息
List<String> departId = mapper.getDepartId(username);
// 根据项目部id查询工程信息
if (!CollectionUtils.isEmpty(departId)) {
List<String> projectIdList = mapper.getProjectId(departId);
if (!CollectionUtils.isEmpty(projectIdList)) {
bean.setProjectIdList(projectIdList);
}
}
// 部门查询赋值
extractedDept(bean);
}
// 部门查询赋值
extractedDept(bean);
}
return materialMachineMapper.getImpUnitNameList(bean);
}
@ -1123,22 +1125,25 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
*/
@Override
public List<MaterialRetainedEquipmentInfo> getDepartNameList(MaterialRetainedEquipmentInfo bean) {
String username = SecurityUtils.getLoginUser().getUsername();
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
// 检查用户是否具有特殊角色
boolean hasSpecialRole = hasSpecialRole(userRoles);
if (!hasSpecialRole) {
// 根据用户名查询项目部信息
List<String> departId = mapper.getDepartId(username);
// 根据项目部id查询工程信息
if (!CollectionUtils.isEmpty(departId)) {
List<String> projectIdList = mapper.getProjectId(departId);
if (!CollectionUtils.isEmpty(projectIdList)) {
bean.setProjectIdList(projectIdList);
if (bean != null && bean.getEnableFilter()) {
String username = SecurityUtils.getLoginUser().getUsername();
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
// 检查用户是否具有特殊角色
boolean hasSpecialRole = hasSpecialRole(userRoles);
if (!hasSpecialRole) {
// 根据用户名查询项目部信息
List<String> departId = mapper.getDepartId(username);
// 根据项目部id查询工程信息
if (!CollectionUtils.isEmpty(departId)) {
bean.setDepartIdList(departId);
List<String> projectIdList = mapper.getProjectId(departId);
if (!CollectionUtils.isEmpty(projectIdList)) {
bean.setProjectIdList(projectIdList);
}
}
// 部门查询赋值
extractedDept(bean);
}
// 部门查询赋值
extractedDept(bean);
}
return materialMachineMapper.getDepartNameList(bean);
}
@ -1154,18 +1159,20 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
Set<String> userRoles = SecurityUtils.getLoginUser().getRoles();
// 检查用户是否具有特殊角色
boolean hasSpecialRole = hasSpecialRole(userRoles);
if (!hasSpecialRole) {
// 根据用户名查询项目部信息
List<String> departId = mapper.getDepartId(username);
// 根据项目部id查询工程信息
if (!CollectionUtils.isEmpty(departId)) {
List<String> projectIdList = mapper.getProjectId(departId);
if (!CollectionUtils.isEmpty(projectIdList)) {
bean.setProjectIdList(projectIdList);
if (bean != null && bean.getEnableFilter()) {
if (!hasSpecialRole) {
// 根据用户名查询项目部信息
List<String> departId = mapper.getDepartId(username);
// 根据项目部id查询工程信息
if (!CollectionUtils.isEmpty(departId)) {
List<String> projectIdList = mapper.getProjectId(departId);
if (!CollectionUtils.isEmpty(projectIdList)) {
bean.setProjectIdList(projectIdList);
}
}
// 部门查询赋值
extractedDept(bean);
}
// 部门查询赋值
extractedDept(bean);
}
List<MaterialRetainedEquipmentInfo> list = materialMachineMapper.getProjectList(bean);
if (list.size()>0){
@ -1184,13 +1191,15 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
iterator.remove();
continue;
}
// 根据工程去机具协议表查询关联协议数据
List<MaterialRetainedEquipmentInfo> agreementIdList = mapper.getAgreementId(info.getProId());
// 根据工程去材料站协议表查询关联协议数据
List<MaterialRetainedEquipmentInfo> storageAgreementIdList = mapper.getStorageAgreementId(info.getProId());
// 如果获取的协议数据为空则移除该行数据
if (CollectionUtils.isEmpty(agreementIdList) && CollectionUtils.isEmpty(storageAgreementIdList)) {
iterator.remove();
if (bean != null && bean.getEnableFilter()) {
// 根据工程去机具协议表查询关联协议数据
List<MaterialRetainedEquipmentInfo> agreementIdList = mapper.getAgreementId(info.getProId());
// 根据工程去材料站协议表查询关联协议数据
List<MaterialRetainedEquipmentInfo> storageAgreementIdList = mapper.getStorageAgreementId(info.getProId());
// 如果获取的协议数据为空则移除该行数据
if (CollectionUtils.isEmpty(agreementIdList) && CollectionUtils.isEmpty(storageAgreementIdList)) {
iterator.remove();
}
}
}
}
@ -1453,10 +1462,40 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
extractedDept(bean);
}
List<MaterialProvideNumInfo> recordList = materialMachineMapper.getDemandAndSupply(bean);
if (CollectionUtils.isEmpty(recordList)) {
// 获取施工队及分包数据
List<MaterialProvideNumInfo> subList = materialMachineMapper.getSubNumList(bean);
// 若任一列表为空直接返回无需处理
if (CollectionUtils.isEmpty(recordList) || CollectionUtils.isEmpty(subList)) {
return recordList;
}
// 构建 recordList 的索引Mapkey为(typeId, proId)的组合键value为对应的record对象
Map<String, MaterialProvideNumInfo> recordMap = new HashMap<>(recordList.size());
for (MaterialProvideNumInfo record : recordList) {
// 用下划线拼接typeId和proId作为唯一key避免自定义对象作为key的复杂度
String key = record.getTypeId() + "_" + record.getProId();
recordMap.put(key, record);
}
// 遍历subList通过Map快速匹配并合并数据
for (MaterialProvideNumInfo subInfo : subList) {
String key = subInfo.getTypeId() + "_" + subInfo.getProId();
MaterialProvideNumInfo matchedRecord = recordMap.get(key);
// 匹配到对应记录时才进行合并使用Objects.equals避免空指针
if (matchedRecord != null
&& Objects.equals(subInfo.getTypeId(), matchedRecord.getTypeId())
&& Objects.equals(subInfo.getProId(), matchedRecord.getProId())) {
// 合并数值字段假设为BigDecimal确保非null若可能为null需先判断
matchedRecord.setUseNum(subInfo.getUseNum().add(matchedRecord.getUseNum()));
matchedRecord.setStoreNum(matchedRecord.getStoreNum().subtract(subInfo.getUseNum()));
// 合并协议ID使用StringBuilder优化拼接
matchedRecord.setAgreementIds(matchedRecord.getAgreementIds() + "," + subInfo.getAgreementIds());
}
}
// 1. 过滤数据并行流加速大集合过滤
if (teamData != null) {
recordList = recordList.parallelStream()

View File

@ -50,6 +50,17 @@ public class FieldMaintenanceController extends BaseController {
return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, list));
}
/**
* 查询现场维修三级列表
* @param fieldApplyDetails
* @return
*/
@ApiOperation(value = "查询现场维修三级列表")
@GetMapping("/getDetailsInfo")
public AjaxResult getDetailsInfo(FieldApplyDetails fieldApplyDetails) {
return AjaxResult.success(fieldMaintenanceService.getDetailsInfo(fieldApplyDetails));
}
/**
* 新增维修任务app
@ -83,7 +94,7 @@ public class FieldMaintenanceController extends BaseController {
}
@ApiOperation(value = "删除任务")
@ApiOperation(value = "删除任务")
@PreventRepeatSubmit
@SysLog(title = "现场维修任务", businessType = OperaType.INSERT, logType = 1, module = "仓储管理->删除任务")
@PostMapping("/deleteFieldApplyInfoById")
@ -107,13 +118,13 @@ public class FieldMaintenanceController extends BaseController {
}
}
@ApiOperation(value = "提交任务")
@ApiOperation(value = "删除详情数据")
@PreventRepeatSubmit
@SysLog(title = "现场维修任务", businessType = OperaType.INSERT, logType = 1, module = "仓储管理->删除任务")
@PostMapping("/deleteFieldApplyDetailsById")
public AjaxResult deleteFieldApplyDetailsById(@RequestBody FieldApplyDetails fieldApplyDetails) {
try {
return fieldMaintenanceService.deleteFieldApplyDetailsById(fieldApplyDetails.getParentId(), fieldApplyDetails.getTypeId());
return fieldMaintenanceService.deleteFieldApplyDetailsById(fieldApplyDetails);
} catch (Exception e) {
return error();
}

View File

@ -3,6 +3,7 @@ package com.bonus.material.fieldMaintenance.domain;
import com.bonus.common.biz.domain.BmFileInfo;
import com.bonus.common.core.annotation.Excel;
import com.bonus.material.back.domain.MaCodeDto;
import com.bonus.material.repair.domain.RepairPartDetails;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -78,7 +79,7 @@ public class FieldApplyDetails {
/** 退料数量 */
@ApiModelProperty(value = "维修数量")
private BigDecimal preNum;
private BigDecimal repairNum;
/** 审批数量 */
@ApiModelProperty(value = "审批数量")
@ -116,4 +117,14 @@ public class FieldApplyDetails {
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/**
* 附件集合
*/
private List<BmFileInfo> fileInfoList;
/**
* 维修配件集合
*/
private List<RepairPartDetails> partDetails;
}

View File

@ -2,6 +2,8 @@ package com.bonus.material.fieldMaintenance.mapper;
import com.bonus.material.fieldMaintenance.domain.FieldApplyDetails;
import com.bonus.material.fieldMaintenance.domain.FieldApplyInfo;
import com.bonus.material.repair.domain.RepairCost;
import com.bonus.material.repair.domain.RepairPartDetails;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -45,4 +47,43 @@ public interface FieldMaintenanceMapper {
int deleteFieldApplyDetailsById(@Param("id") Long id, @Param("typeId") Long typeId);
int insertDetails(FieldApplyDetails fieldApplyDetails);
/**
* 新增配件明细
* @param partDetails
* @return
*/
int insertRepairPartDetailsList(@Param("list") List<RepairPartDetails> partDetails);
/**
* 往repair_cost表新增数据
* @param repairCost
*/
int addRepairCost(RepairCost repairCost);
/**
* 查询配件详情
* @param fieldApplyDetails
* @return
*/
List<RepairPartDetails> selectRepairPartDetailsList(FieldApplyDetails fieldApplyDetails);
int deletePartDetails(FieldApplyDetails fieldApplyDetails);
int deleteRepairCost(FieldApplyDetails fieldApplyDetails);
int deleteByTaskId(FieldApplyDetails fieldApplyDetails);
/**
* 个人配件库存扣除
* @param partDetails
*/
int subtractStorageNum(RepairPartDetails partDetails);
/**
* 配件库存增加
* @param partDetail
* @return
*/
int addStorageNum(RepairPartDetails partDetail);
}

View File

@ -52,9 +52,15 @@ public interface FieldMaintenanceService {
AjaxResult submitTask(Long taskId);
AjaxResult deleteFieldApplyDetailsById(Long id,Long typeId);
AjaxResult deleteFieldApplyDetailsById(FieldApplyDetails fieldApplyDetails);
AjaxResult insertDetails(FieldApplyDetails fieldApplyDetails);
/**
* 查询现场维修三级列表
* @param fieldApplyDetails
* @return
*/
FieldApplyDetails getDetailsInfo(FieldApplyDetails fieldApplyDetails);
}

View File

@ -2,15 +2,19 @@ package com.bonus.material.fieldMaintenance.service.impl;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.bonus.common.biz.constant.MaterialConstants;
import com.bonus.common.biz.domain.BmFileInfo;
import com.bonus.common.biz.enums.FieldTaskStatusEnum;
import com.bonus.common.biz.enums.TmTaskTypeEnum;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.basic.mapper.BmFileInfoMapper;
import com.bonus.material.fieldMaintenance.domain.FieldApplyDetails;
import com.bonus.material.fieldMaintenance.domain.FieldApplyInfo;
import com.bonus.material.fieldMaintenance.mapper.FieldMaintenanceMapper;
import com.bonus.material.fieldMaintenance.service.FieldMaintenanceService;
import com.bonus.material.repair.domain.RepairCost;
import com.bonus.material.repair.domain.RepairPartDetails;
import com.bonus.material.task.domain.TmTask;
import com.bonus.material.task.domain.TmTaskAgreement;
import com.bonus.material.task.mapper.TmTaskAgreementMapper;
@ -19,6 +23,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
@ -37,6 +42,9 @@ public class FieldMaintenanceImpl implements FieldMaintenanceService {
@Resource
private TmTaskAgreementMapper taskAgreementMapper;
@Resource
private BmFileInfoMapper bmFileInfoMapper;
/**
* 查询现场维修任务列表
*
@ -119,7 +127,6 @@ public class FieldMaintenanceImpl implements FieldMaintenanceService {
tmTaskAgreement.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
fieldApplyInfo.setTaskId(tmTask.getTaskId());
fieldApplyInfo.setAgreementId(tmTaskAgreement.getAgreementId());
int insert = fieldMaintenanceMapper.insert(fieldApplyInfo);
return insert > 0 ? AjaxResult.success() : AjaxResult.error("保存失败,请重试!");
}
@ -139,8 +146,24 @@ public class FieldMaintenanceImpl implements FieldMaintenanceService {
@Override
public AjaxResult deleteFieldApplyInfoById(Integer id, Long taskId) {
try {
FieldApplyDetails fieldApplyDetails = new FieldApplyDetails();
fieldApplyDetails.setTaskId(taskId);
taskMapper.deleteTmTaskByTaskId(taskId);
int i = fieldMaintenanceMapper.deleteFieldApplyInfoById(id);
i += fieldMaintenanceMapper.deleteByTaskId(fieldApplyDetails);
// 查询配件详情列表备用用作恢复个人配件库存
List<RepairPartDetails> partDetails = fieldMaintenanceMapper.selectRepairPartDetailsList(fieldApplyDetails);
if (CollectionUtils.isNotEmpty(partDetails)) {
for (RepairPartDetails partDetail : partDetails) {
// 恢复配件库存
partDetail.setCreateBy(SecurityUtils.getUserId().toString());
fieldMaintenanceMapper.addStorageNum(partDetail);
}
}
// 删除配件详情
i += fieldMaintenanceMapper.deletePartDetails(fieldApplyDetails);
// 删除repair_cost表数据
i += fieldMaintenanceMapper.deleteRepairCost(fieldApplyDetails);
return i > 0 ? AjaxResult.success() : AjaxResult.error();
} catch (Exception e) {
log.error(e.getMessage());
@ -166,14 +189,25 @@ public class FieldMaintenanceImpl implements FieldMaintenanceService {
}
/**
* @param id
* @param typeId
* @param fieldApplyDetails
* @return
*/
@Override
public AjaxResult deleteFieldApplyDetailsById(Long id, Long typeId) {
public AjaxResult deleteFieldApplyDetailsById(FieldApplyDetails fieldApplyDetails) {
try {
int i = fieldMaintenanceMapper.deleteFieldApplyDetailsById(id, typeId);
int i = fieldMaintenanceMapper.deleteFieldApplyDetailsById(fieldApplyDetails.getParentId(), fieldApplyDetails.getTypeId());
// 查询配件详情列表备用用作恢复个人配件库存
List<RepairPartDetails> partDetails = fieldMaintenanceMapper.selectRepairPartDetailsList(fieldApplyDetails);
if (CollectionUtils.isNotEmpty(partDetails)) {
for (RepairPartDetails partDetail : partDetails) {
partDetail.setCreateBy(SecurityUtils.getUserId().toString());
fieldMaintenanceMapper.addStorageNum(partDetail);
}
}
// 删除配件详情
i += fieldMaintenanceMapper.deletePartDetails(fieldApplyDetails);
// 删除repair_cost表数据
i += fieldMaintenanceMapper.deleteRepairCost(fieldApplyDetails);
return i > 0 ? AjaxResult.success() : AjaxResult.error();
} catch (Exception e) {
log.error(e.getMessage());
@ -188,14 +222,83 @@ public class FieldMaintenanceImpl implements FieldMaintenanceService {
@Override
public AjaxResult insertDetails(FieldApplyDetails fieldApplyDetails) {
try {
int i = fieldMaintenanceMapper.insertDetails(fieldApplyDetails);
return i > 0 ? AjaxResult.success() : AjaxResult.error();
fieldApplyDetails.setCreateBy(SecurityUtils.getUserId().toString());
fieldApplyDetails.setCreateTime(DateUtils.getNowDate());
int result = fieldMaintenanceMapper.insertDetails(fieldApplyDetails);
if (result < 1) {
return AjaxResult.error("保存失败,请联系管理员!");
}
// 判断附件是否为空
if (CollectionUtils.isNotEmpty(fieldApplyDetails.getFileInfoList())) {
// 不用循环采用集合形式往sql里面新增
fieldApplyDetails.getFileInfoList().forEach(fileInfo -> {
fileInfo.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
fileInfo.setTaskId(fieldApplyDetails.getTaskId());
fileInfo.setModelId(fieldApplyDetails.getTypeId());
fileInfo.setTaskType(21);
});
result = bmFileInfoMapper.insertBmFileInfos(fieldApplyDetails.getFileInfoList());
}
// 判断配件明细是否为空
if (CollectionUtils.isNotEmpty(fieldApplyDetails.getPartDetails())) {
// 不用循环采用集合形式往sql里面新增
fieldApplyDetails.getPartDetails().forEach(partDetails -> {
partDetails.setCreateBy(SecurityUtils.getUserId().toString());
partDetails.setCreateTime(DateUtils.getNowDate());
partDetails.setTaskId(fieldApplyDetails.getTaskId());
partDetails.setTypeId(fieldApplyDetails.getTypeId());
partDetails.setMaId(fieldApplyDetails.getMaId() != null ? fieldApplyDetails.getMaId() : null);
// 单价乘数量
partDetails.setPartCost(partDetails.getPartPrice().multiply(new BigDecimal(partDetails.getPartNum())));
// 个人配件库存扣除
fieldMaintenanceMapper.subtractStorageNum(partDetails);
});
result = fieldMaintenanceMapper.insertRepairPartDetailsList(fieldApplyDetails.getPartDetails());
// 往repair_cost表新增数据
fieldApplyDetails.getPartDetails().forEach(partDetails -> {
RepairCost repairCost = new RepairCost();
repairCost.setTaskId(fieldApplyDetails.getTaskId());
repairCost.setTypeId(fieldApplyDetails.getTypeId());
repairCost.setMaId(fieldApplyDetails.getMaId() != null ? fieldApplyDetails.getMaId() : null);
repairCost.setCosts(partDetails.getPartPrice().multiply(new BigDecimal(partDetails.getPartNum())));
repairCost.setCreateBy(SecurityUtils.getUserId().toString());
repairCost.setCreateTime(DateUtils.getNowDate());
repairCost.setRepairType("4");
repairCost.setPartType(partDetails.getPartType().toString());
repairCost.setRepairNum(fieldApplyDetails.getRepairNum());
fieldMaintenanceMapper.addRepairCost(repairCost);
});
}
return result > 0 ? AjaxResult.success("新增成功") : AjaxResult.error("操作失败");
} catch (Exception e) {
log.error(e.getMessage());
return AjaxResult.error();
}
}
/**
* 查询现场维修三级列表
* @param fieldApplyDetails
* @return
*/
@Override
public FieldApplyDetails getDetailsInfo(FieldApplyDetails fieldApplyDetails) {
FieldApplyDetails applyDetails = new FieldApplyDetails();
// 查询附件列表
BmFileInfo fileInfo = new BmFileInfo();
fileInfo.setTaskId(fieldApplyDetails.getTaskId());
fileInfo.setModelId(fieldApplyDetails.getTypeId());
fileInfo.setTaskType(21);
List<BmFileInfo> bmFileInfos = bmFileInfoMapper.selectBmFileInfoList(fileInfo);
applyDetails.setFileInfoList(bmFileInfos);
// 查询配件详情
List<RepairPartDetails> partDetails = fieldMaintenanceMapper.selectRepairPartDetailsList(fieldApplyDetails);
applyDetails.setPartDetails(partDetails);
return applyDetails;
}
/**
* 生成现场维修任务单号

View File

@ -231,7 +231,7 @@ public class PurchaseStorageServiceImpl implements IPurchaseStorageService {
result += updateTaskStatus(statusList);
return AjaxResult.error("该设备已全部入库,请勿重复操作");
}
purchaseDto.setInputNum(details.get(0).getCheckNum());
purchaseDto.setInputNum(details.get(0).getCheckNum().subtract(details.get(0).getInPutNum()));
result += updatePurchaseInfoAndDetails(details.get(0), Integer.parseInt(purchaseDto.getPurchaseId()));
}
} else {
@ -318,9 +318,9 @@ public class PurchaseStorageServiceImpl implements IPurchaseStorageService {
type.setTypeId(Long.valueOf(detail.getTypeId()));
type.setStyle("4");
type.setCode(detail.getPurchaseCode());
type.setInputNum(detail.getCheckNum());
type.setInputNum(detail.getCheckNum().subtract(detail.getInPutNum()));
int result = typeService.updateNumAddOrSubtract(type);
result += purchaseStorageMapper.updateNum(detail.getPurchaseId(), detail.getCheckNum());
result += purchaseStorageMapper.updateNum(detail.getPurchaseId(), detail.getCheckNum().subtract(detail.getInPutNum()));
//result += purchaseStorageMapper.updateStorageNum(detail.getCheckNum(), detail.getTypeId());
return result + purchaseStorageMapper.updateStatusById(PurchaseTaskStatusEnum.IN_STORE.getStatus(), purchaseId);
}

View File

@ -7,7 +7,6 @@
INSERT INTO field_apply_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="taskId != null">task_id,</if>
<if test="agreementId != null">agreement_id,</if>
<if test="fieldPerson != null">field_person,</if>
<if test="phone != null">phone,</if>
<if test="createBy != null">create_by,</if>
@ -17,7 +16,6 @@
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="taskId != null">#{taskId},</if>
<if test="agreementId != null">#{agreementId},</if>
<if test="fieldPerson != null">#{fieldPerson},</if>
<if test="phone != null">#{phone},</if>
<if test="createBy != null">#{createBy},</if>
@ -29,47 +27,113 @@
<insert id="insertDetails">
INSERT INTO field_apply_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="code != null">code,</if>
<if test="parentId != null">parent_id,</if>
<if test="taskId != null">task_id,</if>
<if test="id != null">parent_id,</if>
<if test="typeId != null">type_id,</if>
<if test="preNum != null">pre_num,</if>
<if test="repairNum != null">repair_num,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="maCode != null">ma_code,</if>
<if test="maId != null">ma_id,</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="code != null">#{code},</if>
<if test="parentId != null">#{taskId},</if>
<if test="taskId != null">#{taskId},</if>
<if test="id != null">#{id},</if>
<if test="typeId != null">#{typeId},</if>
<if test="preNum != null">#{preNum},</if>
<if test="repairNum != null">#{repairNum},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="maCode != null">#{maCode},</if>
<if test="maId != null">#{maId},</if>
</trim>
</insert>
<insert id="insertRepairPartDetailsList">
insert into field_part_details (task_id, type_id,ma_id,part_id,part_num,part_price,part_cost,part_type,create_by,create_time,repair_content, remark)
values
<foreach collection="list" item="item" separator=",">
(#{item.taskId},#{item.typeId},#{item.maId},#{item.partId},#{item.partNum},#{item.partPrice},#{item.partCost},#{item.partType},#{item.createBy},#{item.createTime},#{item.repairContent},#{item.remark})
</foreach>
</insert>
<insert id="addRepairCost">
insert into repair_cost (task_id, type_id, ma_id, repair_num, costs, part_type, status, repair_type)
values
(#{taskId},#{typeId},#{maId},#{repairNum},#{costs},#{partType},#{status},#{repairType})
</insert>
<insert id="addStorageNum">
update
pa_person_storage
set part_num = part_num + #{partNum}
where part_id = #{partId}
and creator = #{createBy}
</insert>
<update id="deleteFieldApplyInfoById" parameterType="java.lang.Integer">
UPDATE field_apply_info
SET is_valid = 0,
update_time = NOW()
WHERE id = #{id}
</update>
<update id="subtractStorageNum">
update
pa_person_storage
set part_num = part_num - #{partNum}
where part_id = #{partId}
and creator = #{createBy}
</update>
<delete id="deleteFieldApplyDetailsById">
DELETE
FROM field_apply_details
WHERE parent_id = #{id}
and type_id = #{typeId}
</delete>
<delete id="deletePartDetails">
DELETE
FROM field_part_details
<where>
<if test="taskId != null">
and task_id = #{taskId}
</if>
<if test="typeId != null">
and type_id = #{typeId}
</if>
<if test="maId != null">
and ma_id = #{maId}
</if>
</where>
</delete>
<delete id="deleteRepairCost">
DELETE
FROM repair_cost
<where>
<if test="taskId != null">
and task_id = #{taskId}
</if>
<if test="typeId != null">
and type_id = #{typeId}
</if>
<if test="maId != null">
and ma_id = #{maId}
</if>
</where>
</delete>
<delete id="deleteByTaskId">
DELETE
FROM field_apply_details
WHERE task_id = #{taskId}
</delete>
<select id="selectFieldApplyInfoList" resultType="com.bonus.material.fieldMaintenance.domain.FieldApplyInfo">
SELECT
fai.id AS id,
fai.task_id AS taskId,
fai.agreement_id AS agreementId,
tta.agreement_id AS agreementId,
tt.`code` as code,
fai.field_person AS fieldPerson,
fai.phone AS phone,
@ -94,7 +158,7 @@
bad.parent_id,
GROUP_CONCAT(DISTINCT mt2.type_id) AS typeIds,
GROUP_CONCAT(DISTINCT mt2.type_name) AS typeNames,
SUM(bad.pre_num) AS num
SUM(bad.repair_num) AS num
FROM field_apply_details bad
LEFT JOIN ma_type mt1 ON mt1.type_id = bad.type_id AND mt1.del_flag = '0'
LEFT JOIN ma_type mt2 ON mt2.type_id = mt1.parent_id AND mt2.del_flag = '0'
@ -159,13 +223,14 @@
fad.id AS id,
fad.parent_id AS parentId,
fad.type_id AS typeId,
fad.task_id AS taskId,
mt2.type_name AS materialType,
mt.type_name AS typeModel,
mt1.type_name AS typeName,
mt.unit_name AS unitName,
mt.unit_value AS unitValue,
mt.manage_type AS manageType,
SUM(fad.pre_num) AS preNum,
SUM(fad.repair_num) AS repairNum,
fad.create_by AS createBy,
fad.create_time AS createTime,
fad.update_by AS updateBy,
@ -188,5 +253,28 @@
GROUP BY fad.type_id,mt.manage_type
</select>
<select id="selectRepairPartDetailsList" resultType="com.bonus.material.repair.domain.RepairPartDetails">
SELECT
fpd.part_id AS partId,
mpt.pa_name AS partName,
fpd.part_num AS partNum,
fpd.repair_content AS repairContent,
mt1.type_name AS typeName,
mt.type_name AS typeModelName,
mm.ma_code AS maCode,
fpd.part_type AS partType
FROM
field_part_details fpd
LEFT JOIN ma_part_type mpt ON fpd.part_id = mpt.pa_id
LEFT JOIN ma_type mt ON fpd.type_id = mt.type_id
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
LEFT JOIN ma_machine mm ON fpd.ma_id = mm.ma_id
WHERE
fpd.task_id = #{taskId}
<if test="typeId != null">
AND fpd.type_id = #{typeId}
</if>
</select>
</mapper>

View File

@ -1651,6 +1651,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item}
</foreach>
</if>
<if test="departIdList != null and departIdList.size() > 0">
AND sp.id in
<foreach item="item" collection="departIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="impUnit != null and impUnit != ''">
AND bp.imp_unit = #{impUnit}
</if>
@ -2017,18 +2023,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
subquery1.externalId AS externalId,
subquery1.impUnit AS impUnit,
subquery3.idCard AS idCard,
CASE
WHEN subquery1.typeId = 36 THEN
GREATEST(IFNULL(subquery1.usNum, 0) - IFNULL(subquery3.usNum, 0), 0)
ELSE
0
END AS storeNum,
CASE
WHEN subquery1.typeId = 36 THEN
IFNULL(subquery3.usNum, 0)
ELSE
IFNULL(subquery1.usNum, 0)
END AS useNum,
GREATEST(IFNULL(subquery1.useNum, 0) - IFNULL(subquery3.useNum, 0), 0) AS storeNum,
IFNULL(subquery3.useNum, 0) AS useNum,
IFNULL(subquery1.supplyNum, 0) AS supplyNum,
IFNULL(subquery1.backNum, 0) AS backNum,
subquery1.proCenter AS departName,
@ -2058,7 +2054,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mt2.type_name AS typeName,
mt2.type_id AS thirdTypeId,
mt.type_name AS typeModelName,
SUM(CASE WHEN sai.`status` = '0' THEN IFNULL(sai.num, 0) ELSE 0 END) AS usNum,
SUM(CASE WHEN sai.`status` = '0' THEN IFNULL(sai.num, 0) ELSE 0 END) AS useNum,
SUM(CASE WHEN sai.`status` = '1' THEN IFNULL(sai.num, 0) ELSE 0 END) AS backNum,
SUM(IFNULL( sai.num, 0 )) AS supplyNum,
bp.pro_name as proName,
@ -2068,8 +2064,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bu.bzz_idcard AS idCard,
df.project_dept AS proCenter,
sd.dept_name AS departName,
GROUP_CONCAT(DISTINCT sai.agreement_id) AS agreementId,
bu.type_id AS typeId
GROUP_CONCAT(DISTINCT sai.agreement_id) AS agreementId
FROM
slt_agreement_info sai
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
@ -2137,7 +2132,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mt2.type_name AS typeName,
mt2.type_id AS thirdTypeId,
mt.type_name AS typeModelName,
SUM(IFNULL( sai.num, 0 )) AS usNum,
SUM(IFNULL( sai.num, 0 )) AS useNum,
bp.pro_name as proName,
bp.pro_id as proId,
bp.external_id as externalId,
@ -2210,21 +2205,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
WHERE mt.`level` = 4 and mt.del_flag = '0'
AND subquery1.proName IS NOT NULL
AND (
IFNULL(subquery1.usNum, 0) > 0
OR (
CASE
WHEN subquery1.typeId = 36 THEN GREATEST(IFNULL(subquery1.usNum, 0) - IFNULL(subquery3.usNum, 0), 0)
ELSE IFNULL(subquery3.usNum, 0)
END
) > 0
OR (
CASE
WHEN subquery1.typeId = 36 THEN IFNULL(subquery3.usNum, 0)
ELSE IFNULL(subquery1.usNum, 0)
END
) > 0
)
GROUP BY
subquery1.proId,
mt.type_id
@ -2674,6 +2654,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN data_center.dx_fb_son df ON bp.external_id = df.id
WHERE
sai.is_slt = '0'
AND bu.type_id in (32, 33, 36)
AND bp.external_id IS NOT NULL
AND sd.dept_id not in (342,345,347,348,101,344)
AND bp.pro_id not in (3414,1192,3321,3595)
<if test="impUnitName != null and impUnitName != ''">
AND sd.dept_name = #{impUnitName}
</if>
@ -2720,4 +2704,84 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
GROUP BY
sai.id
</select>
<select id="getSubNumList" resultType="com.bonus.material.clz.domain.vo.MaterialProvideNumInfo">
SELECT
mt.type_id AS typeId,
mt4.type_name AS constructionType,
mt4.type_id AS firstTypeId,
mt3.type_name AS materialType,
mt3.type_id AS secondTypeId,
mt2.type_name AS typeName,
mt2.type_id AS thirdTypeId,
mt.type_name AS typeModelName,
SUM(CASE WHEN sai.`status` = '0' THEN IFNULL(sai.num, 0) ELSE 0 END) AS useNum,
SUM(CASE WHEN sai.`status` = '1' THEN IFNULL(sai.num, 0) ELSE 0 END) AS backNum,
SUM(IFNULL( sai.num, 0 )) AS supplyNum,
bp.pro_name as proName,
bp.pro_id as proId,
bp.external_id as externalId,
bp.imp_unit AS impUnit,
bu.bzz_idcard AS idCard,
df.project_dept AS proCenter,
sd.dept_name AS departName,
GROUP_CONCAT(DISTINCT sai.agreement_id) AS agreementId
FROM
slt_agreement_info sai
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
LEFT JOIN bm_agreement_info bai ON sai.agreement_id = bai.agreement_id
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
LEFT JOIN bm_unit bu ON bai.unit_id = bu.unit_id
AND bu.del_flag = '0'
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
LEFT JOIN data_center.dx_fb_son df ON bp.external_id = df.id
WHERE
sai.is_slt = '0'
AND bp.external_id IS NOT NULL
and bp.pro_id not in (3414,1192,3321,3595)
and bp.pro_center IS NOT NULL
and bu.type_id in (32,33)
<if test="impUnitName != null and impUnitName != ''">
AND sd.dept_name = #{impUnitName}
</if>
<if test="proName != null and proName != ''">
AND bp.pro_name = #{proName}
</if>
<if test="departName != null and departName != ''">
AND bp.pro_center = #{departName}
</if>
<if test="typeName != null and typeName != ''">
AND mt2.type_name = #{typeName}
</if>
<if test="typeModelName != null and typeModelName != ''">
AND mt.type_name = #{typeModelName}
</if>
<if test="projectIdList != null and projectIdList.size() > 0">
AND bp.external_id in
<foreach item="item" collection="projectIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="impUnit != null and impUnit != ''">
AND bp.imp_unit = #{impUnit}
</if>
<if test="jiJuType != null and jiJuType != ''">
AND mt.jiju_type = #{jiJuType}
</if>
<if test="keyWord != null and keyWord != ''">
AND (
mt2.type_name like concat('%', #{keyWord}, '%') or
mt.type_name like concat('%', #{keyWord}, '%') or
bp.pro_name like concat('%', #{keyWord}, '%')
)
</if>
<if test="unitValue != null and unitValue != ''">
AND mt.unit_value = #{unitValue}
</if>
GROUP BY mt.type_id,
bp.pro_id
</select>
</mapper>