瀏覽代碼

u8产品入库成本导入及工单服务申请单功能补充

hu 4 月之前
父節點
當前提交
ab7123d48e

+ 40 - 0
src/custom/restcontroller/R.java

@@ -6651,6 +6651,46 @@ public class R {
         public static class v1 {
         }
     }
+
+    public static class ID2025082214054703 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025082214055703 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025082214060603 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025082214061603 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025082214071703 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025082214133003 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025082214133803 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID2025082214313103 {
+        public static class v1 {
+        }
+    }
 }
 
 

+ 27 - 10
src/custom/restcontroller/webmanage/sale/aftersalesmag/aftersalesmag.java

@@ -3,9 +3,11 @@ package restcontroller.webmanage.sale.aftersalesmag;
 import beans.accountbalance.Accountbalance;
 import beans.accountbalance.CashbillEntity;
 import beans.aftersalesmag.Aftersalesmag;
+import beans.brand.Brand;
 import beans.data.BatchDeleteErr;
 import beans.datacontrllog.DataContrlLog;
 import beans.hr.Hr;
+import beans.itemclass.ItemClass;
 import beans.parameter.Parameter;
 import beans.remind.Remind;
 import beans.salesforecast.Salesforecast;
@@ -28,6 +30,7 @@ import utility.ERPDocking;
 
 import java.math.BigDecimal;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.HashMap;
 
 
@@ -240,28 +243,42 @@ public class aftersalesmag extends Controller {
                 where.append(")");
             }
         }
-//		String hrid = content.getString("hrid");
-//        SQLFactory sqlFactory = new SQLFactory(this, "审核订单列表查询", pageSize, pageNumber, pageSorting);
-//        sqlFactory.addParameter_SQL("where", where);
-//        sqlFactory.addParameter("siteid", siteid);
-//        sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
-//        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL(false));
         QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_itemsku ", "sku");
         querySQL.setTableAlias("t1");
         querySQL.addJoinTable(JOINTYPE.left, "plm_item", "t2", "t1.itemid=t2.itemid and t1.siteid=t2.siteid","itemid","itemno","itemname","model","spec");
-        querySQL.addJoinTable(JOINTYPE.left, "plm_unit", "t3", "t3.unitid=t2.unitid and t3.siteid=t2.siteid","unitname");
-        querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t4", "t4.sa_agentsid=t1.sa_agentsid and t4.siteid=t1.siteid","agentnum");
-        querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t5", "t5.sys_enterpriseid=t4.sys_enterpriseid and t5.siteid=t4.siteid","contact","phonenumber","address");
         querySQL.addJoinTable(JOINTYPE.inner, "sa_warrantycard", "t6", "t6.sku=t1.sku and t6.siteid=t1.siteid","cardno","begdate","enddate");
+        querySQL.addJoinTable(JOINTYPE.left, "sa_customers", "t7", "t6.sa_customersid=t7.sa_customersid and t6.siteid=t7.siteid","name","phonenumber","province","city","county","address");
 
         querySQL.setSiteid(siteid);
         querySQL.setWhere("t6.sa_customersid",sa_customersid);
         querySQL.setWhere(where.toString());
-        querySQL.setDistinct(true);
         querySQL.setPage(pageSize, pageNumber);
         querySQL.setOrderBy(pageSorting);
         Rows rows = querySQL.query();
 
+        // 默认商品图片
+        Rows defaultImageRows = beans.Item.Item.getItemdefaultImage(this);
+        // 附件
+        ArrayList<Long> ids = rows.toArrayList("itemid", new ArrayList<>());
+        RowsMap attRowsMapCover = getAttachmentUrl("plm_item", ids, "cover");
+        RowsMap attRowsMap = getAttachmentUrl("plm_item", ids);
+
+        for (Row row : rows) {
+            if (attRowsMapCover.getOrDefault(row.getString("itemid"), new Rows()).isNotEmpty()) {
+                row.put("attinfos", attRowsMapCover.getOrDefault(row.getString("itemid"), new Rows()));
+            } else if (attRowsMap.getOrDefault(row.getString("itemid"), new Rows()).isNotEmpty()) {
+                row.put("attinfos", attRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
+            } else {
+                row.put("attinfos", defaultImageRows);
+            }
+            Date date=new Date();
+            if(date.before(row.getDate("enddate"))){
+                row.put("iswarranty", true);
+            }else{
+                row.put("iswarranty", false);
+            }
+        }
+
         return getSucReturnObject().setData(rows).toString();
     }
 

+ 3 - 0
src/custom/restcontroller/webmanage/sale/serviceorder/serviceorder.java

