Min 1 year ago
parent
commit
5cbcb23068

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

@@ -1431,8 +1431,8 @@ public class ProjectController {
     //同步SAP项目数据到工时管家
     @RequestMapping("/syncProjectWithSap")
     @Transactional
-    public HttpRespMsg syncProjectWithSap(String startDate,String endDate){
-        return projectService.syncProjectWithSap(startDate,endDate);
+    public HttpRespMsg syncProjectWithSap(String startDate,String endDate,String projectCodes){
+        return projectService.syncProjectWithSap(startDate,endDate,projectCodes);
     }
 
     @RequestMapping("/getEffectiveLaborHourRate")

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ProjectService.java

@@ -263,7 +263,7 @@ public interface ProjectService extends IService<Project> {
 
     HttpRespMsg getFunWorkContextList(Integer id);
 
-    HttpRespMsg syncProjectWithSap(String startDate,String endDate);
+    HttpRespMsg syncProjectWithSap(String startDate,String endDate,String projectCodes);
 
     HttpRespMsg getEffectiveLaborHourRate(String startDate, String endDate);
 

+ 2 - 8
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -11581,21 +11581,15 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     }
 
     @Override
-    public HttpRespMsg syncProjectWithSap(String startDate,String endDate) {
+    public HttpRespMsg syncProjectWithSap(String startDate,String endDate,String projectCodes) {
         HttpRespMsg msg=new HttpRespMsg();
         Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
         //获取SAP项目服务数据 ----> 工时管家任务分组下阶段作为项目服务数据
-        if(StringUtils.isEmpty(startDate)||StringUtils.isEmpty(endDate)){
-            //没设置开始或者结束日期 同步当天新增的项目数据
-            DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
-            startDate=df.format(LocalDate.now());
-            endDate=df.format(LocalDate.now());
-        }
         XmlResponseData projectServiceData= SyncSapUtils.syncServiceData("2020-01-01", endDate, companyId);
         //已有的项目分类
         List<ProjectCategory> allProjectCategoryList = projectCategoryMapper.selectList(new QueryWrapper<ProjectCategory>().eq("company_id", companyId));
         List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId));
-        XmlResponseData xmlResponseData = SyncSapUtils.syncProjectFromSap(startDate, endDate);
+        XmlResponseData xmlResponseData = SyncSapUtils.syncProjectFromSap(startDate, endDate,projectCodes);
         List<ProjectQueryResponse> projectQueryResponses = xmlResponseData.getProjectQueryResponses();
         List<Map<String,Object>> idsMapList=new ArrayList<>();
         LocalDate localDate=LocalDate.now();

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/task/TimingTask.java

@@ -1759,7 +1759,7 @@ public class TimingTask {
             //已有的项目分类
             List<ProjectCategory> allProjectCategoryList = projectCategoryMapper.selectList(new QueryWrapper<ProjectCategory>().eq("company_id", companyId));
             List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId));
-            XmlResponseData xmlResponseData = SyncSapUtils.syncProjectFromSap(df.format(date.minusDays(1)), df.format(date.minusDays(1)));
+            XmlResponseData xmlResponseData = SyncSapUtils.syncProjectFromSap(df.format(date.minusDays(1)), df.format(date.minusDays(1)),null);
             List<ProjectQueryResponse> projectQueryResponses = xmlResponseData.getProjectQueryResponses();
             List<Map<String,Object>> idsMapList=new ArrayList<>();
             LocalDate localDate=LocalDate.now();

+ 32 - 18
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/SyncSapUtils.java

@@ -183,28 +183,42 @@ public class SyncSapUtils {
 
 
     //同步SAP项目数据到工时管家
-    public static XmlResponseData syncProjectFromSap(String startDate, String endDate) {
+    public static XmlResponseData syncProjectFromSap(String startDate, String endDate,String projectCodes) {
         //配置请求xml
         XmlRequestData xmlRequestData=new XmlRequestData();
         ProcessingConditions processingConditions=new ProcessingConditions();
-        processingConditions.setQueryHitsUnlimitedIndicator("true");
-        xmlRequestData.setProcessingConditions(processingConditions);
-        ProjectSelectionByElement projectSelectionByElement=new ProjectSelectionByElement();
-        //todo:根据时间范围
-        SelectionByLastChangeDateTime selectionByLastChangeDateTime=new SelectionByLastChangeDateTime();
-        selectionByLastChangeDateTime.setInclusionExclusionCode("I");
-        selectionByLastChangeDateTime.setIntervalBoundaryTypeCode("3");
-        selectionByLastChangeDateTime.setLowerBoundaryLastChangeDateTime(startDate+"T00:00:00Z");
-        selectionByLastChangeDateTime.setUpperBoundaryLastChangeDateTime(endDate+"T00:00:00Z");
-        projectSelectionByElement.setSelectionByLastChangeDateTime(selectionByLastChangeDateTime);
-        //todo:根据编号
-//        SelectionByProjectID selectionByProjectID=new SelectionByProjectID();
-//        selectionByProjectID.setInclusionExclusionCode("I");
-//        selectionByProjectID.setIntervalBoundaryTypeCode("1");
-//        selectionByProjectID.setLowerBoundaryProjectID("CPSP2250001");
-//        projectSelectionByElement.setSelectionByProjectID(selectionByProjectID);
         List<ProjectSelectionByElement> list=new ArrayList<>();
-        list.add(projectSelectionByElement);
+        if(!StringUtils.isEmpty(startDate)&&!StringUtils.isEmpty(endDate)){
+            processingConditions.setQueryHitsUnlimitedIndicator("true");
+            ProjectSelectionByElement projectSelectionByElement=new ProjectSelectionByElement();
+            //todo:根据时间范围
+            SelectionByLastChangeDateTime selectionByLastChangeDateTime=new SelectionByLastChangeDateTime();
+            selectionByLastChangeDateTime.setInclusionExclusionCode("I");
+            selectionByLastChangeDateTime.setIntervalBoundaryTypeCode("3");
+            selectionByLastChangeDateTime.setLowerBoundaryLastChangeDateTime(startDate+"T00:00:00Z");
+            selectionByLastChangeDateTime.setUpperBoundaryLastChangeDateTime(endDate+"T00:00:00Z");
+            projectSelectionByElement.setSelectionByLastChangeDateTime(selectionByLastChangeDateTime);
+            list.add(projectSelectionByElement);
+        }else if(!StringUtils.isEmpty(projectCodes)){
+            String[] projectCodeArray = projectCodes.split(",");
+            processingConditions.setQueryHitsUnlimitedIndicator("false");
+            processingConditions.setQueryHitsMaximumNumberValue(String.valueOf(projectCodeArray.length));
+            //todo:根据编号
+            ProjectSelectionByElement projectSelectionByElement=new ProjectSelectionByElement();
+            List<SelectionByProjectID> selectionByProjectIDS=new ArrayList<>();
+            for (String projectCode : projectCodeArray) {
+                SelectionByProjectID selectionByProjectID=new SelectionByProjectID();
+                selectionByProjectID.setInclusionExclusionCode("I");
+                selectionByProjectID.setIntervalBoundaryTypeCode("1");
+                selectionByProjectID.setLowerBoundaryProjectID(projectCode);
+                selectionByProjectIDS.add(selectionByProjectID);
+            }
+            projectSelectionByElement.setSelectionByProjectID(selectionByProjectIDS);
+            list.add(projectSelectionByElement);
+        }else {
+            return new XmlResponseData();
+        }
+        xmlRequestData.setProcessingConditions(processingConditions);
         xmlRequestData.setProjectSelectionByElements(list);
         String xml = CommonUtils.convertToXml(xmlRequestData);
         xml=xml.substring(xml.indexOf("<XMLDATA>")+9,xml.lastIndexOf("</XMLDATA>"));

+ 6 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/webservice/po/ProcessingConditions.java

@@ -9,12 +9,18 @@ public class ProcessingConditions {
 
     private String queryHitsUnlimitedIndicator;
     private String returnedQueryHitsNumberValue;
+    private String queryHitsMaximumNumberValue;
 
     @XmlElement(name = "QueryHitsUnlimitedIndicator")
     public String getQueryHitsUnlimitedIndicator() {
         return queryHitsUnlimitedIndicator;
     }
 
+    @XmlElement(name = "QueryHitsMaximumNumberValue")
+    public String getQueryHitsMaximumNumberValue(){
+        return queryHitsMaximumNumberValue;
+    }
+
     //返回的项目条数
     @XmlElement(name = "ReturnedQueryHitsNumberValue")
     public String getReturnedQueryHitsNumberValue() {

+ 4 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/webservice/po/ProjectSelectionByElement.java

@@ -3,12 +3,14 @@ package com.management.platform.webservice.po;
 import lombok.Data;
 
 import javax.xml.bind.annotation.XmlElement;
+import java.util.List;
 
 @Data
 public class ProjectSelectionByElement {
 
     private SelectionByLastChangeDateTime selectionByLastChangeDateTime;
-    private SelectionByProjectID selectionByProjectID;
+//    private SelectionByProjectID selectionByProjectID;
+    private List<SelectionByProjectID> selectionByProjectID;
 
     @XmlElement(name = "SelectionByLastChangeDateTime")
     public SelectionByLastChangeDateTime getSelectionByLastChangeDateTime() {
@@ -16,7 +18,7 @@ public class ProjectSelectionByElement {
     }
 
     @XmlElement(name = "SelectionByProjectID")
-    public SelectionByProjectID getSelectionByProjectID() {
+    public List<SelectionByProjectID> getSelectionByProjectIDs() {
         return selectionByProjectID;
     }
 }

+ 54 - 4
fhKeeper/formulahousekeeper/timesheet/src/views/project/list.vue

@@ -85,7 +85,7 @@
                                 <el-link type="primary" :underline="false" @click="projectLevelDialog = true">{{ $t('projectlevelmanagement') }}</el-link>
                             </el-dropdown-item>
                             <el-dropdown-item v-if="user.timeType.syncFanwei==1||user.timeType.syncSap==1">
-                                <el-link type="primary" :underline="false" @click="syncProjectForThird()">{{'同步项目信息'}}</el-link>
+                                <el-link type="primary" :underline="false" @click="syncProjectDig=true">{{'同步项目信息'}}</el-link>
                             </el-dropdown-item>
                             <el-dropdown-item v-if="user.companyId==3385 && permissions.projectClassification">
                                 <el-link type="primary" :underline="false" @click="functionalDivisionDig=true,getFunctionalList()">{{'职能分工设置'}}</el-link>
@@ -1630,6 +1630,23 @@
                 <el-button type="primary" @click="batchSetGroupIncharger()">{{ $t('btn.determine') }}</el-button>
             </div>
         </el-dialog>
+        <!-- 项目同步弹窗 -->
+        <el-dialog title="提示" :visible.sync="syncProjectDig" width="600px" :before-close="handleClose">
+            <el-form label-width="100px">
+                <el-form-item :label="'项目编号:'">
+                     <el-select filterable collapse-tags clearable  v-model="hasChooseProjectCode" multiple placeholder="请选择" style="width:100%">
+                        <el-option v-for="item in allProjectList" :key="item.id" :label="item.projectName  + '\u3000' + item.projectCode" :value="item.projectCode">
+                            <span style="float: right; color: #8492a6; font-size: 13px;">{{ item.projectCode }}</span>
+                            <span style="float: left;">{{ item.projectName }}</span>
+                        </el-option>
+                    </el-select>
+                </el-form-item>
+            </el-form>
+            <span slot="footer" class="dialog-footer">
+                <el-button @click="syncProjectDig = false">取 消</el-button>
+                <el-button type="primary" @click="syncProjectForThird(hasChooseProjectCode)">开始同步</el-button>
+            </span>
+        </el-dialog>
     </section>
 </template>
 <style scoped>
@@ -1923,7 +1940,10 @@ a {
                 hasSetGroupInchargerId:null,
                 hasSetGroupList:[],
                 addTaskGroupInchargerDig:false,
-                filterNodePersonnel: []
+                filterNodePersonnel: [],
+                syncProjectDig:false,
+                allProjectList:[],
+                hasChooseProjectCode:[],
             };
         },
         // 过滤器
@@ -3952,14 +3972,20 @@ a {
                 .catch(() => {});
             },
             
-            syncProjectForThird(){
+            syncProjectForThird(hasChooseProjectCode){
                 let url=''
+                let param={}
                 if(this.user.timeType.syncFanwei==1){
                     // 美莱德同步项目信息来源泛微
                     url='/project/syncProjectWithFanwei'
                 }else if(this.user.timeType.syncSap==1){
                     // 依斯倍同步项目信息来源SAP
                     url='/project/syncProjectWithSap'
+                    if(hasChooseProjectCode){
+                        param={
+                            projectCodes:hasChooseProjectCode.toString()
+                        }
+                    }
                 }
                 this.$confirm('确认同步项目数据?','提示',{
                     confirmButtonText: '确定',
@@ -3972,7 +3998,7 @@ a {
                         spinner: 'el-icon-loading',
                         background: 'rgba(0, 0, 0, 0.7)'
                     });
-                    this.http.post(url,{},
+                    this.http.post(url,param,
                     res => {
                         loading.close();
                         console.log(res, 'res')
@@ -3981,6 +4007,7 @@ a {
                                 message: '项目同步成功',
                                 type: "success"
                             });
+                            this.syncProjectDig=false
                         } else {
                             this.$message({
                                 message: res.msg,
@@ -5352,6 +5379,28 @@ a {
             jisuanEstimatedWorkTime(manDay){
                 this.estimatedWorkTime=manDay*this.user.timeType.allday
             },
+            getProjectList(){
+                this.http.post(this.port.project.list,{
+                },
+                res => {
+                    this.listLoading = false;
+                    if (res.code == "ok") {
+                        this.allProjectList=res.data
+                    } else {
+                        this.$message({
+                            message: res.msg,
+                            type: "error"
+                        });
+                    }
+                },
+                error => {
+                    this.$message({
+                        message: error,
+                        type: "error"
+                    });
+                    }
+                );
+            },
             //点击添加
             addFunctional(type){
                 if(type=="functional"){
@@ -5654,6 +5703,7 @@ a {
             this.getClfConfigList()
             this.yanjiuzx()
             this.getObtain()
+            this.getProjectList()
             // this.getRoleList()
 
             // 判断是否有供应商字段