| | |
| | | package com.whyc.service; |
| | | |
| | | import com.whyc.constant.EnumWorksheetType; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.WorksheetLinkMapper; |
| | | 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.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.logging.SimpleFormatter; |
| | | |
| | | /** |
| | | * @author perryhsu |
| | | * @date 2022/12/17 22:18 |
| | | */ |
| | | @Service |
| | | public class WorksheetMainService { |
| | | @Resource |
| | | private WorksheetMainMapper mainMapper; |
| | | @Resource |
| | | private WorksheetLinkMapper linkMapper; |
| | | |
| | | /** |
| | | * 获取工单号 |
| | | * WS-210907-00009 |
| | | * @return |
| | | */ |
| | | public String getSheetId(){ |
| | | String datetime = new SimpleDateFormat("yyMMdd").format(new Date()); |
| | | String sheetId = mainMapper.getSheetId(); |
| | | if(sheetId==null || "".equals(sheetId)) { |
| | | sheetId = "WS-" + datetime + "-0001"; |
| | | }else{ |
| | | sheetId = "WS-" + datetime +"-"+ String.format("%04d",Integer.parseInt(sheetId.substring(sheetId.length()-4))+1); |
| | | } |
| | | return sheetId; |
| | | } |
| | | @Resource |
| | | private WorksheetMainMapper mapper; |
| | | |
| | | public Response add(WorksheetMain main){ |
| | | main.setCreateTime(new Date()); |
| | | main.setStatus(0); |
| | | String sheetId = getSheetId(); |
| | | main.setSheetId(sheetId); |
| | | mainMapper.insert(main); |
| | | //T0处理 |
| | | @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.setSheetId(sheetId); |
| | | link.setProcessLevel("T0"); |
| | | link.setProcessLevelName("工单派发"); |
| | | link.setDealUserId(main.getDealUserId()); |
| | | link.setDealUser(main.getDealUser()); |
| | | link.setLinkStatus(5); |
| | | link.setDealType(0); |
| | | link.setDealDesc("派单给T1"); |
| | | linkMapper.insert(link); |
| | | //T1处理 |
| | | WorksheetLink link1 = new WorksheetLink(); |
| | | link1.setParentId(link.getId()); |
| | | link1.setSheetId(sheetId); |
| | | link1.setMainId(main.getId()); |
| | | link1.setProcessLevel("T1"); |
| | | link1.setProcessLevelName("T1处理"); |
| | | link1.setDealUserId(main.getDealUserId()); |
| | | link1.setDealUser(main.getDealUser()); |
| | | link1.setDealRoleId(main.getDealRoleId()); |
| | | link1.setDealRole(main.getDealRole()); |
| | | link1.setLinkStatus(0); |
| | | link1.setDealAndClose(1); |
| | | linkMapper.insert(link1); |
| | | return new Response().setII(1,"添加成功"); |
| | | 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,"提交完成"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |