wangxin преди 10 месеца
родител
ревизия
a745d86c7e
променени са 19 файла, в които са добавени 786 реда и са изтрити 180 реда
  1. 295 0
      src/main/java/cn/ezhizao/project/business/controller/BizSpecialDayworkController.java
  2. 56 20
      src/main/java/cn/ezhizao/project/business/domain/BizDaywork.java
  3. 18 0
      src/main/java/cn/ezhizao/project/business/domain/BizDayworkItem.java
  4. 5 0
      src/main/java/cn/ezhizao/project/business/mapper/BizDayworkItemMapper.java
  5. 3 0
      src/main/java/cn/ezhizao/project/business/mapper/BizDayworkMapper.java
  6. 2 0
      src/main/java/cn/ezhizao/project/business/mapper/BizLotMapper.java
  7. 1 0
      src/main/java/cn/ezhizao/project/business/mapper/BizProductionPlanDetailMapper.java
  8. 7 0
      src/main/java/cn/ezhizao/project/business/service/IBizDayworkItemService.java
  9. 2 0
      src/main/java/cn/ezhizao/project/business/service/IBizDayworkService.java
  10. 1 0
      src/main/java/cn/ezhizao/project/business/service/IBizLotService.java
  11. 1 2
      src/main/java/cn/ezhizao/project/business/service/IBizProductionPlanDetailService.java
  12. 87 4
      src/main/java/cn/ezhizao/project/business/service/impl/BizDayworkItemServiceImpl.java
  13. 5 0
      src/main/java/cn/ezhizao/project/business/service/impl/BizDayworkServiceImpl.java
  14. 5 0
      src/main/java/cn/ezhizao/project/business/service/impl/BizLotServiceImpl.java
  15. 5 0
      src/main/java/cn/ezhizao/project/business/service/impl/BizProductionPlanDetailServiceImpl.java
  16. 41 0
      src/main/resources/mybatis/business/BizDayworkItemMapper.xml
  17. 213 154
      src/main/resources/mybatis/business/BizDayworkMapper.xml
  18. 15 0
      src/main/resources/mybatis/business/BizLotMapper.xml
  19. 24 0
      src/main/resources/mybatis/business/BizProductionPlanDetailMapper.xml

+ 295 - 0
src/main/java/cn/ezhizao/project/business/controller/BizSpecialDayworkController.java

