|
|
@@ -8,6 +8,9 @@ import com.steerinfo.meterwork.except.MarkerMetException;
|
|
|
import com.steerinfo.meterwork.meterworkcarrecover.model.MeterWorkCarRecover;
|
|
|
import com.steerinfo.meterwork.meterworkprewgttype.model.MeterWorkPreWgttype;
|
|
|
import com.steerinfo.meterwork.meterworkprewgttype.service.IMeterWorkPreWgttypeService;
|
|
|
+import com.steerinfo.pretrack.pretrackscale.model.PreTrackScale;
|
|
|
+import com.steerinfo.pretrack.pretrackscale.service.IPreTrackScaleService;
|
|
|
+import com.steerinfo.pretrack.pretrackscale.service.impl.PreTrackScaleServiceImpl;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
@@ -15,6 +18,8 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
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 java.util.Arrays;
|
|
|
@@ -44,6 +49,9 @@ public class MeterWorkPreWgttypeController extends BaseRESTfulController {
|
|
|
@Autowired
|
|
|
IMeterWorkPreWgttypeService meterWorkPreWgttypeService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ IPreTrackScaleService preTrackScaleService;
|
|
|
+
|
|
|
@ApiOperation(value="获取列表", notes="分页查询")
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
|
|
|
@@ -71,19 +79,39 @@ public class MeterWorkPreWgttypeController extends BaseRESTfulController {
|
|
|
@ApiOperation(value="创建", notes="根据MeterWorkPreWgttype对象创建")
|
|
|
@ApiImplicitParam(name = "meterWorkPreWgttype", value = "详细实体meterWorkPreWgttype", required = true, dataType = "MeterWorkPreWgttype")
|
|
|
//@RequiresPermissions("meterworkprewgttype:create")
|
|
|
+ @Transactional
|
|
|
@PostMapping(value = "/")
|
|
|
- public RESTfulResult add(@ModelAttribute MeterWorkPreWgttype model){
|
|
|
+ public RESTfulResult add(@RequestBody MeterWorkPreWgttype model,String preTrackScaleNo){
|
|
|
try {
|
|
|
HashMap map = meterWorkPreWgttypeService.addOrAbolish(model);
|
|
|
-
|
|
|
- if (map.get("code").equals("0")){
|
|
|
- return success();
|
|
|
- }
|
|
|
- else {
|
|
|
- return failed(map.get("msg"));
|
|
|
+ if (preTrackScaleNo == "" || preTrackScaleNo.equals("")){
|
|
|
+ if (map.get("code").equals("0")){
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return failed(map.get("msg"));
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ PreTrackScale preTrackScale = new PreTrackScale();
|
|
|
+ preTrackScale.setPredictionNo(preTrackScaleNo);
|
|
|
+ preTrackScale.setCarNo(model.getCarNo());
|
|
|
+ int scale = preTrackScaleService.setPreIndex(preTrackScale);
|
|
|
+ if (map.get("code").equals("0") && scale > 0){
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+ else if(scale == -1){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return failed("已经存在已使用的委托,不可修改");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return failed(map.get("msg"));
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
} catch (Exception ex) {
|
|
|
ex.printStackTrace();
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
throw new MarkerMetException(500, "操作异常!!");
|
|
|
}
|
|
|
}
|