@@ -77,6 +77,9 @@ public class serviceorder extends Controller {
                 if (StringUtils.isBlank(sku)) {
                     return getErrReturnObject().setErrMsg("安装服务单需添加序列号").toString();
                 }
+                if(dbConnect.runSqlQuery("select * from sa_warrantycard where sku='"+sku+"' and siteid='"+siteid+"'").isNotEmpty()){
+                    return getErrReturnObject().setErrMsg("该序列号已安装,无法再次安装").toString();
+                }
             }
         }
         if (content.containsKey("phonenumber") && !"".equals(content.getString("phonenumber"))) {

+ 263 - 0
src/custom/restcontroller/webmanage/sale/u8prodprice/ExportExcel.java

@@ -0,0 +1,263 @@
+package restcontroller.webmanage.sale.u8prodprice;
+
+
+import org.apache.poi.ss.usermodel.BorderStyle;
+import org.apache.poi.ss.usermodel.FillPatternType;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.*;
+
+import java.awt.*;
+
+public class ExportExcel {
+    /**
+     * 设置标题单元样式
+     *
+     * @param workbook
+     * @return
+     */
+    public static XSSFCellStyle createTitleCellStyle1(XSSFWorkbook workbook) {
+        XSSFCellStyle cellStyle = workbook.createCellStyle();
+        XSSFFont font = workbook.createFont();
+        font.setFontHeightInPoints((short) 12);
+        font.setColor(IndexedColors.RED.getIndex());
+        font.setFontName("微软雅黑");// 设置标题字体
+        cellStyle.setFont(font);
+        cellStyle.setWrapText(true);  //自动换行
+        cellStyle = workbook.createCellStyle();
+        cellStyle.setFont(font);// 设置列标题样式
+        XSSFColor colorBlue = new XSSFColor(new Color(48, 84, 150));
+        cellStyle.setFillForegroundColor(colorBlue);
+        cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        cellStyle.setAlignment(HorizontalAlignment.CENTER); // 居中
+        return cellStyle;
+    }
+
+    /**
+     * 设置中文提示信息样式
+     *
+     * @param workbook
+     * @return
+     */
+    public static XSSFCellStyle createTitleCellStyle2(XSSFWorkbook workbook) {
+        XSSFCellStyle cellStyle = workbook.createCellStyle();
+        XSSFFont font = workbook.createFont();
+        font.setFontHeightInPoints((short) 12);
+        font.setColor(IndexedColors.RED.getIndex());
+        font.setFontName("微软雅黑");// 设置标题字体
+        cellStyle.setFont(font);
+        cellStyle.setWrapText(true);  //自动换行
+        cellStyle = workbook.createCellStyle();
+        cellStyle.setFont(font);// 设置列标题样式
+        XSSFColor colorGrey = new XSSFColor(new Color(217, 225, 242));
+        cellStyle.setFillForegroundColor(colorGrey);
+        cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        cellStyle.setAlignment(HorizontalAlignment.LEFT); // 居左
+        return cellStyle;
+    }
+
+    /**
+     * 设置正文单元样式
+     *
+     * @param workbook
+     * @return
+     */
+    public static XSSFCellStyle createBodyCellStyle4(XSSFWorkbook workbook) {
+        XSSFCellStyle cellStyle = workbook.createCellStyle();
+        XSSFFont font = workbook.createFont();
+        font.setFontHeightInPoints((short) 12);
+        font.setFontName("微软雅黑");// 设置标题字体
+        // font.setFontName(HSSFFont.FONT_ARIAL);// 设置标题字体
+        cellStyle.setFont(font);
+        cellStyle = workbook.createCellStyle();
+        cellStyle.setAlignment(HorizontalAlignment.CENTER);
+        return cellStyle;
+    }
+
+    public static XSSFCellStyle createTitleCellStyle3(XSSFWorkbook workbook) {
+        XSSFCellStyle cellStyle = workbook.createCellStyle();
+        XSSFFont font = workbook.createFont();
+        font.setFontHeightInPoints((short) 12);
+        font.setColor(IndexedColors.WHITE.getIndex());
+        font.setFontName("微软雅黑");// 设置标题字体
+        cellStyle.setFont(font);
+        cellStyle.setWrapText(true);  //自动换行
+        cellStyle = workbook.createCellStyle();
+        cellStyle.setFont(font);// 设置列标题样式
+        XSSFColor colorBlue = new XSSFColor(new Color(48, 84, 150));
+        cellStyle.setFillForegroundColor(colorBlue);
+        cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        cellStyle.setAlignment(HorizontalAlignment.CENTER); // 居中
+        return cellStyle;
+    }
+
+    /**
+     * 2022-07-14 17:41:39
+     * 设置表格宽度(导入模板)
+     **/
+    public static void setBatchDetailSheetColumn1(XSSFSheet sheet) {
+        sheet.setDefaultRowHeight((short) 600);
+        sheet.setColumnWidth((short) 0, (short) 5000);
+        sheet.setColumnWidth((short) 1, (short) 5000);
+        sheet.setColumnWidth((short) 2, (short) 5000);
+    }
+
+
+    /**
+     * 2022-07-14 17:41:39
+     * 设置表格宽度(返回错误Excel的样式)
+     **/
+    public static void setBatchDetailSheetColumn2(XSSFSheet sheet) {
+        sheet.setDefaultRowHeight((short) 600);
+        sheet.setColumnWidth((short) 0, (short) 5000);
+        sheet.setColumnWidth((short) 1, (short) 5000);
+        sheet.setColumnWidth((short) 2, (short) 5000);
+        sheet.setColumnWidth((short) 3, (short) 5000);
+    }
+
+    /**
+     * 2022-07-14 17:42:03
+     * 设置表头
+     * cellStyle1 中文提示信息样式
+     * cellStyle2 标题提示信息样式
+     * cellStyle3 正文提示信息样式
+     **/
+    public static void batchDetail(XSSFSheet sheet, XSSFCellStyle cellStyle1, XSSFCellStyle cellStyle2, XSSFCellStyle cellStyle3, XSSFCellStyle cellStyle4, XSSFWorkbook xssfFWorkbook) {
+//        HSSFCellStyle bcs = ExportExcel.createTitleCellStyle1(workbook);
+//        bcs.setBorderBottom(BorderStyle.THIN); //下边框
+//        bcs.setBorderLeft(BorderStyle.THIN);//左边框
+//        bcs.setBorderTop(BorderStyle.THIN);//上边框
+//        bcs.setBorderRight(BorderStyle.THIN);//右边框
+//        bcs.setWrapText(true);
+
+
+        XSSFRow row = null;
+        XSSFCell cell = null;
+
+        cellStyle1.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle1.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle1.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle1.setBorderRight(BorderStyle.THIN);//右边框
+        cellStyle1.setWrapText(true);
+
+        cellStyle2.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle2.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle2.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle2.setBorderRight(BorderStyle.THIN);//右边框
+        cellStyle2.setWrapText(true);
+        cellStyle1.setDataFormat(xssfFWorkbook.createDataFormat().getFormat("TEXT"));
+        cellStyle2.setDataFormat(xssfFWorkbook.createDataFormat().getFormat("TEXT"));
+        cellStyle3.setDataFormat(xssfFWorkbook.createDataFormat().getFormat("TEXT"));
+        cellStyle4.setDataFormat(xssfFWorkbook.createDataFormat().getFormat("TEXT"));
+
+        /*第一行*/
+        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 2));
+
+        /*第一行塞值*/
+        row = sheet.createRow(0);
+
+        cell = row.createCell(0);// ID
+        cell.setCellStyle(cellStyle1);
+        cell.setCellValue("u8产品入库成本明细导入");
+
+        /*第二行*/
+        sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 2));
+        /*第二行塞值*/
+        row = sheet.createRow(1);
+        cell = row.createCell(0);// ID
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("注意:①请按照以下示例填写信息;②最多不超过5000行;③导入前,请记得删除示例行!");
+        /*第三行塞值*/
+        row = sheet.createRow(2);
+
+        cell = row.createCell(0);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("erp仓库编号");
+
+        cell = row.createCell(1);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("品号(必填)");
+
+        cell = row.createCell(2);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("成本单价");
+
+        /*第四行塞值*/
+        row = sheet.createRow(3);
+
+        cell = row.createCell(0);
+        cell.setCellStyle(cellStyle4);
+        cell.setCellValue("测试erp仓库编号");
+
+        cell = row.createCell(1);
+        cell.setCellStyle(cellStyle4);
+        cell.setCellValue("测试品号");
+
+        cell = row.createCell(2);
+        cell.setCellStyle(cellStyle4);
+        cell.setCellValue("测试成本单价");
+
+    }
+
+
+    /**
+     * 2022-07-14 17:42:03
+     * 设置表头
+     **/
+    public static void batchDetailErr(XSSFSheet sheet, XSSFCellStyle cellStyle1, XSSFCellStyle cellStyle2, XSSFCellStyle cellStyle3, XSSFWorkbook workbook) {
+//        HSSFCellStyle bcs = ExportExcel.createTitleCellStyle1(workbook);
+//        bcs.setBorderBottom(BorderStyle.THIN); //下边框
+//        bcs.setBorderLeft(BorderStyle.THIN);//左边框
+//        bcs.setBorderTop(BorderStyle.THIN);//上边框
+//        bcs.setBorderRight(BorderStyle.THIN);//右边框
+//        bcs.setWrapText(true);
+
+
+        XSSFRow row = null;
+        XSSFCell cell = null;
+
+        cellStyle1.setBorderBottom(BorderStyle.THIN); //下边框
+        cellStyle1.setBorderLeft(BorderStyle.THIN);//左边框
+        cellStyle1.setBorderTop(BorderStyle.THIN);//上边框
+        cellStyle1.setBorderRight(BorderStyle.THIN);//右边框
+        cellStyle1.setWrapText(true);
+
+
+
+        /*第一行*/
+        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 3));
+
+        /*第一行塞值*/
+        row = sheet.createRow(0);
+        cell = row.createCell(0);// ID
+        cell.setCellStyle(cellStyle1);
+        cell.setCellValue("u8产品入库成本明细导入");
+        /*第二行*/
+        sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 3));
+        /*第二行塞值*/
+        row = sheet.createRow(1);
+        cell = row.createCell(0);// ID
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("注意:①请按照以下示例填写信息;②最多不超过5000行;③导入前,请记得删除示例行!");
+        /*第三行塞值*/
+        row = sheet.createRow(2);
+
+        cell = row.createCell(0);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("erp仓库编号");
+
+        cell = row.createCell(1);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("品号(必填)");
+
+        cell = row.createCell(2);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("成本单价");
+
+        cell = row.createCell(3);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("错误信息");
+
+    }
+}