@@ -0,0 +1,295 @@
+package cn.ezhizao.project.business.controller;
+
+import cn.ezhizao.framework.aspectj.lang.annotation.Log;
+import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
+import cn.ezhizao.framework.web.controller.BaseController;
+import cn.ezhizao.framework.web.domain.AjaxResult;
+import cn.ezhizao.framework.web.page.TableDataInfo;
+import cn.ezhizao.project.business.domain.*;
+import cn.ezhizao.project.business.service.*;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+import  java.util.List;
+
+/**
+ * 报工Controller
+ *
+ * @author ezhizao
+ * @date 2023-11-29
+ */
+@RestController
+@RequestMapping("/business/specialDaywork")
+public class BizSpecialDayworkController extends BaseController {
+    @Resource
+    private IBizDayworkService bizDayworkService;
+
+    @Resource
+    private IBizTechnologicalProcessDetailService bizTechnologicalProcessDetailService;
+
+    @Resource
+    private IBizLotTechnologicalProcessDetailService bizTechnologicalAmendDetailService;
+
+    @Resource
+    private IBizDayworkCarrierService bizDayworkCarrierService;
+
+    @Resource
+    private IBizDayworkItemService bizDayworkItemService;
+    @Resource
+    private IBizDayworkItemRejectService bizDayworkItemRejectService;
+
+    @Resource
+    private IBizProductionPlanDetailService bizProductionPlanDetailService;
+
+    @Resource
+    private IBizLotService bizLotService;
+
+
+    /**
+     * 查询报工列表
+     */
+    @Log(title = "特殊报工列表查询", businessType = BusinessType.SELECT)
+    @PreAuthorize("@ss.hasPermi('business:specialDaywork:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(BizDayworkItem bizDayworkItem) {
+        /**
+         * 查询特殊报工信息,先查询所有是特殊报工(is_special=1)的明细(daywork_item)的数据查出来,查询时跟据创建时间正序排列
+         */
+
+        if(bizDayworkItem.getSpecialStartTime()!=null) {
+            bizDayworkItem.setSpecialStartTime(bizDayworkItem.getSpecialStartTime()+ " 00:00:00");
+        }
+        if(bizDayworkItem.getSpecialEndTime()!=null) {
+            bizDayworkItem.setSpecialEndTime(bizDayworkItem.getSpecialEndTime()+ " 23:59:59");
+        }
+        //查询出所有特殊报工的报工信息
+        List<BizDayworkItem> dayworkItemList = bizDayworkItemService.getSpecialList(bizDayworkItem);
+
+        //根据报工信息筛选出符合条件的dayworkId
+        List<Long> specialIds= bizDayworkItemService.screenDayworkItem(dayworkItemList,bizDayworkItem);
+
+        if(specialIds.isEmpty()){
+            return getDataTable(new ArrayList<>());
+        }
+        //分页请求
+        startPage();
+        //查询daywork信息
+        List<BizDaywork> dayworks=bizDayworkService.selectScreenDaywork(specialIds);
+
+        //如果没有数据则返回空
+        if(dayworks.isEmpty()){
+            return getDataTable(new ArrayList<>());
+        }
+
+        //查询工序信息
+        dayworks=selectDayworkProcess(dayworks);
+
+        //查询产品信息
+        dayworks=selectProductionPlanDetail(dayworks);
+
+        //查询箱号信息
+        dayworks=selectCarrierCode(dayworks);
+
+        /*
+          查询合格数和废品信息需要先查询到每条daywork对应的当前工序的报工信息daywork_item
+          因为需要进行合格数计算所以只查询状态为2和3的数据
+         */
+        List<BizDayworkItem> dayworkItems=bizDayworkItemService.selectListOfspecial(dayworks);
+
+        if(!dayworkItems.isEmpty()){
+            //查询合格数和投产数
+            dayworks=selectNumber(dayworks, dayworkItems);
+            //查询废品数
+            dayworks=selectRejectsNumber(dayworks,dayworkItems);
+        }
+
+        return getDataTable(dayworks);
+    }
+
+    @Log(title = "特殊报工首序报工查询计划单", businessType = BusinessType.SELECT)
+    @GetMapping("/selectProductList")
+    public TableDataInfo selectProductList(BizProductionPlanDetail bizProductionPlanDetail) {
+        List<BizProductionPlanDetail> planDetailList = bizProductionPlanDetailService.selectSpecialFirstProductDetail(bizProductionPlanDetail);
+        return getDataTable(planDetailList);
+    }
+
+    @Log(title = "特殊报工首序报工查询可用批次", businessType = BusinessType.SELECT)
+    @GetMapping("/lotList")
+    public TableDataInfo list(BizLot bizLot) throws NoSuchFieldException, IllegalAccessException {
+        List<BizLot> list = bizLotService.specialGetLotList(bizLot);
+        return getDataTable(list);
+    }
+
+    @Log(title = "特殊报工首序报工查询批次信息", businessType = BusinessType.SELECT)
+    @GetMapping("/selectLotList")
+    public AjaxResult selectLotList(BizLot bizLot) {
+//        List<BizProductionPlanDetail> planDetailList = bizProductionPlanDetailService.selectSpecialFirstProductDetail(bizProductionPlanDetail);
+        return success();
+    }
+
+
+     /**
+     * 根据dayworkItems的id查询废品表数据,将数据按照dayworkId分组
+     * 计算每组所有的废品数总和,在赋值给对应的daywork
+     */
+    private List<BizDaywork> selectRejectsNumber(List<BizDaywork> dayworks,List<BizDayworkItem> dayworkItems){
+
+        List<BizDayworkItemReject> dayworkItemRejects=bizDayworkItemRejectService.query()
+                .in("daywork_item_id",dayworkItems.stream().map(BizDayworkItem::getId).collect(Collectors.toList())).list();
+        // 按 dayworkId 分组并计算每组的废品数总和
+        Map<Long, Long> totalRejectCountsByDayworkId = dayworkItemRejects.stream()
+                .collect(Collectors.groupingBy(
+                        BizDayworkItemReject::getDayworkId,
+                        Collectors.summingLong(BizDayworkItemReject::getRejectNum) // 使用 summingLong 来处理 Long 类型的求和
+                ));
+
+        // 更新 dayworks 列表中的 BizDaywork 对象
+        for (BizDaywork daywork : dayworks) {
+            Long dayworkId = daywork.getId();
+            Long totalRejectCount = totalRejectCountsByDayworkId.getOrDefault(dayworkId, 0L); // 使用 0L 作为 Long 类型的默认值
+            daywork.setRejectSum(totalRejectCount);
+        }
+
+        return dayworks;
+
+    }
+
+    /**
+     * 查询合格数和废品信息需要先查询到每条daywork对应的当前工序的报工信息daywork_item
+     * 因为需要进行合格数计算所以只查询状态为2和3的数据
+     */
+    private List<BizDaywork> selectNumber(List<BizDaywork> dayworks,  List<BizDayworkItem> dayworkItems){
+
+        // 使用 Stream API 来分组并计算每组的 qualifiedNum 总和以及获取每组的第一条数据的 prodNum
+        Map<Long, BizDayworkItem> firstItemByDayworkId = dayworkItems.stream()
+                .collect(Collectors.toMap(BizDayworkItem::getDayworkId, Function.identity(), (oldValue, newValue) -> oldValue));
+
+        //将查询出来的数据按照dayworkId分组,计算总合格数
+        Map<Long, Integer> sumOfQualifiedNums = dayworkItems.stream()
+                .collect(Collectors.groupingBy(
+                        BizDayworkItem::getDayworkId,
+                        Collectors.summingInt(BizDayworkItem::getQualifiedNum)
+                ));
+
+        // 更新 dayworks 列表中的 BizDaywork 对象
+        for (BizDaywork daywork : dayworks) {
+            Long dayworkId = daywork.getId();
+            Integer totalQualifiedNum = sumOfQualifiedNums.getOrDefault(dayworkId, 0); // 如果没有找到对应的分组,返回0
+            daywork.setQualifiedNum(totalQualifiedNum);
+
+            BizDayworkItem firstItem = firstItemByDayworkId.get(dayworkId);
+            if (firstItem != null) {
+                daywork.setProdNum(firstItem.getProdNum());
+            } else {
+                daywork.setProdNum(0);
+            }
+        }
+        return dayworks;
+    }
+
+    /**
+     * 根据dayworkId向biz_daywork_carrier查询绑定信息,查询is_changed=0的数据
+     * 将carrier拼接起来,按”,“分割
+     */
+    private List<BizDaywork> selectCarrierCode(List<BizDaywork> dayworks){
+
+        List<BizDayworkCarrier> dayworkCarriers=bizDayworkCarrierService.query().in("daywork_id",dayworks.stream()
+                .map(BizDaywork::getId).collect(Collectors.toList())).list();
+
+        // 使用 Stream API 来分组和拼接 carrierCode
+        Map<Long, String> carrierCodeMap = dayworkCarriers.stream()
+                .collect(Collectors.groupingBy(
+                        BizDayworkCarrier::getDayworkId, // 分组的键
+                        Collectors.mapping(BizDayworkCarrier::getCarrierCode, Collectors.joining(",")) // 拼接值
+                ));
+
+        // 更新 dayworks 列表
+        for (BizDaywork daywork : dayworks) {
+            Long dayworkId = daywork.getId();
+            String carrierCodes = carrierCodeMap.getOrDefault(dayworkId, ""); // 如果没有找到对应的分组,返回空字符串
+            // 假设 BizDaywork 有一个方法来设置它的 carrierCodes
+            daywork.setCarrierCode(carrierCodes);
+        }
+        return dayworks;
+    }
+
+    /**
+     * 查询产品信息
+     * @param dayworks
+     * @return
+     */
+    private List<BizDaywork> selectProductionPlanDetail(List<BizDaywork> dayworks){
+        //根据生产子计划id查询biz_production_plan_detail表中数据
+        List<BizProductionPlanDetail> productionPlanDetails=bizProductionPlanDetailService.query().in("id",dayworks.stream()
+                .map(BizDaywork::getProductionPlanDetailId).collect(Collectors.toList())).list();
+
+        //给daywork中productionPlanDetail赋值
+        // 将productionPlanDetails转换为Map,以id为键,方便快速查找
+        Map<Long, BizProductionPlanDetail> detailMap = productionPlanDetails.stream()
+                .collect(Collectors.toMap(BizProductionPlanDetail::getId, Function.identity()));
+        // 使用Stream API过滤dayworks中的元素,并设置对应的BizProductionPlanDetail
+        dayworks.stream()
+                .filter(daywork -> detailMap.containsKey(daywork.getProductionPlanDetailId()))
+                .forEach(daywork -> {
+                    BizProductionPlanDetail detail = detailMap.get(daywork.getProductionPlanDetailId());
+                    daywork.setProductionPlanDetail(detail);
+                });
+        return dayworks;
+    }
+
+
+
+    /**
+     * 查询工序信息
+     * 根据daywork查询工序信息,判断批次是否单批单改或废品回用等非正常状态,将正常批次和非正常批次区分开
+     * 正常批次上biz_technological_process_detail表中查询,非正常批次上biz_lot_technological_process_detail中查询
+     */
+    private List<BizDaywork> selectDayworkProcess(List<BizDaywork> dayworks){
+
+        //正常批次工序id
+        List<Long>ids=new ArrayList<>();
+        //工序修改批次工序id
+        List<Long>amendIds=new ArrayList<>();
+        for(BizDaywork bizDaywork:dayworks){
+            if(bizDaywork.getIsAmend().equals(1)){
+                amendIds.add(bizDaywork.getSpecialProcessId());
+            }else{
+                ids.add(bizDaywork.getSpecialProcessId());
+            }
+        }
+
+        //集合不为空进入查询
+        if(!ids.isEmpty()){
+            //根据工序id查询工序信息
+            List<BizTechnologicalProcessDetail> processDetailList=bizTechnologicalProcessDetailService.query().in("id",ids).list();
+            //根据工序id赋值工序信息
+            for(BizTechnologicalProcessDetail processDetail:processDetailList){
+                for(BizDaywork bizDaywork:dayworks){
+                    if(processDetail.getId().equals(bizDaywork.getSpecialProcessId())){
+                        bizDaywork.setProcessAlias(processDetail.getProcessAlias());
+                    }
+                }
+            }
+        }
+        if(!amendIds.isEmpty()){
+            //根据工序id查询工序信息
+            List<BizLotTechnologicalProcessDetail> lotTechnologicalProcessDetails=bizTechnologicalAmendDetailService.query().in("id",amendIds).list();
+            //根据工序id赋值工序信息
+            for(BizLotTechnologicalProcessDetail processDetail:lotTechnologicalProcessDetails){
+                for(BizDaywork bizDaywork:dayworks){
+                    if(processDetail.getId().equals(bizDaywork.getSpecialProcessId())){
+                        bizDaywork.setProcessAlias(processDetail.getProcessAlias());
+                    }
+                }
+            }
+        }
+        return dayworks;
+    }
+
+
+}

+ 56 - 20
src/main/java/cn/ezhizao/project/business/domain/BizDaywork.java

