Explorar o código

网点新件入库

FengChaoYu hai 8 meses
pai
achega
e76f542431

+ 125 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/material/manage/WebsitNewInListBean.java

@@ -0,0 +1,125 @@
+package com.gree.mall.manager.bean.material.manage;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@ApiModel
+@Data
+public class WebsitNewInListBean {
+
+    @ApiModelProperty("id")
+    private String id;
+
+    @ApiModelProperty("凭证号")
+    private String voucherNo;
+
+    @ApiModelProperty("申请单号")
+    private String applyNo;
+
+    @ApiModelProperty("开单备注")
+    private String remark;
+
+    @ApiModelProperty("事物类型")
+    private String objectType;
+
+    @ApiModelProperty("配件编码")
+    private String partsNumber;
+
+    @ApiModelProperty("配件名称")
+    private String partsName;
+
+    @ApiModelProperty("物料组名称")
+    private String materialGroupName;
+
+    @ApiModelProperty("单位")
+    private String goodsStockUnit;
+
+    @ApiModelProperty("单价")
+    private BigDecimal price;
+
+    @ApiModelProperty("数量")
+    private BigDecimal qty;
+
+    @ApiModelProperty("新件编码(退旧件)")
+    private String newNo;
+
+    @ApiModelProperty("原价价格")
+    private BigDecimal primaryPrice;
+
+    @ApiModelProperty("折扣价格")
+    private BigDecimal discPrice;
+
+    @ApiModelProperty("优惠价格(实收)")
+    private BigDecimal realPrice;
+
+    @ApiModelProperty("新旧差价")
+    private BigDecimal diffPrice;
+
+    @ApiModelProperty("发出单位")
+    private String sendUnit;
+
+    @ApiModelProperty("领入单位")
+    private String receiveUnit;
+
+    @ApiModelProperty("发出网点编号")
+    private String sendShopId;
+
+    @ApiModelProperty("发出网点名称")
+    private String sendShopName;
+
+    @ApiModelProperty("发出配件网点编号")
+    private String sendPartsWebsiteNumber;
+
+    @ApiModelProperty("领入网点编号")
+    private String receiveShopId;
+
+    @ApiModelProperty("领入网点名称")
+    private String receiveShopName;
+
+    @ApiModelProperty("领入配件网点编号")
+    private String receivePartsWebsiteNumber;
+
+    @ApiModelProperty("开单日期")
+    private Date orderDate;
+
+    @ApiModelProperty("系统序号")
+    private String sysNo;
+
+    @ApiModelProperty("验收日期")
+    private Date receiveDate;
+
+    @ApiModelProperty("开单人")
+    private String operateBy;
+
+    @ApiModelProperty("发出单位区域")
+    private String sendUnitArea;
+
+    @ApiModelProperty("领入单位区域")
+    private String receiveUnitArea;
+
+    @ApiModelProperty("维修自编号")
+    private String repairCustomNo;
+
+    @ApiModelProperty("导入日期")
+    private Date importDate;
+
+    @ApiModelProperty("验收状态")
+    private String status;
+
+    @ApiModelProperty("创建人")
+    private String createBy;
+
+    @ApiModelProperty("创建时间")
+    private Date createTime;
+
+    @ApiModelProperty("验收人")
+    private String checkBy;
+
+    @ApiModelProperty("验收时间")
+    private Date checkTime;
+
+}

+ 16 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/material/manage/WebsitPartsNewInRecordDTO.java

@@ -0,0 +1,16 @@
+package com.gree.mall.manager.bean.material.manage;
+
+import com.gree.mall.manager.plus.entity.AdminWebsit;
+import com.gree.mall.manager.plus.entity.WebsitPartsNewInRecord;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel
+public class WebsitPartsNewInRecordDTO extends WebsitPartsNewInRecord {
+    @ApiModelProperty("网点")
+    AdminWebsit adminWebsit;
+}

+ 127 - 0
mall-server-api/src/main/java/com/gree/mall/manager/bean/material/manage/WebsitPartsNewInVO.java

