|
@@ -9,6 +9,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
import cn.ezhizao.common.utils.poi.ExcelUtil;
|
|
import cn.ezhizao.common.utils.poi.ExcelUtil;
|
|
import cn.ezhizao.framework.aspectj.lang.annotation.Log;
|
|
import cn.ezhizao.framework.aspectj.lang.annotation.Log;
|
|
import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
|
|
import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
|
|
|
|
+import cn.ezhizao.framework.redis.RedisCache;
|
|
import cn.ezhizao.framework.web.controller.BaseController;
|
|
import cn.ezhizao.framework.web.controller.BaseController;
|
|
import cn.ezhizao.framework.web.domain.AjaxResult;
|
|
import cn.ezhizao.framework.web.domain.AjaxResult;
|
|
import cn.ezhizao.framework.web.page.TableDataInfo;
|
|
import cn.ezhizao.framework.web.page.TableDataInfo;
|
|
@@ -24,6 +25,7 @@ import cn.ezhizao.project.business.technologicalProcessDetail.domain.BizTechnolo
|
|
import cn.ezhizao.project.business.technologicalProcessDetail.service.IBizTechnologicalProcessDetailService;
|
|
import cn.ezhizao.project.business.technologicalProcessDetail.service.IBizTechnologicalProcessDetailService;
|
|
import cn.ezhizao.project.system.domain.SysUser;
|
|
import cn.ezhizao.project.system.domain.SysUser;
|
|
import cn.ezhizao.project.system.service.ISysUserService;
|
|
import cn.ezhizao.project.system.service.ISysUserService;
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -90,6 +92,10 @@ public class BizProcessInspecionController extends BaseController {
|
|
private IBizOutsourcedOrderDetailService bizOutsourcedOrderDetailService;
|
|
private IBizOutsourcedOrderDetailService bizOutsourcedOrderDetailService;
|
|
@Resource
|
|
@Resource
|
|
private IBizOutsourcedOrderDetailProcessService bizOutsourcedOrderDetailProcessService;
|
|
private IBizOutsourcedOrderDetailProcessService bizOutsourcedOrderDetailProcessService;
|
|
|
|
+ @Resource
|
|
|
|
+ private RedisCache redisCache;
|
|
|
|
+
|
|
|
|
+ final private String processInspectionNoKey = "processInspectionCode";
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询序检主列表
|
|
* 查询序检主列表
|
|
@@ -460,6 +466,177 @@ public class BizProcessInspecionController extends BaseController {
|
|
return items.stream().noneMatch(v -> v.getCreateTime().compareTo(bizDayworkItem.getCreateTime()) > 0 && v.getStatus().compareTo("0") >= 0 && v.getStatus().compareTo("3") <= 0);
|
|
return items.stream().noneMatch(v -> v.getCreateTime().compareTo(bizDayworkItem.getCreateTime()) > 0 && v.getStatus().compareTo("0") >= 0 && v.getStatus().compareTo("3") <= 0);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Transactional
|
|
|
|
+// @PostMapping("/saveOutsourcedInspecion")
|
|
|
|
+ public AjaxResult saveOutsourcedInspectionV3(@RequestBody BizProcessInspecion processInspecion) throws NoSuchFieldException, IllegalAccessException {
|
|
|
|
+// // 判断是否已有未确认外协检查
|
|
|
|
+// if (bizProcessInspecionService.query().eq("outsource_order_detail_id", processInspecion.getOutsourceOrderDetailId()).eq("status", 0).count() > 0) {
|
|
|
|
+// return error("已有未完成外协检查单。");
|
|
|
|
+// }
|
|
|
|
+ //根据lot信息保存序检表
|
|
|
|
+ BizDaywork daywork = bizDayworkService.query().eq("lot_code", processInspecion.getLot().getLotCode()).one();
|
|
|
|
+ BizProduct product = bizProductService.getById(processInspecion.getLot().getProductId());
|
|
|
|
+ SysUser technicianUser = sysUserService.selectUserById(product.getTechnicianId());
|
|
|
|
+ BizDayworkItem dayworkItem = bizDayworkItemService.getById(processInspecion.getLot().getDayworkItemId());
|
|
|
|
+ BizReturnReceiptDetail bizReturnReceiptDetail = bizReturnReceiptDetailService.query().eq("daywork_id", dayworkItem.getDayworkId()).eq("technological_process_detail_id", dayworkItem.getTechnologicalProcessDetailId()).eq("deleted", 0).one();
|
|
|
|
+
|
|
|
|
+ SysUser user = sysUserService.selectUserById(processInspecion.getUser().getUserId());
|
|
|
|
+
|
|
|
|
+ // 判断是否已经进行过质检
|
|
|
|
+ BizProcessInspecion previousItem = bizProcessInspecionService.query().eq("outsource_order_detail_id", bizReturnReceiptDetail.getOutsourceDetailId()).one();
|
|
|
|
+ if (previousItem != null) {
|
|
|
|
+ if (processInspecion.getId() == null) {
|
|
|
|
+ previousItem.setRecheckDate(DateTime.now().toJdkDate());
|
|
|
|
+ }
|
|
|
|
+ previousItem.setIsInspectionCarrierChanged(0);
|
|
|
|
+ previousItem.setInspectionCarrierChangedTime(null);
|
|
|
|
+ previousItem.setStatus(processInspecion.getStatus());
|
|
|
|
+ previousItem.setRejectNum(processInspecion.getRejectNum());
|
|
|
|
+ previousItem.setExaminingNum(processInspecion.getExaminingNum());
|
|
|
|
+ previousItem.setDisqualificationNum(processInspecion.getDisqualificationNum());
|
|
|
|
+ } else {
|
|
|
|
+ previousItem = new BizProcessInspecion(processInspecion);
|
|
|
|
+ String beginCode = "WDD" + DateTime.now().toString("yyMM");
|
|
|
|
+ String previous = redisCache.hasKey(processInspectionNoKey) ? redisCache.getCacheObject(processInspectionNoKey) : "";
|
|
|
|
+ String codeValue = "";
|
|
|
|
+ if (previous.isEmpty()) {
|
|
|
|
+ previous = (beginCode + "000001");
|
|
|
|
+ } else {
|
|
|
|
+ codeValue = previous;
|
|
|
|
+ int lastFourDigits = Integer.parseInt(codeValue.substring(7, 13));
|
|
|
|
+ lastFourDigits += 1; // 加1
|
|
|
|
+ codeValue = codeValue.substring(0, 7) + String.format("%06d", lastFourDigits);
|
|
|
|
+ previous = codeValue;
|
|
|
|
+ }
|
|
|
|
+ previousItem.setOutsourcedInspectionNo(previous);
|
|
|
|
+ redisCache.setCacheObject(processInspectionNoKey, previous);
|
|
|
|
+ }
|
|
|
|
+ previousItem.setReturnReceiptDetailId(bizReturnReceiptDetail.getId());
|
|
|
|
+ previousItem.setUserId(user == null ? 0L : user.getUserId());
|
|
|
|
+ previousItem.setNickName(user == null ? "" : user.getNickName());
|
|
|
|
+ previousItem.setCarrierId(processInspecion.getLot().getCarrierId());
|
|
|
|
+ previousItem.setCarrierCode(processInspecion.getLot().getCarrierCode());
|
|
|
|
+ previousItem.setDayworkId(daywork.getId());
|
|
|
|
+ previousItem.setProductionPlanId(daywork.getProductionPlanId());
|
|
|
|
+ previousItem.setDayworkItemId(dayworkItem.getId());
|
|
|
|
+ previousItem.setProductionPlanDetailId(daywork.getProductionPlanDetailId());
|
|
|
|
+ previousItem.setProductionPlanDetailSubDetailId(daywork.getProductionPlanDetailSubDetailId());
|
|
|
|
+ previousItem.setProductDescription(processInspecion.getLot().getProductDescription());
|
|
|
|
+ previousItem.setLotId(processInspecion.getLot().getId());
|
|
|
|
+ previousItem.setLotCode(processInspecion.getLot().getLotCode());
|
|
|
|
+ previousItem.setDeptId(daywork.getDeptId());
|
|
|
|
+ previousItem.setProductId(processInspecion.getLot().getProductId());
|
|
|
|
+ previousItem.setTechnologicalProcessId(processInspecion.getLot().getTechnologicalProcessId());
|
|
|
|
+ previousItem.setInspectionCarrierCode(processInspecion.getInspectionCarrierCode());
|
|
|
|
+ previousItem.setInspectionCarrierId(processInspecion.getInspectionCarrierId());
|
|
|
|
+
|
|
|
|
+ if (previousItem.getStartTime() == null) {
|
|
|
|
+ previousItem.setStartTime(new Date());
|
|
|
|
+ }
|
|
|
|
+ if (previousItem.getStatus() != 0) {
|
|
|
|
+ previousItem.setEndTime(new Date());
|
|
|
|
+ previousItem.setFirstUpdaterId(processInspecion.getFirstUpdaterId() == null || processInspecion.getFirstUpdaterId().equals(0L) ? user != null ? user.getUserId() : 0L : processInspecion.getFirstUpdaterId());
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if (!checkOutsourceDayworkItem(processInspecion.getOutsourceOrderDetailId())) {
|
|
|
|
+ return error("编辑失败,下序已经生产加工");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ BizCarrier carrier = bizCarrierService.query().eq("id", processInspecion.getInspectionCarrierId()).one();
|
|
|
|
+ List<BizDayworkCarrier> dayworkCarriers = bizDayworkCarrierService.query().eq("carrier_id", carrier.getId()).eq("is_changed", 0).list();
|
|
|
|
+ if (dayworkCarriers.stream().anyMatch(v -> !v.getDayworkId().equals(daywork.getId()))) {
|
|
|
|
+ return error("检测载具已绑定其他批次");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //保存
|
|
|
|
+ bizProcessInspecionService.saveOrUpdate(previousItem);
|
|
|
|
+
|
|
|
|
+ if (dayworkCarriers.stream().noneMatch(v -> v.getDayworkId().equals(daywork.getId())) && (previousItem.getIsInspectionCarrierChanged() == null || previousItem.getIsInspectionCarrierChanged().equals(0))) {
|
|
|
|
+ // 该检测载具需要绑定到当前批次
|
|
|
|
+ BizDayworkCarrier newDayworkCarrier = new BizDayworkCarrier();
|
|
|
|
+ newDayworkCarrier.setDayworkId(previousItem.getDayworkId());
|
|
|
|
+ newDayworkCarrier.setCarrierCode(carrier.getCode());
|
|
|
|
+ newDayworkCarrier.setCarrierId(carrier.getId());
|
|
|
|
+ newDayworkCarrier.setLotCode(previousItem.getLotCode());
|
|
|
|
+ newDayworkCarrier.setLotId(previousItem.getLotId());
|
|
|
|
+ newDayworkCarrier.setProductionPlanDetailId(previousItem.getProductionPlanDetailId());
|
|
|
|
+ newDayworkCarrier.setProcessInspectionId(previousItem.getId());
|
|
|
|
+ bizDayworkCarrierService.save(newDayworkCarrier);
|
|
|
|
+ }
|
|
|
|
+ List<BizDayworkItemConsult> consults = new ArrayList<>();
|
|
|
|
+ if (processInspecion.getId() != null) {
|
|
|
|
+ //保存废品信息
|
|
|
|
+ List<BizProcessInspectionDetail> rejects = processInspecion.getRejects();
|
|
|
|
+ //保存前先删除原先废品信息
|
|
|
|
+ BizDayworkItemReject rej = new BizDayworkItemReject();
|
|
|
|
+ rej.setProcessInspectionId(processInspecion.getId());
|
|
|
|
+ bizDayworkItemRejectService.removeReject(rej);
|
|
|
|
+ BizProcessInspectionDetail inspectionDetail = new BizProcessInspectionDetail();
|
|
|
|
+ inspectionDetail.setProcessInspectionId(processInspecion.getId());
|
|
|
|
+ processInspectionDetailService.physicalDelete(inspectionDetail);
|
|
|
|
+ BizDayworkItemReject newRej = new BizDayworkItemReject();
|
|
|
|
+ newRej.setRejectNum(0L);
|
|
|
|
+
|
|
|
|
+ if (rejects != null && rejects.size() > 0) {
|
|
|
|
+ for (BizProcessInspectionDetail reject : rejects) {
|
|
|
|
+ reject.setId(null);
|
|
|
|
+ reject.setUserId(user == null ? 0L : user.getUserId());
|
|
|
|
+ reject.setProcessInspectionId(processInspecion.getId());
|
|
|
|
+ reject.setDayworkId(0L);
|
|
|
|
+ reject.setProductionPlanId(daywork.getProductionPlanId());
|
|
|
|
+ reject.setProductionPlanDetailId(daywork.getProductionPlanDetailId());
|
|
|
|
+ reject.setProductionPlanDetailSubDetailId(daywork.getProductionPlanDetailSubDetailId());
|
|
|
|
+ reject.setLotId(processInspecion.getLot().getId());
|
|
|
|
+ reject.setDayworkItemId(dayworkItem.getId());
|
|
|
|
+ Long rejectNum = reject.getRejectNum() == null ? 0L : reject.getRejectNum();
|
|
|
|
+ newRej.setRejectNum(newRej.getRejectNum());
|
|
|
|
+ newRej.setUserId(user == null ? 0L : user.getUserId());
|
|
|
|
+ newRej.setProcessInspectionId(processInspecion.getId());
|
|
|
|
+ newRej.setDayworkId(0L);
|
|
|
|
+ newRej.setProductionPlanId(daywork.getProductionPlanId());
|
|
|
|
+ newRej.setProductionPlanDetailId(daywork.getProductionPlanDetailId());
|
|
|
|
+ newRej.setProductionPlanDetailSubDetailId(daywork.getProductionPlanDetailSubDetailId());
|
|
|
|
+ newRej.setLotId(processInspecion.getLot().getId());
|
|
|
|
+ newRej.setDayworkItemId(dayworkItem.getId());
|
|
|
|
+ newRej.setReason("外协检查废品");
|
|
|
|
+ newRej.setDeptId(processInspecion.getDeptId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ processInspectionDetailService.saveBatch(rejects);
|
|
|
|
+ bizDayworkItemRejectService.save(newRej);
|
|
|
|
+ //保存咨询信息
|
|
|
|
+ consults.addAll(processInspecion.getDayworkItemConsults());
|
|
|
|
+ if (consults.size() > 0) {
|
|
|
|
+ for (BizDayworkItemConsult consult : consults) {
|
|
|
|
+ consult.setUserId(user == null ? 0L : user.getUserId());
|
|
|
|
+ consult.setNickName(user == null ? "" : user.getNickName());
|
|
|
|
+ consult.setDayworkId(daywork.getId());
|
|
|
|
+ consult.setProcessInspectionId(processInspecion.getId());
|
|
|
|
+ consult.setProductionPlanId(daywork.getProductionPlanId());
|
|
|
|
+ consult.setProductionPlanDetailId(daywork.getProductionPlanDetailId());
|
|
|
|
+ consult.setProductionPlanDetailSubDetailId(daywork.getProductionPlanDetailSubDetailId());
|
|
|
|
+ consult.setLotId(processInspecion.getLot().getId());
|
|
|
|
+ consult.setLotCode(processInspecion.getLot().getLotCode());
|
|
|
|
+ consult.setDayworkId(daywork.getId());
|
|
|
|
+ consult.setDayworkItemId(dayworkItem.getId());
|
|
|
|
+ consult.setProductId(processInspecion.getLot().getProductId());
|
|
|
|
+ consult.setProductDescription(processInspecion.getLot().getProductDescription());
|
|
|
|
+ consult.setTechnologicalProcessId(processInspecion.getLot().getTechnologicalProcessId());
|
|
|
|
+ consult.setTechnologicalProcessDetailId(dayworkItem.getTechnologicalProcessDetailId());
|
|
|
|
+ consult.setProcessId(dayworkItem.getProcessId());
|
|
|
|
+ consult.setProcessAlias(processInspecion.getLot().getProcessAlias());
|
|
|
|
+ consult.setIsOutsourcedInspection(1);
|
|
|
|
+ consult.setTechnicianId(technicianUser == null ? 0L : technicianUser.getUserId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //修改daywaork信息
|
|
|
|
+ dayworkItem.setIsProcessInspection(1);
|
|
|
|
+ return success(bizDayworkItemService.saveOrUpdate(dayworkItem) && (consults.isEmpty() || bizDayworkItemConsultService.saveOrUpdateBatch(consults)));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
@Transactional
|
|
@Transactional
|
|
@PostMapping("/saveOutsourcedInspecion")
|
|
@PostMapping("/saveOutsourcedInspecion")
|
|
public AjaxResult saveOutsourcedInspectionV2(@RequestBody BizProcessInspecion processInspecion) throws NoSuchFieldException, IllegalAccessException {
|
|
public AjaxResult saveOutsourcedInspectionV2(@RequestBody BizProcessInspecion processInspecion) throws NoSuchFieldException, IllegalAccessException {
|
|
@@ -474,6 +651,10 @@ public class BizProcessInspecionController extends BaseController {
|
|
BizDayworkItem dayworkItem = bizDayworkItemService.getById(processInspecion.getLot().getDayworkItemId());
|
|
BizDayworkItem dayworkItem = bizDayworkItemService.getById(processInspecion.getLot().getDayworkItemId());
|
|
BizReturnReceiptDetail bizReturnReceiptDetail = bizReturnReceiptDetailService.query().eq("daywork_id", dayworkItem.getDayworkId()).eq("technological_process_detail_id", dayworkItem.getTechnologicalProcessDetailId()).eq("deleted", 0).one();
|
|
BizReturnReceiptDetail bizReturnReceiptDetail = bizReturnReceiptDetailService.query().eq("daywork_id", dayworkItem.getDayworkId()).eq("technological_process_detail_id", dayworkItem.getTechnologicalProcessDetailId()).eq("deleted", 0).one();
|
|
|
|
|
|
|
|
+ // 判断是否已经进行过质检
|
|
|
|
+// BizProcessInspecion previousItem = bizProcessInspecionService.query().eq("outsource_order_detail_id", bizReturnReceiptDetail.getOutsourceDetailId()).one();
|
|
|
|
+// previousItem.setRecheckDate(DateTime.now().toJdkDate());
|
|
|
|
+
|
|
SysUser user = sysUserService.selectUserById(processInspecion.getUser().getUserId());
|
|
SysUser user = sysUserService.selectUserById(processInspecion.getUser().getUserId());
|
|
processInspecion.setReturnReceiptDetailId(bizReturnReceiptDetail.getId());
|
|
processInspecion.setReturnReceiptDetailId(bizReturnReceiptDetail.getId());
|
|
processInspecion.setUserId(user == null ? 0L : user.getUserId());
|
|
processInspecion.setUserId(user == null ? 0L : user.getUserId());
|
|
@@ -598,7 +779,6 @@ public class BizProcessInspecionController extends BaseController {
|
|
return success(bizDayworkItemService.saveOrUpdate(dayworkItem) && bizDayworkItemConsultService.saveOrUpdateBatch(consults));
|
|
return success(bizDayworkItemService.saveOrUpdate(dayworkItem) && bizDayworkItemConsultService.saveOrUpdateBatch(consults));
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
// /**
|
|
// /**
|
|
// * 根据箱号查询是否为一箱多批
|
|
// * 根据箱号查询是否为一箱多批
|
|
// */
|
|
// */
|