Commit 1fb9243518b8e3bf8d3dfc1083bc2cf06905c7ca
Merge branch 'develop' of http://172.16.29.40:8010/wms/wms2 into develop
Showing
5 changed files
with
45 additions
and
16 deletions
src/main/java/com/huaheng/pc/config/materialMultiple/controller/MaterialMultipleController.java
... | ... | @@ -15,7 +15,7 @@ import com.huaheng.framework.web.page.PageDomain; |
15 | 15 | import com.huaheng.framework.web.page.TableDataInfo; |
16 | 16 | import com.huaheng.framework.web.page.TableSupport; |
17 | 17 | import com.huaheng.pc.config.materialMultiple.domain.MaterialMultiple; |
18 | -import com.huaheng.pc.config.materialMultiple.service.MaterialMultipleService; | |
18 | +import com.huaheng.pc.config.materialMultiple.service.MaterialMultipleServiceImpl; | |
19 | 19 | import io.swagger.annotations.ApiOperation; |
20 | 20 | import io.swagger.annotations.ApiParam; |
21 | 21 | import org.apache.shiro.authz.annotation.RequiresPermissions; |
... | ... | @@ -32,7 +32,7 @@ import java.util.List; |
32 | 32 | public class MaterialMultipleController extends BaseController { |
33 | 33 | |
34 | 34 | @Resource |
35 | - private MaterialMultipleService materialMultipleService; | |
35 | + private MaterialMultipleServiceImpl materialMultipleService; | |
36 | 36 | |
37 | 37 | private String prefix = "config/materialMultiple"; |
38 | 38 | |
... | ... |
src/main/java/com/huaheng/pc/config/materialMultiple/domain/MaterialMultiple.java
src/main/java/com/huaheng/pc/config/materialMultiple/service/MaterialMultipleService.java deleted
src/main/java/com/huaheng/pc/config/materialMultiple/service/MaterialMultipleServiceImpl.java
1 | 1 | package com.huaheng.pc.config.materialMultiple.service; |
2 | 2 | |
3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
4 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
5 | +import com.baomidou.mybatisplus.extension.service.IService; | |
6 | +import com.huaheng.common.utils.security.ShiroUtils; | |
7 | +import com.huaheng.framework.shiro.realm.UserRealm; | |
8 | +import com.huaheng.pc.general.warehouse.domain.Warehouse; | |
9 | +import org.slf4j.Logger; | |
10 | +import org.slf4j.LoggerFactory; | |
3 | 11 | import org.springframework.stereotype.Service; |
4 | -import javax.annotation.Resource; | |
5 | -import java.util.List; | |
6 | 12 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
7 | 13 | import com.huaheng.pc.config.materialMultiple.mapper.MaterialMultipleMapper; |
8 | 14 | import com.huaheng.pc.config.materialMultiple.domain.MaterialMultiple; |
9 | -import com.huaheng.pc.config.materialMultiple.service.MaterialMultipleService; | |
15 | + | |
16 | +import java.math.BigDecimal; | |
17 | + | |
10 | 18 | @Service |
11 | -public class MaterialMultipleServiceImpl extends ServiceImpl<MaterialMultipleMapper, MaterialMultiple> implements MaterialMultipleService{ | |
19 | +public class MaterialMultipleServiceImpl extends ServiceImpl<MaterialMultipleMapper, MaterialMultiple> implements IService<MaterialMultiple> { | |
20 | + | |
21 | + private static final Logger log = LoggerFactory.getLogger(MaterialMultipleServiceImpl.class); | |
22 | + | |
23 | + /** | |
24 | + * 单位转换 | |
25 | + * @param materialCode 物料编码 | |
26 | + * @param unit1 单位1 | |
27 | + * @param unit2 单位2 | |
28 | + * @param value 转换值 | |
29 | + * @return 转换后的值,异常返回"" | |
30 | + */ | |
31 | + public String multiple(String materialCode, String unit1, String unit2, String value){ | |
32 | + LambdaQueryWrapper<MaterialMultiple> lambda = Wrappers.lambdaQuery(); | |
33 | + lambda.select(MaterialMultiple::getMultiple) | |
34 | + .eq(MaterialMultiple::getMaterialCode, materialCode) | |
35 | + .eq(MaterialMultiple::getUnitId1, unit1) | |
36 | + .eq(MaterialMultiple::getUnitId2, unit2) | |
37 | + .eq(MaterialMultiple::getEnable, 1) | |
38 | + .eq(MaterialMultiple::getWarehouseCode, ShiroUtils.getWarehouseCode()); | |
39 | + try { | |
40 | + Double multiple = this.getOne(lambda).getMultiple(); | |
41 | + return String.valueOf(Double.parseDouble(value)*multiple); | |
42 | + } catch (NullPointerException e){ | |
43 | + log.info("查询不到物料编码:"+materialCode+",单位:"+unit1+", "+unit2+"的转换系数"); | |
44 | + } catch (Exception e){ | |
45 | + log.info("查询不到物料编码:"+materialCode+",单位:"+unit1+", "+unit2+"的转换系数出错"); | |
46 | + } | |
12 | 47 | |
48 | + return ""; | |
49 | + } | |
13 | 50 | } |
... | ... |
src/main/resources/mybatis/config/MaterialMultipleMapper.xml
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | <result column="warehouseCode" jdbcType="VARCHAR" property="warehouseCode" /> |
12 | 12 | <result column="unitId1" jdbcType="VARCHAR" property="unitId1" /> |
13 | 13 | <result column="unitId2" jdbcType="VARCHAR" property="unitId2" /> |
14 | - <result column="multiple" jdbcType="INTEGER" property="multiple" /> | |
14 | + <result column="multiple" jdbcType="DOUBLE" property="multiple" /> | |
15 | 15 | <result column="enable" jdbcType="INTEGER" property="enable" /> |
16 | 16 | <result column="created" jdbcType="TIMESTAMP" property="created" /> |
17 | 17 | <result column="createdBy" jdbcType="VARCHAR" property="createdBy" /> |
... | ... |