Explorar el Código

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

Min hace 1 año
padre
commit
77c1c6cfc0

+ 63 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/CostProjectSettingController.java

@@ -0,0 +1,63 @@
+package com.management.platform.controller;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.management.platform.entity.CostProjectSetting;
+import com.management.platform.entity.Project;
+import com.management.platform.service.CostProjectSettingService;
+import com.management.platform.service.ProjectService;
+import com.management.platform.util.HttpRespMsg;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author Seyason
+ * @since 2024-03-14
+ */
+@RestController
+@RequestMapping("/cost-project-setting")
+public class CostProjectSettingController {
+
+    @Resource
+    private CostProjectSettingService costProjectSettingService;
+    @Resource
+    private ProjectService projectService;
+
+    @RequestMapping("/get")
+    public HttpRespMsg getCostProjectSetting(Integer companyId, String ymonth){
+        HttpRespMsg msg = new HttpRespMsg();
+        List<CostProjectSetting> list  = costProjectSettingService.list(new QueryWrapper<CostProjectSetting>().eq("company_id",companyId).eq("ymonth",ymonth));
+        HashMap ret = new HashMap();
+        if (list.size() > 0){
+            CostProjectSetting item = list.get(0);
+            ret.put("setting", item);
+        }
+        List<Project> allProjectList = projectService.list(new QueryWrapper<Project>().select("id", "project_code", "project_name").eq("company_id", companyId));
+
+        ret.put("allProjectList", allProjectList);
+        msg.data = ret;
+        return msg;
+    }
+
+    @RequestMapping("/save")
+    public HttpRespMsg saveCostProjectSetting(CostProjectSetting costProjectSetting){
+        HttpRespMsg msg = new HttpRespMsg();
+        if (costProjectSetting.getId() == null) {
+            costProjectSettingService.save(costProjectSetting);
+        } else {
+            costProjectSettingService.updateById(costProjectSetting);
+        }
+        return msg;
+    }
+
+}
+

+ 8 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectController.java

@@ -1503,5 +1503,13 @@ public class ProjectController {
     public HttpRespMsg exportUserTaskProcessList(Integer deptId,String userId,Integer projectId,String startDate,String endDate){
         return projectService.exportUserTaskProcessList(deptId,userId,projectId,startDate,endDate);
     }
+
+    @RequestMapping("/getSimpleProjectList")
+    public HttpRespMsg getSimpleProjectList(Integer companyId){
+        HttpRespMsg msg = new HttpRespMsg();
+        //只获取id,编号,名称
+        msg.data = projectService.list(new QueryWrapper<Project>().select("id","project_code", "project_name").eq("company_id", companyId));
+        return msg;
+    }
 }
 

+ 57 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/CostProjectSetting.java

@@ -0,0 +1,57 @@
+package com.management.platform.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author Seyason
+ * @since 2024-03-14
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class CostProjectSetting extends Model<CostProjectSetting> {
+
+    private static final long serialVersionUID=1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    @TableField("company_id")
+    private Integer companyId;
+
+    /**
+     * 所属年月
+     */
+    @TableField("ymonth")
+    private String ymonth;
+
+    /**
+     * 0-全部项目,1-选择部分项目,2-排除部分项目
+     */
+    @TableField("setting_type")
+    private Integer settingType;
+
+    /**
+     * 选择的项目列表
+     */
+    @TableField("project_json")
+    private String projectJson;
+
+
+    @Override
+    protected Serializable pkVal() {
+        return this.id;
+    }
+
+}

+ 16 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/CostProjectSettingMapper.java

@@ -0,0 +1,16 @@
+package com.management.platform.mapper;
+
+import com.management.platform.entity.CostProjectSetting;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author Seyason
+ * @since 2024-03-14
+ */
+public interface CostProjectSettingMapper extends BaseMapper<CostProjectSetting> {
+
+}

+ 16 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/CostProjectSettingService.java

@@ -0,0 +1,16 @@
+package com.management.platform.service;
+
+import com.management.platform.entity.CostProjectSetting;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author Seyason
+ * @since 2024-03-14
+ */
+public interface CostProjectSettingService extends IService<CostProjectSetting> {
+
+}

+ 20 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/CostProjectSettingServiceImpl.java

@@ -0,0 +1,20 @@
+package com.management.platform.service.impl;
+
+import com.management.platform.entity.CostProjectSetting;
+import com.management.platform.mapper.CostProjectSettingMapper;
+import com.management.platform.service.CostProjectSettingService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author Seyason
+ * @since 2024-03-14
+ */
+@Service
+public class CostProjectSettingServiceImpl extends ServiceImpl<CostProjectSettingMapper, CostProjectSetting> implements CostProjectSettingService {
+
+}

