一次性导入 出入库记录

出入库记录导出
This commit is contained in:
2024-06-21 10:31:35 +08:00
parent 21b5784829
commit 4ed4a68608
9 changed files with 56 additions and 210 deletions

View File

@@ -1,18 +1,3 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.controller.product;
import cn.ysk.cashier.annotation.Log;
@@ -37,7 +22,7 @@ import javax.servlet.http.HttpServletResponse;
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "/product/StockOperate管理")
@Api(tags = "出入库操作记录管理")
@RequestMapping("/api/tbProductStockOperate")
public class TbProductStockOperateController {
@@ -45,7 +30,6 @@ public class TbProductStockOperateController {
@ApiOperation("导出数据")
@GetMapping(value = "/download")
@PreAuthorize("@el.check('tbProductStockOperate:list')")
public void exportTbProductStockOperate(HttpServletResponse response, TbProductStockOperateQueryCriteria criteria) throws IOException {
tbProductStockOperateService.download(tbProductStockOperateService.queryAll(criteria), response);
}

View File

@@ -52,7 +52,7 @@ public class OutAndOnDto {
@NonNull
private String shopId;
private String isImport;
private String isImport="";
public String getBatchNumber() {

View File

@@ -44,6 +44,7 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
"LEFT JOIN TbShopUnit unit ON pro.unitId = unit.id " +
"WHERE " +
"pro.shopId = :shopId " +
"AND pro.status = 1 " +
"AND (:proName IS NULL OR pro.name LIKE %:proName%) " +
"AND (:isStock IS NULL OR pro.isStock = :isStock) " +
"ORDER BY " +

View File

@@ -1,18 +1,3 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.service;
import cn.ysk.cashier.pojo.BotConfig;

View File

@@ -1,18 +1,3 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.ysk.cashier.service;
import cn.ysk.cashier.pojo.product.TbProductStockOperate;
@@ -46,7 +31,7 @@ public interface TbProductStockOperateService {
* @param criteria 条件参数
* @return List<TbProductStockOperateDto>
*/
List<TbProductStockOperateDto> queryAll(TbProductStockOperateQueryCriteria criteria);
List<TbProductStockOperate> queryAll(TbProductStockOperateQueryCriteria criteria);
/**
* 作废
@@ -88,5 +73,5 @@ public interface TbProductStockOperateService {
* @param response /
* @throws IOException /
*/
void download(List<TbProductStockOperateDto> all, HttpServletResponse response) throws IOException;
void download(List<TbProductStockOperate> all, HttpServletResponse response) throws IOException;
}

View File

@@ -1,5 +1,6 @@
package cn.ysk.cashier.service.impl.productimpl;
import cn.ysk.cashier.pojo.shop.TbShopPurveyor;
import cn.ysk.cashier.repository.shop.TbShopPurveyorRepository;
import cn.ysk.cashier.utils.*;
import com.alibaba.fastjson.JSON;
@@ -84,8 +85,8 @@ public class TbProductStockOperateServiceImpl implements TbProductStockOperateSe
}
@Override
public List<TbProductStockOperateDto> queryAll(TbProductStockOperateQueryCriteria criteria){
return tbProductStockOperateMapper.toDto(tbProductStockOperateRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
public List<TbProductStockOperate> queryAll(TbProductStockOperateQueryCriteria criteria){
return tbProductStockOperateRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder));
}
@Override
@@ -160,11 +161,20 @@ public class TbProductStockOperateServiceImpl implements TbProductStockOperateSe
stockOperate.setCreatedAt(times);
stockOperate.setUpdatedAt(times);
stockOperate.setStatus("normal");
stockOperate.setPurveyorId(resources.getPurveyorId());
stockOperate.setPurveyorName(resources.getPurveyorName());
TbProductStockOperate saveStockOperate = tbProductStockOperateRepository.save(stockOperate);
if (StringUtils.isNotBlank(resources.getIsImport()) && resources.getIsImport().equals("true")) {
if (!resources.getIsImport().equals("true")) {
//供应商退货 reject
//供应商入库 purveyor
if ("reject".equals(resources.getType()) || "purveyor".equals(resources.getType())) {
if(StringUtils.isNotBlank(resources.getPurveyorId())){
Optional<TbShopPurveyor> byId1 = purveyorRepository.findById(Integer.valueOf(resources.getPurveyorId()));
if(byId1.isPresent()){
TbShopPurveyor tbShopPurveyor = byId1.get();
resources.setPurveyorName(tbShopPurveyor.getPurveyorName());
}
}
TbShopPurveyorTransact purveyorTransact = new TbShopPurveyorTransact();
purveyorTransact.setShopId(resources.getShopId());
purveyorTransact.setPurveyorName(resources.getPurveyorName());
@@ -265,24 +275,38 @@ public class TbProductStockOperateServiceImpl implements TbProductStockOperateSe
}
@Override
public void download(List<TbProductStockOperateDto> all, HttpServletResponse response) throws IOException {
public void download(List<TbProductStockOperate> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (TbProductStockOperateDto tbProductStockOperate : all) {
for (TbProductStockOperate stockOperate :all) {
ProductStockOperateVO stockOperateVO = new ProductStockOperateVO();
BeanUtils.copyProperties(stockOperate,stockOperateVO);
stockOperateVO.setType();
stockOperateVO.setStockSnap(ListUtil.stringChangeList(stockOperate.getStockSnap()));
stockOperateVO.setOperatorSnap(StringUtils.stringChangeMap(stockOperate.getOperatorSnap()));
Map<String,Object> map = new LinkedHashMap<>();
map.put("店铺Id", tbProductStockOperate.getShopId());
map.put("操作镜像", tbProductStockOperate.getStockSnap());
map.put(" type", tbProductStockOperate.getType());
map.put(" subType", tbProductStockOperate.getSubType());
map.put("批次", tbProductStockOperate.getBatchNumber());
map.put(" remark", tbProductStockOperate.getRemark());
map.put("操作时间", tbProductStockOperate.getStockTime());
map.put("操作人", tbProductStockOperate.getOperatorSnap());
map.put(" createdAt", tbProductStockOperate.getCreatedAt());
map.put(" updatedAt", tbProductStockOperate.getUpdatedAt());
map.put("供应商Id", tbProductStockOperate.getPurveyorId());
map.put("供应商名称", tbProductStockOperate.getPurveyorName());
map.put("nullify作废normal正常", tbProductStockOperate.getStatus());
list.add(map);
for (int i = 0; i < stockOperateVO.getStockSnap().size(); i++) {
if(i==0){
map.put("操作类型 ", stockOperateVO.getType());
map.put("供应商名称", stockOperateVO.getPurveyorName());
map.put("商品数量 ", stockOperateVO.getStockSnap().size());
map.put(" 备 注 ", stockOperateVO.getRemark());
map.put("操作", stockOperateVO.getOperatorSnap().get("account"));
map.put("创建时间", DateUtil.getStrTime(new Date(stockOperateVO.getStockTime())));
}else {
map.put("操作类型 ", "");
map.put("供应商名称", "");
map.put("商品数量 ", "");
map.put(" 备 注 ", "");
map.put("操 作 人", "");
map.put("创建时间", "");
}
JSONObject jsonObject = stockOperateVO.getStockSnap().getJSONObject(0);
map.put("商品名称", jsonObject.getString("name"));
map.put("商品规格", jsonObject.getString("specSnap"));
map.put("变动数量", jsonObject.getString("number"));
list.add(map);
}
}
FileUtil.downloadExcel(list, response);
}

View File

@@ -60,9 +60,9 @@ public class StockVo {
@Override
public String toString() {
return "{" +
"\"name\":\"" + name + "\""+
"\"unitName\":\"" + unitName +"\""+
"\"specSnap\":\"" + specSnap + "\"" +
"\"name\":\"" + name + "\","+
"\"unitName\":\"" + unitName +"\","+
"\"specSnap\":\"" + specSnap + "\"," +
"\"number\":\"" + number + "\"" +
"}";
}