package com.whyc.service;
|
|
import com.whyc.constant.EnumWorksheetType;
|
import com.whyc.dto.Response;
|
import com.whyc.mapper.WorksheetMainMapper;
|
import com.whyc.pojo.UserInf;
|
import com.whyc.pojo.WorksheetAlarm;
|
import com.whyc.pojo.WorksheetLink;
|
import com.whyc.pojo.WorksheetMain;
|
import com.whyc.util.DateUtil;
|
import com.whyc.util.ThreadLocalUtil;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import javax.annotation.Resource;
|
import java.util.Date;
|
|
/**
|
* @author perryhsu
|
* @date 2022/12/17 22:18
|
*/
|
@Service
|
public class WorksheetMainService {
|
|
@Resource
|
private WorksheetMainMapper mapper;
|
|
@Autowired
|
private WorksheetLinkService linkService;
|
|
@Autowired
|
private WorksheetAlarmService alarmService;
|
|
@Transactional
|
public Response alarmFlowSubmit(WorksheetMain main, UserInf user) {
|
WorksheetAlarm worksheetAlarm = main.getWorksheetAlarm();
|
//存入主表信息,子表信息,附表告警信息
|
Date date = new Date();
|
//String formatDate = DateUtil.YYYY_MM_DD_HH_MM_SS_UNION.format(date);
|
String formatDate = ThreadLocalUtil.format(date,7);
|
main.setTitle("告警派工单-"+user.getUName()+"-"+formatDate);
|
main.setCreateUserId(user.getUId());
|
main.setBeginTime(date);
|
main.setStatus(1);
|
main.setType(EnumWorksheetType.ProductBom.getType());
|
mapper.insert(main);
|
//子表
|
Long nextUser = main.getNextUser();
|
WorksheetLink link = new WorksheetLink();
|
link.setMainId(main.getId());
|
link.setParentId(0);
|
link.setDealUserId(nextUser);
|
link.setDealDesc(main.getDescription());
|
link.setLinkStatus(0);
|
link.setCreateTime(date);
|
linkService.add(link);
|
//附表告警表
|
worksheetAlarm.setMainId(main.getId());
|
worksheetAlarm.setCreateTime(date);
|
alarmService.insert(worksheetAlarm);
|
|
return new Response().setII(1,"提交完成");
|
}
|
}
|