czt
9 天以前 db67639449287bcec461916a7dca6003ee5dd03c
fzzy-igdss-web/src/main/java/com/fzzy/sys/manager/print/PrintManager.java
@@ -1,21 +1,9 @@
package com.fzzy.sys.manager.print;
import com.fzzy.igds.bill.InoutBill;
import com.fzzy.igds.constant.Constant;
import com.fzzy.igds.constant.FoodVariety;
import com.fzzy.igds.data.InoutPrintBill;
import com.fzzy.igds.domain.Depot;
import com.fzzy.igds.domain.InoutRecord;
import com.fzzy.igds.service.DepotService;
import com.fzzy.igds.service.SysDeptService;
import com.fzzy.igds.utils.NumberUtil;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.utils.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import com.fzzy.igds.service.InoutRecordService;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.text.DecimalFormat;
import java.util.*;
/**
 * @Description 单据打印
@@ -26,9 +14,7 @@
public class PrintManager {
    @Resource
    private SysDeptService sysDeptService;
    @Resource
    private DepotService depotService;
    private InoutRecordService inoutRecordService;
    /**
     * 获取入库过磅单数据信息
@@ -37,87 +23,7 @@
     * @return
     */
    public String inWeightBill(InoutRecord data) {
        // 获取表单数据
        InoutPrintBill bill = this.createBillData(data, "入库划码单");
        // 调整模版数据并返回
        String htmlStr = InoutBill.IN_WEIGHT_DEFAULT;
        htmlStr = htmlStr.replace("billTitle", bill.getBillTitle());
        htmlStr = htmlStr.replace("registerTime", bill.getRegisterTime());
        htmlStr = htmlStr.replace("completeTime", bill.getCompleteTime());
        htmlStr = htmlStr.replace("fullTime", bill.getFullTime());
        htmlStr = htmlStr.replace("emptyTime", bill.getEmptyTime());
        htmlStr = htmlStr.replace("serId", bill.getSerId());
        htmlStr = htmlStr.replace("customerName", bill.getCustomerName());
        htmlStr = htmlStr.replace("deptName", bill.getUnitName());
        htmlStr = htmlStr.replace("driverName", bill.getDriverName());
        htmlStr = htmlStr.replace("userNumberId", bill.getUserId());
        htmlStr = htmlStr.replace("userContact", bill.getUserContact());
        htmlStr = htmlStr.replace("userAddress", bill.getUserAddress());
        htmlStr = htmlStr.replace("foodVariety", bill.getFoodVariety());
        htmlStr = htmlStr.replace("depotName", bill.getDepotName());
        htmlStr = htmlStr.replace("foodLocation", bill.getFoodLocation());
        if ("5326".equals(data.getCompanyId())) {
            htmlStr = htmlStr.replace("recordWeight", new DecimalFormat("0").format(bill.getRecordWeight()));
            htmlStr = htmlStr.replace("settleWeight", new DecimalFormat("0").format(bill.getSettleWeight()));
            htmlStr = htmlStr.replace("fullWeight", new DecimalFormat("0").format(bill.getFullWeight()));
            htmlStr = htmlStr.replace("emptyWeight", new DecimalFormat("0").format(bill.getEmptyWeight()));
            htmlStr = htmlStr.replace("netWeight", new DecimalFormat("0").format(bill.getNetWeight()));
        }
        htmlStr = htmlStr.replace("plateNum", bill.getPlateNum());
        htmlStr = htmlStr.replace("fullWeight",
                new DecimalFormat("0.00").format(bill.getFullWeight()));
        htmlStr = htmlStr.replace("emptyWeight",
                new DecimalFormat("0.00").format(bill.getEmptyWeight()));
        htmlStr = htmlStr.replace("netWeight",
                new DecimalFormat("0.00").format(bill.getNetWeight()));
        htmlStr = htmlStr.replace("deImpurity", bill.getDeImpurity() + "");
        htmlStr = htmlStr.replace("deWet", bill.getDeWet() + "");
        htmlStr = htmlStr.replace("recordWeight", new DecimalFormat("0.00").format(bill.getRecordWeight()));
        htmlStr = htmlStr.replace("deCheck", bill.getDeCheck() + "");
        htmlStr = htmlStr.replace("addCheck", bill.getAddCheck() + "");
        htmlStr = htmlStr.replace("deSum", bill.getDeSum() + "");
        htmlStr = htmlStr.replace("settleWeight",
                new DecimalFormat("0.00").format(bill.getSettleWeight()));
        htmlStr = htmlStr.replace("dePackage", bill.getDePackage() + "");
        htmlStr = htmlStr.replace("deHandle", bill.getDeHandle() + "");
        htmlStr = htmlStr.replace("deOther", bill.getDeOther() + "");
        htmlStr = htmlStr.replace("price", bill.getPrice());
        htmlStr = htmlStr.replace("settleMoney", bill.getSettleMoney() + "");
        htmlStr = htmlStr.replace("wet", bill.getWet() + "");
        htmlStr = htmlStr.replace("impurity", bill.getImpurity() + "");
        htmlStr = htmlStr.replace("checkStatus", bill.getCheckStatus());
        htmlStr = htmlStr.replace("remark", bill.getRemark());
        htmlStr = htmlStr.replace("moneyName", bill.getMoneyName());
        htmlStr = htmlStr.replace("unitName", bill.getUnitName());
        htmlStr = htmlStr.replace("time", bill.getRegisterTime());
        htmlStr = htmlStr.replace("handleStart", "");
        htmlStr = htmlStr.replace("handleEnd", "");
        htmlStr = htmlStr.replace("noticeId", bill.getNoticeId() == null ? "" : bill.getNoticeId());
        htmlStr = htmlStr.replace("phone", data.getUserContact() == null ? "" : data.getUserContact() + "");
        htmlStr = htmlStr.replace("printTime", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm"));
        htmlStr = htmlStr.replaceAll("weightUser",
                bill.getWeightUser() == null ? "" : bill.getWeightUser());
        htmlStr = htmlStr.replaceAll("handleUser",
                bill.getHandleUser() == null ? "" : bill.getHandleUser());
        htmlStr = htmlStr.replaceAll("keeperName",
                bill.getKeeperUser() == null ? "" : bill.getKeeperUser());
        return htmlStr;
        return inoutRecordService.inWeightBill( data);
    }
    /**
@@ -127,187 +33,8 @@
     * @return
     */
    public String outWeightBill(InoutRecord data) {
        // 获取表单数据
        InoutPrintBill bill = this.createBillData(data, "出库划码单");
        //默认模版
        String htmlStr = InoutBill.OUT_WEIGHT_DEFAULT;
        htmlStr = htmlStr.replace("billTitle", bill.getBillTitle());
        htmlStr = htmlStr.replace("registerTime", bill.getRegisterTime());
        htmlStr = htmlStr.replace("completeTime", bill.getCompleteTime());
        htmlStr = htmlStr.replace("fullTime", bill.getFullTime());
        htmlStr = htmlStr.replace("emptyTime", bill.getEmptyTime());
        htmlStr = htmlStr.replace("serId", bill.getSerId());
        htmlStr = htmlStr.replace("customerName", bill.getCustomerName());
        htmlStr = htmlStr.replace("deptName", bill.getUnitName());
        htmlStr = htmlStr.replace("driverName", bill.getDriverName());
        htmlStr = htmlStr.replace("userNumberId", bill.getUserId());
        htmlStr = htmlStr.replace("userContact", bill.getUserContact());
        htmlStr = htmlStr.replace("userAddress", bill.getUserAddress());
        htmlStr = htmlStr.replace("foodVariety", bill.getFoodVariety());
        htmlStr = htmlStr.replace("depotName", bill.getDepotName());
        htmlStr = htmlStr.replace("foodLocation", bill.getFoodLocation());
        if ("5326".equals(data.getCompanyId())) {
            htmlStr = htmlStr.replace("recordWeight", new DecimalFormat("0").format(bill.getRecordWeight()));
            htmlStr = htmlStr.replace("settleWeight", new DecimalFormat("0").format(bill.getSettleWeight()));
            htmlStr = htmlStr.replace("fullWeight", new DecimalFormat("0").format(bill.getFullWeight()));
            htmlStr = htmlStr.replace("emptyWeight", new DecimalFormat("0").format(bill.getEmptyWeight()));
            htmlStr = htmlStr.replace("netWeight", new DecimalFormat("0").format(bill.getNetWeight()));
        }
        htmlStr = htmlStr.replace("plateNum", bill.getPlateNum());
        htmlStr = htmlStr.replace("fullWeight",
                new DecimalFormat("0.00").format(bill.getFullWeight()));
        htmlStr = htmlStr.replace("emptyWeight",
                new DecimalFormat("0.00").format(bill.getEmptyWeight()));
        htmlStr = htmlStr.replace("netWeight",
                new DecimalFormat("0.00").format(bill.getNetWeight()));
        htmlStr = htmlStr.replace("dePackage",
                new DecimalFormat("0.00").format(bill.getDePackage()));
        htmlStr = htmlStr.replace("remark", bill.getRemark());
        htmlStr = htmlStr.replace("settleWeight",
                new DecimalFormat("0.00").format(bill.getSettleWeight()));
        htmlStr = htmlStr.replace("deHandle", bill.getDeHandle() + "");
        htmlStr = htmlStr.replace("recordWeight", new DecimalFormat("0.00").format(bill.getRecordWeight()));
        htmlStr = htmlStr.replace("deSum", bill.getDeSum() + "");
        htmlStr = htmlStr.replace("deOther", bill.getDeOther() + "");
        htmlStr = htmlStr.replace("price", bill.getPrice());
        htmlStr = htmlStr.replace("settleMoney", bill.getSettleMoney() + "");
        htmlStr = htmlStr.replace("wet", bill.getWet() + "");
        htmlStr = htmlStr.replace("impurity", bill.getImpurity() + "");
        htmlStr = htmlStr.replace("unitName", getValue(bill.getUnitName()));
        htmlStr = htmlStr.replace("time", bill.getRegisterTime());
        htmlStr = htmlStr.replace("handleStart", "");
        htmlStr = htmlStr.replace("handleEnd", "");
        htmlStr = htmlStr.replace("noticeId", bill.getNoticeId() == null ? "" : bill.getNoticeId());
        htmlStr = htmlStr.replace("phone", data.getUserContact() == null ? "" : data.getUserContact() + "");
        htmlStr = htmlStr.replace("printTime", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm"));
        htmlStr = htmlStr.replaceAll("weightUser", getValue(bill.getWeightUser()));
        htmlStr = htmlStr.replace("handleUser", getValue(bill.getHandleUser()));
        htmlStr = htmlStr.replaceAll("keeperName", getValue(bill.getKeeperUser()));
        return htmlStr;
    }
    public String getValue(String value) {
        if (null == value) return "";
        return value;
    }
    /**
     * 封装过磅单数据
     *
     * @param data
     * @param billTitle
     * @return
     */
    private InoutPrintBill createBillData(InoutRecord data, String billTitle) {
        InoutPrintBill bill = new InoutPrintBill();
        bill.setBillTitle(billTitle);
        SysDept dept = sysDeptService.getCacheDept(data.getCompanyId(), data.getDeptId());
        if (null != dept && StringUtils.isNotEmpty(dept.getDeptName())) {
            bill.setBillTitle(dept.getDeptName() + billTitle);
            bill.setDeptId(dept.getDeptId() + "");
            bill.setDeptName(dept.getDeptName() + "");
            bill.setUnitName(dept.getDeptName());
        }
        //清远出发货单位及标题,使用公司名
        if ("5368".equals(data.getCompanyId())) {
            SysDept company = sysDeptService.getCacheDept(data.getCompanyId(), data.getCompanyId());
            if (null != company && StringUtils.isNotEmpty(company.getDeptName())) {
                bill.setBillTitle(company.getDeptName() + billTitle);
                bill.setUnitName(company.getDeptName());
            }
        }
        bill.setCompanyId(data.getCompanyId() == null ? "" : data
                .getCompanyId());
        if (null == data.getRegisterTime()) {
            data.setRegisterTime(new Date());
        }
        bill.setRegisterTime(DateFormatUtils.format(data.getRegisterTime(),
                "yyyy-MM-dd HH:mm"));
        if (null == data.getCompleteTime()) {
            data.setCompleteTime(new Date());
        }
        bill.setCompleteTime(DateFormatUtils.format(data.getCompleteTime(),
                "yyyy-MM-dd HH:mm"));
        bill.setEmptyTime(DateFormatUtils.format(data.getEmptyWeightTime(),
                "yyyy-MM-dd HH:mm:ss"));
        bill.setFullTime(DateFormatUtils.format(data.getFullWeightTime(),
                "yyyy-MM-dd HH:mm:ss"));
        bill.setSerId(data.getId());
        if ("5016".equals(data.getCompanyId()) || "5347".equals(data.getCompanyId()) || "5352".equals(data.getCompanyId())) {
            bill.setCompleteTime(DateFormatUtils.format(data.getCompleteTime(), "yyyy-MM-dd"));
            bill.setSerId(data.getId().substring(2));
        }
        //客户信息
        bill.setCustomerName(data.getCustomerName() == null ? "" : data.getCustomerName());
        bill.setUserId(data.getUserId() == null ? "" : data.getUserId());
        bill.setUserAddress(data.getUserAddress() == null ? "" : data.getUserAddress());
        bill.setUserContact(data.getUserContact() == null ? "" : data.getUserContact());
        bill.setNoticeId(data.getNoticeId());
        bill.setDriverName(data.getUserName() == null ? "" : data.getUserName());
        // 获取仓库信息
        Depot depot = depotService.getCacheDepot(data.getCompanyId(),
                data.getDepotId());
        if (depot != null) {
            bill.setDepotName(depot.getName() == null ? "" : depot.getName());
            bill.setHandleUser(depot.getStoreKeeperName() == null ? "" : depot
                    .getStoreKeeperName());
        }
        bill.setFoodVariety(FoodVariety.getMsg(data.getFoodVariety()));
        bill.setFoodLocation(data.getFoodLocation() == null ? "" : data
                .getFoodLocation());
        bill.setPlateNum(data.getPlateNum());
        bill.setFullWeight(data.getFullWeight());
        bill.setEmptyWeight(data.getEmptyWeight());
        bill.setNetWeight(data.getNetWeight());
        bill.setRecordWeight(data.getRecordWeight());
        bill.setCheckStatus(data.getCheckStatus().equals(Constant.STATUS_CHECK) ? "合格" : "不合格");
        bill.setDeOther(data.getDeOther());
        bill.setSettleWeight(data.getSettleWeight());
        bill.setPrice(data.getPrice() == null ? "" : data.getPrice() + "");
        if (data.getSettleMoney() <= 0) {
            if (null != data.getPrice() && null != data.getRecordWeight()) {
                data.setSettleMoney(NumberUtil.keepPrecision(data.getPrice() * data.getRecordWeight(), 2));
            }
        }
        bill.setSettleMoney(data.getSettleMoney() == null ? "" : data.getSettleMoney() + "");
        bill.setRemark(data.getRemarks() == null ? "" : data.getRemarks());
        if (Constant.TYPE_IN.equals(data.getType())) {
            bill.setWeightUser(data.getFullWeightUser());
        }
        if (Constant.TYPE_OUT.equals(data.getType())) {
            bill.setWeightUser(data.getEmptyWeightUser());
        }
        bill.setHandleUser(data.getHandleUser());
        bill.setKeeperUser(depot.getStoreKeeperName());
        return bill;
        return inoutRecordService.outWeightBill( data);
    }
}