New file |
| | |
| | | <script setup> |
| | | import {onMounted, reactive, ref, watch} from "vue" |
| | | import {filterChanged} from "@/hook" |
| | | import {useI18n} from "vue-i18n" |
| | | import {ElMessage} from "element-plus"; |
| | | const { t } = useI18n() |
| | | let rowClickIndex = ref(null) |
| | | const xGrid = ref() |
| | | const gridOptions = reactive({ |
| | | border: "full",//表格加边框 |
| | | keepSource: true,//保持源数据 |
| | | align: 'center',//文字居中 |
| | | stripe:true,//斑马纹 |
| | | rowConfig: {isCurrent: true, isHover: true,height: 30},//鼠标移动或选择高亮 |
| | | id: 'OrderList', |
| | | showFooter: true,//显示脚 |
| | | scrollY:{ enabled: true },//开启虚拟滚动 |
| | | showOverflow:true, |
| | | |
| | | columnConfig: { |
| | | // resizable: true, |
| | | useKey: true |
| | | }, |
| | | filterConfig: { //筛选配置项 |
| | | //remote: true //远端筛选 |
| | | }, |
| | | // customConfig: { |
| | | // storage: true |
| | | // }, |
| | | editConfig: { |
| | | trigger: 'click', |
| | | mode: 'cell', |
| | | showStatus: true |
| | | },//表头参数 |
| | | columns:[ |
| | | // {field: 'buildingNumber',width:120, title: '楼号',editRender: { name: 'input'},filters:[{ data: '' }],slots: { filter: 'num1_filter'}, sortable: true,filterMethod:filterChanged}, |
| | | {field: 'alias', title:'其他加工',editRender: { name: 'input'},minWith:'130'}, |
| | | {field: 'price', title:'单价',editRender: { name: 'input'}}, |
| | | {field: 'quantity', title:'数量',editRender: { name: 'input'} }, |
| | | {field: 'money', slots:{default:'default'}, title:'金额'} |
| | | ], |
| | | //表单验证 |
| | | editRules: { |
| | | price: [ |
| | | { |
| | | validator ({ cellValue }) { |
| | | const regex = /^(0(\.\d{1,2})?|([1-9]\d{0,4})(\.\d{1,2})?|99999(\.9{1,2})?)$/ |
| | | if (cellValue && !regex.test(cellValue) ) { |
| | | return new Error(t('basicData.msg.range99999Dec2') ) |
| | | } |
| | | } |
| | | } |
| | | ], |
| | | quantity: [ |
| | | { |
| | | validator ({ cellValue }) { |
| | | const regex = /^[1-9]\d*$|^0$/ |
| | | if (cellValue && !regex.test(cellValue) ) { |
| | | return new Error('请输入大于等于0的整数') |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | |
| | | }, |
| | | toolbarConfig: { |
| | | buttons: [ |
| | | {'code': 'add', 'name': '新增',status: 'primary'}, |
| | | {'code': 'delete', 'name': '删除',status: 'primary'} |
| | | ], |
| | | |
| | | |
| | | // import: false, |
| | | // export: true, |
| | | // print: true, |
| | | // zoom: true, |
| | | // custom: true |
| | | } |
| | | , |
| | | //table body实际数据 |
| | | footerMethod ({ columns, data }) {//页脚函数 |
| | | return[ |
| | | columns.map((column, columnIndex) => { |
| | | if (columnIndex === 0) { |
| | | return t('basicData.total')+':' |
| | | } |
| | | const footList = ['quantity'] |
| | | if (footList.includes(column.field)) { |
| | | return sumNum(data, column.field) |
| | | } |
| | | if(column.field==='money'){ |
| | | let count = 0 |
| | | data.forEach(item => { |
| | | count+=countAmount(item) |
| | | }) |
| | | return parseFloat(count.toFixed(2)) |
| | | } |
| | | return '' |
| | | }) |
| | | ] |
| | | } |
| | | |
| | | }) |
| | | const gridEvents = { |
| | | async toolbarButtonClick({code}) { |
| | | const $grid = xGrid.value |
| | | if ($grid) { |
| | | switch (code) { |
| | | case 'add': { |
| | | if ($grid.getTableData().tableData.length >=240){ |
| | | ElMessage.error(t('order.msg.tableLengthMax')) |
| | | return |
| | | } |
| | | $grid.insert({}) |
| | | break |
| | | } |
| | | case 'delete': { |
| | | if(rowClickIndex.value === null){ |
| | | ElMessage.warning('请先单击选择行') |
| | | return |
| | | } |
| | | $grid.remove(rowClickIndex.value) |
| | | rowClickIndex.value = null |
| | | break |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | cellClick({ row }){ |
| | | rowClickIndex.value = row |
| | | } |
| | | } |
| | | |
| | | const sumNum = (list, field) => { |
| | | let count = 0 |
| | | list.forEach(item => { |
| | | count += Number(item[field]) |
| | | }) |
| | | return count.toFixed(2)==='NaN' ? null : parseFloat(count.toFixed(2)) |
| | | } |
| | | |
| | | let prop = defineProps({ |
| | | otherMoney:{} |
| | | }) |
| | | onMounted(()=>{ |
| | | xGrid.value.reloadData(prop.otherMoney) |
| | | }) |
| | | watch(prop,(newVal)=>{ |
| | | xGrid.value.reloadData(prop.otherMoney) |
| | | }) |
| | | |
| | | const countAmount = (row)=>{ |
| | | return parseFloat((row.price * row.quantity).toFixed(2)) |
| | | } |
| | | |
| | | const validate = async () => { |
| | | const errMap = await xGrid.value.validate(true) |
| | | if (errMap) { |
| | | ElMessage.error(`校验不通过!`) |
| | | return false |
| | | } |
| | | return true |
| | | } |
| | | defineExpose({ |
| | | validate |
| | | }) |
| | | |
| | | </script> |
| | | |
| | | <template> |
| | | <div style="height: 100%;width: 100%"> |
| | | <vxe-grid |
| | | @filter-change="filterChanged" |
| | | ref="xGrid" |
| | | max-height="350px" |
| | | width |
| | | v-bind="gridOptions" |
| | | v-on="gridEvents" |
| | | > |
| | | <template #default="{ row }"> |
| | | <span>{{ countAmount(row) }} </span> |
| | | </template> |
| | | </vxe-grid> |
| | | </div> |
| | | |
| | | |
| | | </template> |
| | | |
| | | <style scoped> |
| | | |
| | | </style> |
| | |
| | | width:'宽', |
| | | height:'高', |
| | | area:'面积', |
| | | trueArea:'实际单片金额', |
| | | trueArea:'实际单片面积', |
| | | trueGrossArea:'实际总面积', |
| | | computeArea:'结算单片面积', |
| | | computeGrossArea:'计算总面积', |
| | |
| | | <img id="img-pic" src="@/assets/img.png" alt=""> |
| | | </div> |
| | | <div id="div-login"> |
| | | <el-select |
| | | @change="changeLanguage" |
| | | v-model="language" |
| | | placeholder=" " |
| | | style="float: right;width: 6rem"> |
| | | <el-option value="zh" label="中文" /> |
| | | <el-option value="en" label="English" /> |
| | | </el-select> |
| | | <!-- <el-select--> |
| | | <!-- @change="changeLanguage"--> |
| | | <!-- v-model="language"--> |
| | | <!-- placeholder=" "--> |
| | | <!-- style="float: right;width: 6rem">--> |
| | | <!-- <el-option value="zh" label="中文" />--> |
| | | <!-- <el-option value="en" label="English" />--> |
| | | <!-- </el-select>--> |
| | | <h2>{{$t('login.SysName')}}</h2> |
| | | <el-form |
| | | @submit.native.prevent |
| | |
| | | import deepClone from "@/utils/deepClone" |
| | | import useUserInfoStore from '@/stores/userInfo' |
| | | import SelectProduct from "@/views/sd/product/SelectProduct.vue" |
| | | import OrderOtherMoney from "@/components/sd/order/OrderOtherMoney.vue" |
| | | import {changeFilterEvent,filterChanged} from "@/hook" |
| | | import {addListener,toolbarButtonClickEvent} from "@/hook/mouseMove" |
| | | import downLoadFile from "@/hook/downLoadFile" |
| | |
| | | |
| | | let dialogTableVisible = ref(false) |
| | | let productVisible = ref(false) |
| | | let errorAreaVisible = ref(false) |
| | | let otherMoneyVisible = ref(false) |
| | | let errorArea = ref(null) |
| | | const userStore = useUserInfoStore() |
| | | const router = useRouter() |
| | | const route = useRoute() |
| | |
| | | }) |
| | | //定义接收加载表头下拉数据 |
| | | const titleSelectJson = ref({ |
| | | orderOtherMoney:[], |
| | | orderType:[], |
| | | alType:[], |
| | | icon:[], |
| | |
| | | let filterData = ref({}) |
| | | let rowIndex = ref(null) |
| | | let rowClickIndex = ref(null) |
| | | let otherMoney = ref(null) |
| | | |
| | | const gridOptions = reactive({ |
| | | border: "full",//表格加边框 |
| | |
| | | { code: 'copyAll', name: t('basicData.sameAfterwards'), prefixIcon: 'vxe-icon-feedback', visible: true, disabled: false }, |
| | | { code: 'clearChecked', name: t('basicData.clearSelection'), prefixIcon: 'vxe-icon-indicator', visible: true, disabled: false }, |
| | | { code: 'computedMoney', name: t('basicData.calculateAmount'), prefixIcon: 'vxe-icon-chart-bar-x', visible: true, disabled: true }, |
| | | { code: 'errorArea', name: '误差结算面积', prefixIcon: 'vxe-icon-chart-bar-x', visible: true, disabled: false }, |
| | | { code: 'otherMoney', name: '其他金额', prefixIcon: 'vxe-icon-chart-bar-x', visible: true, disabled: false } |
| | | ] |
| | | ] |
| | | } |
| | |
| | | editConfig: { |
| | | trigger: 'click', |
| | | mode: 'cell', |
| | | showStatus: true |
| | | showStatus: true, |
| | | showIcon:false |
| | | },//表头参数 |
| | | columns:[ |
| | | {type: 'seq',fixed:"left", title: t('basicData.Number'), width: 80 }, |
| | |
| | | {field: 'bendRadius',width:160, title: t('order.bendRadius'),editRender: { name: 'input'},filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true,filterMethod:filterChanged}, |
| | | {field: 'edgingType',width:160, title: t('order.edgingType'),editRender: { name: 'input'},filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true,filterMethod:filterChanged}, |
| | | {field: 'processingNote',width:200, title: t('order.processingNote'),editRender: { name: 'input'},filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true,filterMethod:filterChanged}, |
| | | {field: 'remarks',width:140, title: t('basicData.remarks'),editRender: { name: 'input'},filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true,filterMethod:filterChanged} |
| | | {field: 'remarks',width:140, title: t('basicData.remarks'),editRender: { name: 'input'},filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true,filterMethod:filterChanged}, |
| | | |
| | | |
| | | ], |
| | | //表单验证 |
| | |
| | | } |
| | | let order ={ |
| | | title:titleUploadData.value, |
| | | detail:$grid.getTableData().tableData |
| | | detail:$grid.getTableData().tableData, |
| | | otherMoney:otherMoney.value |
| | | } |
| | | saveOrder(order) |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | },//右键按钮事件 |
| | | }, |
| | | //右键按钮事件 |
| | | menuClick ({ menu, row, column }) { |
| | | const $grid = xGrid.value |
| | | if ($grid) { |
| | |
| | | titleUploadData.value.money=countMoney(xGrid.value.getTableData().fullData).toString() |
| | | |
| | | gridOptions.menuConfig.body.options[0][5].disabled=true |
| | | break |
| | | } |
| | | case 'errorArea' :{ |
| | | errorAreaVisible.value=true |
| | | break |
| | | } |
| | | case 'otherMoney' :{ |
| | | otherMoneyVisible.value=true |
| | | break |
| | | } |
| | | } |
| | |
| | | } |
| | | if(res.data.order.productionOrder !==0 ){ |
| | | gridOptions.toolbarConfig.buttons[2].disabled = true |
| | | |
| | | } |
| | | const orderDetails = res.data.orderDetails |
| | | orderDetails.forEach(item => { |
| | | item.otherColumns = JSON.parse(item.otherColumns) |
| | | }) |
| | | |
| | | //加载副表数据 |
| | | xGrid.value.reloadData(res.data.orderDetails) |
| | | xGrid.value.reloadData(orderDetails) |
| | | }else{ |
| | | ElMessage.error(res.msg) |
| | | } |
| | |
| | | |
| | | //页面第一次加载执行 |
| | | request.get(`/basicData/orderBasicData`).then((res) => { |
| | | |
| | | if(res.code==200){ |
| | | titleSelectJson.value=deepClone(res.data) |
| | | //其他金额 |
| | | otherMoney.value = titleSelectJson.value.orderOtherMoney[0] |
| | | //let columns = [] |
| | | otherMoney.value.forEach(item => { |
| | | let column = {field: `otherColumns.${item.column}`,width:50, title: item.alias,editRender: { name: 'input'}} |
| | | //columns.push(column) |
| | | gridOptions.columns.push(column) |
| | | }) |
| | | |
| | | //进入页面下拉框设置默认值 |
| | | titleUploadData.value.orderType = titleSelectJson.value.orderType[0].basicName |
| | | titleUploadData.value.orderClassify = titleSelectJson.value.orderClassify[0].basicName |
| | |
| | | list.forEach((item)=>{ |
| | | countMoney += parseFloat(item.grossAmount) |
| | | }) |
| | | otherMoney.value.forEach(item => { |
| | | countMoney+=item.quantity*item.price |
| | | }) |
| | | return parseFloat((countMoney).toFixed(2)) |
| | | } |
| | | //导入功能 |
| | |
| | | downLoadFile('/importTemplate.xlsx','importTemplate.xlsx') |
| | | } |
| | | |
| | | //字符串转object |
| | | |
| | | function getNestedProperty(obj, path) { |
| | | return path.split('.').reduce(function(o, p) { |
| | | if(o && o.hasOwnProperty(p)) { |
| | | return o[p]; |
| | | } |
| | | }, obj); |
| | | } |
| | | |
| | | //行单元格修改修改触发此事件 |
| | | const editClosedEvent = ({ row, column }) => { |
| | | //判断修改相应的数值修改面积与金额 |
| | |
| | | }else if(column.property === 'computeArea'){ |
| | | row.computeGrossArea=parseFloat((row.computeArea*row.quantity).toFixed(2)) |
| | | row.grossAmount=parseFloat((row.price * row.computeGrossArea).toFixed(2)) |
| | | }else if(column.property.indexOf('otherColumns.M')>-1){ |
| | | let quantity = 0 |
| | | xGrid.value.getTableData().fullData.forEach(item => { |
| | | quantity += item.quantity*(getNestedProperty(item,column.property)*1) |
| | | }) |
| | | if(!isNaN(quantity)){ |
| | | otherMoney.value.forEach(item => { |
| | | if(item.column===column.property.split('.')[1]){ |
| | | item.quantity = quantity |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | titleUploadData.value.money=countMoney(xGrid.value.getTableData().fullData).toString() |
| | | |
| | | |
| | | } |
| | | |
| | | //误差面积计算方法 |
| | | const errorAreaComputed = () => { |
| | | const regex = /^(0(\.\d{1,2})?|([1-9]\d{0,4})(\.\d{1,2})?|99999(\.9{1,2})?)$/ |
| | | if (!regex.test(errorArea.value)) { |
| | | ElMessage.warning(t('basicData.msg.range99999Dec2')) |
| | | return |
| | | } |
| | | const fullData = xGrid.value.getTableData().fullData |
| | | if (!fullData.length){ |
| | | ElMessage.warning("表格中无产品数据") |
| | | } |
| | | fullData.forEach((item,index) => { |
| | | if( !isNaN(item.computeArea*1) && item.computeArea != null && item.computeArea*1 < errorArea.value){ |
| | | item.computeArea = errorArea.value |
| | | item.computeGrossArea = parseFloat((item.computeArea*item.quantity).toFixed(2)) |
| | | item.grossAmount=parseFloat((item.price * item.computeGrossArea).toFixed(2)) |
| | | } |
| | | }) |
| | | titleUploadData.value.money=countMoney(xGrid.value.getTableData().fullData).toString() |
| | | errorAreaVisible.value= false |
| | | } |
| | | |
| | | |
| | | |
| | | //关闭其他金额界面 |
| | | const refOtherMoney = ref() |
| | | const closeOtherMoneyDialog = async (done) => { |
| | | const flag = await refOtherMoney.value.validate() |
| | | if(flag){ |
| | | done() |
| | | titleUploadData.value.money=countMoney(xGrid.value.getTableData().fullData).toString() |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | </script> |
| | |
| | | <el-row> |
| | | <el-col :span="2"><el-text>{{$t('order.money')}}:</el-text></el-col> |
| | | <el-col :span="2"><el-text >{{titleUploadData.money}}</el-text></el-col> |
| | | <el-col :span="2"><el-text>{{$t('order.customers')}}:</el-text></el-col> |
| | | <el-col :span="2"><el-text>{{$t('order.contractId')}}:</el-text></el-col> |
| | | <el-col :span="2"><el-input v-model="titleUploadData.contractId"/></el-col> |
| | | <el-col :span="2"><el-text>{{$t('order.customerBatch')}}:</el-text></el-col> |
| | | <el-col :span="2"><el-input v-model="titleUploadData.customerBatch"/></el-col> |
| | |
| | | <el-dialog v-model="productVisible" style="width: 80%;height:75% "> |
| | | <select-product :rowIndex="rowIndex" @getProductRow="getProductRow" style="width: 100%;height: 100%" /> |
| | | </el-dialog> |
| | | |
| | | <!--误差结算--> |
| | | <el-dialog v-model="errorAreaVisible" style="width: 300px;height:150px "> |
| | | <el-row> |
| | | <el-col :span="10"> |
| | | <el-input |
| | | v-model="errorArea" |
| | | :placeholder="'误差值'" |
| | | /> |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | <el-button @click="errorAreaComputed">确认</el-button> |
| | | </el-col> |
| | | </el-row> |
| | | </el-dialog> |
| | | <el-dialog v-model="otherMoneyVisible" |
| | | :title="'其他金额'" |
| | | :close-on-click-modal="false" |
| | | :close-on-press-escape="false" |
| | | :before-close="closeOtherMoneyDialog" |
| | | style="width: 614px;height:445px "> |
| | | <order-other-money |
| | | ref="refOtherMoney" |
| | | :otherMoney="otherMoney" |
| | | style="width: 100%;height: 100%" /> |
| | | </el-dialog> |
| | | |
| | | </div> |
| | | </template> |
| | |
| | | import com.example.erp.common.Result; |
| | | import com.example.erp.entity.sd.BasicData; |
| | | import com.example.erp.service.sd.BasicDateService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Map; |
| | |
| | | @RestController |
| | | @RequestMapping("/basicData") |
| | | public class BasicDataController { |
| | | @Autowired |
| | | final |
| | | BasicDateService basicDateService; |
| | | |
| | | public BasicDataController(BasicDateService basicDateService) { |
| | | this.basicDateService = basicDateService; |
| | | } |
| | | |
| | | @GetMapping("/orderBasicData") |
| | | public Result getOrderBasicData(){ |
| | | return Result.seccess(basicDateService.getOrderBasicData()); |
New file |
| | |
| | | package com.example.erp.controller.sd; |
| | | |
| | | import com.example.erp.common.Result; |
| | | import com.example.erp.entity.sd.BasicData; |
| | | import com.example.erp.service.sd.BasicOtherMoneyService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | @RestController |
| | | @RequestMapping("/basicOtherMoney") |
| | | public class BasicOtherMoneyController { |
| | | private final BasicOtherMoneyService basicOtherMoneyService; |
| | | |
| | | public BasicOtherMoneyController(BasicOtherMoneyService basicOtherMoneyService) { |
| | | this.basicOtherMoneyService = basicOtherMoneyService; |
| | | } |
| | | |
| | | @GetMapping("findAll") |
| | | @PostMapping("findAll") |
| | | public Result findAll(){ |
| | | return Result.seccess(basicOtherMoneyService.findAll()); |
| | | } |
| | | |
| | | @PostMapping("deleteById/{id}") |
| | | public Result deleteById(@PathVariable("id") Integer id){ |
| | | return Result.seccess(basicOtherMoneyService.deleteById(id)); |
| | | } |
| | | |
| | | @PostMapping("save") |
| | | public Result save(String alias){ |
| | | return Result.seccess(basicOtherMoneyService.save(alias)); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.example.erp.entity.sd; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import lombok.Data; |
| | | import org.apache.poi.hpsf.Decimal; |
| | | |
| | | import javax.persistence.Column; |
| | | import java.math.BigDecimal; |
| | | |
| | | @Data |
| | | public class BasicOtherMoney { |
| | | @TableId(type = IdType.AUTO) |
| | | private Integer id; |
| | | @TableField(value = "`column`") |
| | | private String column; |
| | | private String alias; |
| | | @Column(length=7 ,scale=2) |
| | | private BigDecimal quantity; |
| | | @Column(length=7 ,scale=2) |
| | | private BigDecimal price; |
| | | private Boolean state; |
| | | |
| | | } |
| | |
| | | private String edgingType; |
| | | private Double weight; |
| | | private Double perimeter; |
| | | private String otherColumns; |
| | | private Integer warehouseNum; |
| | | private Integer deliveryNum; |
| | | private Integer returnNum; |
New file |
| | |
| | | package com.example.erp.entity.sd; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | public class OrderOtherMoney { |
| | | @TableId(type = IdType.AUTO) |
| | | private Integer id; |
| | | private String orderId; |
| | | @TableField(value = "`column`") |
| | | private String column; |
| | | private Double quantity; |
| | | private Double price; |
| | | private Double money; |
| | | private LocalDateTime createTime; |
| | | } |
New file |
| | |
| | | package com.example.erp.mapper.sd; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.example.erp.entity.sd.BasicOtherMoney; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | @Mapper |
| | | public interface BasicOtherMoneyMapper extends BaseMapper<BasicOtherMoney> { |
| | | } |
New file |
| | |
| | | package com.example.erp.mapper.sd; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.example.erp.entity.sd.OrderOtherMoney; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | @Mapper |
| | | public interface OrderOtherMoneyMapper extends BaseMapper<OrderOtherMoney> { |
| | | } |
| | |
| | | package com.example.erp.service.sd; |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.example.erp.entity.sd.BasicData; |
| | | import com.example.erp.entity.sd.Customer; |
| | | import com.example.erp.mapper.sd.BasicDateMapper; |
| | | import com.example.erp.mapper.sd.BasicOtherMoneyMapper; |
| | | import com.example.erp.mapper.sd.CustomerMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.example.erp.entity.sd.BasicData; |
| | | |
| | | import java.util.*; |
| | | |
| | | @Service |
| | | @DS("sd") |
| | | public class BasicDateService { |
| | | @Autowired |
| | | private BasicDateMapper basicDateMapper; |
| | | private final BasicDateMapper basicDateMapper; |
| | | |
| | | @Autowired |
| | | private CustomerMapper customerMapper; |
| | | private final CustomerMapper customerMapper; |
| | | private final BasicOtherMoneyMapper basicOtherMoneyMapper; |
| | | |
| | | public BasicDateService(BasicDateMapper basicDateMapper, CustomerMapper customerMapper, BasicOtherMoneyMapper basicOtherMoneyMapper) { |
| | | this.basicDateMapper = basicDateMapper; |
| | | this.customerMapper = customerMapper; |
| | | this.basicOtherMoneyMapper = basicOtherMoneyMapper; |
| | | } |
| | | |
| | | //获取订单基本数据 |
| | | public Map<String, List<Object>> getOrderBasicData() { |
| | |
| | | orderBasicDataMap.get("customer").add(customer); |
| | | } |
| | | |
| | | orderBasicDataMap.put("orderOtherMoney", Collections.singletonList(basicOtherMoneyMapper.selectList(null))); |
| | | |
| | | |
| | | //返回Map对象 |
| | | return orderBasicDataMap; |
New file |
| | |
| | | package com.example.erp.service.sd; |
| | | |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.example.erp.entity.sd.BasicOtherMoney; |
| | | import com.example.erp.mapper.sd.BasicOtherMoneyMapper; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | @DS("sd") |
| | | public class BasicOtherMoneyService { |
| | | private final BasicOtherMoneyMapper basicOtherMoneyMapper; |
| | | |
| | | public BasicOtherMoneyService(BasicOtherMoneyMapper basicOtherMoneyMapper) { |
| | | this.basicOtherMoneyMapper = basicOtherMoneyMapper; |
| | | } |
| | | |
| | | public List<BasicOtherMoney> findAll() { |
| | | return basicOtherMoneyMapper.selectList(null); |
| | | |
| | | } |
| | | |
| | | public int deleteById(Integer id) { |
| | | return basicOtherMoneyMapper.deleteById(id); |
| | | } |
| | | |
| | | public int save(String alias) { |
| | | BasicOtherMoney basicOtherMoney = new BasicOtherMoney(); |
| | | basicOtherMoney.setAlias(alias); |
| | | return basicOtherMoneyMapper.insert(basicOtherMoney); |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.example.erp.common.Constants; |
| | | import com.example.erp.entity.sd.Order; |
| | | import com.example.erp.entity.sd.OrderDetail; |
| | | import com.example.erp.entity.sd.OrderGlassDetail; |
| | | import com.example.erp.entity.sd.OrderProcessDetail; |
| | | import com.example.erp.entity.sd.*; |
| | | import com.example.erp.entity.userInfo.SysError; |
| | | import com.example.erp.exception.ServiceException; |
| | | import com.example.erp.mapper.sd.OrderDetailMapper; |
| | | import com.example.erp.mapper.sd.OrderGlassDetailMapper; |
| | | import com.example.erp.mapper.sd.OrderMapper; |
| | | import com.example.erp.mapper.sd.OrderProcessDetailMapper; |
| | | import com.example.erp.mapper.sd.*; |
| | | import com.example.erp.service.userInfo.SysErrorService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | |
| | | private final OrderDetailMapper orderDetailMapper; |
| | | private final OrderGlassDetailMapper orderGlassDetailMapper; |
| | | private final SysErrorService sysErrorService; |
| | | private final OrderOtherMoneyMapper orderOtherMoneyMapper; |
| | | |
| | | private final OrderProcessDetailMapper orderProcessDetailMapper; |
| | | public OrderService(OrderMapper orderMapper, OrderDetailMapper orderDetailMapper, OrderGlassDetailMapper orderGlassDetailMapper, OrderProcessDetailMapper orderProcessDetailMapper, SysErrorService sysErrorService) { |
| | | public OrderService(OrderMapper orderMapper, OrderDetailMapper orderDetailMapper, OrderGlassDetailMapper orderGlassDetailMapper, OrderProcessDetailMapper orderProcessDetailMapper, SysErrorService sysErrorService, OrderOtherMoneyMapper orderOtherMoneyMapper) { |
| | | this.orderMapper = orderMapper; |
| | | this.orderDetailMapper = orderDetailMapper; |
| | | this.orderGlassDetailMapper = orderGlassDetailMapper; |
| | | this.orderProcessDetailMapper = orderProcessDetailMapper; |
| | | this.sysErrorService = sysErrorService; |
| | | this.orderOtherMoneyMapper = orderOtherMoneyMapper; |
| | | } |
| | | |
| | | public boolean saveOrder(Map<String,Object> orderMap) throws Exception { |
| | | JSONObject orderJson = new JSONObject(orderMap); |
| | | Order order = JSONObject.parseObject(JSONObject.toJSONString(orderJson.get("title")), Order.class); |
| | | List<OrderDetail> OrderDetails = JSONArray.parseArray(JSONObject.toJSONString(orderJson.get("detail")), OrderDetail.class); |
| | | List<OrderOtherMoney> orderOtherMoneyList = JSONArray.parseArray(JSONObject.toJSONString(orderJson.get("otherMoney")), OrderOtherMoney.class); |
| | | boolean saveState = true; |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | //判断传入id参数是否为空,未传入id为空插入订单表,传入更新表 |
| | | try{ |
| | | if(order.getOrderId() == null || order.getOrderId().isEmpty()){ |
| | | insertOrder(order,OrderDetails); |
| | | insertOrder(order,OrderDetails,orderOtherMoneyList); |
| | | }else { |
| | | updateOrder(order,OrderDetails); |
| | | updateOrder(order,OrderDetails,orderOtherMoneyList); |
| | | } |
| | | }catch (Exception e){ |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | |
| | | return saveState; |
| | | } |
| | | //生成订单数据 |
| | | public void insertOrder(Order order,List<OrderDetail> OrderDetails) { |
| | | public void insertOrder(Order order,List<OrderDetail> OrderDetails,List<OrderOtherMoney> orderOtherMoneyList) { |
| | | Integer maxOrderId = orderMapper.selectMaxOrderId(); |
| | | //查询订单id,并且自增 |
| | | String formattedNumber = String.format("%02d", maxOrderId+1); |
| | |
| | | order.setOrderId(orderId); |
| | | order.setCreateOrder(2); |
| | | orderMapper.insert(order); |
| | | insertOtherDetail(orderId,OrderDetails); |
| | | insertOtherDetail(orderId,OrderDetails,orderOtherMoneyList); |
| | | |
| | | } |
| | | //修改订单数据,并且重新生成多个副表数据 |
| | | public void updateOrder(Order order,List<OrderDetail> OrderDetails) { |
| | | public void updateOrder(Order order,List<OrderDetail> OrderDetails,List<OrderOtherMoney> orderOtherMoneyList) { |
| | | LambdaUpdateWrapper<Order> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.eq(Order::getOrderId, order.getOrderId()); |
| | | orderMapper.update(order,updateWrapper); |
| | |
| | | orderDetailMapper.delete(new LambdaQueryWrapper<OrderDetail>().eq(OrderDetail::getOrderId, order.getOrderId())); |
| | | //删除订单小片表 |
| | | orderGlassDetailMapper.delete(new LambdaQueryWrapper<OrderGlassDetail>().eq(OrderGlassDetail::getOrderId, order.getOrderId())); |
| | | //删除其他金额明细表 |
| | | orderOtherMoneyMapper.delete(new LambdaQueryWrapper<OrderOtherMoney>().eq(OrderOtherMoney::getOrderId, order.getOrderId())); |
| | | |
| | | //删除订单工艺表 |
| | | // orderProcessDetailMapper.delete(new LambdaQueryWrapper<OrderProcessDetail>().eq(OrderProcessDetail::getOrderId, order.getOrderId())); |
| | | insertOtherDetail(order.getOrderId(),OrderDetails); |
| | | insertOtherDetail(order.getOrderId(),OrderDetails,orderOtherMoneyList); |
| | | } |
| | | |
| | | |
| | | //插入其他副表数据,被其他方法引用 |
| | | public void insertOtherDetail(String orderId,List<OrderDetail> OrderDetails) { |
| | | public void insertOtherDetail(String orderId,List<OrderDetail> OrderDetails,List<OrderOtherMoney> orderOtherMoneyList) { |
| | | //循环给订单明细表字段添加序号和周长 |
| | | for (int i = 0; i < OrderDetails.size(); i++) { |
| | | OrderDetails.get(i).setOrderNumber(i+1); |
| | |
| | | OrderDetails.get(i).setPerimeter(OrderDetails.get(i).getWidth()*OrderDetails.get(i).getHeight()*2/1000); |
| | | OrderDetails.get(i).setWeight(1.0); |
| | | } |
| | | |
| | | |
| | | |
| | | //往明细表插数据 |
| | | orderDetailMapper.insertBatch(OrderDetails); |
| | | //修改订单主表面积与周长以及重量 |
| | | orderMapper.updateOrderParameter(orderId); |
| | | //往小片表传入产品数据 |
| | | orderGlassDetailMapper.insertOrderGlassDetail(orderId); |
| | | //往订单其他金额副表传入数据 |
| | | orderOtherMoneyList.forEach(orderOtherMoney ->{ |
| | | orderOtherMoney.setId(null); |
| | | orderOtherMoney.setOrderId(orderId); |
| | | if(orderOtherMoney.getQuantity()!=null && orderOtherMoney.getPrice()!=null){ |
| | | orderOtherMoney.setMoney((orderOtherMoney.getQuantity()*orderOtherMoney.getPrice())); |
| | | } |
| | | orderOtherMoneyMapper.insert(orderOtherMoney); |
| | | }); |
| | | |
| | | //查询订单小片表获取工艺传入小片工艺表 |
| | | //List<OrderGlassDetail> orderGlassDetails = orderGlassDetailMapper.selectOrderGlassDetail(orderId); |
| | | /*List<OrderProcessDetail> orderProcessDetailList = getOrderProcessDetails(orderGlassDetails); |
| | |
| | | bend_radius, |
| | | edging_type, |
| | | weight, |
| | | perimeter |
| | | perimeter, |
| | | other_columns |
| | | ) |
| | | values |
| | | <foreach collection ="orderDetails" item="orderDetail" separator =","> |
| | |
| | | #{orderDetail.bendRadius}, |
| | | #{orderDetail.edgingType}, |
| | | #{orderDetail.weight}, |
| | | #{orderDetail.perimeter} |
| | | #{orderDetail.perimeter}, |
| | | #{orderDetail.otherColumns} |
| | | ) |
| | | </foreach> |
| | | </insert> |
| | |
| | | bend_radius, |
| | | edging_type, |
| | | weight, |
| | | perimeter |
| | | perimeter, |
| | | other_columns |
| | | ) |
| | | values |
| | | <foreach collection ="orderDetails" item="orderDetail" separator =","> |
| | |
| | | #{orderDetail.bendRadius}, |
| | | #{orderDetail.edgingType}, |
| | | #{orderDetail.weight}, |
| | | #{orderDetail.perimeter} |
| | | #{orderDetail.perimeter}, |
| | | #{orderDetail.otherColumns} |
| | | ) |
| | | </foreach> |
| | | </insert> |