@@ -63,9 +63,6 @@ public class BizDaywork extends BaseEntity {
     @ApiModelProperty(value = "${comment}")
     private Long technologicalProcessId;
 
-    /** 工序id */
-//    @ApiModelProperty(value = "${comment}")
-//    private Long processId;
 
     /** 设备id */
 //    @ApiModelProperty(value = "${comment}")
@@ -76,19 +73,6 @@ public class BizDaywork extends BaseEntity {
 //    @ApiModelProperty(value = "设备编码")
 //    private String equipmentDetailCode;
 
-    /** 用户id */
-    @ApiModelProperty(value = "设备编码")
-    private Long userId;
-
-    /** 员工编码 */
-    @Excel(name = "员工编码")
-    @ApiModelProperty(value = "员工编码")
-    private String userName;
-
-    /** 员工姓名 */
-    @Excel(name = "员工姓名")
-    @ApiModelProperty(value = "员工姓名")
-    private String nickName;
 
     /** 开始时间 */
     @JsonFormat(pattern = "yyyy-MM-dd")
@@ -180,8 +164,7 @@ public class BizDaywork extends BaseEntity {
     @TableField(exist = false)
     private String deptCode;
 
-    @TableField(exist = false)
-    private String processAlias;
+
     /**
      * 是否回退
      */
@@ -229,11 +212,17 @@ public class BizDaywork extends BaseEntity {
     /** 原箱号 **/
     @TableField(exist = false)
     private String originalCarrier;
-    @TableField(exist = false)
-    private String carrierCode;
+
 
     @TableField(exist = false)
     private Integer productNum;
+
+    /** 工序id */
+    @TableField(exist = false)
+    private Long processId;
+
+
+
     /** 新箱号 **/
     @TableField(exist = false)
     private String newCarrier;
@@ -255,6 +244,53 @@ public class BizDaywork extends BaseEntity {
     @TableField(exist = false)
     private Long outsourceDetailId;
 
+    /** 特殊报工使用字段 **/
+    /** 是否有特殊报工 */
+    @Excel(name = "是否有特殊报工")
+    @ApiModelProperty(value = "是否有特殊报工")
+    private Integer hasSpecial;
+
+    @TableField(exist = false)
+    private Long specialProcessId;
+
+    /** 废品数*/
+    @TableField(exist = false)
+    private Long rejectSum;
+    /** 投产数 */
+    @TableField(exist = false)
+    private Integer prodNum;
+
+    /** 合格数 */
+    @TableField(exist = false)
+    private Integer qualifiedNum;
+
+    /** 用户id */
+    @ApiModelProperty(value = "用户id")
+    private Long userId;
+
+    /** 员工编码 */
+    @Excel(name = "员工编码")
+    @ApiModelProperty(value = "员工编码")
+    private String userName;
+
+    @TableField(exist = false)
+    private String processAlias;
+
+    //最新报工状态
+    @TableField(exist = false)
+    private Integer  itemStatus;
+
+    /** 员工姓名 */
+    @Excel(name = "员工姓名")
+    @ApiModelProperty(value = "员工姓名")
+    private String nickName;
+
+    @TableField(exist = false)
+    private String carrierCode;
+
+    @TableField(exist = false)
+    private BizProductionPlanDetail productionPlanDetail;
+
     public BizDaywork() {}
 
     public BizDaywork(BizDaywork copy) {

+ 18 - 0
src/main/java/cn/ezhizao/project/business/domain/BizDayworkItem.java

@@ -137,6 +137,15 @@ public class BizDayworkItem extends BaseEntity {
     @ApiModelProperty(value = "结束时间")
     private Date endTime;
 
+    /** 是否有特殊报工 */
+    @Excel(name = "是否特殊报工")
+    @ApiModelProperty(value = "是否特殊报工")
+    private Integer isSpecial;
+
+    //最新报工状态
+    @TableField(exist = false)
+    private Integer  itemStatus;
+
     @ApiModelProperty(value = "报公工时")
     private Long workingHours;
    @Excel(name = "废品数",sort = 7)
@@ -253,6 +262,15 @@ public class BizDayworkItem extends BaseEntity {
     @TableField(exist = false)
     private Long isWasteRecycling;
 
+    @TableField(exist = false)
+    private String productionPlanNo;
+
+    @TableField(exist = false)
+    private String specialStartTime;
+
+    @TableField(exist = false)
+    private String specialEndTime;
+
     @TableField(exist = false)
     private List<Long> dayworkIds;
 

+ 5 - 0
src/main/java/cn/ezhizao/project/business/mapper/BizDayworkItemMapper.java

@@ -1,5 +1,6 @@
 package cn.ezhizao.project.business.mapper;
 
+import cn.ezhizao.project.business.domain.BizDaywork;
 import cn.ezhizao.project.business.domain.BizDayworkItem;
 import cn.ezhizao.project.business.domain.BizProductionResourceGroupDetail;
 import cn.ezhizao.project.system.domain.SysDept;
@@ -65,4 +66,8 @@ public interface BizDayworkItemMapper extends BaseMapper<BizDayworkItem>
     BizDayworkItem getLastItem(BizDayworkItem bizDayworkItem);
 
     List<BizDayworkItem> getLastFinished(BizDayworkItem dayworkItem);
+
+    List<BizDayworkItem> getSpecialList(BizDayworkItem dayworkItem);
+
+    List<BizDayworkItem> selectListOfspecial(List<BizDaywork> dayworks);
 }

+ 3 - 0
src/main/java/cn/ezhizao/project/business/mapper/BizDayworkMapper.java

@@ -72,4 +72,7 @@ public interface BizDayworkMapper extends BaseMapper<BizDaywork> {
     public int physicalDelete(BizDaywork bizDaywork);
 
     List<BizDaywork> getListFromNoCurrent(BizDaywork bizDaywork);
+
+
+    List<BizDaywork> selectScreenDaywork(List<Long> ids);
 }

+ 2 - 0
src/main/java/cn/ezhizao/project/business/mapper/BizLotMapper.java

@@ -58,4 +58,6 @@ public interface BizLotMapper extends BaseMapper<BizLot> {
      * @return 删除结果
      */
     public int physicalDelete(BizLot data);
+
+    List<BizLot> specialGetLotList(BizLot bizLot);
 }

+ 1 - 0
src/main/java/cn/ezhizao/project/business/mapper/BizProductionPlanDetailMapper.java

@@ -58,4 +58,5 @@ public interface BizProductionPlanDetailMapper extends BaseMapper<BizProductionP
      */
     public int updateLotCodeStatus(BizProductionPlanDetail bizProductionPlanDetail);
 
+    List<BizProductionPlanDetail> selectSpecialFirstProductDetail(BizProductionPlanDetail bizProductionPlanDetail);
 }

+ 7 - 0
src/main/java/cn/ezhizao/project/business/service/IBizDayworkItemService.java

@@ -1,5 +1,6 @@
 package cn.ezhizao.project.business.service;
 
+import cn.ezhizao.project.business.domain.BizDaywork;
 import cn.ezhizao.project.business.domain.BizDayworkItem;
 import cn.ezhizao.project.business.domain.BizOutsourcedOrderDetail;
 import cn.ezhizao.project.business.domain.BizProductionResourceGroupDetail;
@@ -64,4 +65,10 @@ public interface IBizDayworkItemService extends IService<BizDayworkItem>
     BizDayworkItem getLastItem(BizDayworkItem bizDayworkItem);
 
     List<BizDayworkItem> getLastFinished(BizDayworkItem dayworkItem);
+
+    List<BizDayworkItem> getSpecialList(BizDayworkItem bizDayworkItem);
+
+    List<Long> screenDayworkItem(List<BizDayworkItem> dayworkItemList, BizDayworkItem bizDayworkItem);
+
+    List<BizDayworkItem> selectListOfspecial(List<BizDaywork> dayworks);
 }

+ 2 - 0
src/main/java/cn/ezhizao/project/business/service/IBizDayworkService.java

@@ -71,4 +71,6 @@ public interface IBizDayworkService extends IService<BizDaywork> {
 
     public List<BizDayworkItem> listReportItem(BizDayworkItem bizDayworkItem);
     List<BizDayworkItem>  getItemListFromOutsourced(BizDayworkItem  bizDayworkItem);
+
+    List<BizDaywork> selectScreenDaywork(List<Long> ids);
 }

+ 1 - 0
src/main/java/cn/ezhizao/project/business/service/IBizLotService.java

@@ -60,4 +60,5 @@ public interface IBizLotService extends IService<BizLot>
      */
     int physicalDelete(BizLot data);
 
+    List<BizLot> specialGetLotList(BizLot bizLot);
 }

+ 1 - 2
src/main/java/cn/ezhizao/project/business/service/IBizProductionPlanDetailService.java

@@ -63,6 +63,5 @@ public interface IBizProductionPlanDetailService extends IService<BizProductionP
     public List<BizProductionPlanDetail> reportList(BizProductionPlanDetail data);
 
 
-
-
+    public List<BizProductionPlanDetail> selectSpecialFirstProductDetail(BizProductionPlanDetail bizProductionPlanDetail);
 }

+ 87 - 4
src/main/java/cn/ezhizao/project/business/service/impl/BizDayworkItemServiceImpl.java

@@ -6,14 +6,12 @@ import cn.ezhizao.project.business.mapper.BizDayworkMapper;
 import cn.ezhizao.project.business.service.IBizDayworkItemService;
 import cn.ezhizao.project.system.domain.SysDept;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.ibatis.jdbc.Null;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -308,4 +306,89 @@ public class BizDayworkItemServiceImpl extends ServiceImpl<BizDayworkItemMapper,
         return bizDayworkItemMapper.getLastFinished(dayworkItem);
     }
 
+    @Override
+    public List<BizDayworkItem> getSpecialList(BizDayworkItem dayworkItem) {
+        return  bizDayworkItemMapper.getSpecialList(dayworkItem);
+    }
+
+    /**
+     * 查询特殊报工信息,先查询所有是特殊报工(is_special=1)的明细(daywork_item)的数据查出来,查询时跟据创建时间正序排列
+     * 再根据dayweokId进行分组,将最后一条报工状态大于4的去掉,因为状态大于4表示搬运已经进行周转或已经送达
+     * 再判断最后一条报工是状态是否大于3,如果大于3则表示已经提交了周转申请工段已经发生变化所有如果最后一条报工大于3则需要取上一条报工
+     * 根据报工信息的工段来判断是否为当前登陆人员选择的工段,如果是则将该条dayworkdId存到集合里查询
+     */
+    @Override
+    public List<Long> screenDayworkItem(List<BizDayworkItem> dayworkItemList, BizDayworkItem bizDayworkItem) {
+        //按照dayworkid分组
+        Map<Long, List<BizDayworkItem>> groupedMap = dayworkItemList.stream().collect(Collectors.groupingBy(BizDayworkItem::getDayworkId));
+        List<List<BizDayworkItem>> itemList = new ArrayList<>(groupedMap.values());
+        //查询出符合当前选择工段的数据
+        //符合条件的数据
+        List<Long> ids=new ArrayList<>();
+        for (List<BizDayworkItem> items : itemList) {
+            if (!items.isEmpty()) {
+                BizDayworkItem currentItem = items.get(items.size() - 1); // 获取最后一个元素
+                //如果最后一条数据状态>4,表示搬运已经进行周转或已经送达,跳出当前循环不做查询
+                if(Integer.parseInt(currentItem.getStatus()) > 4){
+                    continue;
+                }
+                //根据查询条件查询最一条状态是否符合查询状态,不符合直接跳出
+                if(bizDayworkItem.getItemStatus()!=null && Integer.parseInt(currentItem.getStatus())!=bizDayworkItem.getItemStatus()){
+                    continue;
+                }
+
+                // 如果当前元素的 status 大于 3,则查找上一条数据
+                if (Integer.parseInt(currentItem.getStatus()) > 3 && items.size() > 1) {
+                    currentItem = items.get(items.size() - 2); // 获取倒数第二个元素
+                }
+//                //根据查询条件查询最后一条的创建时间是否在查询时间内
+//                if(bizDayworkItem.getStartTime()!= null && bizDayworkItem.getEndTime()!=null ){
+//                    bizDayworkItem.setStartTime(adjustToMidnight(bizDayworkItem.getStartTime()));
+//                    bizDayworkItem.setEndTime(adjustToEndOfDay(bizDayworkItem.getEndTime()));
+//                    if(currentItem.getCreateTime().before(bizDayworkItem.getStartTime()) || currentItem.getCreateTime().after(bizDayworkItem.getEndTime())){
+//                        continue;
+//                    }
+//                }
+
+                if(bizDayworkItem.getDeptId()!=null){
+                    // 比较 deptId 是否一致
+                    if (Objects.equals(currentItem.getDeptId(), bizDayworkItem.getDeptId())) {
+                        ids.add(currentItem.getDayworkId());
+                    }
+                }else {
+                    ids.add(currentItem.getDayworkId());
+                }
+            }
+        }
+        //将符合条件的dayworkId返回
+        return ids;
+    }
+
+
+//    // 将给定日期的时间部分设置为00:00:00,年月日不变
+//    private Date adjustToMidnight(Date date) {
+//        Calendar calendar = Calendar.getInstance();
+//        calendar.setTime(date);
+//        calendar.set(Calendar.HOUR_OF_DAY, 0);
+//        calendar.set(Calendar.MINUTE, 0);
+//        calendar.set(Calendar.SECOND, 0);
+//        calendar.set(Calendar.MILLISECOND, 0);
+//        return calendar.getTime();
+//    }
+//
+//    // 将给定日期的时间部分设置为23:59:59,年月日不变
+//    private Date adjustToEndOfDay(Date date) {
+//        Calendar calendar = Calendar.getInstance();
+//        calendar.setTime(date);
+//        calendar.set(Calendar.HOUR_OF_DAY, 23);
+//        calendar.set(Calendar.MINUTE, 59);
+//        calendar.set(Calendar.SECOND, 59);
+//        return calendar.getTime();
+//    }
+
+    @Override
+    public List<BizDayworkItem> selectListOfspecial(List<BizDaywork> dayworks) {
+        return bizDayworkItemMapper.selectListOfspecial(dayworks);
+    }
+
 }

+ 5 - 0
src/main/java/cn/ezhizao/project/business/service/impl/BizDayworkServiceImpl.java

@@ -123,4 +123,9 @@ public class BizDayworkServiceImpl extends ServiceImpl<BizDayworkMapper, BizDayw
         return bizDayworkMapper.getItemListFromOutsourced(bizDayworkItem);
     }
 
