瀏覽代碼

feat:勾选导出财务对账单,订单通知单状态bug修复,销售出库列表动态跨行

韩帛霖 1 年之前
父節點
當前提交
d2a6418972

+ 17 - 12
zkqy-custom-business/src/main/java/com/zkqy/business/controller/ProductInvoiceController.java

@@ -101,8 +101,7 @@ public class ProductInvoiceController extends BaseController {
     @Log(title = "产品发货单", businessType = BusinessType.DELETE)
     @DeleteMapping("/{ids}")
     @ApiOperation(value = "删除产品发货单")
-    public AjaxResult remove(@PathVariable List<Long> ids)
-    {
+    public AjaxResult remove(@PathVariable List<Long> ids) {
         return toAjax(productInvoiceService.deleteProductInvoiceByIds(ids));
     }
 
@@ -145,16 +144,22 @@ public class ProductInvoiceController extends BaseController {
 
     @PostMapping("/importFinancialStatement")
     public void importDataOutboundDetails(HttpServletResponse response, ProductInvoiceFinancialExportVo productInvoiceFinancialExportVo) {
-        // 查询需要需要导出的待物对账单
-        List<ProductInvoiceFinancialExportVo> list = productInvoiceService.financialStatementExportList(productInvoiceFinancialExportVo);
-        if (list.size() != 0) {
-            ExcelUtil<ProductInvoiceFinancialExportVo> util = new ExcelUtil<ProductInvoiceFinancialExportVo>(ProductInvoiceFinancialExportVo.class);
-            Map<Integer, String> map = new HashMap<>();
-            map.put(0, "销售客户汇总");
-            List<Map<Integer, String>> mapList = new ArrayList<>();
-            mapList.add(map);
-            util.addCustomHeaderData(mapList);
-            util.exportExcel(response, list, "出库明细");
+        List<ProductInvoiceFinancialExportVo> list = new ArrayList<>();
+        if (productInvoiceFinancialExportVo.getIds() != null && productInvoiceFinancialExportVo.getIds().length != 0) {
+            ProductInvoiceFinancialExportVo productInvoiceFinancialExportVo1 = new ProductInvoiceFinancialExportVo();
+            productInvoiceFinancialExportVo1.setIds(productInvoiceFinancialExportVo.getIds());
+            productInvoiceFinancialExportVo1.setOrderType(productInvoiceFinancialExportVo.getOrderType());
+            list.addAll(productInvoiceService.financialStatementExportList(productInvoiceFinancialExportVo1));
+        } else {
+            // 查询需要需要导出的待物对账单
+            list.addAll(productInvoiceService.financialStatementExportList(productInvoiceFinancialExportVo));
         }
+        ExcelUtil<ProductInvoiceFinancialExportVo> util = new ExcelUtil<ProductInvoiceFinancialExportVo>(ProductInvoiceFinancialExportVo.class);
+        Map<Integer, String> map = new HashMap<>();
+        map.put(0, "销售客户汇总");
+        List<Map<Integer, String>> mapList = new ArrayList<>();
+        mapList.add(map);
+        util.addCustomHeaderData(mapList);
+        util.exportExcel(response, list, "出库明细");
     }
 }

+ 41 - 7
zkqy-custom-business/src/main/java/com/zkqy/business/domain/vo/ProductInvoiceFinancialExportVo.java

@@ -3,7 +3,11 @@ package com.zkqy.business.domain.vo;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.zkqy.common.annotation.Excel;
 import com.zkqy.common.core.domain.BaseEntity;
+import jdk.jfr.Timestamp;
+import org.springframework.format.annotation.DateTimeFormat;
 
+import java.time.LocalDate;
+import java.util.Arrays;
 import java.util.Date;
 
 /**
@@ -58,15 +62,27 @@ public class ProductInvoiceFinancialExportVo extends BaseEntity {
      */
     private String noticeNumber;
 
+    /**
+     * 合同号
+     */
+    private String saleNo;
+
     /**
      * 客户编号
      */
     private Long customerId;
 
     /**
-     * 通知日期
+     * 下单日期
      */
-    private Date noticeDate;
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    private LocalDate saleDate;
+
+    /**
+     * 勾选导出
+     */
+    private Integer[] ids;
 
     @Override
     public String toString() {
@@ -80,8 +96,10 @@ public class ProductInvoiceFinancialExportVo extends BaseEntity {
         sb.append(", suttle='").append(suttle).append('\'');
         sb.append(", orderType='").append(orderType).append('\'');
         sb.append(", noticeNumber='").append(noticeNumber).append('\'');
+        sb.append(", saleNo='").append(saleNo).append('\'');
         sb.append(", customerId=").append(customerId);
-        sb.append(", noticeDate=").append(noticeDate);
+        sb.append(", saleDate=").append(saleDate);
+        sb.append(", ids=").append(Arrays.toString(ids));
         sb.append('}');
         return sb.toString();
     }
@@ -158,6 +176,14 @@ public class ProductInvoiceFinancialExportVo extends BaseEntity {
         this.noticeNumber = noticeNumber;
     }
 
+    public String getSaleNo() {
+        return saleNo;
+    }
+
+    public void setSaleNo(String saleNo) {
+        this.saleNo = saleNo;
+    }
+
     public Long getCustomerId() {
         return customerId;
     }
@@ -166,11 +192,19 @@ public class ProductInvoiceFinancialExportVo extends BaseEntity {
         this.customerId = customerId;
     }
 
-    public Date getNoticeDate() {
-        return noticeDate;
+    public LocalDate getSaleDate() {
+        return saleDate;
+    }
+
+    public void setSaleDate(LocalDate saleDate) {
+        this.saleDate = saleDate;
+    }
+
+    public Integer[] getIds() {
+        return ids;
     }
 
-    public void setNoticeDate(Date noticeDate) {
-        this.noticeDate = noticeDate;
+    public void setIds(Integer[] ids) {
+        this.ids = ids;
     }
 }

+ 7 - 0
zkqy-custom-business/src/main/java/com/zkqy/business/mapper/ProductInvoiceMapper.java

@@ -44,6 +44,13 @@ public interface ProductInvoiceMapper {
      * @return 结果
      */
     public int updateProductInvoice(ProductInvoice productInvoice);
+    /**
+     * 修改产品发货单
+     *
+     * @param productInvoice 产品发货单
+     * @return 结果
+     */
+    public int updateProductInvoiceBySaleNo(ProductInvoice productInvoice);
 
     /**
      * 删除产品发货单

+ 7 - 0
zkqy-custom-business/src/main/java/com/zkqy/business/mapper/SaleProductsMapper.java

@@ -85,6 +85,13 @@ public interface SaleProductsMapper
      * @return
      */
     public int updateSaleProductBatch(List<SaleProducts> saleProducts);
+
+    /**
+     * 批量修改线号
+     * @param saleProduct
+     * @return
+     */
+    public int updateSaleProduct(SaleProducts saleProduct);
     /**
      * 删除销售产品
      * 

+ 84 - 90
zkqy-custom-business/src/main/java/com/zkqy/business/service/impl/AmmunitionPlanInformationIntermediateTableServiceImpl.java

@@ -19,13 +19,12 @@ import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 加弹计划信息Service业务层处理
- * 
+ *
  * @author zkqy
  * @date 2024-04-01
  */
 @Service
-public class AmmunitionPlanInformationIntermediateTableServiceImpl implements IAmmunitionPlanInformationIntermediateTableService 
-{
+public class AmmunitionPlanInformationIntermediateTableServiceImpl implements IAmmunitionPlanInformationIntermediateTableService {
 
     @Autowired
     private AmmunitionPlanInformationIntermediateTableMapper ammunitionPlanInformationIntermediateTableMapper;
@@ -37,7 +36,7 @@ public class AmmunitionPlanInformationIntermediateTableServiceImpl implements IA
     private ProductionLineMapper productionLineMapper;
 
     @Autowired
-    private  DetailsOfTheRefuelingPlanServiceImpl detailsOfTheRefuelingPlanService;
+    private DetailsOfTheRefuelingPlanServiceImpl detailsOfTheRefuelingPlanService;
 
     @Autowired
     private SaleProductsMapper saleProductsMapper;
@@ -50,26 +49,25 @@ public class AmmunitionPlanInformationIntermediateTableServiceImpl implements IA
      */
     @Override
     @Transactional
-    public int insertAmmunitionPlanInformationIntermediateTable(AmmunitionPlanInformationIntermediateTable ammunitionPlanInformationIntermediateTable)
-    {
-        List<SaleProducts> saleProductsList=new ArrayList<>();
+    public int insertAmmunitionPlanInformationIntermediateTable(AmmunitionPlanInformationIntermediateTable ammunitionPlanInformationIntermediateTable) {
+        List<SaleProducts> saleProductsList = new ArrayList<>();
         //改批号,和产线号
-        ammunitionPlanInformationIntermediateTable.getDetailsOfTheRefuelingPlans().forEach(item->{
+        ammunitionPlanInformationIntermediateTable.getDetailsOfTheRefuelingPlans().forEach(item -> {
             //改产品的线号
-            SaleProducts saleProducts=new SaleProducts();
+            SaleProducts saleProducts = new SaleProducts();
             item.setMacId(ammunitionPlanInformationIntermediateTable.getMacId());//机台id
             saleProducts.setId(Long.valueOf(item.getProductId())); //
             saleProducts.setProductionLineNo(item.getMacId()); //机台号
-            if(item.getPlanStatus().equals("待机")){
-               item.setPlanStatus("0");
+            if (item.getPlanStatus().equals("待机")) {
+                item.setPlanStatus("0");
             }
-            if(item.getPlanStatus().equals("上机")){
+            if (item.getPlanStatus().equals("上机")) {
                 item.setPlanStatus("1");
             }
-            if(item.getPlanStatus().equals("停机")){
+            if (item.getPlanStatus().equals("停机")) {
                 item.setPlanStatus("2");
             }
-            if(item.getPlanStatus().equals("完成")){
+            if (item.getPlanStatus().equals("完成")) {
                 item.setPlanStatus("3");
             }
             saleProducts.setOnBoardState(item.getPlanStatus()); //产品状态
@@ -84,7 +82,9 @@ public class AmmunitionPlanInformationIntermediateTableServiceImpl implements IA
             item.setCreateTime(new Date());
         });
         //更新产线
-        int i2 = saleProductsMapper.updateSaleProductBatch(saleProductsList);
+        saleProductsList.forEach(item -> {
+            saleProductsMapper.updateSaleProduct(item);
+        });
         //插入计划数据
         int i3 = detailsOfTheRefuelingPlanService.insertBatchDetailsOfTheRefuelingPlan(ammunitionPlanInformationIntermediateTable.getDetailsOfTheRefuelingPlans());
         return i3;
@@ -92,35 +92,33 @@ public class AmmunitionPlanInformationIntermediateTableServiceImpl implements IA
 
     /**
      * 查询加弹计划信息
-     * 
+     *
      * @param id 加弹计划信息主键
      * @return 加弹计划信息
      */
     @Override
-    public AmmunitionPlanInformationIntermediateTable selectAmmunitionPlanInformationIntermediateTableById(Long id)
-    {
+    public AmmunitionPlanInformationIntermediateTable selectAmmunitionPlanInformationIntermediateTableById(Long id) {
         return ammunitionPlanInformationIntermediateTableMapper.selectAmmunitionPlanInformationIntermediateTableById(id);
     }
 
     /**
      * 查询加弹计划信息列表
-     * 
+     *
      * @param ammunitionPlanInformationIntermediateTablVo 加弹计划信息
      * @return 加弹计划信息
      */
     @Override
-    public List<AmmunitionPlanInformationIntermediateTableRVo>  selectAmmunitionPlanInformationIntermediateTableList(AmmunitionPlanInformationIntermediateTableVo ammunitionPlanInformationIntermediateTablVo)
-    {
+    public List<AmmunitionPlanInformationIntermediateTableRVo> selectAmmunitionPlanInformationIntermediateTableList(AmmunitionPlanInformationIntermediateTableVo ammunitionPlanInformationIntermediateTablVo) {
         //查询产线信息
-        ProductionLine productionLine=new ProductionLine();
+        ProductionLine productionLine = new ProductionLine();
         productionLine.setProductionLineDepartment("加弹部");
         productionLine.setProductionLineWorkshop("南车间");
         //部门
-        if(StringUtils.isNotNull(ammunitionPlanInformationIntermediateTablVo.getProductionLineDepartment())){
+        if (StringUtils.isNotNull(ammunitionPlanInformationIntermediateTablVo.getProductionLineDepartment())) {
             productionLine.setProductionLineDepartment(ammunitionPlanInformationIntermediateTablVo.getProductionLineDepartment());
         }
         //车间
-        if(StringUtils.isNotNull(ammunitionPlanInformationIntermediateTablVo.getProductionLineWorkshop())){
+        if (StringUtils.isNotNull(ammunitionPlanInformationIntermediateTablVo.getProductionLineWorkshop())) {
             productionLine.setProductionLineWorkshop(ammunitionPlanInformationIntermediateTablVo.getProductionLineWorkshop());
         }
         List<ProductionLine> productionLines = productionLineMapper.selectProductionLineList(productionLine);
@@ -129,39 +127,39 @@ public class AmmunitionPlanInformationIntermediateTableServiceImpl implements IA
                 .sorted(Comparator.comparing(ProductionLine::getSort))
                 .collect(Collectors.toList());
         //创建产线对象
-        List<AmmunitionPlanInformationIntermediateTableRVo> list=new ArrayList<>();
+        List<AmmunitionPlanInformationIntermediateTableRVo> list = new ArrayList<>();
         //循环固定死的产线
         sortedList.stream().forEach(item -> {
             //A面待生产
-            DetailsOfTheRefuelingPlan detailsOfTheRefuelingPlan2=new DetailsOfTheRefuelingPlan();
+            DetailsOfTheRefuelingPlan detailsOfTheRefuelingPlan2 = new DetailsOfTheRefuelingPlan();
             detailsOfTheRefuelingPlan2.setMacId(item.getId().toString()); //产线id
             detailsOfTheRefuelingPlan2.setPlanStatus("0");
             detailsOfTheRefuelingPlan2.setProductType("A面");
             List<DetailsOfTheRefuelingPlan> detailsOfTheRefuelingPlans2 = detailsOfTheRefuelingPlanMapper.selectDetailsOfTheRefuelingPlanList(detailsOfTheRefuelingPlan2);
             //B面的待生产
-            DetailsOfTheRefuelingPlan detailsOfTheRefuelingPlan3=new DetailsOfTheRefuelingPlan();
+            DetailsOfTheRefuelingPlan detailsOfTheRefuelingPlan3 = new DetailsOfTheRefuelingPlan();
             detailsOfTheRefuelingPlan3.setMacId(item.getId().toString()); //产线id
             detailsOfTheRefuelingPlan3.setPlanStatus("0");
             detailsOfTheRefuelingPlan3.setProductType("B面");
             List<DetailsOfTheRefuelingPlan> detailsOfTheRefuelingPlans3 = detailsOfTheRefuelingPlanMapper.selectDetailsOfTheRefuelingPlanList(detailsOfTheRefuelingPlan3);
-            System.err.println(detailsOfTheRefuelingPlans3.size()+"dddd");
+            System.err.println(detailsOfTheRefuelingPlans3.size() + "dddd");
             //查询产线A面上机的
-            DetailsOfTheRefuelingPlan Asj=new DetailsOfTheRefuelingPlan();
+            DetailsOfTheRefuelingPlan Asj = new DetailsOfTheRefuelingPlan();
             Asj.setMacId(item.getId().toString());//产线id
             Asj.setPlanStatus("1");
             Asj.setProductType("A面");
             List<DetailsOfTheRefuelingPlan> AList = detailsOfTheRefuelingPlanMapper.selectDetailsOfTheRefuelingPlanList(Asj);
             //A上机数据
-            if(AList.size()>0){
+            if (AList.size() > 0) {
                 //A面上机产品
-                AList.stream().forEach(item1->{
+                AList.stream().forEach(item1 -> {
                     //拿到了某个车间的所有产线
-                    AmmunitionPlanInformationIntermediateTableRVo rs1=new AmmunitionPlanInformationIntermediateTableRVo();
+                    AmmunitionPlanInformationIntermediateTableRVo rs1 = new AmmunitionPlanInformationIntermediateTableRVo();
                     rs1.setMachineId(item.getProductionLineNo());//产线号
                     rs1.setMacId(item.getId().toString());//产线id
-                    AmmunitionPlanInformationIntermediateTableRVo ammunitionPlanInformationIntermediateTableRVo=new AmmunitionPlanInformationIntermediateTableRVo();
-                    BeanUtils.copyProperties(item1,ammunitionPlanInformationIntermediateTableRVo);
-                    BeanUtils.copyProperties(item1,rs1);
+                    AmmunitionPlanInformationIntermediateTableRVo ammunitionPlanInformationIntermediateTableRVo = new AmmunitionPlanInformationIntermediateTableRVo();
+                    BeanUtils.copyProperties(item1, ammunitionPlanInformationIntermediateTableRVo);
+                    BeanUtils.copyProperties(item1, rs1);
                     rs1.setCurrentLotNumber(item1.getCurrentLotNumber().toString());
                     //当前产线A面待生产
                     String collect = detailsOfTheRefuelingPlans2.stream().map(plan -> plan.getCurrentColorCode() + "-(" + plan.getCurrentLotNumber() + ")").collect(Collectors.joining(","));
@@ -170,24 +168,24 @@ public class AmmunitionPlanInformationIntermediateTableServiceImpl implements IA
                 });
             }
             //A面有没有停机的
-            DetailsOfTheRefuelingPlan detailsOfTheRefuelingPlan4=new DetailsOfTheRefuelingPlan();
+            DetailsOfTheRefuelingPlan detailsOfTheRefuelingPlan4 = new DetailsOfTheRefuelingPlan();
             detailsOfTheRefuelingPlan4.setMacId(item.getId().toString());
             detailsOfTheRefuelingPlan4.setPlanStatus("2");
             detailsOfTheRefuelingPlan4.setProductType("A面");
             List<DetailsOfTheRefuelingPlan> detailsOfTheRefuelingPlans4 = detailsOfTheRefuelingPlanMapper.selectDetailsOfTheRefuelingPlanList(detailsOfTheRefuelingPlan4);
-            if(detailsOfTheRefuelingPlans4.size()>0){
+            if (detailsOfTheRefuelingPlans4.size() > 0) {
                 //所有停机的数据不好含字段为停机的数据
                 List<DetailsOfTheRefuelingPlan> tjSize = detailsOfTheRefuelingPlans4.stream().filter(item1 -> !item1.getTimestampRandomCode().equals("停机")).collect(Collectors.toList());
                 //不需要假数据来顶替,因为真实数据有停机的出现
-                if(tjSize.size()>0){
-                    tjSize.stream().forEach(item1->{
+                if (tjSize.size() > 0) {
+                    tjSize.stream().forEach(item1 -> {
                         //拿到了某个车间的所有产线
-                        AmmunitionPlanInformationIntermediateTableRVo rs1=new AmmunitionPlanInformationIntermediateTableRVo();
+                        AmmunitionPlanInformationIntermediateTableRVo rs1 = new AmmunitionPlanInformationIntermediateTableRVo();
                         rs1.setMachineId(item.getProductionLineNo());//产线号
                         rs1.setMacId(item.getId().toString());//产线iD
                         rs1.setProductType("A面");
-                        BeanUtils.copyProperties(item1,rs1);
-                        rs1.setPlannedEndTime(rs1.getPlannedEndTime()+"停机");
+                        BeanUtils.copyProperties(item1, rs1);
+                        rs1.setPlannedEndTime(rs1.getPlannedEndTime() + "停机");
                         rs1.setCurrentLotNumber(item1.getCurrentLotNumber().toString());
                         //当前产线A面待生产
                         String collect = detailsOfTheRefuelingPlans2.stream().map(plan -> plan.getCurrentColorCode() + "-(" + plan.getCurrentLotNumber() + ")").collect(Collectors.joining(","));
@@ -196,11 +194,11 @@ public class AmmunitionPlanInformationIntermediateTableServiceImpl implements IA
                     });
                 }
                 //停机==0 上机也等于0
-                if(tjSize.size()==0&&AList.size()==0){
+                if (tjSize.size() == 0 && AList.size() == 0) {
                     //假数据停机
-                    detailsOfTheRefuelingPlans4.stream().forEach(item1->{
+                    detailsOfTheRefuelingPlans4.stream().forEach(item1 -> {
                         //拿到了某个车间的所有产线
-                        AmmunitionPlanInformationIntermediateTableRVo rs1=new AmmunitionPlanInformationIntermediateTableRVo();
+                        AmmunitionPlanInformationIntermediateTableRVo rs1 = new AmmunitionPlanInformationIntermediateTableRVo();
                         rs1.setMachineId(item.getProductionLineNo());//产线号
                         rs1.setMacId(item.getId().toString());//产线iD
                         rs1.setProductType("A面");
@@ -213,8 +211,8 @@ public class AmmunitionPlanInformationIntermediateTableServiceImpl implements IA
                 }
             }
             //A面有没有待机的
-            if(detailsOfTheRefuelingPlans2.size()>0&&AList.size()<=0&&detailsOfTheRefuelingPlans4.size()<=0){
-                AmmunitionPlanInformationIntermediateTableRVo rs1=new AmmunitionPlanInformationIntermediateTableRVo();
+            if (detailsOfTheRefuelingPlans2.size() > 0 && AList.size() <= 0 && detailsOfTheRefuelingPlans4.size() <= 0) {
+                AmmunitionPlanInformationIntermediateTableRVo rs1 = new AmmunitionPlanInformationIntermediateTableRVo();
                 rs1.setMachineId(item.getProductionLineNo());//产线号
                 rs1.setMacId(item.getId().toString());//产线iD
                 String collect = detailsOfTheRefuelingPlans2.stream().map(plan -> plan.getCurrentColorCode() + "-(" + plan.getCurrentLotNumber() + ")").collect(Collectors.joining(","));
@@ -223,30 +221,30 @@ public class AmmunitionPlanInformationIntermediateTableServiceImpl implements IA
                 list.add(rs1);
             }
             //A待机没有、停机没有、上机也没有
-            if(detailsOfTheRefuelingPlans2.size()<=0&&detailsOfTheRefuelingPlans4.size()<=0&&AList.size()<=0){
-                    AmmunitionPlanInformationIntermediateTableRVo rs1=new AmmunitionPlanInformationIntermediateTableRVo();
-                    rs1.setMachineId(item.getProductionLineNo());//产线号
-                    rs1.setMacId(item.getId().toString());//产线iD
-                    rs1.setProductType("A面");
-                    list.add(rs1);
+            if (detailsOfTheRefuelingPlans2.size() <= 0 && detailsOfTheRefuelingPlans4.size() <= 0 && AList.size() <= 0) {
+                AmmunitionPlanInformationIntermediateTableRVo rs1 = new AmmunitionPlanInformationIntermediateTableRVo();
+                rs1.setMachineId(item.getProductionLineNo());//产线号
+                rs1.setMacId(item.getId().toString());//产线iD
+                rs1.setProductType("A面");
+                list.add(rs1);
             }
 
             //查询B面上机的
-            DetailsOfTheRefuelingPlan Bsj=new DetailsOfTheRefuelingPlan();
+            DetailsOfTheRefuelingPlan Bsj = new DetailsOfTheRefuelingPlan();
             Bsj.setMacId(item.getId().toString());
             Bsj.setPlanStatus("1");
             Bsj.setProductType("B面");
             List<DetailsOfTheRefuelingPlan> BList = detailsOfTheRefuelingPlanMapper.selectDetailsOfTheRefuelingPlanList(Bsj);
-            if(BList.size()>0){
+            if (BList.size() > 0) {
                 //B面上机产品
-                BList.stream().forEach(item1->{
+                BList.stream().forEach(item1 -> {
                     //拿到了某个车间的所有产线
-                    AmmunitionPlanInformationIntermediateTableRVo rs1=new AmmunitionPlanInformationIntermediateTableRVo();
+                    AmmunitionPlanInformationIntermediateTableRVo rs1 = new AmmunitionPlanInformationIntermediateTableRVo();
                     rs1.setMachineId(item.getProductionLineNo());//产线号
                     rs1.setMacId(item.getId().toString()); //产线id
-                    AmmunitionPlanInformationIntermediateTableRVo ammunitionPlanInformationIntermediateTableRVo=new AmmunitionPlanInformationIntermediateTableRVo();
-                    BeanUtils.copyProperties(item1,ammunitionPlanInformationIntermediateTableRVo);
-                    BeanUtils.copyProperties(item1,rs1);
+                    AmmunitionPlanInformationIntermediateTableRVo ammunitionPlanInformationIntermediateTableRVo = new AmmunitionPlanInformationIntermediateTableRVo();
+                    BeanUtils.copyProperties(item1, ammunitionPlanInformationIntermediateTableRVo);
+                    BeanUtils.copyProperties(item1, rs1);
                     rs1.setCurrentLotNumber(item1.getCurrentLotNumber().toString());
                     //当前产线b面待生产
                     String collect = detailsOfTheRefuelingPlans3.stream().map(plan -> plan.getCurrentColorCode() + "-(" + plan.getCurrentLotNumber() + ")").collect(Collectors.joining(","));
@@ -255,29 +253,29 @@ public class AmmunitionPlanInformationIntermediateTableServiceImpl implements IA
                 });
             }
             //B停机的
-            DetailsOfTheRefuelingPlan detailsOfTheRefuelingPlan5=new DetailsOfTheRefuelingPlan();
+            DetailsOfTheRefuelingPlan detailsOfTheRefuelingPlan5 = new DetailsOfTheRefuelingPlan();
             detailsOfTheRefuelingPlan5.setMacId(item.getId().toString());
             detailsOfTheRefuelingPlan5.setPlanStatus("2");
             detailsOfTheRefuelingPlan5.setProductType("B面");
             List<DetailsOfTheRefuelingPlan> detailsOfTheRefuelingPlans5 = detailsOfTheRefuelingPlanMapper.selectDetailsOfTheRefuelingPlanList(detailsOfTheRefuelingPlan5);
-            if(detailsOfTheRefuelingPlans5.size()>0){
-                    detailsOfTheRefuelingPlans5.stream().forEach(item1->{
-                        //拿到了某个车间的所有产线
-                        AmmunitionPlanInformationIntermediateTableRVo rs1=new AmmunitionPlanInformationIntermediateTableRVo();
-                        rs1.setMachineId(item.getProductionLineNo());//产线号
-                        rs1.setMacId(item.getId().toString());//产线id
-                        rs1.setProductType("B面");
-                        rs1.setPlannedEndTime("停机");
-                        //当前产线b面待生产
-                        String collect = detailsOfTheRefuelingPlans3.stream().map(plan -> plan.getCurrentColorCode() + "-(" + plan.getCurrentLotNumber() + ")").collect(Collectors.joining(","));
-                        rs1.setListOfPendingProduction(collect);
-                        list.add(rs1);
-                    });
+            if (detailsOfTheRefuelingPlans5.size() > 0) {
+                detailsOfTheRefuelingPlans5.stream().forEach(item1 -> {
+                    //拿到了某个车间的所有产线
+                    AmmunitionPlanInformationIntermediateTableRVo rs1 = new AmmunitionPlanInformationIntermediateTableRVo();
+                    rs1.setMachineId(item.getProductionLineNo());//产线号
+                    rs1.setMacId(item.getId().toString());//产线id
+                    rs1.setProductType("B面");
+                    rs1.setPlannedEndTime("停机");
+                    //当前产线b面待生产
+                    String collect = detailsOfTheRefuelingPlans3.stream().map(plan -> plan.getCurrentColorCode() + "-(" + plan.getCurrentLotNumber() + ")").collect(Collectors.joining(","));
+                    rs1.setListOfPendingProduction(collect);
+                    list.add(rs1);
+                });
             }
             //B待机
-            if(detailsOfTheRefuelingPlans3.size()>0&&BList.size()<=0&&detailsOfTheRefuelingPlans5.size()<=0){
+            if (detailsOfTheRefuelingPlans3.size() > 0 && BList.size() <= 0 && detailsOfTheRefuelingPlans5.size() <= 0) {
                 System.err.println(item.getId());
-                AmmunitionPlanInformationIntermediateTableRVo rs1=new AmmunitionPlanInformationIntermediateTableRVo();
+                AmmunitionPlanInformationIntermediateTableRVo rs1 = new AmmunitionPlanInformationIntermediateTableRVo();
                 rs1.setMachineId(item.getProductionLineNo());//产线号
                 rs1.setMacId(item.getId().toString());//产线iD
                 String collect = detailsOfTheRefuelingPlans3.stream().map(plan -> plan.getCurrentColorCode() + "-(" + plan.getCurrentLotNumber() + ")").collect(Collectors.joining(","));
@@ -286,8 +284,8 @@ public class AmmunitionPlanInformationIntermediateTableServiceImpl implements IA
                 list.add(rs1);
             }
             //待机没有,停机没有,上机没有
-            if(detailsOfTheRefuelingPlans3.size()<=0&&detailsOfTheRefuelingPlans5.size()<=0&&BList.size()<=0){
-                AmmunitionPlanInformationIntermediateTableRVo rs1=new AmmunitionPlanInformationIntermediateTableRVo();
+            if (detailsOfTheRefuelingPlans3.size() <= 0 && detailsOfTheRefuelingPlans5.size() <= 0 && BList.size() <= 0) {
+                AmmunitionPlanInformationIntermediateTableRVo rs1 = new AmmunitionPlanInformationIntermediateTableRVo();
                 rs1.setMachineId(item.getProductionLineNo());//产线号
                 rs1.setMacId(item.getId().toString());//产线iD
                 rs1.setProductType("B面");
@@ -299,46 +297,42 @@ public class AmmunitionPlanInformationIntermediateTableServiceImpl implements IA
     }
 
 
-
     /**
      * 修改加弹计划信息
-     * 
+     *
      * @param ammunitionPlanInformationIntermediateTable 加弹计划信息
      * @return 结果
      */
     @Override
-    public int updateAmmunitionPlanInformationIntermediateTable(AmmunitionPlanInformationIntermediateTable ammunitionPlanInformationIntermediateTable)
-    {
+    public int updateAmmunitionPlanInformationIntermediateTable(AmmunitionPlanInformationIntermediateTable ammunitionPlanInformationIntermediateTable) {
         return ammunitionPlanInformationIntermediateTableMapper.updateAmmunitionPlanInformationIntermediateTable(ammunitionPlanInformationIntermediateTable);
     }
 
     /**
      * 批量删除加弹计划信息
-     * 
+     *
      * @param ids 需要删除的加弹计划信息主键
      * @return 结果
      */
     @Override
-    public int deleteAmmunitionPlanInformationIntermediateTableByIds(Long[] ids)
-    {
+    public int deleteAmmunitionPlanInformationIntermediateTableByIds(Long[] ids) {
         return ammunitionPlanInformationIntermediateTableMapper.deleteAmmunitionPlanInformationIntermediateTableByIds(ids);
     }
 
     /**
      * 删除加弹计划信息信息
-     * 
+     *
      * @param id 加弹计划信息主键
      * @return 结果
      */
     @Override
-    public int deleteAmmunitionPlanInformationIntermediateTableById(Long id)
-    {
+    public int deleteAmmunitionPlanInformationIntermediateTableById(Long id) {
         return ammunitionPlanInformationIntermediateTableMapper.deleteAmmunitionPlanInformationIntermediateTableById(id);
     }
 
     @Override
     public List<DetailsOfTheRefuelingPlan> getAllPlanListByMachineId(String macId) {
-        DetailsOfTheRefuelingPlan detailsOfTheRefuelingPlan3=new DetailsOfTheRefuelingPlan();
+        DetailsOfTheRefuelingPlan detailsOfTheRefuelingPlan3 = new DetailsOfTheRefuelingPlan();
         detailsOfTheRefuelingPlan3.setMacId(macId);//产线号
         List<DetailsOfTheRefuelingPlan> detailsOfTheRefuelingPlans3 = detailsOfTheRefuelingPlanMapper.selectDetailsOfTheRefuelingPlanListDetiles(detailsOfTheRefuelingPlan3);
         return detailsOfTheRefuelingPlans3;
@@ -346,7 +340,7 @@ public class AmmunitionPlanInformationIntermediateTableServiceImpl implements IA
 
     @Override
     public List<DetailsOfTheRefuelingPlan> getAllPlanListByProductType(DetailsOfTheRefuelingPlan detailsOfTheRefuelingPlan) {
-        DetailsOfTheRefuelingPlan detailsOfTheRefuelingPlan3=new DetailsOfTheRefuelingPlan();
+        DetailsOfTheRefuelingPlan detailsOfTheRefuelingPlan3 = new DetailsOfTheRefuelingPlan();
         detailsOfTheRefuelingPlan3.setMachineId(detailsOfTheRefuelingPlan.getMacId());//产线号
         detailsOfTheRefuelingPlan3.setProductType(detailsOfTheRefuelingPlan.getProductType());//类型
         detailsOfTheRefuelingPlan3.setPlanStatus(detailsOfTheRefuelingPlan.getPlanStatus());//状态

+ 7 - 8
zkqy-custom-business/src/main/java/com/zkqy/business/service/impl/ProductInventoryServiceImpl.java

@@ -252,7 +252,7 @@ public class ProductInventoryServiceImpl implements IProductInventoryService {
         productInvoice1.setDeliveryWarehouse(productInvoice.getDeliveryWarehouse());
         productInvoice1.setTransferWarehouse(productInvoice.getTransferWarehouse());
         productInvoice1.setDeliveryClerk(productInvoice.getDeliveryClerk());
-        productInvoice1.setStatus("2");
+//        productInvoice1.setStatus("2");
         productInvoiceMapper.updateProductInvoice(productInvoice1);
 
 
@@ -306,14 +306,13 @@ public class ProductInventoryServiceImpl implements IProductInventoryService {
         ProductInvoice productInvoice2 = productInvoiceMapper.selectProductInvoiceById(productInvoice.getId());
         //判断当前订单是否为零售单
         SaleOrder saleOrder1 = saleOrderMapper.selectSaleOrderBySaleNo(productInvoice2.getSaleOrderNo());
-        if (saleOrder1.getSaleOrderTechnologyNo().equals("retailOrder")) {
-            SaleOrder saleOrder = new SaleOrder();
-            saleOrder.setSaleNo(productInvoice2.getSaleOrderNo());
+        // 更新销售单状态-》
+        SaleOrder saleOrder = new SaleOrder();
+        saleOrder.setSaleNo(productInvoice2.getSaleOrderNo());
+        //已出库状态
+        saleOrder.setStatus("9");
+        saleOrderMapper.updateSaleOrderBySaleNo(saleOrder);
 
-            //已出库状态
-            saleOrder.setStatus("9");
-            saleOrderMapper.updateSaleOrderBySaleNo(saleOrder);
-        }
         return AjaxResult.success();
     }
 

+ 4 - 3
zkqy-custom-business/src/main/java/com/zkqy/business/service/impl/ProductInvoiceServiceImpl.java

@@ -2,6 +2,7 @@ package com.zkqy.business.service.impl;
 
 import java.text.DecimalFormat;
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -101,8 +102,7 @@ public class ProductInvoiceServiceImpl implements IProductInvoiceService {
      * @return 结果
      */
     @Override
-    public int deleteProductInvoiceByIds(List<Long> ids)
-    {
+    public int deleteProductInvoiceByIds(List<Long> ids) {
         return productInvoiceMapper.deleteProductInvoiceByIds(ids);
     }
 
@@ -203,6 +203,7 @@ public class ProductInvoiceServiceImpl implements IProductInvoiceService {
 
         //根据通知单号查询货品信息
         List<ProductInvoiceVO.SaleProductInfo> saleProductInfoList1 = saleProductsMapper.selectSaleProductsInfo3(productInvoice.getNoticeNumber());
+
         List<ProductInvoiceVO.SaleProductInfo> saleProductInfoList2 = new ArrayList<>();
         saleProductInfoList2.addAll(saleProductInfoList);
 
@@ -221,9 +222,9 @@ public class ProductInvoiceServiceImpl implements IProductInvoiceService {
             saleProductInfoList1.addAll(saleProductInfoList);
         }
 
-
         //客户编号
         vo.setCustomerId(saleOrderMapper.selectCustomerIdBySaleNo(productInvoice.getSaleOrderNo()));
+        saleProductInfoList1.sort(Comparator.comparing(ProductInvoiceVO.SaleProductInfo::getProductId).thenComparing(ProductInvoiceVO.SaleProductInfo::getProductColor));
         vo.setSaleProductInfoList(saleProductInfoList1);
         return vo;
     }

+ 2 - 2
zkqy-custom-business/src/main/java/com/zkqy/business/service/impl/ProductOutboundRecordServiceImpl.java

@@ -157,8 +157,8 @@ public class ProductOutboundRecordServiceImpl implements IProductOutboundRecordS
         productHandsetOutboundRecord.setQrCode(productOutboundRecord.getQrCode());
         productHandsetOutboundRecord.setQrCodeId(productOutboundRecord.getQrCodeId());
         productHandsetOutboundRecord.setProductId(productOutboundRecord.getProductId());
-        productHandsetOutboundRecord.setProductColour(productHandsetOutboundRecord.getProductColour());
-        productHandsetOutboundRecord.setLevels(productHandsetOutboundRecord.getLevels());
+        productHandsetOutboundRecord.setProductColour(productOutboundRecord.getProductColour());
+        productHandsetOutboundRecord.setLevels(productOutboundRecord.getLevels());
         productHandsetOutboundRecord.setLotNum(productOutboundRecord.getLotNum());
         productHandsetOutboundRecord.setNoticeNumber(productOutboundRecord.getNoticeNumber());
         productHandsetOutboundRecord.setDelFlag("2");

+ 39 - 40
zkqy-custom-business/src/main/java/com/zkqy/business/service/impl/SaleOrderServiceImpl.java

@@ -21,13 +21,12 @@ import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 销售订单Service业务层处理
- * 
+ *
  * @author zkqy
  * @date 2024-03-14
  */
 @Service
-public class SaleOrderServiceImpl implements ISaleOrderService 
-{
+public class SaleOrderServiceImpl implements ISaleOrderService {
     @Autowired
     private SaleOrderMapper saleOrderMapper;
 
@@ -42,13 +41,12 @@ public class SaleOrderServiceImpl implements ISaleOrderService
 
     /**
      * 查询销售订单
-     * 
+     *
      * @param id 销售订单主键
      * @return 销售订单
      */
     @Override
-    public SaleOrder selectSaleOrderById(Long id)
-    {
+    public SaleOrder selectSaleOrderById(Long id) {
         return saleOrderMapper.selectSaleOrderById(id);
     }
 
@@ -59,32 +57,30 @@ public class SaleOrderServiceImpl implements ISaleOrderService
 
     /**
      * 查询销售订单列表
-     * 
+     *
      * @param saleOrder 销售订单
      * @return 销售订单
      */
     @Override
-    public List<SaleOrder> selectSaleOrderList(SaleOrder saleOrder)
-    {
+    public List<SaleOrder> selectSaleOrderList(SaleOrder saleOrder) {
         return saleOrderMapper.selectSaleOrderList(saleOrder);
     }
 
     /**
      * 新增销售订单
-     * 
+     *
      * @param saleOrder 销售订单
      * @return 结果
      */
     @Override
-    public int insertSaleOrder(SaleOrder saleOrder)
-    {
+    public int insertSaleOrder(SaleOrder saleOrder) {
         saleOrder.setCreateTime(DateUtils.getNowDate());
         return saleOrderMapper.insertSaleOrder(saleOrder);
     }
 
     /**
      * 修改销售订单
-     * 
+     *
      * @param vo 销售订单
      * @return 结果
      */
@@ -104,14 +100,13 @@ public class SaleOrderServiceImpl implements ISaleOrderService
 
     /**
      * 批量删除销售订单
-     * 
+     *
      * @param ids 需要删除的销售订单主键
      * @return 结果
      */
     @Override
     @Transactional
-    public void deleteSaleOrderByIds(List<Long> ids)
-    {
+    public void deleteSaleOrderByIds(List<Long> ids) {
         List<String> saleOrderNos = new ArrayList<>();
         ids.forEach(id -> {
             //查询销售单编号
@@ -119,7 +114,7 @@ public class SaleOrderServiceImpl implements ISaleOrderService
             saleOrderNos.add(saleOrder.getSaleNo());
             //删除货品明细
             List<Long> saleProductsIds = saleProductsMapper.selectSaleProductsIds(saleOrder.getSaleNo());
-            if(saleProductsIds.size() > 0){
+            if (saleProductsIds.size() > 0) {
                 saleProductsMapper.deleteSaleProductsByIds(saleProductsIds);
             }
             //根据合同号删除通知单
@@ -127,7 +122,7 @@ public class SaleOrderServiceImpl implements ISaleOrderService
 
         });
         //删除销售工艺
-        if(saleOrderNos.size() > 0){
+        if (saleOrderNos.size() > 0) {
             saleCraftMapper.deleteSaleCraftBysaleOrderNos(saleOrderNos);
         }
         //删除销售单
@@ -137,36 +132,35 @@ public class SaleOrderServiceImpl implements ISaleOrderService
 
     /**
      * 删除销售订单信息
-     * 
+     *
      * @param id 销售订单主键
      * @return 结果
      */
     @Override
-    public int deleteSaleOrderById(Long id)
-    {
+    public int deleteSaleOrderById(Long id) {
         return saleOrderMapper.deleteSaleOrderById(id);
     }
 
     @Override
     public boolean checkContractNo(Long id, String saleNo) {
         //判断新增还是修改
-        if(id != null){
+        if (id != null) {
             SaleOrder saleOrder = saleOrderMapper.selectSaleOrderById(id);
-            if(saleOrder.getSaleNo().equals(saleNo)){
+            if (saleOrder.getSaleNo().equals(saleNo)) {
                 return true;
-            }else {
+            } else {
                 SaleOrder saleOrder1 = saleOrderMapper.selectSaleOrderBySaleNo(saleNo);
-                if(saleOrder1 != null){
+                if (saleOrder1 != null) {
                     return false;
-                }else {
+                } else {
                     return true;
                 }
             }
-        }else {
+        } else {
             SaleOrder saleOrder1 = saleOrderMapper.selectSaleOrderBySaleNo(saleNo);
-            if(saleOrder1 != null){
+            if (saleOrder1 != null) {
                 return false;
-            }else {
+            } else {
                 return true;
             }
         }
@@ -186,12 +180,12 @@ public class SaleOrderServiceImpl implements ISaleOrderService
         boolean containsSalesman = roles.stream().anyMatch(role -> "salesman".equals(role.getRoleKey()));
 
         //查看当前用户是否是租户管理员,是返回全部销售单数据
-        if(SecurityUtils.isLoginUserTenantAdmin()){
+        if (SecurityUtils.isLoginUserTenantAdmin()) {
             saleOrderVOS = saleOrderMapper.saleOrderList(saleOrder);
-        }else if(containsSalesman){
+        } else if (containsSalesman) {
             saleOrder.setCreateById(SecurityUtils.getUserId());
             saleOrderVOS = saleOrderMapper.saleOrderList(saleOrder);
-        }else {
+        } else {
             saleOrderVOS = saleOrderMapper.saleOrderList(saleOrder);
         }
         return saleOrderVOS;
@@ -202,7 +196,7 @@ public class SaleOrderServiceImpl implements ISaleOrderService
     public int addRetailOrder(SaleOrderVO vo) {
         //新增零售单
         SaleOrder saleOrder = new SaleOrder();
-        BeanUtils.copyBeanProp(saleOrder,vo);
+        BeanUtils.copyBeanProp(saleOrder, vo);
         saleOrder.setCreateBy(SecurityUtils.getUsername());
         saleOrder.setCreateTime(DateUtils.getNowDate());
         saleOrderMapper.insertSaleOrder(saleOrder);
@@ -220,7 +214,7 @@ public class SaleOrderServiceImpl implements ISaleOrderService
         // 零售单
         SaleOrderVO saleOrderVO = new SaleOrderVO();
         SaleOrder saleOrder = saleOrderMapper.selectSaleOrderById(id);
-        BeanUtils.copyBeanProp(saleOrderVO,saleOrder);
+        BeanUtils.copyBeanProp(saleOrderVO, saleOrder);
 
         // 零售单货品详情
         SaleProducts saleProducts = new SaleProducts();
@@ -247,7 +241,7 @@ public class SaleOrderServiceImpl implements ISaleOrderService
 
         //修改零售单
         SaleOrder saleOrder = new SaleOrder();
-        BeanUtils.copyBeanProp(saleOrder,vo);
+        BeanUtils.copyBeanProp(saleOrder, vo);
 
 
         //修改零售单货品详情
@@ -256,13 +250,13 @@ public class SaleOrderServiceImpl implements ISaleOrderService
         Set<Long> ids = new HashSet<>();
 
         vo.getSaleProductsList().forEach(saleProducts -> {
-            if(saleProducts.getId() != null){
+            if (saleProducts.getId() != null) {
                 ids.add(saleProducts.getId());
                 saleProducts.setUpdateById(SecurityUtils.getUserId());
                 saleProducts.setUpdateTime(DateUtils.getNowDate());
                 saleOrder.setUpdateBy(SecurityUtils.getUsername());
                 updateSaleProductsList.add(saleProducts);
-            }else {
+            } else {
                 saleProducts.setSaleOrderNo(saleOrder.getSaleNo());
                 saleProducts.setCreateById(SecurityUtils.getUserId());
                 saleProducts.setCreateBy(SecurityUtils.getUsername());
@@ -275,14 +269,14 @@ public class SaleOrderServiceImpl implements ISaleOrderService
         Set<Long> allIds = saleProductsMapper.selectSaleProductsIdsBySaleNo(saleOrder.getSaleNo());
         allIds.removeAll(ids);
         // remove
-        if(allIds.size() > 0){
+        if (allIds.size() > 0) {
             saleProductsMapper.deleteSaleProductsByIds(new ArrayList<>(allIds));
         }
         // add
-        if(addSaleProductsList.size() > 0){
+        if (addSaleProductsList.size() > 0) {
             saleProductsMapper.batchInsertSaleProducts(addSaleProductsList);
         }
-        if(updateSaleProductsList.size() > 0){
+        if (updateSaleProductsList.size() > 0) {
             updateSaleProductsList.forEach(saleProducts -> {
                 saleProductsMapper.updateSaleProducts(saleProducts);
             });
@@ -320,7 +314,12 @@ public class SaleOrderServiceImpl implements ISaleOrderService
     }
 
     @Override
+    @Transactional
     public int updateOrder(SaleOrder saleOrder) {
+        ProductInvoice productInvoice1 = new ProductInvoice();
+        productInvoice1.setStatus("2");
+        productInvoice1.setSaleOrderNo(saleOrder.getSaleNo());
+        productInvoiceMapper.updateProductInvoiceBySaleNo(productInvoice1);
         return saleOrderMapper.updateSaleOrder(saleOrder);
     }
 

+ 111 - 62
zkqy-custom-business/src/main/resources/mapper/business/ProductInvoiceMapper.xml

@@ -1,38 +1,38 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.zkqy.business.mapper.ProductInvoiceMapper">
-    
+
     <resultMap type="com.zkqy.business.domain.ProductInvoice" id="ProductInvoiceResult">
-        <result property="id"    column="id"    />
-        <result property="noticeNumber"    column="notice_number"    />
-        <result property="noticeDate"    column="notice_date"    />
-        <result property="salesman"    column="salesman"    />
-        <result property="customerId"    column="customer_id"    />
+        <result property="id" column="id"/>
+        <result property="noticeNumber" column="notice_number"/>
+        <result property="noticeDate" column="notice_date"/>
+        <result property="salesman" column="salesman"/>
+        <result property="customerId" column="customer_id"/>
         <result property="customerName" column="custom_name"/>
-        <result property="drawer"    column="drawer"    />
-        <result property="dispatchNoteRemark"    column="dispatch_note_remark"    />
-        <result property="billingType"    column="billing_type"    />
-        <result property="truckRegistration"    column="truck_registration"    />
-        <result property="documentType"    column="document_type"    />
-        <result property="sellingUnit"    column="selling_unit"    />
-        <result property="calculationType"    column="calculation_type"    />
-        <result property="auditOpinion"    column="audit_opinion"    />
-        <result property="status"    column="status"    />
-        <result property="saleOrderNo"    column="sale_order_no"    />
-        <result property="spare1"    column="spare1"    />
-        <result property="spare2"    column="spare2"    />
-        <result property="spare3"    column="spare3"    />
-        <result property="spare4"    column="spare4"    />
-        <result property="remark"    column="remark"    />
-        <result property="delFlag"    column="del_flag"    />
-        <result property="createBy"    column="create_by"    />
-        <result property="createById"    column="create_by_id"    />
-        <result property="createTime"    column="create_time"    />
-        <result property="updateBy"    column="update_by"    />
-        <result property="updateById"    column="update_by_id"    />
-        <result property="updateTime"    column="update_time"    />
+        <result property="drawer" column="drawer"/>
+        <result property="dispatchNoteRemark" column="dispatch_note_remark"/>
+        <result property="billingType" column="billing_type"/>
+        <result property="truckRegistration" column="truck_registration"/>
+        <result property="documentType" column="document_type"/>
+        <result property="sellingUnit" column="selling_unit"/>
+        <result property="calculationType" column="calculation_type"/>
+        <result property="auditOpinion" column="audit_opinion"/>
+        <result property="status" column="status"/>
+        <result property="saleOrderNo" column="sale_order_no"/>
+        <result property="spare1" column="spare1"/>
+        <result property="spare2" column="spare2"/>
+        <result property="spare3" column="spare3"/>
+        <result property="spare4" column="spare4"/>
+        <result property="remark" column="remark"/>
+        <result property="delFlag" column="del_flag"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createById" column="create_by_id"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateById" column="update_by_id"/>
+        <result property="updateTime" column="update_time"/>
         <result property="deliveryWarehouse" column="delivery_warehouse"/>
         <result property="transferWarehouse" column="transfer_warehouse"/>
         <result property="deliveryDate" column="deliveryDate"/>
@@ -40,34 +40,66 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectProductInvoiceVo">
-        select id, notice_number, notice_date, salesman, customer_id, drawer, dispatch_note_remark, billing_type, truck_registration, document_type, selling_unit, calculation_type, audit_opinion, status, sale_order_no, spare1, spare2, spare3, spare4, remark, del_flag, create_by, create_by_id, create_time, update_by, update_by_id, update_time, delivery_warehouse, transfer_warehouse, delivery_date,delivery_clerk from {DBNAME}.product_invoice
+        select id,
+               notice_number,
+               notice_date,
+               salesman,
+               customer_id,
+               drawer,
+               dispatch_note_remark,
+               billing_type,
+               truck_registration,
+               document_type,
+               selling_unit,
+               calculation_type,
+               audit_opinion,
+               status,
+               sale_order_no,
+               spare1,
+               spare2,
+               spare3,
+               spare4,
+               remark,
+               del_flag,
+               create_by,
+               create_by_id,
+               create_time,
+               update_by,
+               update_by_id,
+               update_time,
+               delivery_warehouse,
+               transfer_warehouse,
+               delivery_date,
+               delivery_clerk
+        from {DBNAME}.product_invoice
     </sql>
 
-    <select id="selectProductInvoiceList" parameterType="com.zkqy.business.domain.ProductInvoice" resultMap="ProductInvoiceResult">
+    <select id="selectProductInvoiceList" parameterType="com.zkqy.business.domain.ProductInvoice"
+            resultMap="ProductInvoiceResult">
         SELECT
-            pi.id,
-            pi.notice_number,
-            pi.notice_date,
-            pi.STATUS,
-            c.custom_name,
-            pi.sale_order_no
-            FROM
-            {DBNAME}.product_invoice pi
-            LEFT JOIN {DBNAME}.customer c ON pi.customer_id = c.id
-            WHERE
-            pi.del_flag = '0'
-            AND c.del_flag = '0'
-            <if test="noticeNumber != null  and noticeNumber != ''"> and pi.notice_number = #{noticeNumber}</if>
-            <if test="noticeDate != null "> and pi.notice_date = #{noticeDate}</if>
-            <if test="customerId != null "> and c.id = #{customerId}</if>
-            <if test="status != null and status != ''"> and pi.status = #{status}</if>
+        pi.id,
+        pi.notice_number,
+        pi.notice_date,
+        pi.STATUS,
+        c.custom_name,
+        pi.sale_order_no
+        FROM
+        {DBNAME}.product_invoice pi
+        LEFT JOIN {DBNAME}.customer c ON pi.customer_id = c.id
+        WHERE
+        pi.del_flag = '0'
+        AND c.del_flag = '0'
+        <if test="noticeNumber != null  and noticeNumber != ''">and pi.notice_number = #{noticeNumber}</if>
+        <if test="noticeDate != null ">and pi.notice_date = #{noticeDate}</if>
+        <if test="customerId != null ">and c.id = #{customerId}</if>
+        <if test="status != null and status != ''">and pi.status = #{status}</if>
     </select>
-    
+
     <select id="selectProductInvoiceById" parameterType="Long" resultMap="ProductInvoiceResult">
         <include refid="selectProductInvoiceVo"/>
         where id = #{id}
     </select>
-        
+
     <insert id="insertProductInvoice" parameterType="com.zkqy.business.domain.ProductInvoice">
         insert into {DBNAME}.product_invoice
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -98,7 +130,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="deliveryDate != null">deliveryDate,</if>
             <if test="deliveryClerk != null">delivery_clerk,</if>
             del_flag
-         </trim>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="noticeNumber != null">#{noticeNumber},</if>
             <if test="noticeDate != null">#{noticeDate},</if>
@@ -127,7 +159,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="deliveryDate != null">#{deliveryDate},</if>
             <if test="deliveryClerk != null">#{deliveryClerk},</if>
             '0'
-         </trim>
+        </trim>
     </insert>
 
     <update id="updateProductInvoice" parameterType="com.zkqy.business.domain.ProductInvoice">
@@ -162,13 +194,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </trim>
         where id = #{id}
     </update>
+    <update id="updateProductInvoiceBySaleNo" parameterType="com.zkqy.business.domain.ProductInvoice">
+        update {DBNAME}.product_invoice
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="status != null">status = #{status},</if>
+        </trim>
+        where sale_order_no = #{saleOrderNo}
+    </update>
 
     <delete id="deleteProductInvoiceById" parameterType="Long">
-        delete from product_invoice where id = #{id}
+        delete
+        from product_invoice
+        where id = #{id}
     </delete>
 
-    <delete id="deleteProductInvoiceByIds" >
-        update {DBNAME}.product_invoice set del_flag = '0' where id in
+    <delete id="deleteProductInvoiceByIds" parameterType="String">
+        delete from product_invoice where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
@@ -180,10 +221,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <update id="deleteProductInvoiceBySaleOrderNo" parameterType="String">
-        update {DBNAME}.product_invoice set del_flag = '2' where sale_order_no = #{saleOrderNo}
+        update {DBNAME}.product_invoice
+        set del_flag = '2'
+        where sale_order_no = #{saleOrderNo}
     </update>
 
-    <select id="financialStatementList"  resultType="map">
+    <select id="financialStatementList" resultType="map">
         select so.id,
         so.sale_no,
         so.sale_date,
@@ -208,9 +251,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         left join {DBNAME}.product_invoice pi on pi.sale_order_no = so.sale_no and pi.del_flag = '0'
         where so.del_flag = '0'
         and so.status = 6
-        <if test="noticeNumber != null  and noticeNumber != ''">and so.notice_number = #{noticeNumber}</if>
+        <if test="saleNo != null  and saleNo != ''">and so.sale_no = #{saleNo}</if>
         <if test="customerId != null  and customerId != ''">and c.id = #{customerId}</if>
-        <if test="noticeDate != null ">and so.notice_date = #{noticeDate}</if>
+        <if test="saleDate != null ">and so.sale_date = #{saleDate}</if>
         <if test="orderType == 'contractOrder'">
             and so.sale_order_technology_no != 'retailOrder'
         </if>
@@ -219,7 +262,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </if>
         order by so.id desc
     </select>
-    <select id="financialStatementExportList" resultType="com.zkqy.business.domain.vo.ProductInvoiceFinancialExportVo" parameterType="com.zkqy.business.domain.vo.ProductInvoiceFinancialExportVo">
+    <select id="financialStatementExportList" resultType="com.zkqy.business.domain.vo.ProductInvoiceFinancialExportVo"
+            parameterType="com.zkqy.business.domain.vo.ProductInvoiceFinancialExportVo">
         select
         pi2.notice_number ,
         c.custom_name,
@@ -252,9 +296,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </if>
         where pi2.del_flag = 0
         and pi2.status = 2
-        <if test="noticeNumber != null  and noticeNumber != ''">and pi.notice_number = #{noticeNumber}</if>
+        <if test="saleNo != null  and saleNo != ''">and so.sale_no = #{saleNo}</if>
         <if test="customerId != null  and customerId != ''">and c.id = #{customerId}</if>
-        <if test="noticeDate != null ">and pi.notice_date = #{noticeDate}</if>
+        <if test="saleDate != null ">and so.sale_date = #{saleDate}</if>
+        <if test="ids != null and ids.length > 0 ">and so.id in
+            <foreach item="id" collection="ids" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
         group by
         por.lot_num ,
         por.product_id ,

+ 320 - 279
zkqy-custom-business/src/main/resources/mapper/business/SaleProductsMapper.xml

@@ -1,66 +1,66 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.zkqy.business.mapper.SaleProductsMapper">
-    
+
     <resultMap type="com.zkqy.business.domain.SaleProducts" id="SaleProductsResult">
-        <result property="id"    column="id"    />
-        <result property="saleProductNo"    column="sale_product_no"    />
-        <result property="saleOrderNo"    column="sale_order_no"    />
-        <result property="productNo"    column="product_no"    />
-        <result property="productName"    column="product_name"    />
-        <result property="productNumber"    column="product_number"    />
-        <result property="productWeight"    column="product_weight"    />
-        <result property="productUnitPrice"    column="product_unit_price"    />
-        <result property="productAmounts"    column="product_amounts"    />
-        <result property="productNotes"    column="product_notes"    />
-        <result property="remark"    column="remark"    />
-        <result property="createById"    column="create_by_id"    />
-        <result property="createBy"    column="create_by"    />
-        <result property="createTime"    column="create_time"    />
-        <result property="updateById"    column="update_by_id"    />
-        <result property="updateBy"    column="update_by"    />
-        <result property="updateTime"    column="update_time"    />
-        <result property="delFlag"    column="del_flag"    />
-        <result property="taskProcessKey"    column="task_process_key"    />
-        <result property="taskNodeKey"    column="task_node_key"    />
-        <result property="processKey"    column="process_key"    />
-        <result property="status"    column="status"    />
-        <result property="productionLineNo"    column="production_line_no"    />
-        <result property="sliceType"    column="slice_type"    />
-        <result property="colourNumber"    column="colour_number"    />
+        <result property="id" column="id"/>
+        <result property="saleProductNo" column="sale_product_no"/>
+        <result property="saleOrderNo" column="sale_order_no"/>
+        <result property="productNo" column="product_no"/>
+        <result property="productName" column="product_name"/>
+        <result property="productNumber" column="product_number"/>
+        <result property="productWeight" column="product_weight"/>
+        <result property="productUnitPrice" column="product_unit_price"/>
+        <result property="productAmounts" column="product_amounts"/>
+        <result property="productNotes" column="product_notes"/>
+        <result property="remark" column="remark"/>
+        <result property="createById" column="create_by_id"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateById" column="update_by_id"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="delFlag" column="del_flag"/>
+        <result property="taskProcessKey" column="task_process_key"/>
+        <result property="taskNodeKey" column="task_node_key"/>
+        <result property="processKey" column="process_key"/>
+        <result property="status" column="status"/>
+        <result property="productionLineNo" column="production_line_no"/>
+        <result property="sliceType" column="slice_type"/>
+        <result property="colourNumber" column="colour_number"/>
         <result property="taskName" column="task_name"/>
         <result property="lotNumber" column="lot_number"/>
         <result property="onBoardState" column="on_board_state"/>
     </resultMap>
 
     <resultMap type="com.zkqy.business.domain.vo.SaleProductsVo" id="SaleProductsResultAndCustomInfo">
-        <result property="id"    column="id"    />
-        <result property="saleProductNo"    column="sale_product_no"    />
-        <result property="saleOrderNo"    column="sale_order_no"    />
-        <result property="productNo"    column="product_no"    />
-        <result property="productName"    column="product_name"    />
-        <result property="productNumber"    column="product_number"    />
-        <result property="productWeight"    column="product_weight"    />
-        <result property="productUnitPrice"    column="product_unit_price"    />
-        <result property="productAmounts"    column="product_amounts"    />
-        <result property="productNotes"    column="product_notes"    />
-        <result property="remark"    column="remark"    />
-        <result property="createById"    column="create_by_id"    />
-        <result property="createBy"    column="create_by"    />
-        <result property="createTime"    column="create_time"    />
-        <result property="updateById"    column="update_by_id"    />
-        <result property="updateBy"    column="update_by"    />
-        <result property="updateTime"    column="update_time"    />
-        <result property="delFlag"    column="del_flag"    />
-        <result property="taskProcessKey"    column="task_process_key"    />
-        <result property="taskNodeKey"    column="task_node_key"    />
-        <result property="processKey"    column="process_key"    />
-        <result property="status"    column="status"    />
-        <result property="productionLineNo"    column="production_line_no"    />
-        <result property="sliceType"    column="slice_type"    />
-        <result property="colourNumber"    column="colour_number"    />
+        <result property="id" column="id"/>
+        <result property="saleProductNo" column="sale_product_no"/>
+        <result property="saleOrderNo" column="sale_order_no"/>
+        <result property="productNo" column="product_no"/>
+        <result property="productName" column="product_name"/>
+        <result property="productNumber" column="product_number"/>
+        <result property="productWeight" column="product_weight"/>
+        <result property="productUnitPrice" column="product_unit_price"/>
+        <result property="productAmounts" column="product_amounts"/>
+        <result property="productNotes" column="product_notes"/>
+        <result property="remark" column="remark"/>
+        <result property="createById" column="create_by_id"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateById" column="update_by_id"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="delFlag" column="del_flag"/>
+        <result property="taskProcessKey" column="task_process_key"/>
+        <result property="taskNodeKey" column="task_node_key"/>
+        <result property="processKey" column="process_key"/>
+        <result property="status" column="status"/>
+        <result property="productionLineNo" column="production_line_no"/>
+        <result property="sliceType" column="slice_type"/>
+        <result property="colourNumber" column="colour_number"/>
         <result property="customName" column="custom_name"/>
         <result property="materieEncoding" column="materie_encoding"/>
         <result property="materieColorNumber" column="materie_color_number"/>
@@ -68,106 +68,147 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectSaleProductsVo">
-        select id, sale_product_no, sale_order_no, product_no, product_name, product_number, product_weight, product_unit_price, product_amounts, product_notes, remark, create_by_id, create_by, create_time, update_by_id, update_by, update_time, del_flag, task_process_key, task_node_key, process_key, status, production_line_no, slice_type, colour_number,task_name,lot_number, on_board_state from {DBNAME}.sale_products
+        select id,
+               sale_product_no,
+               sale_order_no,
+               product_no,
+               product_name,
+               product_number,
+               product_weight,
+               product_unit_price,
+               product_amounts,
+               product_notes,
+               remark,
+               create_by_id,
+               create_by,
+               create_time,
+               update_by_id,
+               update_by,
+               update_time,
+               del_flag,
+               task_process_key,
+               task_node_key,
+               process_key,
+               status,
+               production_line_no,
+               slice_type,
+               colour_number,
+               task_name,
+               lot_number,
+               on_board_state
+        from {DBNAME}.sale_products
     </sql>
 
-    <select id="selectSaleProductsList" parameterType="com.zkqy.business.domain.SaleProducts" resultMap="SaleProductsResult">
+    <select id="selectSaleProductsList" parameterType="com.zkqy.business.domain.SaleProducts"
+            resultMap="SaleProductsResult">
         <include refid="selectSaleProductsVo"/>
         where del_flag = '0'
-            <if test="saleProductNo != null  and saleProductNo != ''"> and sale_product_no = #{saleProductNo}</if>
-            <if test="saleOrderNo != null  and saleOrderNo != ''"> and sale_order_no = #{saleOrderNo}</if>
-            <if test="productNo != null  and productNo != ''"> and product_no = #{productNo}</if>
-            <if test="productName != null  and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
-            <if test="productNumber != null "> and product_number = #{productNumber}</if>
-            <if test="productWeight != null  and productWeight != ''"> and product_weight = #{productWeight}</if>
-            <if test="productUnitPrice != null  and productUnitPrice != ''"> and product_unit_price = #{productUnitPrice}</if>
-            <if test="productAmounts != null  and productAmounts != ''"> and product_amounts = #{productAmounts}</if>
-            <if test="productNotes != null  and productNotes != ''"> and product_notes = #{productNotes}</if>
-            <if test="createById != null "> and create_by_id = #{createById}</if>
-            <if test="updateById != null "> and update_by_id = #{updateById}</if>
-            <if test="taskProcessKey != null  and taskProcessKey != ''"> and task_process_key = #{taskProcessKey}</if>
-            <if test="taskNodeKey != null  and taskNodeKey != ''"> and task_node_key = #{taskNodeKey}</if>
-            <if test="processKey != null  and processKey != ''"> and process_key = #{processKey}</if>
-            <if test="status != null  and status != ''"> and status = #{status}</if>
-            <if test="productionLineNo != null  and productionLineNo != ''"> and production_line_no = #{productionLineNo}</if>
-            <if test="sliceType != null  and sliceType != ''"> and slice_type = #{sliceType}</if>
-            <if test="colourNumber != null  and colourNumber != ''"> and colour_number = #{colourNumber}</if>
-            <if test="lotNumber != null  and lotNumber != ''"> and lot_number = #{lotNumber}</if>
+        <if test="saleProductNo != null  and saleProductNo != ''">and sale_product_no = #{saleProductNo}</if>
+        <if test="saleOrderNo != null  and saleOrderNo != ''">and sale_order_no = #{saleOrderNo}</if>
+        <if test="productNo != null  and productNo != ''">and product_no = #{productNo}</if>
+        <if test="productName != null  and productName != ''">and product_name like concat('%', #{productName}, '%')
+        </if>
+        <if test="productNumber != null ">and product_number = #{productNumber}</if>
+        <if test="productWeight != null  and productWeight != ''">and product_weight = #{productWeight}</if>
+        <if test="productUnitPrice != null  and productUnitPrice != ''">and product_unit_price = #{productUnitPrice}
+        </if>
+        <if test="productAmounts != null  and productAmounts != ''">and product_amounts = #{productAmounts}</if>
+        <if test="productNotes != null  and productNotes != ''">and product_notes = #{productNotes}</if>
+        <if test="createById != null ">and create_by_id = #{createById}</if>
+        <if test="updateById != null ">and update_by_id = #{updateById}</if>
+        <if test="taskProcessKey != null  and taskProcessKey != ''">and task_process_key = #{taskProcessKey}</if>
+        <if test="taskNodeKey != null  and taskNodeKey != ''">and task_node_key = #{taskNodeKey}</if>
+        <if test="processKey != null  and processKey != ''">and process_key = #{processKey}</if>
+        <if test="status != null  and status != ''">and status = #{status}</if>
+        <if test="productionLineNo != null  and productionLineNo != ''">and production_line_no = #{productionLineNo}
+        </if>
+        <if test="sliceType != null  and sliceType != ''">and slice_type = #{sliceType}</if>
+        <if test="colourNumber != null  and colourNumber != ''">and colour_number = #{colourNumber}</if>
+        <if test="lotNumber != null  and lotNumber != ''">and lot_number = #{lotNumber}</if>
     </select>
 
-    <select id="selectSaleProductsListAndCustomInfo" parameterType="com.zkqy.business.domain.SaleProducts" resultMap="SaleProductsResultAndCustomInfo">
+    <select id="selectSaleProductsListAndCustomInfo" parameterType="com.zkqy.business.domain.SaleProducts"
+            resultMap="SaleProductsResultAndCustomInfo">
         SELECT
         sp.*,cs.custom_name,m.materie_encoding,m.materie_color_number,pd.product_specifications
         FROM
         {DBNAME}.sale_products AS sp
         INNER JOIN {DBNAME}.sale_order AS so ON sp.sale_order_no = so.sale_no
         Inner Join {DBNAME}.customer as cs ON so.sale_custom_no= cs.custom_no
-        inner join   {DBNAME}.materiel as m on sp.colour_number= m.materiel_code
-        inner join   {DBNAME}.production as pd on sp.product_no= pd.product_no
-        left  join  {DBNAME}.production_line as pl on sp.production_line_no=pl.id
-        where sp.del_flag = '0' and cs.del_flag = '0' and m.del_flag = '0' and so.order_type=2 and  (sp.status=3 or sp.status=4 or sp.status=5) and sp.status!=6
-        <if test="saleProductNo != null  and saleProductNo != ''"> and sale_product_no = #{saleProductNo}</if>
-            <if test="saleOrderNo != null  and saleOrderNo != ''"> and sale_order_no = #{saleOrderNo}</if>
-            <if test="productNo != null  and productNo != ''"> and product_no = #{productNo}</if>
-            <if test="productName != null  and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
-            <if test="productNumber != null "> and product_number = #{productNumber}</if>
-            <if test="productWeight != null  and productWeight != ''"> and product_weight = #{productWeight}</if>
-            <if test="productUnitPrice != null  and productUnitPrice != ''"> and product_unit_price = #{productUnitPrice}</if>
-            <if test="productAmounts != null  and productAmounts != ''"> and product_amounts = #{productAmounts}</if>
-            <if test="productNotes != null  and productNotes != ''"> and product_notes = #{productNotes}</if>
-            <if test="createById != null "> and create_by_id = #{createById}</if>
-            <if test="updateById != null "> and update_by_id = #{updateById}</if>
-            <if test="taskProcessKey != null  and taskProcessKey != ''"> and task_process_key = #{taskProcessKey}</if>
-            <if test="taskNodeKey != null  and taskNodeKey != ''"> and task_node_key = #{taskNodeKey}</if>
-            <if test="processKey != null  and processKey != ''"> and process_key = #{processKey}</if>
-            <if test="status != null  and status != ''"> and sp.status = #{status}</if>
-<!--            <if test="productionLineNo != null  and productionLineNo != ''"> AND sp.production_line_no IS NULL or sp.status =3 and pl.production_line_no NOT lIKE CONCAT(#{productionLineNo}, '%' )</if>-->
+        inner join {DBNAME}.materiel as m on sp.colour_number= m.materiel_code
+        inner join {DBNAME}.production as pd on sp.product_no= pd.product_no
+        left join {DBNAME}.production_line as pl on sp.production_line_no=pl.id
+        where sp.del_flag = '0' and cs.del_flag = '0' and m.del_flag = '0' and so.order_type=2 and (sp.status=3 or
+        sp.status=4 or sp.status=5) and sp.status!=6
+        <if test="saleProductNo != null  and saleProductNo != ''">and sale_product_no = #{saleProductNo}</if>
+        <if test="saleOrderNo != null  and saleOrderNo != ''">and sale_order_no = #{saleOrderNo}</if>
+        <if test="productNo != null  and productNo != ''">and product_no = #{productNo}</if>
+        <if test="productName != null  and productName != ''">and product_name like concat('%', #{productName}, '%')
+        </if>
+        <if test="productNumber != null ">and product_number = #{productNumber}</if>
+        <if test="productWeight != null  and productWeight != ''">and product_weight = #{productWeight}</if>
+        <if test="productUnitPrice != null  and productUnitPrice != ''">and product_unit_price = #{productUnitPrice}
+        </if>
+        <if test="productAmounts != null  and productAmounts != ''">and product_amounts = #{productAmounts}</if>
+        <if test="productNotes != null  and productNotes != ''">and product_notes = #{productNotes}</if>
+        <if test="createById != null ">and create_by_id = #{createById}</if>
+        <if test="updateById != null ">and update_by_id = #{updateById}</if>
+        <if test="taskProcessKey != null  and taskProcessKey != ''">and task_process_key = #{taskProcessKey}</if>
+        <if test="taskNodeKey != null  and taskNodeKey != ''">and task_node_key = #{taskNodeKey}</if>
+        <if test="processKey != null  and processKey != ''">and process_key = #{processKey}</if>
+        <if test="status != null  and status != ''">and sp.status = #{status}</if>
+        <!--            <if test="productionLineNo != null  and productionLineNo != ''"> AND sp.production_line_no IS NULL or sp.status =3 and pl.production_line_no NOT lIKE CONCAT(#{productionLineNo}, '%' )</if>-->
 
-            <if test="sliceType != null  and sliceType != ''"> and slice_type = #{sliceType}</if>
-            <if test="colourNumber != null  and colourNumber != ''"> and colour_number = #{colourNumber}</if>
-            <if test="lotNumber != null  and lotNumber != ''"> and lot_number = #{lotNumber}</if>
+        <if test="sliceType != null  and sliceType != ''">and slice_type = #{sliceType}</if>
+        <if test="colourNumber != null  and colourNumber != ''">and colour_number = #{colourNumber}</if>
+        <if test="lotNumber != null  and lotNumber != ''">and lot_number = #{lotNumber}</if>
     </select>
 
     <!--不管状态,只查关于这个几台的所有产品-->
-    <select id="selectSaleProductsListAndCustomInfoTwo" parameterType="com.zkqy.business.domain.SaleProducts" resultMap="SaleProductsResultAndCustomInfo">
+    <select id="selectSaleProductsListAndCustomInfoTwo" parameterType="com.zkqy.business.domain.SaleProducts"
+            resultMap="SaleProductsResultAndCustomInfo">
         SELECT
         sp.*,cs.custom_name,m.materie_encoding,m.materie_color_number,pd.product_specifications
         FROM
         {DBNAME}.sale_products AS sp
         INNER JOIN {DBNAME}.sale_order AS so ON sp.sale_order_no = so.sale_no
         Inner Join {DBNAME}.customer as cs ON so.sale_custom_no= cs.custom_no
-        inner join   {DBNAME}.materiel as m on sp.colour_number= m.materiel_code
-        inner join   {DBNAME}.production as pd on sp.product_no= pd.product_no
-        left  join  {DBNAME}.production_line as pl on sp.production_line_no=pl.id
+        inner join {DBNAME}.materiel as m on sp.colour_number= m.materiel_code
+        inner join {DBNAME}.production as pd on sp.product_no= pd.product_no
+        left join {DBNAME}.production_line as pl on sp.production_line_no=pl.id
         where sp.del_flag = '0' and cs.del_flag = '0' and m.del_flag = '0' and so.order_type=2
-        <if test="saleProductNo != null  and saleProductNo != ''"> and sale_product_no = #{saleProductNo}</if>
-        <if test="saleOrderNo != null  and saleOrderNo != ''"> and sale_order_no = #{saleOrderNo}</if>
-        <if test="productNo != null  and productNo != ''"> and product_no = #{productNo}</if>
-        <if test="productName != null  and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
-        <if test="productNumber != null "> and product_number = #{productNumber}</if>
-        <if test="productWeight != null  and productWeight != ''"> and product_weight = #{productWeight}</if>
-        <if test="productUnitPrice != null  and productUnitPrice != ''"> and product_unit_price = #{productUnitPrice}</if>
-        <if test="productAmounts != null  and productAmounts != ''"> and product_amounts = #{productAmounts}</if>
-        <if test="productNotes != null  and productNotes != ''"> and product_notes = #{productNotes}</if>
-        <if test="createById != null "> and create_by_id = #{createById}</if>
-        <if test="updateById != null "> and update_by_id = #{updateById}</if>
-        <if test="taskProcessKey != null  and taskProcessKey != ''"> and task_process_key = #{taskProcessKey}</if>
-        <if test="taskNodeKey != null  and taskNodeKey != ''"> and task_node_key = #{taskNodeKey}</if>
-        <if test="processKey != null  and processKey != ''"> and process_key = #{processKey}</if>
-        <if test="status != null  and status != ''"> and sp.status = #{status}</if>
-        <if test="productionLineNo = null  and productionLineNo = ''"> AND sp.production_line_no is null</if>
-        <if test="productionLineNo != null  and productionLineNo != ''"> AND sp.production_line_no=#{productionLineNo}</if>
-        <if test="sliceType != null  and sliceType != ''"> and slice_type = #{sliceType}</if>
-        <if test="colourNumber != null  and colourNumber != ''"> and colour_number = #{colourNumber}</if>
-        <if test="lotNumber != null  and lotNumber != ''"> and lot_number = #{lotNumber}</if>
+        <if test="saleProductNo != null  and saleProductNo != ''">and sale_product_no = #{saleProductNo}</if>
+        <if test="saleOrderNo != null  and saleOrderNo != ''">and sale_order_no = #{saleOrderNo}</if>
+        <if test="productNo != null  and productNo != ''">and product_no = #{productNo}</if>
+        <if test="productName != null  and productName != ''">and product_name like concat('%', #{productName}, '%')
+        </if>
+        <if test="productNumber != null ">and product_number = #{productNumber}</if>
+        <if test="productWeight != null  and productWeight != ''">and product_weight = #{productWeight}</if>
+        <if test="productUnitPrice != null  and productUnitPrice != ''">and product_unit_price = #{productUnitPrice}
+        </if>
+        <if test="productAmounts != null  and productAmounts != ''">and product_amounts = #{productAmounts}</if>
+        <if test="productNotes != null  and productNotes != ''">and product_notes = #{productNotes}</if>
+        <if test="createById != null ">and create_by_id = #{createById}</if>
+        <if test="updateById != null ">and update_by_id = #{updateById}</if>
+        <if test="taskProcessKey != null  and taskProcessKey != ''">and task_process_key = #{taskProcessKey}</if>
+        <if test="taskNodeKey != null  and taskNodeKey != ''">and task_node_key = #{taskNodeKey}</if>
+        <if test="processKey != null  and processKey != ''">and process_key = #{processKey}</if>
+        <if test="status != null  and status != ''">and sp.status = #{status}</if>
+        <if test="productionLineNo = null  and productionLineNo = ''">AND sp.production_line_no is null</if>
+        <if test="productionLineNo != null  and productionLineNo != ''">AND sp.production_line_no=#{productionLineNo}
+        </if>
+        <if test="sliceType != null  and sliceType != ''">and slice_type = #{sliceType}</if>
+        <if test="colourNumber != null  and colourNumber != ''">and colour_number = #{colourNumber}</if>
+        <if test="lotNumber != null  and lotNumber != ''">and lot_number = #{lotNumber}</if>
     </select>
 
     <select id="selectSaleProductsById" parameterType="Long" resultMap="SaleProductsResult">
         <include refid="selectSaleProductsVo"/>
         where id = #{id}
     </select>
-        
-    <insert id="insertSaleProducts" parameterType="com.zkqy.business.domain.SaleProducts" useGeneratedKeys="true" keyProperty="id">
+
+    <insert id="insertSaleProducts" parameterType="com.zkqy.business.domain.SaleProducts" useGeneratedKeys="true"
+            keyProperty="id">
         insert into {DBNAME}.sale_products
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="saleProductNo != null">sale_product_no,</if>
@@ -194,7 +235,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="lotNumber != null">lot_number,</if>
             <if test="onBoardState != null">on_board_state,</if>
             del_flag
-         </trim>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="saleProductNo != null">#{saleProductNo},</if>
             <if test="saleOrderNo != null">#{saleOrderNo},</if>
@@ -220,7 +261,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="lotNumber != null">#{lotNumber},</if>
             <if test="onBoardState != null">#{onBoardState},</if>
             '0'
-         </trim>
+        </trim>
     </insert>
 
     <update id="updateSaleProducts" parameterType="com.zkqy.business.domain.SaleProducts">
@@ -288,7 +329,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </update>
 
     <delete id="deleteSaleProductsById" parameterType="Long">
-        delete from sale_products where id = #{id}
+        delete
+        from sale_products
+        where id = #{id}
     </delete>
 
     <update id="deleteSaleProductsByIds">
@@ -309,6 +352,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             where id = #{item.id}
         </foreach>
     </update>
+    <update id="updateSaleProduct">
+        update {DBNAME}.sale_products
+        set
+            production_line_no=#{productionLineNo}, lot_number=#{lotNumber}, on_board_state=#{onBoardState}, product_number=#{productNumber}
+        where id = #{id}
+    </update>
     <update id="updateSaleProductsNull">
         update {DBNAME}.sale_products
         <trim prefix="SET" suffixOverrides=",">
@@ -341,156 +390,144 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where id = #{id}
     </update>
     <select id="selectSaleProductsIds" resultType="long">
-        select id from {DBNAME}.sale_products where sale_order_no = #{saleOrderNo}
+        select id
+        from {DBNAME}.sale_products
+        where sale_order_no = #{saleOrderNo}
     </select>
 
     <select id="selectSaleProductsInfo" resultType="com.zkqy.business.domain.vo.ProductInvoiceVO$SaleProductInfo">
-        SELECT
-            a.*,
-            pi.levels,
-            pi.qr_code
-        FROM
-            (
-                SELECT
-                    pt.id AS productId,
-                    pt.product_no AS productCode,
-                    pt.product_name AS productName,
-                    pt.product_specifications AS productSpecifications,
-                    sp.lot_number AS lotNum,
-                    sp.product_unit_price AS unitPrice,
-                    concat(ml.materie_encoding,ml.materie_color_number)  AS productColor,
-                    pt.product_type AS productType,
-                    sp.remark AS productRemark,
-                    sp.product_number AS actualWeight
-                FROM
-                    {DBNAME}.sale_products sp
-                        LEFT JOIN {DBNAME}.production pt ON sp.product_no = pt.product_no
-                    left join {DBNAME}.materiel ml on sp.colour_number = ml.materiel_code
-                WHERE
-                    sp.del_flag = '0'
-                  AND pt.del_flag = '0'
-                   and  ml.del_flag = '0'
-                  AND sp.sale_order_no = #{saleOrderNo}
-            ) AS a
-                LEFT JOIN {DBNAME}.product_inventory pi ON a.productId = pi.product_id and a.productColor = pi.product_colour
-                 where  pi.del_flag = '0'
-                group by a.productId,a.lotNum,a.productColor,pi.levels
+        SELECT a.*,
+               pi.levels,
+               pi.qr_code
+        FROM (SELECT pt.id                                                AS productId,
+                     pt.product_no                                        AS productCode,
+                     pt.product_name                                      AS productName,
+                     pt.product_specifications                            AS productSpecifications,
+                     sp.lot_number                                        AS lotNum,
+                     sp.product_unit_price                                AS unitPrice,
+                     concat(ml.materie_encoding, ml.materie_color_number) AS productColor,
+                     pt.product_type                                      AS productType,
+                     sp.remark                                            AS productRemark,
+                     sp.product_number                                    AS actualWeight
+              FROM {DBNAME}.sale_products sp
+                        LEFT JOIN {DBNAME}.production pt
+              ON sp.product_no = pt.product_no
+                  left join {DBNAME}.materiel ml on sp.colour_number = ml.materiel_code
+              WHERE
+                  sp.del_flag = '0'
+                AND pt.del_flag = '0'
+                and ml.del_flag = '0'
+                AND sp.sale_order_no = #{saleOrderNo}) AS a
+                 LEFT JOIN {DBNAME}.product_inventory pi
+        ON a.productId = pi.product_id and a.productColor = pi.product_colour
+        where pi.del_flag = '0'
+        group by a.productId, a.lotNum, a.productColor, pi.levels
     </select>
 
 
     <select id="selectSaleProductsInfo1" resultType="com.zkqy.business.domain.vo.ProductInvoiceVO$SaleProductInfo">
-                SELECT
-                    pt.id AS productId,
-                    pt.product_no AS productCode,
-                    pt.product_name AS productName,
-                    pt.product_specifications AS productSpecifications,
-                    sp.product_unit_price AS unitPrice,
-                    concat(ml.materie_encoding,ml.materie_color_number)  AS productColor,
-                    pt.product_type AS productType,
-                    sp.remark AS productRemark,
-                    sp.product_number AS actualWeight
-                FROM
-                    {DBNAME}.sale_products sp
-                        LEFT JOIN {DBNAME}.production pt ON sp.product_no = pt.product_no
-                    left join {DBNAME}.materiel ml on sp.colour_number = ml.materiel_code
-                WHERE
-                    sp.del_flag = '0'
-                  AND pt.del_flag = '0'
-                  and  ml.del_flag = '0'
-                  AND sp.sale_order_no = #{saleOrderNo}
+        SELECT pt.id                                                AS productId,
+               pt.product_no                                        AS productCode,
+               pt.product_name                                      AS productName,
+               pt.product_specifications                            AS productSpecifications,
+               sp.product_unit_price                                AS unitPrice,
+               concat(ml.materie_encoding, ml.materie_color_number) AS productColor,
+               pt.product_type                                      AS productType,
+               sp.remark                                            AS productRemark,
+               sp.product_number                                    AS actualWeight
+        FROM {DBNAME}.sale_products sp
+                        LEFT JOIN {DBNAME}.production pt
+        ON sp.product_no = pt.product_no
+            left join {DBNAME}.materiel ml on sp.colour_number = ml.materiel_code
+        WHERE
+            sp.del_flag = '0'
+          AND pt.del_flag = '0'
+          and ml.del_flag = '0'
+          AND sp.sale_order_no = #{saleOrderNo}
 
     </select>
 
 
     <select id="selectSaleProductsInfo2" resultType="com.zkqy.business.domain.vo.ProductInvoiceVO$SaleProductInfo">
-        SELECT
-            a.*,
-            IFNULL( sp.product_unit_price, 0 ) AS unitPrice,
-            sp.remark AS productRemark,
-            sp.product_number AS actualWeight
-        FROM
-            (
-                SELECT
-                    p.id AS productId,
-                    p.product_no AS productCode,
-                    p.product_name AS productName,
-                    p.product_specifications AS productSpecifications,
-                    r.lot_num AS lotNum,
-                    r.levels,
-                    count( r.id ) AS boxNum,
-                    TRUNCATE ( sum( r.suttle ), 2 ) AS weight,
-                    r.product_colour AS productColor,
-                    p.product_type AS productType,
-                    pi.sale_order_no
-                FROM
-                    {DBNAME}.product_outbound_record r
-                        LEFT JOIN {DBNAME}.production p ON r.product_id = p.id
-                        LEFT JOIN {DBNAME}.product_invoice pi ON r.notice_number = pi.notice_number
-                        AND pi.del_flag = '0'
-                WHERE
-                    r.del_flag = '0'
-                  AND r.notice_number = #{noticeNumber}
-                GROUP BY
-                    r.lot_num,
-                    r.product_id,
-                    r.product_colour,
-                    r.levels
-            ) AS a
-                LEFT JOIN {DBNAME}.sale_products sp ON sp.sale_order_no = a.sale_order_no
-                AND sp.product_no = a.productCode and sp.del_flag = '0'
+        SELECT a.*,
+               IFNULL(sp.product_unit_price, 0) AS unitPrice,
+               sp.remark                        AS productRemark,
+               sp.product_number                AS actualWeight
+        FROM (SELECT p.id                       AS productId,
+                     p.product_no               AS productCode,
+                     p.product_name             AS productName,
+                     p.product_specifications   AS productSpecifications,
+                     r.lot_num                  AS lotNum,
+                     r.levels,
+                     count(r.id)                AS boxNum,
+                     TRUNCATE(sum(r.suttle), 2) AS weight,
+                     r.product_colour           AS productColor,
+                     p.product_type             AS productType,
+                     pi.sale_order_no
+              FROM {DBNAME}.product_outbound_record r
+                        LEFT JOIN {DBNAME}.production p
+              ON r.product_id = p.id
+                  LEFT JOIN {DBNAME}.product_invoice pi ON r.notice_number = pi.notice_number
+                  AND pi.del_flag = '0'
+              WHERE
+                  r.del_flag = '0'
+                AND r.notice_number = #{noticeNumber}
+              GROUP BY
+                  r.lot_num,
+                  r.product_id,
+                  r.product_colour,
+                  r.levels) AS a
+                 LEFT JOIN {DBNAME}.sale_products sp
+        ON sp.sale_order_no = a.sale_order_no
+            AND sp.product_no = a.productCode and sp.del_flag = '0'
 
     </select>
 
     <select id="selectSaleProductsInfo3" resultType="com.zkqy.business.domain.vo.ProductInvoiceVO$SaleProductInfo">
-        SELECT
-            a.*,
-            IFNULL( sp.product_unit_price, 0 ) AS unitPrice,
-            sp.remark AS productRemark,
-            sp.product_number AS actualWeight
-        FROM
-            (
-                SELECT
-                    p.id AS productId,
-                    p.product_no AS productCode,
-                    p.product_name AS productName,
-                    p.product_specifications AS productSpecifications,
-                    r.lot_num AS lotNum,
-                    r.levels,
-                    count( r.id ) AS boxNum,
-                    TRUNCATE ( sum( r.suttle ), 2 ) AS weight,
-                    r.product_colour AS productColor,
-                    p.product_type AS productType,
-                    pi.sale_order_no
-                FROM
-                    {DBNAME}.product_handset_outbound_record r
-                        LEFT JOIN {DBNAME}.production p ON r.product_id = p.id
-                    LEFT JOIN {DBNAME}.product_invoice pi ON r.notice_number = pi.notice_number
-                    AND pi.del_flag = '0'
-                WHERE
-                    r.del_flag = '0'
-                  AND r.notice_number = #{noticeNumber}
-                GROUP BY
-                    r.lot_num,
-                    r.product_id,
-                    r.product_colour,
-                    r.levels
-            ) AS a
-                LEFT JOIN {DBNAME}.sale_products sp ON sp.sale_order_no = a.sale_order_no
+        SELECT a.*,
+               IFNULL(sp.product_unit_price, 0) AS unitPrice,
+               sp.remark                        AS productRemark,
+               sp.product_number                AS actualWeight
+        FROM (SELECT p.id                       AS productId,
+                     p.product_no               AS productCode,
+                     p.product_name             AS productName,
+                     p.product_specifications   AS productSpecifications,
+                     r.lot_num                  AS lotNum,
+                     r.levels,
+                     count(r.id)                AS boxNum,
+                     TRUNCATE(sum(r.suttle), 2) AS weight,
+                     r.product_colour           AS productColor,
+                     p.product_type             AS productType,
+                     pi.sale_order_no
+              FROM {DBNAME}.product_handset_outbound_record r
+                        LEFT JOIN {DBNAME}.production p
+              ON r.product_id = p.id
+                  LEFT JOIN {DBNAME}.product_invoice pi ON r.notice_number = pi.notice_number
+                  AND pi.del_flag = '0'
+              WHERE
+                  r.del_flag = '0'
+                AND r.notice_number = #{noticeNumber}
+              GROUP BY
+                  r.lot_num,
+                  r.product_id,
+                  r.product_colour,
+                  r.levels) AS a
+                 LEFT JOIN {DBNAME}.sale_products sp
+        ON sp.sale_order_no = a.sale_order_no
             AND sp.product_no = a.productCode and sp.del_flag = '0'
 
     </select>
 
     <select id="selectOutboundOrderInfo" resultType="com.zkqy.business.domain.vo.SaleProductsVo">
-        SELECT
-            p.product_name as productName,
-            p.product_specifications as productSpecifications,
-            sp.lot_number as lotNumber,
-            sp.product_number as productNumber,
-            sp.product_unit_price as productUnitPrice,
-            sp.product_amounts as productAmounts
-        FROM
-            {DBNAME}.sale_products sp
-                LEFT JOIN {DBNAME}.production p ON sp.product_no = p.product_no
+        SELECT p.product_name           as productName,
+               p.product_specifications as productSpecifications,
+               sp.lot_number            as lotNumber,
+               sp.product_number        as productNumber,
+               sp.product_unit_price    as productUnitPrice,
+               sp.product_amounts       as productAmounts
+        FROM {DBNAME}.sale_products sp
+                LEFT JOIN {DBNAME}.production p
+        ON sp.product_no = p.product_no
         WHERE
             sp.del_flag = '0'
           AND p.del_flag = '0'
@@ -505,29 +542,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         {DBNAME}.sale_products AS sp
         INNER JOIN {DBNAME}.sale_order AS so ON sp.sale_order_no = so.sale_no
         Inner Join {DBNAME}.customer as cs ON so.sale_custom_no= cs.custom_no
-        inner join   {DBNAME}.materiel as m on sp.colour_number= m.materiel_code
-        inner join   {DBNAME}.production as pd on sp.product_no= pd.product_no
-        left  join  {DBNAME}.production_line as pl on sp.production_line_no=pl.id
+        inner join {DBNAME}.materiel as m on sp.colour_number= m.materiel_code
+        inner join {DBNAME}.production as pd on sp.product_no= pd.product_no
+        left join {DBNAME}.production_line as pl on sp.production_line_no=pl.id
         where sp.del_flag = '0' and cs.del_flag = '0' and m.del_flag = '0' and sp.status!=6 and so.order_type=2
-        <if test="saleProductNo != null  and saleProductNo != ''"> and sale_product_no = #{saleProductNo}</if>
-        <if test="saleOrderNo != null  and saleOrderNo != ''"> and sale_order_no = #{saleOrderNo}</if>
-        <if test="productNo != null  and productNo != ''"> and product_no = #{productNo}</if>
-        <if test="productName != null  and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
-        <if test="productNumber != null "> and product_number = #{productNumber}</if>
-        <if test="productWeight != null  and productWeight != ''"> and product_weight = #{productWeight}</if>
-        <if test="productUnitPrice != null  and productUnitPrice != ''"> and product_unit_price = #{productUnitPrice}</if>
-        <if test="productAmounts != null  and productAmounts != ''"> and product_amounts = #{productAmounts}</if>
-        <if test="productNotes != null  and productNotes != ''"> and product_notes = #{productNotes}</if>
-        <if test="createById != null "> and create_by_id = #{createById}</if>
-        <if test="updateById != null "> and update_by_id = #{updateById}</if>
-        <if test="taskProcessKey != null  and taskProcessKey != ''"> and task_process_key = #{taskProcessKey}</if>
-        <if test="taskNodeKey != null  and taskNodeKey != ''"> and task_node_key = #{taskNodeKey}</if>
-        <if test="processKey != null  and processKey != ''"> and process_key = #{processKey}</if>
-        <if test="status != null  and status != ''"> and sp.status = #{status}</if>
-<!--        <if test="productionLineNo != null  and productionLineNo != ''"> AND sp.production_line_no=#{productionLineNo}</if>-->
-        <if test="sliceType != null  and sliceType != ''"> and slice_type = #{sliceType}</if>
-        <if test="colourNumber != null  and colourNumber != ''"> and colour_number = #{colourNumber}</if>
-        <if test="lotNumber != null  and lotNumber != ''"> and lot_number = #{lotNumber}</if>
+        <if test="saleProductNo != null  and saleProductNo != ''">and sale_product_no = #{saleProductNo}</if>
+        <if test="saleOrderNo != null  and saleOrderNo != ''">and sale_order_no = #{saleOrderNo}</if>
+        <if test="productNo != null  and productNo != ''">and product_no = #{productNo}</if>
+        <if test="productName != null  and productName != ''">and product_name like concat('%', #{productName}, '%')
+        </if>
+        <if test="productNumber != null ">and product_number = #{productNumber}</if>
+        <if test="productWeight != null  and productWeight != ''">and product_weight = #{productWeight}</if>
+        <if test="productUnitPrice != null  and productUnitPrice != ''">and product_unit_price = #{productUnitPrice}
+        </if>
+        <if test="productAmounts != null  and productAmounts != ''">and product_amounts = #{productAmounts}</if>
+        <if test="productNotes != null  and productNotes != ''">and product_notes = #{productNotes}</if>
+        <if test="createById != null ">and create_by_id = #{createById}</if>
+        <if test="updateById != null ">and update_by_id = #{updateById}</if>
+        <if test="taskProcessKey != null  and taskProcessKey != ''">and task_process_key = #{taskProcessKey}</if>
+        <if test="taskNodeKey != null  and taskNodeKey != ''">and task_node_key = #{taskNodeKey}</if>
+        <if test="processKey != null  and processKey != ''">and process_key = #{processKey}</if>
+        <if test="status != null  and status != ''">and sp.status = #{status}</if>
+        <!--        <if test="productionLineNo != null  and productionLineNo != ''"> AND sp.production_line_no=#{productionLineNo}</if>-->
+        <if test="sliceType != null  and sliceType != ''">and slice_type = #{sliceType}</if>
+        <if test="colourNumber != null  and colourNumber != ''">and colour_number = #{colourNumber}</if>
+        <if test="lotNumber != null  and lotNumber != ''">and lot_number = #{lotNumber}</if>
     </select>
 
     <insert id="batchInsertSaleProducts" parameterType="java.util.List">
@@ -588,6 +627,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </insert>
 
     <select id="selectSaleProductsIdsBySaleNo" parameterType="string" resultType="java.lang.Long">
-        select id from {DBNAME}.sale_products where sale_order_no = #{saleOrderNo} and del_flag = '0'
+        select id
+        from {DBNAME}.sale_products
+        where sale_order_no = #{saleOrderNo} and del_flag = '0'
     </select>
 </mapper>

+ 50 - 40
zkqy-ui/src/views/orderMange/codeListManage/printIndex.vue

@@ -15,7 +15,7 @@
                   type="primary"
                   size="mini"
                   @click="updateOrderData"
-                  >保存修改
+                >保存修改
                 </el-button>
                 <!-- <el-button
                     :disabled="tableData.length != 1"
@@ -40,14 +40,14 @@
                 >
                 </el-switch>
                 <el-button type="primary" size="mini" @click="readStateChange"
-                  >{{ isStartReadNum ? "停止读数" : "开始读数" }}
+                >{{ isStartReadNum ? "停止读数" : "开始读数" }}
                 </el-button>
                 <el-button
                   v-show="!printAuto"
                   type="success"
                   size="mini"
                   @click="printBtnHandler"
-                  >打印
+                >打印
                 </el-button>
               </div>
               <div class="weightWrap" v-show="excuteType == 1">
@@ -121,7 +121,7 @@
                   size="mini"
                   :disabled="chooseState"
                   @click="handleSaveOne(scope.row)"
-                  >保存修改
+                >保存修改
                 </el-button>
                 <el-button
                   v-else-if="excuteType == 3"
@@ -129,7 +129,7 @@
                   size="mini"
                   :disabled="chooseState"
                   @click="handleSuppleOne(scope.row)"
-                  >打印
+                >打印
                 </el-button>
 
                 <el-button
@@ -138,7 +138,7 @@
                   size="mini"
                   :disabled="chooseState"
                   @click="handleDeleteOne(scope.$index, scope.row)"
-                  >删除
+                >删除
                 </el-button>
               </template>
             </el-table-column>
@@ -224,11 +224,11 @@
                       :value="item.id"
                     >
                       <span class="discribe" style="float: left">{{
-                        item.productionLineName
-                      }}</span>
+                          item.productionLineName
+                        }}</span>
                       <span
                         style="float: right; color: #8492a6; font-size: 13px"
-                        >{{ item.productionLineDepartment }}</span
+                      >{{ item.productionLineDepartment }}</span
                       >
                     </el-option>
                   </el-select>
@@ -490,8 +490,8 @@ import {
   removeProductCodeASInventory,
 } from "@/api/codeListManage/productCodeList";
 import codeListPrint from "@/utils/print/codeListPrint";
-import { getServerPrintData } from "@/utils/print/printUtils";
-import { v4 as uuidv4 } from "uuid";
+import {getServerPrintData} from "@/utils/print/printUtils";
+import {v4 as uuidv4} from "uuid";
 import moment from "moment";
 
 export default {
@@ -564,36 +564,36 @@ export default {
       },
       rules: {
         grossWeight: [
-          { required: true, message: "请输入重量", trigger: "change" },
+          {required: true, message: "请输入重量", trigger: "change"},
         ],
         packaging: [
-          { required: true, message: "请选择包装", trigger: "change" },
+          {required: true, message: "请选择包装", trigger: "change"},
         ],
         machineTool: [
-          { required: true, message: "请选择机台", trigger: "change" },
+          {required: true, message: "请选择机台", trigger: "change"},
         ],
         workShifts: [
-          { required: true, message: "请选择班次", trigger: "change" },
+          {required: true, message: "请选择班次", trigger: "change"},
         ],
         productionDate: [
-          { required: true, message: "请选择生产日期", trigger: "change" },
+          {required: true, message: "请选择生产日期", trigger: "change"},
         ],
-        levels: [{ required: true, message: "请选择等级", trigger: "change" }],
+        levels: [{required: true, message: "请选择等级", trigger: "change"}],
         // foreignTradeNumber: [
         //   { required: true, message: "请输入外贸号", trigger: "blur" },
         // ],
         canisterWeight: [
-          { required: true, message: "请选择筒重", trigger: "change" },
+          {required: true, message: "请选择筒重", trigger: "change"},
         ],
         boxWeight: [
-          { required: true, message: "请选择箱重/车重", trigger: "change" },
+          {required: true, message: "请选择箱重/车重", trigger: "change"},
         ],
         tubeColor: [
-          { required: true, message: "请选择管色", trigger: "change" },
+          {required: true, message: "请选择管色", trigger: "change"},
         ],
-        comPort: [{ required: true, message: "请选择端口", trigger: "change" }],
+        comPort: [{required: true, message: "请选择端口", trigger: "change"}],
         printFormat: [
-          { required: true, message: "请选择格式", trigger: "change" },
+          {required: true, message: "请选择格式", trigger: "change"},
         ],
       },
       dropDownData: {},
@@ -712,7 +712,7 @@ export default {
     },
   },
   mounted() {
-    let { excuteType, qrCode } = this.$route.query;
+    let {excuteType, qrCode} = this.$route.query;
     if (excuteType == 2) {
       //修改
       this.handleUpdate(qrCode);
@@ -858,12 +858,14 @@ export default {
         }
       });
 
-      this.websocket.addEventListener("on", (e) => {});
+      this.websocket.addEventListener("on", (e) => {
+      });
       this.websocket.addEventListener("error", (event) => {
         this.$message.error("WebSocket错误,请重试");
       });
 
-      this.websocket.addEventListener("close", () => {});
+      this.websocket.addEventListener("close", () => {
+      });
     },
     // 用于重置与重量相关的状态
     resetWeightStatus() {
@@ -1032,7 +1034,7 @@ export default {
     },
     // 毛重改变回调
     changeGrossWeight(row) {
-      let { boxWeight, grossWeight, canisterWeight, canisterNum } = row;
+      let {boxWeight, grossWeight, canisterWeight, canisterNum} = row;
       if (!Number(grossWeight)) {
         row.suttle = 0;
         return;
@@ -1061,7 +1063,7 @@ export default {
     // 确认保存修改一条数据
     async handleSaveOne(row) {
       try {
-        let { sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight } =
+        let {sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight} =
           this.count;
         let rowData = JSON.parse(JSON.stringify(row));
 
@@ -1090,7 +1092,8 @@ export default {
         } else {
           this.$message.error(`${msg}失败`);
         }
-      } catch (error) {}
+      } catch (error) {
+      }
     },
     // 确认打印回调
     printConfirmHandler(printData) {
@@ -1127,7 +1130,8 @@ export default {
           }
         } else {
         }
-      } catch (error) {}
+      } catch (error) {
+      }
     },
     // 补码打印回调
     handleSuppleOne(row) {
@@ -1140,7 +1144,7 @@ export default {
       this.$refs.form.validate(async (valid) => {
         if (valid) {
           try {
-            let { sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight } =
+            let {sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight} =
               this.count;
             let rowData = newData.machineTool
               ? JSON.parse(JSON.stringify(newData))
@@ -1197,7 +1201,8 @@ export default {
             } else {
               this.$message.error(`${msg}箱单失败`);
             }
-          } catch (error) {}
+          } catch (error) {
+          }
         }
       });
     },
@@ -1206,7 +1211,7 @@ export default {
       this.$refs.form.validate(async (valid) => {
         if (valid) {
           try {
-            let { sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight } =
+            let {sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight} =
               this.count;
             let rowData = JSON.parse(JSON.stringify(this.tableData[0]));
             this.printTableData = [rowData];
@@ -1235,7 +1240,8 @@ export default {
             } else {
               this.$message.error(`${msg}箱单失败`);
             }
-          } catch (error) {}
+          } catch (error) {
+          }
         }
       });
     },
@@ -1345,7 +1351,7 @@ export default {
     },
     // 计算净重
     getSuttle() {
-      let { boxWeight, canisterWeight, canisterNum } = this.form;
+      let {boxWeight, canisterWeight, canisterNum} = this.form;
       return (Number(boxWeight) - canisterWeight * canisterNum).toFixed(2);
     },
     // 表格点击回调
@@ -1386,7 +1392,7 @@ export default {
             this.$refs.form.validate(async (valid) => {
               if (valid) {
                 try {
-                  let { sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight } =
+                  let {sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight} =
                     this.count;
                   let rowData = JSON.parse(JSON.stringify(row));
                   this.printTableData = [rowData];
@@ -1425,7 +1431,8 @@ export default {
                   } else {
                     this.$message.error(`${msg}箱单失败`);
                   }
-                } catch (error) {}
+                } catch (error) {
+                }
               }
             });
           }
@@ -1435,14 +1442,15 @@ export default {
     // 获取所有批次数据
     async getAllBatchData(id) {
       try {
-        let payload = { machineTool: id };
+        let payload = {machineTool: id};
         let res = await finishedProductList(payload);
         if (res.code == 200) {
           this.batchData = res.data;
           this.batchTableData = res.data;
         } else {
         }
-      } catch (error) {}
+      } catch (error) {
+      }
     },
     // 批号查询接口
     batchNumChange() {
@@ -1492,7 +1500,8 @@ export default {
         } else {
           this.$message.error("网络异常!");
         }
-      } catch (error) {}
+      } catch (error) {
+      }
     },
     /** 查询产品码单列表 */
     getList() {
@@ -1697,7 +1706,8 @@ export default {
           this.getList();
           this.$modal.msgSuccess("删除成功");
         })
-        .catch(() => {});
+        .catch(() => {
+        });
     },
     /** 导出按钮操作 */
     handleExport() {

+ 99 - 65
zkqy-ui/src/views/orderMange/outStock/index.vue

@@ -8,7 +8,7 @@
           @click="handleRefresh"
           :icon="loading ? 'el-icon-loading' : 'el-icon-refresh'"
           :disabled="loading"
-          >刷新
+        >刷新
         </el-button>
 
         <el-table
@@ -20,7 +20,7 @@
           highlight-current-row
         >
           <!-- <el-table-column type="selection" width="55" /> -->
-          <el-table-column type="index" label="序号" width="50" />
+          <el-table-column type="index" label="序号" width="50"/>
           <el-table-column align="center" prop="customerName" label="客户名称">
           </el-table-column>
           <el-table-column align="center" prop="noticeNumber" label="通知单号">
@@ -124,16 +124,14 @@
             </el-col> -->
             <el-form-item>
               <el-button type="primary" @click="outStockHandler"
-                >出库
+              >出库
               </el-button>
               <el-button @click="refreshHandler">刷新</el-button>
             </el-form-item>
           </el-form>
         </el-row>
-        <!--        :span-method="objectSpanMethod"-->
-        <!--        :header-cell-style="{'text-align':'center'}"-->
-        <!--        :cell-style="{'text-align':'center'}" ref="tableRef"-->
-        <el-table :data="saleProductInfoList" border stripe>
+        <el-table :data="saleProductInfoList" border stripe :span-method="objectSpanMethod"
+                  :row-class-name="tableRowClassName">
           <el-table-column align="center" label="编码" prop="productCode">
           </el-table-column>
           <el-table-column align="center" label="品名" prop="productName">
@@ -155,8 +153,12 @@
             </el-table-column>
           </el-table-column>
           <el-table-column align="center" label="实发">
+            <el-table-column align="center" label="总箱数" prop="coutBoxNum">
+            </el-table-column>
             <el-table-column align="center" label="箱数" prop="boxNum">
             </el-table-column>
+            <el-table-column align="center" label="总重量" prop="coutweight">
+            </el-table-column>
             <el-table-column align="center" label="重量" prop="weight">
             </el-table-column>
           </el-table-column>
@@ -173,7 +175,7 @@ import {
   queryDropDownBoxData,
   noticeOutStorage,
 } from "@/api/tablelist/commonTable";
-import { mapState } from "vuex";
+import {mapState} from "vuex";
 
 export default {
   name: "OutStock",
@@ -206,55 +208,44 @@ export default {
       saleProductInfoList: [],
       rules: {
         deliveryDate: [
-          { required: true, message: "请选择发货日期", trigger: "change" },
+          {required: true, message: "请选择发货日期", trigger: "change"},
         ],
         deliveryWarehouse: [
-          { required: true, message: "请选择发货仓库", trigger: "change" },
+          {required: true, message: "请选择发货仓库", trigger: "change"},
         ],
         transferWarehouse: [
-          { required: true, message: "请选择调拨仓库", trigger: "change" },
+          {required: true, message: "请选择调拨仓库", trigger: "change"},
         ],
       },
     };
   },
   methods: {
-    // objectSpanMethod({row, column, rowIndex, columnIndex}) {
-    //   if (this.saleProductInfoList.length == 1 || this.saleProductInfoList.length == 0) {
-    //     console.log("当前长度不满足:" + this.saleProductInfoList.length);
-    //     return [1, 1];
-    //   }
-    //   console.log("当前长度满足le:" + this.saleProductInfoList.length);
-    //   if (columnIndex == 6) {
-    //     if (!this.spanArr[rowIndex]) {
-    //       this.spanArr[rowIndex] = {
-    //         rowspan: 1,
-    //         end: false,
-    //       };
-    //     }
-    //     console.log(this.saleProductInfoList);
-    //     console.log(rowIndex);
-    //     let duixiang = this.saleProductInfoList[rowIndex];
-    //     console.log(duixiang)
-    //     console.log(row.productCode === duixiang.productCode)
-    //     console.log(row.productCode, "----", duixiang.productCode)
-    //     if (rowIndex < this.saleProductInfoList.length - 1 && row.productCode === duixiang.productCode) {
-    //       if (!this.spanArr[rowIndex].end) {
-    //         this.spanArr[rowIndex].rowspan += 1;
-    //         this.spanArr[rowIndex + 1] = {
-    //           rowspan: 0,
-    //           end: false,
-    //         };
-    //       }
-    //     } else {
-    //       this.spanArr[rowIndex].end = true;
-    //     }
-    //     if (this.spanArr[rowIndex].rowspan >= 1) {
-    //       console.log([this.spanArr[rowIndex].rowspan, 1])
-    //       return [this.spanArr[rowIndex].rowspan, 1];
-    //     }
-    //   }
-    //
-    // },
+    tableRowClassName({row, rowIndex}) {
+      if (!row.actualWeight && row.actualWeight != 0) {
+        return 'warning-row';
+      }
+    },
+    objectSpanMethod({row, column, rowIndex, columnIndex}) {
+      // 重量
+      if (columnIndex === 6 || columnIndex === 7 || columnIndex === 9) {
+        const prevRow2 = this.saleProductInfoList[rowIndex - 1] //上一行数据
+        let nextRow2 = this.saleProductInfoList[rowIndex + 1] //下一行数据
+        // 当上一行的数据等于当前行数据时,当前行单元格隐藏
+        if (prevRow2 && prevRow2.productCode == row.productCode && prevRow2.productColor == row.productColor) {
+          return {rowspan: 0, colspan: 0}
+        } else {
+          // 反之,则循环判断若下一行数据等于当前行数据,则当前行开始进行合并单元格
+          let countRowspan2 = 1 //用于合并计数多少单元格
+          while (nextRow2 && nextRow2.productCode == row.productCode && nextRow2.productColor == row.productColor) {
+            nextRow2 = this.saleProductInfoList[++countRowspan2 + rowIndex]
+          }
+          if (countRowspan2 > 1) {
+            // this.saleProductInfoList[rowIndex].coutBoxNum = 9;
+            return {rowspan: countRowspan2, colspan: 1}
+          }
+        }
+      }
+    },
     // 刷新回调
     async handleRefresh() {
       this.loading = true;
@@ -283,7 +274,7 @@ export default {
             type: "warning",
           })
             .then(async () => {
-              let payLoad = { ...this.form };
+              let payLoad = {...this.form};
               payLoad.transferWarehouse = payLoad.deliveryWarehouse;
               if (!this.form.id) {
                 return;
@@ -310,7 +301,8 @@ export default {
         }
       });
     },
-    handleSelectionChange() {},
+    handleSelectionChange() {
+    },
     // 初始化仓库选项数据
     async initWarehouse() {
       try {
@@ -330,7 +322,8 @@ export default {
         } else {
           throw new Error(res.msg);
         }
-      } catch (error) {}
+      } catch (error) {
+      }
     },
     // 初始化数据
     async initData() {
@@ -338,7 +331,6 @@ export default {
         let payload = {
           isEnablePaging: false,
           status: 1,
-          // status: 55,
         };
         let res = await productInvoiceList(payload);
         if (res.code == 200) {
@@ -351,7 +343,6 @@ export default {
           throw new Error(res.msg);
         }
       } catch (error) {
-        console.log(error);
       }
     },
     // 根据字典获取文件类型
@@ -402,11 +393,42 @@ export default {
             id,
           } = res.data;
           let documentTypeName = this.getdocumentTypeName(documentType);
-          this.saleProductInfoList = saleProductInfoList;
+          // let list = saleProductInfoList.sort( (a,b)=>{
+          //    let {productColor : colorA,productCode :codeA}=a
+          //    let {productColor : colorB,productCode : codeB}=b
+          //   return (colorA+codeA)-(colorB-codeB)
+          // })
+
+
+          this.saleProductInfoList = saleProductInfoList
+          // 使用 reduce 方法来累加相同 productCode 和 productColor 的第一条数据的 boxNum
+          const codeColorSums = this.saleProductInfoList.reduce((acc, curr, index) => {
+            // 创建一个用于组合 productCode 和 productColor 的键
+            const key = `${curr.productCode}-${curr.productColor}`;
+
+            // 检查当前 key 是否已经存在
+            if (!acc[key]) {
+              // 如果不存在,添加 key 作为键,并将 boxNum 设置为当前值
+              acc[key] = {
+                firstIndex: index,
+                sum: curr.boxNum,
+                weight: curr.weight,
+                count: 1
+              };
+            } else {
+              acc[key].count++; // 增加计数
+              acc[key].sum += curr.boxNum;
+              acc[key].weight += curr.weight;
+            }
+            return acc;
+          }, {});
+          this.saleProductInfoList.forEach((item, index) => {
+            if (codeColorSums[`${item.productCode}-${item.productColor}`]) {
+              item.coutBoxNum = codeColorSums[`${item.productCode}-${item.productColor}`].sum
+              item.coutweight = codeColorSums[`${item.productCode}-${item.productColor}`].weight.toFixed(2)
+            }
+          })
 
-          // this.$nextTick(() => {
-          //   this.$refs.tableRef.doLayout();
-          // });
           Object.assign(this.form, {
             noticeNumber, //通知单号
             documentType, //通知单类型
@@ -420,19 +442,25 @@ export default {
           });
           this.form.deliveryClerk = this.nickName;
         }
-      } catch (error) {}
+      } catch (error) {
+      }
     },
-  },
+  }
+  ,
   computed: {
-    ...mapState({
-      nickName: (state) => state.user.nickName,
-    }),
-  },
+    ...
+      mapState({
+        nickName: (state) => state.user.nickName,
+      }),
+  }
+  ,
   mounted() {
     this.initData();
     this.initWarehouse();
-  },
-};
+  }
+  ,
+}
+;
 </script>
 
 <style scoped lang="scss">
@@ -455,4 +483,10 @@ export default {
 .table-data > .gutter {
   display: table-cell !important;
 }
+
+
+::v-deep .el-table .warning-row {
+  color: red;
+}
+
 </style>