vince
2023-08-24 9e02c41bbc10752e066917c4237275f5031960f4
igds-inout/src/main/java/com/ld/igds/inout/manager/InoutReportManager.java
@@ -4,13 +4,12 @@
import com.ld.igds.check.dto.CheckItemData;
import com.ld.igds.check.service.CoreCheckStandardService;
import com.ld.igds.common.CoreCommonService;
import com.ld.igds.common.bar.BarCodeUtils;
import com.ld.igds.constant.FoodLevel;
import com.ld.igds.constant.FoodVariety;
import com.ld.igds.inout.InoutBill;
import com.ld.igds.inout.InoutConstant;
import com.ld.igds.inout.dto.InoutData;
import com.ld.igds.inout.dto.InoutRecordItemData;
import com.ld.igds.inout.dto.InoutRecordItemParam;
import com.ld.igds.inout.dto.WeightBill;
import com.ld.igds.inout.dto.*;
import com.ld.igds.inout.service.InoutRecordItemService;
import com.ld.igds.m.dto.NoticeDto;
import com.ld.igds.m.service.HInoutNoticeService;
@@ -85,6 +84,14 @@
        if ("5322".equals(data.getCompanyId())) {
            htmlStr = InoutBill.IN_WEIGHT_5322;
        }
        // 眉山市库使用
        if ("5005".equals(data.getCompanyId())) {
            htmlStr = InoutBill.IN_WEIGHT_5005;
        }
        // 丹棱库使用
        if ("5012".equals(data.getCompanyId())) {
            htmlStr = InoutBill.IN_WEIGHT_5012;
        }
        htmlStr = htmlStr.replace("billTitle", bill.getBillTitle());
@@ -93,7 +100,7 @@
        htmlStr = htmlStr.replace("fullTime", bill.getFullTime());
        htmlStr = htmlStr.replace("emptyTime", bill.getEmptyTime());
        htmlStr = htmlStr.replace("serId", bill.getSerId());
        htmlStr = htmlStr.replace("specType", bill.getSpecType());
//        htmlStr = htmlStr.replace("specType", bill.getSpecType());
        htmlStr = htmlStr.replace("customerName", bill.getCustomerName());
        htmlStr = htmlStr.replace("deptName", bill.getUnitName());
@@ -106,6 +113,7 @@
        htmlStr = htmlStr.replace("depotName", bill.getDepotName());
        htmlStr = htmlStr.replace("foodLocation", bill.getFoodLocation());
        htmlStr = htmlStr.replace("plateNum", bill.getPlateNum());
        htmlStr = htmlStr.replace("fullWeight",
                new DecimalFormat("0").format(bill.getFullWeight()));
@@ -116,6 +124,11 @@
        htmlStr = htmlStr.replace("deImpurity", bill.getDeImpurity() + "");
        htmlStr = htmlStr.replace("deWet", bill.getDeWet() + "");
        htmlStr = htmlStr.replace("recordWeight", 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").format(bill.getSettleWeight()));
@@ -127,11 +140,21 @@
        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("handleUser", bill.getHandleUser());
        htmlStr = htmlStr.replace("unitName", bill.getUnitName());
        htmlStr = htmlStr.replace("time", bill.getRegisterTime());
        htmlStr = htmlStr.replace("handleStart", "");
        htmlStr = htmlStr.replace("handleEnd", "");
        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;
    }
@@ -143,7 +166,7 @@
     */
    public String outWeightBill(InoutData data) {
        // 获取表单数据
        WeightBill bill = this.createBillData(data, "出库称重单");
        WeightBill bill = this.createBillData(data, "出库划码单");
        //默认模版
        String htmlStr = InoutBill.OUT_WEIGHT_DEFAULT;
@@ -177,7 +200,14 @@
        if ("5322".equals(data.getCompanyId())) {
            htmlStr = InoutBill.OUT_WEIGHT_5322;
        }
        // 眉山市库使用
        if ("5005".equals(data.getCompanyId())) {
            htmlStr = InoutBill.OUT_WEIGHT_5005;
        }
        // 丹棱库使用
        if ("5012".equals(data.getCompanyId())) {
            htmlStr = InoutBill.OUT_WEIGHT_5012;
        }
        htmlStr = htmlStr.replace("billTitle", bill.getBillTitle());
        htmlStr = htmlStr.replace("registerTime", bill.getRegisterTime());
@@ -185,7 +215,7 @@
        htmlStr = htmlStr.replace("fullTime", bill.getFullTime());
        htmlStr = htmlStr.replace("emptyTime", bill.getEmptyTime());
        htmlStr = htmlStr.replace("serId", bill.getSerId());
        htmlStr = htmlStr.replace("specType", bill.getSpecType());
//        htmlStr = htmlStr.replace("specType", bill.getSpecType());
        htmlStr = htmlStr.replace("customerName", bill.getCustomerName());
        htmlStr = htmlStr.replace("deptName", bill.getUnitName());
@@ -207,18 +237,29 @@
                new DecimalFormat("0").format(bill.getNetWeight()));
        htmlStr = htmlStr.replace("remark", bill.getRemark());
        htmlStr = htmlStr.replace("deWet", bill.getDeWet() + "");