@@ -0,0 +1,127 @@
+package com.gree.mall.manager.bean.material.manage;
+
+import com.gree.mall.manager.annotation.ZfireField;
+import com.gree.mall.manager.enums.material.PartsCheckStatusEnum;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+@ApiModel
+@ZfireField(tbName = "a")
+public class WebsitPartsNewInVO {
+    @ZfireField(hide = true)
+    @ApiModelProperty("id")
+    private String id;
+
+    @ApiModelProperty("凭证号")
+    private String voucherNo;
+
+    @ApiModelProperty("申请单号")
+    private String applyNo;
+
+    @ApiModelProperty("开单备注")
+    private String remark;
+
+    @ApiModelProperty("事物类型")
+    private String objectType;
+
+    @ApiModelProperty("配件编码")
+    private String partsNumber;
+
+    @ApiModelProperty("配件名称")
+    private String partsName;
+
+    @ApiModelProperty("物料组名称")
+    private String materialGroupName;
+
+    @ApiModelProperty("单位")
+    private String goodsStockUnit;
+
+    @ApiModelProperty("单价")
+    private BigDecimal price;
+
+    @ApiModelProperty("数量")
+    private BigDecimal qty;
+
+    @ApiModelProperty("新件编码(退旧件)")
+    private String newNo;
+
+    @ApiModelProperty("原价价格")
+    private BigDecimal primaryPrice;
+
+    @ApiModelProperty("折扣价格")
+    private BigDecimal discPrice;
+
+    @ApiModelProperty("优惠价格(实收)")
+    private BigDecimal realPrice;
+
+    @ApiModelProperty("新旧差价")
+    private BigDecimal diffPrice;
+
+    @ApiModelProperty("发出单位")
+    private String sendUnit;
+
+    @ApiModelProperty("领入单位")
+    private String receiveUnit;
+
+    @ApiModelProperty("发出网点编号")
+    private String sendShopId;
+
+    @ApiModelProperty("发出网点名称")
+    private String sendShopName;
+
+    @ApiModelProperty("发出配件网点编号")
+    private String sendPartsWebsiteNumber;
+
+    @ApiModelProperty("领入网点编号")
+    private String receiveShopId;
+
+    @ApiModelProperty("领入网点名称")
+    private String receiveShopName;
+
+    @ApiModelProperty("领入配件网点编号")
+    private String receivePartsWebsiteNumber;
+
+    @ApiModelProperty("开单日期")
+    private Date orderDate;
+
+    @ApiModelProperty("系统序号")
+    private String sysNo;
+
+    @ApiModelProperty("验收日期")
+    private Date receiveDate;
+
+    @ApiModelProperty("开单人")
+    private String operateBy;
+
+    @ApiModelProperty("发出单位区域")
+    private String sendUnitArea;
+
+    @ApiModelProperty("领入单位区域")
+    private String receiveUnitArea;
+
+    @ApiModelProperty("维修自编号")
+    private String repairCustomNo;
+
+    @ApiModelProperty("导入日期")
+    private Date importDate;
+
+    @ApiModelProperty("验收状态")
+    private PartsCheckStatusEnum status;
+
+    @ApiModelProperty("创建人")
+    private String createBy;
+
+    @ApiModelProperty("创建时间")
+    private Date createTime;
+
+    @ApiModelProperty("验收人")
+    private String checkBy;
+
+    @ApiModelProperty("验收时间")
+    private Date checkTime;
+}

+ 8 - 0
mall-server-api/src/main/java/com/gree/mall/manager/commonmapper/MaterialMapper.java

@@ -250,4 +250,12 @@ public interface MaterialMapper {
      * @return
      */
     IPage<WebsitPurchaseAdjustmentVO> websitPurchaseAdjustmentPage(Page page, @Param("ex") ZfireParamBean zfireParamBean);
+
+    /**
+     * 配件入库列表
+     * @param page
+     * @param zfireParamBean
+     * @return
+     */
+    IPage<WebsitPartsNewInVO> websitPartsNewInPage(Page page, @Param("ex") ZfireParamBean zfireParamBean);
 }

+ 2 - 0
mall-server-api/src/main/java/com/gree/mall/manager/constant/Constant.java

