8 changed files with 633 additions and 0 deletions
@ -0,0 +1,29 @@ |
|||||
|
package com.yxt.supervise.cyf.app.approvalrecord; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.core.toolkit.Constants; |
||||
|
import com.yxt.supervise.cyf.api.approvalrecord.ApprovalRecord; |
||||
|
import com.yxt.supervise.cyf.api.approvalrecord.ApprovalRecordVo; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
import org.apache.ibatis.annotations.Select; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/5/4 14:37 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface ApprovalRecordAppMapper extends BaseMapper<ApprovalRecord> { |
||||
|
IPage<ApprovalRecordVo> selectPageVo(IPage<ApprovalRecord> page, @Param(Constants.WRAPPER) Wrapper<ApprovalRecord> qw); |
||||
|
|
||||
|
@Select("select *,t.number as tankNumber from crude_oil_inventory_record left join tank_information t on t.sid =c.tankSid where sid=#{sid}") |
||||
|
ApprovalRecord getCrudeBySid(@Param("sid")String sid); |
||||
|
void insertCrudeOilFiles(List<Map<String, String>> maps); |
||||
|
|
||||
|
List<ApprovalRecord> selectRecordBySid(@Param("sid") String sid); |
||||
|
} |
@ -0,0 +1,30 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="com.yxt.supervise.cyf.app.approvalrecord.ApprovalRecordAppMapper"> |
||||
|
<!-- <where> ${ew.sqlSegment} </where>--> |
||||
|
<!-- ${ew.customSqlSegment} --> |
||||
|
<select id="selectPageVo" resultType="com.yxt.supervise.cyf.api.approvalrecord.ApprovalRecordVo"> |
||||
|
SELECT |
||||
|
* |
||||
|
FROM |
||||
|
approval_record |
||||
|
<where> |
||||
|
${ew.sqlSegment} |
||||
|
</where> |
||||
|
</select> |
||||
|
|
||||
|
|
||||
|
<select id="selectRecordBySid" resultType="com.yxt.supervise.cyf.api.approvalrecord.ApprovalRecord"> |
||||
|
select a.*,s.userName as approverName, |
||||
|
case a.operate |
||||
|
when 1 then '订单创建' |
||||
|
when 2 then '订单发起' |
||||
|
when 3 then '订单通过' |
||||
|
when 4 then '订单不通过' |
||||
|
when 5 then '订单已完成' |
||||
|
end as operateValue |
||||
|
from approval_record a |
||||
|
left join sys_user s on s.sid=a.approver |
||||
|
where proSid = #{sid} |
||||
|
</select> |
||||
|
</mapper> |
@ -0,0 +1,42 @@ |
|||||
|
package com.yxt.supervise.cyf.app.approvalrecord; |
||||
|
|
||||
|
import com.yxt.common.core.query.PagerQuery; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.common.core.vo.PagerVo; |
||||
|
import com.yxt.supervise.cyf.api.approvalrecord.ApprovalRecordDto; |
||||
|
import com.yxt.supervise.cyf.api.approvalrecord.ApprovalRecordQuery; |
||||
|
import com.yxt.supervise.cyf.api.approvalrecord.ApprovalRecordVo; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/5/4 14:38 |
||||
|
*/ |
||||
|
@Api(tags = "审批记录信息") |
||||
|
@RestController |
||||
|
@RequestMapping("cyf/app/approval") |
||||
|
public class ApprovalRecordAppRest { |
||||
|
@Autowired |
||||
|
ApprovalRecordAppService ApprovalRecordService; |
||||
|
@ApiOperation("根据条件分页查询数据的列表") |
||||
|
@PostMapping("/listPage") |
||||
|
public ResultBean<PagerVo<ApprovalRecordVo>> listPage(@RequestBody PagerQuery<ApprovalRecordQuery> pq) { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
PagerVo<ApprovalRecordVo> pv = ApprovalRecordService.listPageVo(pq); |
||||
|
return rb.success().setData(pv); |
||||
|
} |
||||
|
@ApiOperation("新增") |
||||
|
@PostMapping("/save") |
||||
|
public ResultBean save (@RequestBody ApprovalRecordDto dto){ |
||||
|
return ApprovalRecordService.save(dto); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation("查询订单审批详细信息") |
||||
|
@GetMapping("/getRecordBySid/{sid}") |
||||
|
public ResultBean selectRecordBySid(@PathVariable String sid){ |
||||
|
return ApprovalRecordService.selectRecordBySid(sid); |
||||
|
} |
||||
|
} |
@ -0,0 +1,82 @@ |
|||||
|
package com.yxt.supervise.cyf.app.approvalrecord; |
||||
|
|
||||
|
import cn.hutool.core.bean.BeanUtil; |
||||
|
import cn.hutool.core.date.DateUtil; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.yxt.common.base.service.MybatisBaseService; |
||||
|
import com.yxt.common.base.utils.PagerUtil; |
||||
|
import com.yxt.common.core.query.PagerQuery; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.common.core.vo.PagerVo; |
||||
|
import com.yxt.supervise.cyf.api.approvalrecord.ApprovalRecord; |
||||
|
import com.yxt.supervise.cyf.api.approvalrecord.ApprovalRecordDto; |
||||
|
import com.yxt.supervise.cyf.api.approvalrecord.ApprovalRecordQuery; |
||||
|
import com.yxt.supervise.cyf.api.approvalrecord.ApprovalRecordVo; |
||||
|
import com.yxt.supervise.cyf.biz.tankinformation.TankInformationMapper; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/5/4 14:37 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class ApprovalRecordAppService extends MybatisBaseService<ApprovalRecordAppMapper, ApprovalRecord> { |
||||
|
@Autowired |
||||
|
TankInformationMapper tankInformationMapper; |
||||
|
|
||||
|
public PagerVo<ApprovalRecordVo> listPageVo(PagerQuery<ApprovalRecordQuery> pq) { |
||||
|
ApprovalRecordQuery query = pq.getParams(); |
||||
|
QueryWrapper<ApprovalRecord> qw = new QueryWrapper<>(); |
||||
|
// if (StringUtils.isNotBlank(query.getDate())) {
|
||||
|
// qw.eq("STR_TO_DATE(c.recordDate,'%Y-%m-%d')", query.getDate());
|
||||
|
// }
|
||||
|
// if (StringUtils.isNotBlank(query.getNumber())) {
|
||||
|
// qw.like("t.number", query.getNumber());
|
||||
|
// }
|
||||
|
IPage<ApprovalRecord> page = PagerUtil.queryToPage(pq); |
||||
|
IPage<ApprovalRecordVo> pagging = baseMapper.selectPageVo(page, qw); |
||||
|
PagerVo<ApprovalRecordVo> p = PagerUtil.pageToVo(pagging, null); |
||||
|
return p; |
||||
|
} |
||||
|
@Transactional |
||||
|
public ResultBean save(ApprovalRecordDto dto){ |
||||
|
ResultBean rb=new ResultBean(); |
||||
|
ApprovalRecord entity=new ApprovalRecord(); |
||||
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
||||
|
Date curDate = new Date(); |
||||
|
String dfmt = DateUtil.format(curDate, "yyyy-MM-dd"); |
||||
|
baseMapper.insert(entity); |
||||
|
//油罐每日填写信息修改
|
||||
|
return rb.success().setMsg("新增成功"); |
||||
|
} |
||||
|
public ResultBean update (ApprovalRecordDto dto){ |
||||
|
ResultBean rb=new ResultBean(); |
||||
|
String dtoSid = dto.getSid(); |
||||
|
ApprovalRecord entity=fetchBySid(dtoSid); |
||||
|
BeanUtil.copyProperties(dto, entity, "id", "sid"); |
||||
|
baseMapper.updateById(entity); |
||||
|
return rb.success().setMsg("修改成功"); |
||||
|
} |
||||
|
public ResultBean getCrudeBySid(String sid){ |
||||
|
ResultBean rb=new ResultBean(); |
||||
|
ApprovalRecord ApprovalRecord=baseMapper.getCrudeBySid(sid); |
||||
|
return rb.success().setData(ApprovalRecord); |
||||
|
} |
||||
|
public ResultBean del(String sid){ |
||||
|
ResultBean rb=new ResultBean(); |
||||
|
baseMapper.delete(new QueryWrapper<ApprovalRecord>().eq("sid",sid)); |
||||
|
return rb.success().setMsg("删除成功"); |
||||
|
} |
||||
|
|
||||
|
public ResultBean selectRecordBySid(String sid){ |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
List<ApprovalRecord> ApprovalRecord = baseMapper.selectRecordBySid(sid); |
||||
|
return rb.success().setData(ApprovalRecord); |
||||
|
} |
||||
|
} |
@ -0,0 +1,69 @@ |
|||||
|
package com.yxt.supervise.cyf.app.procurementdetails; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.core.toolkit.Constants; |
||||
|
import com.yxt.supervise.cyf.api.crudeoiltypeinformation.CrudeOilTypeInformationVo; |
||||
|
import com.yxt.supervise.cyf.api.procurementdetails.ProcurementDetails; |
||||
|
import com.yxt.supervise.cyf.api.procurementdetails.ProcurementDetailsVo; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
import org.apache.ibatis.annotations.Select; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/5/4 14:37 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface ProcurementDetailsAppMapper extends BaseMapper<ProcurementDetails> { |
||||
|
IPage<ProcurementDetailsVo> selectPageVo(IPage<ProcurementDetails> page, @Param(Constants.WRAPPER) Wrapper<ProcurementDetails> qw,@Param("type") String type); |
||||
|
@Select("select * from procurement_details where state =#{state}") |
||||
|
List<ProcurementDetailsVo> listByState(String state); |
||||
|
@Select(" SELECT" + |
||||
|
" *,t.name as typeName,i.inventory as inventory" + |
||||
|
" FROM" + |
||||
|
" material_outbound o" + |
||||
|
" left join material_inventory i on i.sid=o.inventorySid" + |
||||
|
" left join material_type t on t.sid=i.typeSid") |
||||
|
List<ProcurementDetailsVo> outboundList(); |
||||
|
@Select("select * from procurement_details where sid=#{sid}") |
||||
|
List<ProcurementDetailsVo> getProcurementBySid(@Param("sid")String sid); |
||||
|
@Select("SELECT\n" + |
||||
|
"\td.*,\n" + |
||||
|
"\ts.supplierNumber AS supplierNumber,\n" + |
||||
|
"\ts.supplierName AS supplierName,\n" + |
||||
|
"CASE\n" + |
||||
|
"\t\td.state \n" + |
||||
|
"\t\tWHEN 1 THEN\n" + |
||||
|
"\t\t'待提交' \n" + |
||||
|
"\t\tWHEN 2 THEN\n" + |
||||
|
"\t\t'经理审批' \n" + |
||||
|
"\t\tWHEN 3 THEN\n" + |
||||
|
"\t\t'监管审批' \n" + |
||||
|
"\t\tWHEN 4 THEN\n" + |
||||
|
"\t\t'银行审批' \n" + |
||||
|
"\t\tWHEN 5 THEN\n" + |
||||
|
"\t\t'财务审批' \n" + |
||||
|
"\t\tWHEN 6 THEN\n" + |
||||
|
"\t\t'在途' \n" + |
||||
|
"\t\tWHEN 7 THEN\n" + |
||||
|
"\t\t'已入库' \n" + |
||||
|
"\tEND AS stateValue ,count(1) as amount,\n" + |
||||
|
"\tsum(d.price * d.weight) as totalValue\n" + |
||||
|
"FROM\n" + |
||||
|
"\tprocurement_details d\n" + |
||||
|
"\tLEFT JOIN supplier_information s ON d.supplierSid = s.sid\n" + |
||||
|
"\tLEFT JOIN crude_oil_type_information c ON c.sid = d.typeSid \n" + |
||||
|
"WHERE\n" + |
||||
|
"\td.sid=#{sid} \n" + |
||||
|
"GROUP BY\n" + |
||||
|
"\td.sid ") |
||||
|
ProcurementDetailsVo getProBySid(@Param("sid")String sid); |
||||
|
@Select("select * from crude_oil_type_information where sid=#{sid}") |
||||
|
CrudeOilTypeInformationVo getCrudeBySid(@Param("sid")String sid); |
||||
|
@Select("select * from procurement_details where state=#{state} group by sid") |
||||
|
List<ProcurementDetailsVo> getProByState(@Param("state")String state); |
||||
|
} |
@ -0,0 +1,34 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="com.yxt.supervise.cyf.app.procurementdetails.ProcurementDetailsAppMapper"> |
||||
|
<!-- <where> ${ew.sqlSegment} </where>--> |
||||
|
<!-- ${ew.customSqlSegment} --> |
||||
|
<select id="selectPageVo" resultType="com.yxt.supervise.cyf.api.procurementdetails.ProcurementDetailsVo"> |
||||
|
SELECT |
||||
|
<if test="type=='1'.toString()"> |
||||
|
d.*,s.supplierNumber as supplierNumber, s.supplierName as supplierName, |
||||
|
c.name as tradeName,c.number as productCode,c.name as typeName,c.number as typeNumber, |
||||
|
case d.state |
||||
|
when 1 then '待提交' |
||||
|
when 2 then '经理审批' |
||||
|
when 3 then '监管审批' |
||||
|
when 4 then '银行审批' |
||||
|
when 5 then '财务审批' |
||||
|
when 6 then '在途' |
||||
|
when 7 then '已入库' |
||||
|
end as stateValue,count(1) as amount, |
||||
|
sum(d.price * d.weight) as totalValue |
||||
|
</if> |
||||
|
FROM |
||||
|
procurement_details d |
||||
|
<if test="type =='1'.toString()"> |
||||
|
left JOIN supplier_information s on d.supplierSid =s.sid |
||||
|
left join crude_oil_type_information c on c.sid =d.typeSid |
||||
|
</if> |
||||
|
<where> |
||||
|
${ew.sqlSegment} |
||||
|
</where> |
||||
|
group by d.sid |
||||
|
</select> |
||||
|
|
||||
|
</mapper> |
@ -0,0 +1,90 @@ |
|||||
|
package com.yxt.supervise.cyf.app.procurementdetails; |
||||
|
|
||||
|
import com.yxt.common.core.query.PagerQuery; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.common.core.vo.PagerVo; |
||||
|
import com.yxt.supervise.cyf.api.procurementdetails.ProcurementDetailsDto; |
||||
|
import com.yxt.supervise.cyf.api.procurementdetails.ProcurementDetailsQuery; |
||||
|
import com.yxt.supervise.cyf.api.procurementdetails.ProcurementDetailsVo; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/5/4 14:38 |
||||
|
*/ |
||||
|
@Api(tags = "采购信息") |
||||
|
@RestController |
||||
|
@RequestMapping("cyf/app/procurement") |
||||
|
public class ProcurementDetailsAppRest { |
||||
|
@Autowired |
||||
|
ProcurementDetailsAppService RawProcurementDetailsService; |
||||
|
|
||||
|
@ApiOperation("根据条件分页查询数据的列表") |
||||
|
@PostMapping("/listPage") |
||||
|
public ResultBean<PagerVo<ProcurementDetailsVo>> listPage(@RequestBody PagerQuery<ProcurementDetailsQuery> pq) { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
PagerVo<ProcurementDetailsVo> pv = RawProcurementDetailsService.listPageVo(pq); |
||||
|
return rb.success().setData(pv); |
||||
|
} |
||||
|
@ApiOperation("数据的列表") |
||||
|
@PostMapping("/list") |
||||
|
public ResultBean<List<ProcurementDetailsVo>> list() { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
List<ProcurementDetailsVo> pv = RawProcurementDetailsService.lists(); |
||||
|
return rb.success().setData(pv); |
||||
|
} |
||||
|
@ApiOperation("根据订单状态查询数据的列表") |
||||
|
@PostMapping("/listByState") |
||||
|
public ResultBean<PagerVo<ProcurementDetailsVo>> listBystate(String state) { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
List<ProcurementDetailsVo> pv = RawProcurementDetailsService.listByState(state); |
||||
|
return rb.success().setData(pv); |
||||
|
} |
||||
|
@ApiOperation("新增") |
||||
|
@PostMapping("/save") |
||||
|
public ResultBean save (@RequestBody ProcurementDetailsDto dto){ |
||||
|
return RawProcurementDetailsService.save(dto); |
||||
|
} |
||||
|
@ApiOperation("提交") |
||||
|
@PostMapping("/submit") |
||||
|
public ResultBean submit (@RequestBody ProcurementDetailsDto dto){ |
||||
|
return RawProcurementDetailsService.submit(dto); |
||||
|
} |
||||
|
@ApiOperation("修改") |
||||
|
@PostMapping("/update") |
||||
|
public ResultBean update (@RequestBody ProcurementDetailsDto dto){ |
||||
|
return RawProcurementDetailsService.update(dto); |
||||
|
} |
||||
|
@ApiOperation("修改") |
||||
|
@PostMapping("/updateByState") |
||||
|
public ResultBean updateByState (@RequestBody ProcurementDetailsDto dto){ |
||||
|
return RawProcurementDetailsService.updateByState(dto); |
||||
|
} |
||||
|
|
||||
|
@ApiOperation("根据sid查询") |
||||
|
@GetMapping("/getProcurementBySid/{sid}") |
||||
|
public ResultBean getOutboundBySid(@PathVariable String sid){ |
||||
|
return RawProcurementDetailsService.getProcurementBySid(sid); |
||||
|
} |
||||
|
@ApiOperation("删除") |
||||
|
@DeleteMapping("/delete/{sid}") |
||||
|
public ResultBean delete(@PathVariable String sid ){ |
||||
|
return RawProcurementDetailsService.del(sid); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 查询在途订单 |
||||
|
* @param state |
||||
|
* @return |
||||
|
*/ |
||||
|
@ApiOperation("查询在途订单") |
||||
|
@GetMapping("/getProcByState/{sid}") |
||||
|
public ResultBean getProcByState(@PathVariable String state){ |
||||
|
return RawProcurementDetailsService.getProcByState(state); |
||||
|
} |
||||
|
} |
@ -0,0 +1,257 @@ |
|||||
|
package com.yxt.supervise.cyf.app.procurementdetails; |
||||
|
|
||||
|
import cn.dev33.satoken.stp.StpUtil; |
||||
|
import cn.hutool.core.bean.BeanUtil; |
||||
|
import cn.hutool.core.date.DateUtil; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.yxt.common.base.service.MybatisBaseService; |
||||
|
import com.yxt.common.base.utils.PagerUtil; |
||||
|
import com.yxt.common.core.query.PagerQuery; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.common.core.vo.PagerVo; |
||||
|
import com.yxt.supervise.cyf.api.approvalrecord.ApprovalRecordDto; |
||||
|
import com.yxt.supervise.cyf.api.crudeoiltypeinformation.CrudeOilTypeInformationDto; |
||||
|
import com.yxt.supervise.cyf.api.crudeoiltypeinformation.CrudeOilTypeInformationVo; |
||||
|
import com.yxt.supervise.cyf.api.procurementdetails.ProcurementDetails; |
||||
|
import com.yxt.supervise.cyf.api.procurementdetails.ProcurementDetailsDto; |
||||
|
import com.yxt.supervise.cyf.api.procurementdetails.ProcurementDetailsQuery; |
||||
|
import com.yxt.supervise.cyf.api.procurementdetails.ProcurementDetailsVo; |
||||
|
import com.yxt.supervise.cyf.api.sysuser.SysUser; |
||||
|
import com.yxt.supervise.cyf.biz.approvalrecord.ApprovalRecordService; |
||||
|
import com.yxt.supervise.cyf.biz.crudeoilstorage.CrudeOilStorageMapper; |
||||
|
import com.yxt.supervise.cyf.biz.sysuser.CyfSysUserMapper; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author wangpengfei |
||||
|
* @date 2023/5/4 14:37 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class ProcurementDetailsAppService extends MybatisBaseService<ProcurementDetailsAppMapper, ProcurementDetails> { |
||||
|
|
||||
|
@Autowired |
||||
|
CrudeOilStorageMapper crudeOilStorageMapper; |
||||
|
@Autowired |
||||
|
ApprovalRecordService approvalRecordService; |
||||
|
@Autowired |
||||
|
CyfSysUserMapper sysUserMapper; |
||||
|
public PagerVo<ProcurementDetailsVo> listPageVo(PagerQuery<ProcurementDetailsQuery> pq) { |
||||
|
ProcurementDetailsQuery query = pq.getParams(); |
||||
|
QueryWrapper<ProcurementDetails> qw = new QueryWrapper<>(); |
||||
|
// if (StringUtils.isNotBlank(query.getDate())) {
|
||||
|
// qw.eq("STR_TO_DATE(o.deliveryDate,'%Y-%m-%d')", query.getDate());
|
||||
|
// }
|
||||
|
if (StringUtils.isNotBlank(query.getSupplierName())) { |
||||
|
qw.eq("s.supplierNumber", query.getSupplierName()); |
||||
|
} |
||||
|
if (StringUtils.isNotBlank(query.getState())) { |
||||
|
qw.eq("d.state", query.getState()); |
||||
|
} |
||||
|
String type =query.getType(); |
||||
|
IPage<ProcurementDetails> page = PagerUtil.queryToPage(pq); |
||||
|
IPage<ProcurementDetailsVo> pagging = baseMapper.selectPageVo(page, qw,type); |
||||
|
PagerVo<ProcurementDetailsVo> p = PagerUtil.pageToVo(pagging, null); |
||||
|
return p; |
||||
|
} |
||||
|
public List<ProcurementDetailsVo> lists() { |
||||
|
String state="6"; |
||||
|
List<ProcurementDetailsVo> pagging = baseMapper.listByState(state); |
||||
|
return pagging; |
||||
|
} |
||||
|
|
||||
|
public List<ProcurementDetailsVo> listByState(String state) { |
||||
|
List<ProcurementDetailsVo> pagging = baseMapper.listByState(state); |
||||
|
return pagging; |
||||
|
} |
||||
|
|
||||
|
public ResultBean save(ProcurementDetailsDto dto){ |
||||
|
ResultBean rb=new ResultBean(); |
||||
|
Date curDate = new Date(); |
||||
|
String dfmt = DateUtil.format(curDate, "yyyy-MM-dd"); |
||||
|
ProcurementDetails entity=new ProcurementDetails(); |
||||
|
SysUser sysUser=sysUserMapper.selectOne(new QueryWrapper<SysUser>().eq("id",StpUtil.getLoginIdAsString())); |
||||
|
if(null==dto.getSid() || ""==dto.getSid()){ |
||||
|
BeanUtil.copyProperties(dto, entity, "id","sid"); |
||||
|
ApprovalRecordDto recordDto=new ApprovalRecordDto(); |
||||
|
recordDto.setProSid(entity.getSid()); |
||||
|
recordDto.setApprover(sysUser.getSid()); |
||||
|
recordDto.setApprovalOpinions(dto.getApprovalOpinions()==null?"订单创建":dto.getApprovalOpinions()); |
||||
|
recordDto.setOperate("1"); |
||||
|
recordDto.setApprovalDate(dfmt); |
||||
|
approvalRecordService.save(recordDto); |
||||
|
}else{ |
||||
|
BeanUtil.copyProperties(dto, entity, "id"); |
||||
|
} |
||||
|
//多个商品
|
||||
|
if(dto.getCommodityList().size()>1){ |
||||
|
for(CrudeOilTypeInformationDto pro:dto.getCommodityList()){ |
||||
|
entity.setTypeSid(pro.getSid()); |
||||
|
entity.setState(1); |
||||
|
entity.setType("1"); |
||||
|
entity.setWeight(pro.getWeight()); |
||||
|
entity.setPrice(pro.getPrice()); |
||||
|
baseMapper.insert(entity); |
||||
|
} |
||||
|
return rb.success().setMsg("新增成功"); |
||||
|
} |
||||
|
for(CrudeOilTypeInformationDto pro:dto.getCommodityList()){ |
||||
|
entity.setTypeSid(pro.getSid()); |
||||
|
entity.setState(1); |
||||
|
entity.setType("1"); |
||||
|
entity.setWeight(pro.getWeight()); |
||||
|
entity.setPrice(pro.getPrice()); |
||||
|
baseMapper.insert(entity); |
||||
|
} |
||||
|
return rb.success().setMsg("新增成功"); |
||||
|
} |
||||
|
public ResultBean submit(ProcurementDetailsDto dto){ |
||||
|
ResultBean rb=new ResultBean(); |
||||
|
Date curDate = new Date(); |
||||
|
String dfmt = DateUtil.format(curDate, "yyyy-MM-dd"); |
||||
|
String sid =dto.getSid(); |
||||
|
List<ProcurementDetails> procurementDetails=baseMapper.selectList(new QueryWrapper<ProcurementDetails>().eq("sid",sid)); |
||||
|
SysUser sysUser=sysUserMapper.selectOne(new QueryWrapper<SysUser>().eq("id",StpUtil.getLoginIdAsString())); |
||||
|
//不存在保存加提交
|
||||
|
if(sid.equals("")||sid.equals(null)){ |
||||
|
ProcurementDetails entity=new ProcurementDetails(); |
||||
|
BeanUtil.copyProperties(dto, entity, "sid"); |
||||
|
//提交记录
|
||||
|
ApprovalRecordDto recordDto=new ApprovalRecordDto(); |
||||
|
recordDto.setProSid(entity.getSid()); |
||||
|
recordDto.setApprover(sysUser.getSid()); |
||||
|
recordDto.setApprovalOpinions(dto.getApprovalOpinions()==null?"订单创建":dto.getOperate()); |
||||
|
recordDto.setOperate("1"); |
||||
|
recordDto.setApprovalDate(dfmt); |
||||
|
approvalRecordService.save(recordDto); |
||||
|
//发起采购申请记录
|
||||
|
recordDto.setOperate("2"); |
||||
|
recordDto.setApprovalOpinions(dto.getApprovalOpinions()==null?"订单发起":dto.getOperate()); |
||||
|
approvalRecordService.save(recordDto); |
||||
|
if(dto.getCommodityList().size()>1){ |
||||
|
for(CrudeOilTypeInformationDto pro:dto.getCommodityList()){ |
||||
|
entity.setTypeSid(pro.getSid()); |
||||
|
entity.setState(2); |
||||
|
entity.setType("1"); |
||||
|
entity.setWeight(pro.getWeight()); |
||||
|
entity.setPrice(pro.getPrice()); |
||||
|
baseMapper.insert(entity); |
||||
|
} |
||||
|
return rb.success().setMsg("新增成功"); |
||||
|
} |
||||
|
for(CrudeOilTypeInformationDto pro:dto.getCommodityList()){ |
||||
|
entity.setTypeSid(pro.getSid()); |
||||
|
entity.setState(2); |
||||
|
entity.setType("1"); |
||||
|
entity.setWeight(pro.getWeight()); |
||||
|
entity.setPrice(pro.getPrice()); |
||||
|
baseMapper.insert(entity); |
||||
|
} |
||||
|
}else{ |
||||
|
//存在该状态
|
||||
|
List<ProcurementDetails> list =baseMapper.selectList(new QueryWrapper<ProcurementDetails>().eq("sid",sid)); |
||||
|
for(ProcurementDetails pro:list){ |
||||
|
pro.setState(procurementDetails.get(0).getState()+1); |
||||
|
baseMapper.updateById(pro); |
||||
|
} |
||||
|
ApprovalRecordDto recordDto=new ApprovalRecordDto(); |
||||
|
recordDto.setProSid(list.get(0).getSid()); |
||||
|
recordDto.setApprover(sysUser.getSid()); |
||||
|
recordDto.setApprovalOpinions(dto.getApprovalOpinions()==null?"订单发起":dto.getApprovalOpinions()); |
||||
|
recordDto.setOperate(dto.getOperate()==null?"2":dto.getOperate()); |
||||
|
recordDto.setApprovalDate(dfmt); |
||||
|
approvalRecordService.save(recordDto); |
||||
|
} |
||||
|
return rb.success().setMsg("提交成功"); |
||||
|
} |
||||
|
|
||||
|
public ResultBean update (ProcurementDetailsDto dto){ |
||||
|
ResultBean rb=new ResultBean(); |
||||
|
String dtoSid = dto.getSid(); |
||||
|
baseMapper.delete(new QueryWrapper<ProcurementDetails>().eq("sid",dtoSid)); |
||||
|
dto.setSid(dtoSid); |
||||
|
save(dto); |
||||
|
return rb.success().setMsg("修改成功"); |
||||
|
} |
||||
|
public ResultBean updateByState (ProcurementDetailsDto dto){ |
||||
|
ResultBean rb=new ResultBean(); |
||||
|
SysUser sysUser=sysUserMapper.selectOne(new QueryWrapper<SysUser>().eq("id",StpUtil.getLoginIdAsString())); |
||||
|
String dtoSid = dto.getSid(); |
||||
|
ApprovalRecordDto recordDto=new ApprovalRecordDto(); |
||||
|
List<ProcurementDetails> list=baseMapper.selectList(new QueryWrapper<ProcurementDetails>().eq("sid",dtoSid)); |
||||
|
Date curDate = new Date(); |
||||
|
String dfmt = DateUtil.format(curDate, "yyyy-MM-dd"); |
||||
|
if(dto.getOperate().equals("3")){ |
||||
|
//审核通过
|
||||
|
for(ProcurementDetails procurementDetails:list){ |
||||
|
procurementDetails.setPaymentDate(dfmt); |
||||
|
procurementDetails.setPayment(dto.getPayment()==0?0:dto.getPayment()); |
||||
|
procurementDetails.setPayer(dto.getPayer()==null?"":dto.getPayer()); |
||||
|
procurementDetails.setPayerBank(dto.getPayerBank()==null?"":dto.getPayerBank()); |
||||
|
procurementDetails.setPayee(dto.getPayee()==null?"":dto.getPayee()); |
||||
|
procurementDetails.setPayeeBank(dto.getPayeeBank()==null?"":dto.getPayeeBank()); |
||||
|
procurementDetails.setPaymentSummary(dto.getPaymentSummary()==null?"":dto.getPaymentSummary()); |
||||
|
procurementDetails.setState(procurementDetails.getState()+1); |
||||
|
baseMapper.updateById(procurementDetails); |
||||
|
} |
||||
|
recordDto.setOperate(dto.getOperate()); |
||||
|
}else if(dto.getOperate().equals("4")){ |
||||
|
//审核不通过
|
||||
|
for(ProcurementDetails procurementDetails:list){ |
||||
|
procurementDetails.setState(8); |
||||
|
baseMapper.updateById(procurementDetails); |
||||
|
} |
||||
|
recordDto.setOperate(dto.getOperate()); |
||||
|
} |
||||
|
recordDto.setProSid(dtoSid); |
||||
|
recordDto.setApprover(sysUser.getSid()); |
||||
|
recordDto.setApprovalOpinions(dto.getApprovalOpinions()); |
||||
|
recordDto.setApprovalDate(dfmt); |
||||
|
approvalRecordService.save(recordDto); |
||||
|
return rb.success().setMsg("修改成功"); |
||||
|
} |
||||
|
public ResultBean getProcurementBySid(String sid){ |
||||
|
ResultBean rb=new ResultBean(); |
||||
|
List<ProcurementDetailsVo> RawProcurementDetails=baseMapper.getProcurementBySid(sid); |
||||
|
ProcurementDetailsVo procurementDetailsVo=baseMapper.getProBySid(sid); |
||||
|
List<CrudeOilTypeInformationVo> list =new ArrayList<>(); |
||||
|
for (ProcurementDetailsVo pro:RawProcurementDetails){ |
||||
|
CrudeOilTypeInformationVo crudeOilTypeInformationVo=baseMapper.getCrudeBySid(pro.getTypeSid()); |
||||
|
crudeOilTypeInformationVo.setWeight(pro.getWeight()); |
||||
|
crudeOilTypeInformationVo.setPrice(pro.getPrice()); |
||||
|
list.add(crudeOilTypeInformationVo); |
||||
|
} |
||||
|
procurementDetailsVo.setCommodityList(list); |
||||
|
return rb.success().setData(procurementDetailsVo); |
||||
|
} |
||||
|
public ResultBean del(String sid){ |
||||
|
ResultBean rb=new ResultBean(); |
||||
|
baseMapper.delete(new QueryWrapper<ProcurementDetails>().eq("sid",sid)); |
||||
|
return rb.success().setMsg("删除成功"); |
||||
|
} |
||||
|
public ResultBean getProcByState(String state){ |
||||
|
ResultBean rb=new ResultBean(); |
||||
|
List<ProcurementDetailsVo>list=baseMapper.getProByState(state); |
||||
|
for(ProcurementDetailsVo procurementDetailsVo:list){ |
||||
|
List<ProcurementDetails>details=baseMapper.selectList(new QueryWrapper<ProcurementDetails>().eq("sid",procurementDetailsVo.getSid())); |
||||
|
double i=0; |
||||
|
for(ProcurementDetails procurementDetails:details){ |
||||
|
i=i+(procurementDetails.getWeight()*procurementDetails.getPrice()); |
||||
|
} |
||||
|
procurementDetailsVo.setTotalValue(i); |
||||
|
list.add(procurementDetailsVo); |
||||
|
//入库数量
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
return rb.success().setData(list); |
||||
|
} |
||||
|
|
||||
|
} |
Loading…
Reference in new issue