Bladeren bron

Merge branch 'master' of http://47.100.37.243:10191/wutt/manHourHousekeeper

QuYueTing 4 weken geleden
bovenliggende
commit
fdb56aae90

+ 5 - 32
fhKeeper/formulahousekeeper/management-platform-mld/src/main/java/com/management/platform/service/impl/TaskServiceImpl.java

@@ -630,29 +630,13 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
         List<ReportExtraDegree> customerInfoList = reportExtraDegreeMapper.getAll(companyId);
         List<Department> departmentList = departmentService.list(new QueryWrapper<Department>().eq("company_id", companyId));
 
-        //然后处理文件
-        String fileName = multipartFile.getOriginalFilename();
-        File file = new File(fileName == null ? "file" : fileName);
-        InputStream inputStream = null;
-        OutputStream outputStream = null;
-        try {
-            inputStream = multipartFile.getInputStream();
-            outputStream = new FileOutputStream(file);
-            byte[] buffer = new byte[4096];
-            int temp = 0;
-            while ((temp = inputStream.read(buffer, 0, 4096)) != -1) {
-                outputStream.write(buffer, 0, temp);
-            }
-            inputStream.close();
-            outputStream.close();
+        try(InputStream inputStream = multipartFile.getInputStream()) {
+
             //然后解析表格
-            XSSFWorkbook workbook = new XSSFWorkbook(file);
+            XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
             //我们只需要第一个sheet
             XSSFSheet sheet = workbook.getSheetAt(0);
 
-            HttpRespMsg respMsg=new HttpRespMsg();
-
-
             //由于第一行需要指明列对应的标题
             int lastRowNum = sheet.getLastRowNum();
             System.out.println("lastRowNum==>"+lastRowNum);
@@ -1163,23 +1147,12 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                     }
                 }
             }
-        } catch (IOException e) {
+        }
+        catch (IOException e) {
             e.printStackTrace();
             //httpRespMsg.setError("文件处理出错");
             httpRespMsg.setError(MessageUtils.message("file.error"));
             return httpRespMsg;
-        } finally {
-            //关闭流
-            try {
-                if (outputStream != null && inputStream != null) {
-                    outputStream.close();
-                    inputStream.close();
-                    System.out.println("流已关闭");
-                }
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-            System.out.println(file.delete());
         }
         return httpRespMsg;
     }

+ 2 - 29
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/impl/CustomerInfoServiceImpl.java

