|
|
|
@ -0,0 +1,277 @@
|
|
|
|
|
package org.jeecg.modules.demo.ttsulfequip.controller;
|
|
|
|
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.net.URLDecoder;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
|
|
import org.jeecg.common.util.RedisUtil;
|
|
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
|
|
import org.jeecg.modules.demo.ttsulfequip.entity.TtSulfEquip;
|
|
|
|
|
import org.jeecg.modules.demo.ttsulfequip.service.ITtSulfEquipService;
|
|
|
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
|
|
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
|
|
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
|
|
|
import org.jeecgframework.poi.excel.entity.ImportParams;
|
|
|
|
|
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
|
|
|
|
import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description: tt_sulf_equip
|
|
|
|
|
* @Author: jeecg-boot
|
|
|
|
|
* @Date: 2023-02-14
|
|
|
|
|
* @Version: V1.0
|
|
|
|
|
*/
|
|
|
|
|
@Api(tags="tt_sulf_equip")
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/ttsulfequip/ttSulfEquip")
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class TtSulfEquipController extends JeecgController<TtSulfEquip, ITtSulfEquipService> {
|
|
|
|
|
@Autowired
|
|
|
|
|
private ITtSulfEquipService ttSulfEquipService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private RedisUtil redisUtil;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 硫化机看板列表查询
|
|
|
|
|
*
|
|
|
|
|
* @param ttSulfEquip
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
//@AutoLog(value = "tt_inject_data-硫化机看板列表查询")
|
|
|
|
|
@ApiOperation(value="tt_inject_data-硫化机看板列表查询", notes="tt_inject_data-硫化机看板列表查询")
|
|
|
|
|
@GetMapping(value = "/queryList")
|
|
|
|
|
public Result<List<TtSulfEquip>> queryList(TtSulfEquip ttSulfEquip) throws ParseException {
|
|
|
|
|
//select * from tt_inject_data
|
|
|
|
|
//order by equip_no,day_name
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
String nowDateString = sdf.format(date);//2023-02-08 11:23 2023-02-08 08:50
|
|
|
|
|
List<TtSulfEquip> sulfEquipList = new ArrayList<>();
|
|
|
|
|
for(int i = 1; i<15;i++){
|
|
|
|
|
Random generator = new Random();
|
|
|
|
|
int randomIndex1 = generator.nextInt( 7 ) - 3;//随机数-1到1
|
|
|
|
|
int randomIndex2 = generator.nextInt( 5 ) - 2;//随机数-1到1
|
|
|
|
|
int randomIndex3 = generator.nextInt( 5 ) - 2;//随机数-1到1
|
|
|
|
|
int randomIndex4 = generator.nextInt( 5 ) - 2;//随机数-1到1
|
|
|
|
|
int randomIndex5 = 0;
|
|
|
|
|
// int randomIndex6 = generator.nextInt(201) + 300;
|
|
|
|
|
int[] arr = {360,420,480};
|
|
|
|
|
int randomIndex6 = arr[(int) (Math.random() * 3)];
|
|
|
|
|
TtSulfEquip sulfEquip = new TtSulfEquip();
|
|
|
|
|
sulfEquip.setEqtNo("硫化机" + i);
|
|
|
|
|
Object object = redisUtil.get(sulfEquip.getEqtNo());
|
|
|
|
|
if (object != null) {
|
|
|
|
|
randomIndex5 = Integer.parseInt(String.valueOf(object));
|
|
|
|
|
}else{
|
|
|
|
|
randomIndex5 = generator.nextInt( 60 );//随机数0到59 45
|
|
|
|
|
redisUtil.set(sulfEquip.getEqtNo(), randomIndex5);
|
|
|
|
|
}
|
|
|
|
|
String openTimeParam = String.valueOf(randomIndex5);
|
|
|
|
|
if(randomIndex5 < 10){
|
|
|
|
|
openTimeParam = "0" + String.valueOf(randomIndex5);
|
|
|
|
|
}
|
|
|
|
|
sulfEquip.setSulfPressure(72 + randomIndex1);
|
|
|
|
|
sulfEquip.setSulfTempUpper(126 + randomIndex2);
|
|
|
|
|
sulfEquip.setSulfTempMiddle(126 + randomIndex3);
|
|
|
|
|
sulfEquip.setSulfTempLower(126 + randomIndex4);
|
|
|
|
|
sulfEquip.setSulfTime(randomIndex6);
|
|
|
|
|
// if(i == 5 || i == 8){
|
|
|
|
|
// sulfEquip.setEquipStatus(2);
|
|
|
|
|
// sulfEquip.setOpenTime(0);
|
|
|
|
|
// sulfEquip.setTodayProgress(0);
|
|
|
|
|
// sulfEquip.setTodayQty(0);
|
|
|
|
|
// }else if(i == 11 || i == 15){
|
|
|
|
|
// sulfEquip.setEquipStatus(3);
|
|
|
|
|
// sulfEquip.setOpenTime(0);
|
|
|
|
|
// sulfEquip.setTodayProgress(0);
|
|
|
|
|
// sulfEquip.setTodayQty(0);
|
|
|
|
|
// }else if(i == 22){
|
|
|
|
|
// sulfEquip.setEquipStatus(4);
|
|
|
|
|
// sulfEquip.setOpenTime(0);
|
|
|
|
|
// sulfEquip.setTodayProgress(0);
|
|
|
|
|
// sulfEquip.setTodayQty(0);
|
|
|
|
|
// }
|
|
|
|
|
// else{
|
|
|
|
|
// sulfEquip.setEquipStatus(1);
|
|
|
|
|
String openDate = nowDateString.substring(0, 10) + " 08:" + openTimeParam;//开机时间8点到9点之间2023-02-08 08:45
|
|
|
|
|
// sulfEquip.setOpenDate(date);
|
|
|
|
|
String openTime = "08:"+openTimeParam;
|
|
|
|
|
// sulfEquip.setOpenTime(openTime);
|
|
|
|
|
long time = sdf.parse(nowDateString).getTime();
|
|
|
|
|
long time2 = sdf.parse(openDate).getTime();
|
|
|
|
|
int Second = (int)(time - time2) / (1000);
|
|
|
|
|
// if(Second < 0){//未到开机时间
|
|
|
|
|
// sulfEquip.setSulfTime(0);//硫化时长秒
|
|
|
|
|
//// sulfEquip.setOpenTime("0");
|
|
|
|
|
//// sulfEquip.setEquipStatus(4);
|
|
|
|
|
//// sulfEquip.setTodayProgress(0);
|
|
|
|
|
//// sulfEquip.setTodayQty(0);
|
|
|
|
|
// }else{
|
|
|
|
|
// sulfEquip.setSulfTime(Second);//硫化时长秒
|
|
|
|
|
//// sulfEquip.setTodayQty((int)Math.round(Minutes * 2.5));//现在产量,每分钟3个
|
|
|
|
|
//// sulfEquip.setTodayProgress(sulfEquip.getTodayQty()/12);
|
|
|
|
|
// if(sulfEquip.getSulfTime() >= 28800){//生产完成关机
|
|
|
|
|
// sulfEquip.setSulfTime(28800);
|
|
|
|
|
//// sulfEquip.setEquipStatus(4);
|
|
|
|
|
//// sulfEquip.setOpenTime(480);
|
|
|
|
|
//// sulfEquip.setTodayProgress(100);
|
|
|
|
|
//// sulfEquip.setTodayQty(1200);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
sulfEquipList.add(sulfEquip);
|
|
|
|
|
}
|
|
|
|
|
return Result.OK(sulfEquipList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分页列表查询
|
|
|
|
|
*
|
|
|
|
|
* @param ttSulfEquip
|
|
|
|
|
* @param pageNo
|
|
|
|
|
* @param pageSize
|
|
|
|
|
* @param req
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
//@AutoLog(value = "tt_sulf_equip-分页列表查询")
|
|
|
|
|
@ApiOperation(value="tt_sulf_equip-分页列表查询", notes="tt_sulf_equip-分页列表查询")
|
|
|
|
|
@GetMapping(value = "/list")
|
|
|
|
|
public Result<IPage<TtSulfEquip>> queryPageList(TtSulfEquip ttSulfEquip,
|
|
|
|
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
|
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
|
|
HttpServletRequest req) {
|
|
|
|
|
QueryWrapper<TtSulfEquip> queryWrapper = QueryGenerator.initQueryWrapper(ttSulfEquip, req.getParameterMap());
|
|
|
|
|
Page<TtSulfEquip> page = new Page<TtSulfEquip>(pageNo, pageSize);
|
|
|
|
|
IPage<TtSulfEquip> pageList = ttSulfEquipService.page(page, queryWrapper);
|
|
|
|
|
return Result.OK(pageList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加
|
|
|
|
|
*
|
|
|
|
|
* @param ttSulfEquip
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@AutoLog(value = "tt_sulf_equip-添加")
|
|
|
|
|
@ApiOperation(value="tt_sulf_equip-添加", notes="tt_sulf_equip-添加")
|
|
|
|
|
//@RequiresPermissions("ttsulfequip:tt_sulf_equip:add")
|
|
|
|
|
@PostMapping(value = "/add")
|
|
|
|
|
public Result<String> add(@RequestBody TtSulfEquip ttSulfEquip) {
|
|
|
|
|
ttSulfEquipService.save(ttSulfEquip);
|
|
|
|
|
return Result.OK("添加成功!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 编辑
|
|
|
|
|
*
|
|
|
|
|
* @param ttSulfEquip
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@AutoLog(value = "tt_sulf_equip-编辑")
|
|
|
|
|
@ApiOperation(value="tt_sulf_equip-编辑", notes="tt_sulf_equip-编辑")
|
|
|
|
|
//@RequiresPermissions("ttsulfequip:tt_sulf_equip:edit")
|
|
|
|
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
|
|
|
|
public Result<String> edit(@RequestBody TtSulfEquip ttSulfEquip) {
|
|
|
|
|
ttSulfEquipService.updateById(ttSulfEquip);
|
|
|
|
|
return Result.OK("编辑成功!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过id删除
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@AutoLog(value = "tt_sulf_equip-通过id删除")
|
|
|
|
|
@ApiOperation(value="tt_sulf_equip-通过id删除", notes="tt_sulf_equip-通过id删除")
|
|
|
|
|
//@RequiresPermissions("ttsulfequip:tt_sulf_equip:delete")
|
|
|
|
|
@DeleteMapping(value = "/delete")
|
|
|
|
|
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
|
|
|
|
ttSulfEquipService.removeById(id);
|
|
|
|
|
return Result.OK("删除成功!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量删除
|
|
|
|
|
*
|
|
|
|
|
* @param ids
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@AutoLog(value = "tt_sulf_equip-批量删除")
|
|
|
|
|
@ApiOperation(value="tt_sulf_equip-批量删除", notes="tt_sulf_equip-批量删除")
|
|
|
|
|
//@RequiresPermissions("ttsulfequip:tt_sulf_equip:deleteBatch")
|
|
|
|
|
@DeleteMapping(value = "/deleteBatch")
|
|
|
|
|
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
|
|
|
|
this.ttSulfEquipService.removeByIds(Arrays.asList(ids.split(",")));
|
|
|
|
|
return Result.OK("批量删除成功!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过id查询
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
//@AutoLog(value = "tt_sulf_equip-通过id查询")
|
|
|
|
|
@ApiOperation(value="tt_sulf_equip-通过id查询", notes="tt_sulf_equip-通过id查询")
|
|
|
|
|
@GetMapping(value = "/queryById")
|
|
|
|
|
public Result<TtSulfEquip> queryById(@RequestParam(name="id",required=true) String id) {
|
|
|
|
|
TtSulfEquip ttSulfEquip = ttSulfEquipService.getById(id);
|
|
|
|
|
if(ttSulfEquip==null) {
|
|
|
|
|
return Result.error("未找到对应数据");
|
|
|
|
|
}
|
|
|
|
|
return Result.OK(ttSulfEquip);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出excel
|
|
|
|
|
*
|
|
|
|
|
* @param request
|
|
|
|
|
* @param ttSulfEquip
|
|
|
|
|
*/
|
|
|
|
|
//@RequiresPermissions("ttsulfequip:tt_sulf_equip:exportXls")
|
|
|
|
|
@RequestMapping(value = "/exportXls")
|
|
|
|
|
public ModelAndView exportXls(HttpServletRequest request, TtSulfEquip ttSulfEquip) {
|
|
|
|
|
return super.exportXls(request, ttSulfEquip, TtSulfEquip.class, "tt_sulf_equip");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过excel导入数据
|
|
|
|
|
*
|
|
|
|
|
* @param request
|
|
|
|
|
* @param response
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
//@RequiresPermissions("ttsulfequip:tt_sulf_equip:importExcel")
|
|
|
|
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
|
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
return super.importExcel(request, response, TtSulfEquip.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|