+ 214 - 0
src/custom/restcontroller/webmanage/sale/u8prodprice/u8prodprice.java

@@ -0,0 +1,214 @@
+package restcontroller.webmanage.sale.u8prodprice;
+
+import beans.data.BatchDeleteErr;
+import beans.datacontrllog.DataContrlLog;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import common.Controller;
+import common.YosException;
+import common.annotation.API;
+import common.annotation.CACHEING;
+import common.annotation.CACHEING_CLEAN;
+import common.data.*;
+import restcontroller.R;
+
+import java.util.ArrayList;
+
+@API(title = "u8产品入库成本导入")
+public class u8prodprice extends Controller {
+    public u8prodprice(JSONObject content) throws YosException {
+        super(content);
+    }
+
+
+    @API(title = "u8产品入库成本导入更新", apiversion = R.ID2025082214054703.v1.class, intervaltime = 200)
+    @CACHEING_CLEAN(apiClass = {u8prodprice.class})
+    public String insertormodify_u8prodprice() throws YosException {
+        ArrayList<String> sqlList = new ArrayList<>();
+        // 表名
+        String tableName = "sa_u8prodprice";
+        Long sa_u8prodpriceid = content.getLong("sa_u8prodpriceid");
+        String type = content.getStringValue("type");
+        String begindate =content.getString("begindate");
+        String enddate =content.getString("enddate");
+
+        if (sa_u8prodpriceid > 0 && dbConnect.runSqlQuery(
+                        "select sa_u8prodpriceid from sa_u8prodprice where sa_u8prodpriceid=" + sa_u8prodpriceid)
+                .isNotEmpty()) {
+            Rows rows = dbConnect.runSqlQuery(
+                    "SELECT status from sa_u8prodprice WHERE sa_u8prodpriceid = "
+                            + sa_u8prodpriceid);
+            if (rows.isNotEmpty()) {
+                if (rows.get(0).getString("status").equals("新建")) {
+
+                    UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, tableName);
+                    updateSQL.setUniqueid(sa_u8prodpriceid);
+                    updateSQL.setSiteid(siteid);
+                    updateSQL.setValue("type", type);
+                    updateSQL.setValue("begindate",begindate);
+                    updateSQL.setValue("enddate", enddate);
+                    updateSQL.setDateValue("changedate");
+                    updateSQL.setValue("changeby", username);
+                    sqlList.add(updateSQL.getSQL());
+
+                    sqlList.add(DataContrlLog.createLog(this, "sa_u8prodprice", sa_u8prodpriceid, "更新", "u8产品入库成本导入更新成功")
+                            .getSQL());
+                } else {
+                    return getErrReturnObject().setErrMsg("非新建状态下无法编辑").toString();
+                }
+
+            } else {
+                return getErrReturnObject().setErrMsg("该u8产品入库成本导入不存在").toString();
+            }
+
+        }else{
+            InsertSQL insertSQL = SQLFactory.createInsertSQL(this, tableName);
+            sa_u8prodpriceid=createTableID(tableName);
+            insertSQL.setUniqueid(sa_u8prodpriceid);
+            insertSQL.setSiteid(siteid);
+            insertSQL.setValue("billno", createBillCode("u8prodprice"));
+            insertSQL.setValue("type", type);
+            insertSQL.setValue("begindate",begindate);
+            insertSQL.setValue("enddate", enddate);
+            insertSQL.setValue("status", "新建");
+            insertSQL.setValue("createby", username);
+            insertSQL.setValue("changeby", username);
+            insertSQL.setDateValue("createdate");
+            insertSQL.setDateValue("changedate");
+            sqlList.add(insertSQL.getSQL());
+
+            sqlList.add(DataContrlLog.createLog(this, "sa_u8prodprice", sa_u8prodpriceid, "新增", "u8产品入库成本导入新增成功")
+                    .getSQL());
+        }
+
+        dbConnect.runSqlUpdate(sqlList);
+        content.put("sa_u8prodpriceid", sa_u8prodpriceid);
+
+        return queryu8prodpriceMain();
+    }
+
+
+    @API(title = "u8产品入库成本导入详情", apiversion = R.ID2025082214055703.v1.class)
+    @CACHEING
+    public String queryu8prodpriceMain() throws YosException {
+        Long sa_u8prodpriceid = content.getLong("sa_u8prodpriceid");
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_u8prodprice", "*");
+        querySQL.setTableAlias("t1");
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere("t1.sa_u8prodpriceid",sa_u8prodpriceid);
+        Rows rows = querySQL.query();
+        Row row = rows.isNotEmpty() ? rows.get(0) : new Row();
+        return getSucReturnObject().setData(row).toString();
+    }
+
+
+    @API(title = "查询u8产品入库成本导入列表", apiversion = R.ID2025082214060603.v1.class)
+    @CACHEING
+    public String queryu8prodpriceList() throws YosException {
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
+                where.append(" and(");
+                where.append("t1.billno like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.type like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+            if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
+
+                where.append(" and t1.billdate >='" + whereObject.getString("begindate")).append("' ");
+            }
+            if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
+                where.append(" and t1.billdate <='" + whereObject.getString("enddate")).append(" 23:59:59'");
+            }
+            if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
+                where.append(" and t1.status ='").append(whereObject.getString("status")).append("' ");
+            }
+        }
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_u8prodprice", "*");
+        querySQL.setTableAlias("t1");
+
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere(where.toString());
+        querySQL.setPage(pageSize, pageNumber);
+        Rows rows = querySQL.query();
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+
+    @API(title = "删除", apiversion = R.ID2025082214061603.v1.class)
+    @CACHEING_CLEAN(apiClass = {u8prodprice.class})
+    public String delete() throws YosException {
+
+        JSONArray sa_u8prodpriceids = content.getJSONArray("sa_u8prodpriceids");
+        BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_u8prodpriceids.size());
+        for (Object o : sa_u8prodpriceids) {
+            long sa_u8prodpriceid = Long.parseLong(o.toString());
+            Rows RowsStatus = dbConnect
+                    .runSqlQuery("select sa_u8prodpriceid,status from sa_u8prodprice where siteid='" + siteid
+                            + "' and sa_u8prodpriceid='" + sa_u8prodpriceid + "'");
+
+            if (RowsStatus.isNotEmpty()) {
+                if (!RowsStatus.get(0).getString("status").equals("新建")) {
+                    batchDeleteErr.addErr(sa_u8prodpriceid, "非新建状态的u8产品入库成本导入无法删除");
+                    continue;
+                }
+            }
+
+            dbConnect.runSqlUpdate("delete from sa_u8prodprice where siteid='" + siteid + "' and sa_u8prodpriceid="
+                    + sa_u8prodpriceid);
+            dbConnect.runSqlUpdate("delete from sa_u8prodprice_datail where siteid='" + siteid + "' and sa_u8prodpriceid="
+                    + sa_u8prodpriceid);
+        }
+        return batchDeleteErr.getReturnObject().toString();
+    }
+
+
+    @API(title = "审核反审核", apiversion = R.ID2025082214313103.v1.class)
+    @CACHEING_CLEAN( apiClass = {u8prodprice.class})
+    public String check() throws YosException {
+        Long sa_u8prodpriceid = content.getLong("sa_u8prodpriceid");
+        boolean ischeck = content.getBooleanValue("ischeck");
+        Rows rows = dbConnect.runSqlQuery("select t1.sa_u8prodpriceid,t1.status,t1.billno from sa_u8prodprice t1 where t1.sa_u8prodpriceid ='"
+                + sa_u8prodpriceid + "' and  t1.siteid='" + siteid + "'");
+        for (Row row : rows) {
+            if(ischeck){
+                if (!row.getString("status").equals("新建")) {
+                    return getErrReturnObject().setErrMsg("非新建状态的【"+row.getString("billno")+"】u8产品入库成本导入表无法审核")
+                            .toString();
+                }
+            }else{
+                if (!row.getString("status").equals("审核")) {
+                    return getErrReturnObject().setErrMsg("非审核状态的【"+row.getString("billno")+"】u8产品入库成本导入表无法反审核")
+                            .toString();
+                }
+            }
+
+        }
+        ArrayList<String> sqlList = new ArrayList<>();
+        UpdateSQL updateSQL = SQLFactory.createUpdateSQL(this, "sa_u8prodprice");
+        updateSQL.setUniqueid(sa_u8prodpriceid);
+        updateSQL.setSiteid(siteid);
+        updateSQL.setValue("status", ischeck?"审核":"新建");
+        updateSQL.setValue("checkby", ischeck?username:"null");
+        if(ischeck){
+            updateSQL.setDateValue("checkdate");
+        }else{
+            updateSQL.setValue("checkdate","null");
+        }
+
+        sqlList.add(updateSQL.getSQL());
+        if (ischeck) {
+            sqlList.add(
+                    DataContrlLog.createLog(this, "sa_u8prodprice", sa_u8prodpriceid, "审核", "u8产品入库成本导入表审核成功").getSQL());
+        } else {
+            sqlList.add(
+                    DataContrlLog.createLog(this, "sa_u8prodprice", sa_u8prodpriceid, "反审核", "u8产品入库成本导入表反审核成功").getSQL());
+        }
+
+        dbConnect.runSqlUpdate(sqlList);
+        return getSucReturnObject().toString();
+    }
+}

