package com.steerinfo.meterwork.meterworkrailwayactfirstbak.controller;

import com.jisco.dynamicweight.util.UserUtil;
import com.steerinfo.baseinfo.meterbasecar.model.MeterBaseCar;
import com.steerinfo.baseinfo.meterbaseoperationlog.mapper.MeterBaseOperationLogMapper;
import com.steerinfo.baseinfo.meterbaseoperationlog.model.MeterBaseOperationLog;
import com.steerinfo.baseinfo.meterbaserailwayaiweight.model.MeterBaseRailwayAiweight;
import com.steerinfo.baseinfo.meterbaserailwaycarriageweight.model.MeterBaseRailwayCarriageWeight;
import com.steerinfo.baseinfo.meterbaserailwayweight.mapper.MeterBaseRailwayWeightMapper;
import com.steerinfo.baseinfo.meterbaserailwayweight.model.MeterBaseRailwayWeight;
import com.steerinfo.baseinfo.meterbasespotinfo.mapper.MeterBaseSpotInfoMapper;
import com.steerinfo.baseinfo.meterbasespotinfo.model.MeterBaseSpotInfo;
import com.steerinfo.framework.controller.BaseRESTfulController;
import com.steerinfo.framework.controller.RESTfulResult;
import com.steerinfo.framework.service.pagehelper.PageHelper;
import com.steerinfo.framework.service.pagehelper.PageList;
import com.steerinfo.framework.user.UserPayload;
import com.steerinfo.framework.utils.collection.ListUtils;
import com.steerinfo.metermonitor.metermonitornote.model.MeterMonitorNote;
import com.steerinfo.meterwork.dto.CommonCombination;
import com.steerinfo.meterwork.dto.MeterWorkRailwayActFirstDto;
import com.steerinfo.meterwork.dto.StaffPerformanceAnalysis;
import com.steerinfo.meterwork.except.MarkerMetException;
import com.steerinfo.meterwork.meterworkcaractual.model.MeterWorkCarActual;
import com.steerinfo.meterwork.meterworkcaractualfirst.model.MeterWorkCarActualFirst;
import com.steerinfo.meterwork.meterworkcaractualfirstbak.controller.MeterWorkCarActualFirstBakController;
import com.steerinfo.meterwork.meterworkprelink.model.MeterWorkPreLink;
import com.steerinfo.meterwork.meterworkrailwayactfirst.mapper.MeterWorkRailwayActFirstMapper;
import com.steerinfo.meterwork.meterworkrailwayactfirst.model.MeterWorkRailwayActFirst;
import com.steerinfo.meterwork.meterworkrailwayactfirst.service.IMeterWorkRailwayActFirstService;
import com.steerinfo.meterwork.meterworkrailwayactfirstbak.mapper.MeterWorkRailwayActFirstBakMapper;
import com.steerinfo.meterwork.meterworkrailwayactfirstbak.model.MeterWorkRailwayActFirstBak;
import com.steerinfo.meterwork.meterworkrailwayactfirstbak.service.IMeterWorkRailwayActFirstBakService;
import com.steerinfo.meterwork.meterworkrailwayactual.mapper.MeterWorkRailwayActualMapper;
import com.steerinfo.meterwork.meterworkrailwayactual.model.MeterWorkRailwayActual;
import com.steerinfo.meterwork.meterworkrailwayactualbak.mapper.MeterWorkRailwayActualBakMapper;
import com.steerinfo.meterwork.meterworkrailwayactualbak.model.MeterWorkRailwayActualBak;
import com.steerinfo.meterwork.meterworkrailwaymotorialreceived.model.MeterWorkRailwayMotorialReceived;
import com.steerinfo.meterwork.meterworkrailwayreceived.model.MeterWorkRailwayReceived;
import com.steerinfo.meterwork.meterworkrailwayscheduledhelp.model.MeterWorkRailwayScheduledHelp;
import com.steerinfo.pretrack.prerailwayscale.model.PreRailwayScale;
import com.steerinfo.pretrack.pretrackscale.model.PreTrackScale;
import com.steerinfo.util.PublicMethod;
import com.steerinfo.util.StringUtils;
import feign.Body;
import io.micrometer.core.instrument.Meter;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * MeterWorkRailwayActFirstBak RESTful接口：
 *
 * @author generator
 * @version 1.0-SNAPSHORT 2020-10-14 08:40
 * 类描述
 * 修订历史：
 * 日期：2020-10-14
 * 作者：generator
 * 参考：
 * 描述：MeterWorkRailwayActFirstBak RESTful接口
 * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
 * @see null
 */
@RestController
@RequestMapping("/${api.version}/meterworkrailwayactfirstbaks")
public class MeterWorkRailwayActFirstBakController extends BaseRESTfulController {

    @Resource
    IMeterWorkRailwayActFirstBakService meterWorkRailwayActFirstBakService;

    @Resource
    MeterWorkRailwayActualBakMapper actualMapper;
    @Resource
    MeterWorkRailwayActFirstBakMapper actFirstMapper;
    @Resource
    MeterWorkRailwayActFirstBakMapper meterWorkRailwayActFirstBakMapper;
    @Resource
    MeterBaseRailwayWeightMapper baseRailwayWeightMapper;
    @Resource
    MeterBaseSpotInfoMapper meterBaseSpotInfoMapper;

    @Resource
    MeterBaseOperationLogMapper meterBaseOperationLogMapper;
    private static Logger logger	= LoggerFactory.getLogger( MeterWorkCarActualFirstBakController.class );

