Browse Source

代码更新

master
刘先源 2 years ago
parent
commit
546efbc599
  1. 7
      nladmin-system/pom.xml
  2. 26
      nladmin-system/src/main/java/org/nl/acs/order/rest/ProduceshiftorderController.java
  3. 6
      nladmin-system/src/main/java/org/nl/acs/order/service/ProduceshiftorderService.java
  4. 3
      nladmin-system/src/main/java/org/nl/acs/order/service/dto/ProduceshiftorderdetailDto.java
  5. 60
      nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java
  6. 17
      nladmin-system/src/main/java/org/nl/acs/order/service/wql/QPRODUCESHIFTORDER.wql
  7. BIN
      nladmin-system/src/main/java/org/nl/acs/order/service/wql/order.xls
  8. 119
      qd/src/views/acs/order/AddDialog.vue

7
nladmin-system/pom.xml

@ -26,6 +26,13 @@
<version>6.6</version>
</dependency>
<!-- Excel打印-->
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.xls</artifactId>
<version>3.11.2</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>

26
nladmin-system/src/main/java/org/nl/acs/order/rest/ProduceshiftorderController.java

@ -2,17 +2,25 @@
package org.nl.acs.order.rest;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.order.service.ProduceshiftorderService;
import org.nl.annotation.Log;
import org.nl.domain.LocalStorage;
import org.nl.exception.BadRequestException;
import org.nl.service.LocalStorageService;
import org.nl.utils.SecurityUtils;
import org.nl.wql.core.bean.WQLObject;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@ -30,6 +38,8 @@ import java.util.Map;
public class ProduceshiftorderController {
private final ProduceshiftorderService produceshiftorderService;
private final LocalStorageService localStorageService;
@GetMapping
@Log("查询工单")
@ -185,6 +195,22 @@ public class ProduceshiftorderController {
return new ResponseEntity<>(produceshiftorderService.selectTemplateList(),HttpStatus.OK);
}
@Log("上传Excel模板")
@ApiOperation("上传Excel模板")
@PostMapping({"/pictures"})
public ResponseEntity<Object> uploadTemplate(@RequestParam MultipartFile file) {
LocalStorage localStorage = this.localStorageService.create((String) null, file);
return new ResponseEntity<>(localStorage,HttpStatus.OK);
}
@Log("打印")
@ApiOperation("打印")
@PostMapping("/print")
public ResponseEntity<Object> print(@RequestBody JSONObject whereJson) {
produceshiftorderService.print(whereJson);
return new ResponseEntity<>(HttpStatus.OK);
}
}

6
nladmin-system/src/main/java/org/nl/acs/order/service/ProduceshiftorderService.java

@ -2,6 +2,7 @@
package org.nl.acs.order.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.nl.acs.order.service.dto.ProduceshiftorderDto;
import org.springframework.data.domain.Pageable;
@ -227,4 +228,9 @@ public interface ProduceshiftorderService {
*/
JSONArray selectTemplateList();
/**
* 打印
* @param whereJson
*/
void print(JSONObject whereJson);
}

3
nladmin-system/src/main/java/org/nl/acs/order/service/dto/ProduceshiftorderdetailDto.java

@ -214,4 +214,7 @@ public class ProduceshiftorderdetailDto implements Serializable {
/** 结束时间 */
private String end_time;
/** 模板id */
private String template_id;
}

60
nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java

