use of com.eservice.api.model.machine_order.MachineOrderDetail in project sinsim by WilsonHu.
the class ContractController method update.
@PostMapping("/update")
@Transactional(rollbackFor = Exception.class)
public Result update(String contract, String requisitionForms) {
Contract contract1 = JSONObject.parseObject(contract, Contract.class);
List<MachineOrderWrapper> machineOrderWapperlist = JSONObject.parseArray(requisitionForms, MachineOrderWrapper.class);
// 先获取当前合同的所有订单
List<MachineOrderDetail> originalOrderList = machineOrderService.selectOrder(null, contract1.getId(), null, null, null, null, null, null, null, null, null, null, null, null, null, false);
// /删除该合同下,不在本次保存范围内的需求单
for (MachineOrderDetail item : originalOrderList) {
boolean exist = false;
/**
* web有时会发来有问题的requisitionForms
*/
if (machineOrderWapperlist == null) {
logger.error("machineOrderWapperlist is null, return;");
return ResultGenerator.genFailResult("machineOrderWapperlist is null, nothing updated");
}
if (requisitionForms.isEmpty() || requisitionForms == null) {
logger.error("requisitionForms is empty/null, return;");
return ResultGenerator.genFailResult("requisitionForms is empty/null, nothing updated");
}
for (MachineOrderWrapper wapperItem : machineOrderWapperlist) {
// null
if (item.getId().equals(wapperItem.getMachineOrder().getId())) {
exist = true;
break;
}
}
if (!exist) {
// 删除需求单审核记录
OrderSign orderSign = orderSignService.findBy("orderId", item.getId());
if (orderSign != null) {
orderSignService.deleteById(orderSign.getId());
}
// 删除需求单 ....
/**
* 同时要删除对应的设计单.
* 比如,在更新订单时,改了订单号,旧的订单会被删除,此时如果没有删除对应设计单,会无法删除订单。
* 后来改为订单审核完成才生成设计单,上述情形应该不存在了。
*/
deleteDDIbyOrder(item);
machineOrderService.deleteById(item.getId());
// 删除detail
orderDetailService.deleteById(item.getOrderDetailId());
}
}
for (MachineOrderWrapper item : machineOrderWapperlist) {
// 是内贸还是外贸的订单
String salesDepartment = null;
User machineOrderCreator = null;
MachineOrder orderTemp = item.getMachineOrder();
OrderChangeRecord changeRecord = item.getOrderChangeRecord();
if (orderTemp.getId() != null && orderTemp.getId() != 0) {
// 更新,只对initial和reject状态的需求单就是更新,其他状态的需求单不做更新
OrderDetail temp = item.getOrderDetail();
if (orderTemp.getStatus().equals(Constant.ORDER_REJECTED)) {
orderTemp.setStatus(Constant.ORDER_INITIAL);
}
if (orderTemp.getStatus().equals(Constant.ORDER_INITIAL)) {
orderDetailService.update(temp);
machineOrderService.update(orderTemp);
commonService.syncMachineOrderStatusInDesignDepInfo(orderTemp);
// 在改单之后,在重新提交之前,允许修改改单原因,即:改单原因不仅仅在改单时允许修改,在上述情况下也允许修改。
if (null != changeRecord) {
orderChangeRecordService.update(changeRecord);
}
}
} else {
// 新增
OrderDetail temp = item.getOrderDetail();
orderDetailService.saveAndGetID(temp);
orderTemp.setOrderDetailId(temp.getId());
orderTemp.setContractId(contract1.getId());
orderTemp.setStatus(Constant.ORDER_INITIAL);
machineOrderService.saveAndGetID(orderTemp);
// 初始化需求单审核记录
OrderSign orderSignData = item.getOrderSign();
OrderSign orderSign = new OrderSign();
orderSign.setSignContent(orderSignData.getSignContent());
orderSign.setOrderId(orderTemp.getId());
orderSign.setCreateTime(new Date());
// 是内贸还是外贸一部,二部
if (salesDepartment == null) {
machineOrderCreator = userService.findById(orderTemp.getCreateUserId());
if (machineOrderCreator.getMarketGroupName().equals(Constant.STR_DEPARTMENT_DOMESTIC)) {
salesDepartment = Constant.STR_DEPARTMENT_DOMESTIC;
} else if (machineOrderCreator.getMarketGroupName().equals(Constant.STR_DEPARTMENT_FOREIGN_1)) {
salesDepartment = Constant.STR_DEPARTMENT_FOREIGN_1;
} else if (machineOrderCreator.getMarketGroupName().equals(Constant.STR_DEPARTMENT_FOREIGN_2)) {
salesDepartment = Constant.STR_DEPARTMENT_FOREIGN_2;
} else if (machineOrderCreator.getRoleId() == Constant.ROLE_ID_FOREIGN_DIRECTOR) {
/**
* 外贸总监的MarketGroupName部门为空, 外贸总监录的订单,也算为一部的。
* 外贸经理的MarketGroupName部门为外贸二部
*/
salesDepartment = Constant.STR_DEPARTMENT_FOREIGN_1;
}
orderSign.setSalesDepartment(salesDepartment);
}
orderSignService.save(orderSign);
}
}
// 前端只要操作了“保存”,合同的状态回到“CONTRACT_INITIAL”状态
contract1.setStatus(Constant.CONTRACT_INITIAL);
contract1.setUpdateTime(new Date());
contractService.update(contract1);
// 检查需求单中的销售员和合同中销售员是否一致,如果不一致则更新需求单中的销售员
for (MachineOrderWrapper item : machineOrderWapperlist) {
if (!item.getMachineOrder().getSellman().equals(contract1.getSellman())) {
MachineOrder order = new MachineOrder();
order.setId(item.getMachineOrder().getId());
// 只更新销售员
order.setSellman(contract1.getSellman());
machineOrderService.update(order);
}
}
return ResultGenerator.genSuccessResult();
}
use of com.eservice.api.model.machine_order.MachineOrderDetail in project sinsim by WilsonHu.
the class MachineOrderController method exportToSaleExcel.
@PostMapping("/exportToSaleExcel")
public Result exportToSaleExcel(Integer id, Integer contract_id, String order_num, String contract_num, String status, String sellman, String customer, String marketGroupName, // 这个是查询创建日期
String query_start_time, // 这个是查询创建日期
String query_finish_time, // 这个是查询审核日期
String queryStartTimeSign, // 这个是查询审核日期
String queryFinishTimeSign, String machine_name, String oderSignCurrentStep, String searchDepartment, @RequestParam(defaultValue = "true") Boolean is_fuzzy) {
List<MachineOrderDetail> list = machineOrderService.selectOrder(id, contract_id, order_num, contract_num, status, sellman, customer, marketGroupName, query_start_time, query_finish_time, queryStartTimeSign, queryFinishTimeSign, machine_name, oderSignCurrentStep, searchDepartment, is_fuzzy);
HSSFWorkbook wb = null;
FileOutputStream out = null;
String downloadPath = "";
/*
返回给docker外部下载
*/
String downloadPathForNginx = "";
SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
try {
// 生成一个空的Excel文件
wb = new HSSFWorkbook();
Sheet sheet1 = wb.createSheet("销售报表");
// 设置标题行格式
HSSFCellStyle headcellstyle = wb.createCellStyle();
HSSFFont headfont = wb.createFont();
headfont.setFontHeightInPoints((short) 10);
// 粗体显示
headfont.setBold(true);
headcellstyle.setFont(headfont);
Row row;
// 新创建一行,行号为row+1
row = sheet1.createRow(0);
int columnSum = 22;
for (int c = 0; c < columnSum; c++) {
// 列头
// 创建一个单元格,列号为col+1
row.createCell(c);
sheet1.setColumnWidth(c, 4500);
sheet1.getRow(0).getCell(c).setCellStyle(headcellstyle);
}
// 第一行为标题
int columnX = 0;
sheet1.getRow(0).getCell(columnX++).setCellValue("客户");
sheet1.getRow(0).getCell(columnX++).setCellValue("国家");
sheet1.getRow(0).getCell(columnX++).setCellValue("部门");
sheet1.getRow(0).getCell(columnX++).setCellValue("合同号");
sheet1.getRow(0).getCell(columnX++).setCellValue("订单号");
// sheet1.getRow(0).getCell(3).setCellValue("铭牌号");
sheet1.getRow(0).getCell(columnX++).setCellValue("机器信息");
sheet1.getRow(0).getCell(columnX++).setCellValue("台数");
sheet1.getRow(0).getCell(columnX++).setCellValue("单价");
sheet1.getRow(0).getCell(columnX++).setCellValue("装置");
sheet1.getRow(0).getCell(columnX++).setCellValue("装置数量");
sheet1.getRow(0).getCell(columnX++).setCellValue("装置总价");
sheet1.getRow(0).getCell(columnX++).setCellValue("优惠金额");
sheet1.getRow(0).getCell(columnX++).setCellValue("订单总金额(美元)");
sheet1.getRow(0).getCell(columnX++).setCellValue("订单总金额(人民币)");
sheet1.getRow(0).getCell(columnX++).setCellValue("订单总金额(欧元)");
// sheet1.getRow(0).getCell(columnX++).setCellValue("币种");
sheet1.getRow(0).getCell(columnX++).setCellValue("销售员");
// 销售费
sheet1.getRow(0).getCell(columnX++).setCellValue("业务费");
sheet1.getRow(0).getCell(columnX++).setCellValue("付款方式");
sheet1.getRow(0).getCell(columnX++).setCellValue("毛利");
sheet1.getRow(0).getCell(columnX++).setCellValue("订单类型");
sheet1.getRow(0).getCell(columnX++).setCellValue("保修费");
sheet1.getRow(0).getCell(columnX++).setCellValue("签核完成时间");
DataFormat dataFormat = wb.createDataFormat();
CellStyle cellStyle;
HSSFCellStyle wrapStyle = wb.createCellStyle();
wrapStyle.setWrapText(true);
// 第二行开始,填入值
// 各订单的装置数量-合计
int allOrdersEquipmentCount = 0;
// 各订单的装置总价-合计
int allOrdersEquipemntAmountCount = 0;
// 各订单的优惠金额-合计
int allOrdersDiscountCount = 0;
// 各订单订单总金额(美元) 合计
int allOrdersTotalPriceCount_USD = 0;
// 各订单订单总金额(人民币)合计
int allOrdersTotalPriceCount_RMB = 0;
// 各订单订单总金额(欧元)合计
int allOrdersTotalPriceCount_EUR = 0;
cellStyle = wb.createCellStyle();
// 金额格式
cellStyle.setDataFormat(dataFormat.getFormat("#,##0.00"));
for (int i = 0; i < list.size(); i++) {
String dateStringSignFinish = "未完成签核";
int r = i + 1;
MachineOrderDetail mod = list.get(i);
// 新创建一行
row = sheet1.createRow(r);
for (int c = 0; c < columnSum; c++) {
// 创建列单元格
row.createCell(c);
}
// 合同的内容也用到
Contract contract = contractService.findById(list.get(i).getContractId());
if (contract == null) {
logger.error("异常,根据合同ID号,查找不到合同");
return ResultGenerator.genFailResult("异常,根据合同ID号,查找不到合同");
}
// 签核也用到:签核完成时间
List<OrderSign> orderSignList = orderSignService.getOrderSignListByOrderId(mod.getOrderSign().getOrderId());
OrderSign orderSign = null;
List<SignContentItem> signContentItemList = null;
if (orderSignList.size() > 0) {
// 订单的签核记录只有在新增合同-订单时,才创建订单的签核记录,所以这里 getOrderSignListByOrderId其实只返回一个签核记录
orderSign = orderSignList.get(orderSignList.size() - 1);
if (orderSign.getCurrentStep() == null) {
logger.warn("异常,orderSign.getCurrentStep()为null, 比如测试数据手动乱改动时可能出现");
}
if (orderSign.getCurrentStep() != null && orderSign.getCurrentStep().equals("签核完成")) {
// 如果签核完成,取最后一个角色的签核时间
signContentItemList = JSON.parseArray(orderSign.getSignContent(), SignContentItem.class);
// 注意订单签核没有enable开关
if (signContentItemList.get(signContentItemList.size() - 1).getDate() != null) {
dateStringSignFinish = formatter.format(signContentItemList.get(signContentItemList.size() - 1).getDate());
} else {
logger.warn("signContentItemList.get(signContentItemList.size()-1).getDate() 是 null,比如测试数据手动乱改动时可能出现");
}
}
}
columnX = 0;
// 客户
sheet1.getRow(r).getCell(columnX).setCellValue(mod.getCustomer());
sheet1.getRow(r).getCell(columnX++).setCellStyle(wrapStyle);
// 国家
sheet1.getRow(r).getCell(columnX++).setCellValue(mod.getCountry());
// 部门
sheet1.getRow(r).getCell(columnX++).setCellValue(contract.getMarketGroupName());
// 合同号
sheet1.getRow(r).getCell(columnX).setCellValue(mod.getContractNum());
sheet1.getRow(r).getCell(columnX++).setCellStyle(wrapStyle);
//
sheet1.getRow(r).getCell(columnX).setCellValue(mod.getOrderNum());
sheet1.getRow(r).getCell(columnX++).setCellStyle(wrapStyle);
// sheet1.getRow(r).getCell(3).setCellValue(mod.getNameplate());//
MachineType mt = mod.getMachineType();
if (mt != null) {
// 机器信息
String machineInfo = mt.getName() + "/" + mod.getNeedleNum() + "/" + mod.getHeadNum() + "/" + mod.getHeadDistance() + "/" + mod.getxDistance() + "/" + mod.getyDistance() + "/" + mod.getElectricTrim() + "/" + mod.getElectricPc();
//
sheet1.getRow(r).getCell(columnX++).setCellValue(machineInfo);
}
//
sheet1.getRow(r).getCell(columnX++).setCellValue(mod.getMachineNum());
//
sheet1.getRow(r).getCell(columnX).setCellValue(mod.getMachinePrice());
sheet1.getRow(r).getCell(columnX++).setCellStyle(cellStyle);
List<Equipment> epArray = JSON.parseArray(mod.getEquipment(), Equipment.class);
String strEp = "";
// 订单内 各种装置数量之和
int equipmentCount = 0;
int epPriceAmount = 0;
for (Equipment itemEquipment : epArray) {
strEp += itemEquipment.getName() + ":" + itemEquipment.getNumber() + "个" + "\r\n";
epPriceAmount += itemEquipment.getPrice() * itemEquipment.getNumber();
equipmentCount += itemEquipment.getNumber();
}
allOrdersEquipmentCount += equipmentCount;
allOrdersEquipemntAmountCount += epPriceAmount;
// sheet1.getRow(r).getCell(columnX).setCellStyle(wrapStyle);
// 装置
sheet1.getRow(r).getCell(columnX++).setCellValue(new HSSFRichTextString(strEp));
// 装置数量
sheet1.getRow(r).getCell(columnX++).setCellValue(equipmentCount);
// 装置总价
sheet1.getRow(r).getCell(columnX).setCellValue(epPriceAmount);
sheet1.getRow(r).getCell(columnX++).setCellStyle(cellStyle);
// 优惠金额
sheet1.getRow(r).getCell(columnX).setCellValue(mod.getDiscounts());
allOrdersDiscountCount += Integer.valueOf(mod.getDiscounts());
Double totalAmount = Double.parseDouble(mod.getMachinePrice()) * mod.getMachineNum() + epPriceAmount * mod.getMachineNum() - // 优惠金额 (需求单总价格优惠金额)
Double.parseDouble(mod.getOrderTotalDiscounts()) - // 每台的优惠金额
Double.parseDouble(mod.getDiscounts()) * mod.getMachineNum();
// - Double.parseDouble(mod.getIntermediaryPrice())*mod.getMachineNum();//每台的居间费用 和总价无关
sheet1.getRow(r).getCell(columnX++).setCellStyle(cellStyle);
if (mod.getCurrencyType().equals("美元")) {
allOrdersTotalPriceCount_USD += totalAmount;
// 总金额(美元)
sheet1.getRow(r).getCell(columnX).setCellValue(totalAmount);
sheet1.getRow(r).getCell(columnX++).setCellStyle(cellStyle);
columnX++;
//
columnX++;
}
if (mod.getCurrencyType().equals("人民币")) {
allOrdersTotalPriceCount_RMB += totalAmount;
columnX++;
// 总金额(人民币)
sheet1.getRow(r).getCell(columnX).setCellValue(totalAmount);
sheet1.getRow(r).getCell(columnX++).setCellStyle(cellStyle);
columnX++;
}
if (mod.getCurrencyType().equals("欧元")) {
allOrdersTotalPriceCount_EUR += totalAmount;
columnX++;
columnX++;
// 总金额(欧元)
sheet1.getRow(r).getCell(columnX).setCellValue(totalAmount);
sheet1.getRow(r).getCell(columnX++).setCellStyle(cellStyle);
}
// sheet1.getRow(r).getCell(columnX++).setCellValue(mod.getCurrencyType());//币种
// 销售员
sheet1.getRow(r).getCell(columnX++).setCellValue(mod.getSellman());
// 销售费 业务费
sheet1.getRow(r).getCell(columnX).setCellValue(mod.getBusinessExpense());
sheet1.getRow(r).getCell(columnX++).setCellStyle(cellStyle);
// 付款方式
sheet1.getRow(r).getCell(columnX++).setCellValue(mod.getPayMethod());
// 毛利率
sheet1.getRow(r).getCell(columnX++).setCellValue(mod.getGrossProfit());
// 订单类型
sheet1.getRow(r).getCell(columnX++).setCellValue(mod.getOrderType());
// 保修费
sheet1.getRow(r).getCell(columnX++).setCellValue(mod.getWarrantyFee());
// 签核完成时间
sheet1.getRow(r).getCell(columnX++).setCellValue(dateStringSignFinish);
}
// 最后一行 汇总
// 新创建一行
Row rowSum = sheet1.createRow(list.size() + 1);
for (int c = 0; c < columnSum; c++) {
// 创建列单元格
rowSum.createCell(c);
}
// 各订单的装置数量-合计
rowSum.getCell(9).setCellValue(allOrdersEquipmentCount);
// 各订单的装置总价 合计
rowSum.getCell(10).setCellValue(allOrdersEquipemntAmountCount);
rowSum.getCell(10).setCellStyle(cellStyle);
// 优惠金额 合计
rowSum.getCell(11).setCellValue(allOrdersDiscountCount);
// 订单总金额(美元) 合计
rowSum.getCell(12).setCellValue(allOrdersTotalPriceCount_USD);
rowSum.getCell(12).setCellStyle(cellStyle);
// 订单总金额(人民币)合计
rowSum.getCell(13).setCellValue(allOrdersTotalPriceCount_RMB);
rowSum.getCell(13).setCellStyle(cellStyle);
// 订单总金额(欧元)合计
rowSum.getCell(14).setCellValue(allOrdersTotalPriceCount_EUR);
rowSum.getCell(14).setCellStyle(cellStyle);
downloadPath = reportOutputPath + "销售报表" + ".xls";
downloadPathForNginx = "/report/" + "销售报表" + ".xls";
out = new FileOutputStream(downloadPath);
wb.write(out);
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if ("".equals(downloadPath)) {
return ResultGenerator.genFailResult("异常导出失败!");
} else {
return ResultGenerator.genSuccessResult(downloadPathForNginx);
}
}
use of com.eservice.api.model.machine_order.MachineOrderDetail in project sinsim by WilsonHu.
the class MachineOrderController method selectOrders.
/**
* 根据条件查询订单。
* 比如 查询 建立时间create_time在传入的参数 query_start_time 和 query_finish_time 之间的订单
* @param id
* @param contract_id
* @param order_num
* @param contract_num
* @param status 支持多个状态用逗号隔开, "2,3,4"
* @param sellman
* @param customer
* @param marketGroupName
* @param query_start_time
* @param query_finish_time
* @param queryStartTimeSign
* @param queryFinishTimeSign
* @param machine_name
* @param is_fuzzy
* @return
*/
// 注意这个接口在不带参数时查询全部数据会有一定耗时,加了联系单查询。
@PostMapping("/selectOrders")
public Result selectOrders(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size, Integer id, Integer contract_id, String order_num, String contract_num, String status, String sellman, String customer, // 订单归属部门 这个是自动限制的,根据角色自动限制查看哪些订单可见
String marketGroupName, // 这个是查询创建日期
String query_start_time, // 这个是查询创建日期
String query_finish_time, // 这个是查询审核日期
String queryStartTimeSign, // 这个是查询审核日期
String queryFinishTimeSign, // 这个其实是机型
String machine_name, // 订单签核的当前步骤
String oderSignCurrentStep, // 查询框里 查询部门,注意,这个和marketGroupName互不干涉
String searchDepartment, @RequestParam(defaultValue = "true") Boolean is_fuzzy) {
PageHelper.startPage(page, size);
// workaround
// 外贸经理:看外贸一部、二部订单,查询用词"外贸“ 两个字,后台已经模糊查询,匹配“外贸一部”和“外贸二部”
// 外贸总监:看外贸一部、二部订单,查询用词"外贸“ 两个字,后台已经模糊查询,匹配“外贸一部”和“外贸二部”
// if (marketGroupName != null && !marketGroupName.isEmpty()) {
// if (marketGroupName.equals(Constant.STR_DEPARTMENT_FOREIGN_FUZZY)) {
// marketGroupName = Constant.STR_DEPARTMENT_FOREIGN_FUZZY;
// }
// }
List<MachineOrderDetail> list = machineOrderService.selectOrder(id, contract_id, order_num, contract_num, status, sellman, customer, marketGroupName, query_start_time, query_finish_time, queryStartTimeSign, queryFinishTimeSign, machine_name, oderSignCurrentStep, searchDepartment, is_fuzzy);
PageInfo pageInfo = new PageInfo(list);
return ResultGenerator.genSuccessResult(pageInfo);
}
use of com.eservice.api.model.machine_order.MachineOrderDetail in project sinsim by WilsonHu.
the class TaskRecordController method exportToExcel.
/**
* 在”生产管理”的“生产报表”导出到excel.
*/
@PostMapping("/exportToExcel")
public Result exportToExcel(Integer taskRecordId, String taskName, String machineOrderNumber, String queryStartTime, String queryFinishTime, String nameplate) {
List<TaskRecordDetail> list = taskRecordService.searchTaskRecordDetail(taskRecordId, taskName, machineOrderNumber, queryStartTime, queryFinishTime, nameplate);
HSSFWorkbook wb = null;
FileOutputStream out = null;
String downloadPath = "";
/*
返回给docker外部下载
*/
String downloadPathForNginx = "";
SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm");
String dateString;
try {
// 生成一个空的Excel文件
wb = new HSSFWorkbook();
Sheet sheet1 = wb.createSheet("生产报表");
// 设置标题行格式
HSSFCellStyle headcellstyle = wb.createCellStyle();
HSSFFont headfont = wb.createFont();
headfont.setFontHeightInPoints((short) 10);
// 粗体显示
headfont.setBold(true);
headcellstyle.setFont(headfont);
Row row;
// 创建行和列
for (int r = 0; r < list.size() + 1; r++) {
// 新创建一行,行号为row+1
row = sheet1.createRow(r);
// 序号,工序名称,订单号,机器编号,安装组长,安装的开始时间,安装的结束时间,耗时
for (int c = 0; c < 8; c++) {
// 创建一个单元格,列号为col+1
row.createCell(c);
sheet1.getRow(0).getCell(c).setCellStyle(headcellstyle);
}
}
for (int k = 1; k < 8; k++) {
sheet1.setColumnWidth(k, 4500);
}
// 第一行为标题
sheet1.getRow(0).getCell(0).setCellValue("序号");
sheet1.getRow(0).getCell(1).setCellValue("工序名称");
sheet1.getRow(0).getCell(2).setCellValue("订单号");
sheet1.getRow(0).getCell(3).setCellValue("铭牌号/机器类型/针数/头数/头距/X行程/Y行程");
sheet1.getRow(0).getCell(4).setCellValue("安装组长");
sheet1.getRow(0).getCell(5).setCellValue("开始时间");
sheet1.getRow(0).getCell(6).setCellValue("结束时间");
sheet1.getRow(0).getCell(7).setCellValue("耗时(分钟)");
// 第二行开始,填入值
MachineType machineType1 = null;
Byte taskStatus = 0;
for (int r = 0; r < list.size(); r++) {
row = sheet1.getRow(r + 1);
row.getCell(0).setCellValue(r + 1);
// 工序名称
if (list.get(r).getTaskName() != null) {
row.getCell(1).setCellValue(list.get(r).getTaskName());
}
// 订单号
if (list.get(r).getMachineOrder().getOrderNum() != null) {
row.getCell(2).setCellValue(list.get(r).getMachineOrder().getOrderNum());
}
// 机器编号等机器信息
Machine machine = list.get(r).getMachine();
MachineOrder machineOrder = list.get(r).getMachineOrder();
MachineOrderDetail machineOrderDetail = machineOrderService.getOrderAllDetail(machineOrder.getId());
if (machine != null && machineOrder != null) {
String machineInfo = machine.getNameplate() + "/" + machineOrderDetail.getMachineType().getName() + "/" + machineOrder.getNeedleNum() + "/" + machineOrder.getHeadNum() + "/" + machineOrder.getHeadDistance() + "/" + machineOrder.getxDistance() + "/" + machineOrder.getyDistance();
row.getCell(3).setCellValue(machineInfo);
}
// 安装组长
if (list.get(r).getLeader() != null) {
row.getCell(4).setCellValue(list.get(r).getLeader());
}
// 开始时间
if (list.get(r).getInstallBeginTime() != null) {
dateString = formatter.format(list.get(r).getInstallBeginTime());
row.getCell(5).setCellValue(dateString);
}
// 结束时间
if (list.get(r).getInstallEndTime() != null) {
dateString = formatter.format(list.get(r).getInstallEndTime());
row.getCell(6).setCellValue(dateString);
}
// 耗时
if (list.get(r).getInstallBeginTime() != null && list.get(r).getInstallEndTime() != null) {
long minHourDay = commonService.secondsToMin(list.get(r).getInstallEndTime().getTime() - list.get(r).getInstallBeginTime().getTime());
row.getCell(7).setCellValue(minHourDay);
}
}
downloadPath = taskRecordExcelOutputDir + "生产报表" + ".xls";
downloadPathForNginx = "/excel/" + "生产报表" + ".xls";
out = new FileOutputStream(downloadPath);
wb.write(out);
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if ("".equals(downloadPath)) {
return ResultGenerator.genFailResult("异常导出失败!");
} else {
return ResultGenerator.genSuccessResult(downloadPathForNginx);
}
}
use of com.eservice.api.model.machine_order.MachineOrderDetail in project sinsim by WilsonHu.
the class MachineOrderController method exportToFinaceExcel.
@PostMapping("/exportToFinaceExcel")
public Result exportToFinaceExcel(Integer id, Integer contract_id, String order_num, String contract_num, String status, String sellman, String customer, String marketGroupName, // 这个是查询创建日期
String query_start_time, // 这个是查询创建日期
String query_finish_time, // 这个是查询审核日期
String queryStartTimeSign, // 这个是查询审核日期
String queryFinishTimeSign, String machine_name, // 订单签核的当前步骤
String oderSignCurrentStep, String searchDepartment, @RequestParam(defaultValue = "true") Boolean is_fuzzy) {
List<MachineOrderDetail> list = machineOrderService.selectOrder(id, contract_id, order_num, contract_num, status, sellman, customer, marketGroupName, query_start_time, query_finish_time, queryStartTimeSign, queryFinishTimeSign, machine_name, oderSignCurrentStep, searchDepartment, is_fuzzy);
HSSFWorkbook wb = null;
FileOutputStream out = null;
String downloadPath = "";
/*
返回给docker外部下载
*/
String downloadPathForNginx = "";
SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
String dateString;
try {
// 生成一个空的Excel文件
wb = new HSSFWorkbook();
Sheet sheet1 = wb.createSheet("账务报表");
// 设置标题行格式
HSSFCellStyle headcellstyle = wb.createCellStyle();
HSSFFont headfont = wb.createFont();
headfont.setFontHeightInPoints((short) 10);
// 粗体显示
headfont.setBold(true);
headcellstyle.setFont(headfont);
Row row;
// 新创建一行,行号为row+1
row = sheet1.createRow(0);
int columnSum = 35;
for (int c = 0; c < columnSum; c++) {
// 列头
// 创建一个单元格,列号为col+1
row.createCell(c);
sheet1.setColumnWidth(c, 4500);
sheet1.getRow(0).getCell(c).setCellStyle(headcellstyle);
}
// 第一行为标题
sheet1.getRow(0).getCell(0).setCellValue("客户");
sheet1.getRow(0).getCell(1).setCellValue("合同号");
sheet1.getRow(0).getCell(2).setCellValue("订单号");
// sheet1.getRow(0).getCell(3).setCellValue("铭牌号");
sheet1.getRow(0).getCell(3).setCellValue("机器信息");
sheet1.getRow(0).getCell(4).setCellValue("台数");
sheet1.getRow(0).getCell(5).setCellValue("单价");
sheet1.getRow(0).getCell(6).setCellValue("装置");
sheet1.getRow(0).getCell(7).setCellValue("装置总价");
sheet1.getRow(0).getCell(8).setCellValue("优惠金额");
sheet1.getRow(0).getCell(9).setCellValue("订单总价");
sheet1.getRow(0).getCell(10).setCellValue("币种");
sheet1.getRow(0).getCell(11).setCellValue("销售员");
// 销售费
sheet1.getRow(0).getCell(12).setCellValue("业务费");
sheet1.getRow(0).getCell(13).setCellValue("保修费");
sheet1.getRow(0).getCell(14).setCellValue("保修人员");
sheet1.getRow(0).getCell(15).setCellValue("付款方式");
sheet1.getRow(0).getCell(16).setCellValue("定金率");
sheet1.getRow(0).getCell(17).setCellValue("毛利");
sheet1.getRow(0).getCell(18).setCellValue("包装方式");
sheet1.getRow(0).getCell(19).setCellValue("机架长度");
sheet1.getRow(0).getCell(20).setCellValue("针数");
sheet1.getRow(0).getCell(21).setCellValue("头数");
sheet1.getRow(0).getCell(22).setCellValue("头距");
sheet1.getRow(0).getCell(23).setCellValue("X行程");
sheet1.getRow(0).getCell(24).setCellValue("Y行程");
sheet1.getRow(0).getCell(25).setCellValue("电脑");
sheet1.getRow(0).getCell(26).setCellValue("剪线方式");
sheet1.getRow(0).getCell(27).setCellValue("换色方式");
sheet1.getRow(0).getCell(28).setCellValue("加油系统");
sheet1.getRow(0).getCell(29).setCellValue("夹线器");
sheet1.getRow(0).getCell(30).setCellValue("跳跃方式");
sheet1.getRow(0).getCell(31).setCellValue("旋梭");
sheet1.getRow(0).getCell(32).setCellValue("面线夹持");
sheet1.getRow(0).getCell(33).setCellValue("订单类型");
sheet1.getRow(0).getCell(34).setCellValue("填表日期");
DataFormat dataFormat = wb.createDataFormat();
CellStyle cellStyle;
HSSFCellStyle wrapStyle = wb.createCellStyle();
wrapStyle.setWrapText(true);
// 第二行开始,填入值
for (int i = 0; i < list.size(); i++) {
int r = i + 1;
MachineOrderDetail mod = list.get(i);
OrderDetail od = mod.getOrderDetail();
// 新创建一行
row = sheet1.createRow(r);
for (int c = 0; c < columnSum; c++) {
// 创建列单元格
row.createCell(c);
}
// 客户
sheet1.getRow(r).getCell(0).setCellValue(mod.getCustomer());
// 合同号
sheet1.getRow(r).getCell(1).setCellValue(mod.getContractNum());
//
sheet1.getRow(r).getCell(2).setCellValue(mod.getOrderNum());
sheet1.getRow(r).getCell(0).setCellStyle(wrapStyle);
sheet1.getRow(r).getCell(1).setCellStyle(wrapStyle);
sheet1.getRow(r).getCell(2).setCellStyle(wrapStyle);
// sheet1.getRow(r).getCell(3).setCellValue(mod.getNameplate());//
MachineType mt = mod.getMachineType();
if (mt != null) {
// 机器信息
String machineInfo = mt.getName() + "/" + mod.getNeedleNum() + "/" + mod.getHeadNum() + "/" + mod.getHeadDistance() + "/" + mod.getxDistance() + "/" + mod.getyDistance() + "/" + mod.getElectricTrim() + "/" + mod.getElectricPc();
//
sheet1.getRow(r).getCell(3).setCellValue(machineInfo);
}
//
sheet1.getRow(r).getCell(4).setCellValue(mod.getMachineNum());
//
sheet1.getRow(r).getCell(5).setCellValue(mod.getMachinePrice());
cellStyle = wb.createCellStyle();
// 金额格式
cellStyle.setDataFormat(dataFormat.getFormat("#,##0.00"));
sheet1.getRow(r).getCell(5).setCellStyle(cellStyle);
List<Equipment> epArray = JSON.parseArray(mod.getEquipment(), Equipment.class);
String strEp = "";
int epAmount = 0;
for (Equipment itemEquipment : epArray) {
strEp += itemEquipment.getName() + ":" + itemEquipment.getNumber() + "个" + "\r\n";
epAmount += itemEquipment.getPrice() * itemEquipment.getNumber();
}
sheet1.getRow(r).getCell(6).setCellStyle(wrapStyle);
// 装置
sheet1.getRow(r).getCell(6).setCellValue(new HSSFRichTextString(strEp));
// 装置金额
sheet1.getRow(r).getCell(7).setCellValue(epAmount);
sheet1.getRow(r).getCell(7).setCellStyle(cellStyle);
// 优惠金额
sheet1.getRow(r).getCell(8).setCellValue(mod.getDiscounts());
Double totalAmount = Double.parseDouble(mod.getMachinePrice()) * mod.getMachineNum() + epAmount - Double.parseDouble(mod.getDiscounts());
sheet1.getRow(r).getCell(8).setCellStyle(cellStyle);
// 总金额
sheet1.getRow(r).getCell(9).setCellValue(totalAmount);
sheet1.getRow(r).getCell(9).setCellStyle(cellStyle);
// 币种
sheet1.getRow(r).getCell(10).setCellValue(mod.getCurrencyType());
// 销售员
sheet1.getRow(r).getCell(11).setCellValue(mod.getSellman());
// 销售费
sheet1.getRow(r).getCell(12).setCellValue(mod.getBusinessExpense());
// 保修费
sheet1.getRow(r).getCell(13).setCellValue(mod.getWarrantyFee());
// 保修人员
sheet1.getRow(r).getCell(14).setCellValue(mod.getMaintainPerson());
// 付款方式
sheet1.getRow(r).getCell(15).setCellValue(mod.getPayMethod());
// sheet1.getRow(r).getCell(16).setCellValue(0);//定金率 先空着
// 改为要从成本核算员的意见中抽取 毛利率
// 毛利率
sheet1.getRow(r).getCell(17).setCellValue(mod.getGrossProfit());
// 包装方式
sheet1.getRow(r).getCell(18).setCellValue(mod.getPackageMethod());
// 订单中关于技术部的意见里长度:***,显示在财务报表中,显示方式为【机架长度】一栏
// 机架长度
sheet1.getRow(r).getCell(19).setCellValue(mod.getMachineFrameLength());
// 针数
sheet1.getRow(r).getCell(20).setCellValue(mod.getNeedleNum());
// 头数
sheet1.getRow(r).getCell(21).setCellValue(mod.getHeadNum());
// 头距
sheet1.getRow(r).getCell(22).setCellValue(mod.getHeadDistance());
// X行程
sheet1.getRow(r).getCell(23).setCellValue(mod.getxDistance());
// Y行程
sheet1.getRow(r).getCell(24).setCellValue(mod.getyDistance());
// 电脑
sheet1.getRow(r).getCell(25).setCellValue(od.getElectricPc());
// 剪线方式
sheet1.getRow(r).getCell(26).setCellValue(od.getElectricTrim());
// 换色方式
sheet1.getRow(r).getCell(27).setCellValue(od.getColorChangeMode());
// 加油系统
sheet1.getRow(r).getCell(28).setCellValue(od.getElectricOil());
// 夹线器
sheet1.getRow(r).getCell(29).setCellValue(od.getAxleSplit());
// 跳跃方式
sheet1.getRow(r).getCell(30).setCellValue(od.getAxleJump());
// 旋梭
sheet1.getRow(r).getCell(31).setCellValue(od.getAxleHook());
// 面线夹持
sheet1.getRow(r).getCell(32).setCellValue(od.getAxleUpperThread());
// 订单类型
sheet1.getRow(r).getCell(33).setCellValue(mod.getOrderType());
dateString = formatter.format(mod.getCreateTime());
// 填表日期
sheet1.getRow(r).getCell(34).setCellValue(dateString);
}
downloadPath = reportOutputPath + "账务报表" + ".xls";
downloadPathForNginx = "/report/" + "账务报表" + ".xls";
out = new FileOutputStream(downloadPath);
wb.write(out);
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if ("".equals(downloadPath)) {
return ResultGenerator.genFailResult("异常导出失败!");
} else {
return ResultGenerator.genSuccessResult(downloadPathForNginx);
}
}
Aggregations