@@ -82,6 +82,8 @@ public class Constant {
         public final static String ISSUE_SAL_MOBILE_SMS = "jsm:SETTLE:ISSUE:SMS";
         public final static String LOCK_SUMMARY_ISSUE = "jsm:SETTLE:lock:issue:summary";
         public static final String LOCK_MATERIAL_PURCHASE = "jsm:sxb:material:purchase:";
+
+        public final static String NEW_IN = "jsm:parts:new:in:";
     }
     public class ChatMessage {
         public final static String MSG_TYPE_DOC = "docmsg";

+ 149 - 0
mall-server-api/src/main/java/com/gree/mall/manager/controller/material/manage/WebsitPartsNewInController.java

@@ -0,0 +1,149 @@
+package com.gree.mall.manager.controller.material.manage;
+
+import cn.hutool.core.lang.TypeReference;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.gree.mall.manager.annotation.ZfireList;
+import com.gree.mall.manager.bean.material.manage.WebsitNewInListBean;
+import com.gree.mall.manager.bean.material.manage.WebsitPartsNewInVO;
+import com.gree.mall.manager.constant.Constant;
+import com.gree.mall.manager.exception.RemoteServiceException;
+import com.gree.mall.manager.helper.ResponseHelper;
+import com.gree.mall.manager.logic.material.manage.WebsitPartsNewInLogic;
+import com.gree.mall.manager.utils.excel.ExcelUtils;
+import com.gree.mall.manager.zfire.bean.ZfireParamBean;
+import com.gree.mall.manager.zfire.util.FieldUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.integration.redis.util.RedisLockRegistry;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Lock;
+
+@Slf4j
+@RestController
+@Api(value = "网点新件入库记录", tags ={"网点新件入库记录"} )
+@RequestMapping(value = "/websit/parts/new-in", produces = "application/json; charset=utf-8")
+public class WebsitPartsNewInController {
+
+    @Resource
+    WebsitPartsNewInLogic websitPartsNewInLogic;
+    @Resource
+    RedisLockRegistry redisLockRegistry;
+
+    @ZfireList
+    @PostMapping("/list")
+    @ApiOperation("列表")
+    public ResponseHelper<IPage<WebsitPartsNewInVO>> list(
+            @RequestBody ZfireParamBean zfireParamBean
+    ) throws RemoteServiceException {
+        IPage<WebsitPartsNewInVO> partsBeanIPage = websitPartsNewInLogic.pageList(zfireParamBean);
+        return ResponseHelper.success(partsBeanIPage, new TypeReference<WebsitPartsNewInVO>() {});
+    }
+
+    @PostMapping("/list/export")
+    @ApiOperation("列表导出")
+    public void listExport(
+            @RequestBody ZfireParamBean zfireParamBean,
+            HttpServletRequest request,
+            HttpServletResponse response
+    ) throws Exception {
+        //2.查询要导出的内容
+        IPage<WebsitPartsNewInVO> baseVOIPage = websitPartsNewInLogic.pageList(zfireParamBean);
+        //3.导出
+        FieldUtils.exportData(baseVOIPage.getRecords(), zfireParamBean.getExportFields(), request, response);
+    }
+
+    @PostMapping("/import")
+    @ApiOperation("导入网点新件入库记录")
+    public ResponseHelper importOldOut(
+            MultipartFile file
+    ) throws Exception {
+        Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.NEW_IN + "add");
+        if (!obtain.tryLock(10, TimeUnit.SECONDS)) {
+            throw new RemoteServiceException("请稍候再导入...");
+        }
+        try {
+            List<Object> objects = ExcelUtils.importExcel(file);
+            websitPartsNewInLogic.importNewIn(objects);
+        } catch(Exception e) {
+            log.error("【网点新件入库记录处理】失败", e);
+            throw e;
+        } finally {
+            obtain.unlock();
+        }
+        return ResponseHelper.success();
+    }
+
+    @ApiOperation(value = "新增网点新件入库记录")
+    @PostMapping("/add")
+    public ResponseHelper add(
+            @ApiParam(required = true, value = "网点新件入库记录") @RequestBody List<WebsitNewInListBean> websitNewInListBean
+    ) throws Exception {
+        Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.NEW_IN + "add");
+        if (!obtain.tryLock(10, TimeUnit.SECONDS)) {
+            throw new RemoteServiceException("请稍候再操作...");
+        }
+        try {
+            websitPartsNewInLogic.add(websitNewInListBean);
+        } catch(Exception e) {
+            log.error("【网点新件入库记录处理】失败", e);
+            throw e;
+        } finally {
+            obtain.unlock();
+        }
+
+        return ResponseHelper.success();
+    }
+
+    @ApiOperation(value = "更新网点新件入库记录")
+    @PostMapping("/update")
+    public ResponseHelper updateIn(
+            @ApiParam(required = true, value = "网点新件入库记录id") @RequestParam List<String> ids
+    ) throws Exception {
+        Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.NEW_IN + "add");
+        if (!obtain.tryLock(10, TimeUnit.SECONDS)) {
+            throw new RemoteServiceException("请稍候再操作...");
+        }
+        try {
+            websitPartsNewInLogic.updateIn(ids);
+        } catch(Exception e) {
+            log.error("【网点新件入库记录处理】失败", e);
+            throw e;
+        } finally {
+            obtain.unlock();
+        }
+
+        return ResponseHelper.success();
+    }
+
+    @ApiOperation(value = "删除网点新件入库记录")
+    @PostMapping("/del")
+    public ResponseHelper delNewIn(
+            @ApiParam(required = true, value = "网点新件入库记录id") @RequestParam List<String> ids
+    ) throws Exception {
+        Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.NEW_IN + "add");
+        if (!obtain.tryLock(10, TimeUnit.SECONDS)) {
+            throw new RemoteServiceException("请稍候再操作...");
+        }
+        try {
+            websitPartsNewInLogic.delNewIn(ids);
+        } catch(Exception e) {
+            log.error("【网点旧件出库记录处理】失败", e);
+            throw e;
+        } finally {
+            obtain.unlock();
+        }
+
+        return ResponseHelper.success();
+    }
+
+
+}

