Browse Source

Merge remote-tracking branch 'origin/dev_hjj_522'

yangzhi 2 weeks ago
parent
commit
e5838f26fc

+ 14 - 77
src/main/java/com/jsh/erp/controller/DepotItemController.java

@@ -360,93 +360,30 @@ public class DepotItemController {
                     //拓展信息
                     diEx.setMaterialOther(depotItemService.getOtherInfo(mpArr, diEx));
                     //库存
-                    diEx.setStock(materialService.getMaterialStockByMid(diEx.getMaterialId()));
+                    diEx.setStock(materialService.getCurrentStockByMaterialIdAndDepotId(diEx.getMaterialId(), diEx.getDepotId()));
                     //原数量
                     diEx.setPreNumber(diEx.getOperNumber());
                     //完成数量
                     Unit unitInfo = materialService.findUnit(diEx.getMaterialId()); //查询多单位信息
                     String materialUnit = diEx.getMaterialUnit();
                     diEx.setFinishNumber(depotItemService.getFinishNumber(diEx.getMaterialExtendId(), diEx.getId(), diEx.getHeaderId(), unitInfo, materialUnit, linkType));
-                    JSONObject item = new JSONObject();
-                    item.put("id", diEx.getId());
-                    item.put("materialExtendId", diEx.getMaterialExtendId() == null ? "" : diEx.getMaterialExtendId());
-//                    item.put("barCode", diEx.getBarCode());
-                    item.put("name", diEx.getMName());
-                    item.put("standard", diEx.getMStandard());
-                    item.put("model", diEx.getMModel());
-                    item.put("color", diEx.getMColor());
-                    item.put("brand", diEx.getBrand());
-//                    item.put("mfrs", diEx.getMMfrs());
-                    item.put("materialOther", depotItemService.getOtherInfo(mpArr, diEx));
-                    BigDecimal stock;
-                    if(StringUtil.isNotEmpty(diEx.getSku())){
-                        stock = depotItemService.getSkuStockByParam(diEx.getDepotId(),diEx.getMaterialExtendId(),null,null);
-                    } else {
-                        stock = depotItemService.getCurrentStockByParam(diEx.getDepotId(),diEx.getMaterialId());
-                        if (StringUtil.isNotEmpty(unitInfo.getName())) {
-                            stock = unitService.parseStockByUnit(stock, unitInfo, materialUnit);
-                        }
-                    }
-                    item.put("stock", stock);
-                    item.put("unit", diEx.getMaterialUnit());
-                    item.put("snList", diEx.getSnList());
-//                    item.put("batchNumber", diEx.getBatchNumber());
-                    item.put("expirationDate", Tools.parseDateToStr(diEx.getExpirationDate()));
-                    item.put("sku", diEx.getSku());
-                    item.put("enableSerialNumber", diEx.getEnableSerialNumber());
-//                    item.put("enableBatchNumber", diEx.getEnableBatchNumber());
-                    item.put("operNumber", diEx.getOperNumber());
-                    item.put("basicNumber", diEx.getBasicNumber());
-                    item.put("preNumber", diEx.getOperNumber()); //原数量
-                    item.put("finishNumber", depotItemService.getFinishNumber(diEx.getMaterialExtendId(), diEx.getId(), diEx.getHeaderId(), unitInfo, materialUnit, linkType)); //已入库|已出库
-                    item.put("purchaseDecimal", roleService.parseBillPriceByLimit(diEx.getPurchaseDecimal(), billCategory, priceLimit, request));  //采购价
+//                    item.put("purchaseDecimal", roleService.parseBillPriceByLimit(diEx.getPurchaseDecimal(), billCategory, priceLimit, request));  //采购价
                     if("basic".equals(linkType) || "1".equals(isReadOnly)) {
                         //正常情况显示金额,而以销定购的情况不能显示金额
-                        item.put("unitPrice", roleService.parseBillPriceByLimit(diEx.getUnitPrice(), billCategory, priceLimit, request));
-                        item.put("taxUnitPrice", roleService.parseBillPriceByLimit(diEx.getTaxUnitPrice(), billCategory, priceLimit, request));
-                        item.put("allPrice", roleService.parseBillPriceByLimit(diEx.getAllPrice(), billCategory, priceLimit, request));
-                        item.put("taxRate", roleService.parseBillPriceByLimit(diEx.getTaxRate(), billCategory, priceLimit, request));
-                        item.put("taxMoney", roleService.parseBillPriceByLimit(diEx.getTaxMoney(), billCategory, priceLimit, request));
-                        item.put("taxLastMoney", roleService.parseBillPriceByLimit(diEx.getTaxLastMoney(), billCategory, priceLimit, request));
+//                        item.put("unitPrice", roleService.parseBillPriceByLimit(diEx.getUnitPrice(), billCategory, priceLimit, request));
+                        diEx.setUnitPrice(roleService.parseBillPriceByLimit(diEx.getUnitPrice(), billCategory, priceLimit, request));
+//                        item.put("taxUnitPrice", roleService.parseBillPriceByLimit(diEx.getTaxUnitPrice(), billCategory, priceLimit, request));
+                        diEx.setTaxUnitPrice(roleService.parseBillPriceByLimit(diEx.getTaxUnitPrice(), billCategory, priceLimit, request));
+//                        item.put("allPrice", roleService.parseBillPriceByLimit(diEx.getAllPrice(), billCategory, priceLimit, request));
+                        diEx.setAllPrice(roleService.parseBillPriceByLimit(diEx.getAllPrice(), billCategory, priceLimit, request));
+//                        item.put("taxRate", roleService.parseBillPriceByLimit(diEx.getTaxRate(), billCategory, priceLimit, request));
+                        diEx.setTaxRate(roleService.parseBillPriceByLimit(diEx.getTaxRate(), billCategory, priceLimit, request));
+//                        item.put("taxMoney", roleService.parseBillPriceByLimit(diEx.getTaxMoney(), billCategory, priceLimit, request));
+                        diEx.setTaxMoney(roleService.parseBillPriceByLimit(diEx.getTaxMoney(), billCategory, priceLimit, request));
+//                        item.put("taxLastMoney", roleService.parseBillPriceByLimit(diEx.getTaxLastMoney(), billCategory, priceLimit, request));
+                        diEx.setTaxLastMoney(roleService.parseBillPriceByLimit(diEx.getTaxLastMoney(), billCategory, priceLimit, request));
                     }
                     BigDecimal allWeight = diEx.getBasicNumber()==null||diEx.getWeight()==null?BigDecimal.ZERO:diEx.getBasicNumber().multiply(diEx.getWeight());
-                    item.put("weight", allWeight);
-                    item.put("position", diEx.getPosition());
-                    item.put("remark", diEx.getRemark());
-                    item.put("imgName", diEx.getImgName());
-                    if(fileUploadType == 2) {
-                        item.put("imgSmall", "small");
-                        item.put("imgLarge", "large");
-                    } else {
-                        item.put("imgSmall", "");
-                        item.put("imgLarge", "");
-                    }
-                    item.put("linkId", diEx.getLinkId());
-                    item.put("depotId", diEx.getDepotId() == null ? "" : diEx.getDepotId());
-                    item.put("depotName", diEx.getDepotId() == null ? "" : diEx.getDepotName());
-                    item.put("anotherDepotId", diEx.getAnotherDepotId() == null ? "" : diEx.getAnotherDepotId());
-                    item.put("anotherDepotName", diEx.getAnotherDepotId() == null ? "" : diEx.getAnotherDepotName());
-                    item.put("mType", diEx.getMaterialType());
-                    item.put("op", 1);
-                    String productionDate = diEx.getProductionDate() == null ? null : DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",diEx.getProductionDate());
-                    item.put("productionDate",productionDate);
-                    item.put("expiryNum",diEx.getExpiryNum());
-                    item.put("supplierId",diEx.getSupplierId());
-                    item.put("batchNumber",diEx.getBatchNumber());
-                    item.put("inventory",materialService.getMaterialStockByMid(diEx.getMaterialId()));
-                    item.put("supplierName",diEx.getSupplierName());
-                    item.put("unitId",diEx.getUnitId());
-                    item.put("unitList",diEx.getUnitId() == null ? null : unitService.getUnitListByID(diEx.getUnitId()));
-                    item.put("unitName", diEx.getUnitName());
-                    item.put("actualQuantityInStorage",diEx.getActualQuantityInStorage());
-                    item.put("warehousingVariance",diEx.getWarehousingVariance());
-                    item.put("reasonOfDifference",diEx.getReasonOfDifference());
-                    item.put("warehousingUser",diEx.getWarehousingUser());
-                    item.put("warehousingTime",diEx.getWarehousingTime());
-                    item.put("warehousingUserName",diEx.getWarehousingUserName());
-                    item.put("wholesaleDecimal",diEx.getWholesaleDecimal());
-                    item.put("defaultPurchaseDecimal",diEx.getDefaultPurchaseDecimal());
-                    item.put("defaultWholesaleDecimal",diEx.getDefaultWholesaleDecimal());
                     dataArray.add(diEx);
                     //合计数据汇总
                     totalOperNumber = totalOperNumber.add(diEx.getOperNumber()==null?BigDecimal.ZERO:diEx.getOperNumber());

+ 5 - 1
src/main/java/com/jsh/erp/exception/GlobalExceptionHandler.java

@@ -9,6 +9,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestControllerAdvice;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Map;
 
 @Slf4j
 @RestControllerAdvice
@@ -34,7 +36,9 @@ public class GlobalExceptionHandler {
         }
 
         status.put(ExceptionConstants.GLOBAL_RETURNS_CODE, ExceptionConstants.SERVICE_SYSTEM_ERROR_CODE);
-        status.put(ExceptionConstants.GLOBAL_RETURNS_DATA, ExceptionConstants.SERVICE_SYSTEM_ERROR_MSG);
+        Map<String, Object> objectMap = new HashMap<>();
+        objectMap.put("message", ExceptionConstants.SERVICE_SYSTEM_ERROR_MSG);
+        status.put(ExceptionConstants.GLOBAL_RETURNS_DATA, objectMap);
         log.error("Global Exception Occured => url : {}, msg : {}", request.getRequestURL(), e.getMessage());
         /**
          * 这里输出完整的堆栈信息,否则有些异常完全不知道哪里出错了。

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

@@ -14,6 +14,7 @@ import com.jsh.erp.datasource.pda.vo.PDADepotHeadVO;
 import com.jsh.erp.datasource.vo.AuditNodeVo;
 import com.jsh.erp.datasource.vo.AuditVo;
 import com.jsh.erp.exception.BusinessRunTimeException;
+import com.jsh.erp.exception.ServiceException;
 import com.jsh.erp.query.LambdaQueryWrapperX;
 import com.jsh.erp.service.*;
 import com.jsh.erp.utils.PageUtils;
@@ -109,7 +110,7 @@ public class AuditServiceImpl extends ServiceImpl<AuditMapper, Audit> implements
             }
         } catch (Exception e) {
             log.error("创建审核流程失败", e);
-            return false;
+            throw new ServiceException(e.getMessage());
         }
         return true;
     }

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

@@ -16,6 +16,7 @@ import com.jsh.erp.datasource.pda.vo.PDADepotHeadVO;
 import com.jsh.erp.datasource.vo.*;
 import com.jsh.erp.exception.BusinessRunTimeException;
 import com.jsh.erp.exception.JshException;
+import com.jsh.erp.exception.ServiceException;
 import com.jsh.erp.query.LambdaQueryWrapperX;
 import com.jsh.erp.query.QueryWrapperX;
 import com.jsh.erp.service.*;
@@ -175,7 +176,7 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
                     .eq("id",pdaDepotHeadDTO.getId()));
         }catch (Exception e){
             logger.info("复核任务设置失败!",e);
-            return false;
+            throw new ServiceException(e.getMessage());
         }
         return true;
     }
@@ -231,10 +232,12 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
             Map<Long,String> accountMap = accountService.getAccountMap();
             beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME);
             endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
-            PageUtils.startPage();
-            list = depotHeadMapperEx.selectByConditionDepotHead(type, subType, creatorArray, hasDebt,
-                    statusArray, purchaseStatusArray, number, linkApply, linkNumber, beginTime, endTime,
-                    materialParam, organId, organArray, creator, depotId, depotArray, accountId, remark);
+            if (null != depotArray && depotArray.length > 0){
+                PageUtils.startPage();
+                list = depotHeadMapperEx.selectByConditionDepotHead(type, subType, creatorArray, hasDebt,
+                        statusArray, purchaseStatusArray, number, linkApply, linkNumber, beginTime, endTime,
+                        materialParam, organId, organArray, creator, depotId, depotArray, accountId, remark);
+            }
             if (null != list) {
                 List<Long> idList = new ArrayList<>();
                 List<String> numberList = new ArrayList<>();
@@ -338,9 +341,7 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
     @Override
     public String[] getDepotArray(String subType) throws Exception {
         String [] depotArray = null;
-        if(!BusinessConstants.SUB_TYPE_PURCHASE_APPLY.equals(subType)
-                && !BusinessConstants.SUB_TYPE_PURCHASE_ORDER.equals(subType)
-                && !BusinessConstants.SUB_TYPE_SALES_ORDER.equals(subType)) {
+        if(!BusinessConstants.SUB_TYPE_PURCHASE_APPLY.equals(subType)) {
             String depotIds = depotService.findDepotStrByCurrentUser();
             depotArray = StringUtil.isNotEmpty(depotIds) ? depotIds.split(",") : null;
         }

+ 4 - 6
src/main/java/com/jsh/erp/service/impl/MaterialBatchServiceImpl.java

@@ -3,14 +3,13 @@ package com.jsh.erp.service.impl;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jsh.erp.constants.BusinessConstants;
-import com.jsh.erp.constants.ExceptionConstants;
 import com.jsh.erp.datasource.entities.*;
 import com.jsh.erp.datasource.mappers.MaterialBatchMapper;
 import com.jsh.erp.datasource.mappers.MaterialExtendMapper;
 import com.jsh.erp.datasource.mappers.MaterialInitialStockMapper;
 import com.jsh.erp.datasource.vo.TaskStocktakingItemVO;
-import com.jsh.erp.exception.BusinessRunTimeException;
 import com.jsh.erp.exception.JshException;
+import com.jsh.erp.exception.ServiceException;
 import com.jsh.erp.query.LambdaQueryWrapperX;
 import com.jsh.erp.service.*;
 import com.jsh.erp.utils.DateUtils;
@@ -155,6 +154,7 @@ public class MaterialBatchServiceImpl extends ServiceImpl<MaterialBatchMapper,Ma
                     BigDecimal inventory = materialBatch.getInventory().subtract(basicNumber);
                     materialBatch.setInventory(inventory);
                     updateInventory("出库",diId,materialBatch);
+                    basicNumber = BigDecimal.ZERO;
                     break;
                 }else {
                     //库存不足,扣除当前批次库存,继续循环
@@ -164,8 +164,7 @@ public class MaterialBatchServiceImpl extends ServiceImpl<MaterialBatchMapper,Ma
                 }
             }
             if (basicNumber.compareTo(BigDecimal.ZERO) > 0){
-                throw new BusinessRunTimeException(ExceptionConstants.SERVICE_SYSTEM_ERROR_CODE,
-                        "商品库存不足");
+                throw new ServiceException("商品库存不足");
             }
         }
     }
@@ -246,8 +245,7 @@ public class MaterialBatchServiceImpl extends ServiceImpl<MaterialBatchMapper,Ma
      */
     @Override
     public List<TaskStocktakingItemVO> getMaterialByBatchNumber(String[] batchNumbers) {
-        List<TaskStocktakingItemVO> list =  materialBatchMapper.getMaterialByBatchNumber(batchNumbers);
-        return list;
+        return materialBatchMapper.getMaterialByBatchNumber(batchNumbers);
     }
 
 }

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