+    @Override
+    public List<BizDaywork> selectScreenDaywork(List<Long> ids) {
+        return bizDayworkMapper.selectScreenDaywork(ids);
+    }
+
 }

+ 5 - 0
src/main/java/cn/ezhizao/project/business/service/impl/BizLotServiceImpl.java

@@ -68,6 +68,11 @@ public class BizLotServiceImpl extends ServiceImpl<BizLotMapper, BizLot> impleme
         return bizLotMapper.physicalDelete(data);
     }
 
+    @Override
+    public List<BizLot> specialGetLotList(BizLot bizLot) {
+        return bizLotMapper.specialGetLotList(bizLot);
+    }
+
     ;
 
 }

+ 5 - 0
src/main/java/cn/ezhizao/project/business/service/impl/BizProductionPlanDetailServiceImpl.java

@@ -90,6 +90,11 @@ public class BizProductionPlanDetailServiceImpl  extends ServiceImpl<BizProducti
         return bizProductionPlanDetailMapper.reportList(data);
     }
 
+    @Override
+    public List<BizProductionPlanDetail> selectSpecialFirstProductDetail(BizProductionPlanDetail bizProductionPlanDetail) {
+        return bizProductionPlanDetailMapper.selectSpecialFirstProductDetail(bizProductionPlanDetail);
+    }
+
     ;
 
 }

+ 41 - 0
src/main/resources/mybatis/business/BizDayworkItemMapper.xml

@@ -49,6 +49,47 @@
         ORDER BY process_step_number DESC
     </select>
 