+ 21 - 0
mall-server-api/src/main/java/com/gree/mall/manager/enums/material/PartsCheckStatusEnum.java

@@ -0,0 +1,21 @@
+package com.gree.mall.manager.enums.material;
+
+import com.baomidou.mybatisplus.annotation.EnumValue;
+import com.fasterxml.jackson.annotation.JsonValue;
+import com.gree.mall.manager.enums.base.BaseEnum;
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+@Getter
+@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
+public enum PartsCheckStatusEnum implements BaseEnum {
+    CHECKED("CHECKED","已验收"),
+    WAIT_CHECK("WAIT_CHECK","未验收");
+
+    @EnumValue
+    @JsonValue
+    private final String key;
+
+    private final String remark;
+}

+ 330 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/material/manage/WebsitPartsNewInLogic.java

@@ -0,0 +1,330 @@
+package com.gree.mall.manager.logic.material.manage;
+
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.ReUtil;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gree.mall.manager.bean.admin.AdminUserCom;
+import com.gree.mall.manager.bean.material.manage.WebsitNewInListBean;
+import com.gree.mall.manager.bean.material.manage.WebsitPartsNewInRecordDTO;
+import com.gree.mall.manager.bean.material.manage.WebsitPartsNewInVO;
+import com.gree.mall.manager.commonmapper.MaterialMapper;
+import com.gree.mall.manager.enums.IsEnum;
+import com.gree.mall.manager.enums.material.NormTypeEnum;
+import com.gree.mall.manager.enums.material.PartsCheckStatusEnum;
+import com.gree.mall.manager.enums.material.WebsitGoodsTypeEnum;
+import com.gree.mall.manager.exception.RemoteServiceException;
+import com.gree.mall.manager.logic.common.CommonLogic;
+import com.gree.mall.manager.logic.material.stock.WebitPurchaseStockLogic;
+import com.gree.mall.manager.plus.entity.*;
+import com.gree.mall.manager.plus.service.*;
+import com.gree.mall.manager.zfire.bean.ZfireParamBean;
+import com.gree.mall.manager.zfire.util.FieldUtils;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class WebsitPartsNewInLogic {
+
+    private final CommonLogic commonLogic;
+    private final MaterialMapper materialMapper;
+    private final WebsitPartsNewInRecordService websitPartsNewInRecordService;
+    private final AdminWebsitService adminWebsitService;
+    private final WebsitGoodsService websitGoodsService;
+    private final WebitPurchaseStockLogic webitPurchaseStockLogic;
+    private final StorageService storageService;
+    private final WebsitPartsNewInRecordBakService websitPartsNewInRecordBakService;
+
+    public IPage<WebsitPartsNewInVO> pageList(ZfireParamBean zfireParamBean) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        FieldUtils.materialParam(zfireParamBean, WebsitPartsNewInVO.class, adminUser);
+        IPage<WebsitPartsNewInVO> page = materialMapper.websitPartsNewInPage(new Page(zfireParamBean.getPageNum(), zfireParamBean.getPageSize()), zfireParamBean);
+        return page;
+    }
+
+    @Transactional
+    public void importNewIn(List<Object> objects) {
+        if (objects.size() > 0) {
+            // 注入对象
+            List<WebsitPartsNewInRecordDTO> newInRecordDTOList = this.handleNewInRecordObj(objects);
+            for (WebsitPartsNewInRecordDTO newInRecordDTO : newInRecordDTOList) {
+                Integer count = websitPartsNewInRecordService.lambdaQuery()
+                        .eq(WebsitPartsNewInRecord::getSysNo, newInRecordDTO.getSysNo())
+                        .count();
+                if (count > 0) {
+                    // 已经处理过的系统序号就跳过
+                    continue;
+                }
+                websitPartsNewInRecordService.save(newInRecordDTO);
+            }
+        }
+    }
+
+    private List<WebsitPartsNewInRecordDTO> handleNewInRecordObj(List<Object> objects) {
+        DateTime curDate = DateUtil.date();
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+
+        if (adminUser.getType() == 2) {
+            throw new RemoteServiceException("平台账号禁止操作");
+        }
+
+        final List<AdminWebsit> websitList = adminWebsitService.lambdaQuery()
+                .in(AdminWebsit::getWebsitId, adminUser.getAdminWebsitIds())
+                .isNotNull(AdminWebsit::getPartsWebsitId)
+                .list();
+
+        Map<String, AdminWebsit> websitMap = websitList.stream()
+                .collect(Collectors.toMap(AdminWebsit::getPartsWebsitId, Function.identity()));
+
+        // 查询配件资料
+        final List<WebsitGoods> partsList = websitGoodsService.lambdaQuery()
+                .eq(WebsitGoods::getGoodsCode, objects.stream()
+                        .map(v -> (Optional.ofNullable(((List<Object>) v).get(4))).orElse(""))
+                        .collect(Collectors.toSet()))
+                .eq(WebsitGoods::getGoodsType, WebsitGoodsTypeEnum.P.getKey())
+                .eq(WebsitGoods::getNormType, NormTypeEnum.M.getKey())
+                .list();
+
+        Map<String, WebsitGoods> partsMap = partsList.stream()
+                .collect(Collectors.toMap(WebsitGoods::getGoodsCode, Function.identity()));
+
+        final List<Storage> storageList = storageService.lambdaQuery()
+                .eq(Storage::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
+                .in(Storage::getWebsitId, adminUser.getAdminWebsitIds())
+                .eq(Storage::getIsDefault, IsEnum.Y.getValue())
+                .list();
+
+        Map<String, Storage> storageMap = storageList.stream()
+                .collect(Collectors.toMap(Storage::getWebsitId, Function.identity()));
+
+        List<WebsitPartsNewInRecordDTO> inRecordDTOS = new ArrayList<>();
+        for (int i = 1; i < objects.size(); i++) {
+            List<Object> row = (List<Object>) objects.get(i);
+            String voucherNo = (String) row.get(0);
+            String applyNo = (String) row.get(1);
+            String remark = (String) row.get(2);
+            String objectType = (String) row.get(3);
+            String partsNumber = (String) row.get(4);
+            String priceStr = (String) row.get(7);
+            String qtyStr = (String) row.get(8);
+            String newNo = (String) row.get(9);
+            String primaryPriceStr = (String) row.get(10);
+            String discPriceStr = (String) row.get(11);
+            String realPriceStr = (String) row.get(12);
+            String diffPriceStr = (String) row.get(13);
+            String sendUnit = (String) row.get(14);
+            String receiveUnit = (String) row.get(15);
+            String orderDateStr = (String) row.get(16);
+            String sysNo = (String) row.get(17);
+            String receiveDate = (String) row.get(18);
+            String operateBy = (String) row.get(19);
+            String sendUnitArea = (String) row.get(20);
+            String receiveUnitArea = (String) row.get(21);
+            String repairCustomNo = (String) row.get(22);
+            if (StringUtils.isBlank(objectType) || !"新件申领".contains(objectType)) {
+                throw new RemoteServiceException("第" + (i+2) + "行,事物类型格式不符,只能是“新件申领”");
+            }
+            if (StringUtils.isBlank(voucherNo)) {
+                throw new RemoteServiceException("第" + (i+2) + "行,凭证号不能为空");
+            }
+            if (StringUtils.isBlank(partsNumber)) {
+                throw new RemoteServiceException("第" + (i+2) + "行,配件编码不能为空");
+            }
+            if (StringUtils.isBlank(receiveUnit) || receiveUnit.indexOf(":") <= 0) {
+                throw new RemoteServiceException("第" + (i+2) + "行,领入单位格式不符");
+            }
+            if (StringUtils.isBlank(orderDateStr) || !ReUtil.isMatch("^\\d{4}-\\d{1,2}-\\d{1,2}\\s\\d{1,2}:\\d{1,2}:\\d{1,2}", orderDateStr)) {
+                throw new RemoteServiceException("第" + (i+1) + "行,开单日期格式不符");
+            }
+            String receiveUnitNumber = receiveUnit.split(":")[0];
+            AdminWebsit receiveShop = websitMap.get(receiveUnitNumber);
+            WebsitGoods parts = partsMap.get(partsNumber);
+            if (Objects.isNull(receiveShop)) {
+//                throw new RemoteServiceException("第" + (i+2) + "行,领入单位未配置");
+                continue;
+            }
+            if (Objects.isNull(parts)) {
+                throw new RemoteServiceException("第" + (i+2) + "行,配件编码未配置");
+            }
+            if (StringUtils.isBlank(sysNo)) {
+                throw new RemoteServiceException("第" + (i+2) + "行,系统序号不能为空");
+            }
+            final Storage storage = storageMap.get(receiveShop.getWebsitId());
+
+            WebsitPartsNewInRecordDTO partsShopNewInRecordDTO = new WebsitPartsNewInRecordDTO();
+            partsShopNewInRecordDTO.setVoucherNo(voucherNo)
+                    .setCompanyWechatId(adminUser.getAdminCompanyWechat().getCompanyWechatId())
+                    .setCompanyWechatName(adminUser.getAdminCompanyWechat().getCompanyName())
+                    .setApplyNo(applyNo)
+                    .setRemark(remark)
+                    .setObjectType(objectType.trim())
+                    .setGoodsId(parts.getGoodsId())
+                    .setPartsNumber(partsNumber)
+                    .setPartsName(parts.getGoodsName())
+                    .setMaterialGroupName(parts.getMaterialGroupName())
+                    .setMaterialGroupName(parts.getMaterialGroupName())
+                    .setGoodsStockUnit(parts.getGoodsStockUnit())
+                    .setPrice(new BigDecimal(StringUtils.isNotBlank(priceStr) ? priceStr : "0"))
+                    .setQty(new BigDecimal(StringUtils.isNotBlank(qtyStr) ? qtyStr : "0"))
+                    .setNewNo(newNo)
+                    .setPrimaryPrice(new BigDecimal(StringUtils.isNotBlank(primaryPriceStr) ? primaryPriceStr : "0"))
+                    .setDiscPrice(new BigDecimal(StringUtils.isNotBlank(discPriceStr) ? discPriceStr : "0"))
+                    .setRealPrice(new BigDecimal(StringUtils.isNotBlank(realPriceStr) ? realPriceStr : "0"))
+                    .setDiffPrice(new BigDecimal(StringUtils.isNotBlank(diffPriceStr) ? diffPriceStr : "0"))
+                    .setSendUnit(sendUnit)
+                    .setReceiveUnit(receiveUnit)
+                    .setSendWebsitId("")
+                    .setSendWebsitName("")
+                    .setReceiveWebsitId(receiveShop.getWebsitId())
+                    .setReceiveWebsitName(receiveShop.getName())
+                    .setOrderDate(StringUtils.isNotBlank(orderDateStr) ? DateUtil.parseDateTime(orderDateStr) : null)
+                    .setSysNo(sysNo)
+                    .setReceiveDate(StringUtils.isNotBlank(receiveDate) ? DateUtil.parseDate(receiveDate) : null)
+                    .setOperateBy(operateBy)
+                    .setSendUnitArea(sendUnitArea)
+                    .setReceiveUnitArea(receiveUnitArea)
+                    .setRepairCustomNo(repairCustomNo)
+                    .setImportDate(curDate)
+                    .setStatus(PartsCheckStatusEnum.WAIT_CHECK.getKey())
+                    .setStorageId(storage.getStorageId())
+                    .setStorageName(storage.getStorageName());
+            partsShopNewInRecordDTO.setAdminWebsit(receiveShop);
+            inRecordDTOS.add(partsShopNewInRecordDTO);
+        }
+
+        return inRecordDTOS;
+    }
+
+    @Transactional
+    public void add(List<WebsitNewInListBean> websitNewInListBean) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        if (adminUser.getType() == 2) {
+            throw new RemoteServiceException("平台账号禁止操作");
+        }
+        final List<AdminWebsit> websitList = adminWebsitService.lambdaQuery()
+                .in(AdminWebsit::getWebsitId, adminUser.getAdminWebsitIds())
+                .isNotNull(AdminWebsit::getPartsWebsitId)
+                .list();
+
+        Map<String, AdminWebsit> websitMap = websitList.stream()
+                .collect(Collectors.toMap(AdminWebsit::getPartsWebsitId, Function.identity()));
+
+        // 查询配件资料
+        final List<WebsitGoods> partsList = websitGoodsService.lambdaQuery()
+                .eq(WebsitGoods::getGoodsCode, websitNewInListBean.stream()
+                        .map(WebsitNewInListBean::getPartsNumber)
+                        .collect(Collectors.toSet()))
+                .eq(WebsitGoods::getGoodsType, WebsitGoodsTypeEnum.P.getKey())
+                .eq(WebsitGoods::getNormType, NormTypeEnum.M.getKey())
+                .list();
+
+        Map<String, WebsitGoods> partsMap = partsList.stream()
+                .collect(Collectors.toMap(WebsitGoods::getGoodsCode, Function.identity()));
+
+        final List<Storage> storageList = storageService.lambdaQuery()
+                .eq(Storage::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
+                .in(Storage::getWebsitId, adminUser.getAdminWebsitIds())
+                .eq(Storage::getIsDefault, IsEnum.Y.getValue())
+                .list();
+
+        Map<String, Storage> storageMap = storageList.stream()
+                .collect(Collectors.toMap(Storage::getWebsitId, Function.identity()));
+
+        List<WebsitPartsNewInRecord> partsShopNewInRecordList = new ArrayList<>();
+        for (WebsitNewInListBean newInListBean : websitNewInListBean) {
+            WebsitPartsNewInRecord partsShopNewInRecord = new WebsitPartsNewInRecord();
+            AdminWebsit websit = websitMap.get(newInListBean.getReceivePartsWebsiteNumber());
+            if (Objects.isNull(websit)) {
+                throw new RemoteServiceException(newInListBean.getPartsNumber() + ":未找到网点信息");
+            }
+            WebsitGoods parts = partsMap.get(newInListBean.getPartsNumber());
+            if (Objects.isNull(parts)) {
+                throw new RemoteServiceException(newInListBean.getPartsNumber() + ":未找到配件编码");
+            }
+            final Storage storage = storageMap.get(websit.getWebsitId());
+            partsShopNewInRecord.setId(IdWorker.getIdStr())
+                    .setCompanyWechatId(adminUser.getAdminCompanyWechat().getCompanyWechatId())
+                    .setCompanyWechatName(adminUser.getAdminCompanyWechat().getCompanyName())
+                    .setVoucherNo(IdWorker.getIdStr())
+                    .setApplyNo(IdWorker.getIdStr())
+                    .setRemark(newInListBean.getRemark())
+                    .setObjectType("新件入库")
+                    .setGoodsId(parts.getGoodsId())
+                    .setPartsNumber(newInListBean.getPartsNumber())
+                    .setPartsName(parts.getGoodsName())
+                    .setMaterialGroupName(parts.getMaterialGroupName())
+                    .setGoodsStockUnit(parts.getGoodsStockUnit())
+                    .setPrice(newInListBean.getPrice())
+                    .setQty(newInListBean.getQty())
+                    .setReceiveWebsitId(websit.getWebsitId())
+                    .setReceiveWebsitName(websit.getName())
+                    .setOrderDate(DateUtil.date())
+                    .setSysNo(IdWorker.getIdStr())
+                    .setOperateBy(adminUser.getNickName())
+                    .setStatus(PartsCheckStatusEnum.WAIT_CHECK.getKey())
+                    .setStorageId(storage.getStorageId())
+                    .setStorageName(storage.getStorageName());
+
+            partsShopNewInRecordList.add(partsShopNewInRecord);
+        }
+        websitPartsNewInRecordService.saveBatch(partsShopNewInRecordList);
+    }
+
+    @Transactional
+    public void updateIn(List<String> ids) throws Exception {
+        DateTime curDate = DateUtil.date();
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        List<WebsitPartsNewInRecord> partsShopNewInRecords = websitPartsNewInRecordService.lambdaQuery()
+                .in(WebsitPartsNewInRecord::getId, ids)
+                .list();
+
+        if (CollectionUtil.isNotEmpty(partsShopNewInRecords)) {
+            final List<WebsitPartsNewInRecord> collect = partsShopNewInRecords.stream()
+                    .peek(v -> v.setCheckBy(adminUser.getNickName())
+                            .setCheckTime(curDate)
+                            .setStatus(PartsCheckStatusEnum.CHECKED.getKey()))
+                    .collect(Collectors.toList());
+            Map<String, List<WebsitPartsNewInRecord>> listMap = collect.stream()
+                    .collect(Collectors.groupingBy(WebsitPartsNewInRecord::getReceiveWebsitId));
+
+            for (List<WebsitPartsNewInRecord> shopNewInRecords : listMap.values()) {
+                webitPurchaseStockLogic.newInStock(shopNewInRecords);
+            }
+            websitPartsNewInRecordService.saveOrUpdateBatch(collect);
+        }
+    }
+
+    public void delNewIn(List<String> ids) {
+        List<WebsitPartsNewInRecord> partsShopNewInRecords = websitPartsNewInRecordService.lambdaQuery()
+                .in(WebsitPartsNewInRecord::getId, ids)
+                .eq(WebsitPartsNewInRecord::getStatus, PartsCheckStatusEnum.WAIT_CHECK.getKey())
+                .list();
+
+        websitPartsNewInRecordService.lambdaUpdate()
+                .in(WebsitPartsNewInRecord::getId, ids)
+                .eq(WebsitPartsNewInRecord::getStatus, PartsCheckStatusEnum.WAIT_CHECK.getKey())
+                .remove();
+
+        List<WebsitPartsNewInRecordBak> partsShopNewInRecordBakList = new ArrayList<>();
+        for (WebsitPartsNewInRecord websitPartsNewInRecord : partsShopNewInRecords) {
+            WebsitPartsNewInRecordBak partsShopNewInRecordBak = new WebsitPartsNewInRecordBak();
+            BeanUtils.copyProperties(websitPartsNewInRecord, partsShopNewInRecordBak);
+            partsShopNewInRecordBakList.add(partsShopNewInRecordBak);
+        }
+        websitPartsNewInRecordBakService.saveBatch(partsShopNewInRecordBakList);
+    }
+}