    @ApiOperation(value = "获取列表", notes = "分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
    })
    //@RequiresPermissions("meterworkrailwayactfirst:view")
    @GetMapping(value = "/")
    public RESTfulResult list(@RequestParam HashMap parmas, Integer pageNum, Integer pageSize) {
        try {
            PageList<MeterWorkRailwayActFirstBak> list = meterWorkRailwayActFirstBakService.queryForPage(parmas, pageNum, pageSize);
            return success(list);
        } catch (Exception ex) {
           ex.printStackTrace();
throw new MarkerMetException(500, "操作异常！！");
        }
    }

    @ApiOperation(value = "获取列表", notes = "分页模糊查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
    })
    //@RequiresPermissions("meterworkrailwayactfirst:view")
    @GetMapping(value = "/like/")
    public RESTfulResult listLike(@RequestParam HashMap parmas, Integer pageNum, Integer pageSize) {
        try {
            PageList<MeterWorkRailwayActFirstBak> list = meterWorkRailwayActFirstBakService.queryLikeForPage(parmas, pageNum, pageSize);
            return success(list);
        } catch (Exception ex) {
           ex.printStackTrace();
throw new MarkerMetException(500, "操作异常！！");
        }
    }

    @ApiOperation(value = "获取列表", notes = "分页模糊查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
    })
    //@RequiresPermissions("meterworkrailwayactfirst:view")
    @PostMapping(value = "/likeByDesc")
    public RESTfulResult likeByDesc(@RequestBody HashMap parmas, Integer pageNum, Integer pageSize) {
        try {
            PageList<MeterWorkRailwayActFirstBak> list = meterWorkRailwayActFirstBakService.likeByDesc(parmas, pageNum, pageSize);
            return success(list);
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new MarkerMetException(500, "操作异常！！");
        }
    }

    @ApiOperation(value = "降序获取列表", notes = "web端不分页模糊查询")
    @PostMapping(value = "/webByLikeDesc")
    public RESTfulResult webByLikeDesc(@RequestBody HashMap parmas) {
        try {
            List<MeterWorkRailwayActFirstBak> list = meterWorkRailwayActFirstBakService.webByLikeDesc(parmas);
            return success(list);
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new MarkerMetException(500, "操作异常！！");
        }
    }

    @ApiOperation(value = "获取列表", notes = "分页模糊查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
    })
    //@RequiresPermissions("meterworkrailwayactfirst:view")
    @GetMapping(value = "/likeByDesc/")
    public RESTfulResult likeDesc(@RequestParam HashMap parmas, Integer pageNum, Integer pageSize) {
        try {
            PageList<MeterWorkRailwayActFirstBak> list = meterWorkRailwayActFirstBakService.likeByDesc(parmas, pageNum, pageSize);
            return success(list);
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new MarkerMetException(500, "操作异常！！");
        }
    }

    @ApiOperation(value = "C#动轨倒序获取列表", notes = "不分页模糊查询")
    //@RequiresPermissions("meterworkrailwayactfirst:view")
    @PostMapping(value = "/noPage")
    public RESTfulResult noPage(@RequestBody HashMap parmas) {
        try {
            List<MeterWorkRailwayActFirstBak> list = meterWorkRailwayActFirstBakService.noPage(parmas);
            return success(list);
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new MarkerMetException(500, "操作异常！！");
        }
    }

    @ApiOperation(value = "获取倒序列表", notes = "分页模糊查询静态铁水衡和吊钩秤委托")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
    })
    //@RequiresPermissions("meterworkrailwayactfirst:view")
    @GetMapping(value = "/likeByDescTSDG/")
    public RESTfulResult likeByDescTSDG(@RequestParam HashMap parmas, Integer pageNum, Integer pageSize) {
        try {
            PageList<MeterWorkRailwayActFirstBak> list = meterWorkRailwayActFirstBakService.likeByDescTSDG(parmas, pageNum, pageSize);
            return success(list);
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new MarkerMetException(500, "操作异常！！");
        }
    }

    @ApiOperation(value = "获取列表", notes = "分页模糊查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
    })
    //@RequiresPermissions("meterworkrailwayactfirst:view")
    @PostMapping(value = "/like/")
    public RESTfulResult listLikePost(@RequestBody HashMap parmas, Integer pageNum, Integer pageSize) {
        try {
            PageList<MeterWorkRailwayActFirstBak> list = meterWorkRailwayActFirstBakService.queryLikeForPage(parmas, pageNum, pageSize);
            return success(list);
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new MarkerMetException(500, "操作异常！！");
        }
    }

    @ApiOperation(value = "创建", notes = "根据MeterWorkRailwayActFirst对象创建")
    @ApiImplicitParam(name = "meterWorkRailwayActFirst", value = "详细实体meterWorkRailwayActFirst", required = true, dataType = "MeterWorkRailwayActFirst")
    //@RequiresPermissions("meterworkrailwayactfirst:create")
    @PostMapping(value = "/")
    public RESTfulResult add(@RequestBody MeterWorkRailwayActFirstBak model) {
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
            String afl = sdf.format(new Date());
            String no = meterWorkRailwayActFirstBakMapper.getNewID(afl);
            model.setActualFirstNo(afl + no);
//            String no = PublicMethod.IdCreate(3);
//            model.setActualFirstNo(no);
            model.setValueFlag("1");
            model.setMeterWeight(model.getMeterWeight().multiply(new BigDecimal(1000)));
            if(model.getCreateTime() == null || StringUtils.isEmpty(model.getCreateTime().toString())){
                model.setCreateTime(new Date());
            }
            String userId = null;
            String userName = null;
            try{
                UserPayload payload = UserPayload.getCurrUser();
                userId = payload.getUserCode();
                userName = payload.getUserName();
            }catch(Exception e) {
                userId = "admin";
                userName = "admins";
            }
            model.setCreateManNo(userId);
            model.setCreateManName(userName);
            HashMap<String, Object> obj = new HashMap<>();
            obj.put("baseSpotNo", model.getBaseSpotNo());
            List<MeterBaseSpotInfo> spotModel = meterBaseSpotInfoMapper.selectByParameters(obj);
            if(spotModel.size() >= 1) {
                model.setBaseSpotName(spotModel.get(0).getBaseSpotName());
            }else {
                throw new MarkerMetException(500, "计量点配置表未找到相应的计量点！！");
            }


            MeterWorkRailwayActFirstBak meterWorkCarActualFirst = meterWorkRailwayActFirstBakService.add(model);
            return success(meterWorkCarActualFirst);
        } catch (Exception ex) {
           ex.printStackTrace();
           throw new MarkerMetException(500, "操作异常！！");
        }
    }

    @ApiOperation(value = "获取详细信息", notes = "根据url的id来获取详细信息")
    @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "String")
    //@RequiresPermissions("meterworkrailwayactfirst:view")
    @GetMapping(value = "/{id}")
    public RESTfulResult get(@PathVariable String id) {
        try {
            MeterWorkRailwayActFirstBak meterWorkRailwayActFirst = meterWorkRailwayActFirstBakService.getById(id);
            return success(meterWorkRailwayActFirst);
        } catch (Exception ex) {
           ex.printStackTrace();
throw new MarkerMetException(500, "操作异常！！");
        }
    }

    @ApiOperation(value = "更新详细信息", notes = "根据url的id来指定更新对象，并根据传过来的meterWorkRailwayActFirst信息来更新详细信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "String"),
            @ApiImplicitParam(name = "meterWorkRailwayActFirst", value = "详细实体meterWorkRailwayActFirst", required = true, dataType = "MeterWorkRailwayActFirst")
    })
    //@RequiresPermissions("meterworkrailwayactfirst:update")
    @PutMapping(value = "/{id}", produces = "application/json;charset=UTF-8")
    public RESTfulResult update(@PathVariable String id, @RequestBody MeterWorkRailwayActFirstBak model) {
        try {
            model.setId(id);
            MeterWorkRailwayActFirstBak meterWorkRailwayActFirst = meterWorkRailwayActFirstBakService.modify(model);
            return success(meterWorkRailwayActFirst);
        } catch (Exception ex) {
           ex.printStackTrace();
throw new MarkerMetException(500, "操作异常！！");
        }
    }

    @ApiOperation(value = "删除", notes = "根据url的id来指定删除对象")
    @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "String")
    //@RequiresPermissions("meterworkrailwayactfirst:delete")
    @DeleteMapping(value = "/{id}")//String
    public RESTfulResult delete(@PathVariable String id) {
        try {
            List<String> list = Arrays.asList(id.split(","));
            if (ListUtils.isNotEmpty(list)) {
                List<String> ids = ListUtils.convertList(list);
                meterWorkRailwayActFirstBakService.delete(ids);
            }
            return success();
        } catch (Exception ex) {
           ex.printStackTrace();
throw new MarkerMetException(500, "操作异常！！");
        }
    }

    @ApiOperation(value = "新增数据", notes = "根据MeterWorkRailwayActFirst对象创建")
    @ApiImplicitParam(name = "MeterWorkRailwayActFirst", value = "详细实体MeterWorkRailwayActFirst", required = true, dataType = "MeterWorkRailwayActFirst")
    @PostMapping(value = "/add")
    public RESTfulResult chechandadd(@RequestBody MeterWorkRailwayActFirstBak model) {
        RESTfulResult rm = failed();
        try {
            rm = meterWorkRailwayActFirstBakService.checkandadd(model);
            return rm;
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        }
        return rm;
    }

    @ApiOperation(value = "C#动轨新增数据", notes = "根据MeterWorkRailwayActFirst对象创建")
    @ApiImplicitParam(name = "MeterWorkRailwayActFirst", value = "详细实体MeterWorkRailwayActFirst", required = true, dataType = "MeterWorkRailwayActFirst")
    @PostMapping(value = "/dynamicAdd")
    public RESTfulResult dynamicAdd(@RequestBody MeterWorkRailwayActFirstBak model) {
        RESTfulResult rm = failed();
        try {
            rm = meterWorkRailwayActFirstBakService.dynamicAdd(model);
            return rm;
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        }
        return rm;
    }


    @ApiOperation(value = "修改数据", notes = "根据MeterWorkRailwayActFirst对象创建")
    @PostMapping(value = "/update")
    public RESTfulResult chechandupdate(@RequestBody MeterWorkRailwayActFirstBak model) {
        RESTfulResult rm = failed();
        try {
            int num = meterWorkRailwayActFirstBakService.checkandupdate(model);
            if (num >= 1) {
                return success(num);
            } else {
                return failed("修改失败");
            }
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        } finally {

        }
        return rm;
    }

    @ApiOperation(value = "修改数据", notes = "根据MeterWorkRailwayActFirst对象创建")
    @PostMapping(value = "/updateList")
    public RESTfulResult updateList(@RequestBody List<MeterWorkRailwayActFirstBak> models) {
        RESTfulResult rm = new RESTfulResult();
        try {
            rm = meterWorkRailwayActFirstBakService.updateList(models);
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        } finally {

        }
        return rm;
    }

    @ApiOperation(value = "数据审核", notes = "根据MeterWorkRailwayActFirst对象创建")
    @PostMapping(value = "/audit")
    public RESTfulResult audit(@RequestBody MeterWorkRailwayActFirstBak model) {
        RESTfulResult rm = failed();
        try {
            int num = meterWorkRailwayActFirstBakService.audit(model);
            if (num >= 1) {
                return success(num);
            } else {
                return failed("审核失败");
            }
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        } finally {

        }
        return rm;
    }

    @ApiOperation(value = "数据反审", notes = "根据MeterWorkRailwayActFirst对象创建")
    @PostMapping(value = "/unaudit")
    public RESTfulResult unaudit(@RequestBody MeterWorkRailwayActFirstBak model) {
        RESTfulResult rm = failed();
        try {
            int num = meterWorkRailwayActFirstBakService.unaudit(model);
            if (num >= 1) {
                return success(num);
            } else {
                return failed("反审失败");
            }
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        } finally {

        }
        return rm;
    }

    @ApiOperation(value = "条件查询视图", notes = "根据传入参数进行查询")
    @GetMapping(value = "/selectView")
    public RESTfulResult selectView(@RequestParam HashMap parmas, Integer pageNum, Integer pageSize) {
        RESTfulResult rm = failed();
        try {
            PageList<MeterWorkRailwayActFirstBak> pageInfo = meterWorkRailwayActFirstBakService.selectView(parmas, pageNum, pageSize);
            return success(pageInfo);
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        } finally {

        }
        return rm;
    }

    @ApiOperation(value = "修改车号-网页", notes = "根据MeterWorkRailwayActFirst对象修改车号")
    @PostMapping(value = "/updateCar")
    public RESTfulResult updateCar(@RequestBody MeterWorkRailwayActFirstBak model) {
        RESTfulResult rm = failed();
        try {
            int num = meterWorkRailwayActFirstBakService.updateCar(model);
                return success(num);
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        } finally {

        }
        return rm;
    }

    @ApiOperation(value = "停用-网页", notes = "根据MeterWorkRailwayActFirst对象修改状态")
    @PostMapping(value = "/abolish")
    public RESTfulResult abolish(@RequestBody MeterWorkRailwayActFirstBak model) {
        RESTfulResult rm = failed();
        try {
            int num = meterWorkRailwayActFirstBakService.abolish(model);
            if (num >= 1) {
                return success(num);
            } else {
                return failed("停用失败");
            }
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        } finally {

        }
        return rm;
    }


    @ApiOperation(value = "启用-网页", notes = "根据MeterWorkRailwayActFirst对象创建")
    @PostMapping(value = "/recover")
    public RESTfulResult recover(@RequestBody MeterWorkRailwayActFirstBak model) {
        RESTfulResult rm = failed();
        try {
            int num = meterWorkRailwayActFirstBakService.recover(model);
            if (num >= 1) {
                return success(num);
            } else {
                return failed("启用失败");
            }
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        }
        return rm;
    }

    @ApiOperation(value = "解除委托-网页", notes = "根据MeterWorkRailwayActFirst对象创建")
    @PostMapping(value = "/remove")
    public RESTfulResult remove(@RequestBody MeterWorkRailwayActFirstBak model) {
        RESTfulResult rm = failed();
        try {
            int num = meterWorkRailwayActFirstBakService.remove(model);
            if (num >= 1) {
                return success(num);
            } else {
                return failed("解除失败");
            }
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        }
        return rm;
    }

    @ApiOperation(value = "一次数据维护-网页", notes = "根据传入时间和火车号，查询给定时间段去重车号")
    @GetMapping(value = "/distinctRailwayNo")
    public RESTfulResult distinctRailwayNo(@RequestParam HashMap param) {
        RESTfulResult rm = failed();
        try {
            List<String> rows = meterWorkRailwayActFirstBakService.distinctRailwayNo(param);
            return success(rows);
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！>>>" + e.getMessage());
        }
        return rm;
    }

    @ApiOperation(value = "一次数据维护-网页", notes = "根据传入时间和火车号，查询给定时间段去重车号")
    @PostMapping(value = "/distinctRailwayNo")
    public RESTfulResult distinctRailwayNoPost(@RequestBody(required = false) HashMap param) {
        RESTfulResult rm = failed();
        try {
            List<String> rows = meterWorkRailwayActFirstBakService.distinctRailwayNo(param);
            return success(rows);
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！>>>" + e.getMessage());
        }
        return rm;
    }

    @ApiOperation(value = "一次数据维护-网页", notes = "根据传入开始时间、结束时间、轨道衡类型、车号、计量点编号、及连点去重列次编号")
    @PostMapping(value = "/distinctLcNo")
    public RESTfulResult distinctLcNo(@RequestBody HashMap param) {
        RESTfulResult rm = failed();
        try {
            List<String> rows = meterWorkRailwayActFirstBakService.distinctLcNo(param);
            return success(rows);
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！>>>" + e.getMessage());
        }
        return rm;
    }

    @ApiOperation(value = "一次数据维护-查询车次车号", notes = "根据传入时间、火车号、计量站点、物料名称、委托号、数据状态、发货单位和收货单位查询去重车次车号")
    @PostMapping(value = "/distinctLcNoAndRailwayNo")
    public RESTfulResult distinctLcNoAndRailwayNo(@RequestBody HashMap param) {
        RESTfulResult rm = failed();
        try {
            rm = meterWorkRailwayActFirstBakService.distinctLcNoAndRailwayNo(param);
            return rm;
        }catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！>>>" + e.getMessage());
        }
        return rm;
    }

    @ApiOperation(value = "匹配委托-网页", notes = "根据MeterWorkRailwayActFirst对象创建")
    @PostMapping(value = "/match")
    public RESTfulResult match(@RequestBody MeterWorkRailwayActFirstDto model) {
        RESTfulResult rm = failed();
        try {
            MeterWorkRailwayActFirstBak mwraf = meterWorkRailwayActFirstBakService.match(model.getActualFirstNo(), model.getPredictionNo());
            if (mwraf != null) {
                return success(mwraf);
            } else {
                return failed("匹配失败");
            }
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        } finally {

        }
        return rm;
    }

    @ApiOperation(value = "区分动态静态数据", notes = "根据传入参数进行查询")
    @GetMapping(value = "/selectDiff")
    public RESTfulResult selectDiff(@RequestParam Integer pageNum, Integer pageSize, String flag) {
        RESTfulResult rm = failed();
        try {
            PageList<MeterWorkRailwayActFirstBak> pageInfo = meterWorkRailwayActFirstBakService.selectDiff(flag, pageNum, pageSize);
            return success(pageInfo);
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        } finally {

        }
        return rm;
    }

    @ApiOperation(value = "查询毛重数据", notes = "根据传入参数进行查询")
    @GetMapping(value = "/selectTa")
    public RESTfulResult selectTa(@RequestParam HashMap parmas, Integer pageNum, Integer pageSize) {
        RESTfulResult rm = failed();
        try {
            PageList<MeterWorkRailwayActFirstBak> pageInfo = meterWorkRailwayActFirstBakService.selectTa(parmas, pageNum, pageSize);
            return success(pageInfo);
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        } finally {

        }
        return rm;
    }

    @ApiOperation(value = "查询皮重数据", notes = "根据传入参数进行查询")
    @GetMapping(value = "/selectNet")
    public RESTfulResult selectNet(@RequestParam String weightType, String railwayNo, String flag, Integer pageNum, Integer pageSize) {
        RESTfulResult rm = failed();
        try {
            PageHelper.startPage(pageNum, pageSize);
            List<MeterWorkRailwayActFirstBak> rows = meterWorkRailwayActFirstBakService.selectNet(weightType, railwayNo, flag);
            PageList pageInfo = new PageList(rows);
            return success(pageInfo);
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        } finally {

        }
        return rm;
    }

    @ApiOperation(value = "获取动态列表", notes = "分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
    })
    //@RequiresPermissions("meterworkrailwayactfirst:view")
    @GetMapping(value = "/selectAct")
    public RESTfulResult listAct(@RequestParam HashMap parmas, Integer pageNum, Integer pageSize) {
        RESTfulResult rm = failed();
        try {
            PageHelper.startPage(pageNum, pageSize);
            List<MeterWorkRailwayActFirstBak> rows = meterWorkRailwayActFirstBakService.selectAct(parmas, pageNum, pageSize);
            PageList pageInfo = new PageList(rows);
            return success(pageInfo);
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        } finally {

        }
        return rm;
    }

    @ApiOperation(value = "获取静态列表", notes = "分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
    })
    //@RequiresPermissions("meterworkrailwayactfirst:view")
    @GetMapping(value = "/selectSta")
    public RESTfulResult listSta(@RequestParam HashMap parmas, Integer pageNum, Integer pageSize) {
        RESTfulResult rm = failed();
        try {
            PageHelper.startPage(pageNum, pageSize);
            List<MeterWorkRailwayActFirstBak> rows = meterWorkRailwayActFirstBakService.selectSta(parmas);
            PageList pageInfo = new PageList(rows);
            return success(pageInfo);
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        } finally {

        }
        return rm;
    }

    @ApiOperation(value = "获取计量效率具体信息", notes = "根据传入参数进行查询")
    @GetMapping(value = "/detailed")
    public RESTfulResult detailed(@RequestParam String times, String num) {
        RESTfulResult rm = failed();
        try {
            List<MeterWorkRailwayActFirstBak> rows = meterWorkRailwayActFirstBakService.detailed(times, num);
            return success(rows);
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        } finally {

        }
        return rm;
    }

    @ApiOperation(value = "计量员绩效分析", notes = "根据传入参数进行查询")
    @GetMapping(value = "/analysis")
    public RESTfulResult analysis(@RequestParam String startTime, String endTime, Integer pageNum, Integer pageSize) {
        RESTfulResult rm = failed();
        try {
            PageHelper.startPage(pageNum, pageSize);
            List<StaffPerformanceAnalysis> rows = meterWorkRailwayActFirstBakService.analysis(startTime, endTime);
            PageList pageInfo = new PageList(rows);
            return success(pageInfo);
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        } finally {

        }
        return rm;
    }

    @ApiOperation(value = "C#端入库秤实绩静轨使用固重结净", notes = "根据MeterWorkStorageActual对象创建")
    @ApiImplicitParam(name = "meterWorkStorageActual", value = "详细实体meterWorkStorageActual", required = true, dataType = "MeterWorkStorageActual")
    //@RequiresPermissions("meterworkstorageactual:create")
    @PostMapping(value = "/doAddWf")
    public RESTfulResult doAddWf(@RequestBody CommonCombination<MeterWorkRailwayActFirstBak, MeterWorkRailwayActualBak, MeterWorkRailwayActFirstBak, MeterMonitorNote> model) {
        RESTfulResult rm = failed();
        try {
            String no = meterWorkRailwayActFirstBakService.doAddWf(model.getOne(), model.getTwo());
            if (StringUtils.isEmpty(no)) {
                return failed(null, "新增数据失败");
            }
            return success(no);
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        } finally {

        }
        return rm;
    }

    @ApiOperation(value = "C#端轨道衡实绩动轨", notes = "根据MeterWorkStorageActual对象创建")
    @ApiImplicitParam(name = "meterWorkStorageActual", value = "详细实体meterWorkStorageActual", required = true, dataType = "MeterWorkStorageActual")
    //@RequiresPermissions("meterworkstorageactual:create")
    @PostMapping(value = "/doAddMotoriaWf")
    public RESTfulResult doAddWfAct(@RequestBody CommonCombination<PreRailwayScale, List<MeterWorkRailwayActFirstBak>, MeterBaseRailwayWeight, MeterMonitorNote> model) {
        RESTfulResult rm = failed();
        try {
            String userId = "";
            String userName = "";
            if(StringUtils.isEmpty(model.getTwo().get(0).getCreateManNo())){
                UserPayload payload = UserPayload.getCurrUser();
                userId = payload.getUserCode();
                userName = payload.getUserName();
            }

            String no = "";
            MeterBaseRailwayWeight mbr = baseRailwayWeightMapper.selectByPrimaryKey(model.getThree().getRailwayPk());
            for (MeterWorkRailwayActFirstBak first : model.getTwo()) {
                if(StringUtils.isEmpty(first.getCreateManNo())){
                    first.setCreateManNo(userId);
                    first.setCreateManName(userName);
                }
                if(first.getCreateTime()==null){
                    first.setCreateTime(new Date());
                }
                if(StringUtils.isEmpty(first.getActualFirstNo())) {
                    //此为第一次计量的数据
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
                    String afl = sdf.format(new Date());
                    //一次数据
                    String firstNo = actFirstMapper.getNewID(afl);
                    first.setActualFirstNo(afl + firstNo);
                }else if(first.getActualFirstNo().length()>14){
                    first.setActualFirstNo(first.getActualFirstNo().substring(2));
                }
                no += meterWorkRailwayActFirstBakService.doAddWfAct(model.getOne(), first, mbr) + ",";
            }

            if (StringUtils.isEmpty(no)) {
                return failed(null, "新增数据失败");
            }
            return success(no.substring(0, no.length() - 1));
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        } finally {

        }
        return rm;
    }

    @ApiOperation(value = "C#端轨道衡实绩静轨需二次结净", notes = "根据MeterWorkStorageActual对象创建")
    @PostMapping(value = "/doAddWfStatic")
    public RESTfulResult doAddWfStatic(@RequestBody MeterWorkRailwayActFirstBak model) {
        RESTfulResult rm = failed();
        try {
            rm = meterWorkRailwayActFirstBakService.doAddWfStatic(model);
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        }
        return rm;
    }

    @ApiOperation(value = "C#端轨道衡实绩静轨需标志皮重结净", notes = "根据MeterWorkStorageActual对象创建")
    @PostMapping(value = "/doIdentifyWeight")
    public RESTfulResult doIdentifyWeight(@RequestBody MeterWorkRailwayActFirstBak model) {
        RESTfulResult rm = failed();
        try {
            rm = meterWorkRailwayActFirstBakService.doIdentifyWeight(model);
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常,请确认！！！>>>" + e.getMessage());
        }
        return rm;
    }

    @ApiOperation(value = "C#端轨道衡实绩静轨结净--两条数据", notes = "根据两个MeterWorkStorageActual对象创建")
    @PostMapping(value = "/doAddWfStaticTwo")
    public RESTfulResult doAddWfStaticTwo(@RequestBody CommonCombination<PreRailwayScale, MeterWorkRailwayActFirstBak, MeterWorkRailwayActFirstBak, MeterWorkRailwayActFirstBak> com) {
        RESTfulResult rm = failed();
        try {
            rm = meterWorkRailwayActFirstBakService.doAddWfStaticTwo(com.getOne(), com.getTwo(), com.getThree());
            return rm;
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！>>>" + e.getMessage());
        }
        return rm;
    }

    @ApiOperation(value = "C#端轨道衡实绩静轨复磅", notes = "根据MeterWorkStorageActual对象创建")
    @PostMapping(value = "/doAddWfRecover")
    public RESTfulResult doAddWfRecover(@RequestBody MeterWorkRailwayActFirstBak model) {
        RESTfulResult rm = failed();
        try {
            String no = meterWorkRailwayActFirstBakService.doAddWfRecover(model);
            if (StringUtils.isEmpty(no)) {
                return failed(null, "复磅数据保存失败");
            }
            return success(no);
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        } finally {

        }
        return rm;
    }

    @ApiOperation(value = "C#端轨道衡实绩静轨-复磅-更新自重", notes = "根据MeterWorkStorageActual对象创建")
    @PostMapping(value = "/doUpdateSelfWeight")
    public RESTfulResult doUpdateSelfWeight(@RequestBody MeterWorkRailwayActFirstBak model) {
        RESTfulResult rm = failed();
        try {
            String no = meterWorkRailwayActFirstBakService.doUpdateSelfWeight(model);
            if (StringUtils.isEmpty(no)) {
                return failed(null, "复磅数据保存失败");
            }
            return success(no);
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        } finally {

        }
        return rm;
    }

    @ApiOperation(value = "动轨获取列表", notes = "分页查询")
    @GetMapping(value = "/doQueryWf")
    public RESTfulResult doQueryWf(@RequestParam HashMap parmas, Integer pageNum, Integer pageSize) {
        try {
            PageList<MeterWorkRailwayActFirstBak> list = meterWorkRailwayActFirstBakService.doQueryWf(parmas, pageNum, pageSize);
            return success(list);
        } catch (Exception ex) {
           ex.printStackTrace();
throw new MarkerMetException(500, "操作异常！！");
        }
    }

    @ApiOperation(value = "水分数据操作", notes = "水分数据操作")
    @PostMapping(value = "/doEditMotoriaWf")
    public RESTfulResult doEditMotoriaWf(@RequestBody List<MeterWorkRailwayActualBak> lma) {
        try {
            if (lma != null && lma.size() > 0) {
                for (MeterWorkRailwayActualBak ma : lma) {
                    MeterWorkRailwayActualBak m = new MeterWorkRailwayActualBak();
                    m.setActualNo(ma.getActualNo());
                    m.setWaterNum(ma.getWaterNum());
                    actualMapper.updateByPrimaryKeySelective(m);

                    MeterWorkRailwayActFirstBak first = new MeterWorkRailwayActFirstBak();
                    first.setActualFirstNo(ma.getActualFirst1No());
                    first.setWaterNum(ma.getWaterNum());
                    actFirstMapper.updateByPrimaryKeySelective(first);
                }
            }
            return success();
        } catch (Exception ex) {
           ex.printStackTrace();
throw new MarkerMetException(500, "操作异常！！");
        }
    }
    @ApiOperation(value = "智能终端混装混卸--远程计量")
    @Transactional
    @PostMapping(value = "/doAddNetHZHX", produces = "application/json;charset=UTF-8")
    public RESTfulResult doAddNetHZHX(@RequestBody CommonCombination<MeterWorkRailwayActFirstBak, MeterWorkRailwayActualBak,MeterWorkRailwayActFirstBak, MeterMonitorNote> com) {
        try {
            RESTfulResult rm = meterWorkRailwayActFirstBakService.doAddNetHZHX(com.getOne(), com.getTwo(), com.getThree(), com.getFour());
            return rm;
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return failed(null, "操作异常，请确认！");
        }
    }

    @ApiOperation(value = "智能终端混装混卸--智能计量(记录)")
    @Transactional
    @PostMapping(value = "/doAddNetHZHXTwo", produces = "application/json;charset=UTF-8")
    public RESTfulResult doAddNetHZHXTwo(@RequestBody CommonCombination<PreRailwayScale, MeterWorkRailwayActFirstBak,MeterWorkRailwayActFirstBak, MeterMonitorNote> com) {
        try {
            RESTfulResult rm = meterWorkRailwayActFirstBakService.doAddNetHZHXTwo(com.getOne(), com.getTwo(), com.getThree(), com.getFour(), com.getSOne());
            return rm;
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return failed(null, "操作异常，请确认！");
        }
    }

    @ApiOperation(value = "双委托结净--远程计量")
    @Transactional
    @PostMapping(value = "/doNetAddTwo", produces = "application/json;charset=UTF-8")
    public RESTfulResult doNetAddTwo(@RequestBody CommonCombination<MeterWorkRailwayActFirstBak, MeterWorkRailwayActualBak, PreRailwayScale, PreRailwayScale> com) {
        try {
            RESTfulResult rm = meterWorkRailwayActFirstBakService.doNetAddTwo(com.getOne(), com.getTwo(), com.getThree(), com.getFour());
            return rm;
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return failed(null, "操作异常，请确认！");
        }
    }

    @ApiOperation(value = "双委托结净--远程计量")
    @Transactional
    @PostMapping(value = "/doNetAddTwo02", produces = "application/json;charset=UTF-8")
    public RESTfulResult doNetAddTwo02(@RequestBody CommonCombination<List<MeterWorkRailwayActFirstBak>, List<MeterWorkRailwayActFirstBak>, List<PreRailwayScale>, String> com) {
        try {
            RESTfulResult rm = meterWorkRailwayActFirstBakService.doNetAddTwo02(com.getOne(), com.getTwo(), com.getThree(), com.getFour());
            return rm;
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return failed(null, "操作异常，请确认！");
        }
    }

    @ApiOperation(value = "双委托结净--智能计量(记录)")
    @Transactional
    @PostMapping(value = "/doNetAddTwoDouble", produces = "application/json;charset=UTF-8")
    public RESTfulResult doNetAddTwoDouble(@RequestBody CommonCombination<PreRailwayScale, PreRailwayScale, MeterWorkRailwayActFirstBak, MeterWorkRailwayActFirstBak> com) {
        try {
            RESTfulResult rm = meterWorkRailwayActFirstBakService.doNetAddTwoDouble(com.getOne(), com.getTwo(), com.getThree(), com.getFour());
            return rm;
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return failed(null, "操作异常，请确认！");
        }
    }

    @ApiOperation(value = "轨道衡双委托匹配结净", notes = "轨道衡双委托匹配结净")
    //@RequiresPermissions("meterworkcaractual:view")
    @PostMapping(value = "/doubleEntrustMatch")
    public RESTfulResult doubleEntrustmentMatch(@RequestBody HashMap parmas) {
        RESTfulResult rm = failed();
        try {
            String actualNo1 = parmas.get("actualNo1").toString();
            String actualNo2 = parmas.get("actualNo2").toString();
            String predictionNo1 = parmas.get("predictionNo1").toString();
            String predictionNo2 = parmas.get("predictionNo2").toString();

            String msg = meterWorkRailwayActFirstBakService.doubleEntrustMatch(actualNo1, actualNo2,predictionNo1,predictionNo2);
            rm.setMessage(msg);
            if (rm.getMessage() != "" || !rm.getMessage().equals("")){
                return rm;
            }
            return success();
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new MarkerMetException(500, "操作异常！！");
        }
    }

    @ApiOperation(value = "混装", notes = "混装")
    //@RequiresPermissions("meterworkcaractual:view")
    @PostMapping(value = "/mixedLoading")
    public RESTfulResult mixedLoading(@RequestBody HashMap parmas) {
        try {
            String actualNo1 = parmas.get("actualNo1").toString();
            String actualNo2 = parmas.get("actualNo2").toString();
            String actualNo3 = parmas.get("actualNo3").toString();
            String predictionNo1 = parmas.get("predictionNo1").toString();
            String predictionNo2 = parmas.get("predictionNo2").toString();
            String msg = meterWorkRailwayActFirstBakService.mixedLoading(actualNo1, actualNo2,actualNo3,predictionNo1,predictionNo2);
            if (msg != "" || !msg.equals("")){
                return failed(null,msg);
            }
            return success();
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new MarkerMetException(500, "操作异常！！");
        }
    }

    @ApiOperation(value = "混卸", notes = "混卸")
    //@RequiresPermissions("meterworkcaractual:view")
    @PostMapping(value = "/mixedDischarge")
    public RESTfulResult mixedDischarge(@RequestBody HashMap parmas) {
        try {
            String actualNo1 = parmas.get("actualNo1").toString();
            String actualNo2 = parmas.get("actualNo2").toString();
            String actualNo3 = parmas.get("actualNo3").toString();
            String predictionNo1 = parmas.get("predictionNo1").toString();
            String predictionNo2 = parmas.get("predictionNo2").toString();

            String msg = meterWorkRailwayActFirstBakService.mixedDischarge(actualNo1, actualNo2,actualNo3,predictionNo1,predictionNo2);
            if (msg != "" || !msg.equals("")){
                return failed(null,msg);
            }
            return success();
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new MarkerMetException(500, "操作异常！！");
        }
    }

    @ApiOperation(value = "标识皮重结净", notes = "标识皮重结净")
    //@RequiresPermissions("meterworkcaractual:view")
    @PostMapping(value = "/fixedTare")
    public RESTfulResult fixedTare(@RequestBody HashMap parmas) {
        RESTfulResult rm = failed();
        try {
            String actualNo = parmas.get("actualNo") == null ? "" : parmas.get("actualNo").toString();
            String predictionNo = parmas.get("predictionNo") == null ? "" : parmas.get("predictionNo").toString();
            String tareWeight = parmas.get("tareWeight") == null ? "" : parmas.get("tareWeight").toString();

            String msg = meterWorkRailwayActFirstBakService.fixedTare(actualNo, tareWeight, predictionNo);
            if (msg.equals("")){
                return rm;
            }
            rm.setSucceed();
            rm.setCode("200");
            rm.setMessage(msg);
            return rm;


        } catch (Exception ex) {
            ex.printStackTrace();
            throw new MarkerMetException(500, "操作异常！！");
        }
    }

    @ApiOperation(value = "历史皮重结净", notes = "历史皮重结净")
    //@RequiresPermissions("meterworkcaractual:view")
    @PostMapping(value = "/HistoricalTare")
    public RESTfulResult HistoricalTare(@RequestBody HashMap parmas) {
        RESTfulResult rm = failed();
        try {
            String actualNo = parmas.get("actualNo") == null ? "" : parmas.get("actualNo").toString();
            String predictionNo = parmas.get("predictionNo") == null ? "" : parmas.get("predictionNo").toString();

            rm = meterWorkRailwayActFirstBakService.HistoricalTare(actualNo, predictionNo);
            return rm;
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new MarkerMetException(500, "操作异常！！");
        }
    }

    @ApiOperation(value = "轨道衡衡一次数据补录", notes = "根据MeterWorkRailwayActFirst对象创建")
    @PostMapping(value = "/supplementaryData")
    public RESTfulResult supplementaryData(@RequestBody HashMap map) {
        RESTfulResult rm = failed();
        try {
            MeterWorkRailwayActFirstBak model = new MeterWorkRailwayActFirstBak();
            model.setBaseSpotNo(map.get("baseSpotNo").toString());
            model.setBaseSpotName(map.get("baseSpotName").toString());
            model.setCreateManNo(map.get("createManNo").toString());
            model.setCreateManName(map.get("createManName").toString());
            /*SimpleDateFormat sdf = new SimpleDateFormat( "yyyy/MM/dd HH24:mm:ss" );
            Date date = sdf.parse(map.get("createTime").toString());*/
            model.setMeterWeight(new BigDecimal(map.get("meterWeight").toString()));
            model.setWeightType(map.get("weightType").toString());
            model.setRailwayNo(map.get("railwayNo").toString());
            model.setRailwayModelNo(map.get("railwayModelNo").toString());
            model.setRailwayModelName(map.get("railwayModelName").toString());
            model.setRailwayTypeNo(map.get("railwayTypeNo").toString());
            model.setRailwayTypeName(map.get("railwayTypeName").toString());
//            model.setBaseSpotNo(splitString(map.get("baseSpotNo").toString(), 0));
//            model.setBaseSpotName(splitString(map.get("baseSpotNo").toString(), 1));
//            model.setCreateManNo(splitString(map.get("createManNo").toString(), 0));
//            model.setCreateManName(splitString(map.get("createManNo").toString(), 1));
//            model.setRailwayModelNo(splitString(map.get("railwayModelNo").toString(), 0));
//            model.setRailwayModelName(splitString(map.get("railwayModelNo").toString(), 1));
//            model.setRailwayTypeNo(splitString(map.get("railwayTypeNo").toString(), 0));
//            model.setRailwayTypeName(splitString(map.get("railwayTypeNo").toString(), 1));
            rm = meterWorkRailwayActFirstBakService.supplementaryData(model);
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        } finally {

        }
        return rm;
    }

    //获取编号或者名称
    public String splitString(String str, int i) {
        String[] newString = str.split(",");
        return newString[0];
    }

    @ApiOperation(value = "动态衡维护界面--皮重保存", notes = "根据List<MeterWorkRailwayActFirst>对象进行批量修改重量类型")
    @PostMapping(value = "/doAddRailWf")
    public RESTfulResult doAddRailWf(@RequestBody List<MeterWorkRailwayActFirstBak> models) {
        RESTfulResult rm = failed();
        try {
            if(models.size() >= 1) {
                rm = meterWorkRailwayActFirstBakService.doAddRailWf(models);
            }else {
                rm.setMessage("至少需要选择一条数据进行皮重保存，请确认！！！！");
            }
            return rm;
        }catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！>>>>" + e.getMessage());
            return rm;
        }
    }

    @ApiOperation(value = "动态衡维护界面--毛皮匹配结净保存", notes = "根据毛皮的List<MeterWorkRailwayActFirst>对象进行批量匹配结净保存")
    @PostMapping(value = "/doAddRailNetWf")
    public RESTfulResult doAddRailNetWf(@RequestBody CommonCombination<List<MeterWorkRailwayMotorialReceived>, List<MeterWorkRailwayActFirstBak>, MeterBaseRailwayWeight,MeterBaseRailwayWeight> com) {
        RESTfulResult rm = failed();
        try {

            if(com.getOne().size() >= 1 && com.getTwo().size() >= 1) {
                rm = meterWorkRailwayActFirstBakService.doAddRailNetWf(com.getOne(), com.getTwo());
            }else if(com.getOne().size() < 1){
                rm.setMessage("至少需要选择一条毛重数据进行匹配结净保存，请确认！！！！");
            }else if(com.getTwo().size() < 1) {
                rm.setMessage("至少需要选择一条皮重数据进行匹配结净保存，请确认！！！！");
            }
            return rm;
        }catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！>>>>" + e.getMessage());
            return rm;
        }
    }

    @ApiOperation(value = "动态衡维护界面--毛皮匹配结净保存", notes = "根据毛皮的List<MeterWorkRailwayActFirst>对象进行批量匹配结净保存")
    @PostMapping(value = "/doNetAddMotoriaRailway")
    public RESTfulResult doNetAddMotoriaRailway(@RequestBody CommonCombination<MeterWorkRailwayMotorialReceived, MeterWorkRailwayActFirstBak, PreRailwayScale,MeterBaseRailwayWeight> com) {
        RESTfulResult rm = failed();
        try {

            if(Objects.nonNull(com.getOne()) && Objects.nonNull(com.getTwo())) {
                rm = meterWorkRailwayActFirstBakService.doNetAddMotoriaRailway(com.getOne(), com.getTwo(), com.getThree());
            }else if(Objects.isNull(com.getOne())){
                rm.setMessage("需要选择一条毛重数据进行匹配结净保存，请确认！！！！");
            }else if(Objects.isNull(com.getTwo())) {
                rm.setMessage("需要选择一条皮重数据进行匹配结净保存，请确认！！！！");
            }
            return rm;
        }catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！>>>>" + e.getMessage());
            return rm;
        }
    }

    @ApiOperation(value = "动态衡维护界面--毛皮匹配结净保存", notes = "根据毛皮的List<MeterWorkRailwayActFirst>对象进行批量匹配结净保存")
    @PostMapping(value = "/doAddRailAINetWf")
    public RESTfulResult doAddRailAINetWf(@RequestBody CommonCombination<List<MeterWorkRailwayMotorialReceived>, List<MeterBaseRailwayAiweight>, MeterBaseRailwayWeight,MeterBaseRailwayWeight> com) {
        RESTfulResult rm = failed();
        try {

            if(com.getOne().size() >= 1 && com.getTwo().size() >= 1) {
                rm = meterWorkRailwayActFirstBakService.doAddRailAINetWf(com.getOne(), com.getTwo());
            }else if(com.getOne().size() < 1){
                rm.setMessage("至少需要选择一条毛重数据进行匹配结净保存，请确认！！！！");
            }else if(com.getTwo().size() < 1) {
                rm.setMessage("至少需要选择一条AI标志皮重数据进行匹配结净保存，请确认！！！！");
            }
            return rm;
        }catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！>>>>" + e.getMessage());
            return rm;
        }
    }

    @ApiOperation(value = "动态衡维护界面--对从表数据进行AI标志皮结净", notes = "根据毛皮的MeterWorkRailwayActFirst对象进行批量匹配结净保存")
    @PostMapping(value = "/doAddNetInnerWf")
    public RESTfulResult doAddNetInnerWf(@RequestBody CommonCombination<MeterBaseRailwayAiweight,MeterWorkRailwayMotorialReceived, PreRailwayScale,MeterBaseRailwayWeight> com) {
        RESTfulResult rm = failed();
        try {
            if(Objects.nonNull(com.getOne()) && Objects.nonNull(com.getTwo())) {
                rm = meterWorkRailwayActFirstBakService.doAddNetInnerWf(com.getTwo(),com.getOne(), com.getThree());
            }else if(Objects.isNull(com.getOne())){
                rm.setMessage("选择一条AI标志皮重数据进行匹配结净保存，请确认！！");
            }else if(Objects.isNull(com.getTwo())) {
                rm.setMessage("选择一条一次数据进行匹配结净保存，请确认！！");
            }
            return rm;
        }catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！>>>>" + e.getMessage());
            return rm;
        }
    }

    @ApiOperation(value = "动态衡维护界面--对从表数据进行标准皮结净", notes = "根据毛的MeterWorkRailwayMotorialReceivedt对象进行批量匹配结净保存")
    @PostMapping(value = "/doAddNetWeight")
    public RESTfulResult doAddNetWeight(@RequestBody CommonCombination<MeterBaseRailwayCarriageWeight,MeterWorkRailwayMotorialReceived, PreRailwayScale,MeterBaseRailwayWeight> com) {
        RESTfulResult rm = failed();
        try {
            if(Objects.nonNull(com.getOne()) && Objects.nonNull(com.getTwo())) {
                rm = meterWorkRailwayActFirstBakService.doAddNetWeight(com.getTwo(),com.getOne(), com.getThree());
            }else if(Objects.isNull(com.getOne())){
                rm.setMessage("选择一条标准皮重数据进行匹配结净保存，请确认！！");
            }else if(Objects.isNull(com.getTwo())) {
                rm.setMessage("选择一条一次数据进行匹配结净保存，请确认！！");
            }
            return rm;
        }catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！>>>>" + e.getMessage());
            return rm;
        }
    }

    @ApiOperation(value = "动态衡维护界面--毛皮匹配结净保存", notes = "根据毛皮的List<MeterWorkRailwayActFirst>对象进行批量匹配结净保存")
    @PostMapping(value = "/selfServiceMeasurement")
    public RESTfulResult selfServiceMeasurement(@RequestBody MeterWorkRailwayActFirstBak first) {
        RESTfulResult rm = failed();
        try {

            if(first != null) {
                rm = meterWorkRailwayActFirstBakService.selfServiceMeasurement(first);
            }else {
                rm.setMessage("至少需要穿一条一次数据进行匹配结净保存，请确认！！！！");
            }
            return rm;
        }catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！>>>>" + e.getMessage());
            return rm;
        }
    }

    @ApiOperation(value = "批量修改静态衡列次编号", notes = "批量修改静态衡列次编号")
    @PostMapping(value = "/batchUpdateLcNo")
    public RESTfulResult batchUpdateLcNo(@RequestBody List<MeterWorkRailwayActFirstBak> models) {
        RESTfulResult rm = failed();
        try {
            rm = meterWorkRailwayActFirstBakService.batchUpdateLcNo(models);
        } catch (MarkerMetException e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！");
        } finally {

        }
        return rm;
    }

    @ApiOperation(value = "静态衡维护界面--对一次数据进行标准皮结净", notes = "根据毛的MeterWorkRailwayactFirst对象进行批量匹配结净保存")
    @PostMapping(value = "/doStandardMatch")
    public RESTfulResult doStandardMatch(@RequestBody HashMap param) {
        RESTfulResult rm = failed();
        try {
            rm = meterWorkRailwayActFirstBakService.doStandardMatch(param);
            return rm;
        }catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！>>>>" + e.getMessage());
            return rm;
        }
    }

    @ApiOperation(value = "轨道衡批量匹配界面显示")
    @Transactional
    @PostMapping(value = "/batchMatchView")
    public RESTfulResult batchMatchView(@RequestBody HashMap param) {
        RESTfulResult rm = failed();
        try {
            rm = meterWorkRailwayActFirstBakService.batchMatchView(param);
            return rm;
        }catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！>>>>" + e.getMessage());
            return rm;
        }
    }

    @ApiOperation(value = "动轨计量终端从表数据处理批量匹配AI标识皮", notes = "一定要有委托才能才能进行结净")
    @Transactional
    @PostMapping(value = "/DynamicBatchMatchAIweight")
    public RESTfulResult DynamicBatchMatchAIweight(@RequestBody List<MeterWorkRailwayReceived> receivedList) {
        RESTfulResult rm = failed();
        try {
            rm = meterWorkRailwayActFirstBakService.DynamicBatchMatchAIweight(receivedList);
            return rm;
        }catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！>>>>" + e.getMessage());
            return rm;
        }
    }

    @ApiOperation(value = "动轨计量终端从表数据处理批量匹配标准皮", notes = "一定要有委托才能才能进行结净")
    @Transactional
    @PostMapping(value = "/DynamicBatchMatchCarriageWeight")
    public RESTfulResult DynamicBatchMatchCarriageWeight(@RequestBody List<MeterWorkRailwayReceived> receivedList) {
        RESTfulResult rm = failed();
        try {
            rm = meterWorkRailwayActFirstBakService.DynamicBatchMatchCarriageWeight(receivedList);
            return rm;
        }catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！>>>>" + e.getMessage());
            return rm;
        }
    }

    @ApiOperation(value = "动轨计量终端从表数据处理批量匹配一次空皮", notes = "一定要有委托才能才能进行结净")
    @Transactional
    @PostMapping(value = "/DynamicBatchMatchFirstWeight")
    public RESTfulResult DynamicBatchMatchFirstWeight(@RequestBody List<MeterWorkRailwayReceived> receivedList) {
        RESTfulResult rm = failed();
        try {
            rm = meterWorkRailwayActFirstBakService.DynamicBatchMatchFirstWeight(receivedList);
            return rm;
        }catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！>>>>" + e.getMessage());
            return rm;
        }
    }

    @ApiOperation(value = "动轨计量终端从表数据处理批量匹配一次历史皮", notes = "一定要有委托才能才能进行结净")
    @Transactional
    @PostMapping(value = "/DynamicBatchMatchHisTareWeight")
    public RESTfulResult DynamicBatchMatchHisTareWeight(@RequestBody List<MeterWorkRailwayReceived> receivedList) {
        RESTfulResult rm = failed();
        try {
            rm = meterWorkRailwayActFirstBakService.DynamicBatchMatchHisTareWeight(receivedList);
            return rm;
        }catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！>>>>" + e.getMessage());
            return rm;
        }
    }

    @ApiOperation(value = "web端一次轨道衡数据处理批量匹配标识皮", notes = "")
    @Transactional
    @PostMapping(value = "/WebBatchMatchidentifyWeight")
    public RESTfulResult WebBatchMatchidentifyWeight(@RequestBody List<HashMap> models) {
        RESTfulResult rm = failed();
        try {
            rm = meterWorkRailwayActFirstBakService.WebBatchMatchidentifyWeight(models);
            return rm;
        }catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！>>>>" + e.getMessage());
            return rm;
        }
    }


    @ApiOperation(value = "静态轨道衡自助计量保存", notes = "")
    @Transactional
    @PostMapping(value = "/saveAutoScale")
    public RESTfulResult saveAutoScale(@RequestBody  CommonCombination<MeterWorkRailwayActFirstBak, MeterWorkRailwayActFirstBak, MeterWorkRailwayActualBak, MeterWorkRailwayScheduledHelp> com) {
        RESTfulResult rm = failed();
        try {
            rm = meterWorkRailwayActFirstBakService.saveAutoScale(com);
            return rm;
        }catch (Exception e) {
            e.printStackTrace();
            rm.setMessage("操作异常，请确认！>>>>" + e.getMessage());
            return rm;
        }
    }

    @ApiOperation(value = "应急计量单个新增")
    @Transactional
    @PostMapping(value = "/addFirstEmergency", produces = "application/json;charset=UTF-8")
    public RESTfulResult addFirstEmergency(@RequestBody MeterWorkRailwayActFirstBak model) {
        try {
            RESTfulResult rm = meterWorkRailwayActFirstBakService.addFirstEmergency(model);
            if(!rm.isSucceed()) {
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            }
            return rm;
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return failed(null, "操作异常，请确认！");
        }
    }

    @ApiOperation(value = "应急计量-两个一次数据编号结净")
    @Transactional
    @PostMapping(value = "/doNetEmergency", produces = "application/json;charset=UTF-8")
    public RESTfulResult doNetEmergency(@RequestBody MeterWorkRailwayActualBak model) {
        try {
            RESTfulResult rm = meterWorkRailwayActFirstBakService.doNetEmergency(model);
            return rm;
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return failed(null, "操作异常，请确认！");
        }
    }

    @ApiOperation(value = "毛皮转换")
    @Transactional
    @PostMapping(value = "/furConversion")
    public RESTfulResult furConversion(@RequestBody HashMap params) {
        try {
            RESTfulResult rm = meterWorkRailwayActFirstBakService.furConversion(params);
            if(!rm.isSucceed()) {
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            }
            return rm;
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return failed(null, "操作异常，请确认！");
        }
    }

    @ApiOperation(value = "将数据从MeterWorkCarRaiFirstBak复制到MeterWorkCarActualFirst")
    @PostMapping(value = "/copyToFirst")
    public RESTfulResult copyToFirst(@RequestBody HashMap params){
        RESTfulResult rm = new RESTfulResult();
        rm.setFailed();
        try {
            List<String> ids = (List<String>) params.get("ids");
            String railwayNo = params.get("railwayNo") == null ? "": params.get("railwayNo").toString();
            rm = meterWorkRailwayActFirstBakService.CopyToFirst(ids,railwayNo);
        } catch (Exception e) {
            e.printStackTrace();
            rm.setMessage(e.getMessage());
        }
        return rm;
    }


    //======================eason add 2023-04-14 =============================================
    @ApiOperation(value = "创建", notes = "根据MeterWorkRailwayActFirst对象创建")
    @ApiImplicitParam(name = "meterWorkRailwayActFirst", value = "详细实体meterWorkRailwayActFirst", required = true, dataType = "MeterWorkRailwayActFirst")
    @PostMapping(value = "/addFirstEmergencyList")
    @Transactional
    public RESTfulResult addFirstEmergencyList(@RequestBody List<MeterWorkRailwayActFirstBak> lt) {
        try {
            RESTfulResult rm = meterWorkRailwayActFirstBakService.addFirstEmergencyList(lt);
            if(!rm.isSucceed()) {
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            }
            return rm;
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return failed(null, "操作异常，请确认！");
        }
    }
}