//        htmlStr = htmlStr.replace("deWet", bill.getDeWet() + "");
        htmlStr = htmlStr.replace("settleWeight",
                new DecimalFormat("0").format(bill.getSettleWeight()));
        htmlStr = htmlStr.replace("deHandle", bill.getDeHandle() + "");
        htmlStr = htmlStr.replace("handleUser", bill.getHandleUser());
        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", bill.getUnitName());
        htmlStr = htmlStr.replace("time", bill.getRegisterTime());
        htmlStr = htmlStr.replace("handleStart", "");
        htmlStr = htmlStr.replace("handleEnd", "");
        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;
    }
@@ -261,7 +302,6 @@
        bill.setFullTime(DateFormatUtils.format(data.getFullWeightTime(),
                "yyyy-MM-dd HH:mm:ss"));
        bill.setSerId(data.getId());
//        bill.setSpecType(StringUtils.isEmpty(data.getSpecType())?"散粮":data.getSpecType());
        if ("5016".equals(data.getCompanyId())) {
            bill.setCompleteTime(DateFormatUtils.format(data.getCompleteTime(), "yyyy-MM-dd"));
            bill.setSerId(data.getId().substring(2));
@@ -269,7 +309,6 @@
        }
        //客户信息
       // bill.setCustomerId(data.getCustomerId() == null ? "" : data.getCustomerId());
        bill.setCustomerName(data.getCustomerName() == null ? "" : data.getCustomerName());
        bill.setUserId(data.getUserId() == null ? "" : data.getUserId());
        bill.setUserAddress(data.getUserAddress() == null ? "" : data.getUserAddress());
@@ -277,7 +316,7 @@
        //从通知单中获取收发货单位信息
        NoticeDto noticeDto = noticeService.queryNoticeById(data.getNoticeId(), data.getType());
        if(null != noticeDto && StringUtils.isNotEmpty(noticeDto.getUnitName())){
        if (null != noticeDto && StringUtils.isNotEmpty(noticeDto.getUnitName())) {
            bill.setUnitName(noticeDto.getUnitName());
        }
@@ -300,30 +339,34 @@
        bill.setFullWeight(data.getFullWeight());
        bill.setEmptyWeight(data.getEmptyWeight());
        bill.setNetWeight(data.getNetWeight());
        bill.setDeCheck(data.getDeCheck());
        bill.setAddCheck(data.getAddCheck());
        bill.setRecordWeight(data.getRecordWeight());
        bill.setCheckStatus(data.getCheckStatus().equals(InoutConstant.STATUS_PASS) ? "合格" : "不合格");
//        bill.setDeWet(data.getDeWet());
//        bill.setDeImpurity(data.getDeImpurity());
//        bill.setDeHandle(data.getDeHandle());
//        bill.setDeOther(data.getDeOther());
//        bill.setDeSum(data.getDeSum() == null ? 0.0 :data.getDeSum());
        bill.setDeHandle(data.getDeHandle());
        bill.setDeOther(data.getDeOther());
        bill.setSettleWeight(data.getSettleWeight());
//        if(data.getWet() != null && data.getWet() > 0){
//            bill.setWet(data.getWet() +"");
//        }
//        if(data.getImpurity() != null && data.getImpurity() > 0){
//            bill.setImpurity(data.getImpurity()+"");
//        }
        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.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.setSettleMoney(data.getSettleMoney() == null ? "" : data.getSettleMoney() + "");
        bill.setRemark(data.getRemarks() == null ? "" : data.getRemarks());
        bill.setDeSum(data.getDeCheck() + data.getDeOther() + data.getDeHandle() + data.getDePackage());
        if(InoutConstant.TYPE_IN.equals(data.getType())){
            bill.setWeightUser(data.getFullWeightUser());
        }
        if(InoutConstant.TYPE_OUT.equals(data.getType())){
            bill.setWeightUser(data.getEmptyWeightUser());
        }
        bill.setHandleUser(data.getHandleUser());
        bill.setKeeperUser(depot.getStoreKeeperName());
        return bill;
    }
