Merge remote-tracking branch 'origin/master'

master
赵嘉伟 4 years ago
commit f30b98a362

@ -14,6 +14,8 @@ public class CustomFieldConstant {
*/
public static final String RESRCE_CUSTOM_FIELD_PROCESS_CONTROL = "PROCESS_CONTROL";//工控程序
public static final String RESRCE_CUSTOM_FIELD_PRINT_NAME = "PRINT_NAME";//打印机名称
/**
*
*/

@ -25,6 +25,17 @@ public class ProdReadyTaskController {
@Autowired
public ProdReadyTaskService prodReadyTaskService;
/**
*
*
* @return
*/
@ResponseBody
@GetMapping("/doPrint")
public R doPrint(ProdReadyTask prodReadyTask){
prodReadyTaskService.doPrint(prodReadyTask);
return R.ok();
}
/**
*
*

@ -37,4 +37,6 @@ public interface ProdReadyTaskService extends IService<ProdReadyTask> {
List<Map<String, Object>> getInspectionDetailList(Map<String, String> param);
boolean saveResult(ProdReadyTask prodReadyTask);
void doPrint(ProdReadyTask prodReadyTask);
}

@ -1,5 +1,8 @@
package com.foreverwin.mesnac.common.service.impl;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@ -7,34 +10,41 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.mesnac.common.constant.Constants;
import com.foreverwin.mesnac.common.constant.CustomFieldConstant;
import com.foreverwin.mesnac.common.dto.LabelPrintDto;
import com.foreverwin.mesnac.common.dto.SfcDispatchDto;
import com.foreverwin.mesnac.common.enums.DispatchStatusEnum;
import com.foreverwin.mesnac.common.enums.HandleEnum;
import com.foreverwin.mesnac.common.mapper.ProdReadyTaskMapper;
import com.foreverwin.mesnac.common.model.PrintLog;
import com.foreverwin.mesnac.common.model.ProdReadyTask;
import com.foreverwin.mesnac.common.model.ProdReadyTaskDetail;
import com.foreverwin.mesnac.common.service.PrintLogService;
import com.foreverwin.mesnac.common.service.ProdReadyTaskDetailService;
import com.foreverwin.mesnac.common.service.ProdReadyTaskService;
import com.foreverwin.mesnac.common.service.SfcDispatchCommonService;
import com.foreverwin.mesnac.common.util.StringUtil;
import com.foreverwin.mesnac.meapi.dto.BomComponentDto;
import com.foreverwin.mesnac.meapi.model.Item;
import com.foreverwin.mesnac.meapi.model.Sfc;
import com.foreverwin.mesnac.meapi.model.ShopOrder;
import com.foreverwin.mesnac.meapi.model.WorkCenter;
import com.foreverwin.mesnac.meapi.service.BomComponentService;
import com.foreverwin.mesnac.meapi.service.CustomFieldsService;
import com.foreverwin.mesnac.meapi.service.ShopOrderService;
import com.foreverwin.mesnac.meapi.service.WorkCenterService;
import com.foreverwin.mesnac.meapi.service.*;
import com.foreverwin.modular.core.exception.BaseException;
import com.foreverwin.modular.core.exception.BusinessException;
import com.foreverwin.modular.core.util.CommonMethods;
import com.foreverwin.modular.core.util.FrontPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* <p>
@ -56,11 +66,15 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl<ProdReadyTaskMapper, P
public static final String STATUS_FINISH = "FINISH";
public static final String STATUS_CANCEL = "CANCEL";
@Value("${print.server}")
private String printServer;
@Autowired
private ProdReadyTaskMapper prodReadyTaskMapper;
@Autowired
private ProdReadyTaskDetailService prodReadyTaskDetailService;
@Autowired
private SfcDispatchCommonService sfcDispatchCommonService;
@Autowired
private BomComponentService bomComponentService;
@Autowired
private CustomFieldsService customFieldsService;
@ -68,6 +82,12 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl<ProdReadyTaskMapper, P
private ShopOrderService shopOrderService;
@Autowired
private WorkCenterService workCenterService;
@Autowired
private PrintLogService printLogService;
@Autowired
private ItemService itemService;
@Autowired
private SfcService sfcService;
@Override
public IPage<ProdReadyTask> selectPage(FrontPage<ProdReadyTask> frontPage, ProdReadyTask prodReadyTask) {
@ -289,5 +309,102 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl<ProdReadyTaskMapper, P
return update;
}
@Override
public void doPrint(ProdReadyTask prodReadyTask) {
String site = CommonMethods.getSite();
String user = CommonMethods.getUser();
String dispatchNo = prodReadyTask.getDispatchNo();
SfcDispatchDto sfcDispatchDto=new SfcDispatchDto();
sfcDispatchDto.setHandle(HandleEnum.SFC_DISPATCH.getHandle(site,dispatchNo));
sfcDispatchDto = sfcDispatchCommonService.findSfcDispatchBySfc(sfcDispatchDto);
List<PrintLog> printList=new ArrayList<>();
List<LabelPrintDto> labelPrintDtoList = new ArrayList<>();
String printData = null;
PrintLog printTag=new PrintLog();
String resrce = sfcDispatchDto.getResrce();
String printName = customFieldsService.getCustomFieldsValue(HandleEnum.RESOURCE.getHandle(site, resrce), CustomFieldConstant.RESRCE_CUSTOM_FIELD_PRINT_NAME);
if (StringUtil.isBlank(printName)){
throw new BaseException("资源维护的打印机不能为空");
}
String item = prodReadyTask.getItem();
Item selectCurrent = itemService.selectCurrent(site, item);
QueryWrapper<PrintLog> queryWrapper=new QueryWrapper();
queryWrapper.eq(PrintLog.SFC,prodReadyTask.getSfc());
queryWrapper.eq(PrintLog.STEP_ID,prodReadyTask.getStepId());
queryWrapper.eq(PrintLog.RESRCE,prodReadyTask.getResrce());
queryWrapper.eq(PrintLog.CATEGORY,Constants.PRINT_TYPE_SFC);
queryWrapper.eq(PrintLog.CATEGORY,Constants.PRINT_TYPE_SFC);
List<PrintLog> printLogList = printLogService.list(queryWrapper);
if (printLogList.isEmpty()){
//打印参数
LabelPrintDto labelPrintDto = new LabelPrintDto();
labelPrintDto.setPrinter(printName);
labelPrintDto.setPrintTemplate(Constants.PRINT_TYPE_SFC);
labelPrintDto.setItem(sfcDispatchDto.getItem());
labelPrintDto.setItemDescription(selectCurrent.getDescription());
labelPrintDto.setSfc(prodReadyTask.getSfc());
Sfc sfcServiceById = sfcService.getById(HandleEnum.SFC.getHandle(site, prodReadyTask.getSfc()));
String drawingRevision = customFieldsService.getCustomFieldsValue(sfcServiceById.getItemBo(), CustomFieldConstant.ITEM_DRAWING_REVISION);
labelPrintDto.setDrawingVersion(drawingRevision);
labelPrintDto.setQty(new BigDecimal(sfcServiceById.getQty()));
String workOrder = customFieldsService.getCustomFieldsValue(sfcServiceById.getShopOrderBo(), "WORK_ORDER");
labelPrintDto.setWorkOrder(workOrder);
labelPrintDto.setBlankingSize(sfcDispatchDto.getBlankingSize());
labelPrintDto.setOperation(sfcDispatchDto.getOperation());
labelPrintDtoList.add(labelPrintDto);
printData = JSON.toJSONString(labelPrintDtoList);
List<PrintLog> list = printLogService.list();
//打印记录
printTag.setHandle(UUID.randomUUID().toString());
printTag.setPrintName(printName);
printTag.setPrintTemplate(Constants.PRINT_TYPE_SFC);
printTag.setSite(site);
printTag.setCategory(Constants.PRINT_TYPE_SFC);
printTag.setPrintParam(JSON.toJSONString(labelPrintDtoList));
printTag.setSfc(prodReadyTask.getSfc());
printTag.setResrce(prodReadyTask.getResrce());
printTag.setStepId(prodReadyTask.getStepId());
printTag.setOperation(prodReadyTask.getOperation());
printTag.setItemBo(selectCurrent.getHandle());
printTag.setIsPrint("false");
printTag.setPrintNum(0);
printTag.setItem(item);
printTag.setItemDescription(selectCurrent.getDescription());
printList.add(printTag);
printLogService.savePrintLog(site,user,printTag);
}else {
printData = printLogList.get(0).getPrintParam();
}
String post = HttpUtil.post(printServer,printData , 30000);
/**
* {"msg":"打印成功","code":0}
* {"msg":"打印失败","code":500}
* -printNameisPrint
*/
JSONObject jsonObject = JSONObject.parseObject(post);
String code = jsonObject.getString("code");
if (code == null){
}
if (post.indexOf("500") != -1){
throw BusinessException.build("打印失败!");
}
if (printLogList.isEmpty()){
printTag.setIsPrint("true");
printTag.setPrintNum(1);
printLogService.updateById(printTag);
}else {
PrintLog printLog = printLogList.get(0);
printTag.setIsPrint("true");
printTag.setPrintNum(printLog.getPrintNum()+1);
printTag.setModifiedDateTime(LocalDateTime.now());
printTag.setModifyUser(user);
printLogService.updateById(printLog);
}
}
}

