| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- package com.chinaitop.depot.device.controller;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import com.chinaitop.depot.device.model.*;
- import com.chinaitop.depot.device.service.DSblxxjyService;
- import org.springframework.http.MediaType;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
- import com.alibaba.fastjson.JSONObject;
- import com.chinaitop.depot.device.service.StorageDeviceInputService;
- import com.chinaitop.depot.device.service.StorageDeviceRepairService;
- import com.chinaitop.depot.utils.ParameterUtil;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiImplicitParam;
- import io.swagger.annotations.ApiImplicitParams;
- import io.swagger.annotations.ApiOperation;
- @RestController
- @RequestMapping(value = {"/deviceRepair"})
- @Api(value = "StorageDeviceRepairController", description = "器材设备维修")
- public class StorageDeviceRepairController {
- @Resource
- private StorageDeviceRepairService deviceRepairService;
- @Resource
- private StorageDeviceInputService deviceInputService;
- @Resource
- private DSblxxjyService sblxxjyService;
- /*@Resource
- private OrgInfoService orgInfoService;*/
- /**
- * 分页获取器材信息
- *
- * @throws Exception
- */
- @RequestMapping(value = "/getDeviceList", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
- @ApiOperation(value = "查询维修设备信息", notes = "查询维修设备列表,支持分页")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query"),
- @ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
- })
- public PageInfo<StorageDevicerepair> listCheckPage(HttpServletRequest request, Integer pageNum, Integer pageSize, Integer repairStatus,Integer orgId) throws Exception {
- StorageDevicerepairExample storageDevicerepairExample = new StorageDevicerepairExample();
- StorageDevicerepairExample.Criteria criteria = storageDevicerepairExample.createCriteria();
- if (ParameterUtil.isnotnull(repairStatus)) {
- criteria.andRepairStatusEqualTo(repairStatus);
- }
- if (ParameterUtil.isnotnull(orgId)) {
- criteria.andOrgIdEqualTo(orgId);
- }
- //按照id进行降序
- storageDevicerepairExample.setOrderByClause("repair_status=1 desc,repair_status=2 desc,repair_status=0 desc,repair_end desc,id desc");
- if (pageNum != null && pageSize != null) {
- PageHelper.startPage(pageNum, pageSize);
- }
- List<StorageDevicerepair> list = deviceRepairService.queryByDevice(storageDevicerepairExample);
- PageInfo<StorageDevicerepair> pageInfo = new PageInfo<StorageDevicerepair>(list);
- return pageInfo;
- }
- /**
- * 新增维修
- */
- @RequestMapping(value = "/save", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
- @ApiOperation(value = "保存数据", notes = "保存增加或修改的数据")
- public Map<String, Object> save(@RequestBody StorageDevicerepair storageDevicerepair) {
- Map<String, Object> modelMap = new HashMap<>();
- // JSON字符串转对象
- ObjectMapper mapper = new ObjectMapper();
- //StorageDevicerepair storageDevicerepair = null;
- try {
- //storageDevicerepair = (StorageDevicerepair) mapper.readValue(deviceRepairJson, StorageDevicerepair.class);
- storageDevicerepair.setRepairStatus(1);//改变维修表中的状态
- deviceRepairService.save(storageDevicerepair);
- //入库表中的数量增加 状态发生改变
- DSbxxsjyExample example = new DSbxxsjyExample();
- DSbxxsjyExample.Criteria criteria = example.createCriteria();
- criteria.andSbbhEqualTo(storageDevicerepair.getNumber());
- DSbxxsjy dSbxxsjy = sblxxjyService.getList(example).get(0);
- long lnumber = storageDevicerepair.getRepairNumber().longValue();
- dSbxxsjy.setSbsl(dSbxxsjy.getSbsl() - lnumber);
- dSbxxsjy.setMqzt("3");
- sblxxjyService.update(dSbxxsjy);
- modelMap.put("status", "success");
- } catch (Exception e) {
- modelMap.put("status", "error");
- e.printStackTrace();
- }
- return modelMap;
- }
- /**
- * 查询仓房对应的设备名称
- *
- * @return
- */
- @RequestMapping(value = "/getDeviceName", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
- @ApiOperation(value = "查询数据", notes = "根据depotId查询数据")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "depotId", value = "depotId", paramType = "query"),
- })
- public List<StorageDeviceinput> getHouseList(Integer depotId) {
- List<StorageDeviceinput> storageDeviceinput = null;
- if (depotId != 0) {
- storageDeviceinput = deviceInputService.getDeviceInputList(depotId);
- }
- return storageDeviceinput;
- }
- /**
- * 查询维修的设备名称
- */
- @RequestMapping(value = "/getDeviceNameList", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
- @ApiOperation(value = "查询数据", notes = "查询数据")
- public List<String> getDeviceNameList(String orgId) {
- return deviceInputService.getRepairNameList(orgId);
- }
- /**
- * 查询设备名称对应的型号
- *
- * @return
- */
- @RequestMapping(value = "/getDeviceModel", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
- @ApiOperation(value = "查询数据根据名称", notes = "查询数据根据名称")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "deviceName", value = "deviceName", paramType = "query"),
- })
- public List<StorageDeviceinput> getModelList(String deviceName) {
- List<StorageDeviceinput> storageDeviceinput = deviceInputService.getDeviceModelRepair(deviceName);
- return storageDeviceinput;
- }
- /**
- * 查询设备名称对应的型号
- *
- * @return
- */
- @RequestMapping(value = "/getDeviceNumber", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
- @ApiOperation(value = "查询设备名称对应的型号", notes = "查询设备名称对应的型号")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "deviceModel", value = "deviceModel", paramType = "query")
- })
- public List<StorageDeviceinput> getDeviceNumber(String deviceModel) {
- List<StorageDeviceinput> storageDeviceinput = deviceInputService.getNumberList(deviceModel);
- return storageDeviceinput;
- }
- /**
- * 查询型号对应的数量
- *
- * @return
- */
- @RequestMapping(value = "/getDeviceCount", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
- @ApiOperation(value = "查询数量", notes = "查询设备名称对应的型号")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "deviceModel", value = "deviceModel", paramType = "query")
- })
- public List<StorageDeviceinput> getDeviceCount(String number, String model) {
- List<StorageDeviceinput> storageDeviceinput = deviceInputService.getCountList(number);
- return storageDeviceinput;
- }
- /**
- * 结束维修
- */
- @RequestMapping(value = "/end", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
- @ApiOperation(value = "结束维修", notes = "结束维修")
- public Map<String, Object> end(@RequestBody StorageDevicerepair storageDevicerepair) {
- Map<String, Object> modelMap = new HashMap<>();
- // JSON字符串转对象
- ObjectMapper mapper = new ObjectMapper();
- //StorageDevicerepair storageDevicerepair = null;
- try {
- //storageDevicerepair = (StorageDevicerepair) mapper.readValue(deviceListJson, StorageDevicerepair.class);
- //改变维修表中的信息
- storageDevicerepair.setRepairEnd(new Date());
- storageDevicerepair.setRepairStatus(0);
- deviceRepairService.updateByPrimaryKeySelective(storageDevicerepair);
- //根据id获取编号和型号
- storageDevicerepair = deviceRepairService.loadDataById(storageDevicerepair.getId());
- //入库表中的数量增加 状态发生改变
- DSbxxsjyExample example = new DSbxxsjyExample();
- DSbxxsjyExample.Criteria criteria = example.createCriteria();
- criteria.andSbbhEqualTo(storageDevicerepair.getNumber());
- DSbxxsjy dSbxxsjy = sblxxjyService.getList(example).get(0);
- long lnumber = storageDevicerepair.getRepairNumber().longValue();
- dSbxxsjy.setSbsl(dSbxxsjy.getSbsl() + lnumber);
- dSbxxsjy.setMqzt("1");
- sblxxjyService.update(dSbxxsjy);
- modelMap.put("status", "success");
- } catch (Exception e) {
- modelMap.put("status", "error");
- e.printStackTrace();
- }
- return modelMap;
- }
- /**
- * 批量结束维修
- */
- @RequestMapping(value = "/endMore", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
- @ApiOperation(value = "批量结束维修", notes = "批量结束维修")
- public Map<String, Object> endMore(String deviceListJson) {
- Map<String, Object> modelMap = new HashMap<>();
- // JSON字符串转对象
- //ObjectMapper mapper = new ObjectMapper();
- try {
- JSONObject jsonObject = JSONObject.parseObject(deviceListJson);
- String idStr = jsonObject.getString("id");
- if (idStr != null && !"".equals(idStr)) {
- String[] ids = idStr.split(",");
- for (int i = 0; i < ids.length; i++) {
- StorageDevicerepair storageDevicerepair = new StorageDevicerepair();
- storageDevicerepair.setRepairEnd(new Date());
- storageDevicerepair.setRepairStatus(0);
- storageDevicerepair.setId(Integer.parseInt(ids[i]));
- deviceRepairService.updateByPrimaryKeySelective(storageDevicerepair);
- }
- }
- modelMap.put("status", "success");
- } catch (Exception e) {
- modelMap.put("status", "error");
- e.printStackTrace();
- }
- return modelMap;
- }
- /**
- * 根据id加载对应数据
- *
- * @param id
- * @return
- * @throws Exception
- */
- @RequestMapping(value = "/loadDataById", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
- @ApiOperation(value = "根据id加载数据", notes = "根据id加载数据")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "id", value = "id", paramType = "query")
- })
- public List<StorageDevicerepair> loadDataById(int id) throws Exception {
- StorageDevicerepair storageDevicerepair = deviceRepairService.loadDataById(id);
- List<StorageDevicerepair> repairMassageList = new ArrayList<StorageDevicerepair>();
- repairMassageList.add(storageDevicerepair);
- return repairMassageList;
- }
- }
|