#
luxiaotao1123
2021-04-14 0f8e6adafe3210f9c6480f07340f2baa2e821752
#
6个文件已修改
1105 ■■■■ 已修改文件
src/main/java/zy/cloud/wms/common/service/erp/ErpScheduler.java 1085 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/zy/cloud/wms/common/utils/VersionUtils.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/zy/cloud/wms/manager/entity/OrderDetl.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/zy/cloud/wms/manager/service/CstmrService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/zy/cloud/wms/manager/service/impl/CstmrServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/order/order.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/zy/cloud/wms/common/service/erp/ErpScheduler.java
@@ -1,410 +1,447 @@
//package zy.cloud.wms.common.service.erp;
//
//import com.alibaba.fastjson.JSON;
//import com.baomidou.mybatisplus.mapper.EntityWrapper;
//import com.core.common.Cools;
//import com.core.common.DateUtils;
//import com.core.common.SnowflakeIdWorker;
//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.*;
//import zy.cloud.wms.manager.entity.*;
//import zy.cloud.wms.manager.mapper.CustOrderMapper;
//import zy.cloud.wms.manager.mapper.TagMapper;
//import zy.cloud.wms.manager.service.*;
//import zy.cloud.wms.manager.utils.HttpHandler;
//import zy.cloud.wms.manager.utils.NodeUtils;
//
//import java.io.IOException;
//import java.util.*;
//import java.util.stream.Collectors;
//
///**
// * erp任务控制器
// * Created by vincent on 2020/11/27
// */
//@Slf4j
//@Component
//@RestController
//public class ErpScheduler {
//
//    public static final String URI = "http://8.133.182.21:8080/api";
//    public static final String GET_ORDERS = "cM/basis/getOrders";
//    public static final String GET_BASIS = "cM/basis/getBasis";
//    public static final String UPLOAD_BILL = "cM/basis/uploadBill";
//    public static final String UPLOAD_STOCK = "cM/basis/uploadStock";
//    public static final String OVER_BILL = "cM/basis/OverBill";
//    public static final String UPLOAD_CANCEL_RESULT = "cM/basis/cancelOrders";
//
//    @Autowired
//    private CustOrderService custOrderService;
//    @Autowired
//    private MatService matService;
//    @Autowired
//    private CstmrService cstmrService;
//    @Autowired
//    private LocDetlService locDetlService;
//    @Autowired
//    private TagService tagService;
//    @Autowired
//    private TagMapper tagMapper;
//    @Autowired
//    private CustOrderMapper custOrderMapper;
//    @Autowired
//    private SnowflakeIdWorker snowflakeIdWorker;
//
//    /**
//     * 商品下载
//     */
//    //    @Scheduled(cron = "0/5 * * * * ? ")
//    @GetMapping("/test1")
////    @PostConstruct
//    public void getBasis1Execute(){
//        try {
//            Map<String, Object> param = new HashMap<>();
//            param.put("rec", 0);
//            param.put("Flag", 1);
//            String response = new HttpHandler.Builder()
//                    .setUri(URI)
//                    .setPath(GET_BASIS)
//                    .setJson(JSON.toJSONString(param))
//                    .build()
//                    .doPost();
//            if (!Cools.isEmpty(response)) {
package zy.cloud.wms.common.service.erp;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.SnowflakeIdWorker;
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.*;
import zy.cloud.wms.common.utils.VersionUtils;
import zy.cloud.wms.manager.entity.*;
import zy.cloud.wms.manager.mapper.TagMapper;
import zy.cloud.wms.manager.service.*;
import zy.cloud.wms.manager.utils.HttpHandler;
import zy.cloud.wms.manager.utils.NodeUtils;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
/**
 * erp任务控制器
 * Created by vincent on 2020/11/27
 */