@@ -338,15 +381,26 @@
        // 获取化验数据
        List<CheckItemData> checkLst = data.getCheckItems();
        if (null == checkLst)
            checkStandardService.getCheckItemById(data.getCheckId(),
                    data.getCompanyId());
            checkStandardService.getCheckItemById(data.getCheckId(), data.getCompanyId());
        if (checkLst == null || checkLst.size() < 1) {
            return "无化验数据,不打印!";
        }
        String mark = data.getFoodVariety().substring(0, 3);
        // 调整模版数据并返回
        String htmlStr = InoutBill.IN_CHECK_DEFAULT;
        String htmlStr = "";
        if (FoodVariety.FOOD_VARIETY_WHEAT.equals(mark)) {
            htmlStr = InoutBill.IN_CHECK_WHEAT;
        } else if (FoodVariety.FOOD_VARIETY_PADDY.equals(mark)) {
            htmlStr = InoutBill.IN_CHECK_PADDY;
        } else if (FoodVariety.FOOD_VARIETY_CORN.equals(mark)) {
            htmlStr = InoutBill.IN_CHECK_CORN;
        } else if (FoodVariety.FOOD_VARIETY_SOYBEAN.equals(data.getFoodVariety())) {
            htmlStr = InoutBill.IN_CHECK_SOYBEAN;
        } else {
            return "模板暂未确定!!";
        }
        DefaultDept dept = sysDeptService.getCacheDept(data.getCompanyId(),
                data.getDeptId());
@@ -355,26 +409,44 @@
                (dept == null ? "入库化验单" : dept.getName() + "入库化验单"));
        // 替换基础数据
        String time = DateFormatUtils.format(data.getRegisterTime(),
                "yyyy-MM-dd");
        htmlStr = htmlStr.replace("time", time);
//        String time = DateFormatUtils.format(data.getRegisterTime(),
//                "yyyy-MM-dd");
        String checkTime = data.getCheckTime() == null ? "-" : DateFormatUtils.format(data.getCheckTime(), "yyyy-MM-dd HH:mm:ss");
        String sampleTime = data.getSampleTime() == null ? "-" : DateFormatUtils.format(data.getSampleTime(), "yyyy-MM-dd HH:mm:ss");
        String reportTime = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss");
//        htmlStr = htmlStr.replace("time", time);
        htmlStr = htmlStr.replace("customerName", data.getCustomerName());
        htmlStr = htmlStr.replace("serId", data.getId());
        htmlStr = htmlStr.replace("serId", data.getId().substring(2));
        htmlStr = htmlStr.replace("deptName", dept.getName());
        htmlStr = htmlStr.replace("foodVariety", FoodVariety.getMsg(data.getFoodVariety()));
        htmlStr = htmlStr.replace("plateNum", data.getPlateNum());
        htmlStr = htmlStr.replace("userName", data.getUserName());
        htmlStr = htmlStr.replace("foodYear", data.getFoodYear() == null ? "/" : data.getFoodYear());
        htmlStr = htmlStr.replace("foodYear", data.getFoodYear() == null ? "-" : data.getFoodYear());
        Depot depot = commonService.getCacheDepot(data.getCompanyId(), data.getDepotId());
        htmlStr = htmlStr.replace("depotName", depot == null ? "/" : depot.getName());
        htmlStr = htmlStr.replace("checkUser", data.getCheckUser() == null ? "/" : data.getCheckUser());
        htmlStr = htmlStr.replace("storeKeeperName", depot == null ? "" : (depot.getStoreKeeperName() == null ? "" : depot.getStoreKeeperName()));
        htmlStr = htmlStr.replace("depotName", depot == null ? "-" : depot.getName());
        htmlStr = htmlStr.replace("checkUser", data.getCheckUser() == null ? "-" : data.getCheckUser());
        htmlStr = htmlStr.replace("foodType", data.getFoodType() == null ? "-" : data.getFoodType());
        htmlStr = htmlStr.replace("foodNumber", data.getSettleWeight() + "");
        htmlStr = htmlStr.replace("checkNum", data.getDeCheck() + "");
        htmlStr = htmlStr.replace("foodLocation", data.getFoodLocation() == null ? "-" : data.getFoodLocation());
        htmlStr = htmlStr.replace("foodLevel", data.getFoodLevel() == null ? "-" : FoodLevel.getMsg(data.getFoodLevel()));
        htmlStr = htmlStr.replace("hwmc", "");
        htmlStr = htmlStr.replace("unit", "");
        htmlStr = htmlStr.replace("sampleUser", data.getSampleUser() == null ? "-" : data.getSampleUser());
        htmlStr = htmlStr.replace("checkTime", checkTime);
        htmlStr = htmlStr.replace("sampleTime", sampleTime);
        htmlStr = htmlStr.replace("bgcjsj", reportTime);
        htmlStr = htmlStr.replace("remark", data.getRemarks() == null ? "无" : data.getRemarks());
        Map<String, String> checkBillItems = getCheckBillItems();
        // 遍历化验结果,存入map集合中
        String key;
        for (CheckItemData item : checkLst) {
            key = item.getStandardId() + "_ST";
           // checkBillItems.put(key, item.getStandardValue());
            key = item.getStandardId() + "_VAL";
            // checkBillItems.put(key, item.getStandardValue());
//            key = item.getStandardId() + "_VAL";
            checkBillItems.put(key, item.getValue());
        }
