diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/MaterialLeaseMaCodeDto.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/MaterialLeaseMaCodeDto.java index d3523baf..986700dd 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/MaterialLeaseMaCodeDto.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/MaterialLeaseMaCodeDto.java @@ -47,4 +47,7 @@ public class MaterialLeaseMaCodeDto { @ApiModelProperty(value = "协议id") private Long agreementId; + + @ApiModelProperty(value = "规格型号") + private String typeName; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/impl/BackApplyInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/impl/BackApplyInfoServiceImpl.java index 221114e0..2b8aff86 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/impl/BackApplyInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/impl/BackApplyInfoServiceImpl.java @@ -454,7 +454,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { if (backApplyInfo.getUnitId() != null && backApplyInfo.getProId() != null) { SelectDto selectDto = new SelectDto(); selectDto.setUnitId(backApplyInfo.getUnitId().intValue()); - selectDto.setProjectId(backApplyInfo.getProId().intValue()); + selectDto.setProjectId(backApplyInfo.getProId().toString()); List list = mapper.getAgreementInfoById(selectDto); if (CollectionUtils.isNotEmpty(list)) { backApplyInfo.setAgreementId(Long.valueOf(list.get(0).getAgreementId())); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/BmTeamController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/BmTeamController.java index 7f8b5fab..b2e6cb60 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/BmTeamController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/BmTeamController.java @@ -37,7 +37,7 @@ public class BmTeamController extends BaseController { public AjaxResult queryByPage(BmTeam tbTeam) { try { if (tbTeam.getIsAll() != null && tbTeam.getIsAll() == 0) { - return AjaxResult.success(bmTeamService.getList(tbTeam)); + return bmTeamService.getList(tbTeam); } startPage(); List list = bmTeamService.queryByPage(tbTeam); @@ -48,6 +48,17 @@ public class BmTeamController extends BaseController { } } + @ApiOperation(value = "分页查询班组信息") + @GetMapping("/getTeamList") + public AjaxResult getTeamList(BmTeam tbTeam) { + try { + return bmTeamService.getTeamList(tbTeam); + } catch (Exception e) { + log.error("查询班组数据失败", e); + return AjaxResult.error("班组数据查询失败"); + } + } + /** * 新增班组信息 * @param tbTeam diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/MaterialLeaseInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/MaterialLeaseInfoController.java index 9f7131fb..f27a283a 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/MaterialLeaseInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/MaterialLeaseInfoController.java @@ -11,7 +11,6 @@ import com.bonus.common.log.annotation.SysLog; import com.bonus.common.log.enums.OperaType; import com.bonus.material.back.domain.vo.MaCodeVo; import com.bonus.material.basic.domain.BmQrcodeInfo; -import com.bonus.material.clz.domain.back.MaterialBackApplyInfo; import com.bonus.material.common.annotation.PreventRepeatSubmit; import com.bonus.material.clz.domain.lease.LeaseApplyDetailsInfo; import com.bonus.material.clz.domain.lease.LeaseOutDetailsInfo; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/BmTeam.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/BmTeam.java index 921a2bab..87216422 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/BmTeam.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/BmTeam.java @@ -101,7 +101,7 @@ public class BmTeam { private String projectName; /** - * 工程id + * i8工程id */ private String projectId; @@ -114,4 +114,14 @@ public class BmTeam { * 单位类型id */ private Long typeId; + + /** + * 工程id + */ + private String proId; + + /** + * 班组id + */ + private String bzId; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/MaterialLeaseApplyDetails.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/MaterialLeaseApplyDetails.java index 587d8bd6..54dc31a6 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/MaterialLeaseApplyDetails.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/MaterialLeaseApplyDetails.java @@ -140,7 +140,7 @@ public class MaterialLeaseApplyDetails extends BaseEntity { private Long userId; @ApiModelProperty(value = "编码类型集合") - private List maCodeVoList; + private List maCodeVoList; @ApiModelProperty(value = "领料出库编码类型集合") private List outMaCodeVoList; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/MaterialLeaseApplyInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/MaterialLeaseApplyInfo.java index ef51b4fb..5166da8b 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/MaterialLeaseApplyInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/MaterialLeaseApplyInfo.java @@ -57,7 +57,7 @@ public class MaterialLeaseApplyInfo extends BaseEntity { private Integer leaseUnitId; @ApiModelProperty(value = "班组id") - private Long teamId; + private String teamId; @ApiModelProperty(value = "班组名称") @Excel(name = "领料班组") @@ -66,15 +66,15 @@ public class MaterialLeaseApplyInfo extends BaseEntity { @ApiModelProperty(value = "租赁工程") private String leaseProject; - @ApiModelProperty(value = "工程id") - private Long projectId; + @ApiModelProperty(value = "i8工程id") + private String projectId; @ApiModelProperty(value = "工程名称") @Excel(name = "租赁工程") private String projectName; @ApiModelProperty(value = "领料工程id") - private Integer leaseProjectId; + private Long leaseProjectId; @ApiModelProperty(value = "领料人签名URL") private String leaseSignUrl; @@ -290,4 +290,19 @@ public class MaterialLeaseApplyInfo extends BaseEntity { @ApiModelProperty(value = "实施单位id") private String impUnit; + + /** + * 班组长姓名 + */ + private String relName; + + /** + * 班组长手机号 + */ + private String relPhone; + + /** + * 班组长身份证号 + */ + private String teamLeaderIdCard; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/IwsTeamUserVo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/IwsTeamUserVo.java index 844c0cbf..d430f93d 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/IwsTeamUserVo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/IwsTeamUserVo.java @@ -44,12 +44,12 @@ public class IwsTeamUserVo extends IwsUserBean { /** * 班组长姓名 */ - private String teamLeaderName; + private String relName; /** * 班组长手机号 */ - private String teamLeaderPhone; + private String relPhone; /** * 工程id diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/BmTeamMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/BmTeamMapper.java index f06abcb6..98bbda78 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/BmTeamMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/BmTeamMapper.java @@ -44,4 +44,11 @@ public interface BmTeamMapper { * @return */ int deleteById(BmTeam tbTeam); + + /** + * 查询班组数据 + * @param tbTeam + * @return + */ + List getTeamList(BmTeam tbTeam); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/BmTeamService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/BmTeamService.java index 9b8b44ed..629033c8 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/BmTeamService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/BmTeamService.java @@ -39,5 +39,17 @@ public interface BmTeamService { */ AjaxResult deleteById(BmTeam tbTeam); - List getList(BmTeam tbTeam); + /** + * 查询 + * @param tbTeam + * @return + */ + AjaxResult getList(BmTeam tbTeam); + + /** + * 查询班组信息 + * @param tbTeam + * @return + */ + AjaxResult getTeamList(BmTeam tbTeam); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/BmTeamServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/BmTeamServiceImpl.java index 71a12a65..e42e4012 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/BmTeamServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/BmTeamServiceImpl.java @@ -8,11 +8,14 @@ import com.bonus.common.core.utils.encryption.Sm4Utils; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.security.utils.SecurityUtils; import com.bonus.material.clz.domain.BmTeam; +import com.bonus.material.clz.domain.vo.IwsTeamUserVo; import com.bonus.material.clz.mapper.BmTeamMapper; +import com.bonus.material.clz.mapper.IwsTeamUserMapper; import com.bonus.material.clz.service.BmTeamService; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.Collections; import java.util.List; import java.util.Objects; @@ -27,6 +30,9 @@ public class BmTeamServiceImpl implements BmTeamService { @Resource private BmTeamMapper bmTeamMapper; + @Resource + private IwsTeamUserMapper iwsTeamUserMapper; + /** * 查询班组信息 * @param tbTeam @@ -120,25 +126,25 @@ public class BmTeamServiceImpl implements BmTeamService { } @Override - public List getList(BmTeam tbTeam) { - List list = bmTeamMapper.queryByPage(tbTeam); - // 第一次查询结果为空,尝试第二次查询 - if (CollectionUtil.isEmpty(list)) { - tbTeam.setIdCard(null); - list = bmTeamMapper.queryByPage(tbTeam); + public AjaxResult getList(BmTeam tbTeam) { + List iwsTeamUserVos = iwsTeamUserMapper.selectProjectTeamInfoByIdCard(tbTeam.getIdCard()); + if (CollectionUtil.isNotEmpty(iwsTeamUserVos)) { + return AjaxResult.success(iwsTeamUserVos); } - // 处理查询结果,解密手机号 - if (CollectionUtil.isNotEmpty(list)) { - for (BmTeam bmTeam : list) { - if (StringUtils.isNotBlank(bmTeam.getRelPhone())) { - if (bmTeam.getRelPhone().length() > 11) { - //进行解密 - bmTeam.setRelPhone(Sm4Utils.decrypt(bmTeam.getRelPhone())); - } - } - } - } - return list; + // 根据i8工程id查询班组信息 + List ids = Collections.singletonList(tbTeam.getProjectId()); + iwsTeamUserVos = iwsTeamUserMapper.selectProjectTeamInfoByProjectIds(ids); + return AjaxResult.success(iwsTeamUserVos); + } + + /** + * 查询班组信息 + * @param tbTeam + * @return + */ + @Override + public AjaxResult getTeamList(BmTeam tbTeam) { + return AjaxResult.success(bmTeamMapper.getTeamList(tbTeam)); } /** diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/IwsTeamUserServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/IwsTeamUserServiceImpl.java index ed595c51..3ead6169 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/IwsTeamUserServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/IwsTeamUserServiceImpl.java @@ -111,10 +111,10 @@ public class IwsTeamUserServiceImpl implements IwsTeamUserService { BmTeam bmTeam = new BmTeam(); bmTeam.setTeamName(StringUtils.isNotBlank(iwsTeamUserVo.getTeamName()) ? iwsTeamUserVo.getTeamName() : null); bmTeam.setCreateUser(SecurityUtils.getLoginUser().getUserid().toString()); - bmTeam.setRelName(StringUtils.isNotBlank(iwsTeamUserVo.getTeamLeaderName()) ? iwsTeamUserVo.getTeamLeaderName() : null); + bmTeam.setRelName(StringUtils.isNotBlank(iwsTeamUserVo.getRelName()) ? iwsTeamUserVo.getRelName() : null); bmTeam.setIdCard(StringUtils.isNotBlank(iwsTeamUserVo.getTeamLeaderIdCard()) ? iwsTeamUserVo.getTeamLeaderIdCard() : null); bmTeam.setProjectId(StringUtils.isNotBlank(iwsTeamUserVo.getProjectId()) ? iwsTeamUserVo.getProjectId() : null); - bmTeam.setRelPhone(StringUtils.isNotBlank(iwsTeamUserVo.getTeamLeaderPhone()) ? iwsTeamUserVo.getTeamLeaderPhone() : null); + bmTeam.setRelPhone(StringUtils.isNotBlank(iwsTeamUserVo.getRelPhone()) ? iwsTeamUserVo.getRelPhone() : null); // 班组类型固定传值 bmTeam.setTypeId(1731L); // 根据班组名称去bm_unit表查询班组信息 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java index 97cfbf27..68cb61c6 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java @@ -23,6 +23,7 @@ import com.bonus.material.basic.mapper.BmAgreementInfoMapper; import com.bonus.material.basic.mapper.BmFileInfoMapper; import com.bonus.material.clz.domain.BmTeam; import com.bonus.material.clz.domain.vo.MaterialMaCodeVo; +import com.bonus.material.clz.mapper.BmTeamMapper; import com.bonus.material.clz.mapper.MaterialMachineMapper; import com.bonus.material.common.domain.dto.SelectDto; import com.bonus.material.common.domain.vo.AgreementVo; @@ -45,6 +46,7 @@ import com.bonus.material.task.mapper.TmTaskMapper; import lombok.extern.slf4j.Slf4j; import org.springframework.dao.DataAccessException; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; @@ -86,6 +88,9 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { @Resource private MaterialMachineMapper materialMachineMapper; + @Resource + private BmTeamMapper bmTeamMapper; + /** * 查询领料任务列表 * @@ -112,7 +117,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { if (teamData != null) { // 将sortedList中班组身份证号与username相同的元素过滤处理 sortedList = sortedList.stream() - .filter(item -> StringUtils.isBlank(item.getIdCard()) || username.equals(item.getIdCard())) + .filter(item -> StringUtils.isBlank(item.getTeamLeaderIdCard()) || username.equals(item.getTeamLeaderIdCard())) .collect(Collectors.toList()); } else { sortedList = filterByDataPermission(sortedList); @@ -331,7 +336,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { detail.setUseNum(BigDecimal.ZERO); } SelectDto selectDto = new SelectDto(); - selectDto.setProjectId(info.getProjectId().intValue()); + selectDto.setProId(info.getProId()); List list = mapper.getAgreementInfoBy(selectDto); // 先查第四层类型 List listL4 = new ArrayList<>(); @@ -364,7 +369,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { } // 根据工程id去协议表中查询协议id MaterialLeaseApplyInfo bean = new MaterialLeaseApplyInfo(); - bean.setProId(info.getProjectId()); + bean.setProId(info.getProId()); List listAgreement = materialLeaseInfoMapper.getAgreementIdByProId(bean); if (!CollectionUtils.isEmpty(listAgreement)) { for (BmAgreementInfo agreementInfo : listAgreement) { @@ -422,30 +427,34 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { } } // 获取编码详情 - // 移出maCodeList集合中状态不为在库的数据 List maCodeVoList = materialLeaseInfoMapper.getCodeList(id, detail.getTypeId()); if (!CollectionUtils.isEmpty(maCodeVoList)) { - if (!CollectionUtils.isEmpty(maCodeVoList)) { - // 根据id查询协议id - Long agreementId = materialLeaseInfoMapper.getAgreementId(id); - // 将maCodeList不等于1的收集到新集合中 - for (MaterialLeaseMaCodeDto maCodeVo : maCodeVoList) { - if (maCodeVo.getMaId() != null) { - // 根据协议id,typeId,maId查询设备是否已被领料 - maCodeVo.setAgreementId(agreementId); - MaterialLeaseApplyInfo applyInfo = materialLeaseInfoMapper.selectInfoById(maCodeVo); - if (applyInfo != null) { - newCodeList.add(maCodeVo); + // 将maCodeVoList中的materialModel值赋值给typeName + maCodeVoList.forEach(maCodeVo -> maCodeVo.setTypeName(maCodeVo.getMaterialModel())); + detail.setMaCodeVoList(maCodeVoList); + if (info.getTaskStatus() == 1) { + if (!CollectionUtils.isEmpty(maCodeVoList)) { + // 根据id查询协议id + Long agreementId = materialLeaseInfoMapper.getAgreementId(id); + for (MaterialLeaseMaCodeDto maCodeVo : maCodeVoList) { + if (maCodeVo.getMaId() != null) { + // 根据协议id,typeId,maId查询设备是否已被领料 + maCodeVo.setAgreementId(agreementId); + MaterialLeaseApplyInfo applyInfo = materialLeaseInfoMapper.selectInfoById(maCodeVo); + if (applyInfo != null) { + // 将maCodeList中已领料的收集到新集合中 + newCodeList.add(maCodeVo); + } } } } + // 将maCodeVoList中包含newCodeList集合的数据移除 + if (!CollectionUtils.isEmpty(newCodeList)) { + maCodeVoList.removeAll(newCodeList); + } + detail.setMaCodeVoList(maCodeVoList); + detail.setPreNum(BigDecimal.valueOf(maCodeVoList.size())); } - // 将maCodeVoList中包含newCodeList集合的数据移除 - if (!CollectionUtils.isEmpty(newCodeList)) { - maCodeVoList.removeAll(newCodeList); - } - detail.setMaCodeList(maCodeVoList); - detail.setPreNum(BigDecimal.valueOf(maCodeVoList.size())); } } } @@ -454,7 +463,8 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { for (MaterialLeaseApplyDetails detail : outDetailsList) { List maCodeVoList = materialLeaseInfoMapper.getCodeList(id, detail.getTypeId()); if (!CollectionUtils.isEmpty(maCodeVoList)) { - detail.setMaCodeList(maCodeVoList); + maCodeVoList.forEach(maCodeVo -> maCodeVo.setTypeName(maCodeVo.getMaterialModel())); + detail.setMaCodeVoList(maCodeVoList); } } } @@ -539,14 +549,104 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { if (!CollectionUtils.isEmpty(details)) { leaseApplyRequestVo.setLeaseApplyDetailsList(details); for (MaterialLeaseApplyDetails detail : details) { - // 获取编码详情 - List maCodeVoList = materialLeaseInfoMapper.getCodeList(dto.getId(), detail.getTypeId()); - if (!CollectionUtils.isEmpty(maCodeVoList)) { - detail.setMaCodeList(maCodeVoList); + SelectDto selectDto = new SelectDto(); + selectDto.setProId(Long.valueOf(info.getProjectId())); + List list = mapper.getAgreementInfoBy(selectDto); + // 先查第四层类型 + List listL4 = new ArrayList<>(); + List listL5 = new ArrayList<>(); + List list7 = new ArrayList<>(); + BackApplyInfo backApplyInfo = new BackApplyInfo(); + if (!CollectionUtils.isEmpty(list)) { + for (AgreementVo agreementVo : list) { + backApplyInfo.setAgreementId(Long.valueOf(agreementVo.getAgreementId())); + listL4 = mapper.getUseTypeTreeL4(backApplyInfo); + if (!CollectionUtils.isEmpty(listL4)) { + listL4 = listL4.stream() + .filter(item -> StringUtils.isNotBlank(item.getMaterialName()) && StringUtils.isNotBlank(item.getTypeName())) + .collect(Collectors.toList()); + // 将listL5中typeId相同的数据进行num相加 + for (TypeTreeNode node : listL4) { + // 根据node中的typeId查询listL5中相同数据,如果在listL5中存在,则将num相加,反之将node添加到list5中 + TypeTreeNode node1 = listL5.stream() + .filter(item -> item.getTypeId() == (node.getTypeId())) + .findFirst() + .orElse(null); + if (node1 != null) { + node1.setNum(node1.getNum().add(node.getNum())); + } + if (node1 == null) { + listL5.add(node); + } + } + } + } + // 根据工程id去协议表中查询协议id + MaterialLeaseApplyInfo bean = new MaterialLeaseApplyInfo(); + bean.setProId(info.getProId()); + List listAgreement = materialLeaseInfoMapper.getAgreementIdByProId(bean); + if (!CollectionUtils.isEmpty(listAgreement)) { + for (BmAgreementInfo agreementInfo : listAgreement) { + bean.setAgreementId(agreementInfo.getAgreementId()); + List list6 = materialLeaseInfoMapper.getUseTypeTree(bean); + if (!CollectionUtils.isEmpty(list6)) { + for (TypeTreeNode node : list6) { + // 根据node中的typeId查询listL7中相同数据,如果在listL7中存在,则将num相加,反之将node添加到list7中 + TypeTreeNode node1 = list7.stream() + .filter(item -> item.getTypeId() == (node.getTypeId())) + .findFirst() + .orElse(null); + if (node1 != null) { + node1.setNum(node1.getNum().add(node.getNum())); + } + if (node1 == null) { + list7.add(node); + } + } + } + } + } + // 根据协议id去clz_slt_agreement_info材料站协议表中查询在用设备,进行数据筛选去除 + if (!CollectionUtils.isEmpty(listL5)) { + if (!CollectionUtils.isEmpty(list7)) { + // 将list5中typeId和list7中相同数据进行num相减,并剔除相减后为0的数据 + Map typeIdToNum = list7.stream() + .collect(Collectors.toMap( + TypeTreeNode::getTypeId, + TypeTreeNode::getNum, + BigDecimal::add + )); + Iterator iterator = listL5.iterator(); + while (iterator.hasNext()) { + TypeTreeNode node = iterator.next(); + Long typeId = node.getTypeId(); + // 获取要减去的值,默认值为BigDecimal.ZERO + BigDecimal subtractNum = typeIdToNum.getOrDefault(typeId, BigDecimal.ZERO); + // 计算新值,处理num为null的情况(若业务允许) + BigDecimal currentNum = Optional.ofNullable(node.getNum()) + .orElse(BigDecimal.ZERO); + BigDecimal newNum = currentNum.subtract(subtractNum); + if (newNum.compareTo(BigDecimal.ZERO) == 0) { + iterator.remove(); + } else { + node.setNum(newNum); + } + } + } + // 根据details中的typeId去list5中获取库存 + listL5.stream() + .filter(node -> detail.getTypeId().equals(node.getTypeId())) + .findFirst() + .ifPresent(node -> detail.setStorageNum(node.getNum())); + } + // 获取编码详情 + List maCodeVoList = materialLeaseInfoMapper.getCodeList(dto.getId(), detail.getTypeId()); + if (!CollectionUtils.isEmpty(maCodeVoList)) { + detail.setMaCodeList(maCodeVoList); + } } } } - }); return leaseApplyRequestVo; } catch (Exception e) { @@ -677,6 +777,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { * @return */ @Override + @Transactional(rollbackFor = Exception.class) public AjaxResult insertLeaseApplyInfo(MaterialLeaseApplyRequestVo leaseApplyRequestVo) { log.info("新增接口传参:{}", leaseApplyRequestVo); if (null == leaseApplyRequestVo.getLeaseApplyInfo()) { @@ -721,13 +822,33 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { tmTask.setCreateBy(createBy); tmTaskMapper.insertTmTask(tmTask); BmAgreementInfo bmAgreementInfo = new BmAgreementInfo(); - bmAgreementInfo.setProjectId(leaseApplyRequestVo.getLeaseApplyInfo().getProjectId()); - bmAgreementInfo.setTeamId(leaseApplyRequestVo.getLeaseApplyInfo().getTeamId()); - bmAgreementInfo.setUnitId(leaseApplyRequestVo.getLeaseApplyInfo().getTeamId()); + bmAgreementInfo.setProjectId(leaseApplyRequestVo.getLeaseApplyInfo().getProId()); bmAgreementInfo.setCreateTime(DateUtils.getNowDate()); bmAgreementInfo.setCreateBy(createBy); bmAgreementInfo.setSignTime(DateUtils.getNowDate()); bmAgreementInfo.setAgreementCode(getAgreementCode()); + // 先根据班组名称查询此班组是否存在 + BmTeam tbTeam = new BmTeam(); + tbTeam.setTeamName(leaseApplyRequestVo.getLeaseApplyInfo().getTeamName()); + tbTeam.setRelName(StringUtils.isNotBlank(leaseApplyRequestVo.getLeaseApplyInfo().getRelName()) ? leaseApplyRequestVo.getLeaseApplyInfo().getRelName() : null); + tbTeam.setIdCard(StringUtils.isNotBlank(leaseApplyRequestVo.getLeaseApplyInfo().getTeamLeaderIdCard()) ? leaseApplyRequestVo.getLeaseApplyInfo().getTeamLeaderIdCard() : null); + tbTeam.setProjectId(leaseApplyRequestVo.getLeaseApplyInfo().getProjectId().toString()); + tbTeam.setRelPhone(StringUtils.isNotBlank(leaseApplyRequestVo.getLeaseApplyInfo().getRelPhone()) ? leaseApplyRequestVo.getLeaseApplyInfo().getRelPhone() : null); + // 班组类型固定传值 + tbTeam.setTypeId(1731L); + BmTeam bmTeam = bmTeamMapper.selectByName(tbTeam); + if (bmTeam == null) { + // 新增班组 + tbTeam.setCreateUser(SecurityUtils.getLoginUser().getUserid().toString()); + int result = bmTeamMapper.insert(tbTeam); + if (result <= 0) { + return AjaxResult.error(HttpCodeEnum.UPDATE_TO_DATABASE.getCode(), HttpCodeEnum.UPDATE_TO_DATABASE.getMsg()); + } + bmAgreementInfo.setUnitId(tbTeam.getId()); + } else { + bmAgreementInfo.setUnitId(bmTeam.getId()); + bmTeamMapper.update(tbTeam); + } // 先根据班组和工程id查询,若存在则直接返回,不存在则新增 BmAgreementInfo info = bmAgreementInfoMapper.queryByTeamIdAndProjectIdCl(bmAgreementInfo); if (info != null) { @@ -749,6 +870,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { // 领料任务类型为1 工器具领料 leaseApplyRequestVo.getLeaseApplyInfo().setLeaseStyle("1"); + leaseApplyRequestVo.getLeaseApplyInfo().setTeamId(bmAgreementInfo.getUnitId().toString()); int count = materialLeaseInfoMapper.insertLeaseApplyInfo(leaseApplyRequestVo.getLeaseApplyInfo()); if (!CollectionUtils.isEmpty(leaseApplyRequestVo.getLeaseApplyInfo().getBmFileInfos())) { TmTask finalTmTask = tmTask; @@ -1173,15 +1295,24 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { } if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(listL5)) { for (TypeTreeNode node : listL5) { - // 根据工程和班组id查询协议id - BmAgreementInfo info = materialLeaseInfoMapper.getAgreeId(bean); - if (info != null) { - Type maType = new Type(); - maType.setAgreementId(info.getAgreementId()); - maType.setTypeId(node.getTypeId()); - Type dto = typeMapper.getNumList(maType); - if (dto != null) { - node.setUseNum(dto.getUseNum()); + // 先根据班组id查询班组是否存在 + BmTeam bmTeam = new BmTeam(); + bmTeam.setTeamName(bean.getTeamName()); + BmTeam team = bmTeamMapper.selectByName(bmTeam); + if (team != null) { + bean.setTeamId(team.getId().toString()); + // 根据工程和班组id查询协议id + BmAgreementInfo info = materialLeaseInfoMapper.getAgreeId(bean); + if (info != null) { + Type maType = new Type(); + maType.setAgreementId(info.getAgreementId()); + maType.setTypeId(node.getTypeId()); + Type dto = typeMapper.getNumList(maType); + if (dto != null) { + node.setUseNum(dto.getUseNum()); + } else { + node.setUseNum(BigDecimal.ZERO); + } } else { node.setUseNum(BigDecimal.ZERO); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/domain/dto/SelectDto.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/domain/dto/SelectDto.java index 31ac6c09..41225b5c 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/domain/dto/SelectDto.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/domain/dto/SelectDto.java @@ -34,7 +34,7 @@ public class SelectDto { private int unitId; /** 标段工程id*/ - private int projectId; + private String projectId; /** 计量单位*/ private String unitName; @@ -42,5 +42,7 @@ public class SelectDto { private List unitIds; /** 班组id*/ - private int teamId; + private String teamId; + + private Long proId; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/impl/SelectServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/impl/SelectServiceImpl.java index 8c15cb13..c7bda057 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/impl/SelectServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/service/impl/SelectServiceImpl.java @@ -1,5 +1,6 @@ package com.bonus.material.common.service.impl; +import com.alibaba.nacos.common.utils.StringUtils; import com.bonus.common.biz.domain.*; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.security.utils.SecurityUtils; @@ -12,7 +13,6 @@ import com.bonus.material.common.domain.vo.SelectVo; import com.bonus.material.common.mapper.SelectMapper; import com.bonus.material.common.service.SelectService; import com.bonus.material.materialStation.domain.ProAuthorizeInfo; -import com.bonus.system.api.model.LoginUser; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; @@ -261,8 +261,8 @@ public class SelectServiceImpl implements SelectService { public AjaxResult getAgreementInfoByIdBack(SelectDto dto) { AgreementVo vo = new AgreementVo(); try { - if (dto != null && dto.getTeamId() > 0) { - dto.setUnitId(dto.getTeamId()); + if (dto != null && dto.getTeamId() != null) { + dto.setUnitId(Integer.parseInt(dto.getTeamId())); } List list = mapper.getAgreementInfoById(dto); if (CollectionUtils.isNotEmpty(list)) { @@ -556,7 +556,7 @@ public class SelectServiceImpl implements SelectService { List agreementIdList = new ArrayList<>(); AgreementVo vo = new AgreementVo(); try { - if (dto != null && dto.getTeamId() > 0) { + if (dto != null && StringUtils.isNotBlank(dto.getTeamId())) { List list = mapper.getAgreementInfoBy(dto); if (CollectionUtils.isNotEmpty(list)) { for (AgreementVo agreementVo : list) { diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java index 228c84af..7834f710 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java @@ -706,7 +706,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { public AjaxResult getAgreementInfoById(SelectDto dto) { List vo = new ArrayList<>(); try { - List list = sltAgreementInfoMapper.getAgreementInfoById(dto.getUnitIds(), dto.getProjectId()); + List list = sltAgreementInfoMapper.getAgreementInfoById(dto.getUnitIds(), Integer.parseInt(dto.getProjectId())); if (CollectionUtils.isNotEmpty(list)) { vo = list; } else { diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/BmTeamMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/BmTeamMapper.xml index 9557a1a9..d46d7625 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/BmTeamMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/BmTeamMapper.xml @@ -3,7 +3,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + INSERT INTO bm_unit unit_name, @@ -14,7 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" create_by, del_flag, project_id, - bzz_idcard, + bzz_idcard, type_id, @@ -26,7 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{createUser}, 0, #{projectId}, - #{idCard}, + #{idCard}, #{typeId}, @@ -35,11 +35,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" UPDATE bm_unit unit_name = #{teamName}, - depart_id = #{departId}, + type_id = #{typeId}, link_man = #{relName}, telphone = #{relPhone}, update_by = #{updateUser}, status = #{status}, + project_id = #{projectId}, + bzz_idcard = #{idCard}, + bz_id = #{bzId}, update_time = NOW() WHERE unit_id = #{id} @@ -90,11 +93,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + \ No newline at end of file diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/IwsTeamUserMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/IwsTeamUserMapper.xml index c1fe6a08..c48de2dd 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/IwsTeamUserMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/IwsTeamUserMapper.xml @@ -18,9 +18,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select - bzgl_bz.id, bzgl_bz.bzmc as teamName, bzgl_bz.bzz_name as teamLeaderName, bzgl_bz.bzz_idcard as teamLeaderIdCard, + bzgl_bz.id, bzgl_bz.bzmc as teamName, bzgl_bz.bzz_name as relName, bzgl_bz.bzz_idcard as teamLeaderIdCard, bzgl_bz.bz as remark, bzgl_bz.bz_status as teamStatus, bzgl_bz.project_id as projectId, bzgl_bz.project_name as projectName, - bzgl_bz.bzz_idcard as teamLeaderIdCard, org_user.mobile as teamLeaderPhone + bzgl_bz.bzz_idcard as teamLeaderIdCard, org_user.mobile as relPhone from `micro-tool`.bzgl_bz bzgl_bz left join `uni_org`.org_user org_user on bzgl_bz.bzz_idcard = org_user.id_card diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialLeaseInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialLeaseInfoMapper.xml index 7475b0bc..e4b80d30 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialLeaseInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialLeaseInfoMapper.xml @@ -8,7 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + @@ -39,7 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + @@ -70,7 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" lai.dept_audit_remark, lai.direct_audit_by, lai.direct_audit_time, lai.direct_audit_remark, lai.create_by, lai.create_time, lai.update_by, lai.update_time, lai.remark, lai.company_id, lai.direct_id, lai.lease_type, lai.estimate_lease_time, lai.cost_bearing_party, lai.lease_sign_url, lai.lease_sign_type, - lai.project_id as projectId, bp.pro_name as projectName, tt.task_status as taskStatus, + lai.project_id as proId, bp.pro_name as projectName, tt.task_status as taskStatus, sda.dict_label as taskStatusName, lai.team_id as teamId, bt.unit_name as teamName, @@ -84,7 +84,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bp.imp_unit, bt.bzz_idcard, bai.unit_id, - bai.project_id + bai.project_id as projectId, + bt.link_man as relName from clz_lease_apply_info lai left join tm_task tt on lai.task_id = tt.task_id @@ -148,7 +149,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" estimate_lease_time, cost_bearing_party, team_id, - project_id, + project_id, lease_style, @@ -177,7 +178,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{estimateLeaseTime}, #{costBearingParty}, #{teamId}, - #{projectId}, + #{proId}, #{leaseStyle}, @@ -517,7 +518,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" mt.type_name as materialModel, mm.ma_id as maId, mm.ma_code as maCode, - sd.dict_label as maStatus, + '在用' as maStatus, mm.ma_status as status FROM clz_lease_out_details lod @@ -526,8 +527,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND mt.del_flag = '0' LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id AND mt1.del_flag = '0' - LEFT JOIN sys_dict_data sd ON mm.ma_status = sd.dict_value - and sd.dict_type = 'ma_machine_status' WHERE lod.parent_id = #{id} and mt.type_id = #{typeId} @@ -617,7 +616,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" mt.unit_value as unitValue, SUM(lad.out_num) as outNum, IFNULL( lod.pre_num, 0 ) as preNum, - lad.remark as remark + lod.remark as remark FROM clz_lease_out_details lad LEFT JOIN clz_lease_apply_details lod ON lad.parent_id = lod.parent_id diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml index b451cda6..5a59bef4 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/common/SelectMapper.xml @@ -476,7 +476,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHERE bai.status = '1' AND bu.type_id = 36 - AND bai.project_id = #{projectId} + AND bai.project_id = #{proId}