Browse Source

apk上传地址修改,pda、pc端bug修改

huang 1 tuần trước cách đây
mục cha
commit
3652023c1a

+ 3 - 0
src/main/java/com/jsh/erp/controller/DepotItemController.java

@@ -149,6 +149,7 @@ public class DepotItemController {
         Map<String, Object> map = new HashMap<String, Object>();
         try {
             BigDecimal stock = BigDecimal.ZERO;
+            String position = "";
             List<MaterialVo4Unit> list = materialService.getMaterialByBarCode(barCode);
             if(list!=null && list.size()>0) {
                 MaterialVo4Unit materialVo4Unit = list.get(0);
@@ -161,9 +162,11 @@ public class DepotItemController {
                         String commodityUnit = materialVo4Unit.getCommodityUnit();
                         stock = unitService.parseStockByUnit(stock, unit, commodityUnit);
                     }
+                    position = materialService.getPositionByDidAndMid(depotId,materialVo4Unit.getId());
                 }
             }
             map.put("stock", stock);
+            map.put("position", position);
             res.code = 200;
             res.data = map;
         } catch (Exception e) {

+ 0 - 8
src/main/java/com/jsh/erp/controller/MaterialController.java

@@ -896,12 +896,4 @@ public class MaterialController extends BaseController {
     }
 
 
-    @GetMapping(value = "/getPositionByDidAndMid")
-    @ApiOperation(value = "获取商品仓库库位")
-    public AjaxResult getPositionByDidAndMid(@RequestParam(value = "did") Long did,
-                                             @RequestParam(value = "mid") Long mid){
-        return AjaxResult.success(materialService.getPositionByDidAndMid(did,mid));
-    }
-
-
 }

+ 2 - 8
src/main/java/com/jsh/erp/controller/apkVersion/apkVersionController.java