+ 44 - 7
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/FinanceServiceImpl.java

@@ -55,6 +55,8 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
     @Resource
     private DepartmentMapper departmentMapper;
     @Resource
+    private CostProjectSettingMapper costProjectSettingMapper;
+    @Resource
     private TimeTypeMapper timeTypeMapper;
     @Resource
     private FinanceService financeService;
@@ -707,7 +709,27 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
             endDate = endDate.plusMonths(1);
 
             List<Map<String, Object>> projectTimeList = reportMapper.getRealProjectTime(startDate, endDate, companyId);
-
+            //如果定义了可分摊项目的过滤,按照数据处理一下
+            CostProjectSetting setting = costProjectSettingMapper.selectOne(new QueryWrapper<CostProjectSetting>().eq("company_id", companyId));
+            if (setting != null && setting.getSettingType() > 0) {
+                List<Map<String, Object>> newProjectTimeList = new ArrayList<>();
+                for (Map<String, Object> map : projectTimeList) {
+                    Integer projectId = ((Long) map.get("projectId")).intValue();
+                    JSONArray chosenPList = JSONArray.parseArray(setting.getProjectJson());
+                    if (setting.getSettingType() == 1) {
+                        //设置了可分摊的项目
+                        if (chosenPList.contains(projectId)) {
+                            newProjectTimeList.add(map);
+                        }
+                    } else {
+                        //设置了不可分摊的项目,要排除
+                        if (!chosenPList.contains(projectId)) {
+                            newProjectTimeList.add(map);
+                        }
+                    }
+                }
+                projectTimeList = newProjectTimeList;
+            }
 
             //计算每个项目的时间和成本
             ProjectSumItem item = new ProjectSumItem();
