智慧保安后台管理-外网-验收版本
tangzy
2021-12-06 cc057177b2fb17aee9a173a6adbabdc578fd74c7
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);
   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(gunService.saveOrUpdate(gun));
      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)));
   }