廖井涛
2024-04-18 45835ffc03d7a1a1a4a86a33382ad367bfb597e0
打印跳转
5个文件已修改
797 ■■■■ 已修改文件
north-glass-erp/northglass-erp/src/views/sd/delivery/DeliveryPrinting.vue 526 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/northglass-erp/src/views/sd/delivery/SelectDelivery.vue 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/src/main/java/com/example/erp/service/sd/DeliveryService.java 258 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/src/main/resources/mapper/sd/Delivery.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/target/classes/mapper/sd/Delivery.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/northglass-erp/src/views/sd/delivery/DeliveryPrinting.vue
@@ -1,9 +1,11 @@
<script setup>
import request from "@/utils/request"
import {ElDatePicker, ElMessage} from "element-plus"
import {nextTick, onMounted, onUnmounted, reactive, ref, watch} from "vue"
import {Search} from "@element-plus/icons-vue"
import {useRouter} from 'vue-router'
import {useRoute, useRouter} from "vue-router"
import {changeFilterEvent, filterChanged} from "@/hook"
import { useI18n } from 'vue-i18n'
@@ -11,8 +13,12 @@
//语言获取
const { t } = useI18n()
let router=useRouter()
const route = useRoute()
let produceList = ref([])
let delivery = ref([])
let money = ref("")
let takeCare = "注意:请妥善保管好我司的玻璃架,如有丢失或损坏,按1500元只赔偿。谢谢配合!"
let remark = "备注:本批玻璃为优等合格品,请在卸货时,当面消点验收、如有质量问题在一周内与本公司联系,否则概不负责!"
let props = defineProps({
  deliveryId:null
@@ -21,18 +27,65 @@
const form = ref({
})
const Printing =  ()=>{
  // 需要打印的局部区域赋予"print-wrap"的id
  let el = document.getElementById("pis");
  let doc = document;
  let body = doc.body || doc.getElementsByTagName("body")[0];
  let printId = "print-" + Date.now();
  // 创建无副作用的打印容器(因不确定页面的打印元素有无其它样式)
  let content = doc.createElement("div");
  content.id = printId;
  // 样式控制与打印无关的元素隐藏
  let style = doc.createElement("style");
  style.innerHTML =
      "body>#" +
      printId +
      "{display:none}@media print{body>:not(#" +
      printId +
      "){display:none !important}body>#" +
      printId +
      "{display:block;padding-top:1px}}";
  content.innerHTML = el.outerHTML;
  // console.log("el.outerHTML", el.outerHTML);
  body.appendChild(style);
  // 与style元素设置的样式相配合
  // 把打印内容的元素添加到body(作为body的子元素,可用body的子选择器 '>' 控制打印样式)
  body.appendChild(content);
  setTimeout(() => {
    window.print();
    body.removeChild(content);
    body.removeChild(style);
  }, 20);
}
onMounted(()=>{
  console.log(props.deliveryId)
  if(props.deliveryId===null  || props.deliveryId===undefined || props.deliveryId===''){
  /*if(props.deliveryId===null  || props.deliveryId===undefined || props.deliveryId===''){
    return
  }
  form.value.deliveryId = props.deliveryId
  form.value.deliveryId = props.deliveryId*/
  if(route.query.deliveryID===null  || route.query.deliveryID===undefined || route.query.deliveryID===''){
    return
  }
  form.value.deliveryId=route.query.deliveryID
  request.post(`/Delivery/getSelectDeliveryPrinting`,form.value).then((res) => {
    if(res.code==200){
      produceList = deepClone(res.data.data)
      delivery=deepClone(res.data.delivery)
      console.log(produceList)
      console.log(delivery)
      produceList.value = deepClone(res.data.data)
      delivery.value=deepClone(res.data.delivery)
      money.value=deepClone(res.data.money)
    }else{
      ElMessage.warning(res.msg)
      router.push("/login")
@@ -41,184 +94,321 @@
})
setTimeout(function(){
  Printing()
}, 1000);
</script>
<template>
  <div style="width: 100%;height: 100%">
    <div style="font-size: 30px;text-align: center">常州市吉利玻璃有限公司</div>
    <el-row :gutter="20">
      <el-col :span="6"><div></div></el-col>
      <el-col :span="12"><div style="font-size: 25px;text-align: center">销售发货单</div></el-col>
      <el-col :span="6">
        <div style="font-size: 20px;text-align: center;display: flex">
          <div>发货单号:</div>
          <div>{{delivery.deliveryId}}</div>
        </div>
      </el-col>
    </el-row>
    <div style="border: 1px solid #d3dce6;border-collapse: collapse;width: 100%">
      <table id="day-in" style="border: 1px solid #d3dce6;border-collapse: collapse;width: 100%">
        <tr>
          <th>序号</th>
          <th>楼层编号</th>
          <th>宽(弧度)*高</th>
          <th>数量</th>
          <th>面积</th>
          <th>单价</th>
          <th>金额</th>
          <th>加工要求</th>
        </tr>
        <template v-for="(item, index) in produceList" :key="index" >
              <tr>
                <td colspan="3">产品名称:{{item.DeliveryDetail.orderDetail.productName}}</td>
                <td colspan="3">对方单号:</td>
                <td colspan="2">订单编号:{{item.DeliveryDetail.orderDetail.orderId}}</td>
              </tr>
  <div>
    <el-button @click="Printing" style="margin-top: -5px"  id="searchButton" type="primary" >打印</el-button>
    <div id="pis" style="width: 100%;height: 100%">
      <div style="font-size: 30px;text-align: center;font-weight: bold;">常州市吉利玻璃有限公司</div>
      <el-row :gutter="20">
        <el-col :span="7"><div></div></el-col>
        <el-col :span="10"><div style="font-size: 25px;text-align: center;font-weight: bold;">销售发货单</div></el-col>
        <el-col :span="7">
          <div style="display: flex;margin-top: 10px">
            <div style="font-weight: bold;font-size: 15px">发货单号:</div>
            <div style="font-weight: bold;font-size: 15px">{{delivery.deliveryId}}</div>
          </div>
        </el-col>
      </el-row>
      <div style="border: 1px solid #d3dce6;border-collapse: collapse;width: 100%;height: 100%;">
        <table id="table1" style="border: 1px solid #d3dce6;border-collapse: collapse;width: 100%;height: 100%;">
          <tr>
            <th style="text-align: left;border:none;font-size: 15px;font-weight: bold;" colspan="3">客户名称:<span>{{delivery.customerName}}</span></th>
            <th style="text-align: left;border:none;font-size: 15px;font-weight: bold;" colspan="3">项目名称:<span>{{delivery.project}}</span></th>
            <th style="text-align: left;border:none;font-size: 15px;font-weight: bold;" colspan="2">联系人:<span>{{delivery.contacts}}</span></th>
              <tr v-for="(items, index1) in item.DeliveryDetailList" :key="index1">
                <td>{{items.order_number}}</td>
                <td>{{items.buildingNumber}}</td>
                <td>{{items.width}}x{{items.height}}</td>
                <td>{{items.quantity}}</td>
                <td>{{items.area}}</td>
                <td>{{items.price}}</td>
                <td>{{items.money}}</td>
                <td>{{items.processingNote}}</td>
              </tr>
              <tr>
                <td colspan="3">小计:</td>
                <td>{{item.DeliveryDetail.quantity}}</td>
                <td>{{item.DeliveryDetail.area}}</td>
                <td></td>
                <td>{{item.DeliveryDetail.money}}</td>
                <td></td>
              </tr>
          </tr>
          <tr>
            <th style="text-align: left;border:none;font-size: 15px;font-weight: bold;" colspan="6">送货地址:<span>{{delivery.deliveryAddress}}</span></th>
            <th style="text-align: left;border:none;font-size: 15px;font-weight: bold;" colspan="2">联系电话:<span>{{delivery.contactNumber}}</span></th>
        </template>
        <tr>
          <td colspan="3">合计:</td>
          <td>{{delivery.quantity}}</td>
          <td>{{delivery.area}}</td>
          <td></td>
          <td>{{delivery.money}}</td>
          <td></td>
        </tr>
      </table>
          </tr>
          <tr>
            <th style="width: 6%;font-size: 15px;font-weight: bold;">序号</th>
            <th style="width: 20%;font-size: 15px;font-weight: bold;">楼层编号</th>
            <th style="width: 20%;font-size: 15px;font-weight: bold;">宽(弧度)*高</th>
            <th style="width: 10%;font-size: 15px;font-weight: bold;">数量</th>
            <th style="width: 10%;font-size: 15px;font-weight: bold;">面积</th>
            <th style="width: 10%;font-size: 15px;font-weight: bold;">单价</th>
            <th style="width: 12%;font-size: 15px;font-weight: bold;">金额</th>
            <th style="width: 12%;font-size: 15px;font-weight: bold;">加工要求</th>
          </tr>
          <template v-for="(item, index) in produceList" :key="index" >
            <tr>
              <td style="font-size: 15px;font-weight: bold;" colspan="3">产品名称:<span>{{item.DeliveryDetail.orderDetail.productName}}</span></td>
              <td style="font-size: 15px;font-weight: bold;" colspan="3">对方单号:</td>
              <td style="font-size: 15px;font-weight: bold;" colspan="2">订单编号:<span>{{item.DeliveryDetail.orderDetail.orderId}}</span></td>
            </tr>
            <tr class="day-in" v-for="(items, index1) in item.DeliveryDetailList" :key="index1">
              <td>{{items.order_number}}</td>
              <td>{{items.buildingNumber}}</td>
              <td style="font-size: 15px;font-weight: bold;">{{items.width}}x{{items.height}}</td>
              <td>{{items.quantity}}</td>
              <td>{{items.area}}</td>
              <td>{{items.price}}</td>
              <td>{{items.money}}</td>
              <td>{{items.processingNote}}</td>
            </tr>
            <tr class="day-in">
              <td style="font-size: 15px;font-weight: bold;" colspan="3">小计:</td>
              <td>{{item.DeliveryDetail.quantity}}</td>
              <td>{{item.DeliveryDetail.area}}</td>
              <td></td>
              <td>{{item.DeliveryDetail.money}}</td>
              <td></td>
            </tr>
          </template>
          <tr class="day-in">
            <td style="font-size: 15px;font-weight: bold;" colspan="3">合计:</td>
            <td>{{delivery.quantity}}</td>
            <td>{{delivery.area}}</td>
            <td></td>
            <td>{{delivery.money}}</td>
            <td></td>
          </tr>
          <tr class="day-in">
            <td style="text-align: left;border-width: 0 1px 0 0; border-style: solid; border-color: #d3dce6" colspan="3">
              <div style="display: flex;font-size: 10px;">
                <div>加工费用</div>
                <div  style="margin-left: 20%">单价</div>
                <div  style="margin-left: 20%">数量</div>
                <div  style="margin-left: 20%">金额</div>
              </div>
            </td>
            <td style="text-align: left;border:none;font-size: 15px;font-weight: bold;" colspan="5">总金额:&nbsp;&nbsp;&nbsp;&nbsp;{{delivery.money}}</td>
          </tr>
          <tr class="day-in">
            <td style="text-align: left;border-width: 0 1px 0 0; border-style: solid; border-color: #d3dce6;" colspan="3"></td>
            <td style="text-align: left;border:none;font-size: 15px;font-weight: bold;" colspan="5">大写金额:&nbsp;&nbsp;&nbsp;&nbsp;{{money}}</td>
          </tr>
        </table>
      </div>
      <el-row :gutter="20">
        <el-col :span="3"><div class="bottom">制单员:<span style="font-size: 10px">{{delivery.creator}}</span></div></el-col>
        <el-col :span="5"><div class="bottom">制单日期:<span style="font-size: 10px">{{delivery.createTime}}</span></div></el-col>
        <el-col :span="4"><div class="bottom">发货员:</div></el-col>
        <el-col :span="4"><div class="bottom">司机:</div></el-col>
        <el-col :span="4"><div class="bottom">客户签字:</div></el-col>
        <el-col :span="4"><div class="bottom">签收日期:</div></el-col>
      </el-row>
      <el-row :gutter="20" style="margin-top: 20px;">
        <el-col :span="3"><div class="bottom">架子&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;只</div></el-col>
        <el-col :span="21"><div class="bottom">{{takeCare}}</div></el-col>
      </el-row>
      <el-row :gutter="20" style="margin-top: 20px;">
        <el-col :span="24"><div class="bottom">{{remark}}</div></el-col>
      </el-row>
    </div>
<!--    <div style="border: 1px solid #d3dce6;border-collapse: collapse;">-->
<!--      <el-row :gutter="20" >-->
<!--        <el-col :span="9">-->
<!--          <div style="font-size: 20px;display: flex">-->
<!--            <div>客户名称:</div>-->
<!--            <div>常州市金宝石门窗有限公司</div>-->
<!--          </div>-->
<!--        </el-col>-->
<!--        <el-col :span="9">-->
<!--          <div style="font-size: 20px;display: flex">-->
<!--            <div>项目名称:</div>-->
<!--            <div>公园道</div>-->
<!--          </div>-->
<!--        </el-col>-->
<!--        <el-col :span="6">-->
<!--          <div style="font-size: 20px;display: flex">-->
<!--            <div>联系人:</div>-->
<!--            <div></div>-->
<!--          </div>-->
<!--        </el-col>-->
<!--      </el-row>-->
<!--      <el-row :gutter="20" >-->
<!--        <el-col :span="18">-->
<!--          <div style="font-size: 20px;display: flex">-->
<!--            <div>送货地址:</div>-->
<!--            <div></div>-->
<!--          </div>-->
<!--        </el-col>-->
<!--        <el-col :span="6">-->
<!--          <div style="font-size: 20px;display: flex">-->
<!--            <div>联系电话:</div>-->
<!--            <div></div>-->
<!--          </div>-->
<!--        </el-col>-->
<!--      </el-row>-->
<!--    </div>-->
<!--    <div style="border: 1px solid #d3dce6;border-collapse: collapse;">-->
<!--      <el-row :gutter="20" >-->
<!--        <el-col :span="2">-->
<!--          <div class="alias">-->
<!--            <div>序号</div>-->
<!--          </div>-->
<!--        </el-col>-->
<!--        <el-col :span="5">-->
<!--          <div class="alias">-->
<!--            <div>楼层编号</div>-->
<!--          </div>-->
<!--        </el-col>-->
<!--        <el-col :span="5">-->
<!--          <div class="alias">-->
<!--            <div>宽(弧长)*高</div>-->
<!--          </div>-->
<!--        </el-col>-->
<!--        <el-col :span="2">-->
<!--          <div class="alias">-->
<!--            <div>数量</div>-->
<!--          </div>-->
<!--        </el-col>-->
<!--        <el-col :span="2">-->
<!--          <div class="alias">-->
<!--            <div>面积</div>-->
<!--          </div>-->
<!--        </el-col>-->
<!--        <el-col :span="2">-->
<!--          <div class="alias">-->
<!--            <div>单价</div>-->
<!--          </div>-->
<!--        </el-col>-->
<!--        <el-col :span="2">-->
<!--          <div class="alias" >-->
<!--            <div>金额</div>-->
<!--          </div>-->
<!--        </el-col>-->
<!--        <el-col :span="4">-->
<!--          <div class="alias" >-->
<!--            <div>加工要求</div>-->
<!--          </div>-->
<!--        </el-col>-->
<!--      </el-row>-->
<!--    </div>-->
  </div>
</template>
<style>
@media print{
  @page {
    mso-header:none;
    margin: 10mm 16mm;
    margin-bottom: 8mm;
    margin-top:8mm;
  }
}
#table1 tr{
  height: 30px;
}
#table1 th{
  height: 30px;
  border: 1px solid #d3dce6;
  border-collapse: collapse;
}
.day-in td{
text-align: center;
}
#table1 td{
  border: 1px solid #d3dce6;
  border-collapse: collapse;
}
#deliveryPrinting .el-dialog__header{
  visibility:hidden
}
.el-overlay-dialog{
  overflow-y: scroll;
}
::-webkit-scrollbar {
  display: none;
}
.bottom{
  font-size: 10px;
  font-weight: bold;
}
</style>
<!--
<template>
  <div>
    <div id="pis" style="width: 100%;height: 100%">
      <div style="font-size: 35px;text-align: center;font-weight: bold;">常州市吉利玻璃有限公司</div>
      <el-row :gutter="20">
        <el-col :span="6"><div></div></el-col>
        <el-col :span="12"><div style="font-size: 30px;text-align: center;font-weight: bold;">销售发货单</div></el-col>
        <el-col :span="6">
          <div style="font-size: 20px;display: flex;margin-top: 10px">
            <div style="font-weight: bold;">发货单号:</div>
            <div style="font-weight: bold;">{{delivery.deliveryId}}</div>
          </div>
        </el-col>
      </el-row>
      <div style="border: 1px solid #d3dce6;border-collapse: collapse;width: 100%;height: 100%;">
        <table id="table1" style="border: 1px solid #d3dce6;border-collapse: collapse;width: 100%;height: 100%;">
          <tr>
            <th style="text-align: left;border:none;font-size: 15px;font-weight: bold;" colspan="3">客户名称:{{delivery.customerName}}</th>
            <th style="text-align: left;border:none;font-size: 15px;font-weight: bold;" colspan="3">项目名称:{{delivery.project}}</th>
            <th style="text-align: left;border:none;font-size: 15px;font-weight: bold;" colspan="2">联系人:{{delivery.contacts}}</th>
          </tr>
          <tr>
            <th style="text-align: left;border:none;font-size: 15px;font-weight: bold;" colspan="6">送货地址:{{delivery.deliveryAddress}}</th>
            <th style="text-align: left;border:none;font-size: 15px;font-weight: bold;" colspan="2">联系电话:{{delivery.contactNumber}}</th>
          </tr>
          <tr>
            <th style="width: 6%;font-size: 15px;font-weight: bold;">序号</th>
            <th style="width: 20%;font-size: 15px;font-weight: bold;">楼层编号</th>
            <th style="width: 20%;font-size: 15px;font-weight: bold;">宽(弧度)*高</th>
            <th style="width: 10%;font-size: 15px;font-weight: bold;">数量</th>
            <th style="width: 10%;font-size: 15px;font-weight: bold;">面积</th>
            <th style="width: 10%;font-size: 15px;font-weight: bold;">单价</th>
            <th style="width: 12%;font-size: 15px;font-weight: bold;">金额</th>
            <th style="width: 12%;font-size: 15px;font-weight: bold;">加工要求</th>
          </tr>
          <template v-for="(item, index) in produceList" :key="index" >
            <tr>
              <td style="font-size: 15px;font-weight: bold;" colspan="3">产品名称:{{item.DeliveryDetail.orderDetail.productName}}</td>
              <td style="font-size: 15px;font-weight: bold;" colspan="3">对方单号:</td>
              <td style="font-size: 15px;font-weight: bold;" colspan="2">订单编号:{{item.DeliveryDetail.orderDetail.orderId}}</td>
            </tr>
            <tr class="day-in" v-for="(items, index1) in item.DeliveryDetailList" :key="index1">
              <td>{{items.order_number}}</td>
              <td>{{items.buildingNumber}}</td>
              <td style="font-size: 15px;font-weight: bold;">{{items.width}}x{{items.height}}</td>
              <td>{{items.quantity}}</td>
              <td>{{items.area}}</td>
              <td>{{items.price}}</td>
              <td>{{items.money}}</td>
              <td>{{items.processingNote}}</td>
            </tr>
            <tr class="day-in">
              <td style="font-size: 15px;font-weight: bold;" colspan="3">小计:</td>
              <td>{{item.DeliveryDetail.quantity}}</td>
              <td>{{item.DeliveryDetail.area}}</td>
              <td></td>
              <td>{{item.DeliveryDetail.money}}</td>
              <td></td>
            </tr>
          </template>
          <tr class="day-in">
            <td style="font-size: 15px;font-weight: bold;" colspan="3">合计:</td>
            <td>{{delivery.quantity}}</td>
            <td>{{delivery.area}}</td>
            <td></td>
            <td>{{delivery.money}}</td>
            <td></td>
          </tr>
          <tr class="day-in">
            <td style="text-align: left;border-width: 0 1px 0 0; border-style: solid; border-color: #d3dce6" colspan="3">
              <div style="display: flex">
                <div>加工费用</div>
                <div  style="margin-left: 20%">单价</div>
                <div  style="margin-left: 20%">数量</div>
                <div  style="margin-left: 20%">金额</div>
              </div>
            </td>
            <td style="text-align: left;border:none;font-size: 15px;font-weight: bold;" colspan="5">总金额:&nbsp;&nbsp;&nbsp;&nbsp;{{delivery.money}}</td>
          </tr>
          <tr class="day-in">
            <td style="text-align: left;border-width: 0 1px 0 0; border-style: solid; border-color: #d3dce6;" colspan="3"></td>
            <td style="text-align: left;border:none;font-size: 15px;font-weight: bold;" colspan="5">大写金额:&nbsp;&nbsp;&nbsp;&nbsp;{{money}}</td>
          </tr>
        </table>
      </div>
      <el-row :gutter="20">
        <el-col :span="3"><div class="bottom">制单员:<span style="font-size: 15px">{{delivery.creator}}</span></div></el-col>
        <el-col :span="5"><div class="bottom">制单日期:<span style="font-size: 15px">{{delivery.createTime}}</span></div></el-col>
        <el-col :span="4"><div class="bottom">发货员:</div></el-col>
        <el-col :span="4"><div class="bottom">司机:</div></el-col>
        <el-col :span="4"><div class="bottom">客户签字:</div></el-col>
        <el-col :span="4"><div class="bottom">签收日期:</div></el-col>
      </el-row>
      <el-row :gutter="20" style="margin-top: 20px;">
        <el-col :span="3"><div class="bottom">架子&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;只</div></el-col>
        <el-col :span="21"><div class="bottom">{{takeCare}}</div></el-col>
      </el-row>
      <el-row :gutter="20" style="margin-top: 20px;">
        <el-col :span="24"><div class="bottom">{{remark}}</div></el-col>
      </el-row>
    </div>
  </div>
</template>
<style >
.el-row {
  margin-bottom: 10px;
#table1 tr{
  height: 30px;
}
.el-row:last-child {
  margin-bottom: 0;
#table1 th{
  height: 30px;
  border: 1px solid #d3dce6;
  border-collapse: collapse;
}
.el-col {
  border-radius: 4px;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.alias{
.day-in td{
  text-align: center;
  font-size: 20px;
}
#table1 td{
  border: 1px solid #d3dce6;
  border-collapse: collapse;
}
#deliveryPrinting .el-dialog__header{
  visibility:hidden
}
</style>
.el-overlay-dialog{
  overflow-y: scroll;
}
::-webkit-scrollbar {
  display: none;
}
.bottom{
  font-size: 20px;
  font-weight: bold;
}
</style>-->
north-glass-erp/northglass-erp/src/views/sd/delivery/SelectDelivery.vue
@@ -26,8 +26,10 @@
      break
    }
    case 'printing' :{
      const url = router.resolve({path: '/main/delivery/deliveryPrinting', query: { deliveryID: row.deliveryId }})
      /*const url = router.resolve({path: '/main/delivery/deliveryPrinting', query: { deliveryID: row.deliveryId }})
      window.open(url.href, '_blank')
      break*/
      router.push({path: '/main/delivery/deliveryPrinting', query: { deliveryID: row.deliveryId }})
      break
    }
    case 'delete':{
@@ -355,10 +357,11 @@
    <el-dialog
        v-model="dialogTableVisible"
        destroy-on-close
        style="width: 75%;height:70% ">
        id="deliveryPrinting"
        style="width: 100%;height:100%;margin-top: 0; ">
      <DeliveryPrinting
          :deliveryId="rowClickIndex.deliveryId"
          style="width: 100%;height: 100%" />
          style="width: 100%;height: 100%;" />
    </el-dialog>
  </div>
north-glass-erp/src/main/java/com/example/erp/service/sd/DeliveryService.java
@@ -1,5 +1,6 @@
package com.example.erp.service.sd;
import com.alibaba.excel.util.StringUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
@@ -22,6 +23,7 @@
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
import java.math.BigDecimal;
@Service
@DS("sd")
@@ -268,26 +270,268 @@
    public Map<String, Object> getSelectDeliveryPrinting( DeliveryDetail deliveryDetail) {
        Map<String, Object> map = new HashMap<>();
        List <Map<String, Object>> list=new ArrayList<Map<String, Object>>();//最终结果
        System.out.println(deliveryDetail);
        List<DeliveryDetail> deliveryDetailList=deliveryDetailMapper.getSelectDeliveryPrinting(deliveryDetail);
        for (int i = 0; i < deliveryDetailList.size(); i++) {
        for (DeliveryDetail detail : deliveryDetailList) {
            Map<String, Object> itemmap = new HashMap<>();
            List <Map<String, Object>> deliveryDetailList2=deliveryDetailMapper.getSelectDeliveryDetailPrinting(deliveryDetailList.get(i).getDeliveryId(),
                    deliveryDetailList.get(i).getOrderDetail().getProductId(),deliveryDetailList.get(i).getOrderDetail().getOrderId());
            itemmap.put("DeliveryDetail",deliveryDetailList.get(i));
            itemmap.put("DeliveryDetailList",deliveryDetailList2);
            List<Map<String, Object>> deliveryDetailList2 = deliveryDetailMapper.getSelectDeliveryDetailPrinting(detail.getDeliveryId(),
                    detail.getOrderDetail().getProductId(), detail.getOrderDetail().getOrderId());
            itemmap.put("DeliveryDetail", detail);
            itemmap.put("DeliveryDetailList", deliveryDetailList2);
            list.add(itemmap);
        }
        Delivery delivery=deliveryMapper.getSelectShippingOrderDetailDeliveryPrinting(deliveryDetail);
        map.put("data", list);
        map.put("delivery", deliveryMapper.getSelectShippingOrderDetailDeliveryPrinting(deliveryDetail));
        map.put("money", toChinese(delivery.getMoney().toString(), false));
        return map;
    }
    private static final String[] NUMBERS = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};
    private static final String[] IUNIT = {"元", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟"};
    private static final String[] DUNIT = {"角", "分"};
    private static final String[] CN_NUMBERS = {"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"};
    private static final String[] CN_IUNIT = {"", "十", "百", "千", "万", "十", "百", "千", "亿", "十", "百", "千"};
    /**
     *  转换为大写的中文金额,支持负数
     * @param amount 金额
     * @param isSimplified 是否简体中文:true:简体,false:繁体
     * @return
     */
    public static String toChinese(String amount, boolean isSimplified) {
        // 判断输入的金额字符串是否符合要求
        if (StringUtils.isBlank(amount) || !amount.matches("(-)?[\\d]*(.)?[\\d]*")) {
            throw new RuntimeException("请输入数字");
        }
        if ("0".equals(amount) || "0.00".equals(amount) || "0.0".equals(amount)) {
            return isSimplified ? "零" : "零元";
        }
        // 判断金额数字中是否存在负号"-"
        boolean flag = false;
        if (amount.startsWith("-")) {
            // 标志位,标志此金额数字为负数
            flag = true;
            amount = amount.replaceAll("-", "");
        }
        // 去掉金额数字中的逗号","
        amount = amount.replaceAll(",", "");
        // 初始化:分离整数部分和小数部分
        String[] separateNum = separateNum(amount);
        // 整数部分数字
        String integerStr = separateNum[0];
        // 小数部分数字
        String decimalStr = separateNum[1];
        // beyond超出计算能力,直接返回
        if (integerStr.length() > IUNIT.length) {
            throw new RuntimeException("输入数字超限");
        }
        // 整数部分数字
        int[] integers = toIntArray(integerStr);
        // 判断整数部分是否存在输入012的情况
        if (integers.length > 1 && integers[0] == 0) {
            throw new RuntimeException("输入数字不符合要求");
        }
        // 设置万单位
        boolean isWan = isWan5(integerStr);
        // 小数部分数字
        int[] decimals = toIntArray(decimalStr);
        // 返回最终的大写金额
        String result = "";
        String chineseInteger = getChineseInteger(integers, isWan, isSimplified);
        String chineseDecimal = getChineseDecimal(decimals, isSimplified);
        if (decimals.length > 0 && isSimplified) {
            result = chineseInteger;
            if (!chineseDecimal.equals("零零")) {
                result = result + "点" + chineseDecimal;
            }
        } else {
            result = chineseInteger + chineseDecimal;
        }
        if (flag) {
            // 如果是负数,加上"负"
            return "负" + result;
        } else {
            return result;
        }
    }
    /**
     * 分离整数部分和小数部分
     * @param str
     * @return
     */
    private static String[] separateNum(String str) {
        String integerStr;// 整数部分数字
        String decimalStr;// 小数部分数字
        if (str.indexOf('.') >= 1) {
            integerStr = str.substring(0, str.indexOf('.'));
            decimalStr = str.substring(str.indexOf('.') + 1);
            if (decimalStr.length() > 2) {
                decimalStr = decimalStr.substring(0, 2);
            }
        } else if (str.indexOf('.') == 0) {
            integerStr = "";
            decimalStr = str.substring(1);
        } else {
            integerStr = str;
            decimalStr = "";
        }
        return new String[] {integerStr, decimalStr};
    }
    /**
     *  将字符串转为int数组
     * @param number  数字
     * @return
     */
    private static int[] toIntArray(String number) {
        int[] array = new int[number.length()];
        for (int i = 0; i < number.length(); i++) {
            array[i] = Integer.parseInt(number.substring(i, i + 1));
        }
        return array;
    }
    /**
     *  将整数部分转为大写的金额
     * @param integers 整数部分数字
     * @param isWan  整数部分是否已经是达到【万】
     * @return
     */
    private static String getChineseInteger(int[] integers, boolean isWan, boolean isSimplified) {
        int length = integers.length;
        if (!isSimplified && length == 1 && integers[0] == 0) {
            return "";
        }
        if (!isSimplified) {
            return traditionalChineseInteger(integers, isWan);
        } else {
            return simplifiedChineseInteger(integers, isWan);
        }
    }
    /**
     * 繁体中文整数
     * @param integers
     * @param isWan
     * @return
     */
    private static String traditionalChineseInteger(int[] integers, boolean isWan) {
        StringBuilder chineseInteger = new StringBuilder("");
        int length = integers.length;
        for (int i = 0; i < length; i++) {
            String key = "";
            if (integers[i] == 0) {
                if ((length - i) == 13)// 万(亿)
                    key = IUNIT[4];
                else if ((length - i) == 9) {// 亿
                    key = IUNIT[8];
                } else if ((length - i) == 5 && isWan) {// 万
                    key = IUNIT[4];
                } else if ((length - i) == 1) {// 元
                    key = IUNIT[0];
                }
                if ((length - i) > 1 && integers[i + 1] != 0) {
                    key += NUMBERS[0];
                }
            }
            chineseInteger.append(integers[i] == 0 ? key : (NUMBERS[integers[i]] + IUNIT[length - i - 1]));
        }
        return chineseInteger.toString();
    }
    /**
     * 简体中文整数
     * @param integers
     * @param isWan
     * @return
     */
    private static String simplifiedChineseInteger(int[] integers, boolean isWan) {
        StringBuilder chineseInteger = new StringBuilder("");
        int length = integers.length;
        for (int i = 0; i < length; i++) {
            String key = "";
            if (integers[i] == 0) {
                if ((length - i) == 13) {// 万(亿)
                    key = CN_IUNIT[4];
                } else if ((length - i) == 9) {// 亿
                    key = CN_IUNIT[8];
                } else if ((length - i) == 5 && isWan) {// 万
                    key = CN_IUNIT[4];
                } else if ((length - i) == 1) {// 元
                    key = CN_IUNIT[0];
                }
                if ((length - i) > 1 && integers[i + 1] != 0) {
                    key += CN_NUMBERS[0];
                }
                if (length == 1 && integers[i] == 0) {
                    key += CN_NUMBERS[0];
                }
            }
            chineseInteger.append(integers[i] == 0 ? key : (CN_NUMBERS[integers[i]] + CN_IUNIT[length - i - 1]));
        }
        return chineseInteger.toString();
    }
    /**
     *  将小数部分转为大写的金额
     * @param decimals 小数部分的数字
     * @return
     */
    private static String getChineseDecimal(int[] decimals, boolean isSimplified) {
        StringBuilder chineseDecimal = new StringBuilder("");
        if (!isSimplified) {
            for (int i = 0; i < decimals.length; i++) {
                String key = "";
                if ((decimals.length - i) > 1 && decimals[i + 1] != 0) {
                    key += NUMBERS[0];
                }
                chineseDecimal.append(decimals[i] == 0 ? key : (NUMBERS[decimals[i]] + DUNIT[i]));
            }
        } else {
            for (int i = 0; i < decimals.length; i++) {
                chineseDecimal.append(CN_NUMBERS[decimals[i]]);
            }
        }
        return chineseDecimal.toString();
    }
    /**
     *  判断当前整数部分是否已经是达到【万】
     * @param integerStr  整数部分数字
     * @return
     */
    private static boolean isWan5(String integerStr) {
        int length = integerStr.length();
        if (length > 4) {
            String subInteger = "";
            if (length > 8) {
                subInteger = integerStr.substring(length - 8, length - 4);
            } else {
                subInteger = integerStr.substring(0, length - 4);
            }
            return Integer.parseInt(subInteger) > 0;
        } else {
            return false;
        }
    }
    public String orderNumberSetting(String type) {
        //根据类型自动生成不同的操作单号
north-glass-erp/src/main/resources/mapper/sd/Delivery.xml
@@ -204,7 +204,7 @@
    <select id="getSelectShippingOrderDetailDeliveryPrinting" >
        select
        d.delivery_id,d.quantity,d.money,d.area,
        d.delivery_id,d.quantity,d.money,d.area,d.project,
        d.customer_id,d.customer_name,d.project,d.pay_method,d.pay_date,d.contacts,d.contact_number,
        d.delivery_address,d.remarks,d.create_time,d.delivery_date,d.creator,d.salesman,d.salesman_id
        from sd.delivery d
north-glass-erp/target/classes/mapper/sd/Delivery.xml
@@ -204,7 +204,7 @@
    <select id="getSelectShippingOrderDetailDeliveryPrinting" >
        select
        d.delivery_id,d.quantity,d.money,d.area,
        d.delivery_id,d.quantity,d.money,d.area,d.project,
        d.customer_id,d.customer_name,d.project,d.pay_method,d.pay_date,d.contacts,d.contact_number,
        d.delivery_address,d.remarks,d.create_time,d.delivery_date,d.creator,d.salesman,d.salesman_id
        from sd.delivery d