@ -6,9 +6,12 @@ import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.spire.xls.Workbook;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device_driver.hailiang.hailiang_feeding_trunk.HaiLiangFeedingTrunkDeviceDriver;
@ -33,6 +36,10 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.awt.print.PageFormat;
import java.awt.print.Paper;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.io.IOException;
import java.util.*;
@ -417,6 +424,8 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
String labeling_template = jsonObject.getString("labeling_template");
//优先级
String priority = jsonObject.getString("priority");
//优先级
String template_id = jsonObject.getString("template_id");
ProduceshiftorderdetailDto detaildto = new ProduceshiftorderdetailDto();
detaildto.setOrder_id(order_id);
@ -442,6 +451,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
detaildto.setLettering_icon(lettering_icon);
detaildto.setStrap_number(strap_number);
detaildto.setStrap_tailint_number(strap_tailint_number);
detaildto.setTemplate_id(template_id);
produceshiftorderdetailService.create(detaildto);
}
}
@ -860,4 +870,54 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
return result;
}
@Override
public void print(JSONObject whereJson) {
String order_id = whereJson.getString("order_id");
String template_id = whereJson.getString("template_id");
WQLObject mst = WQLObject.getWQLObject("acs_produceshiftorder"); // 主表
// 1.根据明细找主表
JSONObject jsonMst = mst.query("order_id = '" + order_id + "' and is_deleted ='0'").uniqueResult(0);
// 2.根据明细template_id 找到对应的模板
JSONObject jsonStor = WQL.getWO("QPRODUCESHIFTORDER").addParam("flag", "3").addParam("storage_id", template_id).process().uniqueResult(0);
// 3.创建模板工作簿 并指定储存路径
String path = jsonStor.getString("path");
String pathName = "D:\\work\\"+jsonStor.getString("name")+ jsonStor.getString("storage_id") + ".xlsx";
ExcelWriter workBook = EasyExcel.write(pathName).withTemplate(path).build();
// 获取第一个sheet
WriteSheet sheet = EasyExcel.writerSheet().build();
// 4.将主表当中的属性填充到excel当中
HashMap<String, String> map = new HashMap<>();
map.put("material_name",jsonMst.getString("material_code"));
map.put("qty",jsonMst.getString("qty"));
map.put("tttt",jsonMst.getString("qty"));
workBook.fill(map, sheet);
workBook.finish();
// 5.打印
Workbook workbook = new Workbook();
workbook.loadFromFile(pathName);
//创建 PrinterJob对象
PrinterJob printerJob = PrinterJob.getPrinterJob();
//指定打印页面为默认大小和方向
PageFormat pageFormat = printerJob.defaultPage();
//设置相关打印选项
Paper paper = pageFormat.getPaper();
paper.setSize(1240,1754);
paper.setImageableArea(0, 0, 1240, 1754);
pageFormat.setPaper(paper);
printerJob.setCopies(1);
printerJob.setPrintable(workbook, pageFormat);
try {
// 执行打印
printerJob.print();
} catch (PrinterException e) {
e.printStackTrace();
}
}
}

17
nladmin-system/src/main/java/org/nl/acs/order/service/wql/QPRODUCESHIFTORDER.wql

@ -16,6 +16,7 @@
输入.flag TYPEAS s_string
输入.template_code TYPEAS s_string
输入.template_address TYPEAS s_string
输入.storage_id TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
@ -68,4 +69,20 @@
ENDPAGEQUERY
ENDIF
IF 输入.flag = "3"
QUERY
SELECT
*
FROM
tool_local_storage
WHERE
1=1
OPTION 输入.storage_id <> ""
storage_id = 输入.storage_id
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF

BIN
nladmin-system/src/main/java/org/nl/acs/order/service/wql/order.xls

Binary file not shown.

119
qd/src/views/acs/order/AddDialog.vue

