feat(material): 支持班组领料功能

- 新增字段和方法以支持班组领料
- 修改出库流程,增加对班组领料的处理逻辑
- 更新退料和结算相关功能,以适应班组领料
- 优化查询接口,支持按班组查询领料信息
This commit is contained in:
syruan 2025-08-12 15:09:12 +08:00
parent 185769e896
commit a0f4d1e8d5
20 changed files with 217 additions and 22 deletions

View File

@ -48,4 +48,7 @@ public class TypeTreeNode {
@ApiModelProperty(value = "协议id") @ApiModelProperty(value = "协议id")
private Long agreementId; private Long agreementId;
@ApiModelProperty(value = "领料方式 0材料领料 1工器具领料 2数据同步")
private Integer leaseStyle;
} }

View File

@ -108,6 +108,9 @@ public class LeaseOutDetails extends BaseEntity {
@ApiModelProperty(value = "协议id") @ApiModelProperty(value = "协议id")
private Long agreementId; private Long agreementId;
@ApiModelProperty(value = "项目部协议id")
private Long projectUnitAgreementId;
@ApiModelProperty(value = "是否完成 (0:未完成 1:已完成)") @ApiModelProperty(value = "是否完成 (0:未完成 1:已完成)")
private Integer isFinished; private Integer isFinished;
@ -140,6 +143,9 @@ public class LeaseOutDetails extends BaseEntity {
@ApiModelProperty(value = "领料id") @ApiModelProperty(value = "领料id")
private Integer leaseUnitId; private Integer leaseUnitId;
@ApiModelProperty(value = "领料单位是否为班组")
private Boolean leaseUnitIsTeam;
@ApiModelProperty(value = "领料工程id") @ApiModelProperty(value = "领料工程id")
private Integer leaseProjectId; private Integer leaseProjectId;

View File

@ -39,6 +39,9 @@ public class BackApplyInfo implements Serializable {
@ApiModelProperty(value = "协议id") @ApiModelProperty(value = "协议id")
private Long agreementId; private Long agreementId;
@ApiModelProperty(value = "材料站协议id")
private Long clzAgreementId;
@ApiModelProperty(value = "任务类型") @ApiModelProperty(value = "任务类型")
private Integer taskType; private Integer taskType;

View File

@ -49,6 +49,13 @@ public class BmAgreementInfo extends BaseEntity
@NotNull(message = "往来单位id不能为空") @NotNull(message = "往来单位id不能为空")
private Long unitId; private Long unitId;
/**
* 往来单位所属项目部ID
*/
@NotNull(message = "所属项目部ID不能为空")
@ApiModelProperty(value = "所属项目部ID")
private Long projectUnitId;
/** /**
* 往来单位 * 往来单位
*/ */

View File

@ -62,6 +62,11 @@ public interface BmAgreementInfoMapper
public int selectNumByMonth(Date nowDate); public int selectNumByMonth(Date nowDate);
/**
* 查询单位类型是内部单位/外部单位
* @param agreementId
* @return
*/
String getProtocol(String agreementId); String getProtocol(String agreementId);
/** /**

View File

@ -119,6 +119,10 @@ public class MaterialBackApplyDetails extends BaseEntity {
@ApiModelProperty(value = "数据所属组织") @ApiModelProperty(value = "数据所属组织")
private Long companyId; private Long companyId;
/** 领用方式 */
@ApiModelProperty(value = "领用方式 2数据同步")
private Integer leaseStyle;
/** /**
* 附件列表 * 附件列表
*/ */

View File

@ -416,6 +416,7 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe
TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(tmTask.getTaskId(), dto.getBackApplyInfo().getAgreementId()); TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(tmTask.getTaskId(), dto.getBackApplyInfo().getAgreementId());
tmTaskAgreement.setCreateTime(DateUtils.getNowDate()); tmTaskAgreement.setCreateTime(DateUtils.getNowDate());
tmTaskAgreement.setCreateBy(createBy); tmTaskAgreement.setCreateBy(createBy);
// 增加任务和协议关联表数据
taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement); taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
backApplyInfo.setTaskId(tmTask.getTaskId()); backApplyInfo.setTaskId(tmTask.getTaskId());
backApplyInfo.setBackStyle("1"); backApplyInfo.setBackStyle("1");
@ -443,7 +444,7 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe
//对提交的退料详情数量进行校验 //对提交的退料详情数量进行校验
for (MaterialBackApplyDetails backApplyDetails : dto.getBackApplyDetailsList()) { for (MaterialBackApplyDetails backApplyDetails : dto.getBackApplyDetailsList()) {
if (backApplyDetails.getNum() != null && backApplyDetails.getPreNum() != null) { if (backApplyDetails.getNum() != null && backApplyDetails.getPreNum() != null) {
if (backApplyDetails.getNum().compareTo(backApplyDetails.getPreNum())<0 ) { if (backApplyDetails.getNum().compareTo(backApplyDetails.getPreNum()) < 0) {
return AjaxResult.error(backApplyDetails.getTypeName() + "退料数量不能大于预退数量,请重新填写!"); return AjaxResult.error(backApplyDetails.getTypeName() + "退料数量不能大于预退数量,请重新填写!");
} }
} }
@ -851,6 +852,7 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe
* @return * @return
*/ */
private int saveBackApplyDetails(String createBy, MaterialBackApplyRequestVo dto, MaterialBackApplyInfo backApplyInfo, int result) { private int saveBackApplyDetails(String createBy, MaterialBackApplyRequestVo dto, MaterialBackApplyInfo backApplyInfo, int result) {
// 循环退料详情
for (MaterialBackApplyDetails details : dto.getBackApplyDetailsList()) { for (MaterialBackApplyDetails details : dto.getBackApplyDetailsList()) {
details.setCode(backApplyInfo.getCode()); details.setCode(backApplyInfo.getCode());
details.setParentId(backApplyInfo.getId()); details.setParentId(backApplyInfo.getId());
@ -862,15 +864,18 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe
result += materialBackInfoMapper.insertBackApplyDetails(details); result += materialBackInfoMapper.insertBackApplyDetails(details);
// 处理附件 // 处理附件
result = saveBmFileInfo(details, backApplyInfo.getId(), result); result = saveBmFileInfo(details, backApplyInfo.getId(), result);
// 判断是否为编码设备并处理附件 // 判断是否为编码设备并处理附件
Integer isBack = dto.getBackApplyInfo().getIsBack(); Integer isBack = dto.getBackApplyInfo().getIsBack();
details.setIsFinished(isBack); details.setIsFinished(isBack);
result = saveMaCodeBmFileInfo(createBy, isBack, details, backApplyInfo.getId(), result); result = saveMaCodeBmFileInfo(createBy, isBack, details, backApplyInfo.getId(), result);
if (isBack == 1) { if (isBack == 1) {
// 更新任务表及退料申请表状态 // 更新任务表及退料申请表状态
result += updateTaskAndBackInfo(backApplyInfo); result += updateTaskAndBackInfo(backApplyInfo);
// 更新结算表 // 更新结算表
backApplyInfo.setTypeId(details.getTypeId().toString()); backApplyInfo.setTypeId(details.getTypeId().toString());
// 查询材料站的退料明细
List<MaterialBackApplyInfo> allList = materialBackInfoMapper.selectBackDetails(backApplyInfo); List<MaterialBackApplyInfo> allList = materialBackInfoMapper.selectBackDetails(backApplyInfo);
if (CollectionUtils.isNotEmpty(allList)) { if (CollectionUtils.isNotEmpty(allList)) {
List<MaterialBackApplyInfo> newList = new ArrayList<>(); List<MaterialBackApplyInfo> newList = new ArrayList<>();
@ -892,6 +897,7 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe
} }
} }
} }
// 更新材料站的结算协议表
int res = updateSlt4Bean(backApplyInfo, newList); int res = updateSlt4Bean(backApplyInfo, newList);
// 检查机具是否领料 // 检查机具是否领料
if (res == 0) { if (res == 0) {

View File

@ -1380,8 +1380,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
// 获取要减去的值默认值为BigDecimal.ZERO // 获取要减去的值默认值为BigDecimal.ZERO
BigDecimal subtractNum = typeIdToNum.getOrDefault(typeId, BigDecimal.ZERO); BigDecimal subtractNum = typeIdToNum.getOrDefault(typeId, BigDecimal.ZERO);
// 计算新值处理num为null的情况若业务允许 // 计算新值处理num为null的情况若业务允许
BigDecimal currentNum = Optional.ofNullable(node.getNum()) BigDecimal currentNum = Optional.ofNullable(node.getNum()).orElse(BigDecimal.ZERO);
.orElse(BigDecimal.ZERO);
BigDecimal newNum = currentNum.subtract(subtractNum); BigDecimal newNum = currentNum.subtract(subtractNum);
if (newNum.compareTo(BigDecimal.ZERO) == 0) { if (newNum.compareTo(BigDecimal.ZERO) == 0) {
iterator.remove(); iterator.remove();

View File

@ -1,6 +1,7 @@
package com.bonus.material.common.domain.dto; package com.bonus.material.common.domain.dto;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List; import java.util.List;
@ -8,6 +9,7 @@ import java.util.List;
* @author 10488 * @author 10488
*/ */
@Data @Data
@Accessors(chain = true)
public class SelectDto { public class SelectDto {
/** 参数id*/ /** 参数id*/

View File

@ -507,6 +507,14 @@ public class SelectServiceImpl implements SelectService {
List<TypeTreeNode> listL3 = new ArrayList<>(); List<TypeTreeNode> listL3 = new ArrayList<>();
List<TypeTreeNode> listL21 = new ArrayList<>(); List<TypeTreeNode> listL21 = new ArrayList<>();
try { try {
// 判断单位是否为班组如果为班组的话把材料站的领用数据也查询出来
if (bean.getUnitId() != null && bean.getProId() != null) {
List<AgreementVo> clzAgreementInfos = mapper.getAgreementInfoByIdBack(new SelectDto().setProId(bean.getProId()).setUnitId(Math.toIntExact(bean.getUnitId())));
// 如果在材料站该单位有签署协议说明该单位是班组
if (CollectionUtils.isNotEmpty(clzAgreementInfos)) {
bean.setClzAgreementId(Long.valueOf(clzAgreementInfos.get(0).getAgreementId()));
}
}
// 先查第四层类型 // 先查第四层类型
listL4 = mapper.getUseTypeTreeL4(bean); listL4 = mapper.getUseTypeTreeL4(bean);
if (CollectionUtils.isNotEmpty(listL4)) { if (CollectionUtils.isNotEmpty(listL4)) {

View File

@ -1,6 +1,5 @@
package com.bonus.material.lease.mapper; package com.bonus.material.lease.mapper;
import java.util.Date;
import java.util.List; import java.util.List;
import com.bonus.common.biz.domain.lease.LeaseApplyInfo; import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
import com.bonus.common.biz.domain.lease.LeaseConfirmSign; import com.bonus.common.biz.domain.lease.LeaseConfirmSign;
@ -75,6 +74,33 @@ public interface LeaseApplyInfoMapper {
*/ */
int deleteLeaseApplyInfoByIds(Long[] ids); int deleteLeaseApplyInfoByIds(Long[] ids);
/**
* 查询领料任务的单位类型是否是班组
* @param leaseId 领料任务id
* @return 领料单位类型
*/
Long selectLeaseApplyInfoIsTeam(Long leaseId);
/**
* 根据单位id查询单位类型
*/
Long selectUnitTypeByUnitId(Long unitId);
/**
* 查询领料任务的单位ID
* @param leaseId 领料任务id
* @return 单位ID
*/
Long selectLeaseApplyInfoUnitIdByLeaseId(Long leaseId);
/**
* 根据班组ID和工程ID查询挂靠的项目部的协议id
* @param teamId 班组单位id
* @param projectId 工程id
* @return 挂靠的项目部协议id
*/
Long selectProjectUnitAgreementIdByTeamAndProject(@Param("teamId") Integer teamId, @Param("projectId") Integer projectId);
String getTaskId(Long parentId); String getTaskId(Long parentId);
/** 设置审批人为默认的董班长 --防止代码冲突 **/ /** 设置审批人为默认的董班长 --防止代码冲突 **/

View File

@ -1273,6 +1273,22 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
@Override @Override
public AjaxResult leaseOut(LeaseOutRequestVo leaseOutRequestVo) { public AjaxResult leaseOut(LeaseOutRequestVo leaseOutRequestVo) {
for (LeaseOutDetails bean : leaseOutRequestVo.getLeaseOutDetailsList()) { for (LeaseOutDetails bean : leaseOutRequestVo.getLeaseOutDetailsList()) {
if (Objects.isNull(bean)) {
continue;
}
// 默认设置领料单位为非班组
bean.setLeaseUnitIsTeam(false);
// 根据现在的领料发布出库单位ID来判断类型是否是班组
if (bean.getLeaseUnitId() != null) {
// 查询单位类型
Long leaseUnitTypeId = leaseApplyInfoMapper.selectUnitTypeByUnitId(Long.valueOf(bean.getLeaseUnitId()));
if (leaseUnitTypeId != null && Objects.equals(leaseUnitTypeId, 1731L)) {
System.out.println("发布出库的领料单位是班组,Yes");
bean.setLeaseUnitIsTeam(true);
} else {
System.out.println("发布出库的领料单位不是班组,No");
}
}
AjaxResult ajaxResult = leaseOutDetailsService.leaseOut(bean); AjaxResult ajaxResult = leaseOutDetailsService.leaseOut(bean);
if (ajaxResult.isError()) { if (ajaxResult.isError()) {
return ajaxResult; return ajaxResult;

View File

@ -205,6 +205,27 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
// 5插入结算记录 // 5插入结算记录
String taskId = leaseApplyInfoMapper.getTaskId(record.getParentId()); String taskId = leaseApplyInfoMapper.getTaskId(record.getParentId());
record.setTaskId(taskId); record.setTaskId(taskId);
// 判断如果是班组领料则插入原本项目部的协议结算记录
if (record.getLeaseUnitIsTeam() != null && record.getLeaseUnitIsTeam()) {
// 暂存现在出库的班组单位ID
Integer thisOutId = record.getLeaseUnitId();
// 查询班组挂靠的项目部协议ID
Long projectUnitAgreementId = leaseApplyInfoMapper.selectProjectUnitAgreementIdByTeamAndProject(record.getLeaseUnitId(), record.getLeaseProjectId());
if (projectUnitAgreementId != null && projectUnitAgreementId > 0L) {
record.setProjectUnitAgreementId(projectUnitAgreementId);
} else {
return AjaxResult.error("出库失败,没有找到班组所属项目部协议信息");
}
// 查询申请领料的项目部单位ID
Long originLeaseUnitId = leaseApplyInfoMapper.selectLeaseApplyInfoUnitIdByLeaseId(record.getParentId());
record.setLeaseUnitId(Math.toIntExact(originLeaseUnitId));
// 插入项目部领料的结算记录
int inserts = insSltInfo(taskId, record);
System.out.println("插入原本项目部领料结算记录" + (inserts > 0 ? "成功" : "失败"));
// 恢复出库班组单位ID
record.setLeaseUnitId(thisOutId);
record.setLeaseUnitIsTeam(false);
}
res = insSltInfo(taskId, record); res = insSltInfo(taskId, record);
if (res == 0) { if (res == 0) {
throw new RuntimeException("出库失败,插入结算记录失败"); throw new RuntimeException("出库失败,插入结算记录失败");
@ -230,8 +251,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
if (task == null) { if (task == null) {
int thisMonthMaxOrder = tmTaskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_MATERIAL_LEASE.getTaskTypeId()); int thisMonthMaxOrder = tmTaskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_MATERIAL_LEASE.getTaskTypeId());
String taskCode = genderTaskCode(thisMonthMaxOrder); String taskCode = genderTaskCode(thisMonthMaxOrder);
TmTask tmTask = new TmTask(); TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_MATERIAL_LEASE.getTaskTypeId(),
tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_MATERIAL_LEASE.getTaskTypeId(),
LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatus(), LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatus(),
null, thisMonthMaxOrder + 1, taskCode); null, thisMonthMaxOrder + 1, taskCode);
tmTask.setCreateTime(DateUtils.getNowDate()); tmTask.setCreateTime(DateUtils.getNowDate());
@ -261,6 +281,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
bmAgreementInfo.setUnitId(tbTeam.getId()); bmAgreementInfo.setUnitId(tbTeam.getId());
} else { } else {
bmAgreementInfo.setUnitId(bmTeam.getId()); bmAgreementInfo.setUnitId(bmTeam.getId());
// 修改班组信息
bmTeamMapper.update(tbTeam); bmTeamMapper.update(tbTeam);
} }
// 先根据班组和工程id查询若存在则直接返回不存在则新增 // 先根据班组和工程id查询若存在则直接返回不存在则新增
@ -313,6 +334,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
throw new Exception("更新clz_lease_apply_details表数据失败"); throw new Exception("更新clz_lease_apply_details表数据失败");
} }
} else { } else {
// 走新增
record.setPreNum(record.getOutNum()); record.setPreNum(record.getOutNum());
record.setAlNum(record.getOutNum()); record.setAlNum(record.getOutNum());
res = materialLeaseInfoMapper.insertLeaseApplyDetails(record); res = materialLeaseInfoMapper.insertLeaseApplyDetails(record);
@ -357,7 +379,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
} }
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage()); log.error(e.getMessage());
return AjaxResult.error("出库失败"); return AjaxResult.error("出库失败" + e.getMessage());
} }
return AjaxResult.success("出库成功"); return AjaxResult.success("出库成功");
} }
@ -758,21 +780,35 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
return res; return res;
} }
/**
* 插入结算信息
* @param taskId 任务id
* @param record 出库记录
*/
public int insSltInfo(String taskId, LeaseOutDetails record) { public int insSltInfo(String taskId, LeaseOutDetails record) {
int res = 0; int res = 0;
SltAgreementInfo sltAgreementInfo = sltAgreementInfoMapper.getSltAgreementInfo(record); // 根据发布批次查询结算协议信息
SltAgreementInfo sltAgreementInfo;
// 判断是否是班组领用
sltAgreementInfo = sltAgreementInfoMapper.getSltAgreementInfo(record);
if (sltAgreementInfo != null) { if (sltAgreementInfo != null) {
BigDecimal num = sltAgreementInfo.getNum(); BigDecimal num = sltAgreementInfo.getNum();
BigDecimal outNum = record.getOutNum(); BigDecimal outNum = record.getOutNum();
sltAgreementInfo.setNum(num.add(outNum)); sltAgreementInfo.setNum(num.add(outNum));
res = sltAgreementInfoMapper.updSltInfo(sltAgreementInfo); res = sltAgreementInfoMapper.updSltInfo(sltAgreementInfo);
record.setAgreementId(sltAgreementInfo.getAgreementId()); if (!record.getLeaseUnitIsTeam()) {
record.setAgreementId(sltAgreementInfo.getAgreementId());
}
} else { } else {
String agreementId = " "; String agreementId = tmTaskAgreementMapper.getAgreementId(taskId);
agreementId = tmTaskAgreementMapper.getAgreementId(taskId); // 根据发布批次查询协议ID🆔
if (StringUtils.isNotBlank(record.getPublishTask())) { if (StringUtils.isNotBlank(record.getPublishTask())) {
agreementId = tmTaskAgreementMapper.selectAgreementId(record.getPublishTask()); agreementId = tmTaskAgreementMapper.selectAgreementId(record.getPublishTask());
} }
if (record.getLeaseUnitIsTeam()) {
agreementId = String.valueOf(record.getProjectUnitAgreementId());
}
// 查询单位类型内部单位/外部单位
String protocol = bmAgreementInfoMapper.getProtocol(agreementId); String protocol = bmAgreementInfoMapper.getProtocol(agreementId);
Type maType = typeMapper.getMaType(record.getTypeId()); Type maType = typeMapper.getMaType(record.getTypeId());
if (StringUtils.isEmpty(protocol)) { if (StringUtils.isEmpty(protocol)) {
@ -787,7 +823,9 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
} }
} }
res = sltAgreementInfoMapper.insSltInfo(record, agreementId, maType); res = sltAgreementInfoMapper.insSltInfo(record, agreementId, maType);
record.setAgreementId(Long.valueOf(agreementId)); if (!record.getLeaseUnitIsTeam()) {
record.setAgreementId(Long.valueOf(agreementId));
}
} }
return res; return res;
} }

View File

@ -587,7 +587,7 @@ public class LeaseTaskServiceImpl implements ILeaseTaskService {
if (0==sysWorkflowNode.getNodeSignType()){ if (0==sysWorkflowNode.getNodeSignType()){
//当前节点已经审核需要修改节点值 //当前节点已经审核需要修改节点值
if (SysWorkflowRecordHistoryList.get(0) != null) { if (SysWorkflowRecordHistoryList.get(0) != null) {
// todo 固定的人员id 修改成 判断人员/角色 如果是人员的话要进行二次查询 // 固定的人员id 修改成 判断人员/角色 如果是人员的话要进行二次查询
// String configValueNew = sysWorkflowConfigMapper.selectConfigValueByNodeId(SysWorkflowRecordHistoryList.get(0).getNextNodeId()); // String configValueNew = sysWorkflowConfigMapper.selectConfigValueByNodeId(SysWorkflowRecordHistoryList.get(0).getNextNodeId());
// leaseApplyInfoNew.setNodeId(SysWorkflowRecordHistoryList.get(0).getNextNodeId()); // leaseApplyInfoNew.setNodeId(SysWorkflowRecordHistoryList.get(0).getNextNodeId());
// leaseApplyInfoNew.setConfigValue(configValueNew); // leaseApplyInfoNew.setConfigValue(configValueNew);

View File

@ -330,7 +330,6 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
} }
for (SltAgreementInfo lose : loseList) { for (SltAgreementInfo lose : loseList) {
if (lose.getAgreementId().equals(sltInfo.getAgreementId().toString())) { if (lose.getAgreementId().equals(sltInfo.getAgreementId().toString())) {
//TODO 上面已经set过值这里为什么还要set值
relation.setAgreementId(String.valueOf(lose.getAgreementId())); relation.setAgreementId(String.valueOf(lose.getAgreementId()));
relation.setProjectName(lose.getProjectName()); relation.setProjectName(lose.getProjectName());
relation.setUnitName(lose.getUnitName()); relation.setUnitName(lose.getUnitName());

View File

@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="agreementCode" column="agreement_code" /> <result property="agreementCode" column="agreement_code" />
<result property="signTime" column="sign_time" /> <result property="signTime" column="sign_time" />
<result property="unitId" column="unit_id" /> <result property="unitId" column="unit_id" />
<result property="projectUnitId" column="project_unit_id" />
<result property="unitName" column="unit_name" /> <result property="unitName" column="unit_name" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
<result property="leaseDay" column="lease_day" /> <result property="leaseDay" column="lease_day" />
@ -28,7 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectBmAgreementInfoList" parameterType="com.bonus.material.basic.domain.BmAgreementInfo" resultMap="BmAgreementInfoResult"> <select id="selectBmAgreementInfoList" parameterType="com.bonus.material.basic.domain.BmAgreementInfo" resultMap="BmAgreementInfoResult">
SELECT bai.agreement_id, bai.agreement_code , contract_code,sign_time, SELECT bai.agreement_id, bai.agreement_code , contract_code,sign_time,
bu.unit_id,bu.unit_name , bp.pro_id as projectId , bp.pro_name as projectName, bu.unit_id, bai.project_unit_id, bu.unit_name , bp.pro_id as projectId , bp.pro_name as projectName,
plan_start_time,lease_day,auth_person,phone,bai.remark,bai.protocol,bai.branch_project as branchProIdsStr plan_start_time,lease_day,auth_person,phone,bai.remark,bai.protocol,bai.branch_project as branchProIdsStr
FROM bm_agreement_info bai FROM bm_agreement_info bai
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id
@ -63,7 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectBmAgreementInfoByAgreementId" parameterType="Long" resultMap="BmAgreementInfoResult"> <select id="selectBmAgreementInfoByAgreementId" parameterType="Long" resultMap="BmAgreementInfoResult">
SELECT bai.agreement_id, bai.agreement_code , contract_code,sign_time, SELECT bai.agreement_id, bai.agreement_code , contract_code,sign_time,
bu.unit_id,bu.unit_name , bp.pro_id as projectId , bp.pro_name as projectName, bu.unit_id, bai.project_unit_id, bu.unit_name , bp.pro_id as projectId , bp.pro_name as projectName,
plan_start_time,lease_day,auth_person,phone,bai.remark,bai.protocol,tta.task_id,bai.branch_project as branchProIdsStr plan_start_time,lease_day,auth_person,phone,bai.remark,bai.protocol,tta.task_id,bai.branch_project as branchProIdsStr
FROM bm_agreement_info bai FROM bm_agreement_info bai
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id
@ -74,14 +75,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<insert id="insertBmAgreementInfo" parameterType="com.bonus.material.basic.domain.BmAgreementInfo" useGeneratedKeys="true" keyProperty="agreementId"> <insert id="insertBmAgreementInfo" parameterType="com.bonus.material.basic.domain.BmAgreementInfo" useGeneratedKeys="true" keyProperty="agreementId">
insert into bm_agreement_info (agreement_code, sign_time, unit_id, insert into bm_agreement_info (agreement_code, sign_time, unit_id, project_unit_id,
project_id, create_by, lease_day, project_id, create_by, lease_day,
plan_start_time, contract_code, auth_person, plan_start_time, contract_code, auth_person,
phone, create_time, update_by, phone, create_time, update_by,
update_time, remark, company_id, protocol, update_time, remark, company_id, protocol,
branch_project branch_project
) )
values (#{agreementCode,jdbcType=VARCHAR}, #{signTime,jdbcType=VARCHAR}, #{unitId,jdbcType=INTEGER}, values (#{agreementCode,jdbcType=VARCHAR}, #{signTime,jdbcType=VARCHAR}, #{unitId,jdbcType=INTEGER}, #{projectUnitId,jdbcType=INTEGER},
#{projectId,jdbcType=INTEGER}, #{createBy,jdbcType=VARCHAR}, #{leaseDay,jdbcType=INTEGER}, #{projectId,jdbcType=INTEGER}, #{createBy,jdbcType=VARCHAR}, #{leaseDay,jdbcType=INTEGER},
#{planStartTime,jdbcType=TIMESTAMP}, #{contractCode,jdbcType=VARCHAR}, #{authPerson,jdbcType=VARCHAR}, #{planStartTime,jdbcType=TIMESTAMP}, #{contractCode,jdbcType=VARCHAR}, #{authPerson,jdbcType=VARCHAR},
#{phone,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR},
@ -113,6 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="agreementCode != null">agreement_code = #{agreementCode},</if> <if test="agreementCode != null">agreement_code = #{agreementCode},</if>
<if test="signTime != null">sign_time = #{signTime},</if> <if test="signTime != null">sign_time = #{signTime},</if>
<if test="unitId != null">unit_id = #{unitId},</if> <if test="unitId != null">unit_id = #{unitId},</if>
<if test="projectUnitId != null">project_unit_id = #{projectUnitId},</if>
<if test="projectId != null">project_id = #{projectId},</if> <if test="projectId != null">project_id = #{projectId},</if>
<if test="createBy != null">create_by = #{createBy},</if> <if test="createBy != null">create_by = #{createBy},</if>
<if test="leaseDay != null">lease_day = #{leaseDay},</if> <if test="leaseDay != null">lease_day = #{leaseDay},</if>

View File

@ -663,11 +663,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mt.unit_value as unitValue, mt.unit_value as unitValue,
mt.manage_type as manageType, mt.manage_type as manageType,
SUM(sai.num) AS num, SUM(sai.num) AS num,
mt.LEVEL as level mt.LEVEL as level,
clai.lease_style as leaseStyle
FROM FROM
ma_type mt ma_type mt
LEFT JOIN clz_slt_agreement_info sai ON mt.type_id = sai.type_id LEFT JOIN clz_slt_agreement_info sai ON mt.type_id = sai.type_id
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = '0' LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = '0'
LEFT JOIN clz_lease_apply_info clai ON sai.lease_id = clai.id
WHERE WHERE
sai.STATUS = '0' and sai.agreement_id = #{agreementId} sai.STATUS = '0' and sai.agreement_id = #{agreementId}
GROUP BY GROUP BY

View File

@ -216,13 +216,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mt.LEVEL as level mt.LEVEL as level
FROM FROM
ma_type mt ma_type mt
LEFT JOIN slt_agreement_info sai ON mt.type_id = sai.type_id LEFT JOIN slt_agreement_info sai ON mt.type_id = sai.type_id
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = '0' LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = '0'
WHERE WHERE
sai.STATUS = '0' and sai.agreement_id = #{agreementId} sai.STATUS = '0' and sai.agreement_id = #{agreementId}
GROUP BY GROUP BY
mt.type_id mt.type_id
HAVING num> 0 HAVING
num > 0
<if test="clzAgreementId != null and clzAgreementId != 0">
union all
SELECT
mt.type_id as typeId,
mt1.type_name as materialName,
mt.type_name as typeName,
mt.parent_id as parentId,
mt.unit_name as unitName,
mt.unit_value as unitValue,
mt.manage_type as manageType,
SUM( IF(sai.agreement_id = #{clzAgreementId} AND sai.STATUS = '0', sai.num, 0) ) AS num,
mt.LEVEL as level
FROM
ma_type mt
LEFT JOIN clz_slt_agreement_info sai ON mt.type_id = sai.type_id
LEFT JOIN clz_lease_apply_info clai ON sai.lease_id = clai.id
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = '0'
WHERE
sai.STATUS = '0' and clai.lease_style != 2
GROUP BY
mt.type_id
HAVING
num> 0
</if>
</select> </select>
<select id="getUseTypeTreeL3" resultType="com.bonus.common.biz.domain.TypeTreeNode"> <select id="getUseTypeTreeL3" resultType="com.bonus.common.biz.domain.TypeTreeNode">
@ -753,6 +780,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
team_id as unitId team_id as unitId
FROM pro_authorize_info FROM pro_authorize_info
WHERE lease_id = #{leaseId} WHERE lease_id = #{leaseId}
limit 1
</select> </select>
<select id="getBackDeviceTypeTree" resultType="com.bonus.common.biz.domain.TreeNode"> <select id="getBackDeviceTypeTree" resultType="com.bonus.common.biz.domain.TreeNode">
SELECT mt.type_id AS id, SELECT mt.type_id AS id,

View File

@ -824,4 +824,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sys_user sys_user
where user_name = #{cno} where user_name = #{cno}
</select> </select>
<select id="selectLeaseApplyInfoIsTeam" resultType="java.lang.Long">
select
bu.type_id as typeId
from
lease_apply_info lai
left join bm_unit bu on lai.unit_id = bu.unit_id
where
lai.id = #{leaseId}
</select>
<select id="selectLeaseApplyInfoUnitIdByLeaseId" resultType="java.lang.Long">
select
lai.unit_id as unitId
from
lease_apply_info lai
where
lai.id = #{leaseId}
</select>
<select id="selectUnitTypeByUnitId" resultType="java.lang.Long">
select type_id as typeId
from bm_unit
where unit_id = #{unitId}
</select>
<select id="selectProjectUnitAgreementIdByTeamAndProject" resultType="java.lang.Long">
SELECT
baii.agreement_id AS projectUnitAgreementId
FROM
bm_agreement_info bai
LEFT JOIN bm_agreement_info baii ON baii.unit_id = bai.project_unit_id AND baii.project_id = #{projectId}
WHERE
bai.unit_id = #{teamId} AND bai.project_id = #{projectId}
</select>
</mapper> </mapper>

View File

@ -177,6 +177,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="publishTask != null and publishTask != ''"> <if test="publishTask != null and publishTask != ''">
AND publish_task = #{publishTask} AND publish_task = #{publishTask}
</if> </if>
<if test="leaseUnitIsTeam">
AND agreement_id = #{projectUnitAgreementId}
</if>
<if test="!leaseUnitIsTeam">
AND agreement_id = #{agreementId}
</if>
AND AND
DATE(start_time) = CURDATE(); DATE(start_time) = CURDATE();
</select> </select>