| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.aspose.cad.internal.I.S; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.example.erp.common.AsyncQueryExecutor; |
| | | import com.example.erp.common.Constants; |
| | | import com.example.erp.common.Result; |
| | | import com.example.erp.dto.pp.OrderNumberTransferDTO; |
| | | import com.example.erp.dto.sd.OrderProcessSortDTO; |
| | | import com.example.erp.entity.pp.*; |
| | | import com.example.erp.entity.sd.*; |
| | | import com.example.erp.entity.sd.BasicData; |
| | | import com.example.erp.entity.sd.Order; |
| | | import com.example.erp.entity.sd.OrderDetail; |
| | | import com.example.erp.entity.sd.OrderProcessDetail; |
| | | import com.example.erp.entity.userInfo.Log; |
| | | import com.example.erp.entity.userInfo.SysError; |
| | | import com.example.erp.exception.ServiceException; |
| | | import com.example.erp.mapper.mm.FinishedOperateLogMapper; |
| | | import com.example.erp.mapper.pp.*; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.example.erp.mapper.sd.*; |
| | | import com.example.erp.mapper.userInfo.LogMapper; |
| | | import com.example.erp.service.mm.FinishedGoodsInventoryService; |
| | | import com.example.erp.service.sd.OrderProcessDetailService; |
| | | import com.example.erp.service.userInfo.LogService; |
| | | import com.example.erp.service.userInfo.SysErrorService; |
| | | import com.example.erp.tools.JacksonUtil; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.core.type.TypeReference; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpMethod; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | |
| | | import javax.annotation.PreDestroy; |
| | | import javax.annotation.Resource; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.concurrent.CompletableFuture; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | @Service |
| | | @DS("pp") |
| | |
| | | private final ReportingWorkDetailMapper reportingWorkDetailMapper; |
| | | private final OrderMapper orderMapper; |
| | | private final OrderDetailMapper orderDetailMapper; |
| | | |
| | | private final FlowCardMapper flowCardMapper; |
| | | |
| | | private final OrderProcessDetailService orderProcessDetailService; |
| | | |
| | | private final LogService logService; |
| | | |
| | | private final LogMapper logMapper; |
| | | private final OrderGlassDetailMapper orderGlassDetailMapper; |
| | | private final SysErrorService sysErrorService; |
| | |
| | | private final ReworkMapper reworkMapper; |
| | | private final BasicDataMapper basicDataMapper; |
| | | private final FinishedGoodsInventoryService finishedGoodsInventoryService; |
| | | private final StringRedisTemplate stringRedisTemplate; |
| | | |
| | | @Resource |
| | | private AsyncQueryExecutor asyncExecutor; |
| | |
| | | List<ReportingWork> ReportingWorks = reportingWorkMapper.selectJoinList(ReportingWork.class, |
| | | new MPJLambdaWrapper<ReportingWork>() |
| | | .select(ReportingWork::getReportingWorkId) |
| | | .leftJoin(ReportingWorkDetail.class, ReportingWorkDetail::getReportingWorkId, ReportingWork::getReportingWorkId) |
| | | .leftJoin(ReportingWorkDetail.class, |
| | | ReportingWorkDetail::getReportingWorkId, |
| | | ReportingWork::getReportingWorkId) |
| | | .eq(ReportingWork::getProcessId,reportingWork.getProcessId()) |
| | | .eq(ReportingWork::getThisProcess,reportingWork.getThisProcess()) |
| | | .eq(ReportingWork::getDeviceName,reportingWork.getDeviceName()) |
| | |
| | | //将异常传入数据库 |
| | | SysError sysError = new SysError(); |
| | | sysError.setError(e +Arrays.toString(e.getStackTrace())); |
| | | sysError.setFunc("汉玻mes报工"); |
| | | sysError.setFunc("mes报工"); |
| | | sysErrorService.insert(sysError); |
| | | throw new ServiceException(Constants.Code_500, "数据请求异常,请检查"); |
| | | |
| | |
| | | map.put("breakageReason", reportingWorkMapper.selectBasicNameByType("breakagereason")); |
| | | return map; |
| | | } |
| | | |
| | | |
| | | //@Transactional(rollbackFor = Exception.class , noRollbackFor = ServiceException.class) |
| | | public Result mesReportingWorkSv1(Map<String, Object> reportingWorkMap) throws JsonProcessingException { |
| | | |
| | | //设置回滚点 |
| | | //Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | //接收解析主附表信息 |
| | | String titleJson = JacksonUtil.writeValueAsString(reportingWorkMap.get("title")); |
| | | String detailJson = JacksonUtil.writeValueAsString(reportingWorkMap.get("detail")); |
| | | ReportingWork reportingWork = JacksonUtil.readValue(titleJson, ReportingWork.class); |
| | | ReportingWorkDetail reportingWorkDetail = JacksonUtil.readValue(detailJson, ReportingWorkDetail.class); |
| | | String Base_KEY = reportingWork.getProcessId()+":"+reportingWork.getThisProcess()+":"+reportingWork.getDeviceName(); |
| | | String reportingWork_KEY = Base_KEY+":title"; |
| | | String reportingWorkDetail_KEY = Base_KEY+":detail:"+reportingWorkDetail.getOrderNumber()+":"+reportingWorkDetail.getTechnologyNumber(); |
| | | |
| | | String process_KEY = reportingWork.getProcessId()+":process:"+reportingWorkDetail.getOrderNumber()+":"+reportingWorkDetail.getTechnologyNumber(); |
| | | |
| | | //判断工序是否存在redis中 |
| | | if(!Boolean.TRUE.equals(stringRedisTemplate.hasKey(process_KEY+":"+reportingWork.getThisProcess()))){ |
| | | List<OrderProcessSortDTO> orderProcessSortDTOList = orderProcessDetailMapper.selectProcessSort( |
| | | reportingWork.getOrderId(), |
| | | reportingWork.getProcessId(), |
| | | reportingWorkDetail.getOrderNumber(), |
| | | reportingWorkDetail.getTechnologyNumber() |
| | | ); |
| | | if (orderProcessSortDTOList.isEmpty()){ |
| | | throw new ServiceException(Constants.Code_600, "未检测到流程卡信息,请检查"); |
| | | } |
| | | |
| | | orderProcessSortDTOList.forEach(orderProcessSortDTO -> { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("sort",orderProcessSortDTO.getSort()); |
| | | map.put("recombination",orderProcessSortDTO.getRecombination()); |
| | | stringRedisTemplate.opsForHash().putAll(process_KEY+":"+orderProcessSortDTO.getProcess(), map); |
| | | }); |
| | | } |
| | | String recombination = (String) stringRedisTemplate.opsForHash().get(process_KEY+":"+reportingWork.getThisProcess(),"recombination"); |
| | | |
| | | if (!recombination.isEmpty()){ |
| | | throw new ServiceException(Constants.Code_600, "复合工序请到ERP中进行报工"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //判断是否redis此报工编号key是否存在 |
| | | if(Boolean.TRUE.equals(stringRedisTemplate.hasKey(reportingWork_KEY))){ |
| | | stringRedisTemplate.opsForHash().increment( |
| | | reportingWork_KEY, |
| | | "thisCompletedQuantity", |
| | | reportingWork.getThisCompletedQuantity() |
| | | ); |
| | | } |
| | | else{ |
| | | stringRedisTemplate.opsForHash().putAll( |
| | | reportingWork_KEY, |
| | | JacksonUtil.readValueObjectToString(reportingWork,new TypeReference<Map<String, String>>() {}) |
| | | ); |
| | | } |
| | | //判断是否redis此报工明细中key是否存在 |
| | | if(Boolean.TRUE.equals(stringRedisTemplate.hasKey(reportingWorkDetail_KEY))){ |
| | | stringRedisTemplate.opsForHash().increment( |
| | | reportingWorkDetail_KEY, |
| | | "completedQuantity", |
| | | reportingWorkDetail.getCompletedQuantity() |
| | | ); |
| | | }else { |
| | | stringRedisTemplate.opsForHash().putAll( |
| | | reportingWorkDetail_KEY, |
| | | JacksonUtil.readValueObjectToString(reportingWorkDetail,new TypeReference<Map<String, String>>() {}) |
| | | ); |
| | | } |
| | | return Result.success("提交成功"); |
| | | } |
| | | } |