|
@@ -8,6 +8,7 @@ import com.management.platform.entity.vo.OvertimeListVO;
|
|
|
import com.management.platform.mapper.*;
|
|
|
import com.management.platform.service.OperationRecordService;
|
|
|
import com.management.platform.service.ProjectService;
|
|
|
+import com.management.platform.util.DockWithMLD;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
import com.management.platform.util.MessageUtils;
|
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
@@ -20,12 +21,9 @@ import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-import org.springframework.web.client.RestTemplate;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
+import sun.util.resources.LocaleData;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
@@ -33,10 +31,7 @@ import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -1231,5 +1226,47 @@ public class ProjectController {
|
|
|
public HttpRespMsg exportFTEData(String month,String area,HttpServletRequest request){
|
|
|
return projectService.exportFTEData(month,area,request);
|
|
|
}
|
|
|
+
|
|
|
+ @RequestMapping("/syncProjectWithFanwei")
|
|
|
+ public HttpRespMsg syncProjectWithFanwei(){
|
|
|
+ HttpRespMsg httpRespMsg=new HttpRespMsg();
|
|
|
+ String url="http://10.1.10.51:20175/api/cube/restful/interface/getModeDataPageList/getProejct";
|
|
|
+ JSONObject jsonObject=new JSONObject();
|
|
|
+ jsonObject.put("rybh","");
|
|
|
+ jsonObject.put("workDate","");
|
|
|
+ String jsonString = jsonObject.toJSONString();
|
|
|
+ HttpRespMsg result = DockWithMLD.getResult(url, null);
|
|
|
+ List<Map<String,Object>> dataList= (List<Map<String, Object>>) result.data;
|
|
|
+ List<Project> workTimeProjectList = projectService.list(new QueryWrapper<Project>().eq("company_id", 876).select("project_code"));
|
|
|
+ List<Map<String, Object>> mapList = dataList.stream().filter(dl ->!dl.get("xmdm").equals("")&&
|
|
|
+ !workTimeProjectList.stream().anyMatch(wl->wl.getProjectCode()!=null&&!wl.getProjectCode().equals("")&&wl.getProjectCode().equals(dl.get("xmdm")))).collect(Collectors.toList());
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", 876).select("job_number", "id","name"));
|
|
|
+ List<Project> needInsert=new ArrayList<>();
|
|
|
+ for (Map<String, Object> map : mapList) {
|
|
|
+ Optional<User> first = userList.stream().filter(ul ->ul.getJobNumber()!=null&&ul.getJobNumber().equals(map.get("xmfzrplxm"))).findFirst();
|
|
|
+ Project project=new Project();
|
|
|
+ project.setProjectName(String.valueOf(map.get("xmmc")))
|
|
|
+ .setProjectCode(String.valueOf(map.get("xmdm")))
|
|
|
+ .setCompanyId(876)
|
|
|
+ .setCreateDate(LocalDate.now());
|
|
|
+ if(first.isPresent()){
|
|
|
+ project.setInchargerId(first.get().getId())
|
|
|
+ .setInchargerName(first.get().getName());
|
|
|
+ }
|
|
|
+ needInsert.add(project);
|
|
|
+ }
|
|
|
+ httpRespMsg.setData(dataList);
|
|
|
+ if(!projectService.saveBatch(needInsert)){
|
|
|
+ httpRespMsg.setError("操作失败");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ OperationRecord operationRecord=new OperationRecord();
|
|
|
+ operationRecord.setCompanyId(876)
|
|
|
+ .setContent("同步来自泛微的项目数据,共"+needInsert.size()+"条数据")
|
|
|
+ .setModuleName("项目管理").setOperationTime(LocalDateTime.now());
|
|
|
+ operationRecordService.save(operationRecord);
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|