|
@@ -1,6 +1,8 @@
|
|
|
package com.jeeplus.test.materialManagement.collect.service;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
@@ -16,14 +18,19 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.jeeplus.sys.utils.UserUtils;
|
|
|
import com.jeeplus.test.cw.contractRegistration.service.ContractInfoService;
|
|
|
import com.jeeplus.test.materialManagement.collect.domain.CollectBasic;
|
|
|
+import com.jeeplus.test.materialManagement.collect.domain.CollectBasicsReturn;
|
|
|
+import com.jeeplus.test.materialManagement.collect.domain.CollectBasicsReturnHi;
|
|
|
import com.jeeplus.test.materialManagement.collect.domain.CollectDetailed;
|
|
|
import com.jeeplus.test.materialManagement.collect.mapper.CollectBasicMapper;
|
|
|
+import com.jeeplus.test.materialManagement.collect.mapper.CollectBasicsReturnHiMapper;
|
|
|
+import com.jeeplus.test.materialManagement.collect.mapper.CollectBasicsReturnMapper;
|
|
|
import com.jeeplus.test.materialManagement.collect.mapper.CollectDetailedMapper;
|
|
|
import com.jeeplus.test.materialManagement.collect.service.dto.CollectDto;
|
|
|
import com.jeeplus.test.materialManagement.collect.service.dto.WareHouseSummaryDto;
|
|
|
import com.jeeplus.test.materialManagement.wareHouse.domain.WareHouseBasic;
|
|
|
import com.jeeplus.test.materialManagement.wareHouse.domain.WareHouseDetailed;
|
|
|
import com.jeeplus.test.materialManagement.wareHouse.domain.WareHouseSummary;
|
|
|
+import com.jeeplus.test.materialManagement.wareHouse.domain.WarehouseUpHi;
|
|
|
import com.jeeplus.test.materialManagement.wareHouse.mapper.WareHouseBasicMapper;
|
|
|
import com.jeeplus.test.materialManagement.wareHouse.mapper.WareHouseDetailedMapper;
|
|
|
import com.jeeplus.test.materialManagement.wareHouse.mapper.WareHouseSummaryMapper;
|
|
@@ -39,10 +46,7 @@ import org.springframework.beans.BeanUtils;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.UUID;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 领用表
|
|
@@ -83,6 +87,12 @@ public class CollectService {
|
|
|
@Resource
|
|
|
private FlowTaskService flowTaskService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private CollectBasicsReturnMapper returnMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private CollectBasicsReturnHiMapper returnHiMapper;
|
|
|
+
|
|
|
public void updateStatusById(CollectDto dto) {
|
|
|
basicMapper.updateStatusById(dto.getId(), dto.getStatus());
|
|
|
}
|
|
@@ -111,6 +121,89 @@ public class CollectService {
|
|
|
return "操作成功";
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 发起退回流程
|
|
|
+ * @param dto
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String saveReturn(CollectDto dto) {
|
|
|
+ if (CollectionUtils.isNotEmpty(dto.getDetailInfos()) && StringUtils.isNotBlank(dto.getId())) {
|
|
|
+ for (CollectDetailed detailInfo : dto.getDetailInfos()) {
|
|
|
+ if (StringUtils.isNotBlank(detailInfo.getId()) && StringUtils.isNotBlank(detailInfo.getIsReturn())) {
|
|
|
+ detailedMapper.updateReturnFlagById(detailInfo.getId(), detailInfo.getIsReturn()); // 修改退回状态
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String returnId = createReturnData(dto.getId());
|
|
|
+ detailedMapper.updateByIdReturn(returnId, dto.getStatusReturn(), UserUtils.getCurrentUserDTO().getId(), dto.getReturnCause());
|
|
|
+ return returnId;
|
|
|
+ } else {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 退回流程审核同意
|
|
|
+ * @param dto
|
|
|
+ */
|
|
|
+ public String saveReturnAgree(CollectDto dto) {
|
|
|
+ // 将数据存储到历史表中
|
|
|
+ // 将未修改的数据添加到历史数据表中
|
|
|
+ CollectDto byId = this.findById(dto.getId());
|
|
|
+ String jsonString = JSON.toJSONString(byId);
|
|
|
+ if (ObjectUtil.isNotEmpty(byId) && StringUtils.isNotBlank(byId.getReturnId())) {
|
|
|
+ // 清空退回原因
|
|
|
+ basicMapper.setCauseEmptyById(byId.getReturnId());
|
|
|
+ }
|
|
|
+ CollectBasicsReturnHi returnHi = new CollectBasicsReturnHi();
|
|
|
+ returnHi.setJsonData(jsonString); // json
|
|
|
+ returnHi.setCollectId(dto.getId()); // 领用id
|
|
|
+ CollectBasicsReturn collectBasicsReturn = returnMapper.selectOne(new LambdaQueryWrapper<CollectBasicsReturn>().eq(CollectBasicsReturn::getBasicId, dto.getId()));
|
|
|
+ if (ObjectUtil.isNotEmpty(collectBasicsReturn) && StringUtils.isNotBlank(collectBasicsReturn.getRequestUser())) {
|
|
|
+ returnHi.setReturnUser(collectBasicsReturn.getRequestUser()); // 退回申请人
|
|
|
+ }
|
|
|
+ List<String> returnGoodsName = new ArrayList<>();
|
|
|
+ // 将退回的明细数据删除
|
|
|
+ if (CollectionUtils.isNotEmpty(dto.getDetailInfos())) {
|
|
|
+ for (CollectDetailed detailInfo : dto.getDetailInfos()) {
|
|
|
+ if (StringUtils.isNotBlank(detailInfo.getId()) && StringUtils.isNotBlank(detailInfo.getIsReturn())) {
|
|
|
+ if("1".equals(detailInfo.getIsReturn())) { // 退回状态
|
|
|
+ if (StringUtils.isNotBlank(detailInfo.getCollectNumber())) {
|
|
|
+ // 如果数量不是空的话,将小数点后的0去除
|
|
|
+ BigDecimal value = new BigDecimal(detailInfo.getCollectNumber());
|
|
|
+ BigDecimal noZeros = value.stripTrailingZeros();
|
|
|
+ String resultNum = noZeros.toPlainString();
|
|
|
+ returnGoodsName.add(detailInfo.getGoodsName() + "*" + resultNum);
|
|
|
+ } else {
|
|
|
+ returnGoodsName.add(detailInfo.getGoodsName());
|
|
|
+ }
|
|
|
+ detailedMapper.delete(new LambdaQueryWrapper<CollectDetailed>().eq(CollectDetailed::getId,detailInfo.getId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String returnGoods = String.join(",", returnGoodsName);
|
|
|
+ if (StringUtils.isNotBlank(returnGoods)) {
|
|
|
+ returnHi.setReturnGoods(returnGoods); // 退回的数据(字符串展示)
|
|
|
+ }
|
|
|
+ returnHiMapper.insert(returnHi); // 将数据存储到历史表中
|
|
|
+ // 修改退回流程的状态
|
|
|
+ String returnId = createReturnData(dto.getId());
|
|
|
+ detailedMapper.updateStatusByIdReturn(returnId, dto.getStatusReturn());
|
|
|
+
|
|
|
+ if (ObjectUtil.isNotEmpty(collectBasicsReturn)) {
|
|
|
+ return collectBasicsReturn.getId();
|
|
|
+ } else {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void updateStatusByIdReturn(String id, String status) {
|
|
|
+ CollectBasicsReturn returnData = returnMapper.selectOne(new LambdaQueryWrapper<CollectBasicsReturn>().eq(CollectBasicsReturn::getBasicId, id));
|
|
|
+ if (ObjectUtil.isNotEmpty(returnData) && StringUtils.isNotBlank(returnData.getId())) {
|
|
|
+ detailedMapper.updateStatusByIdReturn(returnData.getId(), status); // 修改退回的流程状态
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public String save(CollectDto dto) throws Exception{
|
|
|
// 获取当前登录人信息
|
|
|
UserDTO userDTO = UserUtils.getCurrentUserDTO();
|
|
@@ -351,6 +444,25 @@ public class CollectService {
|
|
|
dto.setHandledById(info.getHandledBy());
|
|
|
dto.setFiles(files);
|
|
|
}
|
|
|
+ // 领用-退回流程信息
|
|
|
+ CollectBasicsReturn collectBasicsReturn = basicMapper.selectReturnByBasicId(id);
|
|
|
+ if (ObjectUtil.isNotEmpty(collectBasicsReturn)) {
|
|
|
+ if (StringUtils.isNotBlank(collectBasicsReturn.getProcessDefinitionId())){
|
|
|
+ dto.setProcessDefinitionIdReturn(collectBasicsReturn.getProcessDefinitionId());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(collectBasicsReturn.getProcInsId())){
|
|
|
+ dto.setProcInsIdReturn(collectBasicsReturn.getProcInsId());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(collectBasicsReturn.getStatus())){
|
|
|
+ dto.setStatusReturn(collectBasicsReturn.getStatus());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(collectBasicsReturn.getId())){
|
|
|
+ dto.setReturnId(collectBasicsReturn.getId());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(collectBasicsReturn.getRemarks())){
|
|
|
+ dto.setReturnCause(collectBasicsReturn.getRemarks());
|
|
|
+ }
|
|
|
+ }
|
|
|
return dto;
|
|
|
}
|
|
|
|
|
@@ -393,6 +505,12 @@ public class CollectService {
|
|
|
item.setAuditUserIds(flowTaskService.getTaskAuditUsers(item.getTaskId())); // 获取数据审核人
|
|
|
}
|
|
|
}
|
|
|
+ // 领用-退回申请
|
|
|
+ if (StringUtils.isNotBlank(item.getTaskIdReturn()) && StringUtils.isNotBlank(item.getStatusReturn())) {
|
|
|
+ if ("2".equals(item.getStatusReturn())) { // “审核中”的数据要获取数据审核人
|
|
|
+ item.setAuditUserIdsReturn(flowTaskService.getTaskAuditUsers(item.getTaskIdReturn())); // 获取数据审核人
|
|
|
+ }
|
|
|
+ }
|
|
|
});
|
|
|
return list;
|
|
|
}
|
|
@@ -412,4 +530,89 @@ public class CollectService {
|
|
|
|
|
|
return basicMapper.findWareHouseList(page, queryWrapper);
|
|
|
}
|
|
|
+
|
|
|
+ public String createReturnData (String basicId) {
|
|
|
+ CollectBasicsReturn returnData = returnMapper.selectOne(new LambdaQueryWrapper<CollectBasicsReturn>().eq(CollectBasicsReturn::getBasicId, basicId));
|
|
|
+ if (ObjectUtil.isNotEmpty(returnData)) {
|
|
|
+ return returnData.getId();
|
|
|
+ } else {
|
|
|
+ CollectBasicsReturn collectBasicsReturn = new CollectBasicsReturn();
|
|
|
+ collectBasicsReturn.setBasicId(basicId);
|
|
|
+ collectBasicsReturn.setStatus("0"); // 未发起状态
|
|
|
+ returnMapper.insert(collectBasicsReturn);
|
|
|
+ return collectBasicsReturn.getId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public CollectDto findByReturnId (String returnId) {
|
|
|
+ CollectBasicsReturn returnData = returnMapper.selectOne(new LambdaQueryWrapper<CollectBasicsReturn>().eq(CollectBasicsReturn::getId, returnId));
|
|
|
+ if (ObjectUtil.isNotEmpty(returnData) && StringUtils.isNotBlank(returnData.getBasicId())) {
|
|
|
+ CollectDto byId = this.findById(returnData.getBasicId());
|
|
|
+ return byId;
|
|
|
+ } else {
|
|
|
+ return new CollectDto();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void returnRequest(String id) {
|
|
|
+ CollectBasicsReturn returnData = returnMapper.selectOne(new LambdaQueryWrapper<CollectBasicsReturn>().eq(CollectBasicsReturn::getBasicId, id));
|
|
|
+ if (ObjectUtil.isNotEmpty(returnData) && StringUtils.isNotBlank(returnData.getId())) {
|
|
|
+ detailedMapper.updateStatusByIdReturn(returnData.getId(), "0"); // 修改退回的流程状态
|
|
|
+ basicMapper.setCauseEmptyById(returnData.getId()); // 清空退回原因
|
|
|
+ }
|
|
|
+ // 将退回状态的数据全部撤回
|
|
|
+ detailedMapper.updateNoReturnByBasicId(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据领用表id查询其全部历史修改数据
|
|
|
+ public List<CollectBasicsReturnHi> findHiById(String collectId) {
|
|
|
+ List<CollectBasicsReturnHi> hiById = returnHiMapper.findHiById(collectId);
|
|
|
+ return hiById;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据历史表id查询历史表数据
|
|
|
+ public CollectDto findHiByHiId(String hiId) {
|
|
|
+ CollectDto collectDto = new CollectDto();
|
|
|
+ CollectBasicsReturnHi hiByHiId = returnHiMapper.findHiByHiId(hiId); // 根据历史表id查询历史表数据
|
|
|
+ if (ObjectUtil.isNotEmpty(hiByHiId) && StringUtils.isNotBlank(hiByHiId.getJsonData())) {
|
|
|
+ collectDto = JSON.parseObject(hiByHiId.getJsonData(), CollectDto.class); // json字符串解析为java对象
|
|
|
+ // 领用详情中的附件数据获取。
|
|
|
+ // 在这里要重新获取一下领用详情附件的原因是,json字符串中的附件createBy值存储不正确,所以重新获取一下
|
|
|
+ if(ObjectUtil.isNotEmpty(collectDto) && CollectionUtil.isNotEmpty(collectDto.getDetailInfos())) {
|
|
|
+ collectDto.getDetailInfos().forEach(detailed->{
|
|
|
+ List<WorkAttachmentDto> acList = detailedMapper.getByAttachmentId(detailed.getId());
|
|
|
+ if (CollectionUtils.isNotEmpty(acList)) {
|
|
|
+ for (WorkAttachmentDto i : acList) {
|
|
|
+ i.setCreateBy(UserUtils.get(i.getBy()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ detailed.setFileInfoLost(acList);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return collectDto;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据领用表id查询最近的一个修改历史
|
|
|
+ public CollectDto findLastHiByid(String collectId) {
|
|
|
+ CollectDto collectDto = new CollectDto();
|
|
|
+ CollectBasicsReturnHi hiByHiId = returnHiMapper.findLastHiByid(collectId); // 根据领用表id查询最近的一个修改历史
|
|
|
+ if (ObjectUtil.isNotEmpty(hiByHiId) && StringUtils.isNotBlank(hiByHiId.getJsonData())) {
|
|
|
+ collectDto = JSON.parseObject(hiByHiId.getJsonData(), CollectDto.class); // json字符串解析为java对象
|
|
|
+ // 领用详情中的附件数据获取。
|
|
|
+ // 在这里要重新获取一下领用详情附件的原因是,json字符串中的附件createBy值存储不正确,所以重新获取一下
|
|
|
+ if(ObjectUtil.isNotEmpty(collectDto) && CollectionUtil.isNotEmpty(collectDto.getDetailInfos())) {
|
|
|
+ collectDto.getDetailInfos().forEach(detailed->{
|
|
|
+ List<WorkAttachmentDto> acList = detailedMapper.getByAttachmentId(detailed.getId());
|
|
|
+ if (CollectionUtils.isNotEmpty(acList)) {
|
|
|
+ for (WorkAttachmentDto i : acList) {
|
|
|
+ i.setCreateBy(UserUtils.get(i.getBy()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ detailed.setFileInfoLost(acList);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return collectDto;
|
|
|
+ }
|
|
|
}
|