懒羊羊
2023-10-17 92cffc135581ce2cf4aecac745ddb88e739c17de
guns-vip-main/src/main/java/cn/stylefeng/guns/modular/zsx/kb/formula/controller/FormulaKbController.java
@@ -1,14 +1,23 @@
package cn.stylefeng.guns.modular.zsx.kb.formula.controller;
import cn.stylefeng.guns.modular.zsx.bs.formulaChild.entity.FormulaChildInfo;
import cn.stylefeng.guns.modular.zsx.bs.formulaChild.model.params.FormulaChildInfoParam;
import cn.stylefeng.guns.modular.zsx.bs.formulaChild.service.FormulaChildInfoService;
import cn.stylefeng.guns.modular.zsx.bs.formulaChild.service.impl.FormulaChildInfoServiceImpl;
import cn.stylefeng.guns.modular.zsx.kb.utils.IPUtil;
import cn.stylefeng.guns.modular.zsx.pm.salesOrder.service.SalesOrderService;
import cn.stylefeng.roses.core.mutidatasource.annotion.DataSource;
import cn.stylefeng.roses.kernel.model.response.ResponseData;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.net.*;
import java.util.Enumeration;
import java.util.List;
import java.util.Set;
@@ -16,6 +25,9 @@
@RequestMapping("/kb/formulaView")
public class FormulaKbController {
    private String PREFIX = "/modular/kb/formula";
    @Autowired
    private FormulaChildInfoService formulaChildInfoService;
    /**
     * 跳转到主页面
@@ -28,21 +40,48 @@
        return PREFIX + "/formulaView.html";
    }
    public static void main(String[] args) {
        try {
            Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
            while (networkInterfaces.hasMoreElements()) {
                NetworkInterface networkInterface = networkInterfaces.nextElement();
                Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();
                while (inetAddresses.hasMoreElements()) {
                    InetAddress inetAddress = inetAddresses.nextElement();
                    if (inetAddress instanceof Inet4Address) { // 过滤IPv4地址
                        System.out.println(inetAddress.getHostAddress());
                    }
                }
            }
        } catch (SocketException e) {
            throw new RuntimeException(e);
    /**
     * 新增接口
     *
     * @author ruimin
     * @Date 2023-10-09
     */
    @RequestMapping("/addFormulaState")
    @ResponseBody
    @DataSource(name = "self")
    public ResponseData addFormulaState(FormulaChildInfoParam formulaChildInfoParam) {
        List<FormulaChildInfo> list = this.formulaChildInfoService.list(new QueryWrapper<FormulaChildInfo>()
                .eq("formula_code", formulaChildInfoParam.getFormulaCode())
                .eq("spare_field_1","")
                .orderByAsc("step_sort")
        );
        if(list.size()>0){
            FormulaChildInfo formulaChildInfo = list.get(0);
            formulaChildInfo.setSpareField1("3");
            this.formulaChildInfoService.saveOrUpdate(formulaChildInfo);
        }
        return ResponseData.success();
    }
    /**
     * 新增接口
     *
     * @author ruimin
     * @Date 2023-10-09
     */
    @RequestMapping("/clear")
    @ResponseBody
    @DataSource(name = "self")
    public ResponseData clear(FormulaChildInfoParam formulaChildInfoParam) {
        List<FormulaChildInfo> list = this.formulaChildInfoService.list(new QueryWrapper<FormulaChildInfo>()
                .eq("formula_code", formulaChildInfoParam.getFormulaCode())
        );
        for (int i = 0; i < list.size(); i++) {
            FormulaChildInfo formulaChildInfo = list.get(i);
            formulaChildInfo.setSpareField1("");
            this.formulaChildInfoService.saveOrUpdate(formulaChildInfo);
        }
        return ResponseData.success();
    }
}