skyouc
2 天以前 902ec017c2c6b01bacc67a0a65fbb5a53a951c1e
rsf-server/src/main/java/com/vincent/rsf/server/api/controller/erp/ReceiveMsgController.java
@@ -1,30 +1,25 @@
package com.vincent.rsf.server.api.controller.erp;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.vincent.rsf.framework.common.R;
import com.vincent.rsf.server.api.service.ReceiveMsgService;
import com.vincent.rsf.framework.exception.CoolException;
import com.vincent.rsf.server.api.controller.erp.params.*;
import com.vincent.rsf.server.api.service.ReceiveMsgService;
import com.vincent.rsf.server.common.domain.BaseParam;
import com.vincent.rsf.server.common.domain.PageParam;
import com.vincent.rsf.server.common.utils.ExcelUtil;
import com.vincent.rsf.framework.common.R;
import com.vincent.rsf.server.manager.entity.Loc;
import com.vincent.rsf.server.manager.entity.excel.AsnOrderTemplate;
import com.vincent.rsf.server.manager.service.MatnrGroupService;
import com.vincent.rsf.server.manager.service.MatnrService;
import com.vincent.rsf.server.system.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.ApiOperation;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -37,91 +32,33 @@
 */
@RestController
@RequestMapping("/erp")
//@Api(tags = "三方接口文档")
@Api(tags = "综合查询")
public class ReceiveMsgController extends BaseController {
    @Autowired
    private ReceiveMsgService receiveMsgService;
    @Autowired
    private MatnrService matnrService;
    @Autowired
    private MatnrGroupService matnrGroupService;
    /**
     * @author Ryan
     * @description 接收ERP推送的PO单据
     * @throws
     * @return
     * @time 2025/3/4 13:57
     */
    @ApiOperation(value = "接收同步ERP采购单", tags = "单据同步")
    @PostMapping("/sync/purchase")
    public R syncPurchases(@RequestBody List<OrderParams> orders) {
        if (orders.isEmpty()) {
            return R.error("推送订单不能为空,请检查校验后再操作!!");
        }
        if (!receiveMsgService.syncPurchasee(orders)) {
            return R.error("保存失败");
        } else {
            return R.ok("保存成功!!");
        }
    }
    /**
     * @author Ryan
     * @date 2025/8/15
     * @description: DO单同步
     * @date 2025/8/19
     * @description: 物料分类列表查询
     * @version 1.0
     */
    @ApiOperation(value = "出库通知单(DO单同步)", tags = "单据同步")
    @PostMapping("/sync/delivery")
    public R syncDelivery(@RequestBody List<OrderParams> orders) {
        if (!receiveMsgService.syncPurchasee(orders)) {
            return R.error("保存失败");
        } else {
            return R.ok("保存成功!!");
        }
    }
    /**
     * @author Ryan
     * @description 同步质检结果信息
     * @param
     * @return
     * @time 2025/3/12 16:56
     */
    @ApiOperation(value = "质检结果同步", tags = "单据同步")
    @PostMapping("/sync/inspect")
    public void syncQlyInspect(HttpServletRequest request, HttpServletResponse response) {
        AsnOrderTemplate template = ExcelUtil.mockData(AsnOrderTemplate.class);
        List<AsnOrderTemplate> list = new ArrayList<>();
        list.add(template);
        ExcelUtil.build(ExcelUtil.create(list, AsnOrderTemplate.class), response);
        System.out.println(template);
//        return R.ok();
    }
    @ApiOperation(value = "基础物料信息同步", tags = "基础信息同步")
    @PostMapping("/sync/base/matnrs")
    public R syncMatnrs(@RequestBody List<BaseMatParms> matnrs) {
        if (Objects.isNull(matnrs)) {
            return R.error("参数不能为空!");
        }
        receiveMsgService.syncMatnrs(matnrs);
        return R.ok();
    }
    @ApiOperation(value = "查询分类信息", tags = "查询")
    @ApiOperation(value = "查询分类信息")
    @PostMapping("/query/matnr/group")
    public R syncMatGroup() {
        return R.ok().add(matnrGroupService.list());
    }
    @ApiOperation(value = "查询单据状态及明细", tags = "查询")
    /**
     * @author Ryan
     * @date 2025/8/19
     * @description: 查询单据及明细
     * @version 1.0
     */
    @ApiOperation(value = "查询单据状态及明细")
    @PostMapping("/query/order")
    public R queryOrderStatus(@RequestBody QueryOrderParam queryParams) {
        if (Objects.isNull(queryParams)) {
@@ -137,45 +74,14 @@
     * @description: 库位信息查询
     * @version 1.0
     */
    @PostMapping("/sync/locs/detls")
    @ApiOperation(value = "库位信息查询", tags = "查询")
    @PostMapping("/query/locs/detls")
    @ApiOperation(value = "库位信息查询")
    public R syncLocDetls(@RequestBody Map<String, Object> map) {
        BaseParam baseParam = buildParam(map, BaseParam.class);
        PageParam<Loc, BaseParam> pageParam = new PageParam<>(baseParam, Loc.class);
        QueryWrapper<Loc> wrapper = pageParam.buildWrapper(true);
        return receiveMsgService.syncLocsDetl(pageParam, wrapper);
    }
    /**
     * @author Ryan
     * @date 2025/8/18
     * @description: 库位信息同步
     * @version 1.0
     */
    @PostMapping("/sync/locs")
    @ApiOperation(value = "库位信息同步", tags = "基础信息同步")
    public R syncLocs(@RequestBody List<SyncLocsParams> locs) {
        if (locs.isEmpty()) {
            throw new CoolException("参数不能为空!!");
        }
        return receiveMsgService.syncLocs(locs);
    }
    /**
     * @author Ryan
     * @date 2025/8/18
     * @description: 物料分组信息同步
     * @version 1.0
     */
    @PostMapping("/sync/matGroups")
    @ApiOperation(value = "物料分组信息同步", tags = "基础信息同步")
    public R syncMatGroup(@RequestBody List<SyncMatGroupsParams> matGroupsParams) {
        if (matGroupsParams.isEmpty()) {
            throw new CoolException("参数不能为空!!");
        }
        return receiveMsgService.syncMatGroups(matGroupsParams);
    }
}