+ 36 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/material/stock/WebitPurchaseStockLogic.java

@@ -158,6 +158,41 @@ public class WebitPurchaseStockLogic {
         websitGoodsStockLogic.handleWebsitStock(shopStockDTOS);
     }
 
+    public void newInStock(List<WebsitPartsNewInRecord> shopNewInRecords) throws Exception {
+        List<WebsitStockDTO> shopStockDTOS = new ArrayList<>();
+        for (WebsitPartsNewInRecord inRecord : shopNewInRecords) {
+            // 入库注值
+            WebsitStockDTO websitStockDTO = new WebsitStockDTO();
+            websitStockDTO.setCompanyWechatId(inRecord.getCompanyWechatId());
+            websitStockDTO.setCompanyWechatName(inRecord.getCompanyWechatName());
+            websitStockDTO.setWebsitId(inRecord.getReceiveWebsitId());
+            websitStockDTO.setWebsitName(inRecord.getReceiveWebsitName());
+            websitStockDTO.setSdate(inRecord.getCreateTime());
+            websitStockDTO.setPartsAttr(PartsAttrEnum.NEW.toString());
+            websitStockDTO.setGoodsId(inRecord.getPartsNumber());
+            websitStockDTO.setGoodsName(inRecord.getPartsName());
+            websitStockDTO.setGoodsType(WebsitGoodsTypeEnum.P.getKey());
+            websitStockDTO.setPrice(inRecord.getPrice());
+            websitStockDTO.setRef(inRecord.getId());
+            websitStockDTO.setRefType(inRecord.getObjectType());
+            websitStockDTO.setChangeQty(inRecord.getQty());
+            websitStockDTO.setDirectFlag(DirectFlagEnum.ADD.getKey());
+            websitStockDTO.setRemark(inRecord.getRemark());
+            websitStockDTO.setOperateBy(inRecord.getCheckBy());
+            websitStockDTO.setOperateTime(inRecord.getCheckTime());
+            websitStockDTO.setObj("网点");
+            websitStockDTO.setStorageId(inRecord.getStorageId());
+            shopStockDTOS.add(websitStockDTO);
+        }
+
+        if (CollectionUtil.isEmpty(shopStockDTOS)) {
+            return;
+        }
+
+        // 开始处理库存
+        websitGoodsStockLogic.handleWebsitStock(shopStockDTOS);
+    }
+
     public Storage handleStorage(AdminUserCom adminUser, String websitId, String goodsType, String storageId) {
 //        String storageType = goodsType.equals(WebsitGoodsTypeEnum.M.getKey()) ? WebsitGoodsTypeEnum.M.getRemark() : WebsitGoodsTypeEnum.P.getRemark();
 //        if (adminUser.getAdminCompanyWechat().getJoinCode().equals("NO")) {
@@ -196,4 +231,5 @@ public class WebitPurchaseStockLogic {
     }
 
 
+
 }

+ 19 - 0
mall-server-api/src/main/resources/mapper/MaterialMapper.xml

@@ -502,4 +502,23 @@
         </if>
         ${ex.orderBy}
     </select>
+
+    <select id="websitPartsNewInPage"
+            resultType="com.gree.mall.manager.bean.material.manage.WebsitPartsNewInVO">
+        SELECT
+            ${ex.selected}
+        FROM
+            websit_parts_new_in_record a
+        ${ex.query}
+        <if test="ex.adminWebsitIds != null and ex.adminWebsitIds.size > 0">
+            AND a.receive_websit_id IN
+            <foreach item="item" index="index" collection="ex.adminWebsitIds" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="ex.orderBy == null or ex.orderBy ==''">
+            ORDER BY a.create_time DESC
+        </if>
+        ${ex.orderBy}
+    </select>
 </mapper>