@Slf4j
@Component
@RestController
public class ErpScheduler {
    public static final String URI = "http://8.133.182.21:8080/api";
    public static final String GET_ORDERS = "cM/basis/getOrders";
    public static final String GET_BASIS = "cM/basis/getBasis";
    public static final String UPLOAD_BILL = "cM/basis/uploadBill";
    public static final String UPLOAD_STOCK = "cM/basis/uploadStock";
    public static final String OVER_BILL = "cM/basis/OverBill";
    public static final String UPLOAD_CANCEL_RESULT = "cM/basis/cancelOrders";
    @Autowired
    private MatService matService;
    @Autowired
    private CstmrService cstmrService;
    @Autowired
    private LocDetlService locDetlService;
    @Autowired
    private TagService tagService;
    @Autowired
    private TagMapper tagMapper;
    @Autowired
    private OrderService orderService;
    @Autowired
    private OrderDetlService orderDetlService;
    @Autowired
    private SnowflakeIdWorker snowflakeIdWorker;
    /**
     * 商品下载
     */
    //    @Scheduled(cron = "0/5 * * * * ? ")
    @GetMapping("/test1")
//    @PostConstruct
    public void getBasis1Execute(){
        try {
            Map<String, Object> param = new HashMap<>();
            param.put("rec", 0);
            param.put("Flag", 1);
            String response = new HttpHandler.Builder()
                    .setUri(URI)
                    .setPath(GET_BASIS)
                    .setJson(JSON.toJSONString(param))
                    .build()
                    .doPost();
            if (!Cools.isEmpty(response)) {
                log.info(response);
                Date now = new Date();
                Result result = JSON.parseObject(response, Result.class);
                if (result.getCode() != 1) {
                    return;
                }
                List<GetBasisResult> list = JSON.parseArray(result.getData(), GetBasisResult.class);
                Tag first = null;
                for (GetBasisResult data : list) {
                    Mat mat = matService.selectByMatnr(data.getUserCode());
                    String modifyDate = data.getModifyDate();
                    Date updateTime = null;
                    if (!Cools.isEmpty(modifyDate)) {
                        updateTime = DateUtils.convert(data.getModifyDate());
                    }
                    // 分类
                    Tag second = tagService.selectOne(new EntityWrapper<Tag>().eq("name", data.getYjfl()).eq("level", 2));
                    if (second == null) {
                        if (first == null) {
                            first = tagService.selectOne(new EntityWrapper<Tag>().eq("level", 1));
                            if (first == null) {
                                throw new CoolException("全部分类出错");
                            }
                        }
                        NodeUtils nodeUtils = new NodeUtils();
                        nodeUtils.executePath(first.getId());
                        second = new Tag(
                                null,    // 编号
                                data.getYjfl(),    // 名称
                                first.getId(),    // 父级
                                first.getName(),    // 父级名称
                                nodeUtils.path.toString(),    // 关联路径
                                nodeUtils.pathName.toString(),    // 关联路径名
                                0,    // 类型
                                null,    // 负责人
                                null,    // 图片
                                null,    // 简要描述
                                null,    // 数量
                                2,    // 等级
                                null,    // 排序
                                1,    // 状态
                                now,    // 添加时间
                                null,    // 添加人员
                                now,    // 修改时间
                                null,    // 修改人员
                                null    // 备注
                        );
                        if (tagMapper.insert(second) == 0) {
                            throw new CoolException("插入分类失败");
                        }
                    }
                    Tag third = tagService.selectOne(new EntityWrapper<Tag>().eq("level", 3).eq("name", data.getEjfl()).eq("parent_name", data.getYjfl()));
                    if (third == null) {
                        NodeUtils nodeUtils = new NodeUtils();
                        nodeUtils.executePath(second.getId());
                        third = new Tag(
                                null,    // 编号
                                data.getEjfl(),    // 名称
                                second.getId(),    // 父级
                                second.getName(),    // 父级名称
                                nodeUtils.path.toString(),    // 关联路径
                                nodeUtils.pathName.toString(),    // 关联路径名
                                0,    // 类型
                                null,    // 负责人
                                null,    // 图片
                                null,    // 简要描述
                                null,    // 数量
                                3,    // 等级
                                null,    // 排序
                                1,    // 状态
                                now,    // 添加时间
                                null,    // 添加人员
                                now,    // 修改时间
                                null,    // 修改人员
                                null    // 备注
                        );
                        if (tagMapper.insert(third) == 0) {
                            throw new CoolException("插入分类失败");
                        }
                    }
                    if (null == mat) {
                        mat = new Mat(
                                String.valueOf(data.getRec()),    // 编号
                                null,    // 所属区域
                                third.getId(),    // 所属归类
                                data.getUserCode(),    // 商品编号
                                data.getFullName(),    // 商品名称
                                null,    // 名称
                                data.getStandard(),    // 规格
                                null,    // 型号
                                null,    // 批号
                                data.getUnit3(),    // 单位
                                data.getBarcode(),    // 条码
                                null,    // 单据类型
                                null,    // 单据编号
                                null,    // 客户名称
                                null,    // 品项数
                                null,    // 库存余量
                                null,    // 重量
                                1,    //
                                null,    // 添加人员
                                now,    // 添加时间
                                null,    // 修改人员
                                updateTime,    // 修改时间
                                null    // 备注
                        );
                        matService.insert(mat);
                    } else {
                        mat.setUuid(String.valueOf(data.getRec()));
                        mat.setMatnr(data.getUserCode());
                        mat.setMaktx(data.getFullName());
                        mat.setSpecs(data.getStandard());
                        mat.setUpdateTime(updateTime);
                        mat.setBarcode(data.getBarcode());
                        mat.setUnit(data.getUnit3());
                        matService.updateById(mat);
                    }
                    log.info("====>> 更新物料:{}", data.getUserCode());
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e.getMessage());
        }
    }
    /**
     * 客户下载
     */
    //    @Scheduled(cron = "0/5 * * * * ? ")
//    @PostConstruct
    public void getBasis2Execute(){
        try {
            Map<String, Object> param = new HashMap<>();
            param.put("rec", 0);
            param.put("Flag", 2);
            String response = new HttpHandler.Builder()
                    .setUri(URI)
                    .setPath(GET_BASIS)
                    .setJson(JSON.toJSONString(param))
                    .build()
                    .doPost();
            if (!Cools.isEmpty(response)) {
                log.info(response);
                Date now = new Date();
                Result result = JSON.parseObject(response, Result.class);
                if (result.getCode() != 1) {
                    return;
                }
                List<GetBasisResult> list = JSON.parseArray(result.getData(), GetBasisResult.class);
                for (GetBasisResult data : list) {
                    Cstmr cstmr = cstmrService.selectOne(new EntityWrapper<Cstmr>().eq("uuid", data.getUserCode()));
                    String modifyDate = data.getModifyDate();
                    Date updateTime = null;
                    if (!Cools.isEmpty(modifyDate)) {
                        updateTime = DateUtils.convert(data.getModifyDate());
                    }
                    if (null == cstmr) {
                        cstmr = new Cstmr(
                                data.getUserCode(),    // 客户编号[非空]
                                data.getFullName(),    // 客户名称
                                null,    // 联系人
                                null,    // 联系电话
                                null,    // 联系地址
                                1,    // 状态
                                null,    // 添加人员
                                now,    // 添加时间
                                null,    // 修改人员
                                updateTime,    // 修改时间
                                String.valueOf(data.getRec())    // 备注
                        );
                        cstmrService.insert(cstmr);
                    } else {
                        cstmr.setUuid(data.getUserCode());
                        cstmr.setName(data.getFullName());
                        cstmr.setUpdateTime(updateTime);
                        cstmr.setMemo(String.valueOf(data.getRec()));
                        cstmrService.updateById(cstmr);
                    }
                    log.info("====>> 更新客户资料:{}", data.getUserCode());
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e.getMessage());
        }
    }
    /**
     * 持久化销售订单
     */
    @Scheduled(cron = "0/5 * * * * ? ")
    @Transactional
//    @PostConstruct
    public void getOrdersExecute(){
        try {
            Map<String, Object> json = new HashMap<>();
            json.put("vchType", 151);
            String response = new HttpHandler.Builder()
                    .setUri(URI)
                    .setPath(GET_ORDERS)
                    .setJson(JSON.toJSONString(json))
                    .build()
                    .doPost();
            if (!Cools.isEmpty(response)) {
//                log.info(response);
//                Date now = new Date();
//                Result result = JSON.parseObject(response, Result.class);
//                if (result.getCode() != 1) {
//                    return;
//                }
//                List<GetBasisResult> list = JSON.parseArray(result.getData(), GetBasisResult.class);
//                Tag first = null;
//                for (GetBasisResult data : list) {
//                    Mat mat = matService.selectByMatnr(data.getUserCode());
//                    String modifyDate = data.getModifyDate();
//                    Date updateTime = null;
//                    if (!Cools.isEmpty(modifyDate)) {
//                        updateTime = DateUtils.convert(data.getModifyDate());
//                    }
//
//                    // 分类
//                    Tag second = tagService.selectOne(new EntityWrapper<Tag>().eq("name", data.getYjfl()).eq("level", 2));
//                    if (second == null) {
//                        if (first == null) {
//                            first = tagService.selectOne(new EntityWrapper<Tag>().eq("level", 1));
//                            if (first == null) {
//                                throw new CoolException("全部分类出错");
//                            }
//                        }
//                        NodeUtils nodeUtils = new NodeUtils();
//                        nodeUtils.executePath(first.getId());
//                        second = new Tag(
//                                null,    // 编号
//                                data.getYjfl(),    // 名称
//                                first.getId(),    // 父级
//                                first.getName(),    // 父级名称
//                                nodeUtils.path.toString(),    // 关联路径
//                                nodeUtils.pathName.toString(),    // 关联路径名
//                                0,    // 类型
//                                null,    // 负责人
//                                null,    // 图片
//                                null,    // 简要描述
//                                null,    // 数量
//                                2,    // 等级
//                                null,    // 排序
//                                1,    // 状态
//                                now,    // 添加时间
//                                null,    // 添加人员
//                                now,    // 修改时间
//                                null,    // 修改人员
//                                null    // 备注
//                        );
//                        if (tagMapper.insert(second) == 0) {
//                            throw new CoolException("插入分类失败");
//                        }
//                    }
//
//                    Tag third = tagService.selectOne(new EntityWrapper<Tag>().eq("level", 3).eq("name", data.getEjfl()).eq("parent_name", data.getYjfl()));
//                    if (third == null) {
//                        NodeUtils nodeUtils = new NodeUtils();
//                        nodeUtils.executePath(second.getId());
//                        third = new Tag(
//                                null,    // 编号
//                                data.getEjfl(),    // 名称
//                                second.getId(),    // 父级
//                                second.getName(),    // 父级名称
//                                nodeUtils.path.toString(),    // 关联路径
//                                nodeUtils.pathName.toString(),    // 关联路径名
//                                0,    // 类型
//                                null,    // 负责人
//                                null,    // 图片
//                                null,    // 简要描述
//                                null,    // 数量
//                                3,    // 等级
//                                null,    // 排序
//                                1,    // 状态
//                                now,    // 添加时间
//                                null,    // 添加人员
//                                now,    // 修改时间
//                                null,    // 修改人员
//                                null    // 备注
//                        );
//                        if (tagMapper.insert(third) == 0) {
//                            throw new CoolException("插入分类失败");
//                        }
//                    }
//
//                    if (null == mat) {
//                        mat = new Mat(
//                                String.valueOf(data.getRec()),    // 编号
//                                null,    // 所属区域
//                                third.getId(),    // 所属归类
//                                data.getUserCode(),    // 商品编号
//                                data.getFullName(),    // 商品名称
//                                null,    // 名称
//                                data.getStandard(),    // 规格
//                                null,    // 型号
//                                null,    // 批号
//                                data.getUnit3(),    // 单位
//                                data.getBarcode(),    // 条码
//                                null,    // 单据类型
//                                null,    // 单据编号
//                                null,    // 客户名称
//                                null,    // 品项数
//                                null,    // 库存余量
//                                null,    // 重量
//                                1,    //
//                                null,    // 添加人员
//                                now,    // 添加时间
//                                null,    // 修改人员
//                                updateTime,    // 修改时间
//                                null    // 备注
//                        );
//                        matService.insert(mat);
//                    } else {
//                        mat.setUuid(String.valueOf(data.getRec()));
//                        mat.setMatnr(data.getUserCode());
//                        mat.setMaktx(data.getFullName());
//                        mat.setSpecs(data.getStandard());
//                        mat.setUpdateTime(updateTime);
//                        mat.setBarcode(data.getBarcode());
//                        mat.setUnit(data.getUnit3());
//                        matService.updateById(mat);
//                    }
//                    log.info("====>> 更新物料:{}", data.getUserCode());
//                }
//
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//            throw new RuntimeException(e.getMessage());
//        }
//    }
//
//    /**
//     * 客户下载
//     */
//    //    @Scheduled(cron = "0/5 * * * * ? ")
////    @PostConstruct
//    public void getBasis2Execute(){
//        try {
//            Map<String, Object> param = new HashMap<>();
//            param.put("rec", 0);
//            param.put("Flag", 2);
//            String response = new HttpHandler.Builder()
//                    .setUri(URI)
//                    .setPath(GET_BASIS)
//                    .setJson(JSON.toJSONString(param))
//                    .build()
//                    .doPost();
//            if (!Cools.isEmpty(response)) {
//                log.info(response);
//                Date now = new Date();
//                Result result = JSON.parseObject(response, Result.class);
//                if (result.getCode() != 1) {
//                    return;
//                }
//                List<GetBasisResult> list = JSON.parseArray(result.getData(), GetBasisResult.class);
//                for (GetBasisResult data : list) {
//                    Cstmr cstmr = cstmrService.selectOne(new EntityWrapper<Cstmr>().eq("uuid", data.getUserCode()));
//                    String modifyDate = data.getModifyDate();
//                    Date updateTime = null;
//                    if (!Cools.isEmpty(modifyDate)) {
//                        updateTime = DateUtils.convert(data.getModifyDate());
//                    }
//                    if (null == cstmr) {
//                        cstmr = new Cstmr(
//                                data.getUserCode(),    // 客户编号[非空]
//                                data.getFullName(),    // 客户名称
//                                null,    // 联系人
//                                null,    // 联系电话
//                                null,    // 联系地址
//                                1,    // 状态
//                                null,    // 添加人员
//                                now,    // 添加时间
//                                null,    // 修改人员
//                                updateTime,    // 修改时间
//                                String.valueOf(data.getRec())    // 备注
//                        );
//                        cstmrService.insert(cstmr);
//                    } else {
//                        cstmr.setUuid(data.getUserCode());
//                        cstmr.setName(data.getFullName());
//                        cstmr.setUpdateTime(updateTime);
//                        cstmr.setMemo(String.valueOf(data.getRec()));
//                        cstmrService.updateById(cstmr);
//                    }
//                    log.info("====>> 更新客户资料:{}", data.getUserCode());
//                }
//
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//            throw new RuntimeException(e.getMessage());
//        }
//    }
//
//    /**
//     * 持久化销售订单
//     */
//    @Scheduled(cron = "0/5 * * * * ? ")
//    @Transactional
////    @PostConstruct
//    public void getOrdersExecute(){
//        try {
//            Map<String, Object> json = new HashMap<>();
//            json.put("vchType", 151);
//            String response = new HttpHandler.Builder()
//                    .setUri(URI)
//                    .setPath(GET_ORDERS)
//                    .setJson(JSON.toJSONString(json))
//                    .build()
//                    .doPost();
//            if (!Cools.isEmpty(response)) {
////                log.info(response);
//                Date now = new Date();
//                Result result = JSON.parseObject(response, Result.class);
//                if (result.getCode() != 1) {
//                    return;
//                }
//                List<GetOrderResult0> list = JSON.parseArray(result.getData(), GetOrderResult0.class);
//                if (!Cools.isEmpty(list)) {
//                    boolean complete = true;
//                    Set<String> existNumbers = new HashSet<>();
//                    for (GetOrderResult0 data : list) {
//                        if (custOrderService.selectCount(new EntityWrapper<CustOrder>()
//                                .eq("number", data.getNumber())
////                                .ne("bType_id", data.getBTypeID())
//                                ) > 0) {
////                            log.error("{}单号已存在", data.getNumber());
////                            complete = false;
//                            existNumbers.add(data.getNumber());
//                            continue;
//                        }
//                        for (GetOrderResultDetl0 detl0 : data.getDetail()) {
//                            CustOrder custOrder = new CustOrder(
//                                    data.getNumber(),    // 销售单号
//                                    data.getBillDate(),    // 单据日期[非空]
//                                    data.getBTypeID(),    // 客户编号
//                                    data.getETypeID(),    // 经手人编号[非空]
//                                    data.getVchcode(),  // 单据自增ID
//                                    detl0.getUserCode(),    // 商品编号
//                                    detl0.getQty(),    // 商品数量
//                                    detl0.getQty(),    // 总数量
//                                    detl0.getPrice(),    // 商品单价
//                                    detl0.getRowNo(),       // 商品明细行号
//                                    detl0.getComment(),    // 商品备注[非空]
//                                    0,    // 状态
//                                    now,    // 添加时间
//                                    now,    // 修改时间
//                                    data.getSummary()    // 备注
//                            );
//                            if (!custOrderService.insert(custOrder)) {
//                                complete = false;
//                                log.error("保存销售订单失败!");
//                            }
//                        }
//                    }
//                    if (complete) {
//                        List<String> collect = list.stream().map(GetOrderResult0::getNumber).distinct().collect(Collectors.toList());
//                        for (String number : collect) {
//                            if (!existNumbers.contains(number)) {
//                                custOrderService.updateStatus(number, 1);
//                            }
//                        }
//                    }
//
//                }
//            }
//        } catch (IOException e) {
//            e.printStackTrace();
//            throw new RuntimeException(e.getMessage());
//        }
//
//    }
//
//    /**
//     * 完成销售订单
//     */
//    @Scheduled(cron = "0/10 * * * * ? ")
//    @Transactional
////    @PostConstruct
//    public void finishOrdersExecute(){
//        try {
//            List<CustOrder> custOrders = custOrderService.selectList(new EntityWrapper<CustOrder>().eq("status", 4).isNotNull("vch_code"));
//            if (!Cools.isEmpty(custOrders)) {
//                List<String> numbers = custOrders.stream().map(CustOrder::getNumber).distinct().collect(Collectors.toList());
//                for (String number : numbers) {
//                    GetOrderResult0 getOrderResult0 = new GetOrderResult0();
//                    List<GetOrderResultDetl0> list = new ArrayList<>();
//                    getOrderResult0.setDetail(list);
//                    // 遍历递减
//                    Iterator<CustOrder> iterator = custOrders.iterator();
//                    while (iterator.hasNext()) {
//                        CustOrder custOrder = iterator.next();
//                        if (custOrder.getNumber().equals(number)) {
//                            // 表头
//                            if (Cools.isEmpty(getOrderResult0.getNumber())) {
//                                getOrderResult0.setNumber(number);
//                                getOrderResult0.setVchType(11); // todo:luxiaotao
//                                getOrderResult0.setBillDate(custOrder.getBillDate());
//                                getOrderResult0.setBTypeID(custOrder.getBTypeId());
//                                getOrderResult0.setKTypeID("宏挺仓库");
//                                getOrderResult0.setVchcode(custOrder.getVchcode());
//                            }
//                            // 表体
//                            GetOrderResultDetl0 detl0 = new GetOrderResultDetl0();
//                            detl0.setUserCode(custOrder.getUserCode());
//                            detl0.setQty(custOrder.getTotal());
//                            detl0.setPrice(custOrder.getPrice());
//                            detl0.setComment(custOrder.getComment());
//                            detl0.setRowNo(custOrder.getRowNo());
//                            list.add(detl0);
//                            iterator.remove();
//                        }
//                    }
//
//                    System.out.println(JSON.toJSONString(getOrderResult0));
//
//
//                    String response = new HttpHandler.Builder()
//                            .setUri(URI)
//                            .setPath(UPLOAD_BILL)
//                            .setJson(JSON.toJSONString(getOrderResult0))
//                            .build()
//                            .doPost();
//                    if (!Cools.isEmpty(response)) {
//                        log.warn(response);
//                        Result result = JSON.parseObject(response, Result.class);
//                        if (result.getCode() != 1) {
//                            continue;
//                        }
                Date now = new Date();
                Result result = JSON.parseObject(response, Result.class);
                if (result.getCode() != 1) {
                    return;
                }
                List<GetOrderResult0> list = JSON.parseArray(result.getData(), GetOrderResult0.class);
                if (!Cools.isEmpty(list)) {
                    boolean complete = true;
                    Set<String> existNumbers = new HashSet<>();
                    for (GetOrderResult0 data : list) {
                        if (orderService.selectByOrderNo(data.getNumber()) != null) {
                            existNumbers.add(data.getNumber());
                            continue;
                        }
                        Cstmr cstmr = cstmrService.selectByUuid(data.getBTypeID());
                        Order order = new Order(
                                String.valueOf(snowflakeIdWorker.nextId()),    // 编号[非空]
                                data.getNumber(),    // 订单编号
                                data.getBillDate(),    // 单据日期
                                11L,    // 单据类型
                                null,    // 项目编号
                                null,   // 项目名称
                                null,    // 调拨项目编号
                                null,    // 初始票据号
                                String.valueOf(data.getVchcode()),    // 票据号
                                null,    // 客户编号
                                cstmr==null?data.getBTypeID():cstmr.getName(),    // 客户
                                data.getBTypeID(),    // 联系方式 *
                                null,    // 操作人员
                                null,    // 合计金额
                                null,    // 优惠率
                                null,    // 优惠金额
                                null,    // 销售或采购费用合计
                                null,    // 实付金额
                                null,    // 付款类型
                                data.getETypeID(),    // 业务员 *
                                null,    // 结算天数
                                null,    // 邮费支付类型
                                null,    // 邮费
                                null,    // 付款时间
                                null,    // 发货时间
                                null,    // 物流名称
                                null,    // 物流单号
                                1L,    // 订单状态
                                1,    // 状态
                                9527L,    // 添加人员
                                now,    // 添加时间
                                9527L,    // 修改人员
                                now,    // 修改时间
                                data.getSummary()    // 备注
                        );
                        if (!orderService.insert(order)) {
                            throw new CoolException("保存订单表头失败!");
                        }
                        for (GetOrderResultDetl0 detl0 : data.getDetail()) {
                            Mat mat = matService.selectByMatnr(detl0.getUserCode());
                            if (mat == null) {
                                log.error("{}商品不存在。", detl0.getUserCode());
                                continue;
                            }
                            OrderDetl orderDetl = new OrderDetl();
                            VersionUtils.setOrderDetl(orderDetl, mat);
                            orderDetl.setName(String.valueOf(detl0.getRowNo())); // 商品明细行号
                            orderDetl.setOrderId(order.getId());                 // 订单内码
                            orderDetl.setAnfme(detl0.getQty());                  // 商品数量
                            orderDetl.setCount(detl0.getQty());                  // 总数量 *
                            orderDetl.setUnitPrice(detl0.getPrice());            // 商品单价
                            orderDetl.setCreateBy(9527L);
                            orderDetl.setCreateTime(now);
                            orderDetl.setUpdateBy(9527L);
                            orderDetl.setUpdateTime(now);
                            orderDetl.setStatus(1);
                            orderDetl.setMemo(detl0.getComment());
                            if (!orderDetlService.insert(orderDetl)) {
                                complete = false;
                                log.error("保存销售订单失败!");
                            }
                        }
                    }
                    if (complete) {
                        List<String> collect = list.stream().map(GetOrderResult0::getNumber).distinct().collect(Collectors.toList());
                        for (String number : collect) {
                            if (!existNumbers.contains(number)) {
                                orderService.updateSettle(number, 1L);
                            }
                        }
                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
            throw new RuntimeException(e.getMessage());
        }
    }
    /**
     * 完成销售订单
     */
    @Scheduled(cron = "0/10 * * * * ? ")
    @Transactional
//    @PostConstruct
    public void finishOrdersExecute(){
        try {
            List<Order> orders = orderService.selectList(new EntityWrapper<Order>().eq("settle", 4).isNotNull("number"));
            if (!Cools.isEmpty(orders)) {
                List<String> orderNos = orders.stream().map(Order::getOrderNo).distinct().collect(Collectors.toList());
                for (Order order : orders) {
                    GetOrderResult0 getOrderResult0 = new GetOrderResult0();
                    List<GetOrderResultDetl0> list = new ArrayList<>();
                    getOrderResult0.setDetail(list);
                    // 头
                    getOrderResult0.setNumber(order.getOrderNo());
                    getOrderResult0.setVchType(11); // todo:luxiaotao
                    getOrderResult0.setBillDate(order.getOrderTime());
                    getOrderResult0.setBTypeID(order.getTel());
                    getOrderResult0.setKTypeID("宏挺仓库");
                    getOrderResult0.setVchcode(Integer.parseInt(order.getNumber()));
                    // 体
                    List<OrderDetl> orderDetls = orderDetlService.selectByOrderNo(order.getOrderNo());
                    for (OrderDetl orderDetl : orderDetls) {
                        GetOrderResultDetl0 detl0 = new GetOrderResultDetl0();
                        detl0.setUserCode(orderDetl.getMatnr());
                        detl0.setQty(orderDetl.getCount());
                        detl0.setPrice(orderDetl.getUnitPrice());
                        detl0.setComment(orderDetl.getMemo());
                        detl0.setRowNo(Integer.parseInt(orderDetl.getName()));
                        list.add(detl0);
                    }
                    System.out.println(JSON.toJSONString(getOrderResult0));
                    String response = new HttpHandler.Builder()
                            .setUri(URI)
                            .setPath(UPLOAD_BILL)
                            .setJson(JSON.toJSONString(getOrderResult0))
                            .build()
                            .doPost();
                    if (!Cools.isEmpty(response)) {
                        log.warn(response);
                        Result result = JSON.parseObject(response, Result.class);
                        if (result.getCode() != 1) {
                            continue;
                        }
                        if (!orderService.updateSettle(getOrderResult0.getNumber(), 6L)) {
                            throw new CoolException("修改订单状态失败");
                        }
//                        // 转历史档
//                        int save = custOrderMapper.saveLog(getOrderResult0.getNumber());
//                        if (save > 0) {
@@ -413,121 +450,121 @@
//                            }
//                            log.info("{}销售订单拣货结束", getOrderResult0.getNumber());
//                        }
//                    }
//
//                }
//            }
//
//
//        } catch (Exception e) {
//            e.printStackTrace();
//            throw new RuntimeException(e.getMessage());
//        }
//
//    }
//
//    /**
//     * 库存上传
//     */
////    @Scheduled(cron = "0/15 * * * * ? ")
//    @GetMapping("test2")
//    public void uploadStockExecute(){
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e.getMessage());
        }
    }
    /**
     * 库存上传
     */
//    @Scheduled(cron = "0/15 * * * * ? ")
    @GetMapping("test2")
    public void uploadStockExecute(){
        try {
            List<LocDetl> statis = locDetlService.getLocDetlStatis();
            if (!Cools.isEmpty(statis)) {
                UploadStock uploadStock = new UploadStock();
                uploadStock.setNumber(String.valueOf(snowflakeIdWorker.nextId()));
                uploadStock.setVchType(89);
                uploadStock.setBillDate(DateUtils.convert(new Date(), DateUtils.yyyyMMdd_F));
                uploadStock.setDataSize(statis.size());
                List<UploadStockDtel> detail = new ArrayList<>();
                uploadStock.setDetail(detail);
                for (LocDetl locDetl : statis) {
                    Mat mat = matService.selectByMatnr(locDetl.getMatnr());
                    if (mat == null) {continue;}
                    UploadStockDtel detl = new UploadStockDtel();
                    detl.setUserCode(mat.getMatnr());
                    detl.setQty(locDetl.getAnfme());
//                    detl.setPrice(Double.parseDouble());
                    detl.setComment(mat.getMemo());
                    detail.add(detl);
                }
                String response = new HttpHandler.Builder()
                        .setUri(URI)
                        .setPath(UPLOAD_STOCK)
                        .setJson(JSON.toJSONString(uploadStock))
                        .build()
                        .doPost();
                if (!Cools.isEmpty(response)) {
                    log.info("上报库存明细统计 ======>> \nrequest:{} \nresponse:{}", JSON.toJSONString(uploadStock), response);
                    Result result = JSON.parseObject(response, Result.class);
                    if (result.getCode() != 1) {
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 获取取消订单
     */
    @Scheduled(cron = "0/5 * * * * ? ")
    @Transactional
//    @PostConstruct
    public void getCancelOrdersExecute(){
        try {
            Map<String, Object> json = new HashMap<>();
            String response = new HttpHandler.Builder()
                    .setUri(URI)
                    .setPath(OVER_BILL)
                    .setJson(JSON.toJSONString(json))
                    .build()
                    .doPost();
            if (!Cools.isEmpty(response)) {
//                log.info(response);
                Date now = new Date();
                Result result = JSON.parseObject(response, Result.class);
                if (result.getCode() != 1) {
                    return;
                }
                List<GetOrderResult0> list = JSON.parseArray(result.getData(), GetOrderResult0.class);
                if (!Cools.isEmpty(list)) {
                    boolean complete = true;
                    Set<String> existNumbers = new HashSet<>();
                    String cancelNumber = "";
                    if (!orderService.updateSettle(cancelNumber, 5L)) {
                        throw new CoolException("修改订单状态失败");
                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
            throw new RuntimeException(e.getMessage());
        }
    }
    /**
     * 上传销售订单取消结果
     */
    @Scheduled(cron = "0/5 * * * * ? ")
    @Transactional
//    @PostConstruct
    public void uploadCancelOrdersExecute(){
//        try {
//
//            List<LocDetl> statis = locDetlService.getLocDetlStatis();
//            if (!Cools.isEmpty(statis)) {
//                UploadStock uploadStock = new UploadStock();
//                uploadStock.setNumber(String.valueOf(snowflakeIdWorker.nextId()));
//                uploadStock.setVchType(89);
//                uploadStock.setBillDate(DateUtils.convert(new Date(), DateUtils.yyyyMMdd_F));
//                uploadStock.setDataSize(statis.size());
//                List<UploadStockDtel> detail = new ArrayList<>();
//                uploadStock.setDetail(detail);
//                for (LocDetl locDetl : statis) {
//                    Mat mat = matService.selectByMatnr(locDetl.getMatnr());
//                    if (mat == null) {continue;}
//                    UploadStockDtel detl = new UploadStockDtel();
//                    detl.setUserCode(mat.getMatnr());
//                    detl.setQty(locDetl.getAnfme());
////                    detl.setPrice(Double.parseDouble());
//                    detl.setComment(mat.getMemo());
//                    detail.add(detl);
//                }
//
//                String response = new HttpHandler.Builder()
//                        .setUri(URI)
//                        .setPath(UPLOAD_STOCK)
//                        .setJson(JSON.toJSONString(uploadStock))
//                        .build()
//                        .doPost();
//                if (!Cools.isEmpty(response)) {
//                    log.info("上报库存明细统计 ======>> \nrequest:{} \nresponse:{}", JSON.toJSONString(uploadStock), response);
//                    Result result = JSON.parseObject(response, Result.class);
//                    if (result.getCode() != 1) {
//                    }
//                }
//            }
//
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//
//
//    }
//
//
//    /**
//     * 获取取消订单
//     */
//    @Scheduled(cron = "0/5 * * * * ? ")
//    @Transactional
////    @PostConstruct
//    public void getCancelOrdersExecute(){
//        try {
//            Map<String, Object> json = new HashMap<>();
//            String response = new HttpHandler.Builder()
//                    .setUri(URI)
//                    .setPath(OVER_BILL)
//                    .setJson(JSON.toJSONString(json))
//                    .build()
//                    .doPost();
//            if (!Cools.isEmpty(response)) {
////                log.info(response);
//                Date now = new Date();
//                Result result = JSON.parseObject(response, Result.class);
//                if (result.getCode() != 1) {
//                    return;
//                }
//                List<GetOrderResult0> list = JSON.parseArray(result.getData(), GetOrderResult0.class);
//                if (!Cools.isEmpty(list)) {
//                    boolean complete = true;
//                    Set<String> existNumbers = new HashSet<>();
//
//                    String cancelNumber = "";
//                    if (!custOrderService.updateStatus(cancelNumber, 5)) {
//                        throw new CoolException("修改订单状态失败");
//                    }
//
//
//                }
//            }
//        } catch (IOException e) {
//            e.printStackTrace();
//            throw new RuntimeException(e.getMessage());
//        }
//
//    }
//
//    /**
//     * 上传销售订单取消结果
//     */
//    @Scheduled(cron = "0/5 * * * * ? ")
//    @Transactional
////    @PostConstruct
//    public void uploadCancelOrdersExecute(){
//        try {
//            List<CustOrder> custOrders = custOrderService.selectList(new EntityWrapper<CustOrder>().eq("status", 3).isNotNull("vch_code"));
//            if (Cools.isEmpty(custOrders)) {
//            List<Order> orders = orderService.selectList(new EntityWrapper<Order>().eq("settle", 3).isNotNull("number"));
//            if (Cools.isEmpty(orders)) {
//                return;
//            }
//            Map<String, Object> json = new HashMap<>();
@@ -568,7 +605,7 @@
//            e.printStackTrace();
//            throw new RuntimeException(e.getMessage());
//        }
//
//    }
//
//}
    }
}
src/main/java/zy/cloud/wms/common/utils/VersionUtils.java
@@ -129,7 +129,6 @@
        orderDetl.setUnit(mat.getUnit());
        orderDetl.setBarcode(mat.getBarcode());
        orderDetl.setItemNum(mat.getItemNum());
        orderDetl.setCount(mat.getCount());
        orderDetl.setWeight(mat.getWeight());
    }
src/main/java/zy/cloud/wms/manager/entity/OrderDetl.java
@@ -112,7 +112,7 @@
     * 数量
     */
    @ApiModelProperty(value= "数量")
    private Integer count;
    private Double count;
    /**
     * 重量
@@ -162,7 +162,7 @@
    public OrderDetl() {}
    public OrderDetl(Long orderId,Double anfme,String matnr,String maktx,String name,String specs,String model,String batch,String unit,String barcode,String supplier,Double unitPrice,Integer itemNum,Integer count,Double weight,Integer status,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) {
    public OrderDetl(Long orderId,Double anfme,String matnr,String maktx,String name,String specs,String model,String batch,String unit,String barcode,String supplier,Double unitPrice,Integer itemNum,Double count,Double weight,Integer status,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) {
        this.orderId = orderId;
        this.anfme = anfme;
        this.matnr = matnr;
@@ -331,11 +331,11 @@
        this.itemNum = itemNum;
    }
    public Integer getCount() {
    public Double getCount() {
        return count;
    }
    public void setCount(Integer count) {
    public void setCount(Double count) {
        this.count = count;
    }
src/main/java/zy/cloud/wms/manager/service/CstmrService.java
@@ -7,4 +7,6 @@
    Cstmr selectByName(String name);
    Cstmr selectByUuid(String uuid);
}
src/main/java/zy/cloud/wms/manager/service/impl/CstmrServiceImpl.java
@@ -16,4 +16,9 @@
        cstmr.setName(name);
        return this.selectOne(new EntityWrapper<>(cstmr));
    }
    @Override
    public Cstmr selectByUuid(String uuid) {
        return this.selectOne(new EntityWrapper<Cstmr>().eq("uuid", uuid));
    }
}
src/main/webapp/static/js/order/order.js
@@ -163,7 +163,7 @@
            {type: 'checkbox'}
            // ,{field: 'uuid', align: 'center',title: '编号'}
            ,{field: 'docType$', align: 'center',title: '类别', templet: '#docTypeTpl', width: 100}
            ,{field: 'orderNo', align: 'center',title: '单据编号', minWidth: 200}
            ,{field: 'orderNo', align: 'center',title: '单据编号', minWidth: 250}
            ,{field: 'orderTime', align: 'center',title: '单据日期'}
            ,{field: 'itemName', align: 'center',title: '项目'}
            ,{field: 'allotItemId$', align: 'center',title: '调拨项目编号', hide: true}
@@ -171,7 +171,7 @@
            ,{field: 'number', align: 'center',title: '票据号', hide: true}
            ,{field: 'cstmrName', align: 'center',title: '客户'}
            ,{field: 'tel', align: 'center',title: '联系方式', hide: true}
            ,{field: 'operMemb', align: 'center',title: '操作人员'}
            ,{field: 'operMemb', align: 'center',title: '操作人员', hide: true}
            ,{field: 'totalFee', align: 'center',title: '合计金额', hide: true}
            ,{field: 'discount', align: 'center',title: '优惠率', hide: true}
            ,{field: 'discountFee', align: 'center',title: '优惠金额', hide: true}