+    <select id="getSpecialList" parameterType="BizDayworkItem" resultMap="BizDayworkItemResult">
+        SELECT * FROM biz_daywork_item d
+        LEFT JOIN biz_daywork dw ON d.daywork_id = dw.id
+        LEFT JOIN biz_production_plan_detail p ON d.production_plan_detail_id = p.id
+        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
+            d.deleted = 0 and d.outsource_detail_id = 0  and d.is_special=1
+            <if test="specialStartTime != null "> AND
+                dw.start_time
+                >= #{specialStartTime}</if>
+            <if test="specialEndTime != null "> AND
+                dw.start_time &lt;= #{specialEndTime}</if>
+            <if test="lotCode != null and  lotCode != ''">AND   dw.lot_code LIKE CONCAT('%', #{lotCode}, '%') </if>
+            <if test="productionPlanNo != null and  productionPlanNo != ''">AND p.production_plan_no  LIKE CONCAT('%', #{productionPlanNo}, '%') </if>
+            <if test="productDescription != null and  productDescription != ''">AND p.product_description  LIKE CONCAT('%', #{productDescription}, '%') </if>
+        </trim>
+        ORDER BY d.create_time ASC
+    </select>
+
+    <select id="selectListOfspecial" parameterType="list" resultMap="BizDayworkItemResult">
+        SELECT * FROM biz_daywork_item
+        <trim prefix="WHERE" suffixOverrides="AND">
+            deleted = 0
+            <if test="list != null and list.size() > 0">
+                AND daywork_id IN
+                <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
+                    #{item.id}
+                </foreach>
+                AND technological_process_detail_id IN
+                <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
+                    #{item.specialProcessId}
+                </foreach>
+            </if>
+            AND (status = 3 OR status = 2)
+        </trim>
+    </select>
+
+
+
+
+
+
     <select id="selectLatestItemByDayworkIds" resultType="cn.ezhizao.project.business.domain.BizDayworkItem">
         SELECT *
         FROM biz_daywork_item d

+ 213 - 154
src/main/resources/mybatis/business/BizDayworkMapper.xml

@@ -21,10 +21,10 @@
                      select="getLastLotQuantity"/>
         <association property="totalWorkingHours" column="{id=id,deptId=dept_id}" select="getTotalWorkingHours"/>
     </resultMap>
-
     <resultMap type="cn.ezhizao.project.business.domain.BizDaywork" id="BizDayworkResultForOutsource">
         <id column="id" property="id"/>
-        <collection property="originalCarrierList" ofType="cn.ezhizao.project.business.domain.BizDayworkCarrier" column="id" select="getOriginalCarrierList"/>
+        <collection property="originalCarrierList" ofType="cn.ezhizao.project.business.domain.BizDayworkCarrier"
+                    column="id" select="getOriginalCarrierList"/>
     </resultMap>
 
     <resultMap id="BizDayworkItemResult" type="cn.ezhizao.project.business.domain.BizDayworkItem">
@@ -35,12 +35,15 @@
         <result column="equipment_detail_id" property="equipmentDetailId"/>
         <result column="equipment_detail_code" property="equipmentDetailCode"/>
         <result column="lot_id" property="lotId"/>
-        <result column="production_plan_detail_id" property="productionPlanDetailId" />
+        <result column="production_plan_detail_id" property="productionPlanDetailId"/>
         <result column="technological_process_detail_id" property="technologicalProcessDetailId"/>
         <association property="lotCode" column="lot_id" javaType="java.lang.String" select="getLotCode"/>
-        <association property="processAlias" column="technological_process_detail_id" javaType="java.lang.String" select="getProcessName"/>
-        <association property="technologyVersion" column="lot_id" javaType="java.lang.String" select="getTechnologyVersion"/>
-        <association property="productDescription" column="production_plan_detail_id" javaType="java.lang.String" select="getProductDescription"/>
+        <association property="processAlias" column="technological_process_detail_id" javaType="java.lang.String"
+                     select="getProcessName"/>
+        <association property="technologyVersion" column="lot_id" javaType="java.lang.String"
+                     select="getTechnologyVersion"/>
+        <association property="productDescription" column="production_plan_detail_id" javaType="java.lang.String"
+                     select="getProductDescription"/>
         <association property="rejectNum" column="id" javaType="java.lang.String" select="getRejectNum"></association>
         <association property="firstProcessId" column="daywork_id" select="getFirstProcess"/>
     </resultMap>
@@ -66,7 +69,7 @@
         <association property="lastLotQuantity" javaType="java.lang.Integer" column="production_plan_detail_id"
                      select="getLastLotQuantity"/>
         <association property="processAlias" column="id" select="getProcessAlias"/>
-<!--        <association property="lotWaste" column="lot_id" select="getLotWaste"/>-->
+        <!--        <association property="lotWaste" column="lot_id" select="getLotWaste"/>-->
         <association property="totalWorkingHours" column="{id=id,deptId=dept_id}" select="getTotalWorkingHours"/>
     </resultMap>
     <select id="getDayworkInfo" resultMap="BizLotResult">
@@ -80,7 +83,9 @@
         <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
             t2.production_plan_no = #{productionPlanNo} AND t2.line_number = #{lineNumber}
             <if test="deptId != null  AND deptId != 0">AND t3.dept_id = #{deptId}</if>
-            <if test="productDescription != null  AND productDescription != ''">AND t2.product_description like concat('%',#{productDescription},'%')</if>
+            <if test="productDescription != null  AND productDescription != ''">AND t2.product_description like
+                concat('%',#{productDescription},'%')
+            </if>
             <if test="lotCode != null  AND lotCode != ''">AND t1.lot_code like concat('%',#{lotCode},'%')</if>
             <if test="isWasteRecycling != null ">AND t1.is_waste_recycling = #{isWasteRecycling}</if>
             <if test="isFallback != null ">AND t1.is_fallback = #{isFallback}</if>
@@ -88,28 +93,28 @@
     </select>
     <select id="getProducedLot" resultMap="BizLotResult">
         SELECT DISTINCT
-            t2.id AS lot_id,
-            t2.lot_code,
-            t2.technology_version,
-            t2.production_quantity,
-            t2.from_id,
-            (select lot_code from biz_lot where t2.from_id =biz_lot.id ) as from_code,
-            t2.is_waste_recycling,
-            t2.is_amend,
-            t2.is_fallback,
-            t2.is_waste,
-            t3.company_alias,
-            t3.production_plan_no,
-            t3.product_description AS description,
-            t1.id,
-            t1.create_time,
-            t1.temporary_process_qualified_num,
-            t4.dept_name,
-            t4.dept_id
+        t2.id AS lot_id,
+        t2.lot_code,
+        t2.technology_version,
+        t2.production_quantity,
+        t2.from_id,
+        (select lot_code from biz_lot where t2.from_id =biz_lot.id ) as from_code,
+        t2.is_waste_recycling,
+        t2.is_amend,
+        t2.is_fallback,
+        t2.is_waste,
+        t3.company_alias,
+        t3.production_plan_no,
+        t3.product_description AS description,
+        t1.id,
+        t1.create_time,
+        t1.temporary_process_qualified_num,
+        t4.dept_name,
+        t4.dept_id
         FROM biz_daywork t1
-            LEFT JOIN biz_lot t2 on t2.id = t1.lot_id
-            INNER JOIN biz_production_plan_detail t3 on t2.production_plan_detail_id = t3.id
-            LEFT JOIN sys_dept t4 on t1.dept_id = t4.dept_id
+        LEFT JOIN biz_lot t2 on t2.id = t1.lot_id
+        INNER JOIN biz_production_plan_detail t3 on t2.production_plan_detail_id = t3.id
+        LEFT JOIN sys_dept t4 on t1.dept_id = t4.dept_id
         <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
             t3.production_plan_no = #{productionPlanNo} AND t3.line_number = #{lineNumber}
             <if test="deptId != null ">AND t1.dept_id = #{deptId}</if>
@@ -117,59 +122,73 @@
                 AND t3.product_description like concat('%',#{productDescription},'%')
             </if>
             <if test="lotCode != null  and lotCode != ''">AND t2.lot_code like concat('%',#{lotCode},'%')</if>
-            <if test="technologyVersion != null  and technologyVersion != ''">AND t2.technology_version = #{technologyVersion}</if>
+            <if test="technologyVersion != null  and technologyVersion != ''">AND t2.technology_version =
+                #{technologyVersion}
+            </if>
             <if test="processId != null">AND (select process_id from biz_daywork_item where lot_id = t2.id order by
                 create_time desc limit 1) = #{processId}
             </if>
             <if test="flags != null and flags.size() > 0">
                 AND
                 <foreach collection="flags" item="flag" separator=" OR " open="(" close=")">
-                    <if test="flag != null and flag == 2"> t2.is_amend= 1</if>
-                    <if test="flag != null and flag == 1"> t2.is_waste_recycling= 1</if>
-                    <if test="flag != null and flag == 0"> t2.is_waste= 1</if>
-                    <if test="flag != null and flag == 3"> t2.is_waste= 0 and  t2.is_waste_recycling= 0 and t2.is_amend = 0 </if>
+                    <if test="flag != null and flag == 2">t2.is_amend= 1</if>
+                    <if test="flag != null and flag == 1">t2.is_waste_recycling= 1</if>
+                    <if test="flag != null and flag == 0">t2.is_waste= 1</if>
+                    <if test="flag != null and flag == 3">t2.is_waste= 0 and t2.is_waste_recycling= 0 and t2.is_amend =
+                        0
+                    </if>
                 </foreach>
             </if>
         </trim>
     </select>
-<!--    <select id="getLotWaste" resultType="cn.ezhizao.project.business.domain.BizLotWaste">
-        select * FROM biz_lot_waste t1 where t1.lot_id = #{lotId} AND t1.deleted = 0
-    </select>-->
+    <!--    <select id="getLotWaste" resultType="cn.ezhizao.project.business.domain.BizLotWaste">
+            select * FROM biz_lot_waste t1 where t1.lot_id = #{lotId} AND t1.deleted = 0
+        </select>-->
     <select id="getFirstProcess" resultType="long">
-        SELECT
-            process_id AS firstProcessId
+        SELECT process_id AS firstProcessId
         FROM biz_daywork_item
         WHERE daywork_id = #{dayworkId}
         ORDER BY create_time
         LIMIT 1
     </select>
     <select id="getProcessAlias" resultType="String">
-        SELECT process_alias FROM biz_process t1 LEFT JOIN biz_daywork_item t2 ON t1.id =
-        t2.process_id WHERE t2.daywork_id = #{id} ORDER BY t2.create_time DESC LIMIT 1
+        SELECT process_alias
+        FROM biz_process t1
+                 LEFT JOIN biz_daywork_item t2 ON t1.id =
+                                                  t2.process_id
+        WHERE t2.daywork_id = #{id}
+        ORDER BY t2.create_time DESC
+        LIMIT 1
     </select>
     <select id="getTotalWorkingHours" resultType="long">
-        SELECT sum(working_hours) FROM biz_daywork_item WHERE daywork_id = #{id} AND dept_id = #{deptId} AND deleted = 0
+        SELECT sum(working_hours)
+        FROM biz_daywork_item
+        WHERE daywork_id = #{id}
+          AND dept_id = #{deptId}
+          AND deleted = 0
     </select>
     <select id="getLastLotQuantity" resultType="java.lang.Integer">
-        SELECT last_lot_quantity FROM biz_production_plan_detail WHERE deleted = 0 AND id = #{productionPlanDetailId}
+        SELECT last_lot_quantity
+        FROM biz_production_plan_detail
+        WHERE deleted = 0
+          AND id = #{productionPlanDetailId}
     </select>
     <select id="getRejectNum" resultType="int">
-        SELECT sum(reject_num) rejectNum FROM biz_daywork_item_reject WHERE daywork_item_id = #{id} AND deleted = 0
+        SELECT sum(reject_num) rejectNum
+        FROM biz_daywork_item_reject
+        WHERE daywork_item_id = #{id}
+          AND deleted = 0
     </select>
     <select id="getProcessList" resultType="cn.ezhizao.project.business.domain.BizProcess">
-        SELECT id AS Value,process_alias AS Label
+        SELECT id AS Value, process_alias AS Label
         FROM biz_process
-        WHERE
-            deleted = 0 AND
-            tenant_id !=9 AND
-            id IN (
-                    SELECT process_id
-                    FROM biz_technological_process_detail
-                    WHERE
-                       deleted = 0 AND
-                       tenant_id !=9 AND
-                       technological_process_id = #{technologicalProcessId}
-                  )
+        WHERE deleted = 0
+          AND tenant_id != 9
+          AND id IN (SELECT process_id
+                     FROM biz_technological_process_detail
+                     WHERE deleted = 0
+                       AND tenant_id != 9
+                       AND technological_process_id = #{technologicalProcessId})
     </select>
     <select id="getList" resultMap="BizDayworkResult">
         SELECT
@@ -185,10 +204,10 @@
         t1.is_waste_recycling,
         t1.is_amend
         FROM biz_daywork t1
-            LEFT JOIN biz_lot t3 ON t1.lot_id = t3.id
-            LEFT JOIN biz_production_plan_detail t4 ON t1.production_plan_detail_id = t4.id
-            LEFT JOIN biz_product t2 ON t4.product_id = t2.id
-            LEFT JOIN sys_dept t5 ON t1.dept_id = t5.dept_id
+        LEFT JOIN biz_lot t3 ON t1.lot_id = t3.id
+        LEFT JOIN biz_production_plan_detail t4 ON t1.production_plan_detail_id = t4.id
+        LEFT JOIN biz_product t2 ON t4.product_id = t2.id
+        LEFT JOIN sys_dept t5 ON t1.dept_id = t5.dept_id
 
         <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
             t1.deleted = 0
@@ -216,35 +235,54 @@
         <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
             t1.deleted = 0
             <if test="keyword != null  and keyword != ''">
-                AND (t4.product_description LIKE CONCAT('%', #{keyword}, '%') OR t1.lot_code LIKE CONCAT('%', #{keyword}, '%'))
+                AND (t4.product_description LIKE CONCAT('%', #{keyword}, '%') OR t1.lot_code LIKE CONCAT('%',
+                #{keyword}, '%'))
             </if>
         </trim>
         ORDER BY t1.create_time DESC
     </select>
+
+    <select id="selectScreenDaywork" resultMap="BizDayworkResult" parameterType="list">
+        SELECT
+        d.*,
+        (SELECT status FROM biz_daywork_item WHERE daywork_id=d.id AND deleted=0 ORDER BY create_time DESC LIMIT 1)AS item_status,
+        (SELECT technological_process_detail_id FROM biz_daywork_item WHERE daywork_id=d.id AND deleted=0 ORDER BY create_time DESC LIMIT 1)AS special_process_id
+        FROM
+        biz_daywork d
+        WHERE
+        d.id IN
+        <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        AND
+        d.deleted = 0
+    </select>
+
+
     <select id="getOriginalCarrierList" resultType="cn.ezhizao.project.business.domain.BizDayworkCarrier">
         SELECT t1.*
         FROM biz_daywork_carrier t1
         WHERE t1.daywork_id = #{id}
-        AND  t1.is_changed=0
-        AND t1.deleted = 0
+          AND t1.is_changed = 0
+          AND t1.deleted = 0
     </select>
     <select id="getListForOutsource" resultMap="BizDayworkResultForOutsource">
         SELECT
-            t1.*,
-            t2.product_code,
-            t2.description AS product_description,
-            t3.technology_version,
-            (
-            SELECT
-                GROUP_CONCAT(carrier_code ORDER BY carrier_code SEPARATOR ',')
-            FROM biz_daywork_carrier
-            WHERE daywork_id = t1.id
-            AND  is_changed=0
-            AND deleted = 0
-            ) AS original_carrier
+        t1.*,
+        t2.product_code,
+        t2.description AS product_description,
+        t3.technology_version,
+        (
+        SELECT
+        GROUP_CONCAT(carrier_code ORDER BY carrier_code SEPARATOR ',')
+        FROM biz_daywork_carrier
+        WHERE daywork_id = t1.id
+        AND is_changed=0
+        AND deleted = 0
+        ) AS original_carrier
         FROM biz_daywork t1
-            LEFT JOIN biz_product t2 ON t1.product_id = t2.id
-            LEFT JOIN biz_technological_process t3 ON t1.technological_process_id=t3.id
+        LEFT JOIN biz_product t2 ON t1.product_id = t2.id
+        LEFT JOIN biz_technological_process t3 ON t1.technological_process_id=t3.id
         <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
             t1.deleted = 0
             <if test="tenantId != null and tenantId != 0">AND t1.tenant_id = #{tenantId}</if>
@@ -268,75 +306,88 @@
                 t2.description LIKE concat('%', #{keyword}, '%'))
             </if>
             <if test="isSupplierProducts == 1 and supplierId != null and supplierId != ''">
-                AND t1.product_id IN (SELECT product_id FROM biz_supplier_product WHERE supplier_id=#{supplierId} AND deleted=0)
+                AND t1.product_id IN (SELECT product_id FROM biz_supplier_product WHERE supplier_id=#{supplierId} AND
+                deleted=0)
             </if>
         </trim>
         ORDER BY t1.create_time DESC
     </select>
-<!--    之前遗留暂时注释
-    <select id="getItemList" parameterType="BizDayworkItem" resultMap="BizDayworkItemResult">
-        SELECT
-        DISTINCT
-        t1.id,
-        t1.start_time,
-        t1.end_time,
-        t1.daywork_id,
-        t1.working_hours,
-        t1.status,
-        t1.prod_num,
-        t1.qualified_num,
-        t2.nick_name,
-        t1.process_id,
-        t2.user_name,
-        t4.process_alias ,
-        t4.process_code,
-        t1.equipment_detail_id,
-        t1.equipment_detail_code,
-        t4.technological_process_id
-        FROM biz_daywork_item t1
-        LEFT JOIN sys_user t2 ON t1.user_id = t2.user_id
-        LEFT JOIN biz_technological_process_detail t4 ON t1.technological_process_id = t4.technological_process_id and
-        t1.process_id = t4.process_id
+    <!--    之前遗留暂时注释
+        <select id="getItemList" parameterType="BizDayworkItem" resultMap="BizDayworkItemResult">
+            SELECT
+            DISTINCT
+            t1.id,
+            t1.start_time,
+            t1.end_time,
+            t1.daywork_id,
+            t1.working_hours,
+            t1.status,
+            t1.prod_num,
+            t1.qualified_num,
+            t2.nick_name,
+            t1.process_id,
+            t2.user_name,
+            t4.process_alias ,
+            t4.process_code,
+            t1.equipment_detail_id,
+            t1.equipment_detail_code,
+            t4.technological_process_id
+            FROM biz_daywork_item t1
+            LEFT JOIN sys_user t2 ON t1.user_id = t2.user_id
+            LEFT JOIN biz_technological_process_detail t4 ON t1.technological_process_id = t4.technological_process_id and
+            t1.process_id = t4.process_id
 
-        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
-        t1.deleted = 0 and t1.status &lt; 4
-        <if test="dayworkId != null and dayworkId != 0">AND t1.daywork_id = #{dayworkId}</if>
-            <if test="processId != null">AND t1.process_id = #{processId}</if>
-        <if test="isAmend != null and isAmend != 0">AND t1.form_daywork_item_id !=0 </if>
-        ORDER BY t1.process_step_number ASC ,t1.start_time DESC
+            <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
             t1.deleted = 0 and t1.status &lt; 4
             <if test="dayworkId != null and dayworkId != 0">AND t1.daywork_id = #{dayworkId}</if>
-            <if test="tenantId != null  and tenantId != 0">AND t1.tenant_id = #{tenantId}</if>
-            <if test="processId != null  and processId != 0">AND t1.process_id = #{processId}</if>
-            # and t4.process_id = t1.process_id
-        </trim>
-        ORDER BY t4.process_step_number ASC ,t1.start_time DESC
-</select>-->
+                <if test="processId != null">AND t1.process_id = #{processId}</if>
+            <if test="isAmend != null and isAmend != 0">AND t1.form_daywork_item_id !=0 </if>
+            ORDER BY t1.process_step_number ASC ,t1.start_time DESC
+                t1.deleted = 0 and t1.status &lt; 4
+                <if test="dayworkId != null and dayworkId != 0">AND t1.daywork_id = #{dayworkId}</if>
+                <if test="tenantId != null  and tenantId != 0">AND t1.tenant_id = #{tenantId}</if>
+                <if test="processId != null  and processId != 0">AND t1.process_id = #{processId}</if>
+                # and t4.process_id = t1.process_id
+            </trim>
+            ORDER BY t4.process_step_number ASC ,t1.start_time DESC
+    </select>-->
     <select id="getItemList" parameterType="BizDayworkItem" resultMap="BizDayworkItemResult">
         SELECT
-            t1.*,
-            t2.user_name
+        t1.*,
+        t2.user_name
         FROM biz_daywork_item t1
-            LEFT JOIN sys_user t2 ON t1.user_id = t2.user_id
+        LEFT JOIN sys_user t2 ON t1.user_id = t2.user_id
         <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
             t1.deleted = 0 AND t1.status &lt; 4
             <if test="dayworkId != null and dayworkId != 0">AND t1.daywork_id = #{dayworkId}</if>
-            <if test="isAmend != null and isAmend != 0">AND t1.form_daywork_item_id !=0 </if>
+            <if test="isAmend != null and isAmend != 0">AND t1.form_daywork_item_id !=0</if>
             <if test="processId != null  and processId != 0">AND t1.process_id = #{processId}</if>
             ORDER BY t1.process_step_number ASC ,t1.create_time ASC
         </trim>
     </select>
     <select id="getProcessName" resultType="java.lang.String">
-        select process_alias from biz_technological_process_detail where deleted = 0 and id = #{technologicalProcessDetailId}
+        select process_alias
+        from biz_technological_process_detail
+        where deleted = 0
+          and id = #{technologicalProcessDetailId}
     </select>
     <select id="getProductDescription" resultType="java.lang.String">
-        select product_description from biz_production_plan_detail where deleted = 0 and id = #{productionPlanDetailId}
+        select product_description
+        from biz_production_plan_detail
+        where deleted = 0
+          and id = #{productionPlanDetailId}
     </select>
     <select id="getTechnologyVersion" resultType="java.lang.String">
-        select technology_version from biz_lot where deleted = 0 and id = #{lotId}
+        select technology_version
+        from biz_lot
+        where deleted = 0
+          and id = #{lotId}
     </select>
     <select id="getLotCode" resultType="java.lang.String">
-        select lot_code from biz_lot where deleted = 0 and id = #{lotId}
+        select lot_code
+        from biz_lot
+        where deleted = 0
+          and id = #{lotId}
     </select>
 
     <select id="listReportItem" parameterType="BizDayworkItem" resultMap="BizDayworkItemResult">
@@ -349,7 +400,7 @@
         GROUP_CONCAT(carrier_code ORDER BY carrier_code SEPARATOR ',')
         FROM biz_daywork_carrier
         WHERE daywork_id = t1.daywork_id
-        AND  is_changed=0
+        AND is_changed=0
         AND deleted = 0
         ) AS original_carrier
         FROM biz_daywork_item t1
@@ -359,13 +410,21 @@
             t1.deleted = 0 AND t1.status &lt; 4
             <if test="dayworkId != null and dayworkId != 0">AND t1.daywork_id = #{dayworkId}</if>
             <if test="deptId != null and deptId != 0">AND t1.dept_id = #{deptId}</if>
-            <if test="isAmend != null and isAmend != 0">AND t1.form_daywork_item_id !=0 </if>
+            <if test="isAmend != null and isAmend != 0">AND t1.form_daywork_item_id !=0</if>
             <if test="startTime != null ">AND t1.end_time &gt;= #{startTime}</if>
             <if test="endTime != null ">AND t1.end_time &lt;= #{endTime}</if>
-            <if test="productDescription != null and productDescription != ''">AND t1.production_plan_detail_id in (select id from biz_production_plan_detail where deleted = 0 and product_description  LIKE CONCAT('%', #{productDescription}, '%'))</if>
-            <if test="lotCode != null and lotCode != ''">AND t1.lot_id in (select id from biz_lot where deleted = 0 and lot_code  LIKE CONCAT('%', #{lotCode}, '%'))</if>
-            <if test="nickName != null and nickName != ''">AND t1.nick_name  LIKE CONCAT('%', #{nickName}, '%')</if>
-            <if test="originalCarrier != null and originalCarrier != ''">AND t1.daywork_id in (select daywork_id from biz_daywork_carrier where deleted = 0 AND  is_changed=0 and carrier_code LIKE CONCAT('%', #{originalCarrier}, '%'))  </if>
+            <if test="productDescription != null and productDescription != ''">AND t1.production_plan_detail_id in
+                (select id from biz_production_plan_detail where deleted = 0 and product_description LIKE CONCAT('%',
+                #{productDescription}, '%'))
+            </if>
+            <if test="lotCode != null and lotCode != ''">AND t1.lot_id in (select id from biz_lot where deleted = 0 and
+                lot_code LIKE CONCAT('%', #{lotCode}, '%'))
+            </if>
+            <if test="nickName != null and nickName != ''">AND t1.nick_name LIKE CONCAT('%', #{nickName}, '%')</if>
+            <if test="originalCarrier != null and originalCarrier != ''">AND t1.daywork_id in (select daywork_id from
+                biz_daywork_carrier where deleted = 0 AND is_changed=0 and carrier_code LIKE CONCAT('%',
+                #{originalCarrier}, '%'))
+            </if>
             <if test="processId != null  and processId != 0">AND t1.process_id = #{processId}</if>
             ORDER BY t1.lot_id, t1.end_time DESC
         </trim>
@@ -405,8 +464,10 @@
         biz_daywork_item.create_time DESC
         LIMIT 1
         ) AS processAlias,
-        ( SELECT place FROM biz_daywork_item WHERE biz_daywork_item.daywork_id = t1.id ORDER BY biz_daywork_item.create_time DESC LIMIT 1 ) AS place,
-        ( SELECT turnover_area FROM biz_daywork_item WHERE biz_daywork_item.daywork_id = t1.id ORDER BY biz_daywork_item.create_time DESC LIMIT 1 ) AS turnoverArea,
+        ( SELECT place FROM biz_daywork_item WHERE biz_daywork_item.daywork_id = t1.id ORDER BY
+        biz_daywork_item.create_time DESC LIMIT 1 ) AS place,
+        ( SELECT turnover_area FROM biz_daywork_item WHERE biz_daywork_item.daywork_id = t1.id ORDER BY
+        biz_daywork_item.create_time DESC LIMIT 1 ) AS turnoverArea,
         (
         SELECT
         GROUP_CONCAT( carrier_code ORDER BY carrier_code SEPARATOR ',' )
@@ -443,21 +504,22 @@
                 AND biz_daywork_carrier.is_changed = 0
                 AND biz_daywork_carrier.deleted = 0
                 and biz_daywork_carrier.carrier_code like concat('%',#{carrierCode},'%')
-                )</if>
+                )
+            </if>
         </trim>
     </select>
 
-<!--    -->
+    <!--    -->
     <select id="getItemListForOutsource" parameterType="BizDayworkItem" resultMap="BizDayworkItemResultForOutsource">
         SELECT
-            t1.*
+        t1.*
         FROM biz_daywork_item t1
-            LEFT JOIN sys_dept t2 ON t1.dept_id=t2.dept_id
-            LEFT JOIN biz_daywork t3 ON t1.daywork_id = t3.id
+        LEFT JOIN sys_dept t2 ON t1.dept_id=t2.dept_id
+        LEFT JOIN biz_daywork t3 ON t1.daywork_id = t3.id
         <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
             t1.deleted = 0 AND
             t1.status >= 4 AND
-#             查找创建时间最新的一条
+            # 查找创建时间最新的一条
             t1.create_time = (
             SELECT MAX(t5.create_time)
             FROM biz_daywork_item t5
@@ -465,7 +527,8 @@
             )
             <if test="deptCode != null and deptCode != ''">AND t2.dept_code = #{deptCode}</if>
             <if test="isSupplierProducts != null and isSupplierProducts != 1 ">
-                AND t3.product_id IN (SELECT product_id FROM biz_supplier_product WHERE supplier_id=#{supplierId} AND deleted=0)
+                AND t3.product_id IN (SELECT product_id FROM biz_supplier_product WHERE supplier_id=#{supplierId} AND
+                deleted=0)
             </if>
 
             ORDER BY t1.process_step_number ASC
@@ -474,28 +537,24 @@
 
 
     <select id="getDeptList" resultType="cn.ezhizao.project.system.domain.SysDept">
-        SELECT DISTINCT
-            t3.dept_id AS Value,
-            t3.dept_name AS Label
+        SELECT DISTINCT t3.dept_id   AS Value,
+                        t3.dept_name AS Label
         FROM biz_daywork t1
-            LEFT JOIN biz_production_plan_detail t2 ON t2.id = t1.production_plan_detail_id
-            LEFT JOIN sys_dept t3 ON t1.dept_id = t3.dept_id
-        WHERE
-            t2.production_plan_no = #{productionPlanNo} AND
-            t2.line_number = #{lineNumber}
+                 LEFT JOIN biz_production_plan_detail t2 ON t2.id = t1.production_plan_detail_id
+                 LEFT JOIN sys_dept t3 ON t1.dept_id = t3.dept_id
+        WHERE t2.production_plan_no = #{productionPlanNo}
+          AND t2.line_number = #{lineNumber}
     </select>
 
     <select id="getDayworkProcessList" resultType="cn.ezhizao.project.business.domain.BizProcess">
-        SELECT DISTINCT
-            t3.id AS Value,
-            t3.process_alias AS Label
+        SELECT DISTINCT t3.id            AS Value,
+                        t3.process_alias AS Label
         FROM biz_daywork t1
-            LEFT JOIN biz_daywork_item t2 ON t1.id = t2.daywork_id
-            LEFT JOIN biz_process t3 ON t2.process_id = t3.id
-        WHERE
-            t1.id = #{id} AND
-            t2.dept_id = #{deptId} AND
-            t2.status &lt; 4
+                 LEFT JOIN biz_daywork_item t2 ON t1.id = t2.daywork_id
+                 LEFT JOIN biz_process t3 ON t2.process_id = t3.id
+        WHERE t1.id = #{id}
+          AND t2.dept_id = #{deptId}
+          AND t2.status &lt; 4
         ORDER BY t2.create_time
     </select>
 

+ 15 - 0
src/main/resources/mybatis/business/BizLotMapper.xml

@@ -57,6 +57,21 @@
     <select id="getProductShaftCategoryName" resultType="String">
         select product_shaft_category_name from biz_technological_process t1 where t1.id = #{technological_process_id}
     </select>
+
+    <select id="specialGetLotList" parameterType="BizLot" resultMap="BizLotResult">
+        SELECT * FROM biz_lot
+        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
+            deleted = 0
+            AND id NOT IN(select lot_id from biz_daywork where biz_daywork.deleted = 0)
+            <if test="id != null and id != ''"> AND id = #{id}</if>
+            <if test="lotCode != null  and lotCode != ''"> AND lot_code = #{lotCode}</if>
+            <if test="productionPlanDetailId != null and productionPlanDetailId!=''"> AND production_plan_detail_id = #{productionPlanDetailId}</if>
+            <if test="productCode != null  and productCode != ''"> AND product_code = #{productCode}</if>
+            <if test="specification != null  and specification != ''"> AND specification = #{specification}</if>
+            <if test="drawingNumber != null  and drawingNumber != ''"> AND drawing_number = #{drawingNumber}</if>
+        </trim>
+    </select>
+
     <select id="getList" parameterType="BizLot" resultMap="BizLotResult">
         SELECT * FROM biz_lot
         <trim prefix=" WHERE" suffix="" suffixOverrides="AND">

+ 24 - 0
src/main/resources/mybatis/business/BizProductionPlanDetailMapper.xml

@@ -221,6 +221,30 @@
         UPDATE biz_production_plan_detail SET lot_code_status_code = #{lotCodeStatusCode} WHERE id = #{id}
     </update>
 
+    <select id="selectSpecialFirstProductDetail" resultMap="BizProductionPlanDetailResult">
+        SELECT * FROM biz_production_plan_detail
+        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
+            deleted=0 AND
+            id IN (
+            SELECT production_plan_detail_id FROM biz_production_plan_detail_sub_detail
+            <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
+                deleted=0
+                <if test="deptId != null">
+                    AND dept_id = #{deptId}
+                </if>
+            </trim>
+            )
+            <if test="productDescription != null and productDescription !=''">
+                AND product_description LIKE CONCAT('%', #{productDescription}, '%')
+            </if>
+            <if test="productionPlanNo != null and productionPlanNo !=''">
+                 AND production_plan_no LIKE CONCAT('%',#{productionPlanNo}, '%')
+            </if>
+        </trim>
+    </select>
+
+
+
     <delete id="physicalDelete">
         DELETE FROM biz_production_plan_detail
         <trim prefix=" WHERE" suffix="" suffixOverrides="AND">