123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620 |
- package com.steerinfo.dil.controller;
- import com.steerinfo.dil.feign.ColumnDataFeign;
- import com.steerinfo.dil.feign.ESFeign;
- import com.steerinfo.dil.mapper.AmsContractTruckPriceMapper;
- import com.steerinfo.dil.model.AmsContractTransportPrice;
- import com.steerinfo.dil.service.IAmsContractTruckPriceService;
- import com.steerinfo.dil.util.BaseRESTfulController;
- import com.steerinfo.dil.util.ColumnDataUtil;
- import com.steerinfo.dil.util.DataChange;
- import com.steerinfo.dil.util.PageListAdd;
- import com.steerinfo.framework.controller.RESTfulResult;
- import com.steerinfo.framework.service.pagehelper.PageHelper;
- import io.swagger.annotations.ApiImplicitParam;
- import io.swagger.annotations.ApiImplicitParams;
- import io.swagger.annotations.ApiModelProperty;
- import io.swagger.annotations.ApiOperation;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import java.math.BigDecimal;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.*;
- import java.util.stream.Collectors;
- /**
- * AmsContractTransportPrice RESTful接口:
- * @author generator
- * @version 1.0-SNAPSHORT 2021-09-06 07:10
- * 类描述
- * 修订历史:
- * 日期:2021-09-06
- * 作者:generator
- * 参考:
- * 描述:AmsContractTransportPrice RESTful接口
- * @see null
- * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
- */
- @RestController
- @RequestMapping("/${api.version}/amscontracttruckprices")
- public class AmsContractTruckPriceController extends BaseRESTfulController {
- @Autowired
- IAmsContractTruckPriceService amsContractTruckPriceService;
- @Autowired
- ColumnDataFeign columnDataFeign;
- @Autowired
- ColumnDataUtil columnDataUtil;
- @Autowired
- ESFeign esFeign;
- @Autowired
- AmsContractTruckPriceMapper amsContractTruckPriceMapper;
- @ApiOperation(value="查询汽运单价信息")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "apiId(109)", value = "表头", required = false, dataType = "Interger")
- })
- @PostMapping("/getAmsContractTransportPrice1")
- public RESTfulResult getAmsContractTransportPrice(@RequestBody(required=false) Map<String,Object> mapValue,
- Integer apiId,
- Integer pageNum,
- Integer pageSize,
- String con,
- Integer deleted){
- if(deleted != null) {
- mapValue.put("deleted", deleted);
- }
- if(con !=null){
- mapValue.put("con",con);
- }
- if(pageNum==null&&pageSize==null){
- }else {
- PageHelper.startPage(pageNum, pageSize);
- }
- List<Map<String, Object>> amsContractTransportPrice1 = amsContractTruckPriceService.getAmsContractTransportPrice(mapValue);
- //PageListAdd pageList = columnDataUtil.tableColumnData(apiId, null,amsContractTransportPrice1);
- List<Map<String, Object>> columnDataList = columnDataFeign.getColumnData(apiId);
- int i=0;
- for (Map<String, Object> columnData : columnDataList) {
- //每个表头字段的过滤条件
- if(columnData.get("isFilter") == null || DataChange.dataToBigDecimal(columnData.get("isFilter")).intValue() == 1) {
- columnData.put("filters", setListMap(amsContractTransportPrice1, columnData.get("prop").toString()));
- if (i==0){
- columnData.put("min-width",62);
- }else if (i==1){
- columnData.put("min-width",69);
- }else if (i==3){
- columnData.put("min-width",130);
- }else if (i==4){
- columnData.put("min-width",138);
- }else if (i==5){
- columnData.put("min-width",82);
- }else if (i==6){
- columnData.put("min-width",154);
- }else if (i==7){
- columnData.put("min-width",324);
- }
- i++;
- }
- }
- PageListAdd pageList = new PageListAdd(amsContractTransportPrice1);
- pageList.setColumnData(columnDataList);
- return success(pageList);
- }
- @ApiOperation(value="删除单价信息")
- @PostMapping("/deleteSalelPrice")
- public RESTfulResult deleteSalelPrice(@RequestBody(required=false) Map<String,Object> mapValue){
- int i = amsContractTruckPriceService.deleteSalePrice(mapValue);
- if (i>0){
- return success("删除成功");
- }else{
- return failed("删除失败");
- }
- }
- @ApiModelProperty(value = "更新卸货地址")
- @PostMapping("/updateaddressDeliveryAddress")
- public RESTfulResult updateaddressDeliveryAddress(@RequestBody(required = false) Map<String,Object> mapValue) {
- int i = amsContractTruckPriceService.updateaddressDeliveryAddress(mapValue);
- if (i>0){
- return success("更新卸货地址成功");
- }else {
- return failed("更新卸货地址失败");
- }
- }
- @ApiModelProperty(value = "更新单价")
- @PostMapping("/updatePriceValue")
- public RESTfulResult updatePriceValue(@RequestBody(required = false) Map<String,Object> mapValue) {
- int i = amsContractTruckPriceService.updatePriceValue(mapValue);
- if (i>0){
- return success("更新单价成功");
- }else {
- return failed("更新单价失败");
- }
- }
- @ApiModelProperty(value = "查询承运商")
- @PostMapping("/getCarrierListByAddress")
- public RESTfulResult getCarrierListByAddress(@RequestBody(required = false) Map<String,Object> mapValue){
- List<Map<String, Object>> carrierListByAddress = amsContractTruckPriceService.getCarrierListByAddress(mapValue);
- return success(carrierListByAddress);
- }
- @ApiModelProperty(value = "修改承运商")
- @PostMapping("/updateCarrierName")
- public RESTfulResult updateCarrierName(@RequestBody(required = false) Map<String,Object> mapValue) throws ParseException {
- int i = amsContractTruckPriceService.updateCarrierName(mapValue);
- if (i>0){
- return success("修改承运商成功");
- }else {
- return failed("修改承运商失败");
- }
- }
- @ApiModelProperty(value = "模糊查询承运商")
- @PostMapping("/getCarrierListByPrice")
- public RESTfulResult getCarrierListByPrice(@RequestBody(required = false) Map<String,Object> mapValue) {
- String index = (String) mapValue.get("index");
- if(index != null){
- if(index.length() == 0){
- index = null;
- }else {
- index = "%" + index + "%";
- }
- }
- mapValue.put("index",index);
- /*Integer pageNum = (Integer) mapValue.get("pageNum");
- Integer pageSize = (Integer) mapValue.get("pageSize");
- if (pageNum==null){
- mapValue.put("pageNum",1);
- }
- if (pageSize==null){
- mapValue.put("pageSize",10);
- }*/
- List<Map<String, Object>> carrierListByPrice = amsContractTruckPriceService.getCarrierListByPrice(mapValue);
- return success(carrierListByPrice);
- }
- @ApiOperation(value="查询汽运单价信息")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "apiId(519)", value = "表头", required = false, dataType = "Interger")
- })
- @PostMapping("/getAmsContractTransportPriceForDetail")
- public RESTfulResult getAmsContractTransportPriceForDetail(@RequestBody(required=false) Map<String,Object> mapValue,
- Integer apiId,
- Integer pageNum,
- Integer pageSize,
- String con,String userId) throws ParseException {
- if (con != null && !con.equals("undefined")) {
- mapValue.put("con","%" + con + "%");
- }
- if (userId != null && !userId.equals("undefined")) {
- //查询承运商ID
- String carrierName1 = amsContractTruckPriceService.getCarrierNameForDetail(userId);
- mapValue.put("carrierName1","%" + carrierName1 + "%");
- }
- //1.先查询出收货地址的所有收货ID
- List<Map<String, Object>> receiveAddress = amsContractTruckPriceService.getReceiveAddressId(mapValue);
- //2.查询出该收货所有的单价信息
- List<Map<String, Object>> saleOrderList = amsContractTruckPriceService.getAmsContractTransportPriceForDetail(mapValue);
- //3.遍历查询出最近的单价信息
- List<Map<String,Object>> salePriceList=new LinkedList<>();
- //格式化
- SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
- //获取数据的订单时间
- Date orderTime = simpleDateFormat.parse((String) mapValue.get("orderTime"));
- //最近的留下
- for (Map<String, Object> address : receiveAddress) {
- String address1 = (String) address.get("address");
- //BigDecimal placeId = bigDecimal;
- Map<String,Object> map1=new HashMap<>();
- int flag=0;
- for (Map<String, Object> stringObjectMap : saleOrderList) {
- String address2 = (String) stringObjectMap.get("address");
- //单价的执行日期
- Date priceDate = (Date) stringObjectMap.get("priceDate");
- String format = simpleDateFormat.format(priceDate);
- Date parse = simpleDateFormat.parse(format);
- //Date parse1 = simpleDateFormat.parse("2022-12-10")
- if (parse.before(orderTime)||parse.equals(orderTime)){
- if (address2.equals(address1)){
- flag=1;
- if (map1.size()==0){
- map1.putAll(stringObjectMap);
- }else{
- //比较日期(如果日期在存入的日期之后,则存入该日期)
- Date priceDate1 = (Date) map1.get("priceDate");
- String format1 = simpleDateFormat.format(priceDate1);
- Date parse1 = simpleDateFormat.parse(format1);
- if (parse.after(parse1)){
- map1.clear();
- map1.putAll(stringObjectMap);
- }
- }
- }
- }
- }
- if (flag==1){
- salePriceList.add(map1);
- }
- }
- return success(salePriceList);
- }
- @ApiOperation(value="查询内转汽运单价信息")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "apiId(109)", value = "表头", required = false, dataType = "Interger")
- })
- @PostMapping("/getInwardContractPrice")
- public RESTfulResult getInwardContractPrice(@RequestBody(required=false) Map<String,Object> mapValue,
- Integer apiId,
- Integer pageNum,
- Integer pageSize,
- Integer deleted,
- String con){
- if(deleted != null) {
- mapValue.put("deleted", deleted);
- }
- if (con != null && !con.equals("undefined")) {
- mapValue.put("con","%" + con + "%");
- }
- PageHelper.startPage(pageNum,pageSize);
- if ("materialNames".equals(mapValue.get("orderField"))){
- mapValue.put("orderField",null);
- }
- List<Map<String, Object>> amsContractTransportPrice1 = amsContractTruckPriceService.getInwardContractPrice(mapValue);
- if (mapValue.get("materialNames")!=null && !"".equals(mapValue.get("materialNames"))) {
- String materialNames = mapValue.get("materialNames").toString();
- List<Map<String, Object>> amsContractTransportPrice2=new ArrayList<>();
- amsContractTransportPrice1.forEach(map->{
- if (map.get("materialNames")!=null && !"".equals(map.get("materialNames"))) {
- if (materialNames.equals("["+map.get("materialNames")+"]")) {
- amsContractTransportPrice2.add(map);
- }
- }
- });
- amsContractTransportPrice1=amsContractTransportPrice2;
- }
- PageListAdd pageList = columnDataUtil.tableColumnData(apiId, null,amsContractTransportPrice1);
- return success(pageList);
- }
- /**
- * 新增汽运单价
- * @param mapValue
- * @return
- */
- @ApiOperation(value="新增汽运单价")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "amsContractTransportPrice", value = "销售订单对象", required = false, dataType = "AmsContractTransportPrice")
- })
- @PostMapping(value = "/addAmsContractTransportPrice1")
- public RESTfulResult addAmsContractTransportPrice(@RequestBody(required = false) Map<String,Object> mapValue){
- int i = amsContractTruckPriceService.addAmsContractTransportPrice(mapValue);
- return success(i);
- }
- /**
- * 新增内转汽运单价
- * @param mapValue
- * @return
- */
- @ApiOperation(value="新增内转汽运单价")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "amsContractTransportPrice", value = "销售订单对象", required = false, dataType = "AmsContractTransportPrice")
- })
- @PostMapping(value = "/insertInwardPrice")
- public RESTfulResult insertInwardPrice(@RequestBody(required = false) Map<String,Object> mapValue){
- int i = amsContractTruckPriceService.insertInwardPrice(mapValue);
- return success(i);
- }
- /**
- * 通过主键删除汽运单价
- * @param priceId
- * @return
- */
- @ApiOperation(value="通过主键删除汽运单价")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "priceId", value = "主键Id", required = false, dataType = "java.math.BigDecimal")
- })
- @PostMapping(value = "/deleteAmsContractTransportPrice1")
- public RESTfulResult deleteAmsContractTransportPrice(BigDecimal priceId){
- int i = amsContractTruckPriceService.deleteAmsContractTransportPrice(priceId);
- return success(i);
- }
- /**
- * 通过主键渲染汽运单价信息
- * @param priceId
- * @return
- */
- @ApiOperation(value="通过主键渲染汽运单价信息")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "priceId", value = "主键Id", required = false, dataType = "java.math.BigDecimal")
- })
- @PostMapping(value = "/getAmsContractTransportPriceByPriceId1")
- public RESTfulResult getAmsContractTransportPriceByPriceId(@RequestParam BigDecimal priceId){
- List<Map<String, Object>> maps = amsContractTruckPriceService.selectByPriceId(priceId);
- return success(maps);
- }
- /**
- * 通过主键修改汽运单价
- * @param amsContractTransportPrice
- * @return
- */
- @ApiOperation(value="通过主键修改汽运单价")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "amsContractTransportPrice", value = "销售订单对象", required = false, dataType = "AmsContractTransportPrice")
- })
- @PostMapping(value = "/updateAmsContractTransportPrice1")
- public RESTfulResult updateAmsContractTransportPrice(@RequestParam AmsContractTransportPrice amsContractTransportPrice){
- int i = amsContractTruckPriceService.updateAmsContractTransportPrice(amsContractTransportPrice);
- return success(i);
- }
- /**
- * 油价联动导致运价变动,批量修改运价
- * @param
- * @return
- */
- @ApiOperation(value="油价联动导致运价变动,批量修改运价")
- @ApiImplicitParams({
- })
- @PostMapping(value = "/batchUpdateTransportPriceByOilPrice1")
- public RESTfulResult batchUpdateTransportPriceByOilPrice(@RequestBody Map<String,Object> map) throws ParseException {
- int i = amsContractTruckPriceService.batchUpdateTransportPriceByOilPrice(map);
- return success(i);
- }
- /**
- * 获取承运商名称
- * @param
- * @return
- */
- @ApiOperation(value="获取承运商名称")
- @ApiImplicitParams({
- })
- @GetMapping(value = "/getCarrierName")
- public RESTfulResult getCarrierName(){
- return success(amsContractTruckPriceService.getCarrierName());
- }
- /**
- * 获取线路编号
- * @param
- * @return
- */
- @ApiOperation(value="获取线路编号")
- @ApiImplicitParams({
- })
- @GetMapping(value = "/getLineNo")
- public RESTfulResult getLineNo(){
- return success(amsContractTruckPriceService.getLineNo());
- }
- /**
- * 获取运力编号
- * @param
- * @return
- */
- @ApiOperation(value="获取运力编号")
- @ApiImplicitParams({
- })
- @GetMapping(value = "/getCapacityNumber")
- public RESTfulResult getCapacityNumber(){
- return success(amsContractTruckPriceService.getCapacityNumber());
- }
- /**
- * 获取收货地址
- * @param
- * @return
- */
- @ApiOperation(value="获取收货地址")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "apiId" ,value = "255")
- })
- @PostMapping (value = "/getAddressDeliveryAddress")
- public RESTfulResult getAddressDeliveryAddress(@RequestBody(required=false) Map<String,Object> mapValue,
- Integer apiId,
- Integer pageNum,
- Integer pageSize,
- String con){
- if (con != null && !con.equals("undefined")) {
- mapValue.put("con","%" + con + "%");
- }
- //不分页筛选数据
- PageHelper.startPage(pageNum,pageSize);
- //分页数据
- List<Map<String, Object>> saleOrderList = amsContractTruckPriceService.getAddressDeliveryAddress(mapValue);
- List<Map<String, Object>> columnDataList = columnDataFeign.getColumnData(apiId);
- int i=0;
- for (Map<String, Object> columnData : columnDataList) {
- //每个表头字段的过滤条件
- columnData.put("filters", setListMap(saleOrderList, columnData.get("prop").toString()));
- if (i==0){
- columnData.put("min-width","78px");
- }else if (i==2){
- columnData.put("min-width","94px");
- }
- i++;
- }
- PageListAdd pageList = new PageListAdd(saleOrderList);
- pageList.setColumnData(columnDataList);
- //PageListAdd pageList = columnDataUtil.tableColumnData(apiId, null,saleOrderList);
- return success(pageList);
- }
- private Set<Map<String, Object>> setListMap(List<Map<String, Object>> list, String name) {
- Set<Map<String, Object>> setString = new HashSet<>();
- for (Map<String, Object> map : list) {//遍历每条数据
- Map<String, Object> map1 = new HashMap<>();
- //map.get(name)获取每条数据中对应表头字段的数据
- map1.put("text", map.get(name));
- if (map.get(name) != null) {
- map1.put("value", map.get(name));
- setString.add(map1);
- }
- }
- return setString;
- }
- /**
- * 获取货物类型
- * @param
- * @return
- */
- @ApiOperation(value="获取货物类型")
- @ApiImplicitParams({
- })
- @GetMapping(value = "/getCargoName")
- public RESTfulResult getCargoName(){
- return success(amsContractTruckPriceService.getCargoName());
- }
- /**
- * 获取油品名称
- * @param
- * @return
- */
- @ApiOperation(value="获取油品名称")
- @ApiImplicitParams({
- })
- @GetMapping(value = "/getOilTypeName")
- public RESTfulResult getOilTypeName(){
- return success(amsContractTruckPriceService.getOilTypeName());
- }
- @ApiModelProperty(value = "边输边查具体地址")
- @PostMapping("/getRealAddressByLike")
- public RESTfulResult getRealAddressByLike(@RequestParam Integer addressId,@RequestParam String index){
- if (index != null ) {
- if (index.length() == 0 || index.equals("undefined")) {
- index = null;
- }
- else {
- index = "%" + index + "%";
- }
- }
- Map<String,Object> map = new HashMap<>();
- map.put("addressId",addressId);
- map.put("index",index);
- List<Map<String,Object>> mapList = amsContractTruckPriceService.getRealAddressByLike(map);
- return success(mapList);
- }
- @ApiOperation("通过物资,车型,承运起止范围匹配运输单价")
- @PostMapping("/getInwardPriceBy")
- public Map<String,Object> getInwardPriceBy(@RequestBody(required = false) Map<String,Object> mapvalue){
- //接受结算是内转计重还是计时还是计数
- String settleMentType = (String) mapvalue.get("requirementType");
- String insertUpdateRemark = (String) mapvalue.get("insertUpdateRemark");
- BigDecimal type = null;
- if("计重".equals(settleMentType)){
- if(insertUpdateRemark!=null && !"".equals(insertUpdateRemark) && insertUpdateRemark.contains("计时且过计量")){
- //计重且计时,走计时流程
- type = new BigDecimal(5);
- }else{
- //在单价表里内转计重是2
- type = new BigDecimal(2);
- }
- }else if("计时".equals(settleMentType)){
- //在单价表里内转计时是5
- type = new BigDecimal(5);
- }else if("计次".equals(settleMentType)){
- //在单价表里内转计时是6
- type = new BigDecimal(6);
- }
- List<Map<String,Object>> mapList=new LinkedList<>();
- try{
- mapvalue.put("type",type);
- mapList=mapList = amsContractTruckPriceService.selectInwardPrice(mapvalue);
- }catch (Exception e){
- System.out.println("e"+e.getMessage());
- }
- if(mapList.size()!=0){
- return mapList.get(0);
- }
- else{
- return null;
- }
- }
- @ApiOperation(value = "承运起止范围与装货点")
- @PostMapping("/getRangePoint")
- public RESTfulResult getRangePoint(@RequestBody(required = false)Map<String,Object>mapValue,
- Integer apiId,
- Integer pageNum,
- Integer pageSize,
- String con){
- if (con != null && !con.equals("undefined")) {
- mapValue.put("con","%" + con + "%");
- }
- //不分页筛选数据
- PageHelper.startPage(pageNum,pageSize);
- //分页数据
- List<Map<String, Object>> rangePointList = amsContractTruckPriceService.getRangePoint(mapValue);
- PageListAdd pageList = columnDataUtil.tableColumnData(apiId, null,rangePointList);
- return success(pageList);
- }
- @ApiOperation(value = "插入承运起止范围与装货点")
- @PostMapping("/insertLineNodePoint")
- public RESTfulResult insertLineNodePoint(@RequestBody(required = false)Map<String,Object>map){
- return success(amsContractTruckPriceService.insertLineNodePoint(map));
- }
- @ApiOperation("根据汽运ID修改单价")
- @PostMapping("updatePriceById")
- public RESTfulResult updatePriceById(@RequestBody(required = false) Map<String,Object> map) {
- //
- int i = amsContractTruckPriceService.updatePriceById(map);
- return success(i);
- }
- @ApiOperation(value = "查询出收货地址ID")
- @PostMapping("/queryPlaceId")
- public BigDecimal queryPlaceId(@RequestBody(required = false) BigDecimal bigDecimal){
- List<Map<String, Object>> maps = amsContractTruckPriceMapper.selectByPriceId(bigDecimal);
- BigDecimal b=BigDecimal.ZERO;
- for (Map<String, Object> map : maps) {
- b = (BigDecimal) map.get("PLACE_ID");
- }
- return b;
- }
- @ApiOperation(value="修改内转汽运单价")
- @PostMapping("/updateTransPrice")
- public RESTfulResult updateTransPrice(@RequestBody(required=false) Map<String,Object> map){
- int i = amsContractTruckPriceService.updatePriceByPriceId(map);
- return success(i);
- }
- @ApiOperation(value="查询物资")
- @PostMapping("/getwz")
- public RESTfulResult getwz(@RequestBody(required=false) Map<String,Object> map){
- List<Map<String, Object>> i = amsContractTruckPriceService.getwz(map);
- return success(i);
- }
- @ApiOperation(value="查询联动公式数据")
- @PostMapping("/getcargonameId")
- public RESTfulResult getcargonameId(@RequestBody(required=false) Map<String,Object> map){
- Map<String, Object> i = amsContractTruckPriceService.getcargonameId(map);
- return success(i);
- }
- }
|