package com.ruoyi.web.controller.station;
|
|
import java.util.Date;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
import com.ruoyi.common.utils.IdUtils;
|
import com.ruoyi.station.domain.MjEquipment;
|
import com.ruoyi.station.service.IMjEquipmentService;
|
import lombok.SneakyThrows;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.ui.ModelMap;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.station.domain.MjOpenHnwe;
|
import com.ruoyi.station.service.IMjOpenHnweService;
|
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
/**
|
* ax模式临时Controller
|
*
|
* @author ruoyi
|
* @date 2020-09-15
|
*/
|
@Controller
|
@RequestMapping("/station/openHnwe")
|
public class MjOpenHnweController extends BaseController
|
{
|
private String prefix = "station/openHnwe";
|
|
@Autowired
|
private IMjOpenHnweService mjOpenHnweService;
|
@Autowired
|
private IMjEquipmentService equipmentService;
|
|
@RequiresPermissions("station:openHnwe:view")
|
@GetMapping()
|
public String openHnwe()
|
{
|
return prefix + "/openHnwe";
|
}
|
|
/**
|
* 查询ax模式临时列表
|
*/
|
@PostMapping("/list")
|
@ResponseBody
|
public Object list(MjOpenHnwe mjOpenHnwe)
|
{
|
//startPage();
|
List<MjOpenHnwe> list = mjOpenHnweService.selectMjOpenHnweList(mjOpenHnwe);
|
//return getDataTable(list);
|
String ids = "";
|
for(MjOpenHnwe openHnwe:list){
|
ids+=openHnwe.getId()+",";
|
}
|
if(ids.indexOf(",")!=-1){
|
deleteAll(ids.substring(0,ids.length()-1));
|
}
|
insertAll(list);
|
Map<String,Object> map = new HashMap<String,Object>();
|
map.put("list",list);
|
|
MjEquipment eq = new MjEquipment();
|
eq.setEquipmentType(1);
|
List<MjEquipment> mjEquipments = equipmentService.selectMjEquipmentList(eq);
|
if(mjEquipments.size()==1){
|
MjEquipment equipment = mjEquipments.get(0);
|
equipment.setStatus(1);
|
equipment.setUpdateTime(new Date());
|
equipmentService.updateMjEquipment(equipment);
|
}
|
if(mjEquipments.size()==0){
|
eq.setStatus(1);
|
eq.setUpdateTime(new Date());
|
eq.setId(IdUtils.fastSimpleUUID());
|
equipmentService.insertMjEquipment(eq);
|
}
|
//eq.setEquipmentType();
|
return map;
|
}
|
|
public void deleteAll(String ids){
|
mjOpenHnweService.deleteMjOpenHnweByIds(ids);
|
// Thread t = new Thread(new Runnable(){
|
// public void run(){
|
// System.out.println("ids:"+ids);
|
// mjOpenHnweService.deleteMjOpenHnweByIds(ids);
|
// }
|
// });
|
// t.start();
|
}
|
|
public void insertAll(List<MjOpenHnwe> list){
|
if(list.size()==0){
|
return;
|
}
|
int i=0;
|
for(MjOpenHnwe openHnwe:list){
|
if(openHnwe.getDelFlag()==0){
|
if(openHnwe.getDoorControlId()==null){
|
i++;
|
}else if(openHnwe.getDoorControlId().equals("1")){
|
i++;
|
}
|
}
|
}
|
if(i==0){
|
return;
|
}
|
Thread t = new Thread(new Runnable(){
|
@SneakyThrows
|
public void run(){
|
Thread.sleep(5*1000);
|
for(MjOpenHnwe openHnwe:list){
|
if(openHnwe.getDoorControlId()==null){
|
if (openHnwe.getDelFlag()==0){
|
openHnwe.setDelFlag(1);
|
openHnwe.setId(IdUtils.fastSimpleUUID());
|
mjOpenHnweService.insertMjOpenHnwe(openHnwe);
|
}
|
}else{
|
if(openHnwe.getDoorControlId().equals("1")){
|
if (openHnwe.getDelFlag()==0){
|
openHnwe.setDelFlag(1);
|
openHnwe.setId(IdUtils.fastSimpleUUID());
|
mjOpenHnweService.insertMjOpenHnwe(openHnwe);
|
}
|
}
|
}
|
}
|
}
|
});
|
t.start();
|
}
|
|
/**
|
* 导出ax模式临时列表
|
*/
|
@RequiresPermissions("station:openHnwe:export")
|
@Log(title = "ax模式临时", businessType = BusinessType.EXPORT)
|
@PostMapping("/export")
|
@ResponseBody
|
public AjaxResult export(MjOpenHnwe mjOpenHnwe)
|
{
|
List<MjOpenHnwe> list = mjOpenHnweService.selectMjOpenHnweList(mjOpenHnwe);
|
ExcelUtil<MjOpenHnwe> util = new ExcelUtil<MjOpenHnwe>(MjOpenHnwe.class);
|
return util.exportExcel(list, "openHnwe");
|
}
|
|
/**
|
* 新增ax模式临时
|
*/
|
@GetMapping("/add")
|
public String add()
|
{
|
return prefix + "/add";
|
}
|
|
/**
|
* 新增保存ax模式临时
|
*/
|
@RequiresPermissions("station:openHnwe:add")
|
@Log(title = "ax模式临时", businessType = BusinessType.INSERT)
|
@PostMapping("/add")
|
@ResponseBody
|
public AjaxResult addSave(MjOpenHnwe mjOpenHnwe)
|
{
|
return toAjax(mjOpenHnweService.insertMjOpenHnwe(mjOpenHnwe));
|
}
|
|
/**
|
* 修改ax模式临时
|
*/
|
@GetMapping("/edit/{id}")
|
public String edit(@PathVariable("id") String id, ModelMap mmap)
|
{
|
MjOpenHnwe mjOpenHnwe = mjOpenHnweService.selectMjOpenHnweById(id);
|
mmap.put("mjOpenHnwe", mjOpenHnwe);
|
return prefix + "/edit";
|
}
|
|
/**
|
* 修改保存ax模式临时
|
*/
|
@RequiresPermissions("station:openHnwe:edit")
|
@Log(title = "ax模式临时", businessType = BusinessType.UPDATE)
|
@PostMapping("/edit")
|
@ResponseBody
|
public AjaxResult editSave(MjOpenHnwe mjOpenHnwe)
|
{
|
return toAjax(mjOpenHnweService.updateMjOpenHnwe(mjOpenHnwe));
|
}
|
|
/**
|
* 删除ax模式临时
|
*/
|
@RequiresPermissions("station:openHnwe:remove")
|
@Log(title = "ax模式临时", businessType = BusinessType.DELETE)
|
@PostMapping( "/remove")
|
@ResponseBody
|
public AjaxResult remove(String ids)
|
{
|
return toAjax(mjOpenHnweService.deleteMjOpenHnweByIds(ids));
|
}
|
}
|