Administrator
2021-08-25 678417ec81cb111f3897b81d5ff09c6247465351
枪支,车辆数据推送
3 files modified
132 ■■■■ changed files
src/main/java/org/springblade/common/constant/FtpConstant.java 16 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/equipage/controller/CarController.java 58 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/equipage/controller/GunController.java 58 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/constant/FtpConstant.java
@@ -8,22 +8,22 @@
    /**
     * sql connect
     */
//    String sql_connect_dev = "jdbc:mysql://223.82.109.183:2083/zhbaw";
    String sql_connect_dev = "jdbc:mysql://223.82.109.183:2083/zhbaw";
    /**
     * sql connect
     */
    String sql_connect_dev = "jdbc:mysql://localhost:2083/zhbaw";
//    String sql_connect_dev = "jdbc:mysql://localhost:2083/zhbaw";
    /**
     * ftp服务器IP地址
     */
//    String ftpHost_dev = "192.168.0.105";
    String ftpHost_dev = "192.168.0.105";
    /**
     * ftp服务器IP地址
     */
    String ftpHost_dev = "172.19.1.30";
//    String ftpHost_dev = "172.19.1.30";
    /**
     * ftp服务器端口
@@ -44,12 +44,12 @@
    /**
     * ftp服务器路径
     */
    String ftpPath = "yly/anbao/";
//    String ftpPath = "anbao/";
//    String ftpPath = "yly/anbao/";
    String ftpPath = "anbao/";
    /**
     * 本地路径
     */
    String localPath = "/home/zhongsong/anbao/";
//    String localPath = "D:\\anbao\\";
//    String localPath = "/home/zhongsong/anbao/";
    String localPath = "D:\\anbao\\";
}
src/main/java/org/springblade/modules/equipage/controller/CarController.java
@@ -10,6 +10,7 @@
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.FTP.FtpUtil;
import org.springblade.modules.equipage.entity.Car;
import org.springblade.modules.equipage.service.CarService;
import org.springblade.modules.equipage.vo.CarVo;
@@ -17,7 +18,10 @@
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * @author zhongrj
@@ -67,11 +71,47 @@
     */
    @PostMapping("/submit")
    public R submit(@RequestBody Car car) throws Exception {
        /*if (car.getId()==null){
            arg arg = new arg();
            arg.test01(arg.url+"/car/save",car);
        }*/
        return R.status(carService.saveOrUpdate(car));
        boolean status = false;
        if (null==car.getId()) {
            car.setDateForProduction(new Date());
            //新增
            status = carService.save(car);
            //数据同步
            String s1 =
                "insert into sys_car(id,car_number,number_type,car_type,dept_id," +
                    "person_in_charge,brand,date_for_production,umweltsatz,mode,jurisdiction) " +
                    "values(" + "'" + car.getId() + "'" + "," +
                    "'" + car.getCarNumber() + "'" + "," +
                    "'" + car.getNumberType() + "'" + "," +
                    "'" + car.getCarType() + "'" + "," +
                    "'" + car.getDeptId() + "'" + "," +
                    "'" + car.getPersonInCharge() + "'" + "," +
                    "'" + car.getBrand() + "'" + "," +
                    "'" + new SimpleDateFormat("yyyy-MM-dd").format(car.getDateForProduction()) + "'" + "," +
                    "'" + car.getUmweltsatz() + "'" + "," +
                    "'" + car.getMode() + "'" + "," +
                    "'" +car.getJurisdiction() + "'" + ")";
            FtpUtil.sqlFileUpload(s1);
        }else {
            //修改
            status = carService.updateById(car);
            //内网同步
            String s1 =
                "update sys_car set car_number = " + "'" + car.getCarNumber() + "'" +
                    ",number_type = " + "'" + car.getNumberType() + "'" +
                    ",car_type = " + "'" + car.getCarType() + "'" +
                    ",dept_id = " + "'" + car.getDeptId() + "'" +
                    ",person_in_charge = " + "'" + car.getJurisdiction() + "'" +
                    ",brand = " + "'" + car.getBrand() + "'" +
                    ",date_for_production = " + "'" + new SimpleDateFormat("yyyy-MM-dd").format(car.getDateForProduction()) + "'" +
                    ",umweltsatz = " + "'" + car.getUmweltsatz() + "'" +
                    ",mode = " + "'" + car.getMode() + "'" +
                    ",jurisdiction = " + "'" + car.getJurisdiction() + "'" +
                    " " +"where id = " + "'" + car.getId() + "'";
            FtpUtil.sqlFileUpload(s1);
        }
        return R.status(status);
    }
    /**
@@ -80,7 +120,13 @@
     */
    @PostMapping("/remove")
    public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
        //arg.sendPostRemoveByIds(arg.url+"/car/remove",ids);
        //内网删除
        List<Long> list = Func.toLongList(ids);
        list.forEach(id ->{
            //内网同步
            String s1 = "delete from sys_car where id = " + "'" + id + "'";
            FtpUtil.sqlFileUpload(s1);
        });
        return R.status(carService.removeByIds(Func.toLongList(ids)));
    }