+ 268 - 0
src/custom/restcontroller/webmanage/sale/u8prodprice/u8prodpricedatail.java

@@ -0,0 +1,268 @@
+package restcontroller.webmanage.sale.u8prodprice;
+
+import beans.datacontrllog.DataContrlLog;
+import com.alibaba.fastjson.JSONObject;
+import common.Controller;
+import common.YosException;
+import common.annotation.API;
+import common.annotation.CACHEING;
+import common.annotation.CACHEING_CLEAN;
+import common.data.*;
+import org.apache.commons.lang.StringUtils;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.DataFormat;
+import org.apache.poi.xssf.usermodel.*;
+import restcontroller.R;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+public class u8prodpricedatail extends Controller {
+    public u8prodpricedatail(JSONObject content) throws YosException {
+        super(content);
+    }
+
+
+    @API(title = "u8产品入库成本导入明细列表", apiversion = R.ID2025082214071703.v1.class)
+    @CACHEING
+    public String queryList_u8prodpricedatail() throws YosException {
+        Long sa_sendplanid = content.getLongValue("sa_u8prodpriceid");
+        /*
+          过滤条件设置
+         */
+        StringBuffer where = new StringBuffer(" 1=1 ");
+        if (content.containsKey("where")) {
+            JSONObject whereObject = content.getJSONObject("where");
+            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
+                where.append(" and(");
+                where.append("t1.itemno like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.itemname like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append("or t2.model like'%").append(whereObject.getString("condition")).append("%' ");
+                where.append(")");
+            }
+        }
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_u8prodprice_datail","*");
+        querySQL.setTableAlias("t1");
+        querySQL.addJoinTable(JOINTYPE.left, "plm_item", "t2", "t1.siteid = t2.siteid and t1.itemno = t2.itemno","itemname","model","itemid");
+        querySQL.setSiteid(siteid);
+        querySQL.setWhere(where.toString());
+        querySQL.setPage(pageSize, pageNumber);
+        querySQL.setOrderBy(pageSorting);
+        Rows rows = querySQL.query();
+        return getSucReturnObject().setData(rows).toString();
+    }
+    
+
+    @API(title = "下载u8产品入库成本导入明细模板", apiversion = R.ID2025082214133803.v1.class)
+    public String downloadU8prodpricedatailExcel() throws YosException {
+        ExcelFactory excelFactory = new ExcelFactory("u8产品入库成本导入明细导入模板");
+
+        XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet("Sheet1");
+        XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
+        CellStyle style = xssfFWorkbook.createCellStyle();
+        DataFormat format = xssfFWorkbook.createDataFormat();
+        style.setDataFormat(format.getFormat("@"));
+        // 对单独某一列进行样式赋值,第一个参数为列数,第二个参数为样式
+        for (int i = 0; i <= 2; i++) {
+            sheet.setDefaultColumnStyle(i, style);
+        }
+        // 设置工作薄列宽
+        ExportExcel.setBatchDetailSheetColumn1(sheet);// 设置工作薄列宽
+        XSSFCellStyle titleCellStyle1 =ExportExcel.createTitleCellStyle1(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle2 = ExportExcel.createTitleCellStyle2(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle3 = ExportExcel.createTitleCellStyle3(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle4 = ExportExcel.createBodyCellStyle4(xssfFWorkbook);
+
+       ExportExcel.batchDetail(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, titleCellStyle4, xssfFWorkbook);
+
+        Rows aa = uploadExcelToObs(excelFactory);
+        String url = "";
+        if (!aa.isEmpty()) {
+            url = aa.get(0).getString("url");
+        }
+        return getSucReturnObject().setData(url).toString();
+
+    }
+
+   
+
+    /**
+     * 导入u8产品入库成本导入明细
+     *
+     * @return
+     */
+    @API(title = "导入u8产品入库成本导入明细", apiversion = R.ID2025082214133003.v1.class)
+    @CACHEING_CLEAN(apiversions = {R.ID20221215100903.v1.class, R.ID20221215101003.v1.class})
+    public String uploadU8propriceByExcel() throws YosException {
+
+        Long sa_u8prodpriceid = content.getLong("sa_u8prodpriceid");
+        Rows u8prodprice = dbConnect.runSqlQuery("select status from sa_u8prodprice where siteid='" + siteid + "' and sa_u8prodpriceid=" + sa_u8prodpriceid);
+        if (u8prodprice.isEmpty()) {
+            return getErrReturnObject().setErrMsg("该u8产品入库成本单不存在").toString();
+        }
+        if (!u8prodprice.get(0).getString("status").equals("新建")) {
+            return getErrReturnObject().setErrMsg("非新建状态不能导入").toString();
+        }
+        ArrayList<String> sqlList = new ArrayList<>();
+        ExcelFactory e;
+        try {
+
+            // 华为云
+            e = getPostExcelFactory(content.getLong("attachmentid"));
+            // 本地
+            //e = getPostExcelFactory();
+
+            ArrayList<String> keys = new ArrayList<>();
+            keys.add("stockno");
+            keys.add("itemno");
+            keys.add("costprice");
+
+            Rows rows = e.getSheetRows(0, keys, 3);
+            boolean iserr = false;
+            Rows rowserr = new Rows();
+            Rows rowssuc = new Rows();
+
+            RowsMap itemRowsMap = dbConnect.runSqlQuery("select itemid,itemno from plm_item where siteid='" + siteid + "'").toRowsMap("itemno");
+
+            RowsMap imtitemRowsMap = rows.toRowsMap("itemno");
+            for (Row row : rows) {
+                String itemno = row.getString("itemno");
+                String stockno = row.getString("stockno");
+                String costprice = row.getString("costprice");
+                if (StringUtils.isEmpty(itemno)) {
+                    iserr = true;
+                    row.put("msg", "错误信息:品号不能为空");
+                    rowserr.add(row);
+                    continue;
+                }
+                if(!isNumeric(costprice)){
+                    iserr = true;
+                    row.put("msg", "成本单价不为数字格式,请检查");
+                    rowserr.add(row);
+                    continue;
+                }
+                if (imtitemRowsMap.get(itemno).size() > 1) {
+                    iserr = true;
+                    row.put("msg", "错误信息:本次导入存在重复商品");
+                    rowserr.add(row);
+                    continue;
+                }
+                if (!itemRowsMap.containsKey(itemno)) {
+                    iserr = true;
+                    row.put("msg", "错误信息:商品不存在");
+                    rowserr.add(row);
+                    continue;
+                } else {
+                    row.put("itemid", itemRowsMap.get(itemno).get(0).getLong("itemid"));
+                }
+                rowssuc.add(row);
+            }
+            if (iserr) {
+                ExcelFactory excelFactory = new ExcelFactory("商品明细导入错误信息");
+                HashMap<String, String> map = new HashMap<String, String>();
+                map.put("stockno", "erp仓库");
+                map.put("itemno", "品号");
+                map.put("costprice", "成本单价");
+                map.put("msg", "错误信息");
+                ArrayList<String> colNameList = new ArrayList<String>();
+                HashMap<String, Class> keytypemap = new HashMap<String, Class>();
+                colNameList.add("stockno");
+                colNameList.add("itemno");
+                colNameList.add("costprice");
+                colNameList.add("msg");
+                keytypemap.put("stockno", String.class);
+                keytypemap.put("itemno", String.class);
+                keytypemap.put("costprice", String.class);
+                keytypemap.put("msg", String.class);
+                rowserr.setFieldList(colNameList);
+                rowserr.setFieldTypeMap(keytypemap);
+                addSheet(excelFactory, "Sheet1", rowserr, map);
+
+                Rows aa = uploadExcelToObs(excelFactory);
+                String url = "";
+                if (!aa.isEmpty()) {
+                    url = aa.get(0).getString("url");
+                }
+                return getSucReturnObject().setData(url).toString();
+            }
+
+            if (!rowssuc.isEmpty()) {
+                for (Row row : rowssuc) {
+                    InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_u8prodprice_datail");
+                    insertSQL.setUniqueid(createTableID("sa_u8prodprice_datail"));
+                    insertSQL.setSiteid(siteid);
+                    insertSQL.setValue("sa_u8prodpriceid", sa_u8prodpriceid);
+                    insertSQL.setValue("itemno", row.getString("itemno"));
+                    insertSQL.setValue("stockno", row.getString("stockno"));
+                    insertSQL.setValue("costprice", row.getDouble("costprice"));
+                    sqlList.add(insertSQL.getSQL());
+                }
+            }
+
+            if (!sqlList.isEmpty()) {
+                dbConnect.runSqlUpdate(sqlList);
+            }
+        } catch (Exception e1) {
+            e1.printStackTrace();
+            return getErrReturnObject().setErrMsg(e1.getMessage()).toString();
+        }
+        return getSucReturnObject().toString();
+
+    }
+    public XSSFSheet addSheet(ExcelFactory excelFactory, String sheetname, Rows datarows,
+                              HashMap<String, String> titlemap) {
+        ArrayList<String> keylist = datarows.getFieldList();
+        XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet(sheetname);
+        XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
+
+        XSSFCellStyle xssfCellStyle1 = xssfFWorkbook.createCellStyle();
+        XSSFFont font = xssfFWorkbook.createFont();
+
+        font.setColor((short) 0xa);
+        font.setFontHeightInPoints((short) 12);
+        font.setBold(true);
+        xssfCellStyle1.setFont(font);
+
+        CellStyle style = xssfFWorkbook.createCellStyle();
+        DataFormat format = xssfFWorkbook.createDataFormat();
+        style.setDataFormat(format.getFormat("@"));
+        // 对单独某一列进行样式赋值,第一个参数为列数,第二个参数为样式
+        for (int i = 0; i <= 3; i++) {
+            sheet.setDefaultColumnStyle(i, style);
+        }
+        ExportExcel.setBatchDetailSheetColumn2(sheet);// 设置工作薄列宽
+        XSSFCellStyle titleCellStyle1 = ExportExcel.createTitleCellStyle1(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle2 = ExportExcel.createTitleCellStyle2(xssfFWorkbook);
+        XSSFCellStyle titleCellStyle3 = ExportExcel.createTitleCellStyle3(xssfFWorkbook);
+        ExportExcel.batchDetailErr(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, xssfFWorkbook);// 写入标题
+
+        for (int n = 0; n < datarows.size(); n++) {
+            Row row = datarows.get(n);
+            XSSFRow datarow = sheet.createRow(n + 3);
+            for (int i1 = 0; i1 < keylist.size(); i1++) {
+                Class fieldclazztype = datarows.getFieldMeta(keylist.get(i1)).getFieldtype();
+                if (fieldclazztype == Integer.class) {
+                    datarow.createCell(i1).setCellValue(row.getInteger((String) keylist.get(i1)));
+                } else if (fieldclazztype == Long.class) {
+                    datarow.createCell(i1).setCellValue(row.getLong((String) keylist.get(i1)));
+                } else if (fieldclazztype == Float.class) {
+                    datarow.createCell(i1).setCellValue(row.getFloat((String) keylist.get(i1)));
+                } else if (fieldclazztype == Double.class) {
+                    datarow.createCell(i1).setCellValue(row.getDouble((String) keylist.get(i1)));
+                } else {
+                    datarow.createCell(i1).setCellValue(row.getString((String) keylist.get(i1)));
+                }
+                if (i1 == 3) {
+                    datarow.getCell(i1).setCellStyle(xssfCellStyle1);
+                }
+            }
+        }
+        return sheet;
+    }
+    public static boolean isNumeric(String strNum) {
+        if (strNum == null) {
+            return false;
+        }
+        return strNum.matches("-?\\d+(\\.\\d+)?");
+    }
+}

+ 37 - 3
src/custom/restcontroller/webmanage/sale/workorder/workorder.java

@@ -974,11 +974,35 @@ public class workorder extends Controller {
         }
 
         if(rows.get(0).getString("type").equals("安装")){
-            Rows itemrows =dbConnect.runSqlQuery("select t1.sku,ifnull(t2.warrantyday,0) warrantyday,t4.sa_agentsid from sa_serviceorderitems t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid left join sa_serviceorder t3 on t1.sa_serviceorderid=t3.sa_serviceorderid and t1.siteid=t3.siteid left join sa_agents t4 on t3.sys_enterpriseid=t4.sys_enterpriseid and t3.siteid=t4.siteid where t1.sa_serviceorderid="+rows.get(0).getLong("sa_serviceorderid")+" and t1.siteid='"+siteid+"' ");
+            Rows itemrows =dbConnect.runSqlQuery("select t3.sa_customersid,t3.name,t3.phonenumber,t3.province,t3.city,t3.county,t3.address,t1.sku,ifnull(t2.warrantyday,0) warrantyday,t4.sa_agentsid,t3.sys_enterpriseid from sa_serviceorderitems t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid left join sa_serviceorder t3 on t1.sa_serviceorderid=t3.sa_serviceorderid and t1.siteid=t3.siteid left join sa_agents t4 on t3.sys_enterpriseid=t4.sys_enterpriseid and t3.siteid=t4.siteid where t1.sa_serviceorderid="+rows.get(0).getLong("sa_serviceorderid")+" and t1.siteid='"+siteid+"' ");
+
             if(itemrows.isNotEmpty()){
+
+                //判断客户id
+                long sa_customersid=0;
+                if(itemrows.get(0).getLong("sa_customersid")!=0){
+                    sa_customersid=itemrows.get(0).getLong("sa_customersid");
+                }else if(false){
+                    //查询序列号是否有客户id(通过crm门店出库单中间表查询)待更新
+                }else{
+                    InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_customers");
+                    sa_customersid=createTableID("sa_customers");
+                    insertSQL.setUniqueid(sa_customersid);
+                    insertSQL.setSiteid(siteid);
+                    insertSQL.setValue("sa_agentsid", itemrows.get(0).getLong("sa_agentsid"));
+                    insertSQL.setValue("name",itemrows.get(0).getString("name"));
+                    insertSQL.setValue("phonenumber",itemrows.get(0).getString("phonenumber"));
+                    insertSQL.setValue("province",itemrows.get(0).getString("province"));
+                    insertSQL.setValue("city",itemrows.get(0).getString("city"));
+                    insertSQL.setValue("county",itemrows.get(0).getString("county"));
+                    insertSQL.setValue("address", itemrows.get(0).getString("address"));
+                    insertSQL.setValue("sa_customersid",sa_customersid);
+                    sqlList.add(insertSQL.getSQL());
+                }
+
                 LocalDate now = LocalDate.now();
 
-                // 将当前日期加上3年
+                // 将当前日期加上年
                 LocalDate futureDate = now.plusYears(itemrows.get(0).getInteger("warrantyday"));
 
                 // 定义日期格式
@@ -992,6 +1016,7 @@ public class workorder extends Controller {
                 insertSQL.setSiteid(siteid);
                 insertSQL.setValue("sa_agentsid", itemrows.get(0).getLong("sa_agentsid"));
                 insertSQL.setValue("cardno", "");
+                insertSQL.setValue("sa_customersid",sa_customersid);
                 insertSQL.setValue("enddate", formattedDate);
                 insertSQL.setValue("begdate", getDateTime_Str());
                 sqlList.add(insertSQL.getSQL());
@@ -1054,6 +1079,16 @@ public class workorder extends Controller {
                 where.append("t6.phonenumber ='").append(whereObject.getString("phonenumber")).append("' ");
                 where.append(")");
             }
+            if (whereObject.containsKey("sku") && !"".equals(whereObject.getString("sku"))) {
+                where.append(" and(");
+                where.append("t1.sku ='").append(whereObject.getString("sku")).append("' ");
+                where.append(")");
+            }
+            if (whereObject.containsKey("sa_customersid") && !"".equals(whereObject.getString("sa_customersid"))) {
+                where.append(" and(");
+                where.append("t6.sa_customersid ='").append(whereObject.getString("sa_customersid")).append("' ");
+                where.append(")");
+            }
         }
 //		String hrid = content.getString("hrid");
 //        SQLFactory sqlFactory = new SQLFactory(this, "审核订单列表查询", pageSize, pageNumber, pageSorting);
@@ -1073,7 +1108,6 @@ public class workorder extends Controller {
         querySQL.addQueryFields("customerphonenumber","t7.phonenumber");
         querySQL.setSiteid(siteid);
         querySQL.setWhere(where.toString());
-        querySQL.setDistinct(true);
         querySQL.setPage(pageSize, pageNumber);
         querySQL.setOrderBy(pageSorting);
         Rows rows = querySQL.query();