@@ -43,23 +43,9 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
     public HttpRespMsg importData(HttpServletRequest request, MultipartFile multipartFile) {
         HttpRespMsg msg=new HttpRespMsg();
         Integer companyId=userMapper.selectById(request.getHeader("token")).getCompanyId();
-        String fileName=multipartFile.getOriginalFilename();
-        File file=new File(fileName == null ? "file" : fileName);
-        InputStream inputStream=null;
-        OutputStream outputStream=null;
-        try {
-            inputStream= multipartFile.getInputStream();
-            outputStream=new FileOutputStream(file);
-            byte[] buffer = new byte[4096];
-            int temp = 0;
-            while ((temp = inputStream.read(buffer, 0, 4096)) != -1) {
-                outputStream.write(buffer, 0, temp);
-            }
-            inputStream.close();
-            outputStream.close();
-
+        try(InputStream inputStream= multipartFile.getInputStream()) {
             //然后解析表格
-            Workbook workbook = WorkbookFactory.create(new FileInputStream(file));
+            Workbook workbook = WorkbookFactory.create(inputStream);
             DateFormat df = new SimpleDateFormat("yyyy-MM");
             //获取公司所有客户
             List<CustomerInfo> allCustomerInfo = customerInfoMapper.selectList(new QueryWrapper<CustomerInfo>().eq("company_id", companyId));
@@ -132,19 +118,6 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
             //msg.setError("文件加密状态,需要先解除加密状态再上传");
             msg.setError(MessageUtils.message("file.encryption"));
             return msg;
-        }finally {
-            //关闭流
-            try {
-                if (outputStream != null && inputStream != null) {
-                    outputStream.close();
-                    inputStream.close();
-                    System.out.println("流已关闭");
-                }
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-//            file.deleteOnExit();//程序退出时删除临时文件
-            System.out.println(file.delete());
         }
     }
 

+ 4 - 29
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/impl/PlanServiceImpl.java

@@ -572,22 +572,9 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
         HttpRespMsg msg=new HttpRespMsg();
         DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
         SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
-        String fileName = multipartFile.getOriginalFilename();
-        File file = new File(fileName == null ? "file" : fileName);
-        InputStream inputStream = null;
-        OutputStream outputStream = null;
-        try {
-            inputStream = multipartFile.getInputStream();
-            outputStream = new FileOutputStream(file);
-            byte[] buffer = new byte[4096];
-            int temp = 0;
-            while ((temp = inputStream.read(buffer, 0, 4096)) != -1) {
-                outputStream.write(buffer, 0, temp);
-            }
-            inputStream.close();
-            outputStream.close();
+        try(InputStream inputStream = multipartFile.getInputStream()) {
             //然后解析表格
-            XSSFWorkbook workbook = new XSSFWorkbook(file);
+            XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
             //我们只需要第一个sheet
             XSSFSheet sheet = workbook.getSheetAt(0);
             int rowNum = sheet.getLastRowNum();
@@ -956,7 +943,8 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
                     msg.setData("导入成功,其中产品[" + sb.toString() + "]产品工序未完成,请完成工序配置后重新导入");
                 }
             }
-        } catch (IOException e) {
+        }
+        catch (IOException e) {
             e.printStackTrace();
         } catch (NullPointerException e) {
             e.printStackTrace();
@@ -979,19 +967,6 @@ public class PlanServiceImpl extends ServiceImpl<PlanMapper, Plan> implements Pl
             //msg.setError("上传失败:" + e.getMessage());
             msg.setError(MessageUtils.message("file.uploadError",e.getMessage()));
             return msg;
-        } finally {
-            //关闭流
-            try {
-                if (outputStream != null && inputStream != null) {
-                    outputStream.close();
-                    inputStream.close();
-                    System.out.println("流已关闭");
-                }
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-//            file.deleteOnExit();//程序退出时删除临时文件
-            System.out.println(file.delete());
         }
         return msg;
     }

+ 2 - 36
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/impl/ProductServiceImpl.java

@@ -231,32 +231,11 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
         List<Product> productList=new ArrayList<>();
         List<ProdProcedure> prodProcedureList=new ArrayList<>();
         List<Plan> needUpdatePlanList=new ArrayList<>();
-
-
         Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
 
-        String fileName = multipartFile.getOriginalFilename();
-        File file = new File(fileName == null ? "file" : fileName);
-        InputStream inputStream = null;
-        OutputStream outputStream = null;
-
-
-        try {
-            inputStream= multipartFile.getInputStream();
-            outputStream=new FileOutputStream(file);
-
-            byte[] buffer = new byte[4096];
-            int temp = 0;
-            while ((temp = inputStream.read(buffer, 0, 4096)) != -1) {
-                outputStream.write(buffer, 0, temp);
-            }
-            inputStream.close();
-            outputStream.close();
-
-
+        try (InputStream inputStream= multipartFile.getInputStream()){
             //然后解析表格
-
-            XSSFWorkbook workbook = new XSSFWorkbook(file);
+            XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
             //第一个sheet 产品信息
             XSSFSheet sheet = workbook.getSheetAt(0);
             int rowNum = sheet.getLastRowNum();
@@ -545,19 +524,6 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
             //msg.setError("上传失败:" + e.getMessage());
             msg.setError(MessageUtils.message("file.uploadError",e.getMessage()));
             return msg;
-        } finally {
-            //关闭流
-            try {
-                if (outputStream != null && inputStream != null) {
-                    outputStream.close();
-                    inputStream.close();
-                    System.out.println("流已关闭");
-                }
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-//            file.deleteOnExit();//程序退出时删除临时文件
-            System.out.println(file.delete());
         }
         return msg;
     }

+ 5 - 55
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/impl/UserServiceImpl.java

@@ -313,23 +313,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
         HttpRespMsg msg = new HttpRespMsg();
         User user = userMapper.selectById(request.getHeader("TOKEN"));
         Integer companyId = user.getCompanyId();
-        //然后处理文件
-        String fileName = multipartFile.getOriginalFilename();
-        File file = new File(fileName == null ? "file" : fileName);
-        InputStream inputStream = null;
-        OutputStream outputStream = null;
-        try {
-            inputStream = multipartFile.getInputStream();
-            outputStream = new FileOutputStream(file);
-            byte[] buffer = new byte[4096];
-            int temp = 0;
-            while ((temp = inputStream.read(buffer, 0, 4096)) != -1) {
-                outputStream.write(buffer, 0, temp);
-            }
-            inputStream.close();
-            outputStream.close();
+        try (InputStream inputStream = multipartFile.getInputStream()){
             //然后解析表格
-            Workbook wb = WorkbookFactory.create(new FileInputStream(file));
+            Workbook wb = WorkbookFactory.create(inputStream);
             Sheet sheet = wb.getSheetAt(0);
             //要插入的账号列表
             List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
@@ -457,17 +443,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
             e.printStackTrace();
             //msg.setError("文件格式错误,如果安装了加密软件需要先解密再上传");
             msg.setError(MessageUtils.message("file.FormatErrorAndDecrypt"));
-        } finally {
-            //关闭流
-            try {
-                if (outputStream != null && inputStream != null) {
-                    outputStream.close();
-                    inputStream.close();
-                }
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-            System.out.println(file.delete());
         }
         return msg;
     }
@@ -1365,22 +1340,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
         }
 //        BigDecimal monthHours = time.getMonthDays().multiply(new BigDecimal(time.getAllday()));
         //然后处理文件
-        String fileName = multipartFile.getOriginalFilename();
-        File file = new File(fileName == null ? "file" : fileName);
-        InputStream inputStream = null;
-        OutputStream outputStream = null;
-        try {
-            inputStream = multipartFile.getInputStream();
-            outputStream = new FileOutputStream(file);
-            byte[] buffer = new byte[4096];
-            int temp = 0;
-            while ((temp = inputStream.read(buffer, 0, 4096)) != -1) {
-                outputStream.write(buffer, 0, temp);
-            }
-            inputStream.close();
-            outputStream.close();
+
+        try(InputStream inputStream = multipartFile.getInputStream()) {
             //然后解析表格
-            XSSFWorkbook workbook = new XSSFWorkbook(file);
+            XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
             //我们只需要第一个sheet
             XSSFSheet sheet = workbook.getSheetAt(0);
             //查重检验的手机号列表
@@ -1538,19 +1501,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
             //httpRespMsg.setError("发生其他错误");
             httpRespMsg.setError(MessageUtils.message("other.error"));
             return httpRespMsg;
-        } finally {
-            //关闭流
-            try {
-                if (outputStream != null && inputStream != null) {
-                    outputStream.close();
-                    inputStream.close();
-                    System.out.println("流已关闭");
-                }
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-//            file.deleteOnExit();//程序退出时删除临时文件
-            System.out.println(file.delete());
         }
         return httpRespMsg;
     }

+ 53 - 2
fhKeeper/formulahousekeeper/timesheet/src/views/project/cost.vue

@@ -33,6 +33,7 @@
                         <el-radio-button :label="$t('lable.department')"
                             v-if="(permissions.viewAllSummary || permissions.viewMagDeptSummary)"></el-radio-button>
                         <el-radio-button :label="$t('ren-yuan')" v-if="permissions.countPersonnel"></el-radio-button>
+                        <el-radio-button label="工单" v-if="user.companyId == 7536"></el-radio-button>
                         <el-radio-button :label="namess"
                             v-if="jichu.customDegreeActive == 1 && !jichu.customDegreeMultiple"></el-radio-button>
                         <el-radio-button v-for="item in theCustomList" :key="item.id"
@@ -57,8 +58,10 @@
                         @change="filterPersonnel"></select-personnel>
                 </el-col>
                 <el-col :span="2" style="display: flex;justify-content: flex-end;">
+                    <el-button @click="reportExportCustomization" size="small" :loading="reportExportLoading"
+                        v-if="user.companyId == 7536">报表导出</el-button>
                     <el-button @click="exportTheCustomListFlg" size="small" :loading="theCustomListFlgBtnLoading"
-                        v-if="theCustomListFlg">报表导</el-button>
+                        v-else-if="theCustomListFlg">报表导</el-button>
                     <el-button @click="showExportDialog" size="small" v-else>报表导出</el-button>
                 </el-col>
             </el-row>
@@ -215,6 +218,10 @@ export default {
                     url: '/device-log/getDeviceTimeCost',
                     extraParams: { projectId: this.chartProjectId }
                 },
+                ['工单']: {
+                    url: '/project/getTimeCostByWorkNum',
+                    extraParams: { }
+                },
                 [this.namess]: {
                     url: '/project/getDegreeCost',
                     extraParams: { projectId: this.chartProjectId }
@@ -347,11 +354,39 @@ export default {
                 this.pageTotal = this.allListData ? this.allListData.length : 0
                 list = this.allListData.slice(0 + 10 * (this.pageIndex - 1), 49 + 50 * (this.pageIndex - 1))
                 newBarChartOptions = this.namessChartData(list, totalMoneyCost, newBarChartOptions)
-            }
+            } else if (this.singleChoiceType == '工单') {
+                newBarChartOptions = this.workOrderChartData(list, totalMoneyCost, newBarChartOptions)
+            } 
 
             console.log({ ...newBarChartOptions }, '<==== 图表数据')
             this.echartsEcharData = { ...newBarChartOptions }
         },
+        workOrderChartData(list, totalMoneyCost = 0, chartData) { // 工单图表数据
+            let xList = [], yList = [], totalHours = 0;
+            const yAxisValue = this.chartYAxisVal[this.chartYAxis]
+            const { countCost, countHours } = this.permissions
+            for (let i in list) {
+                xList.push(this.nameNumber == '1' ? list[i].workNum : list[i].workNum);
+
+                let item = {
+                    "value": yAxisValue == 0 ? (list[i].costMoney ? list[i].costMoney.toFixed(2) : 0) || list[i].costMoney : (list[i].cost ? list[i].cost.toFixed(1) : 0),
+                    "id": list[i].id || i,
+                }
+                if (countCost) {
+                    item.money = (list[i].costMoney ? list[i].costMoney.toFixed(2) : 0)
+                }
+                if (countHours) {
+                    item.cost = list[i].cost
+                    totalHours += parseFloat(list[i].cost);
+                }
+                yList.push(item);
+            }
+
+            totalHours = this.totalHours.toFixed(1);
+            totalMoneyCost = totalMoneyCost.toFixed(2)
+
+            return { ...this.sameChartProcessing(xList, yList, totalHours, totalMoneyCost, chartData) }
+        },
         equipmentChartData(list, totalMoneyCost = 0, chartData) { // 设备图表数据
             let xList = [], yList = [], totalHours = 0;
             const yAxisValue = this.chartYAxisVal[this.chartYAxis]
@@ -1041,6 +1076,22 @@ export default {
         showExportDialog() { // 显示报表导出
             this.reportExportVisable = true
         },
+        reportExportCustomization() { // 报表导出
+            var url = '/project/exportTimeCostByWorkNum';
+            var fileName = this.chartDate.join('至') + '工单统计表.xlsx';
+            this.reportExportLoading = true;
+            this.postData(url, {
+                startDate: this.chartDate[0],
+                endDate: this.chartDate[1],
+            }).then((res) => {
+                const aTag = document.createElement('a');
+                aTag.download = fileName;
+                aTag.href = res.data;
+                aTag.click()
+            }).finally(() => {
+                this.reportExportLoading = false
+            })
+        },
         // 单独封装请求
         async postData(urls, param) {
             return new Promise((resolve, reject) => {

+ 1 - 0
fhKeeper/formulahousekeeper/timesheet/src/views/team/index.vue

@@ -3519,6 +3519,7 @@ export default {
     // 关键搜索
     searchList() {
       this.listLoading = true;
+      this.page = 1
       this.http.post(
         this.port.manage.list,
         {