@ -157,12 +157,19 @@
</el-select>
</template>
</el-table-column>
<!-- <el-table-column prop="priority" label="优先级" align="center">-->
<!-- <template scope="scope">-->
<!-- <el-input v-show="!scope.row.edit" v-model="scope.row.priority" size="mini" />-->
<!-- <span v-show="scope.row.edit">{{ scope.row.priority }}</span>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column prop="priority" label="优先级" align="center">-->
<!-- <template scope="scope">-->
<!-- <el-input v-show="!scope.row.edit" v-model="scope.row.priority" size="mini" />-->
<!-- <span v-show="scope.row.edit">{{ scope.row.priority }}</span>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column prop="template_id" label="上传模板" align="center" width="200px">
<template scope="scope">
<el-input v-model="scope.row.template_id" size="mini" style="width: 140px" disabled>
<el-button slot="append" icon="el-icon-plus" @click="openDialog(scope)" />
</el-input>
</template>
</el-table-column>
<el-table-column v-if="crud.status.cu > 0" align="center" label="操作" width="170" fixed="right">
<template scope="scope">
@ -195,6 +202,38 @@
</el-table-column>
</el-table>
<!-- Excel模板上传弹出框-->
<el-dialog
title="提示"
:visible.sync="dialogUpload"
append-to-body
width="30%"
@close="handleClose"
>
<el-upload
ref="upload"
:limit="1"
:headers="headers"
class="upload-demo"
:auto-upload="false"
drag
:action="baseApi +'/api/produceshiftorder/pictures'"
multiple
:before-upload="beforeUpload"
:on-exceed="handleExceed"
:on-error="handleError"
:on-success="handleSuccess"
>
<i class="el-icon-upload" />
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div slot="tip" class="el-upload__tip">只能上传不超过50MB的文件</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="info" @click="dialogUpload = false">取消</el-button>
<el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传到服务器</el-button>
</div>
</el-dialog>
<MaterDtl
:dialog-show.sync="materShow"
:is-single="true"
@ -212,10 +251,12 @@
<script>
import crudProduceshiftorder from '@/api/acs/order/order'
import MaterDtl from '@/views/acs/order/MaterDialog'
import { getToken } from '@/utils/auth'
import { mapGetters } from 'vuex'
import CustomerDtl from '@/views/acs/order/CustomerDialog'
import CRUD, { crud, form } from '@crud/crud'
const defaultForm = { tableData: [], order_code: null, material_code: null, material_spec: null,
outer_diameter: null, wall_thickness: null }
outer_diameter: null, wall_thickness: null, detail_count: 0 }
export default {
name: 'AddDialog',
@ -240,10 +281,14 @@ export default {
},
data() {
return {
headers: { 'Authorization': getToken() },
dialogVisible: false,
dialogVisible2: false,
dialogUpload: false,
materShow: false,
customerShow: false,
dtlJson: null,
dtlIndex: null,
dtlShow: false,
templateList: [],
opendtlParam: null,
@ -291,6 +336,12 @@ export default {
}
}
},
computed: {
...mapGetters([
'baseApi',
'fileUploadApi'
])
},
created() {
debugger
crudProduceshiftorder.selectTemplateList().then(data => {
@ -363,13 +414,65 @@ export default {
this.nowrow = row
},
async insertdtl() {
this.form.tableData.push({ material_code: '', priority: '1' })
this.form.tableData.push({ material_code: '', priority: '1', customer_code: '' })
this.form.detail_count = this.form.tableData.length
},
deleteRow(index, rows) {
this.form.total_qty = parseFloat(this.form.total_qty) - parseFloat(rows[index].plan_qty)
rows.splice(index, 1)
this.form.detail_count = this.form.tableData.length
},
openDialog(val) {
debugger
if (val.row.customer_code === '') {
return this.crud.notify('请选择客户', CRUD.NOTIFICATION_TYPE.INFO)
}
this.dtlJson = val.row
this.dtlIndex = val.$index
this.dialogUpload = true
},
handleClose() {
this.dialogUpload = false
},
beforeUpload(file) {
let isLt2M = true
isLt2M = file.size / 1024 / 1024 < 50
if (!isLt2M) {
this.loading = false
this.$message.error('上传文件大小不能超过 50MB!')
}
return isLt2M
},
handleExceed(files, fileList) {
this.crud.notify('当前限制最多能选择 1 个文件', CRUD.NOTIFICATION_TYPE.WARNING)
},
//
handleError(e, file, fileList) {
const msg = JSON.parse(e.message)
this.$notify({
title: msg.message,
type: 'error',
duration: 2500
})
this.loading = false
},
handleSuccess(files, fileList) {
debugger
this.dtlJson.template_id = files.id
const arr = this.form.tableData
for (let i = 0; i < arr.length; i++) {
if (i === this.dtlIndex) {
arr[i] = this.dtlJson
}
}
this.form.tableData = arr
this.crud.notify('上传成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
this.$refs.upload.clearFiles()
this.dialogUpload = false
this.crud.toQuery()
},
submitUpload() {
const flag = this.$refs.upload.submit()
}
}
}

Loading…
Cancel
Save