@ -37,4 +37,9 @@ print:
activeMq:
sendWeChatMessage: tcp://localhost:61616?wireFormat.maxInactivityDuration=0
queue: send.weChat.notice
queue: send.weChat.notice
exportDocument:
filePath: /Users/zhaojiawei/Desktop/青岛项目后台/mesnac5.biz/production/src/main/resources/
outputPath: /Users/zhaojiawei/Desktop/
template: scrap.ftl

@ -71,7 +71,7 @@ public class ResrceServiceImpl extends ServiceImpl<ResrceMapper, Resrce> impleme
@Override
public void updateResourceStatus(String site, String resource, String status) {
String statusBo = "StatusBo:" + site + "," + status;
String statusBo = "StatusBO:" + site + "," + status;
String resourceBo = "ResourceBO:" + site + "," + resource;
Resrce resrce = new Resrce();

@ -241,8 +241,7 @@ public class PodTemplateServiceImpl implements PodTemplateService {
if (StringUtil.isBlank(resrce)) {
throw new BaseException("资源不能为空");
}
sfcDtoList.forEach(sfcDto -> {
for (SfcDto sfcDto:sfcDtoList){
String site = CommonMethods.getSite();
String operation = sfcDto.getOperation();
Operation currentRevisionRef = operationService.getCurrentRevisionRef(site, operation);
@ -277,9 +276,6 @@ public class PodTemplateServiceImpl implements PodTemplateService {
//物料消耗
materialConsumption(site, operation, HandleEnum.SFC.getHandle(site, sfc), stepId, resrce);
try {
sfcCrossService.completeAction(site, currentRevisionRef.getHandle(), resrce, sfcServiceById.getHandle(), qty);
//更改派工单状态
sfcDispatchCommonService.updateSfcDispatchStatus(site, CommonMethods.getUser(), dispatchNo, DispatchStatusEnum.COMPLETE.getCode());
//专检创建
Map<String, Object> paramMap=new HashMap<>();
paramMap.put("SFC",sfc);
@ -302,12 +298,15 @@ public class PodTemplateServiceImpl implements PodTemplateService {
paramMap.put("CATEGORY",Constants.INSPECTION_TYPE_S);
inspectionTaskService.createTask(paramMap);
}
sfcCrossService.completeAction(site, currentRevisionRef.getHandle(), resrce, sfcServiceById.getHandle(), qty);
//更改派工单状态
sfcDispatchCommonService.updateSfcDispatchStatus(site, CommonMethods.getUser(), dispatchNo, DispatchStatusEnum.COMPLETE.getCode());
//报工
sendErp(sfc, stepId, qty,BigDecimal.ZERO);
//sendErp(sfc, stepId, qty,BigDecimal.ZERO);
} catch (Exception e) {
ExceptionUtil.throwException(e);
}
});
}
}
public void materialConsumption(String site, String operation, String sfcBo, String stepId, String resource) {
@ -400,7 +399,7 @@ public class PodTemplateServiceImpl implements PodTemplateService {
}
@Override
public void sendErp(String sfc, String stepId, BigDecimal qty ,BigDecimal scrapQty) {
public void sendErp(String sfc, String stepId, BigDecimal qty, BigDecimal scrapQty) {
Sfc sfcServiceById = sfcService.getById(HandleEnum.SFC.getHandle(CommonMethods.getSite(),sfc));
String shopOrderBo = sfcServiceById.getShopOrderBo();
String shopOrder = StringUtil.trimHandle(shopOrderBo);

@ -26,11 +26,12 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
/**
@ -129,7 +130,9 @@ public class SelfReportServiceImpl extends ServiceImpl<SelfReportMapper, SelfRep
stringBuilder.append(",");
}
}
String taskNo = UUID.randomUUID().toString();
Date date = new Date(System.currentTimeMillis());
SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyyMMddHHmmss");
String taskNo = "SR_" + dateFormat1.format(date);
String handle = HandleEnum.SELF_REPORT.getHandle(site, taskNo);
SelfReport selfReport = new SelfReport();
selfReport.setDescription("自报");

Loading…
Cancel
Save