@@ -399,44 +471,76 @@
     */
    private Map<String, String> getCheckBillItems() {
        Map<String, String> map = new HashMap<>();
        map.put("C03_ST", "");
        map.put("C03_VAL", "");
        map.put("C01_ST", "");
        map.put("C01_VAL", "");
        map.put("C02_ST", "");
        map.put("C02_VAL", "");
        map.put("C03_ST", "");
        map.put("C03_VAL", "");
        map.put("C04_ST", "");
        map.put("C04_VAL", "");
        map.put("C05_ST", "");
        map.put("C05_VAL", "");
        map.put("C06_ST", "");
        map.put("C06_VAL", "");
        map.put("C07_ST", "");
        map.put("C07_VAL", "");
        map.put("C08_ST", "");
        map.put("C08_VAL", "");
        map.put("C09_ST", "");
        map.put("C09_VAL", "");
        map.put("C10_ST", "");
        map.put("C10_VAL", "");
        map.put("C11_ST", "");
        map.put("C11_VAL", "");
        map.put("C12_ST", "");
        map.put("C12_VAL", "");
        map.put("C13_ST", "");
        map.put("C13_VAL", "");
        map.put("C14_ST", "");
        map.put("C14_VAL", "");
        map.put("C15_ST", "");
        map.put("C15_VAL", "");
        map.put("C16_ST", "");
        map.put("C16_VAL", "");
        map.put("C17_ST", "");
        map.put("C17_VAL", "");
        map.put("C18_ST", "");
        map.put("C18_VAL", "");
        map.put("C19_ST", "");
        map.put("C19_VAL", "");
        map.put("C20_ST", "");
        map.put("C20_VAL", "");
        map.put("C21_ST", "");
        map.put("C21_VAL", "");
        map.put("C22_ST", "");
        map.put("C22_VAL", "");
        map.put("C23_ST", "");
        map.put("C23_VAL", "");
        map.put("C10_ST", "");
        map.put("C10_VAL", "");
        map.put("C04_ST", "");
        map.put("C04_VAL", "");
        map.put("C24_ST", "");
        map.put("C24_VAL", "");
        map.put("C08_ST", "");
        map.put("C08_VAL", "");
        map.put("C12_ST", "");
        map.put("C12_VAL", "");
        map.put("C25_ST", "");
        map.put("C25_VAL", "");
        map.put("C14_ST", "");
        map.put("C14_VAL", "");
        map.put("C29_ST", "");
        map.put("C29_VAL", "");
        map.put("C11_ST", "");
        map.put("C11_VAL", "");
        map.put("C26_ST", "");
        map.put("C26_VAL", "");
        map.put("C27_ST", "");
        map.put("C27_VAL", "");
        map.put("C28_ST", "");
        map.put("C28_VAL", "");
        map.put("C29_ST", "");
        map.put("C29_VAL", "");
        map.put("C30_ST", "");
        map.put("C30_VAL", "");
        map.put("C31_ST", "");
        map.put("C31_VAL", "");
        map.put("C32_ST", "");
        map.put("C32_VAL", "");
        map.put("C33_ST", "");
        map.put("C33_VAL", "");
        map.put("C34_ST", "");
        map.put("C34_VAL", "");
        map.put("C35_ST", "");
        map.put("C35_VAL", "");
        return map;
    }
