|
@@ -108,6 +108,8 @@ public class TimingTask {
|
|
|
private PlanService planService;
|
|
|
@Resource
|
|
|
private ReportService reportService;
|
|
|
+ @Resource
|
|
|
+ private PlanExtraInfoService extraInfoService;
|
|
|
|
|
|
private static final List<Integer> VALID_TOKEN_CHARS = new ArrayList<>();
|
|
|
static {
|
|
@@ -645,6 +647,11 @@ public class TimingTask {
|
|
|
}
|
|
|
//初始化工位
|
|
|
Integer deptId=0;
|
|
|
+ long startTime=0;
|
|
|
+ long endTime=0;
|
|
|
+ String steelNumArray="";
|
|
|
+ String operationName="";
|
|
|
+ String partName="";
|
|
|
for (int i1 = 0; i1 < contents.size(); i1++) {
|
|
|
JSONObject map = contents.getJSONObject(i1);
|
|
|
JSONArray title = map.getJSONArray("title");
|
|
@@ -671,12 +678,36 @@ public class TimingTask {
|
|
|
plan.setProjectName(text);
|
|
|
}
|
|
|
}
|
|
|
+ if(title.getJSONObject(0).getString("text").contains("包名称")){
|
|
|
+ if(control.equals("Text")||control.equals("Textarea")){
|
|
|
+ String text = value.getString("text");
|
|
|
+ plan.setProductSchedulingNum(text);
|
|
|
+ }
|
|
|
+ }
|
|
|
if(title.getJSONObject(0).getString("text").equals("生产订单号")){
|
|
|
if(control.equals("Text")||control.equals("Textarea")){
|
|
|
String text = value.getString("text");
|
|
|
plan.setProductOrderNum(text);
|
|
|
}
|
|
|
}
|
|
|
+ if(title.getJSONObject(0).getString("text").equals("工序名称")){
|
|
|
+ if(control.equals("Text")||control.equals("Textarea")){
|
|
|
+ String text = value.getString("text");
|
|
|
+ operationName=text;//工序名称
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(title.getJSONObject(0).getString("text").equals("零件编码")){
|
|
|
+ if(control.equals("Text")||control.equals("Textarea")){
|
|
|
+ String text = value.getString("text");
|
|
|
+ steelNumArray=text;//零件编码
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(title.getJSONObject(0).getString("text").equals("零件名称")){
|
|
|
+ if(control.equals("Text")||control.equals("Textarea")){
|
|
|
+ String text = value.getString("text");
|
|
|
+ partName=text;//零件名称
|
|
|
+ }
|
|
|
+ }
|
|
|
if(title.getJSONObject(0).getString("text").equals("生产数量")){
|
|
|
if(control.equals("Number")){
|
|
|
int new_number= value.get("new_number")!=null?value.getIntValue("new_number"):0;
|
|
@@ -737,8 +768,7 @@ public class TimingTask {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- long startTime=0;
|
|
|
- long endTime=0;
|
|
|
+
|
|
|
if(title.getJSONObject(0).getString("text").equals("作业开始日期")){
|
|
|
if(control.equals("Date")){
|
|
|
JSONObject date = value.getJSONObject("date");
|
|
@@ -750,19 +780,41 @@ public class TimingTask {
|
|
|
}
|
|
|
if(title.getJSONObject(0).getString("text").equals("作业结束日期")){
|
|
|
if(control.equals("Date")){
|
|
|
+ long s_timestamp=0;
|
|
|
JSONObject date = value.getJSONObject("date");
|
|
|
- long s_timestamp = date.getLongValue("s_timestamp");
|
|
|
+ if (!StringUtils.isEmpty(date.getString("s_timestamp"))){
|
|
|
+ s_timestamp= date.getLongValue("s_timestamp");
|
|
|
+ LocalDate localDateFromUnix = DateTimeUtil.getLocalDateFromUnix(s_timestamp);
|
|
|
+ plan.setEndDate(localDateFromUnix);
|
|
|
+ }
|
|
|
if (s_timestamp!=0){
|
|
|
endTime=s_timestamp;
|
|
|
}
|
|
|
- LocalDate localDateFromUnix = DateTimeUtil.getLocalDateFromUnix(s_timestamp);
|
|
|
- plan.setEndDate(localDateFromUnix);
|
|
|
}
|
|
|
}
|
|
|
if (endTime>0){
|
|
|
long l = endTime - startTime;//工作时长
|
|
|
- workTime=l/60000.0;
|
|
|
- plan.setPlanWorkHour(workTime);//分钟
|
|
|
+ workTime=l/3600.0;
|
|
|
+ plan.setPlanWorkHour(workTime);//小时
|
|
|
+
|
|
|
+ startTime=0;
|
|
|
+ endTime=0;
|
|
|
+ }
|
|
|
+ if(title.getJSONObject(0).getString("text").equals("所属工位长")){
|
|
|
+ if(control.equals("Contact")){
|
|
|
+ JSONArray members = value.getJSONArray("members");
|
|
|
+ String userid2 = members.getJSONObject(0).getString("userid");
|
|
|
+ User user = userMapper.selectOne(new QueryWrapper<User>().eq("corpwx_real_userid", userid2));
|
|
|
+ Department department = departmentService.getById(user.getDepartmentId());
|
|
|
+ if (user != null) {
|
|
|
+ plan.setForemanId(user.getId());
|
|
|
+ plan.setForemanName(user.getName());
|
|
|
+ if (department != null) {
|
|
|
+ plan.setStationId(department.getDepartmentId());
|
|
|
+ plan.setStationName(department.getDepartmentName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
if(title.getJSONObject(0).getString("text").equals("备注")){
|
|
|
if(control.equals("Text")||control.equals("Textarea")){
|
|
@@ -773,6 +825,8 @@ public class TimingTask {
|
|
|
}
|
|
|
planService.save(plan);
|
|
|
List<Report> reportList=new ArrayList<>();
|
|
|
+ List<PlanExtraInfo> planExtraInfoList=new ArrayList<>();
|
|
|
+
|
|
|
//处理人员日报数据
|
|
|
for (String userTeam : userTeams) {
|
|
|
Optional<User> user = userList.stream().filter(u -> u.getCorpwxRealUserid() != null && u.getCorpwxRealUserid().equals(userTeam)).findFirst();
|
|
@@ -782,19 +836,29 @@ public class TimingTask {
|
|
|
report.setCreatorId(user.get().getId());
|
|
|
report.setCreateTime(LocalDateTime.now());
|
|
|
BigDecimal bigDecimal = new BigDecimal(workTime);
|
|
|
- bigDecimal=bigDecimal.divide(new BigDecimal(plan.getPlanManNum()==null?0:plan.getPlanManNum()),1,RoundingMode.HALF_UP);
|
|
|
report.setWorkingTime(bigDecimal.doubleValue());
|
|
|
- bigDecimal=bigDecimal.multiply(price);
|
|
|
- report.setCost(bigDecimal);
|
|
|
+ report.setCost(plan.getSettlementAmount().divide(BigDecimal.valueOf(userTeams.size())).setScale(2, RoundingMode.HALF_UP));
|
|
|
report.setStatus(2);
|
|
|
report.setPlanId(plan.getId());
|
|
|
report.setCompanyId(7);
|
|
|
- report.setDeptId(deptId);
|
|
|
+ report.setDeptId(user.get().getDepartmentId());
|
|
|
+ report.setSteelNumArray(steelNumArray);
|
|
|
reportList.add(report);
|
|
|
}
|
|
|
}
|
|
|
if(reportList.size()>0){
|
|
|
reportService.saveBatch(reportList);
|
|
|
+ for (Report report : reportList) {
|
|
|
+ PlanExtraInfo planExtraInfo = new PlanExtraInfo();
|
|
|
+ planExtraInfo.setPlanId(plan.getId());
|
|
|
+ planExtraInfo.setReportId(report.getId());
|
|
|
+ planExtraInfo.setOperationName(operationName);
|
|
|
+ planExtraInfo.setPartName(partName);
|
|
|
+ planExtraInfoList.add(planExtraInfo);
|
|
|
+ }
|
|
|
+ if(planExtraInfoList.size()>0){
|
|
|
+ extraInfoService.saveBatch(planExtraInfoList);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|