|
@@ -337,204 +337,210 @@ public class TimingTask {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- @Scheduled(cron = "0 20 2 ? * *")
|
|
|
- public void getTemporaryJobApplication() throws Exception {
|
|
|
- if(isDev){
|
|
|
- return;
|
|
|
- }
|
|
|
- DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- LocalDate start=LocalDate.now().minusDays(1);
|
|
|
- LocalDate end=LocalDate.now();
|
|
|
- JSONArray jsonArrayFilter = new JSONArray();
|
|
|
- JSONObject filter1 = new JSONObject();
|
|
|
- WxCorpTemplate template = wxCorpTemplateService.getById(7);
|
|
|
- filter1.put("key","template_id");
|
|
|
- filter1.put("value",template.getTemplateId());
|
|
|
- jsonArrayFilter.add(filter1);
|
|
|
- JSONObject filter2 = new JSONObject();
|
|
|
- filter2.put("key","sp_status");
|
|
|
- filter2.put("value",2);
|
|
|
- jsonArrayFilter.add(filter2);
|
|
|
- List<String> approvalInfo = wxCorpInfoService.getApprovalInfo(7, df.format(start), df.format(end), "", jsonArrayFilter);
|
|
|
- List<Department> departmentList = departmentService.list(new LambdaQueryWrapper<Department>().eq(Department::getCompanyId, 7));
|
|
|
- List<TaskType> taskTypeList = taskTypeService.list(new LambdaQueryWrapper<TaskType>().eq(TaskType::getCompanyId, 7));
|
|
|
- List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getCompanyId,7));
|
|
|
- if(approvalInfo!=null){
|
|
|
- for (int i = 0; i < approvalInfo.size(); i++) {
|
|
|
- String codeNum = approvalInfo.get(i);
|
|
|
- String approvalInfoDetailResp = wxCorpInfoService.getApprovalInfoDetail(7, codeNum);
|
|
|
- JSONObject approvalInfoDetail = JSONObject.parseObject(approvalInfoDetailResp);
|
|
|
- JSONObject info = approvalInfoDetail.getJSONObject("info");
|
|
|
- JSONObject applyer = info.getJSONObject("applyer");
|
|
|
- String userid = applyer.getString("userid");
|
|
|
- Optional<User> first = userList.stream().filter(u ->u.getCorpwxRealUserid()!=null&&u.getCorpwxRealUserid().equals(userid)).findFirst();
|
|
|
- if(!first.isPresent()){
|
|
|
- continue;
|
|
|
- }
|
|
|
- JSONObject apply_data = info.getJSONObject("apply_data");
|
|
|
- System.out.println("获取到的单据信息===========>"+apply_data);
|
|
|
- JSONArray contents = apply_data.getJSONArray("contents");
|
|
|
- //生成 车间插单计划
|
|
|
- Plan plan=new Plan();
|
|
|
- plan.setCompanyId(7);
|
|
|
- plan.setCreateTime(LocalDateTime.now());
|
|
|
- plan.setPlanType(1);
|
|
|
- plan.setCreateId(first.get().getId());
|
|
|
- //参与人员列表
|
|
|
- List<String> userTeams=new ArrayList<>();
|
|
|
- //初始化 单价(元/小时)
|
|
|
- BigDecimal price=new BigDecimal(0);
|
|
|
- //初始化 工作时长
|
|
|
- double workTime=0;
|
|
|
- //初始话 工作日期
|
|
|
- JSONArray sp_record = info.getJSONArray("sp_record");
|
|
|
- //获取最后一个审批节点
|
|
|
- JSONObject last_sp_record = sp_record.getJSONObject(sp_record.size() - 1);
|
|
|
- JSONArray details = last_sp_record.getJSONArray("details");
|
|
|
- //获取最后详情
|
|
|
- JSONObject lastDetail = details.getJSONObject(details.size() - 1);
|
|
|
- long sptime = lastDetail.getLongValue("sptime");
|
|
|
- LocalDate createDate=LocalDate.now();
|
|
|
- //初始化工位
|
|
|
- Integer deptId=0;
|
|
|
- for (int i1 = 0; i1 < contents.size(); i1++) {
|
|
|
- JSONObject map = contents.getJSONObject(i1);
|
|
|
- JSONArray title = map.getJSONArray("title");
|
|
|
- JSONObject value = map.getJSONObject("value");
|
|
|
- String control = map.getString("control");
|
|
|
- if(title.getJSONObject(0).getString("text").equals("临时报工分类")){
|
|
|
- if(control.equals("Selector")){
|
|
|
- JSONObject selector = value.getJSONObject("selector");
|
|
|
- JSONArray options = selector.getJSONArray("options");
|
|
|
- JSONObject object = options.getJSONObject(0);
|
|
|
- JSONArray value1 = object.getJSONArray("value");
|
|
|
- JSONObject jsonObject = value1.getJSONObject(0);
|
|
|
- String text = jsonObject.getString("text");
|
|
|
- Optional<TaskType> first1 = taskTypeList.stream().filter(t -> t.getTaskTypeName().equals(text)).findFirst();
|
|
|
- if(first1.isPresent()){
|
|
|
- plan.setTaskTypeId(first1.get().getId());
|
|
|
- plan.setTaskTypeName(first1.get().getTaskTypeName());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if(title.getJSONObject(0).getString("text").equals("事由")){
|
|
|
- if(control.equals("Text")||control.equals("Textarea")){
|
|
|
- String text = value.getString("text");
|
|
|
- plan.setTaskName(text);
|
|
|
- }
|
|
|
- }
|
|
|
- //先处理多个人员 公用此单据非工时部分内容
|
|
|
- if(title.getJSONObject(0).getString("text").equals("参与人员")){
|
|
|
- if(control.equals("Contact")){
|
|
|
- JSONArray members = value.getJSONArray("members");
|
|
|
- for (int i2 = 0; i2 < members.size(); i2++) {
|
|
|
- JSONObject jsonObject = members.getJSONObject(i2);
|
|
|
- String userid1 = jsonObject.getString("userid");
|
|
|
- userTeams.add(userid1);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- if(title.getJSONObject(0).getString("text").equals("参与人数")){
|
|
|
- if(control.equals("Number")){
|
|
|
- int new_number = value.getIntValue("new_number");
|
|
|
- plan.setPlanManNum(new_number);
|
|
|
- }
|
|
|
- }
|
|
|
- if(title.getJSONObject(0).getString("text").equals("开始时间")){
|
|
|
- if(control.equals("Date")){
|
|
|
- JSONObject date = value.getJSONObject("date");
|
|
|
- long s_timestamp = date.getLongValue("s_timestamp");
|
|
|
- LocalDate localDateFromUnix = DateTimeUtil.getLocalDateFromUnix(s_timestamp);
|
|
|
- plan.setStartDate(localDateFromUnix);
|
|
|
- if(sptime>0){
|
|
|
- createDate= DateTimeUtil.getLocalDateFromUnix(sptime);
|
|
|
- }else {
|
|
|
- createDate=localDateFromUnix;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- if(title.getJSONObject(0).getString("text").equals("结束时间")){
|
|
|
- if(control.equals("Date")){
|
|
|
- JSONObject date = value.getJSONObject("date");
|
|
|
- long s_timestamp = date.getLongValue("s_timestamp");
|
|
|
- LocalDate localDateFromUnix = DateTimeUtil.getLocalDateFromUnix(s_timestamp);
|
|
|
- plan.setEndDate(localDateFromUnix);
|
|
|
- if(sptime>0){
|
|
|
- createDate= DateTimeUtil.getLocalDateFromUnix(sptime);
|
|
|
- }else {
|
|
|
- createDate=localDateFromUnix;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if(title.getJSONObject(0).getString("text").equals("工作时长")){
|
|
|
- if(control.equals("Number")){
|
|
|
- double new_number = value.getDoubleValue("new_number");
|
|
|
- workTime=new_number;
|
|
|
- }
|
|
|
- }
|
|
|
- BigDecimal bigDecimal = new BigDecimal(plan.getPlanManNum());
|
|
|
- bigDecimal=bigDecimal.multiply(new BigDecimal(workTime));
|
|
|
- plan.setPlanWorkHour(bigDecimal.doubleValue());
|
|
|
- if(title.getJSONObject(0).getString("text").equals("所属工位")){
|
|
|
- if(control.equals("Contact")){
|
|
|
- JSONArray departments = value.getJSONArray("departments");
|
|
|
- String openapi_id = departments.getJSONObject(0).getString("openapi_id");
|
|
|
- Optional<Department> first1 = departmentList.stream().filter(d -> d.getCorpwxDeptid().equals(Integer.valueOf(openapi_id))).findFirst();
|
|
|
- if(first1.isPresent()){
|
|
|
- plan.setStationId(first1.get().getDepartmentId());
|
|
|
- plan.setStationName(first1.get().getDepartmentName());
|
|
|
- plan.setForemanId(first1.get().getManagerId());
|
|
|
- Optional<User> first2 = userList.stream().filter(u -> u.getId().equals(first1.get().getManagerId())).findFirst();
|
|
|
- if(first2.isPresent()){
|
|
|
- plan.setForemanName(first2.get().getName());
|
|
|
- }
|
|
|
- deptId=first1.get().getDepartmentId();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if(title.getJSONObject(0).getString("text").contains("单价")){
|
|
|
- if(control.equals("Number")){
|
|
|
- Double new_money = value.getDouble("new_number");
|
|
|
- plan.setMoneyOfJob(new BigDecimal(new_money));
|
|
|
- price=new BigDecimal(new_money);
|
|
|
- }
|
|
|
- }
|
|
|
- if(title.getJSONObject(0).getString("text").equals("备注")){
|
|
|
- if(control.equals("Text")||control.equals("Textarea")){
|
|
|
- String text = value.getString("text");
|
|
|
- plan.setDescribtion(text);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- planService.save(plan);
|
|
|
- List<Report> reportList=new ArrayList<>();
|
|
|
- //处理人员日报数据
|
|
|
- for (String userTeam : userTeams) {
|
|
|
- Optional<User> user = userList.stream().filter(u -> u.getCorpwxRealUserid() != null && u.getCorpwxRealUserid().equals(userTeam)).findFirst();
|
|
|
- if(user.isPresent()){
|
|
|
- Report report=new Report();
|
|
|
- report.setCreateDate(createDate);
|
|
|
- report.setCreatorId(user.get().getId());
|
|
|
- report.setCreateTime(LocalDateTime.now());
|
|
|
- BigDecimal bigDecimal = new BigDecimal(workTime);
|
|
|
- bigDecimal=bigDecimal.multiply(price);
|
|
|
- report.setCost(bigDecimal);
|
|
|
- report.setWorkingTime(workTime);
|
|
|
- report.setStatus(2);
|
|
|
- report.setPlanId(plan.getId());
|
|
|
- report.setCompanyId(7);
|
|
|
- report.setDeptId(deptId);
|
|
|
- reportList.add(report);
|
|
|
- }
|
|
|
- }
|
|
|
- if(reportList.size()>0){
|
|
|
- reportService.saveBatch(reportList);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * @Description:同步临时报工申请数据到车间管家
|
|
|
+ * @Param:
|
|
|
+ * @return:
|
|
|
+ * @Author: yurk
|
|
|
+ * @Date: 2024/6/20
|
|
|
+ */
|
|
|
+// @Scheduled(cron = "0 20 2 ? * *")
|
|
|
+// public void getTemporaryJobApplication() throws Exception {
|
|
|
+// if(isDev){
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+// LocalDate start=LocalDate.now().minusDays(1);
|
|
|
+// LocalDate end=LocalDate.now();
|
|
|
+// JSONArray jsonArrayFilter = new JSONArray();
|
|
|
+// JSONObject filter1 = new JSONObject();
|
|
|
+// WxCorpTemplate template = wxCorpTemplateService.getById(7);
|
|
|
+// filter1.put("key","template_id");
|
|
|
+// filter1.put("value",template.getTemplateId());
|
|
|
+// jsonArrayFilter.add(filter1);
|
|
|
+// JSONObject filter2 = new JSONObject();
|
|
|
+// filter2.put("key","sp_status");
|
|
|
+// filter2.put("value",2);
|
|
|
+// jsonArrayFilter.add(filter2);
|
|
|
+// List<String> approvalInfo = wxCorpInfoService.getApprovalInfo(7, df.format(start), df.format(end), "", jsonArrayFilter);
|
|
|
+// List<Department> departmentList = departmentService.list(new LambdaQueryWrapper<Department>().eq(Department::getCompanyId, 7));
|
|
|
+// List<TaskType> taskTypeList = taskTypeService.list(new LambdaQueryWrapper<TaskType>().eq(TaskType::getCompanyId, 7));
|
|
|
+// List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getCompanyId,7));
|
|
|
+// if(approvalInfo!=null){
|
|
|
+// for (int i = 0; i < approvalInfo.size(); i++) {
|
|
|
+// String codeNum = approvalInfo.get(i);
|
|
|
+// String approvalInfoDetailResp = wxCorpInfoService.getApprovalInfoDetail(7, codeNum);
|
|
|
+// JSONObject approvalInfoDetail = JSONObject.parseObject(approvalInfoDetailResp);
|
|
|
+// JSONObject info = approvalInfoDetail.getJSONObject("info");
|
|
|
+// JSONObject applyer = info.getJSONObject("applyer");
|
|
|
+// String userid = applyer.getString("userid");
|
|
|
+// Optional<User> first = userList.stream().filter(u ->u.getCorpwxRealUserid()!=null&&u.getCorpwxRealUserid().equals(userid)).findFirst();
|
|
|
+// if(!first.isPresent()){
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// JSONObject apply_data = info.getJSONObject("apply_data");
|
|
|
+// System.out.println("获取到的单据信息===========>"+apply_data);
|
|
|
+// JSONArray contents = apply_data.getJSONArray("contents");
|
|
|
+// //生成 车间插单计划
|
|
|
+// Plan plan=new Plan();
|
|
|
+// plan.setCompanyId(7);
|
|
|
+// plan.setCreateTime(LocalDateTime.now());
|
|
|
+// plan.setPlanType(1);
|
|
|
+// plan.setCreateId(first.get().getId());
|
|
|
+// //参与人员列表
|
|
|
+// List<String> userTeams=new ArrayList<>();
|
|
|
+// //初始化 单价(元/小时)
|
|
|
+// BigDecimal price=new BigDecimal(0);
|
|
|
+// //初始化 工作时长
|
|
|
+// double workTime=0;
|
|
|
+// //初始话 工作日期
|
|
|
+// JSONArray sp_record = info.getJSONArray("sp_record");
|
|
|
+// //获取最后一个审批节点
|
|
|
+// JSONObject last_sp_record = sp_record.getJSONObject(sp_record.size() - 1);
|
|
|
+// JSONArray details = last_sp_record.getJSONArray("details");
|
|
|
+// //获取最后详情
|
|
|
+// JSONObject lastDetail = details.getJSONObject(details.size() - 1);
|
|
|
+// long sptime = lastDetail.getLongValue("sptime");
|
|
|
+// LocalDate createDate=LocalDate.now();
|
|
|
+// //初始化工位
|
|
|
+// Integer deptId=0;
|
|
|
+// for (int i1 = 0; i1 < contents.size(); i1++) {
|
|
|
+// JSONObject map = contents.getJSONObject(i1);
|
|
|
+// JSONArray title = map.getJSONArray("title");
|
|
|
+// JSONObject value = map.getJSONObject("value");
|
|
|
+// String control = map.getString("control");
|
|
|
+// if(title.getJSONObject(0).getString("text").equals("临时报工分类")){
|
|
|
+// if(control.equals("Selector")){
|
|
|
+// JSONObject selector = value.getJSONObject("selector");
|
|
|
+// JSONArray options = selector.getJSONArray("options");
|
|
|
+// JSONObject object = options.getJSONObject(0);
|
|
|
+// JSONArray value1 = object.getJSONArray("value");
|
|
|
+// JSONObject jsonObject = value1.getJSONObject(0);
|
|
|
+// String text = jsonObject.getString("text");
|
|
|
+// Optional<TaskType> first1 = taskTypeList.stream().filter(t -> t.getTaskTypeName().equals(text)).findFirst();
|
|
|
+// if(first1.isPresent()){
|
|
|
+// plan.setTaskTypeId(first1.get().getId());
|
|
|
+// plan.setTaskTypeName(first1.get().getTaskTypeName());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if(title.getJSONObject(0).getString("text").equals("事由")){
|
|
|
+// if(control.equals("Text")||control.equals("Textarea")){
|
|
|
+// String text = value.getString("text");
|
|
|
+// plan.setTaskName(text);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //先处理多个人员 公用此单据非工时部分内容
|
|
|
+// if(title.getJSONObject(0).getString("text").equals("参与人员")){
|
|
|
+// if(control.equals("Contact")){
|
|
|
+// JSONArray members = value.getJSONArray("members");
|
|
|
+// for (int i2 = 0; i2 < members.size(); i2++) {
|
|
|
+// JSONObject jsonObject = members.getJSONObject(i2);
|
|
|
+// String userid1 = jsonObject.getString("userid");
|
|
|
+// userTeams.add(userid1);
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if(title.getJSONObject(0).getString("text").equals("参与人数")){
|
|
|
+// if(control.equals("Number")){
|
|
|
+// int new_number = value.getIntValue("new_number");
|
|
|
+// plan.setPlanManNum(new_number);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if(title.getJSONObject(0).getString("text").equals("开始时间")){
|
|
|
+// if(control.equals("Date")){
|
|
|
+// JSONObject date = value.getJSONObject("date");
|
|
|
+// long s_timestamp = date.getLongValue("s_timestamp");
|
|
|
+// LocalDate localDateFromUnix = DateTimeUtil.getLocalDateFromUnix(s_timestamp);
|
|
|
+// plan.setStartDate(localDateFromUnix);
|
|
|
+// if(sptime>0){
|
|
|
+// createDate= DateTimeUtil.getLocalDateFromUnix(sptime);
|
|
|
+// }else {
|
|
|
+// createDate=localDateFromUnix;
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if(title.getJSONObject(0).getString("text").equals("结束时间")){
|
|
|
+// if(control.equals("Date")){
|
|
|
+// JSONObject date = value.getJSONObject("date");
|
|
|
+// long s_timestamp = date.getLongValue("s_timestamp");
|
|
|
+// LocalDate localDateFromUnix = DateTimeUtil.getLocalDateFromUnix(s_timestamp);
|
|
|
+// plan.setEndDate(localDateFromUnix);
|
|
|
+// if(sptime>0){
|
|
|
+// createDate= DateTimeUtil.getLocalDateFromUnix(sptime);
|
|
|
+// }else {
|
|
|
+// createDate=localDateFromUnix;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if(title.getJSONObject(0).getString("text").equals("工作时长")){
|
|
|
+// if(control.equals("Number")){
|
|
|
+// double new_number = value.getDoubleValue("new_number");
|
|
|
+// workTime=new_number;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// BigDecimal bigDecimal = new BigDecimal(plan.getPlanManNum()==null?0:plan.getPlanManNum());
|
|
|
+// bigDecimal=bigDecimal.multiply(new BigDecimal(workTime));
|
|
|
+// plan.setPlanWorkHour(bigDecimal.doubleValue());
|
|
|
+// if(title.getJSONObject(0).getString("text").equals("所属工位")){
|
|
|
+// if(control.equals("Contact")){
|
|
|
+// JSONArray departments = value.getJSONArray("departments");
|
|
|
+// String openapi_id = departments.getJSONObject(0).getString("openapi_id");
|
|
|
+// Optional<Department> first1 = departmentList.stream().filter(d -> d.getCorpwxDeptid().equals(Integer.valueOf(openapi_id))).findFirst();
|
|
|
+// if(first1.isPresent()){
|
|
|
+// plan.setStationId(first1.get().getDepartmentId());
|
|
|
+// plan.setStationName(first1.get().getDepartmentName());
|
|
|
+// plan.setForemanId(first1.get().getManagerId());
|
|
|
+// Optional<User> first2 = userList.stream().filter(u -> u.getId().equals(first1.get().getManagerId())).findFirst();
|
|
|
+// if(first2.isPresent()){
|
|
|
+// plan.setForemanName(first2.get().getName());
|
|
|
+// }
|
|
|
+// deptId=first1.get().getDepartmentId();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if(title.getJSONObject(0).getString("text").contains("单价")){
|
|
|
+// if(control.equals("Number")){
|
|
|
+// Double new_money = value.getDouble("new_number");
|
|
|
+// plan.setMoneyOfJob(new BigDecimal(new_money));
|
|
|
+// price=new BigDecimal(new_money);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if(title.getJSONObject(0).getString("text").equals("备注")){
|
|
|
+// if(control.equals("Text")||control.equals("Textarea")){
|
|
|
+// String text = value.getString("text");
|
|
|
+// plan.setDescribtion(text);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// planService.save(plan);
|
|
|
+// List<Report> reportList=new ArrayList<>();
|
|
|
+// //处理人员日报数据
|
|
|
+// for (String userTeam : userTeams) {
|
|
|
+// Optional<User> user = userList.stream().filter(u -> u.getCorpwxRealUserid() != null && u.getCorpwxRealUserid().equals(userTeam)).findFirst();
|
|
|
+// if(user.isPresent()){
|
|
|
+// Report report=new Report();
|
|
|
+// report.setCreateDate(createDate);
|
|
|
+// report.setCreatorId(user.get().getId());
|
|
|
+// report.setCreateTime(LocalDateTime.now());
|
|
|
+// BigDecimal bigDecimal = new BigDecimal(workTime);
|
|
|
+// bigDecimal=bigDecimal.multiply(price);
|
|
|
+// report.setCost(bigDecimal);
|
|
|
+// report.setWorkingTime(workTime);
|
|
|
+// report.setStatus(2);
|
|
|
+// report.setPlanId(plan.getId());
|
|
|
+// report.setCompanyId(7);
|
|
|
+// report.setDeptId(deptId);
|
|
|
+// reportList.add(report);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if(reportList.size()>0){
|
|
|
+// reportService.saveBatch(reportList);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
}
|