|
@@ -5,6 +5,7 @@ import com.platform.common.bean.AbstractPageResultBean;
|
|
import com.platform.common.enums.DataFilterTypeEnum;
|
|
import com.platform.common.enums.DataFilterTypeEnum;
|
|
import com.platform.common.exception.BusinessException;
|
|
import com.platform.common.exception.BusinessException;
|
|
import com.platform.common.model.UserInfo;
|
|
import com.platform.common.model.UserInfo;
|
|
|
|
+import com.platform.common.util.BeanConverterUtil;
|
|
import com.platform.common.util.IdGeneratorUtils;
|
|
import com.platform.common.util.IdGeneratorUtils;
|
|
import com.platform.common.util.R;
|
|
import com.platform.common.util.R;
|
|
import com.platform.common.util.SecurityUtils;
|
|
import com.platform.common.util.SecurityUtils;
|
|
@@ -44,6 +45,7 @@ import tk.mybatis.mapper.weekend.Weekend;
|
|
import tk.mybatis.mapper.weekend.WeekendCriteria;
|
|
import tk.mybatis.mapper.weekend.WeekendCriteria;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -62,7 +64,7 @@ public class StoreServiceImpl extends BaseServiceImpl<StoreMapper, Store, StoreD
|
|
private SysDeptService sysDeptService;
|
|
private SysDeptService sysDeptService;
|
|
private SysDeptMapper deptMapper;
|
|
private SysDeptMapper deptMapper;
|
|
private SpareStoreMapper spareStoreMapper;
|
|
private SpareStoreMapper spareStoreMapper;
|
|
-
|
|
|
|
|
|
+ private StoreMapper storeMapper;
|
|
private final String useArea = "5e64ac691c527828b2114da0";
|
|
private final String useArea = "5e64ac691c527828b2114da0";
|
|
private final String useCompany = "6063f905eb190003685af6d4";
|
|
private final String useCompany = "6063f905eb190003685af6d4";
|
|
private final String useProject = "6063f92ceb190003685af6d9";
|
|
private final String useProject = "6063f92ceb190003685af6d9";
|
|
@@ -228,7 +230,6 @@ public class StoreServiceImpl extends BaseServiceImpl<StoreMapper, Store, StoreD
|
|
throw new BusinessException("该项目部已经存在总仓,总仓只能有一个");
|
|
throw new BusinessException("该项目部已经存在总仓,总仓只能有一个");
|
|
}
|
|
}
|
|
}*/
|
|
}*/
|
|
-
|
|
|
|
super.modModelByDTO(model);
|
|
super.modModelByDTO(model);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -327,4 +328,76 @@ public class StoreServiceImpl extends BaseServiceImpl<StoreMapper, Store, StoreD
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 将某个仓库的备件库存全部转移到另外的仓库
|
|
|
|
+ * 原仓库库存全部为0,原仓库为0的不迁移
|
|
|
|
+ * 新仓库已存在的备件直接增加数量或者新增备件
|
|
|
|
+ *
|
|
|
|
+ * @param sourceStoreId
|
|
|
|
+ * @param destStoreId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String changeStore(String sourceStoreId, String destStoreId) {
|
|
|
|
+ Weekend<SpareStore> weekend = new Weekend<>(SpareStore.class);
|
|
|
|
+ WeekendCriteria<SpareStore, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
|
+ weekendCriteria.andEqualTo(SpareStore::getStoreId, sourceStoreId);
|
|
|
|
+ List<SpareStore> storeList = spareStoreMapper.selectByExample(weekend);
|
|
|
|
+ Weekend<SpareStore> weekend2 = new Weekend<>(SpareStore.class);
|
|
|
|
+ WeekendCriteria<SpareStore, Object> weekendCriteria2 = weekend2.weekendCriteria();
|
|
|
|
+ weekendCriteria2.andEqualTo(SpareStore::getStoreId, destStoreId);
|
|
|
|
+ List<SpareStore> destStoreList = spareStoreMapper.selectByExample(weekend2);
|
|
|
|
+ List<SpareStore> addList = new ArrayList<SpareStore>();
|
|
|
|
+ List<SpareStore> updateList = new ArrayList<SpareStore>();
|
|
|
|
+ String result = "";
|
|
|
|
+ int notChange = 0;
|
|
|
|
+ if(CollectionUtil.isNotEmpty(storeList)){
|
|
|
|
+ if(CollectionUtil.isNotEmpty(destStoreList)){
|
|
|
|
+ for(SpareStore source:storeList){
|
|
|
|
+ // 原仓库为0的不迁移
|
|
|
|
+ if(source.getNum()!=null && source.getNum().compareTo(new BigDecimal(0))==0){
|
|
|
|
+ notChange++;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ boolean find = false;
|
|
|
|
+ for(SpareStore dest:destStoreList){
|
|
|
|
+ if(source.getSpareId().equals(dest.getSpareId())){
|
|
|
|
+ find = true;
|
|
|
|
+ dest.setNum(dest.getNum().add(source.getNum()));
|
|
|
|
+ updateList.add(dest);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(!find){
|
|
|
|
+ SpareStore create = BeanConverterUtil.copyObjectProperties(source, SpareStore.class);
|
|
|
|
+ create.setId(IdGeneratorUtils.getObjectId());
|
|
|
|
+ create.setStoreId(destStoreId);
|
|
|
|
+ addList.add(create);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for(SpareStore source:storeList){
|
|
|
|
+ source.setNum(new BigDecimal(0));
|
|
|
|
+ }
|
|
|
|
+ Store sourceStore = storeMapper.selectByPrimaryKey(sourceStoreId);
|
|
|
|
+ sourceStore.setDelFlag(DelFlagEnum.DELETED.getValue());
|
|
|
|
+
|
|
|
|
+ // 更新旧仓库
|
|
|
|
+ spareStoreMapper.updateBatchByStoreChange(storeList);
|
|
|
|
+ storeMapper.updateByPrimaryKey(sourceStore);
|
|
|
|
+
|
|
|
|
+ // 更新新仓库
|
|
|
|
+ if(CollectionUtil.isNotEmpty(addList)){
|
|
|
|
+ spareStoreMapper.insertListforComplex(addList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(CollectionUtil.isNotEmpty(updateList)){
|
|
|
|
+ spareStoreMapper.updateBatchByStoreChange(updateList);
|
|
|
|
+ }
|
|
|
|
+ result = "总迁移备件条数:" + storeList.size() + "迁移更新数量:" + updateList.size()+ "迁移新增数量:"
|
|
|
|
+ + addList.size()+ "未迁移新增数量(为0的备件不迁移):" +notChange;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
}
|
|
}
|