@@ -644,8 +644,6 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
         if (depotList.size() > 1){
             depotName2 = depotList.get(1).getName();
         }
-//        String nameStr = "名称*,规格,型号,颜色,品牌,类别,基础重量(kg),基本单位*,副单位,比例,多属性," +
-//                "状态*,序列号,系统sku,商品条码,默认采购价,默认销售价,自定义1,自定义2,自定义3,备注";
         String nameStr = "SPU编码(可留空),SKU编码(可留空),商品名称(SPU级)*,品牌,类目*,商品效期," + depotName1 + "*," + depotName2 + ",规格*,默认采购价*,默认销售价*," +
                 "基础单位*,是否启用*,UPC1*,UPC2,UPC3,UPC4,UPC5,单位1,单位1换算关系,单位2,单位2换算关系,单位3,单位3换算关系,单位4,单位4换算关系,单位5,单位5换算关系";
         List<String> nameList = StringUtil.strToStringList(nameStr);

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

@@ -36,8 +36,6 @@ import java.util.stream.Collectors;
 @Slf4j
 public class TaskStocktakingServiceImpl extends ServiceImpl<TaskStocktakingMapper, TaskStocktaking> implements TaskStocktakingService {
 
-    private final MaterialExtendMapper materialExtendMapper;
-
     private final UserMapper userMapper;
 
     private final DepotMapper depotMapper;

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

@@ -973,7 +973,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
     public Long getAuditUserIds(Long uid, boolean isParent) {
         Organization organization = orgaUserRelService.getOrganizationByUid(uid);
         Long orgaId = organization.getId();
-        if (isParent){
+        if (isParent && organization.getParentId() != null){
             orgaId = organization.getParentId();
         }
         return userMapper.getAuditUserIds(orgaId);

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

@@ -48,7 +48,7 @@
                 AND u.username LIKE CONCAT('%',#{initiatorName},'%')
             </if>
             <if test="auditStatus != null">
-                AND an.audit_result = #{auditStatus}
+                AND a.audit_status = #{auditStatus}
             </if>
             <if test="beginTime != null">
                 AND an.audit_time >= #{beginTime}

+ 1 - 0
src/main/resources/mapper_xml/UserMapper.xml

@@ -404,6 +404,7 @@
       username AS label
     FROM
       jsh_user
+    WHERE IFNULL(delete_flag,'1') != 1
   </select>
 
   <select id="getAuditUserIds" parameterType="java.lang.Long" resultType="java.lang.Long">