@@ -1077,7 +1099,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
             //按项目名称分组
             DecimalFormat workTimeFormatter = new DecimalFormat("0.00");
             if (groupByCategory == 0) {
-                pList.forEach(p->{
+                for (ProjectSumItem p : pList) {
                     p.cost = p.cost.setScale(2, BigDecimal.ROUND_HALF_UP);
                     p.salary = p.salary.setScale(2, BigDecimal.ROUND_HALF_UP);
                     p.bonus = p.bonus.setScale(2, BigDecimal.ROUND_HALF_UP);
@@ -1343,7 +1365,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
                             }
                         }
                     }
-                });
+                }
             } else {
                 //按项目分类分组,需要重组pList为一个项目分组一条
                 Map<String, List<ProjectSumItem>> categoryMap = pList.stream().collect(Collectors.groupingBy(ProjectSumItem::getCategoryName));
@@ -1526,11 +1548,26 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
             endDate = endDate.plusMonths(1);
 
             List<Map<String, Object>> projectTimeList = reportMapper.getRealProjectTime(startDate, endDate, companyId);
-            for (Map<String, Object> map : projectTimeList) {
-                String p = (String) map.get("project");
-                if (p.equals("10G OLT Driver-XGs combo")) {
-                    System.out.println("找到项目 10G OLT Driver-XGs combo");
+            //如果定义了可分摊项目的过滤,按照数据处理一下
+            CostProjectSetting setting = costProjectSettingMapper.selectOne(new QueryWrapper<CostProjectSetting>().eq("company_id", companyId));
+            if (setting != null && setting.getSettingType() > 0) {
+               List<Map<String, Object>> newProjectTimeList = new ArrayList<>();
+                for (Map<String, Object> map : projectTimeList) {
+                    Integer projectId = ((Long) map.get("projectId")).intValue();
+                    JSONArray chosenPList = JSONArray.parseArray(setting.getProjectJson());
+                    if (setting.getSettingType() == 1) {
+                        //设置了可分摊的项目
+                        if (chosenPList.contains(projectId)) {
+                            newProjectTimeList.add(map);
+                        }
+                    } else {
+                        //设置了不可分摊的项目,要排除
+                        if (!chosenPList.contains(projectId)) {
+                            newProjectTimeList.add(map);
+                        }
+                    }
                 }
+                projectTimeList = newProjectTimeList;
             }
             BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
             //计算每个项目的时间和成本

+ 19 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/CostProjectSettingMapper.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.management.platform.mapper.CostProjectSettingMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.management.platform.entity.CostProjectSetting">
+        <id column="id" property="id" />
+        <result column="company_id" property="companyId" />
+        <result column="ymonth" property="ymonth" />
+        <result column="setting_type" property="settingType" />
+        <result column="project_json" property="projectJson" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, company_id, ymonth, setting_type, project_json
+    </sql>
+
+</mapper>

+ 1 - 0
fhKeeper/formulahousekeeper/timesheet/src/i18n/en.json

@@ -371,6 +371,7 @@
   "Selectmonth": "select month",
   "projectworker": "Personnel without project hours",
   "Apportionmentratesetting": "Apportionment ratio settings",
+  "ApportionmentProjsetting": "Apportionment project settings",
   "Downloadthetemplate": "Template download",
   "Dataupload": "data upload",
   "Exportdata": "Data output",

+ 2 - 1
fhKeeper/formulahousekeeper/timesheet/src/i18n/zh.json

@@ -372,7 +372,8 @@
   "Revocationofsuccess": "撤销成功",
   "Selectmonth": "选择月份",
   "projectworker": "无项目工时人员",
-  "Apportionmentratesetting": "分摊比例设置",
+  "Apportionmentratesetting": "无工时人员分摊比例设置",
+  "ApportionmentProjsetting": "分摊项目设置",
   "Downloadthetemplate": "模板下载",
   "Dataupload": "数据上传",
   "Exportdata": "数据导出",

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

@@ -101,7 +101,7 @@
                 </el-form-item>
                 <el-form-item prop="projectId" :label="$t('defaultText.selectProject')" v-if="radio != $t('ren-yuan') && radio != $t('projectclassification') && radio != $t('lable.department') && radio != $t('zhu-xiang-mu')">
                     <el-select v-model="exportParam.projectId" :placeholder="$t('other.allProject')"  clearable style="width:350px;" filterable="true" popper-class="projectSelectPopperClass">
-                        <el-option v-for="item in projectList"  :key="item.id" :label="item.projectName + item.projectCode" :value="item.id">
+                        <el-option v-for="item in projectList"  :key="item.id" :label="item.projectName + '/'+ item.projectCode" :value="item.id">
                             <span style="float: left;color: #8492a6;">{{ item.projectCode }}</span>
                             <span style="float: right;font-size: 13px;">{{ item.projectName }}</span>
                         </el-option>

+ 91 - 10
fhKeeper/formulahousekeeper/timesheet/src/views/project/finance.vue

@@ -14,7 +14,8 @@
                 <el-radio-button :label="$t('projectworker')">{{$t('projectworker')}}({{noReportUserList.length}})</el-radio-button>
             </el-radio-group>
             <el-form-item v-if="permissions.financialProportion" style="margin-left:5px;">
-                <el-link type="primary" :underline="false" @click="showSettingDialog()" >{{ $t('Apportionmentratesetting') }}</el-link>
+                <el-link type="primary" :underline="false" @click="showProjSettingDialog()" v-if="user.companyId == 88">{{ $t('ApportionmentProjsetting')}}</el-link>
+                <el-link type="primary" :underline="false" @click="showSettingDialog()" style="margin-left:50px;">{{ $t('Apportionmentratesetting') }}</el-link>
             </el-form-item>
 
             <el-form-item style="float:right;" v-if="permissions.financialUpload">
@@ -496,6 +497,24 @@
                 <el-button type="primary" @click="saveProjectSetting()" >{{ $t('btn.determine') }}</el-button>
             </div>
         </el-dialog>
+        <el-dialog :title="proSetting.ymonth + $t('projectstobe assessed')" show-header="false" v-if="projSettingDialog" :visible.sync="projSettingDialog" 
+            :close-on-click-modal="false" customClass="customWidth" width="1000px">
+            <el-radio-group v-model="proSetting.settingType" style="margin-top:15px;">
+                <el-radio :label=0 >全部已填报项目</el-radio>
+                <el-radio :label=1 >选择部分项目</el-radio>
+                <el-radio :label=2 >排除部分项目</el-radio>
+            </el-radio-group>
+            <el-select v-model="proSettingChosenProjects" multiple filterable clearable style="width:100%;margin-top:10px;" v-show="proSetting.settingType > 0" @change="updateChosenView()">
+                <el-option v-for="item in allProjectList"  :key="item.id" :label="item.projectName + '/'+ item.projectCode" :value="item.id">
+                    <span style="float: left;color: #8492a6;">{{ item.projectCode }}</span>
+                    <span style="float: right;font-size: 13px;">{{ item.projectName }}</span>
+                </el-option>
+            </el-select>
+            <div slot="footer" class="dialog-footer">
+                <el-button type="default" @click="projSettingDialog = false" >{{ $t('Shutdown') }}</el-button>
+                <el-button type="primary" @click="saveCostProjectSetting()" >{{ $t('btn.determine') }}</el-button>
+            </div>
+        </el-dialog>
         <el-dialog :title="$t('allocationdata')" v-if="intoAmortizationDialog" :visible.sync="intoAmortizationDialog" customClass="customWidth" width="500px">
             <p>{{'1.' + $t('other.download')}}
             <el-link v-if="financialFlg" type="primary" style="margin-left:5px;" :underline="false" :href="'./upload/'+$t('allocationImporttemplates')+'.xlsx'" :download="$t('allocationImporttemplates') + '.xlsx'">{{$t('allocationImporttemplates')+'.xlsx'}}</el-link>
@@ -593,6 +612,11 @@ import { error } from 'dingtalk-jsapi';
         },
         data() {
             return {
+                proSettingChosenProjects:[],
+                proSetting: {
+                    ymonth:null,settingType:0,
+                },
+                projSettingDialog: false,
                 operating: false,
                 showMissingDialog: false,
                 missingFinanceUserList: [],
@@ -668,6 +692,58 @@ import { error } from 'dingtalk-jsapi';
             };
         },
         methods: {
+            getMonthProjSetting() {
+                this.http.post('/cost-project-setting/get',{companyId: this.user.companyId, ymonth: this.date},res => {
+                    if(res.code == 'ok'){
+                        if (res.data.setting != null) {
+                            this.proSetting = res.data.setting;
+                            this.proSettingChosenProjects = JSON.parse(this.proSetting.projectJson);
+                        }
+                        if (this.allProjectList == null || this.allProjectList.length == 0) {
+                            this.allProjectList = res.data.allProjectList;
+                        }
+                    }else{
+                        this.$message({
+                            message: res.msg,
+                            type: 'error'
+                        })
+                    }
+                },err => {
+                    this.$message({
+                        message: err,
+                        type: 'error'
+                    })
+                })
+            },
+            saveCostProjectSetting() {
+                //处理选中的项目
+                if (this.proSetting.settingType == 0) {
+                    this.proSetting.projectJson = '[]';
+                } else {
+                    this.proSetting.projectJson = JSON.stringify(this.proSettingChosenProjects);
+                }
+                this.http.post('/cost-project-setting/save',this.proSetting,res => {
+                    if(res.code == 'ok'){
+                        this.$message({
+                            message: '保存成功',
+                            type: 'success'
+                        })
+                        this.projSettingDialog = false;
+                        //刷新分摊数据显示
+                        this.assignToProject();
+                    }else{
+                        this.$message({
+                            message: res.msg,
+                            type: 'error'
+                        })
+                    }
+                },err => {
+                    this.$message({
+                        message: er,
+                        type: 'error'
+                    })
+                })
+            },
             uploadTest(){
                 this.http.post('/report/uploadThirdReportData',{
                     yearMonth: this.date
@@ -852,6 +928,7 @@ import { error } from 'dingtalk-jsapi';
                     this.assignToProject();
                 }
             },
+
             getLastMonthSetting() {
                 this.costSettingLoading = true;
                 var dataArr = this.date.split('-');
@@ -1067,6 +1144,12 @@ import { error } from 'dingtalk-jsapi';
                 this.settingDialog = true;
                 this.getMonthSetting();
             },
+            showProjSettingDialog() {
+                this.projSettingDialog = true;
+                this.proSetting.ymonth = this.date;
+                this.proSetting.companyId = this.user.companyId;
+                this.getMonthProjSetting();
+            },
             handleSelectionChange(val) {
                 this.multipleSelection = val;
             },
@@ -1194,15 +1277,14 @@ import { error } from 'dingtalk-jsapi';
             
 
             // },
-            // getProjects() {
-            //     this.http.post('/finance/getProjects', {companyId: this.user.companyId, yearMonth: this.date},
-            //         res => {
-            //             if (res.code == "ok") {
-            //                 this.projectCols = res.data.financeProjects;
-            //                 this.allProjectList = res.data.allProjectList;
-            //             }});
+            getProjects() {
+                this.http.post('/project/getSimpleProjectList', {companyId: this.user.companyId},
+                    res => {
+                        if (res.code == "ok") {
+                            this.allProjectList = res.data.allProjectList;
+                        }});
                 
-            // },
+            },
             // showNoProjectUsers() {
             //     this.showNPDialog = true;
             //     this.http.post('/finance/getNoProjectUsers', {yearMonth: this.date},
@@ -1775,7 +1857,6 @@ import { error } from 'dingtalk-jsapi';
             };
             
             this.getCustomColumn();
-            // this.getProjects();
             this.addreviewer();
             this.arrter()
             this.loadMonthData()