智慧保安后台管理-外网
tangzy
2021-08-27 733edfcd6ad1c38dcf4aa761a417f4e4bfd754b2
src/main/java/org/springblade/modules/record/controller/RecordController.java
@@ -27,15 +27,19 @@
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.record.entity.Record;
import org.springblade.modules.record.service.IRecordService;
import org.springblade.modules.record.vo.RecordVO;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
/**
 *  控制器
 * 控制器
 *
 * @author BladeX
 * @since 2021-07-12
@@ -66,6 +70,7 @@
   @ApiOperationSupport(order = 2)
   @ApiOperation(value = "分页", notes = "传入record")
   public R<IPage<Record>> list(Record record, Query query) {
      record.setStorage("1");
      IPage<Record> pages = recordService.page(Condition.getPage(query), Condition.getQueryWrapper(record));
      return R.data(pages);
   }
@@ -88,7 +93,55 @@
   @ApiOperationSupport(order = 4)
   @ApiOperation(value = "新增", notes = "传入record")
   public R save(@Valid @RequestBody Record record) {
      return R.status(recordService.save(record));
      String cardid = record.getCardid();
      String type = record.getPtype();
      Map map = recordService.selectIn(cardid,type);
      if (map != null) {
         String id = map.get("id").toString();
         recordService.removeByIds(Func.toLongList(id));
      }
      record.setStorage("1");
      record.setType("2");
      record.setPermitime(new Date());
      recordService.save(record);
      String formatStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(record.getEstablishtime());
      String offtime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(record.getOfficetime());
      String pertime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(record.getPermitime());
      String s = "insert into sys_record(id,creditCode,enterpriseName,representative,establishtime," +
         "registeredCapital,organizationCode,registrationNumber,identificationNumber,enterprises," +
         "address,business,region,registration,industry,type,permitime,deptid,ptype,representativecell,contacts,contactscell,perid,offices,officetime,jurisdiction)" +
         "values(" + "'" + record.getId() + "'" + "," + "'" + record.getCreditcode() + "'" + "," + "'" + record.getEnterprisename() + "'" + "," + "'"+ record.getRepresentative() + "'" + "," +
         "'" + formatStr + "'" + "," + "'" + record.getRegisteredcapital() + "'" + "," + "'"
         + record.getOrganizationcode() + "'" + "," + "'" + record.getRegistrationnumber() + "'" + "," +
         "'" + record.getIdentificationnumber() + "'" + "," + "'" + record.getEnterprises() + "'" + "," + "'" +
         record.getAddress() + "'" + "," + "'" + record.getBusiness() + "'" + "," + "'" +
         record.getRegion() + "'" + "," + "'" + record.getRegistration() + "'" + "," + "'" + record.getIndustry() + "'" + "," + "'" + record.getType() + "'" + "," + "'" + pertime + "'" + "," + "'" + record.getDeptid() + "'" + "," + "'" + record.getPtype() + "'" + "," +
         "'" + record.getRepresentativecell() + "'" + "," + "'" + record.getContacts() + "'" + "," + "'" + record.getContactscell() + "'" + "," +"'" + record.getPerid() + "'" + "," + "'" + record.getOffices() + "'" + "," + "'" + offtime + "'" + "," + "'" + record.getJurisdiction() + "'" + ")";
      FtpUtil.sqlFileUpload(s);
      return R.success("成功");
   }
   /**
    * 暂存
    */
   @PostMapping("/rocordsave")
   @ApiOperationSupport(order = 4)
   @ApiOperation(value = "新增", notes = "传入record")
   public R rocordsave(@Valid @RequestBody Record record) {
      String cardid = record.getCardid();
      String type = record.getPtype();
      Map map = recordService.selectIn(cardid,type);
      if (map != null) {
         record.setStorage("0");
         record.setPermitime(new Date());
         recordService.updateById(record);
      } else {
         record.setStorage("0");
         record.setType("2");
         record.setPermitime(new Date());
         recordService.save(record);
      }
      return R.success("暂存成功");
   }
   /**
@@ -123,4 +176,9 @@
   }
   @PostMapping("/selectIn")
   public R selectIn(String cardid,String type) {
      Map map = recordService.selectIn(cardid,type);
      return R.data(map);
   }
}