@@ -33,12 +33,6 @@ public class apkVersionController extends BaseController {
     @Resource
     private ApkVersionService apkVersionService;
 
-    @Resource
-    private SystemConfigService systemConfigService;
-
-    @Value(value="${file.path}")
-    private String filePath;
-
     @ApiOperation("apk版本列表")
     @PostMapping("/list")
     public TableDataInfo list(){
@@ -74,10 +68,10 @@ public class apkVersionController extends BaseController {
             if ("bill".equals(bizPath) || "financial".equals(bizPath) || "material".equals(bizPath)) {
                 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
                 MultipartFile file = multipartRequest.getFile("file");// 获取上传文件对象
-                savePath = systemConfigService.uploadLocal(file, bizPath, request);
+                savePath = apkVersionService.uploadLocal(file, request);
                 if(StringUtil.isNotEmpty(savePath)){
                     res.code = 200;
-                    res.data = filePath + "/" +savePath;
+                    res.data = savePath;
                 }else {
                     res.code = 500;
                     res.data = "上传失败!";

+ 2 - 1
src/main/java/com/jsh/erp/datasource/mappers/MaterialBatchMapper.java

@@ -16,7 +16,8 @@ public interface MaterialBatchMapper extends BaseMapperX<MaterialBatch> {
      * 按生产日期顺序排序
      * @param mid 商品id
      */
-    List<MaterialBatch> getMaterialBatchByMaterialId(Long mid);
+    List<MaterialBatch> getMaterialBatchByMaterialId(@Param("mid") Long mid,
+                                                     @Param("depotID") Long depotID);
 
     /**
      * 根据仓库id和商品id查询商品批次库存

+ 3 - 0
src/main/java/com/jsh/erp/datasource/pda/vo/PDADepotItemVO.java

@@ -75,5 +75,8 @@ public class PDADepotItemVO{
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date warehousingTime;
 
+    @ApiModelProperty("仓库id")
+    private Long depotId;
+
 
 }

+ 8 - 0
src/main/java/com/jsh/erp/service/ApkVersionService.java

@@ -2,7 +2,15 @@ package com.jsh.erp.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.jsh.erp.datasource.entities.ApkVersion;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
 
 public interface ApkVersionService extends IService<ApkVersion> {
 
+    /**
+     * apk文件上传
+     */
+    String uploadLocal(MultipartFile mf, HttpServletRequest request);
+
 }

+ 8 - 0
src/main/java/com/jsh/erp/service/MaterialService.java

@@ -239,4 +239,12 @@ public interface MaterialService extends IService<Material> {
      * @return 商品库存
      */
     BigDecimal getMaterialStockByMid(Long mid);
+
+    /**
+     * 根据商品id和仓库id查询商品当前库存
+     * @param mid 商品id
+     * @param did 仓库id
+     * @return 商品库存
+     */
+    BigDecimal getMaterialStockByMidAndDid(Long mid,Long did);
 }

+ 2 - 1
src/main/java/com/jsh/erp/service/TaskStocktakingService.java

@@ -16,7 +16,8 @@ import java.util.List;
 public interface TaskStocktakingService extends IService<TaskStocktaking> {
 
     /**
-     *
+     * PC-盘点任务列表
+     * @param taskStocktakingQueryDTO 筛选参数
      * @return
      */
     List<TaskStocktakingVO> listBy(TaskStocktakingQueryDTO taskStocktakingQueryDTO);

+ 60 - 0
src/main/java/com/jsh/erp/service/impl/ApkVersionServiceImpl.java

@@ -4,9 +4,18 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jsh.erp.datasource.entities.ApkVersion;
 import com.jsh.erp.datasource.mappers.ApkVersionMapper;
 import com.jsh.erp.service.ApkVersionService;
+import com.jsh.erp.utils.FileUtils;
+import com.jsh.erp.utils.Tools;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.util.FileCopyUtils;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.File;
+import java.io.IOException;
 
 
 @Service
@@ -14,4 +23,55 @@ import org.springframework.stereotype.Service;
 @Slf4j
 public class ApkVersionServiceImpl extends ServiceImpl<ApkVersionMapper, ApkVersion> implements ApkVersionService {
 
+    @Value(value="${file.apkPath}")
+    private String apkPath;
+
+    /**
+     * apk文件上传
+     */
+    @Override
+    public String uploadLocal(MultipartFile mf, HttpServletRequest request) {
+        try {
+            String token = request.getHeader("X-Access-Token");
+            Long tenantId = Tools.getTenantIdByToken(token);
+            String ctxPath = apkPath;
+            String fileName = null;
+            File file = new File(ctxPath + File.separator);
+            if (!file.exists()) {
+                file.mkdirs();// 创建文件根目录
+            }
+            String orgName = mf.getOriginalFilename();// 获取文件名
+            orgName = FileUtils.getFileName(orgName);
+            // 校验文件类型
+            String[] allowedExtensions = {".apk"};
+            boolean isValidExtension = false;
+            for (String ext : allowedExtensions) {
+                if (orgName.toLowerCase().endsWith(ext)) {
+                    isValidExtension = true;
+                    break;
+                }
+            }
+            if (!isValidExtension) {
+                throw new IllegalArgumentException("Invalid file type");
+            }
+            if(orgName.contains(".")){
+                fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.indexOf("."));
+            }else{
+                fileName = orgName+ "_" + System.currentTimeMillis();
+            }
+            String savePath = file.getPath() + File.separator + fileName;
+            File savefile = new File(savePath);
+            FileCopyUtils.copy(mf.getBytes(), savefile);
+
+            // 返回路径
+            String dbpath = fileName;
+            if (dbpath.contains("\\")) {
+                dbpath = dbpath.replace("\\", "/");
+            }
+            return apkPath + "/" +dbpath;
+        } catch (IOException e) {
+            log.error(e.getMessage(), e);
+        }
+        return "";
+    }
 }

+ 1 - 1
src/main/java/com/jsh/erp/service/impl/DepotHeadServiceImpl.java

@@ -2065,7 +2065,7 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
             //修改商品生产日期
             //materialExtendService.update(new UpdateWrapper<MaterialExtend>().set("production_date",materialMap.get(batchNumber).getProductionDate()).eq("id", materialExtend.getId()));
             //修改订单总额
-            //updateTotalPriceById(depotHead);
+            updateTotalPriceById(depotHead);
         }
         //修改采购订单状态、操作人、操作时间
         this.update(new UpdateWrapper<DepotHead>().set("status", "2").set("oper_id",userInfo.getId()).set("submit_time",new Date()).eq("id", pdaDepotHeadDTO.getId()));

+ 2 - 2
src/main/java/com/jsh/erp/service/impl/DepotItemServiceImpl.java

@@ -99,9 +99,9 @@ public class DepotItemServiceImpl extends ServiceImpl<DepotItemMapper, DepotItem
             pdaDepotItemVO.setActualQuantityInStorage(depotItemService.getFinishNumber(pdaDepotItemVO.getMaterialExtendId(), pdaDepotItemVO.getId(), pdaDepotItemVO.getHeaderId(), unitInfo, pdaDepotItemVO.getMaterialUnit(), "basic").toString());
             BigDecimal stock;
             if (unitInfo != null && unitInfo.getId() != null){
-                stock = unitService.parseStockByUnit(materialService.getMaterialStockByMid(pdaDepotItemVO.getMaterialId()),unitInfo,pdaDepotItemVO.getCommodityUnit());
+                stock = unitService.parseStockByUnit(materialService.getCurrentStockByMaterialIdAndDepotId(pdaDepotItemVO.getMaterialId(),pdaDepotItemVO.getDepotId()),unitInfo,pdaDepotItemVO.getCommodityUnit());
             }else {
-                stock = materialService.getMaterialStockByMid(pdaDepotItemVO.getMaterialId());
+                stock = materialService.getCurrentStockByMaterialIdAndDepotId(pdaDepotItemVO.getMaterialId(),pdaDepotItemVO.getDepotId());
             }
             pdaDepotItemVO.setInventory(stock.toString());
         }

+ 1 - 2
src/main/java/com/jsh/erp/service/impl/MaterialBatchServiceImpl.java

@@ -85,7 +85,7 @@ public class MaterialBatchServiceImpl extends ServiceImpl<MaterialBatchMapper,Ma
     public void handleMaterialBatchByDepotItemId(Long diId) throws Exception {
         DepotItem depotItem = depotItemService.getDepotItem(diId);
         //根据单据商品id查询商品批次数据
-        List<MaterialBatch> list = materialBatchMapper.getMaterialBatchByMaterialId(depotItem.getMaterialId());
+        List<MaterialBatch> list = materialBatchMapper.getMaterialBatchByMaterialId(depotItem.getMaterialId(),depotItem.getDepotId());
         //根据单据子表基础单位数量减去批次库存
         BigDecimal basicNumber = depotItem.getBasicNumber();
         for (MaterialBatch materialBatch : list) {
@@ -102,7 +102,6 @@ public class MaterialBatchServiceImpl extends ServiceImpl<MaterialBatchMapper,Ma
                 updateInventory("出库",diId,materialBatch);
             }
         }
-
     }
 
     @Override

+ 14 - 1
src/main/java/com/jsh/erp/service/impl/MaterialServiceImpl.java

@@ -2028,9 +2028,22 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
     }
 
     /**
+     * 根据商品id和仓库id查询商品当前库存
+     *
+     * @param mid 商品id
+     * @param did 仓库id
+     * @return 商品库存
+     */
+    @Override
+    public BigDecimal getMaterialStockByMidAndDid(Long mid, Long did) {
+        MaterialCurrentStock materialCurrentStock = materialCurrentStockMapper.selectOne(new LambdaQueryWrapperX<MaterialCurrentStock>().eq(MaterialCurrentStock::getMaterialId,mid).eq(MaterialCurrentStock::getDepotId,did).eq(MaterialCurrentStock::getDeleteFlag,"0"));
+        return materialCurrentStock == null ? BigDecimal.ZERO : materialCurrentStock.getCurrentNumber();
+    }
+
+    /**
      * 解析excel表格数据为商品对象
      */
-    public List<Material> parseMapByExcelData(List<MaterialWithInitStock> mList){
+    private List<Material> parseMapByExcelData(List<MaterialWithInitStock> mList){
         List<Material> materials = new ArrayList<>();
         Map<String,Material> materialMap = new HashMap<>();
         for (MaterialWithInitStock m : mList) {

+ 3 - 2
src/main/resources/application-dev.yml

@@ -7,7 +7,8 @@ server:
 #文件上传方式 1-本机 2-oss
 file:
   uploadType: 2
-  path: /root/erp/apk #文件上传根目录
+  path: /pc/pro/upload #文件上传根目录
+  apkPath: /root/saas/apk #apk文件上传目录
 
 spring:
   #数据库连接
@@ -20,7 +21,7 @@ spring:
   redis:
     host: 127.0.0.1
     port: 6379
-    password: foobared
+    password: 
 
 aliyun:
   accessKeyId: LTAI5tAWjmJQaDBF6u7JAgap

+ 1 - 0
src/main/resources/application-pro.yml

@@ -8,6 +8,7 @@ server:
 file:
   uploadType: 2
   path: /pc/pro/upload #文件上传根目录
+  apkPath: /root/saas/apk #apk文件上传目录
 
 spring:
   #数据库连接

+ 1 - 0
src/main/resources/application-test.yml

@@ -8,6 +8,7 @@ server:
 file:
   uploadType: 2
   path: /pc/test/upload #文件上传根目录
+  apkPath: /root/saas/apk #apk文件上传目录
 
 spring:
   #数据库连接

+ 2 - 1
src/main/resources/mapper_xml/DepotItemMapper.xml

@@ -611,7 +611,8 @@
       di.material_id AS material_id,
       m.img_name AS img_name,
       di.header_id,
-      di.material_extend_id
+      di.material_extend_id,
+      di.depot_id
     FROM
       jsh_depot_item di
     LEFT JOIN jsh_material m ON di.material_id = m.id

+ 1 - 1
src/main/resources/mapper_xml/MaterialBatchMapper.xml

@@ -4,7 +4,7 @@
 
     <select id="getMaterialBatchByMaterialId" resultType="com.jsh.erp.datasource.entities.MaterialBatch">
         SELECT id,material_id,depot_id,inventory FROM material_batch
-        WHERE material_id = #{mid} AND inventory > 0
+        WHERE material_id = #{mid} AND depot_id = #{depotID} AND inventory > 0
         ORDER BY production_date ASC
     </select>