src/main/java/org/springblade/modules/equipage/controller/GunController.java
@@ -9,10 +9,15 @@
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.FTP.FtpUtil;
import org.springblade.modules.equipage.entity.Gun;
import org.springblade.modules.equipage.service.GunService;
import org.springblade.modules.equipage.vo.GunVo;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
 * @author zhongrj
@@ -61,12 +66,45 @@
     * @param gun 枪支信息对象
     */
    @PostMapping("/submit")
    public R submit(@RequestBody Gun gun) throws Exception {
//        if (gun.getId()==null){
//            arg arg = new arg();
//            arg.test01(arg.url+"/gun/save",gun);
//        }
        return R.status(gunService.saveOrUpdate(gun));
    public R submit(@RequestBody Gun gun){
        boolean status = false;
        if (null==gun.getId()) {
            //新增
            status = gunService.save(gun);
            //数据同步
            String s1 =
                "insert into sys_gun(id,gun_card_number,issue_unit,card_number,gun_mode," +
                    "dept_id,person_in_charge,issue_time,valid_time,jurisdiction) " +
                    "values(" + "'" + gun.getId() + "'" + "," +
                    "'" + gun.getGunCardNumber() + "'" + "," +
                    "'" + gun.getIssueUnit() + "'" + "," +
                    "'" + gun.getCardNumber() + "'" + "," +
                    "'" + gun.getGunMode() + "'" + "," +
                    "'" + gun.getDeptId() + "'" + "," +
                    "'" + gun.getPersonInCharge() + "'" + "," +
                    "'" + new SimpleDateFormat("yyyy-MM-dd").format(gun.getIssueTime()) + "'" + "," +
                    "'" + new SimpleDateFormat("yyyy-MM-dd").format(gun.getValidTime()) + "'" + "," +
                    "'" +gun.getJurisdiction() + "'" + ")";
            FtpUtil.sqlFileUpload(s1);
        }else {
            //修改
            status = gunService.updateById(gun);
            //内网同步
            String s1 =
                "update sys_gun set gun_card_number = " + "'" + gun.getGunCardNumber() + "'" +
                    ",issue_unit = " + "'" + gun.getIssueUnit() + "'" +
                    ",card_number = " + "'" + gun.getCardNumber() + "'" +
                    ",gun_mode = " + "'" + gun.getGunMode() + "'" +
                    ",dept_id = " + "'" + gun.getDeptId() + "'" +
                    ",person_in_charge = " + "'" + gun.getJurisdiction() + "'" +
                    ",issue_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd").format(gun.getIssueTime()) + "'" +
                    ",valid_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd").format(gun.getValidTime()) + "'" +
                    ",jurisdiction = " + "'" + gun.getJurisdiction() + "'" +
                    " " +"where id = " + "'" + gun.getId() + "'";
            FtpUtil.sqlFileUpload(s1);
        }
        return R.status(status);
    }
    /**
@@ -75,7 +113,13 @@
     */
    @PostMapping("/remove")
    public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
        //arg.sendPostRemoveByIds(arg.url+"/gun/remove",ids);
        //内网删除
        List<Long> list = Func.toLongList(ids);
        list.forEach(id ->{
            //内网同步
            String s1 = "delete from sys_gun where id = " + "'" + id + "'";
            FtpUtil.sqlFileUpload(s1);
        });
        return R.status(gunService.removeByIds(Func.toLongList(ids)));
    }