@@ -449,7 +553,7 @@
    public String inSettleBill(InoutData data, InoutSettle settle) {
        if (null != data) {
          //  settle.setCompleteTime(data.getCompleteTime());
            //  settle.setCompleteTime(data.getCompleteTime());
            settle.setDepotId(data.getDepotId());
            settle.setDeptId(data.getDeptId());
//            settle.setUserName(data.getUserName());
@@ -516,12 +620,12 @@
        }
//        htmlStr = htmlStr.replace("driverName", settle.getUserName() + "");
//        htmlStr = htmlStr.replace("otherSum", settle.getOtherSum() + "");
        htmlStr = htmlStr.replace("paySum", settle.getPaySum() + "");
        htmlStr = htmlStr.replace("paySum", settle.getPayMoney() + "");
        htmlStr = htmlStr.replace("remark", settle.getRemarks() == null ? ""
                : settle.getRemarks());
        htmlStr = htmlStr.replace("moneyName",
                MoneyUtil.formatToCN(new BigDecimal(settle.getPaySum())));
                MoneyUtil.formatToCN(new BigDecimal(settle.getPayMoney())));
        return htmlStr;
    }
@@ -614,18 +718,18 @@
        }
        String htmlStr;
        if(list.size() <= 30){
        if (list.size() <= 30) {
            //只有一页时
            htmlStr = getShipBill(data, list, true,0);
            htmlStr = getShipBill(data, list, true, 0);
            result.add(htmlStr);
        }else {
        } else {
            //有多页时
            int page = list.size()/30 + 1;
            int page = list.size() / 30 + 1;
            for (int i = 1; i <= page; i++) {
                if(i == page){
                    htmlStr = getShipBill(data, list.subList((i-1)*30, list.size()),true, i);
                }else {
                    htmlStr = getShipBill(data, list.subList((i-1)*30, i*30),false, i);
                if (i == page) {
                    htmlStr = getShipBill(data, list.subList((i - 1) * 30, list.size()), true, i);
                } else {
                    htmlStr = getShipBill(data, list.subList((i - 1) * 30, i * 30), false, i);
                }
                result.add(htmlStr);
            }
@@ -636,6 +740,7 @@
    /**
     * 获取船运打印模板数据
     *
     * @param data    流水信息
     * @param list    车辆信息,数量不大于30
     * @param moreTag 结算标签,true-代表结算页;false-不是结算页
@@ -646,7 +751,7 @@
        //调整模版数据并返回
        String htmlStr = InoutBill.SHIP_WEIGHT_DEFAULT_MORE;
        if(moreTag){
        if (moreTag) {
            htmlStr = InoutBill.SHIP_WEIGHT_DEFAULT;
        }
@@ -654,7 +759,7 @@
        //表头
        String billTitle = (dept == null ? "船运过磅单" : dept.getName() + "船运过磅单");
        if(0 != pageNum){
        if (0 != pageNum) {
            billTitle += " - 第" + pageNum + "页";
        }
        htmlStr = htmlStr.replace("billTitle", billTitle);
@@ -695,7 +800,7 @@
        }
        //添加结算信息
        if(moreTag){
        if (moreTag) {
            htmlStr = htmlStr.replace("handleUser", depot == null ? "" : (depot.getStoreKeeperName() == null ? "" : depot.getStoreKeeperName()));
            htmlStr = htmlStr.replace("remarks", data.getRemarks() == null ? "" : data.getRemarks());
            htmlStr = htmlStr.replace("fullWeight", new DecimalFormat("0").format(data.getFullWeight()));
@@ -704,6 +809,26 @@
        }
        return htmlStr;
    }
    /**
     * 打印扦样单,直接返回条形码Base64图片
     *
     * @param data
     * @return
     */
    public String simpleBill(InoutCheckData data) {
        if (null == data.getId()) return null;
        if (null == data.getCheckId()) return null;
        if (null == data.getCheckTime()) {
            data.setCheckTime(new Date());
        }
        String imgBase64 = BarCodeUtils.getBarCodeImageBase64(data.getId(), data.getCheckId(), "粮食样品单条码", DateFormatUtils.format(data.getCheckTime(), "yyyy-MM-dd HH:mm"));
        return imgBase64;
    }
    public static void main(String[] args) {
@@ -724,4 +849,5 @@
        List<String> strings3 = result.subList(6, 8);
        System.out.println(strings3);
    }
}