TGasUserInfoController.java 7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
package com.zehong.web.controller.gasBottleTrack;

import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.enums.BusinessType;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.TGasUserInfo;
import com.zehong.system.domain.TGasUserInfolins;
import com.zehong.system.domain.TTaskRecord;
import com.zehong.system.service.ITGasUserInfoService;
import com.zehong.system.service.ITTaskRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 燃气用户Controller
 *
 * @author zehong
 * @date 2023-08-17
 */
@RestController
@RequestMapping("/gasUser/info")
public class TGasUserInfoController extends BaseController
{
    @Autowired
    private ITGasUserInfoService tGasUserInfoService;

    @Autowired
    private ITTaskRecordService tTaskRecordService;
    /**
     * 查询燃气用户列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TGasUserInfo tGasUserInfo)
    {
        startPage();
        List<TGasUserInfo> list = tGasUserInfoService.selectTGasUserInfoList(tGasUserInfo);
        return getDataTable(list);
    }

    /**
     * 微信小程序 获取燃气用户详细信息
     * @param gasUserId
     * @return
     */
    @GetMapping("/selectGet")
    public AjaxResult selectGetInfo(Long gasUserId){
        TGasUserInfo tGasUserInfo = tGasUserInfoService.selectTGasUserInfoById(gasUserId);
        AjaxResult ajax = AjaxResult.success();
        ajax.put("tGasUserInfo", tGasUserInfo);
        return ajax;
    }

    @GetMapping("/gasUserInfoList")
    public AjaxResult gasUserInfoList(TGasUserInfo tGasUserInfo){
        List<TGasUserInfo> list = tGasUserInfoService.selectTGasUserInfoList(tGasUserInfo);
        return AjaxResult.success(list);
    }

    /**
     * 导出燃气用户列表
     */
    @Log(title = "燃气用户", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TGasUserInfo tGasUserInfo)
    {
        List<TGasUserInfo> list = tGasUserInfoService.selectTGasUserInfoList(tGasUserInfo);
        ExcelUtil<TGasUserInfo> util = new ExcelUtil<TGasUserInfo>(TGasUserInfo.class);
        return util.exportExcel(list, "燃气用户数据");
    }

    /**
     * 获取燃气用户详细信息
     */
    @GetMapping(value = "/{gasUserId}")
    public AjaxResult getInfo(@PathVariable("gasUserId") Long gasUserId)
    {
        return AjaxResult.success(tGasUserInfoService.selectTGasUserInfoById(gasUserId));
    }

    @PostMapping("/getUser")
    public AjaxResult getUser(@RequestBody  TGasUserInfo tGasUserInfo)
    {
        AjaxResult ajax = AjaxResult.success();
        ajax.put("tGasUserInfon", tGasUserInfoService.selectTGasUserInfoById(tGasUserInfo.getGasUserId()));
        return ajax;
    }


    /**
     * 微信小程序下拉信息查询
     * @param tGasUserInfo
     * @return
     */
    @PostMapping("/gasUserId")
    public AjaxResult gasUserId(@RequestBody TGasUserInfo tGasUserInfo)
    {
        TGasUserInfo tGasUserInfo1 = tGasUserInfoService.selectTGasUserInfoById(tGasUserInfo.getGasUserId());
        AjaxResult ajax = AjaxResult.success();
        ajax.put("tGasUserInfon", tGasUserInfo1);
        return ajax;
    }

    /**
     * 小程序 查询燃气用户信息
     * @param tGasUserInfo
     * @return
     */
    @PostMapping("/gasUser")
    public AjaxResult gasUser(@RequestBody TGasUserInfo tGasUserInfo)
    {
        List<TGasUserInfo> tGasUserInfos = tGasUserInfoService.gasUser(tGasUserInfo);
        List list=new ArrayList();
        for (int i=0;i<tGasUserInfos.size();i++){
            TGasUserInfolins tGasUserInfolins=new TGasUserInfolins();
            tGasUserInfolins.setLabel(tGasUserInfos.get(i).getGasUserName());
            tGasUserInfolins.setValue(String.valueOf(tGasUserInfos.get(i).getGasUserId()));
            list.add(tGasUserInfolins);
        }
        AjaxResult ajax = AjaxResult.success();
        ajax.put("list", list);
        ajax.put("tGasBottleInfo", tGasUserInfos);
        return ajax;
    }
    /**
     * 新增燃气用户
     */
    @Log(title = "燃气用户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TGasUserInfo tGasUserInfo)
    {
        return toAjax(tGasUserInfoService.insertTGasUserInfo(tGasUserInfo));
    }

    /**
     * 微信小程序新增燃气用户
     * @param tGasUserInfo
     * @return
     */
    @PostMapping("/addUserInfo")
    public AjaxResult addUserInfo(@RequestBody TGasUserInfo tGasUserInfo){
        tGasUserInfoService.insertTGasUserInfo(tGasUserInfo);
        //设置任务记录信息
        TTaskRecord tTaskRecord=new TTaskRecord();
        //操作人id
        tTaskRecord.setOperator(Long.valueOf(tGasUserInfo.getOperator()));
        //工序
        tTaskRecord.setProcessesName("5");
        tTaskRecord.setCreateTime(new Date());
        tTaskRecord.setProcessesRelationId(tGasUserInfo.getGasUserId());
        //任务记录表信息添加
        return toAjax(tTaskRecordService.insertTTaskRecord(tTaskRecord));
    }


    /**
     * 微信小程序修改燃气用户
     * @param tGasUserInfo
     * @return
     */
    @PostMapping("/updateUserInfo")
    public AjaxResult updateUserInfo(@RequestBody TGasUserInfo tGasUserInfo)
    {
        return toAjax(tGasUserInfoService.updateTGasUserInfo(tGasUserInfo));
    }


    /**
     * 修改燃气用户
     */
    @Log(title = "燃气用户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TGasUserInfo tGasUserInfo)
    {
        return toAjax(tGasUserInfoService.updateTGasUserInfo(tGasUserInfo));
    }


    /**
     * 删除燃气用户
     */
    @Log(title = "燃气用户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{gasUserIds}")
    public AjaxResult remove(@PathVariable Long[] gasUserIds)
    {
        return toAjax(tGasUserInfoService.deleteTGasUserInfoByIds(gasUserIds));
    }

    /**
     * 燃气用户导入
     * @param file
     * @param updateSupport
     * @return
     * @throws Exception
     */
    @Log(title = "燃气用户导入", businessType = BusinessType.IMPORT)
    @PostMapping("/importData")
    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
    {
        ExcelUtil<TGasUserInfo> util = new ExcelUtil<>(TGasUserInfo.class);
        List<TGasUserInfo> tGasUserInfoList = util.importExcel(file.getInputStream());
        String message = tGasUserInfoService.importTGasUserInfo(tGasUserInfoList, updateSupport);
        return AjaxResult.success(message);
    }

    @GetMapping("/importTemplate")
    public AjaxResult importTemplate(){
        ExcelUtil<TGasUserInfo> util = new ExcelUtil<>(TGasUserInfo.class);
        return util.importTemplateExcel("燃气用户数据");
    }
}