#
luxiaotao1123
2021-03-16 b10c50ce84e4c6020864bd9f79d12733635a9602
src/main/java/zy/cloud/wms/common/service/erp/ErpScheduler.java
@@ -7,12 +7,14 @@
import com.core.exception.CoolException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import zy.cloud.wms.common.service.erp.entity.GetBasisResult;
import zy.cloud.wms.common.service.erp.entity.GetOrderResult;
import zy.cloud.wms.common.service.erp.entity.GetOrderResult0;
import zy.cloud.wms.common.service.erp.entity.GetOrderResultDetl0;
import zy.cloud.wms.manager.entity.Cstmr;
import zy.cloud.wms.manager.entity.CustOrder;
import zy.cloud.wms.manager.entity.Mat;
@@ -102,26 +104,26 @@
                        NodeUtils nodeUtils = new NodeUtils();
                        nodeUtils.executePath(first.getId());
                        second = new Tag(
                                    null,    // 编号
                                null,    // 编号
                                data.getYjfl(),    // 名称
                                first.getId(),    // 父级
                                first.getName(),    // 父级名称
                                nodeUtils.path.toString(),    // 关联路径
                                nodeUtils.pathName.toString(),    // 关联路径名
                                    0,    // 类型
                                    null,    // 负责人
                                    null,    // 图片
                                    null,    // 简要描述
                                    null,    // 数量
                                    2,    // 等级
                                    null,    // 排序
                                    1,    // 状态
                                    now,    // 添加时间
                                    null,    // 添加人员
                                0,    // 类型
                                null,    // 负责人
                                null,    // 图片
                                null,    // 简要描述
                                null,    // 数量
                                2,    // 等级
                                null,    // 排序
                                1,    // 状态
                                now,    // 添加时间
                                null,    // 添加人员
                                now,    // 修改时间
                                    null,    // 修改人员
                                    null    // 备注
                            );
                                null,    // 修改人员
                                null    // 备注
                        );
                        if (tagMapper.insert(second) == 0) {
                            throw new CoolException("插入分类失败");
                        }
@@ -268,12 +270,13 @@
    /**
     * 持久化销售订单
     */
//    @Scheduled(cron = "0/3 * * * * ? ")
    @Scheduled(cron = "0/5 * * * * ? ")
    @Transactional
//    @PostConstruct
    public void getOrdersExecute(){
        try {
            Map<String, Object> json = new HashMap<>();
            json.put("vchType", 41);
            json.put("vchType", 151);
            String response = new HttpHandler.Builder()
                    .setUri(URI)
                    .setPath(GET_ORDERS)
@@ -287,32 +290,41 @@
                if (result.getCode() != 1) {
                    return;
                }
                List<GetOrderResult> list = JSON.parseArray(result.getData(), GetOrderResult.class);
                List<GetOrderResult0> list = JSON.parseArray(result.getData(), GetOrderResult0.class);
                if (!Cools.isEmpty(list)) {
                    boolean complete = true;
                    for (GetOrderResult data : list) {
                        CustOrder custOrder = new CustOrder(
                                data.getNumber(),    // 销售单号
                                data.getBillDate(),    // 单据日期[非空]
                                data.getBTypeID(),    // 客户编号
                                data.getETypeID(),    // 经手人编号[非空]
                                data.getUserCode(),    // 商品编号
                                data.getQty(),    // 商品数量
                                data.getPrice(),    // 商品单价
                                data.getComment(),    // 商品备注[非空]
                                0,    // 状态
                                now,    // 添加时间
                                now,    // 修改时间
                                null    // 备注
                        );
                        boolean insert = custOrderService.insert(custOrder);
                        if (!insert) {
                            complete = false;
                            log.error("保存销售订单失败!");
                    for (GetOrderResult0 data : list) {
                        if (custOrderService.selectCount(new EntityWrapper<CustOrder>()
                                .eq("number", data.getNumber())
//                                .ne("bType_id", data.getBTypeID())
                                ) > 0) {
                            log.error("{}单号已存在", data.getNumber());
                            continue;
                        }
                        for (GetOrderResultDetl0 detl0 : data.getDetail()) {
                            CustOrder custOrder = new CustOrder(
                                    data.getNumber(),    // 销售单号
                                    data.getBillDate(),    // 单据日期[非空]
                                    data.getBTypeID(),    // 客户编号
                                    data.getETypeID(),    // 经手人编号[非空]
                                    detl0.getUserCode(),    // 商品编号
                                    detl0.getQty(),    // 商品数量
                                    detl0.getPrice(),    // 商品单价
                                    detl0.getComment(),    // 商品备注[非空]
                                    0,    // 状态
                                    now,    // 添加时间
                                    now,    // 修改时间
                                    data.getSummary()    // 备注
                            );
                            boolean insert = custOrderService.insert(custOrder);
                            if (!insert) {
                                complete = false;
                                log.error("保存销售订单失败!");
                            }
                        }
                    }
                    if (complete) {
                        List<String> collect = list.stream().map(GetOrderResult::getNumber).distinct().collect(Collectors.toList());
                        List<String> collect = list.stream().map(GetOrderResult0::getNumber).distinct().collect(Collectors.toList());
                        for (String number : collect) {
                            custOrderService.updateStatus(number, 1);
                        }